# Correct the needed linklibs in curl-config also.
[AROS-Contrib.git] / Games / Quake / net_vcr.c
blobba8f40dcc1c95a48af44b5c9b7d88dbfe0cdb3ba
1 /*
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.
20 // net_vcr.c
22 #include "quakedef.h"
23 #include "net_vcr.h"
25 extern int vcrFile;
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.
32 static struct
34 double time;
35 int op;
36 long session;
37 } next;
39 int VCR_Init (void)
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));
53 return 0;
56 void VCR_ReadNext (void)
58 if (Sys_FileRead(vcrFile, &next, sizeof(next)) == 0)
60 next.op = 255;
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)
80 int ret;
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));
86 if (ret != 1)
88 VCR_ReadNext ();
89 return ret;
92 Sys_FileRead(vcrFile, &net_message.cursize, sizeof(int));
93 Sys_FileRead(vcrFile, net_message.data, net_message.cursize);
95 VCR_ReadNext ();
97 return 1;
101 int VCR_SendMessage (qsocket_t *sock, sizebuf_t *data)
103 int ret;
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));
110 VCR_ReadNext ();
112 return ret;
116 qboolean VCR_CanSendMessage (qsocket_t *sock)
118 qboolean ret;
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));
125 VCR_ReadNext ();
127 return ret;
131 void VCR_Close (qsocket_t *sock)
136 void VCR_SearchForHosts (qboolean xmit)
141 qsocket_t *VCR_Connect (char *host)
143 return NULL;
147 qsocket_t *VCR_CheckNewConnections (void)
149 qsocket_t *sock;
151 if (host_time != next.time || next.op != VCR_OP_CONNECT)
152 Sys_Error ("VCR missmatch");
154 if (!next.session)
156 VCR_ReadNext ();
157 return NULL;
160 sock = NET_NewQSocket ();
161 *(long *)(&sock->driverdata) = next.session;
163 Sys_FileRead (vcrFile, sock->address, NET_NAMELEN);
164 VCR_ReadNext ();
166 return sock;