24 #include "server/mvd/protocol.h"
36 memset(
cls.gtv.entities, 0,
sizeof(
cls.gtv.entities));
42 for (i = 1; i < MAX_EDICTS; i++) {
62 MSG_WriteByte(mvd_serverdata | (MVF_SINGLEPOV << SVCMD_BITS));
70 for (i = 0; i < MAX_CONFIGSTRINGS; i++) {
75 length = strlen(
string);
76 if (length > MAX_QPATH) {
81 MSG_WriteData(
string, length);
90 MSG_WriteDeltaPlayerstate_Packet(NULL, &
cls.gtv.ps,
95 for (i = 1, es =
cls.gtv.entities + 1; i < MAX_EDICTS; i++, es++) {
97 if ((j = es->number) == 0) {
98 flags |= MSG_ES_REMOVE;
109 player_packed_t newps;
110 entity_packed_t *oldes, newes;
131 MSG_WriteDeltaPlayerstate_Packet(&
cls.gtv.ps, &newps,
140 for (i = 1; i < MAX_EDICTS; i++) {
141 oldes = &
cls.gtv.entities[i];
154 flags = MSG_ES_UMASK;
156 if (!oldes->number) {
158 flags |= MSG_ES_FORCE | MSG_ES_NEWENTITY;
179 Com_Printf(
"MVD client [%s] dropped: %s\n",
209 header[0] = len & 255;
210 header[1] = (len >> 8) & 255;
231 case svc_configstring:
233 SZ_Write(&
cls.gtv.message, data + 1, len - 1);
237 SZ_Write(&
cls.gtv.message, data + 1, len - 1);
241 bits = ((len >> 8) & 7) << SVCMD_BITS;
245 SZ_Write(&
cls.gtv.message, data, len);
248 bits = ((len >> 8) & 7) << SVCMD_BITS;
251 SZ_Write(&
cls.gtv.message, data, len);
292 if (
cls.gtv.message.overflowed) {
293 Com_WPrintf(
"MVD message overflowed.\n");
297 if (!
cls.gtv.message.cursize)
301 total =
cls.gtv.message.cursize + 1;
302 header[0] = total & 255;
303 header[1] = (total >> 8) & 255;
304 header[2] = GTS_STREAM_DATA;
326 if (protocol != GTV_PROTOCOL_VERSION) {
339 if (!NET_IsLanAddress(&
cls.gtv.stream.address)) {
352 Com_Printf(
"Accepted MVD client [%s]\n",
421 if (!FIFO_TryRead(&
cls.gtv.stream.recv, &magic, 4)) {
424 if (magic != MVD_MAGIC) {
436 if (!
cls.gtv.msglen) {
437 if (!FIFO_TryRead(&
cls.gtv.stream.recv, &msglen, 2)) {
440 msglen = LittleShort(msglen);
445 if (msglen > MAX_GTC_MSGLEN) {
449 cls.gtv.msglen = msglen;
467 case GTC_STREAM_START:
470 case GTC_STREAM_STOP:
500 Com_DPrintf(
"TCP client [%s] accepted\n",
534 Com_Printf(
"Client GTV already started.\n");
540 Com_Printf(
"Listening for GTV connections.\n");
542 }
else if (ret == NET_ERROR) {
545 Com_EPrintf(
"Client TCP port already in use.\n");
552 Com_Printf(
"Client GTV already stopped.\n");
561 memset(&
cls.gtv, 0,
sizeof(
cls.gtv));
567 Com_Printf(
"Client GTV not running.\n");
572 Com_Printf(
"Listening for GTV connections.\n");
576 Com_Printf(
"TCP client [%s] connected (state %d)\n",