Ensure MS packets are sent correctly

This commit is contained in:
TehRealSalt 2018-11-16 12:01:57 -05:00
parent 692ea23a42
commit cb8bbf8e4c
4 changed files with 23 additions and 20 deletions

View file

@ -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);
}

View file

@ -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];

View file

@ -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.

View file

@ -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,