mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-23 04:11:53 +00:00
Removed vcr code, made portable.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@630 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
2eb8db11d0
commit
cc879e5152
3 changed files with 2 additions and 256 deletions
|
@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "../client/quakedef.h"
|
||||
#ifdef NQPROT
|
||||
#include "net_vcr.h"
|
||||
|
||||
|
||||
#define Sys_FloatTime Sys_DoubleTime
|
||||
|
@ -91,9 +90,6 @@ cvar_t config_modem_hangup = {"_config_modem_hangup", "AT H", CVAR_ARCHIVE};
|
|||
cvar_t idgods = {"idgods", "0"};
|
||||
#endif
|
||||
|
||||
int vcrFile = -1;
|
||||
qboolean recording = false;
|
||||
|
||||
// these two macros are to make the code more readable
|
||||
#define sfunc net_drivers[sock->driver]
|
||||
#define dfunc net_drivers[net_driverlevel]
|
||||
|
@ -451,13 +447,6 @@ NET_CheckNewConnections
|
|||
===================
|
||||
*/
|
||||
|
||||
struct
|
||||
{
|
||||
double time;
|
||||
int op;
|
||||
long session;
|
||||
} vcrConnect;
|
||||
|
||||
qsocket_t *NET_CheckNewConnections (void)
|
||||
{
|
||||
#ifndef CLIENTONLY
|
||||
|
@ -474,25 +463,9 @@ qsocket_t *NET_CheckNewConnections (void)
|
|||
ret = dfunc.CheckNewConnections ();
|
||||
if (ret)
|
||||
{
|
||||
if (recording)
|
||||
{
|
||||
vcrConnect.time = sv.time;
|
||||
vcrConnect.op = VCR_OP_CONNECT;
|
||||
vcrConnect.session = (long)ret;
|
||||
Sys_FileWrite (vcrFile, &vcrConnect, sizeof(vcrConnect));
|
||||
Sys_FileWrite (vcrFile, ret->address, NET_NAMELEN);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (recording)
|
||||
{
|
||||
vcrConnect.time = sv.time;
|
||||
vcrConnect.op = VCR_OP_CONNECT;
|
||||
vcrConnect.session = 0;
|
||||
Sys_FileWrite (vcrFile, &vcrConnect, sizeof(vcrConnect));
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
@ -531,15 +504,6 @@ returns -1 if connection is invalid
|
|||
=================
|
||||
*/
|
||||
|
||||
struct
|
||||
{
|
||||
double time;
|
||||
int op;
|
||||
long session;
|
||||
int ret;
|
||||
int len;
|
||||
} vcrGetMessage;
|
||||
|
||||
extern void PrintStats(qsocket_t *s);
|
||||
|
||||
int NET_GetMessage (qsocket_t *sock)
|
||||
|
@ -580,28 +544,6 @@ int NET_GetMessage (qsocket_t *sock)
|
|||
else if (ret == 2)
|
||||
unreliableMessagesReceived++;
|
||||
}
|
||||
|
||||
if (recording)
|
||||
{
|
||||
vcrGetMessage.time = realtime;
|
||||
vcrGetMessage.op = VCR_OP_GETMESSAGE;
|
||||
vcrGetMessage.session = (long)sock;
|
||||
vcrGetMessage.ret = ret;
|
||||
vcrGetMessage.len = net_message.cursize;
|
||||
Sys_FileWrite (vcrFile, &vcrGetMessage, 24);
|
||||
Sys_FileWrite (vcrFile, net_message.data, net_message.cursize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (recording)
|
||||
{
|
||||
vcrGetMessage.time = realtime;
|
||||
vcrGetMessage.op = VCR_OP_GETMESSAGE;
|
||||
vcrGetMessage.session = (long)sock;
|
||||
vcrGetMessage.ret = ret;
|
||||
Sys_FileWrite (vcrFile, &vcrGetMessage, 20);
|
||||
}
|
||||
}
|
||||
|
||||
*(int *)net_from.ip = 0;
|
||||
|
@ -621,13 +563,6 @@ returns 1 if the message was sent properly
|
|||
returns -1 if the connection died
|
||||
==================
|
||||
*/
|
||||
struct
|
||||
{
|
||||
double time;
|
||||
int op;
|
||||
long session;
|
||||
int r;
|
||||
} vcrSendMessage;
|
||||
|
||||
int NET_SendMessage (qsocket_t *sock, sizebuf_t *data)
|
||||
{
|
||||
|
@ -646,15 +581,6 @@ int NET_SendMessage (qsocket_t *sock, sizebuf_t *data)
|
|||
r = sfunc.QSendMessage(sock, data);
|
||||
if (r == 1 && sock->driver)
|
||||
messagesSent++;
|
||||
|
||||
if (recording)
|
||||
{
|
||||
vcrSendMessage.time = realtime;
|
||||
vcrSendMessage.op = VCR_OP_SENDMESSAGE;
|
||||
vcrSendMessage.session = (long)sock;
|
||||
vcrSendMessage.r = r;
|
||||
Sys_FileWrite (vcrFile, &vcrSendMessage, 20);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -677,15 +603,6 @@ int NET_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data)
|
|||
r = sfunc.SendUnreliableMessage(sock, data);
|
||||
if (r == 1 && sock->driver)
|
||||
unreliableMessagesSent++;
|
||||
|
||||
if (recording)
|
||||
{
|
||||
vcrSendMessage.time = realtime;
|
||||
vcrSendMessage.op = VCR_OP_SENDMESSAGE;
|
||||
vcrSendMessage.session = (long)sock;
|
||||
vcrSendMessage.r = r;
|
||||
Sys_FileWrite (vcrFile, &vcrSendMessage, 20);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -713,15 +630,6 @@ qboolean NET_CanSendMessage (qsocket_t *sock)
|
|||
|
||||
r = sfunc.CanSendMessage(sock);
|
||||
|
||||
if (recording)
|
||||
{
|
||||
vcrSendMessage.time = realtime;
|
||||
vcrSendMessage.op = VCR_OP_CANSENDMESSAGE;
|
||||
vcrSendMessage.session = (long)sock;
|
||||
vcrSendMessage.r = r;
|
||||
Sys_FileWrite (vcrFile, &vcrSendMessage, 20);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -818,15 +726,6 @@ void NQ_NET_Init (void)
|
|||
int controlSocket;
|
||||
qsocket_t *s;
|
||||
|
||||
if (COM_CheckParm("-playback"))
|
||||
{
|
||||
net_numdrivers = 1;
|
||||
net_drivers[0].Init = VCR_Init;
|
||||
}
|
||||
|
||||
if (COM_CheckParm("-record"))
|
||||
recording = true;
|
||||
|
||||
i = COM_CheckParm ("-nqport");
|
||||
if (!i)
|
||||
i = COM_CheckParm ("-udpport");
|
||||
|
@ -936,12 +835,6 @@ void NQ_NET_Shutdown (void)
|
|||
net_drivers[net_driverlevel].initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (vcrFile != -1)
|
||||
{
|
||||
Con_Printf ("Closing vcrfile.\n");
|
||||
Sys_FileClose(vcrFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,151 +20,3 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// net_vcr.c
|
||||
|
||||
#include "../client/quakedef.h"
|
||||
#ifdef NQPROT
|
||||
#include "net_vcr.h"
|
||||
|
||||
extern int vcrFile;
|
||||
|
||||
// This is the playback portion of the VCR. It reads the file produced
|
||||
// by the recorder and plays it back to the host. The recording contains
|
||||
// everything necessary (events, timestamps, and data) to duplicate the game
|
||||
// from the viewpoint of everything above the network layer.
|
||||
|
||||
static struct
|
||||
{
|
||||
double time;
|
||||
int op;
|
||||
long session;
|
||||
} next;
|
||||
|
||||
int VCR_Init (void)
|
||||
{
|
||||
net_drivers[0].Init = VCR_Init;
|
||||
|
||||
net_drivers[0].SearchForHosts = VCR_SearchForHosts;
|
||||
net_drivers[0].Connect = VCR_Connect;
|
||||
net_drivers[0].CheckNewConnections = VCR_CheckNewConnections;
|
||||
net_drivers[0].QGetMessage = VCR_GetMessage;
|
||||
net_drivers[0].QSendMessage = VCR_SendMessage;
|
||||
net_drivers[0].CanSendMessage = VCR_CanSendMessage;
|
||||
net_drivers[0].Close = VCR_Close;
|
||||
net_drivers[0].Shutdown = VCR_Shutdown;
|
||||
|
||||
Sys_FileRead(vcrFile, &next, sizeof(next));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void VCR_ReadNext (void)
|
||||
{
|
||||
if (Sys_FileRead(vcrFile, &next, sizeof(next)) == 0)
|
||||
{
|
||||
next.op = 255;
|
||||
Sys_Error ("=== END OF PLAYBACK===\n");
|
||||
}
|
||||
if (next.op < 1 || next.op > VCR_MAX_MESSAGE)
|
||||
Sys_Error ("VCR_ReadNext: bad op");
|
||||
}
|
||||
|
||||
|
||||
void VCR_Listen (qboolean state)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void VCR_Shutdown (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int VCR_GetMessage (qsocket_t *sock)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (realtime != next.time || next.op != VCR_OP_GETMESSAGE || next.session != *(long *)(&sock->driverdata))
|
||||
Sys_Error ("VCR missmatch");
|
||||
|
||||
Sys_FileRead(vcrFile, &ret, sizeof(int));
|
||||
if (ret != 1)
|
||||
{
|
||||
VCR_ReadNext ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
Sys_FileRead(vcrFile, &net_message.cursize, sizeof(int));
|
||||
Sys_FileRead(vcrFile, net_message.data, net_message.cursize);
|
||||
|
||||
VCR_ReadNext ();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int VCR_SendMessage (qsocket_t *sock, sizebuf_t *data)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (realtime != next.time || next.op != VCR_OP_SENDMESSAGE || next.session != *(long *)(&sock->driverdata))
|
||||
Sys_Error ("VCR missmatch");
|
||||
|
||||
Sys_FileRead(vcrFile, &ret, sizeof(int));
|
||||
|
||||
VCR_ReadNext ();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
qboolean VCR_CanSendMessage (qsocket_t *sock)
|
||||
{
|
||||
qboolean ret;
|
||||
|
||||
if (realtime != next.time || next.op != VCR_OP_CANSENDMESSAGE || next.session != *(long *)(&sock->driverdata))
|
||||
Sys_Error ("VCR missmatch");
|
||||
|
||||
Sys_FileRead(vcrFile, &ret, sizeof(int));
|
||||
|
||||
VCR_ReadNext ();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void VCR_Close (qsocket_t *sock)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void VCR_SearchForHosts (qboolean xmit)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
qsocket_t *VCR_Connect (char *host)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
qsocket_t *VCR_CheckNewConnections (void)
|
||||
{
|
||||
qsocket_t *sock;
|
||||
|
||||
if (realtime != next.time || next.op != VCR_OP_CONNECT)
|
||||
Sys_Error ("VCR missmatch");
|
||||
|
||||
if (!next.session)
|
||||
{
|
||||
VCR_ReadNext ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sock = NET_NewQSocket ();
|
||||
*(long *)(&sock->driverdata) = next.session;
|
||||
|
||||
Sys_FileRead (vcrFile, sock->address, NET_NAMELEN);
|
||||
VCR_ReadNext ();
|
||||
|
||||
return sock;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
// net_wipx.c
|
||||
|
||||
#include "quakedef.h"
|
||||
#ifdef _WIN32
|
||||
#ifdef NQPROT
|
||||
#include "../client/winquake.h"
|
||||
#include <wsipx.h>
|
||||
|
@ -438,4 +439,4 @@ int WIPX_SetSocketPort (struct sockaddr_qstorage *addr, int port)
|
|||
|
||||
//=============================================================================
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue