2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 // This is the playback portion of the VCR. It reads the file produced
28 // by the recorder and plays it back to the host. The recording contains
29 // everything necessary (events, timestamps, and data) to duplicate the game
30 // from the viewpoint of everything above the network layer.
41 net_drivers[0].Init = VCR_Init;
43 net_drivers[0].SearchForHosts = VCR_SearchForHosts;
44 net_drivers[0].Connect = VCR_Connect;
45 net_drivers[0].CheckNewConnections = VCR_CheckNewConnections;
46 net_drivers[0].QGetMessage = VCR_GetMessage;
47 net_drivers[0].QSendMessage = VCR_SendMessage;
48 net_drivers[0].CanSendMessage = VCR_CanSendMessage;
49 net_drivers[0].Close = VCR_Close;
50 net_drivers[0].Shutdown = VCR_Shutdown;
52 Sys_FileRead(vcrFile, &next, sizeof(next));
56 void VCR_ReadNext (void)
58 if (Sys_FileRead(vcrFile, &next, sizeof(next)) == 0)
61 Sys_Error ("=== END OF PLAYBACK===\n");
63 if (next.op < 1 || next.op > VCR_MAX_MESSAGE)
64 Sys_Error ("VCR_ReadNext: bad op");
68 void VCR_Listen (qboolean state)
73 void VCR_Shutdown (void)
78 int VCR_GetMessage (qsocket_t *sock)
82 if (host_time != next.time || next.op != VCR_OP_GETMESSAGE || next.session != *(long *)(&sock->driverdata))
83 Sys_Error ("VCR missmatch");
85 Sys_FileRead(vcrFile, &ret, sizeof(int));
92 Sys_FileRead(vcrFile, &net_message.cursize, sizeof(int));
93 Sys_FileRead(vcrFile, net_message.data, net_message.cursize);
101 int VCR_SendMessage (qsocket_t *sock, sizebuf_t *data)
105 if (host_time != next.time || next.op != VCR_OP_SENDMESSAGE || next.session != *(long *)(&sock->driverdata))
106 Sys_Error ("VCR missmatch");
108 Sys_FileRead(vcrFile, &ret, sizeof(int));
116 qboolean VCR_CanSendMessage (qsocket_t *sock)
120 if (host_time != next.time || next.op != VCR_OP_CANSENDMESSAGE || next.session != *(long *)(&sock->driverdata))
121 Sys_Error ("VCR missmatch");
123 Sys_FileRead(vcrFile, &ret, sizeof(int));
131 void VCR_Close (qsocket_t *sock)
136 void VCR_SearchForHosts (qboolean xmit)
141 qsocket_t *VCR_Connect (char *host)
147 qsocket_t *VCR_CheckNewConnections (void)
151 if (host_time != next.time || next.op != VCR_OP_CONNECT)
152 Sys_Error ("VCR missmatch");
160 sock = NET_NewQSocket ();
161 *(long *)(&sock->driverdata) = next.session;
163 Sys_FileRead (vcrFile, sock->address, NET_NAMELEN);