From cb8bbf8e4c89a76d18cf74eadffd748dd688adf4 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Fri, 16 Nov 2018 12:01:57 -0500 Subject: [PATCH] Ensure MS packets are sent correctly --- src/d_clisrv.c | 23 ++++++++++++++--------- src/d_clisrv.h | 13 ++++++++----- src/dehacked.c | 6 ------ src/doomstat.h | 1 + 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e40a8014..a717273e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1305,7 +1305,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers(); netbuffer->u.serverinfo.maxplayer = (UINT8)cv_maxplayers.value; - netbuffer->u.serverinfo.gametype = (UINT8)gametype; + netbuffer->u.serverinfo.gametype = (UINT8)(G_BattleGametype() ? 3 : 2); // SRB2Kart: Vanilla's gametype constants for MS support netbuffer->u.serverinfo.modifiedgame = (UINT8)modifiedgame; netbuffer->u.serverinfo.cheatsenabled = CV_CheatsEnabled(); netbuffer->u.serverinfo.isdedicated = (UINT8)dedicated; @@ -1395,7 +1395,8 @@ static void SV_SendPlayerInfo(INT32 node) netbuffer->u.playerinfo[i].skin = (UINT8)players[i].skin; // Extra data - netbuffer->u.playerinfo[i].data = players[i].skincolor; + // Kart has extra skincolors, so we can't use this + netbuffer->u.playerinfo[i].data = 0; //netbuffer->u.playerinfo[i].data = players[i].skincolor; if (players[i].pflags & PF_TAGIT) netbuffer->u.playerinfo[i].data |= 0x20; @@ -1444,10 +1445,9 @@ static boolean SV_SendServerConfig(INT32 node) for (i = 0; i < MAXPLAYERS; i++) { - netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; - if (!playeringame[i]) continue; + netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; } @@ -4510,18 +4510,23 @@ static INT16 Consistancy(void) static void CL_SendClientCmd(void) { size_t packetsize = 0; + boolean mis = false; netbuffer->packettype = PT_CLIENTCMD; if (cl_packetmissed) - netbuffer->packettype++; + { + netbuffer->packettype = PT_CLIENTMIS; + mis = true; + } + netbuffer->u.clientpak.resendfrom = (UINT8)(neededtic & UINT8_MAX); netbuffer->u.clientpak.client_tic = (UINT8)(gametic & UINT8_MAX); if (gamestate == GS_WAITINGPLAYERS) { // Send PT_NODEKEEPALIVE packet - netbuffer->packettype += 8; + netbuffer->packettype = (mis ? PT_NODEKEEPALIVEMIS : PT_NODEKEEPALIVE); packetsize = sizeof (clientcmd_pak) - sizeof (ticcmd_t) - sizeof (INT16); HSendPacket(servernode, false, 0, packetsize); } @@ -4532,15 +4537,15 @@ static void CL_SendClientCmd(void) if (splitscreen || botingame) // Send a special packet with 2 cmd for splitscreen { - netbuffer->packettype += 2; + netbuffer->packettype = (mis ? PT_CLIENT2MIS : PT_CLIENT2CMD); G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds2, 1); if (splitscreen > 1) { - netbuffer->packettype += 2; + netbuffer->packettype = (mis ? PT_CLIENT3MIS : PT_CLIENT3CMD); G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds3, 1); if (splitscreen > 2) { - netbuffer->packettype += 2; + netbuffer->packettype = (mis ? PT_CLIENT4MIS : PT_CLIENT4CMD); G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds4, 1); packetsize = sizeof (client4cmd_pak); } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index cee64a78..19c18665 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -40,10 +40,6 @@ typedef enum PT_CLIENTMIS, // Same as above with but saying resend from. PT_CLIENT2CMD, // 2 cmds in the packet for splitscreen. PT_CLIENT2MIS, // Same as above with but saying resend from - PT_CLIENT3CMD, // 3P - PT_CLIENT3MIS, - PT_CLIENT4CMD, // 4P - PT_CLIENT4MIS, PT_NODEKEEPALIVE, // Same but without ticcmd and consistancy PT_NODEKEEPALIVEMIS, PT_SERVERTICS, // All cmds for the tic. @@ -79,6 +75,13 @@ typedef enum #ifdef NEWPING PT_PING, // Packet sent to tell clients the other client's latency to server. #endif + + // Kart-specific packets + PT_CLIENT3CMD, // 3P + PT_CLIENT3MIS, + PT_CLIENT4CMD, // 4P + PT_CLIENT4MIS, + NUMPACKETTYPE } packettype_t; @@ -358,7 +361,7 @@ typedef struct UINT8 cheatsenabled; UINT8 isdedicated; UINT8 fileneedednum; - SINT8 adminplayers[MAXPLAYERS]; + SINT8 adminplayer; tic_t time; tic_t leveltime; char servername[MAXSERVERNAME]; diff --git a/src/dehacked.c b/src/dehacked.c index 1a7a1357..2b89db03 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8551,14 +8551,8 @@ struct { {"PAL_NUKE",PAL_NUKE}, // Gametypes, for use with global var "gametype" - {"GT_COOP",GT_COOP}, - {"GT_COMPETITION",GT_COMPETITION}, {"GT_RACE",GT_RACE}, {"GT_MATCH",GT_MATCH}, - {"GT_TEAMMATCH",GT_TEAMMATCH}, - {"GT_TAG",GT_TAG}, - {"GT_HIDEANDSEEK",GT_HIDEANDSEEK}, - {"GT_CTF",GT_CTF}, // Player state (playerstate_t) {"PST_LIVE",PST_LIVE}, // Playing or camping. diff --git a/src/doomstat.h b/src/doomstat.h index 80e1e9b0..0eeae310 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -313,6 +313,7 @@ enum GameType // SRB2Kart GT_MATCH, // battle, but renaming would be silly NUMGAMETYPES, + // TODO: This is *horrid*. Remove this hack ASAP. // the following have been left in on account of just not wanting to deal with removing all the checks for them GT_COOP, GT_COMPETITION,