Merge branch 'network' into 'master'

Net work

See merge request KartKrew/Kart!557
This commit is contained in:
toaster 2022-03-17 16:50:40 +00:00
commit 306d1cd3ae
15 changed files with 114 additions and 249 deletions

View file

@ -1621,7 +1621,7 @@ static void Got_NetVar(UINT8 **p, INT32 playernum)
// not from server or remote admin, must be hacked/buggy client // not from server or remote admin, must be hacked/buggy client
CONS_Alert(CONS_WARNING, M_GetText("Illegal netvar command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal netvar command received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }

View file

@ -93,7 +93,6 @@ UINT8 playerconsole[MAXPLAYERS];
// Server specific vars // Server specific vars
UINT8 playernode[MAXPLAYERS]; UINT8 playernode[MAXPLAYERS];
char playeraddress[MAXPLAYERS][64];
// Minimum timeout for sending the savegame // Minimum timeout for sending the savegame
// The actual timeout will be longer depending on the savegame length // The actual timeout will be longer depending on the savegame length
@ -129,7 +128,7 @@ static tic_t firstticstosend; // min of the nettics
static tic_t tictoclear = 0; // optimize d_clearticcmd static tic_t tictoclear = 0; // optimize d_clearticcmd
static tic_t maketic; static tic_t maketic;
static INT16 consistancy[TICQUEUE]; static INT16 consistancy[BACKUPTICS];
static UINT8 player_joining = false; static UINT8 player_joining = false;
UINT8 hu_redownloadinggamestate = 0; UINT8 hu_redownloadinggamestate = 0;
@ -177,7 +176,7 @@ typedef struct textcmdtic_s
struct textcmdtic_s *next; struct textcmdtic_s *next;
} textcmdtic_t; } textcmdtic_t;
ticcmd_t netcmds[TICQUEUE][MAXPLAYERS]; ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS];
static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL}; static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL};
@ -409,7 +408,7 @@ static void ExtraDataTicker(void)
{ {
if (server) if (server)
{ {
SendKick(i, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(i, KICK_MSG_CON_FAIL);
DEBFILE(va("player %d kicked [gametic=%u] reason as follows:\n", i, gametic)); DEBFILE(va("player %d kicked [gametic=%u] reason as follows:\n", i, gametic));
} }
CONS_Alert(CONS_WARNING, M_GetText("Got unknown net command [%s]=%d (max %d)\n"), sizeu1(curpos - bufferstart), *curpos, bufferstart[0]); CONS_Alert(CONS_WARNING, M_GetText("Got unknown net command [%s]=%d (max %d)\n"), sizeu1(curpos - bufferstart), *curpos, bufferstart[0]);
@ -433,9 +432,9 @@ static void D_Clearticcmd(tic_t tic)
D_FreeTextcmd(tic); D_FreeTextcmd(tic);
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
netcmds[tic%TICQUEUE][i].flags = 0; netcmds[tic%BACKUPTICS][i].flags = 0;
DEBFILE(va("clear tic %5u (%2u)\n", tic, tic%TICQUEUE)); DEBFILE(va("clear tic %5u (%2u)\n", tic, tic%BACKUPTICS));
} }
void D_ResetTiccmds(void) void D_ResetTiccmds(void)
@ -460,9 +459,6 @@ void SendKick(UINT8 playernum, UINT8 msg)
{ {
UINT8 buf[2]; UINT8 buf[2];
if (!(server && cv_rejointimeout.value))
msg &= ~KICK_MSG_KEEP_BODY;
buf[0] = playernum; buf[0] = playernum;
buf[1] = msg; buf[1] = msg;
SendNetXCmd(XD_KICK, &buf, 2); SendNetXCmd(XD_KICK, &buf, 2);
@ -807,37 +803,6 @@ static boolean CL_SendJoin(void)
return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak)); return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak));
} }
static INT32 FindRejoinerNum(SINT8 node)
{
char strippednodeaddress[64];
const char *nodeaddress;
char *port;
INT32 i;
// Make sure there is no dead dress before proceeding to the stripping
if (!I_GetNodeAddress)
return -1;
nodeaddress = I_GetNodeAddress(node);
if (!nodeaddress)
return -1;
// Strip the address of its port
strcpy(strippednodeaddress, nodeaddress);
port = strchr(strippednodeaddress, ':');
if (port)
*port = '\0';
// Check if any player matches the stripped address
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && playeraddress[i][0] && playernode[i] == UINT8_MAX
&& !strcmp(playeraddress[i], strippednodeaddress))
return i;
}
return -1;
}
static void static void
CopyCaretColors (char *p, const char *s, int n) CopyCaretColors (char *p, const char *s, int n)
{ {
@ -922,7 +887,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers(); netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers();
netbuffer->u.serverinfo.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); netbuffer->u.serverinfo.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value));
if (!node || FindRejoinerNum(node) != -1) if (!node)
netbuffer->u.serverinfo.refusereason = 0; netbuffer->u.serverinfo.refusereason = 0;
else if (!cv_allownewplayer.value) else if (!cv_allownewplayer.value)
netbuffer->u.serverinfo.refusereason = 1; netbuffer->u.serverinfo.refusereason = 1;
@ -1313,11 +1278,6 @@ static void CL_LoadReceivedSavegame(boolean reloading)
else else
{ {
CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n"));
Z_Free(savebuffer);
save_p = NULL;
if (unlink(tmpsave) == -1)
CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave);
return;
} }
// done // done
@ -1325,7 +1285,7 @@ static void CL_LoadReceivedSavegame(boolean reloading)
save_p = NULL; save_p = NULL;
if (unlink(tmpsave) == -1) if (unlink(tmpsave) == -1)
CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave);
consistancy[gametic%TICQUEUE] = Consistancy(); consistancy[gametic%BACKUPTICS] = Consistancy();
CON_ToggleOff(); CON_ToggleOff();
// Tell the server we have received and reloaded the gamestate // Tell the server we have received and reloaded the gamestate
@ -1929,13 +1889,16 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
if (*oldtic != I_GetTime()) if (*oldtic != I_GetTime())
{ {
I_OsPolling(); I_OsPolling();
#if 0
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
G_MapEventsToControls(&events[eventtail]);
#endif
if (cl_mode == CL_CONFIRMCONNECT) if (cl_mode == CL_CONFIRMCONNECT)
{
D_ProcessEvents(); //needed for menu system to receive inputs D_ProcessEvents(); //needed for menu system to receive inputs
}
else
{
for (; eventtail != eventhead; eventtail = (eventtail+1) & (MAXEVENTS-1))
G_MapEventsToControls(&events[eventtail]);
}
if ((gamekeydown[KEY_ESCAPE] || gamekeydown[KEY_JOY1+1]) || cl_mode == CL_ABORTED) if ((gamekeydown[KEY_ESCAPE] || gamekeydown[KEY_JOY1+1]) || cl_mode == CL_ABORTED)
{ {
@ -2356,7 +2319,6 @@ void CL_ClearPlayer(INT32 playernum)
splitscreen_original_party_size[playernum] = 0; splitscreen_original_party_size[playernum] = 0;
memset(&players[playernum], 0, sizeof (player_t)); memset(&players[playernum], 0, sizeof (player_t));
memset(playeraddress[playernum], 0, sizeof(*playeraddress));
} }
// //
@ -2732,12 +2694,9 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
char buf[3 + MAX_REASONLENGTH]; char buf[3 + MAX_REASONLENGTH];
char *reason = buf; char *reason = buf;
kickreason_t kickreason = KR_KICK; kickreason_t kickreason = KR_KICK;
boolean keepbody;
pnum = READUINT8(*p); pnum = READUINT8(*p);
msg = READUINT8(*p); msg = READUINT8(*p);
keepbody = (msg & KICK_MSG_KEEP_BODY) != 0;
msg &= ~KICK_MSG_KEEP_BODY;
if (pnum == serverplayer && IsPlayerAdmin(playernum)) if (pnum == serverplayer && IsPlayerAdmin(playernum))
{ {
@ -2791,7 +2750,6 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
*/ */
pnum = playernum; pnum = playernum;
msg = KICK_MSG_CON_FAIL; msg = KICK_MSG_CON_FAIL;
keepbody = true;
} }
//CONS_Printf("\x82%s ", player_names[pnum]); //CONS_Printf("\x82%s ", player_names[pnum]);
@ -2816,8 +2774,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
switch (msg) switch (msg)
{ {
case KICK_MSG_GO_AWAY: case KICK_MSG_GO_AWAY:
if (!players[pnum].quittime) HU_AddChatText(va("\x82*%s has been kicked (Go away)", player_names[pnum]), false);
HU_AddChatText(va("\x82*%s has been kicked (Go away)", player_names[pnum]), false);
kickreason = KR_KICK; kickreason = KR_KICK;
break; break;
case KICK_MSG_PING_HIGH: case KICK_MSG_PING_HIGH:
@ -2866,7 +2823,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
kickreason = KR_TIMEOUT; kickreason = KR_TIMEOUT;
break; break;
case KICK_MSG_PLAYER_QUIT: case KICK_MSG_PLAYER_QUIT:
if (netgame && !players[pnum].quittime) // not splitscreen/bots or soulless body if (netgame) // not splitscreen/bots
HU_AddChatText(va("\x82*%s left the game", player_names[pnum]), false); HU_AddChatText(va("\x82*%s left the game", player_names[pnum]), false);
kickreason = KR_LEAVE; kickreason = KR_LEAVE;
break; break;
@ -2923,24 +2880,6 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
else else
M_StartMessage(M_GetText("You have been kicked by the server\n\nPress ESC\n"), NULL, MM_NOTHING); M_StartMessage(M_GetText("You have been kicked by the server\n\nPress ESC\n"), NULL, MM_NOTHING);
} }
else if (keepbody)
{
if (server && !demo.playback && playernode[pnum] != UINT8_MAX)
{
INT32 node = playernode[pnum];
playerpernode[node]--;
if (playerpernode[node] <= 0)
{
nodeingame[node] = false;
Net_CloseConnection(node);
ResetNode(node);
}
}
playernode[pnum] = UINT8_MAX;
players[pnum].quittime = 1;
}
else if (server) else if (server)
{ {
// Sal: Because kicks (and a lot of other commands) are player-based, we can't tell which player pnum is on the node from a glance. // Sal: Because kicks (and a lot of other commands) are player-based, we can't tell which player pnum is on the node from a glance.
@ -3086,8 +3025,6 @@ consvar_t cv_maxplayers = CVAR_INIT ("maxplayers", "8", CV_SAVE|CV_CALL, maxplay
static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}}; static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}};
consvar_t cv_joindelay = CVAR_INIT ("joindelay", "10", CV_SAVE|CV_NETVAR, joindelay_cons_t, NULL); consvar_t cv_joindelay = CVAR_INIT ("joindelay", "10", CV_SAVE|CV_NETVAR, joindelay_cons_t, NULL);
static CV_PossibleValue_t rejointimeout_cons_t[] = {{1, "MIN"}, {60 * FRACUNIT, "MAX"}, {0, "Off"}, {0, NULL}};
consvar_t cv_rejointimeout = CVAR_INIT ("rejointimeout", "Off", CV_SAVE|CV_NETVAR|CV_FLOAT, rejointimeout_cons_t, NULL);
// Here for dedicated servers // Here for dedicated servers
static CV_PossibleValue_t discordinvites_cons_t[] = {{0, "Admins Only"}, {1, "Everyone"}, {0, NULL}}; static CV_PossibleValue_t discordinvites_cons_t[] = {{0, "Admins Only"}, {1, "Everyone"}, {0, NULL}};
@ -3221,7 +3158,6 @@ void SV_ResetServer(void)
LUA_InvalidatePlayer(&players[i]); LUA_InvalidatePlayer(&players[i]);
playeringame[i] = false; playeringame[i] = false;
playernode[i] = UINT8_MAX; playernode[i] = UINT8_MAX;
memset(playeraddress[i], 0, sizeof(*playeraddress));
sprintf(player_names[i], "Player %c", 'A' + i); sprintf(player_names[i], "Player %c", 'A' + i);
adminplayers[i] = -1; // Populate the entire adminplayers array with -1. adminplayers[i] = -1; // Populate the entire adminplayers array with -1.
K_ClearClientPowerLevels(); K_ClearClientPowerLevels();
@ -3342,7 +3278,6 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
UINT8 console; UINT8 console;
UINT8 splitscreenplayer = 0; UINT8 splitscreenplayer = 0;
UINT8 i; UINT8 i;
boolean rejoined;
player_t *newplayer; player_t *newplayer;
if (playernum != serverplayer && !IsPlayerAdmin(playernum)) if (playernum != serverplayer && !IsPlayerAdmin(playernum))
@ -3350,7 +3285,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
// protect against hacked/buggy client // protect against hacked/buggy client
CONS_Alert(CONS_WARNING, M_GetText("Illegal add player command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal add player command received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -3359,9 +3294,6 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
CONS_Debug(DBG_NETPLAY, "addplayer: %d %d\n", node, newplayernum); CONS_Debug(DBG_NETPLAY, "addplayer: %d %d\n", node, newplayernum);
rejoined = playeringame[newplayernum];
if (!rejoined)
{ {
// Clear player before joining, lest some things get set incorrectly // Clear player before joining, lest some things get set incorrectly
CL_ClearPlayer(newplayernum); CL_ClearPlayer(newplayernum);
@ -3371,25 +3303,11 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
if (newplayernum+1 > doomcom->numslots) if (newplayernum+1 > doomcom->numslots)
doomcom->numslots = (INT16)(newplayernum+1); doomcom->numslots = (INT16)(newplayernum+1);
if (server && I_GetNodeAddress)
{
const char *address = I_GetNodeAddress(node);
char *port = NULL;
if (address) // MI: fix msvcrt.dll!_mbscat crash?
{
strcpy(playeraddress[newplayernum], address);
port = strchr(playeraddress[newplayernum], ':');
if (port)
*port = '\0';
}
}
} }
newplayer = &players[newplayernum]; newplayer = &players[newplayernum];
newplayer->jointime = 0; newplayer->jointime = 0;
newplayer->quittime = 0;
READSTRINGN(*p, player_names[newplayernum], MAXPLAYERNAME); READSTRINGN(*p, player_names[newplayernum], MAXPLAYERNAME);
@ -3423,27 +3341,6 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
D_SendPlayerConfig(splitscreenplayer); D_SendPlayerConfig(splitscreenplayer);
addedtogame = true; addedtogame = true;
if (rejoined)
{
if (newplayer->mo)
{
newplayer->viewheight = P_GetPlayerViewHeight(newplayer);
if (newplayer->mo->eflags & MFE_VERTICALFLIP)
newplayer->viewz = newplayer->mo->z + newplayer->mo->height - newplayer->viewheight;
else
newplayer->viewz = newplayer->mo->z + newplayer->viewheight;
}
// wake up the status bar
ST_Start();
// wake up the heads up text
HU_Start();
if (camera[splitscreenplayer].chase)
P_ResetCamera(newplayer, &camera[splitscreenplayer]);
}
} }
players[newplayernum].splitscreenindex = splitscreenplayer; players[newplayernum].splitscreenindex = splitscreenplayer;
@ -3459,10 +3356,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
{ {
char joinmsg[256]; char joinmsg[256];
if (rejoined) strcpy(joinmsg, M_GetText("\x82*%s has joined the game (player %d)"));
strcpy(joinmsg, M_GetText("\x82*%s has rejoined the game (player %d)"));
else
strcpy(joinmsg, M_GetText("\x82*%s has joined the game (player %d)"));
strcpy(joinmsg, va(joinmsg, player_names[newplayernum], newplayernum)); strcpy(joinmsg, va(joinmsg, player_names[newplayernum], newplayernum));
if (node != mynode) if (node != mynode)
@ -3482,8 +3376,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
if (server && multiplayer && motd[0] != '\0') if (server && multiplayer && motd[0] != '\0')
COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); COM_BufAddText(va("sayto %d %s\n", newplayernum, motd));
if (!rejoined) LUAh_PlayerJoin(newplayernum);
LUAh_PlayerJoin(newplayernum);
#ifdef HAVE_DISCORDRPC #ifdef HAVE_DISCORDRPC
DRPC_UpdatePresence(); DRPC_UpdatePresence();
@ -3501,7 +3394,7 @@ static void Got_RemovePlayer(UINT8 **p, INT32 playernum)
CONS_Alert(CONS_WARNING, M_GetText("Illegal remove player command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal remove player command received from %s\n"), player_names[playernum]);
if (server) if (server)
{ {
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
} }
return; return;
} }
@ -3530,7 +3423,7 @@ static void Got_AddBot(UINT8 **p, INT32 playernum)
CONS_Alert(CONS_WARNING, M_GetText("Illegal add player command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal add player command received from %s\n"), player_names[playernum]);
if (server) if (server)
{ {
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
} }
return; return;
} }
@ -3580,13 +3473,11 @@ static boolean SV_AddWaitingPlayers(SINT8 node, const char *name, const char *na
{ {
newplayer = true; newplayer = true;
newplayernum = FindRejoinerNum(node);
if (newplayernum == -1)
{ {
UINT8 nobotoverwrite; UINT8 nobotoverwrite;
// search for a free playernum // search for a free playernum
// we can't use playeringame since it is not updated here // we can't solely use playeringame since it is not updated here
for (newplayernum = dedicated ? 1 : 0; newplayernum < MAXPLAYERS; newplayernum++) for (newplayernum = dedicated ? 1 : 0; newplayernum < MAXPLAYERS; newplayernum++)
{ {
if (playeringame[newplayernum]) if (playeringame[newplayernum])
@ -3743,7 +3634,7 @@ void SV_StopServer(void)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
localtextcmd[i][0] = 0; localtextcmd[i][0] = 0;
for (i = firstticstosend; i < firstticstosend + TICQUEUE; i++) for (i = firstticstosend; i < firstticstosend + BACKUPTICS; i++)
D_Clearticcmd(i); D_Clearticcmd(i);
consoleplayer = 0; consoleplayer = 0;
@ -3809,7 +3700,6 @@ static size_t TotalTextCmdPerTic(tic_t tic)
static void HandleConnect(SINT8 node) static void HandleConnect(SINT8 node)
{ {
char names[MAXSPLITSCREENPLAYERS][MAXPLAYERNAME + 1]; char names[MAXSPLITSCREENPLAYERS][MAXPLAYERNAME + 1];
INT32 rejoinernum;
INT32 i; INT32 i;
// Sal: Dedicated mode is INCREDIBLY hacked together. // Sal: Dedicated mode is INCREDIBLY hacked together.
@ -3817,8 +3707,6 @@ static void HandleConnect(SINT8 node)
// It's too much effort to legimately fix right now. Just prevent it from reaching that state. // It's too much effort to legimately fix right now. Just prevent it from reaching that state.
UINT8 maxplayers = min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value); UINT8 maxplayers = min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value);
rejoinernum = FindRejoinerNum(node);
if (bannednode && bannednode[node]) if (bannednode && bannednode[node])
SV_SendRefuse(node, M_GetText("You have been banned\nfrom the server.")); SV_SendRefuse(node, M_GetText("You have been banned\nfrom the server."));
else if (netbuffer->u.clientcfg._255 != 255 || else if (netbuffer->u.clientcfg._255 != 255 ||
@ -3830,9 +3718,9 @@ static void HandleConnect(SINT8 node)
else if (netbuffer->u.clientcfg.version != VERSION else if (netbuffer->u.clientcfg.version != VERSION
|| netbuffer->u.clientcfg.subversion != SUBVERSION) || netbuffer->u.clientcfg.subversion != SUBVERSION)
SV_SendRefuse(node, va(M_GetText("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)"), VERSION, SUBVERSION)); SV_SendRefuse(node, va(M_GetText("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)"), VERSION, SUBVERSION));
else if (!cv_allownewplayer.value && node && rejoinernum == -1) else if (!cv_allownewplayer.value && node)
SV_SendRefuse(node, M_GetText("The server is not accepting\njoins for the moment.")); SV_SendRefuse(node, M_GetText("The server is not accepting\njoins for the moment."));
else if (D_NumPlayers() >= maxplayers && rejoinernum == -1) else if (D_NumPlayers() >= maxplayers)
SV_SendRefuse(node, va(M_GetText("Maximum players reached: %d"), maxplayers)); SV_SendRefuse(node, va(M_GetText("Maximum players reached: %d"), maxplayers));
else if (netgame && netbuffer->u.clientcfg.localplayers > MAXSPLITSCREENPLAYERS) // Hacked client? else if (netgame && netbuffer->u.clientcfg.localplayers > MAXSPLITSCREENPLAYERS) // Hacked client?
SV_SendRefuse(node, M_GetText("Too many players from\nthis node.")); SV_SendRefuse(node, M_GetText("Too many players from\nthis node."));
@ -3854,7 +3742,7 @@ static void HandleConnect(SINT8 node)
for (i = 0; i < netbuffer->u.clientcfg.localplayers - playerpernode[node]; i++) for (i = 0; i < netbuffer->u.clientcfg.localplayers - playerpernode[node]; i++)
{ {
strlcpy(names[i], netbuffer->u.clientcfg.names[i], MAXPLAYERNAME + 1); strlcpy(names[i], netbuffer->u.clientcfg.names[i], MAXPLAYERNAME + 1);
if (!EnsurePlayerNameIsGood(names[i], rejoinernum)) if (!EnsurePlayerNameIsGood(names[i], -1))
{ {
SV_SendRefuse(node, "Bad player name"); SV_SendRefuse(node, "Bad player name");
return; return;
@ -4252,8 +4140,8 @@ static void HandlePacketFromAwayNode(SINT8 node)
*/ */
static boolean CheckForSpeedHacks(UINT8 p) static boolean CheckForSpeedHacks(UINT8 p)
{ {
if (netcmds[maketic%TICQUEUE][p].forwardmove > MAXPLMOVE || netcmds[maketic%TICQUEUE][p].forwardmove < -MAXPLMOVE if (netcmds[maketic%BACKUPTICS][p].forwardmove > MAXPLMOVE || netcmds[maketic%BACKUPTICS][p].forwardmove < -MAXPLMOVE
|| netcmds[maketic%TICQUEUE][p].turning > KART_FULLTURN || netcmds[maketic%TICQUEUE][p].turning < -KART_FULLTURN) || netcmds[maketic%BACKUPTICS][p].turning > KART_FULLTURN || netcmds[maketic%BACKUPTICS][p].turning < -KART_FULLTURN)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal movement value received from node %d\n"), playernode[p]); CONS_Alert(CONS_WARNING, M_GetText("Illegal movement value received from node %d\n"), playernode[p]);
//D_Clearticcmd(k); //D_Clearticcmd(k);
@ -4347,7 +4235,7 @@ static void HandlePacketFromPlayer(SINT8 node)
break; break;
// Copy ticcmd // Copy ticcmd
G_MoveTiccmd(&netcmds[maketic%TICQUEUE][netconsole], &netbuffer->u.clientpak.cmd, 1); G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][netconsole], &netbuffer->u.clientpak.cmd, 1);
// Check ticcmd for "speed hacks" // Check ticcmd for "speed hacks"
if (CheckForSpeedHacks((UINT8)netconsole)) if (CheckForSpeedHacks((UINT8)netconsole))
@ -4359,7 +4247,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|| (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))
&& (nodetoplayer2[node] >= 0)) && (nodetoplayer2[node] >= 0))
{ {
G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer2[node]], G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer2[node]],
&netbuffer->u.client2pak.cmd2, 1); &netbuffer->u.client2pak.cmd2, 1);
if (CheckForSpeedHacks((UINT8)nodetoplayer2[node])) if (CheckForSpeedHacks((UINT8)nodetoplayer2[node]))
@ -4370,7 +4258,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|| (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))
&& (nodetoplayer3[node] >= 0)) && (nodetoplayer3[node] >= 0))
{ {
G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer3[node]], G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer3[node]],
&netbuffer->u.client3pak.cmd3, 1); &netbuffer->u.client3pak.cmd3, 1);
if (CheckForSpeedHacks((UINT8)nodetoplayer3[node])) if (CheckForSpeedHacks((UINT8)nodetoplayer3[node]))
@ -4380,7 +4268,7 @@ static void HandlePacketFromPlayer(SINT8 node)
if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS) if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)
&& (nodetoplayer4[node] >= 0)) && (nodetoplayer4[node] >= 0))
{ {
G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer4[node]], G_MoveTiccmd(&netcmds[maketic%BACKUPTICS][(UINT8)nodetoplayer4[node]],
&netbuffer->u.client4pak.cmd4, 1); &netbuffer->u.client4pak.cmd4, 1);
if (CheckForSpeedHacks((UINT8)nodetoplayer4[node])) if (CheckForSpeedHacks((UINT8)nodetoplayer4[node]))
@ -4388,8 +4276,8 @@ static void HandlePacketFromPlayer(SINT8 node)
} }
// Check player consistancy during the level // Check player consistancy during the level
if (realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL if (realstart <= gametic && realstart + BACKUPTICS - 1 > gametic && gamestate == GS_LEVEL
&& consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) && consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy)
&& !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime()
&& !SV_ResendingSavegameToAnyone()) && !SV_ResendingSavegameToAnyone())
{ {
@ -4404,18 +4292,18 @@ static void HandlePacketFromPlayer(SINT8 node)
if (cv_blamecfail.value) if (cv_blamecfail.value)
CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"), CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"),
netconsole+1, player_names[netconsole], netconsole+1, player_names[netconsole],
consistancy[realstart%TICQUEUE], consistancy[realstart%BACKUPTICS],
SHORT(netbuffer->u.clientpak.consistancy)); SHORT(netbuffer->u.clientpak.consistancy));
DEBFILE(va("Restoring player %d (synch failure) [%update] %d!=%d\n", DEBFILE(va("Restoring player %d (synch failure) [%update] %d!=%d\n",
netconsole, realstart, consistancy[realstart%TICQUEUE], netconsole, realstart, consistancy[realstart%BACKUPTICS],
SHORT(netbuffer->u.clientpak.consistancy))); SHORT(netbuffer->u.clientpak.consistancy)));
break; break;
} }
else else
{ {
SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(netconsole, KICK_MSG_CON_FAIL);
DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n", DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n",
netconsole, realstart, consistancy[realstart%TICQUEUE], netconsole, realstart, consistancy[realstart%BACKUPTICS],
SHORT(netbuffer->u.clientpak.consistancy))); SHORT(netbuffer->u.clientpak.consistancy)));
break; break;
} }
@ -4488,10 +4376,10 @@ static void HandlePacketFromPlayer(SINT8 node)
// search a tic that have enougth space in the ticcmd // search a tic that have enougth space in the ticcmd
while ((textcmd = D_GetExistingTextcmd(tic, netconsole)), while ((textcmd = D_GetExistingTextcmd(tic, netconsole)),
(TotalTextCmdPerTic(tic) > j || netbuffer->u.textcmd[0] + (textcmd ? textcmd[0] : 0) > MAXTEXTCMD) (TotalTextCmdPerTic(tic) > j || netbuffer->u.textcmd[0] + (textcmd ? textcmd[0] : 0) > MAXTEXTCMD)
&& tic < firstticstosend + TICQUEUE) && tic < firstticstosend + BACKUPTICS)
tic++; tic++;
if (tic >= firstticstosend + TICQUEUE) if (tic >= firstticstosend + BACKUPTICS)
{ {
DEBFILE(va("GetPacket: Textcmd too long (max %s, used %s, mak %d, " DEBFILE(va("GetPacket: Textcmd too long (max %s, used %s, mak %d, "
"tosend %u, node %u, player %d)\n", sizeu1(j), sizeu2(TotalTextCmdPerTic(maketic)), "tosend %u, node %u, player %d)\n", sizeu1(j), sizeu2(TotalTextCmdPerTic(maketic)),
@ -4552,7 +4440,6 @@ static void HandlePacketFromPlayer(SINT8 node)
kickmsg = KICK_MSG_TIMEOUT; kickmsg = KICK_MSG_TIMEOUT;
else else
kickmsg = KICK_MSG_PLAYER_QUIT; kickmsg = KICK_MSG_PLAYER_QUIT;
kickmsg |= KICK_MSG_KEEP_BODY;
SendKick(netconsole, kickmsg); SendKick(netconsole, kickmsg);
@ -4607,7 +4494,7 @@ static void HandlePacketFromPlayer(SINT8 node)
{ {
CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_SERVERTICS", node); CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_SERVERTICS", node);
if (server) if (server)
SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(netconsole, KICK_MSG_CON_FAIL);
break; break;
} }
@ -4618,8 +4505,8 @@ static void HandlePacketFromPlayer(SINT8 node)
txtpak = (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots txtpak = (UINT8 *)&netbuffer->u.serverpak.cmds[netbuffer->u.serverpak.numslots
* netbuffer->u.serverpak.numtics]; * netbuffer->u.serverpak.numtics];
if (realend > gametic + TICQUEUE) if (realend > gametic + CLIENTBACKUPTICS)
realend = gametic + TICQUEUE; realend = gametic + CLIENTBACKUPTICS;
cl_packetmissed = realstart > neededtic; cl_packetmissed = realstart > neededtic;
if (realstart <= neededtic && realend > neededtic) if (realstart <= neededtic && realend > neededtic)
@ -4633,7 +4520,7 @@ static void HandlePacketFromPlayer(SINT8 node)
D_Clearticcmd(i); D_Clearticcmd(i);
// copy the tics // copy the tics
pak = G_ScpyTiccmd(netcmds[i%TICQUEUE], pak, pak = G_ScpyTiccmd(netcmds[i%BACKUPTICS], pak,
netbuffer->u.serverpak.numslots*sizeof (ticcmd_t)); netbuffer->u.serverpak.numslots*sizeof (ticcmd_t));
// copy the textcmds // copy the textcmds
@ -4667,7 +4554,7 @@ static void HandlePacketFromPlayer(SINT8 node)
{ {
CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_PING", node); CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_PING", node);
if (server) if (server)
SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(netconsole, KICK_MSG_CON_FAIL);
break; break;
} }
@ -4691,7 +4578,7 @@ static void HandlePacketFromPlayer(SINT8 node)
{ {
CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_FILEFRAGMENT", node); CONS_Alert(CONS_WARNING, M_GetText("%s received from non-host %d\n"), "PT_FILEFRAGMENT", node);
if (server) if (server)
SendKick(netconsole, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(netconsole, KICK_MSG_CON_FAIL);
break; break;
} }
if (client) if (client)
@ -4986,7 +4873,7 @@ static void CL_SendClientCmd(void)
packetsize = sizeof (clientcmd_pak); packetsize = sizeof (clientcmd_pak);
G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds[0][lagDelay], 1); G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds[0][lagDelay], 1);
netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic % TICQUEUE]); netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic % BACKUPTICS]);
if (splitscreen) // Send a special packet with 2 cmd for splitscreen if (splitscreen) // Send a special packet with 2 cmd for splitscreen
{ {
@ -5064,10 +4951,10 @@ static void SV_SendTics(void)
{ {
// assert supposedtics[n]>=nettics[n] // assert supposedtics[n]>=nettics[n]
realfirsttic = supposedtics[n]; realfirsttic = supposedtics[n];
lasttictosend = maketic;
if (lasttictosend - nettics[n] >= TICQUEUE) lasttictosend = nettics[n] + CLIENTBACKUPTICS;
lasttictosend = nettics[n] + TICQUEUE-1; if (lasttictosend > maketic)
lasttictosend = maketic;
if (realfirsttic >= lasttictosend) if (realfirsttic >= lasttictosend)
{ {
@ -5128,7 +5015,7 @@ static void SV_SendTics(void)
for (i = realfirsttic; i < lasttictosend; i++) for (i = realfirsttic; i < lasttictosend; i++)
{ {
bufpos = G_DcpyTiccmd(bufpos, netcmds[i%TICQUEUE], doomcom->numslots * sizeof (ticcmd_t)); bufpos = G_DcpyTiccmd(bufpos, netcmds[i%BACKUPTICS], doomcom->numslots * sizeof (ticcmd_t));
} }
// add textcmds // add textcmds
@ -5210,23 +5097,16 @@ static void SV_Maketic(void)
if (K_PlayerUsesBotMovement(&players[i])) if (K_PlayerUsesBotMovement(&players[i]))
{ {
K_BuildBotTiccmd(&players[i], &netcmds[maketic%TICQUEUE][i]); K_BuildBotTiccmd(&players[i], &netcmds[maketic%BACKUPTICS][i]);
continue; continue;
} }
// We didn't receive this tic // We didn't receive this tic
if ((netcmds[maketic % TICQUEUE][i].flags & TICCMD_RECEIVED) == 0) if ((netcmds[maketic % BACKUPTICS][i].flags & TICCMD_RECEIVED) == 0)
{ {
ticcmd_t * ticcmd = &netcmds[(maketic ) % TICQUEUE][i]; ticcmd_t * ticcmd = &netcmds[(maketic ) % BACKUPTICS][i];
ticcmd_t *prevticcmd = &netcmds[(maketic - 1) % TICQUEUE][i]; ticcmd_t *prevticcmd = &netcmds[(maketic - 1) % BACKUPTICS][i];
if (players[i].quittime)
{
// empty inputs but consider recieved
memset(ticcmd, 0, sizeof(netcmds[0][0]));
ticcmd->flags |= TICCMD_RECEIVED;
}
else
{ {
DEBFILE(va("MISS tic%4d for player %d\n", maketic, i)); DEBFILE(va("MISS tic%4d for player %d\n", maketic, i));
// Copy the input from the previous tic // Copy the input from the previous tic
@ -5324,7 +5204,7 @@ boolean TryRunTics(tic_t realtics)
G_Ticker((gametic % NEWTICRATERATIO) == 0); G_Ticker((gametic % NEWTICRATERATIO) == 0);
ExtraDataTicker(); ExtraDataTicker();
gametic++; gametic++;
consistancy[gametic%TICQUEUE] = Consistancy(); consistancy[gametic%BACKUPTICS] = Consistancy();
ps_tictime = I_GetPreciseTime() - ps_tictime; ps_tictime = I_GetPreciseTime() - ps_tictime;
@ -5365,7 +5245,7 @@ static inline void PingUpdate(void)
{ {
for (i = 1; i < MAXPLAYERS; i++) for (i = 1; i < MAXPLAYERS; i++)
{ {
if (playeringame[i] && !players[i].quittime if (playeringame[i]
&& (realpingtable[i] / pingmeasurecount > (unsigned)cv_maxping.value)) && (realpingtable[i] / pingmeasurecount > (unsigned)cv_maxping.value))
{ {
if (players[i].jointime > 30 * TICRATE) if (players[i].jointime > 30 * TICRATE)
@ -5390,7 +5270,7 @@ static inline void PingUpdate(void)
if (pingtimeout[i] > cv_pingtimeout.value) if (pingtimeout[i] > cv_pingtimeout.value)
{ {
pingtimeout[i] = 0; pingtimeout[i] = 0;
SendKick(i, KICK_MSG_PING_HIGH | KICK_MSG_KEEP_BODY); SendKick(i, KICK_MSG_PING_HIGH);
} }
} }
/* /*
@ -5641,15 +5521,15 @@ void NetUpdate(void)
{ {
firstticstosend = nettics[i]; firstticstosend = nettics[i];
if (maketic + 1 >= nettics[i] + TICQUEUE) if (maketic + 1 >= nettics[i] + BACKUPTICS)
Net_ConnectionTimeout(i); Net_ConnectionTimeout(i);
} }
// Don't erase tics not acknowledged // Don't erase tics not acknowledged
counts = realtics; counts = realtics;
if (maketic + counts >= firstticstosend + TICQUEUE) if (maketic + counts >= firstticstosend + BACKUPTICS)
counts = firstticstosend+TICQUEUE-maketic-1; counts = firstticstosend+BACKUPTICS-maketic-1;
for (i = 0; i < counts; i++) for (i = 0; i < counts; i++)
SV_Maketic(); // Create missed tics and increment maketic SV_Maketic(); // Create missed tics and increment maketic

View file

@ -37,7 +37,8 @@ applications may follow different packet versions.
// be transmitted. // be transmitted.
// Networking and tick handling related. // Networking and tick handling related.
#define TICQUEUE 512 // more than enough for most timeouts.... #define BACKUPTICS 512 // more than enough for most timeouts....
#define CLIENTBACKUPTICS 32
#define MAXTEXTCMD 256 #define MAXTEXTCMD 256
// No. of tics your controls can be delayed by. // No. of tics your controls can be delayed by.
@ -409,7 +410,6 @@ extern consvar_t cv_playbackspeed;
#define KICK_MSG_PING_HIGH 6 #define KICK_MSG_PING_HIGH 6
#define KICK_MSG_CUSTOM_KICK 7 #define KICK_MSG_CUSTOM_KICK 7
#define KICK_MSG_CUSTOM_BAN 8 #define KICK_MSG_CUSTOM_BAN 8
#define KICK_MSG_KEEP_BODY 0x80
typedef enum typedef enum
{ {
@ -445,7 +445,7 @@ extern tic_t servermaxping;
extern boolean server_lagless; extern boolean server_lagless;
extern consvar_t cv_netticbuffer, cv_allownewplayer, cv_maxplayers, cv_joindelay, cv_rejointimeout; extern consvar_t cv_netticbuffer, cv_allownewplayer, cv_maxplayers, cv_joindelay;
extern consvar_t cv_resynchattempts, cv_blamecfail; extern consvar_t cv_resynchattempts, cv_blamecfail;
extern consvar_t cv_maxsend, cv_noticedownload, cv_downloadspeed; extern consvar_t cv_maxsend, cv_noticedownload, cv_downloadspeed;

View file

@ -717,7 +717,6 @@ void D_RegisterServerCommands(void)
// d_clisrv // d_clisrv
CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_maxplayers);
CV_RegisterVar(&cv_joindelay); CV_RegisterVar(&cv_joindelay);
CV_RegisterVar(&cv_rejointimeout);
CV_RegisterVar(&cv_resynchattempts); CV_RegisterVar(&cv_resynchattempts);
CV_RegisterVar(&cv_maxsend); CV_RegisterVar(&cv_maxsend);
CV_RegisterVar(&cv_noticedownload); CV_RegisterVar(&cv_noticedownload);
@ -1280,7 +1279,7 @@ static void SetPlayerName(INT32 playernum, char *newname)
{ {
CONS_Printf(M_GetText("Player %d sent a bad name change\n"), playernum+1); CONS_Printf(M_GetText("Player %d sent a bad name change\n"), playernum+1);
if (server && netgame) if (server && netgame)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
} }
} }
@ -1609,7 +1608,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
if (kick) if (kick)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal color change received from %s (team: %d), color: %d)\n"), player_names[playernum], p->ctfteam, p->skincolor); CONS_Alert(CONS_WARNING, M_GetText("Illegal color change received from %s (team: %d), color: %d)\n"), player_names[playernum], p->ctfteam, p->skincolor);
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
} }
@ -1714,7 +1713,7 @@ static void Got_PartyInvite(UINT8 **cp,INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal splitscreen invitation received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal splitscreen invitation received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -1745,7 +1744,7 @@ static void Got_AcceptPartyInvite(UINT8 **cp,INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal accept splitscreen invite received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal accept splitscreen invite received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -1809,7 +1808,7 @@ static void Got_CancelPartyInvite(UINT8 **cp,INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal cancel splitscreen invite received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal cancel splitscreen invite received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
} }
} }
@ -1821,7 +1820,7 @@ static void Got_LeaveParty(UINT8 **cp,INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal accept splitscreen invite received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal accept splitscreen invite received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -2838,7 +2837,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal map change received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal map change received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -2951,7 +2950,7 @@ static void Got_Pause(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal pause command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal pause command received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -3028,7 +3027,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal respawn command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal respawn command received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -3098,7 +3097,7 @@ static void Got_Clearscores(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal clear scores command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal clear scores command received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -3334,7 +3333,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
// this should never happen unless the client is hacked/buggy // this should never happen unless the client is hacked/buggy
CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
} }
if (NetPacket.packet.verification) // Special marker that the server sent the request if (NetPacket.packet.verification) // Special marker that the server sent the request
@ -3343,7 +3342,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
playernum = NetPacket.packet.playernum; playernum = NetPacket.packet.playernum;
@ -3368,7 +3367,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
} }
return; return;
} }
@ -3392,7 +3391,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
if (server && ((NetPacket.packet.newteam < 0 || NetPacket.packet.newteam > 3) || error)) if (server && ((NetPacket.packet.newteam < 0 || NetPacket.packet.newteam > 3) || error))
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]);
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
} }
//Safety first! //Safety first!
@ -3679,7 +3678,7 @@ static void Got_Verification(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal verification received from %s (serverplayer is %s)\n"), player_names[playernum], player_names[serverplayer]); CONS_Alert(CONS_WARNING, M_GetText("Illegal verification received from %s (serverplayer is %s)\n"), player_names[playernum], player_names[serverplayer]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -3729,7 +3728,7 @@ static void Got_Removal(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal demotion received from %s (serverplayer is %s)\n"), player_names[playernum], player_names[serverplayer]); CONS_Alert(CONS_WARNING, M_GetText("Illegal demotion received from %s (serverplayer is %s)\n"), player_names[playernum], player_names[serverplayer]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -3803,7 +3802,7 @@ static void Got_MotD_f(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal motd change received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal motd change received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
Z_Free(mymotd); Z_Free(mymotd);
return; return;
} }
@ -3859,7 +3858,7 @@ static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal runsoc command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal runsoc command received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -4053,7 +4052,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
if ((playernum != serverplayer && !IsPlayerAdmin(playernum)) || kick) if ((playernum != serverplayer && !IsPlayerAdmin(playernum)) || kick)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal addfile command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal addfile command received from %s\n"), player_names[playernum]);
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -4101,7 +4100,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal addfile command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal addfile command received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -4839,7 +4838,7 @@ static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal exitlevel command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal exitlevel command received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -4855,7 +4854,7 @@ static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal vote setup received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal vote setup received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -4894,7 +4893,7 @@ static void Got_PickVotecmd(UINT8 **cp, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal vote setup received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal vote setup received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -4918,7 +4917,7 @@ static void Got_GiveItemcmd(UINT8 **cp, INT32 playernum)
M_GetText ("Illegal give item received from %s\n"), M_GetText ("Illegal give item received from %s\n"),
player_names[playernum]); player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -5824,7 +5823,7 @@ void Got_DiscordInfo(UINT8 **p, INT32 playernum)
// protect against hacked/buggy client // protect against hacked/buggy client
CONS_Alert(CONS_WARNING, M_GetText("Illegal Discord info command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal Discord info command received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }

View file

@ -547,7 +547,6 @@ typedef struct player_s
UINT8 splitscreenindex; UINT8 splitscreenindex;
tic_t jointime; // Timer when player joins game to change skin/color tic_t jointime; // Timer when player joins game to change skin/color
tic_t quittime; // Time elapsed since user disconnected, zero if connected
UINT8 typing_timer; // Counts down while keystrokes are not emitted UINT8 typing_timer; // Counts down while keystrokes are not emitted
UINT8 typing_duration; // How long since resumed timer UINT8 typing_duration; // How long since resumed timer

View file

@ -774,7 +774,7 @@ extern consvar_t cv_downloading; // allow clients to downloading WADs.
extern consvar_t cv_nettimeout; // SRB2Kart: Advanced server options menu extern consvar_t cv_nettimeout; // SRB2Kart: Advanced server options menu
extern consvar_t cv_jointimeout; extern consvar_t cv_jointimeout;
extern consvar_t cv_maxping; extern consvar_t cv_maxping;
extern ticcmd_t netcmds[TICQUEUE][MAXPLAYERS]; extern ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS];
extern INT32 serverplayer; extern INT32 serverplayer;
extern INT32 adminplayers[MAXPLAYERS]; extern INT32 adminplayers[MAXPLAYERS];

View file

@ -1889,7 +1889,7 @@ void G_Ticker(boolean run)
default: I_Error("gameaction = %d\n", gameaction); default: I_Error("gameaction = %d\n", gameaction);
} }
buf = gametic % TICQUEUE; buf = gametic % BACKUPTICS;
if (!demo.playback) if (!demo.playback)
{ {
@ -2105,7 +2105,6 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
UINT32 availabilities; UINT32 availabilities;
tic_t jointime; tic_t jointime;
tic_t quittime;
UINT8 splitscreenindex; UINT8 splitscreenindex;
boolean spectator; boolean spectator;
@ -2140,7 +2139,6 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
ctfteam = players[player].ctfteam; ctfteam = players[player].ctfteam;
jointime = players[player].jointime; jointime = players[player].jointime;
quittime = players[player].quittime;
splitscreenindex = players[player].splitscreenindex; splitscreenindex = players[player].splitscreenindex;
spectator = players[player].spectator; spectator = players[player].spectator;
@ -2256,7 +2254,6 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
p->pflags = pflags; p->pflags = pflags;
p->ctfteam = ctfteam; p->ctfteam = ctfteam;
p->jointime = jointime; p->jointime = jointime;
p->quittime = quittime;
p->splitscreenindex = splitscreenindex; p->splitscreenindex = splitscreenindex;
p->spectator = spectator; p->spectator = spectator;
p->steering = steering; p->steering = steering;

View file

@ -641,7 +641,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
M_GetText("Illegal say command received from %s while muted\n") : M_GetText("Illegal csay command received from non-admin %s\n"), M_GetText("Illegal say command received from %s while muted\n") : M_GetText("Illegal csay command received from non-admin %s\n"),
player_names[playernum]); player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
@ -655,7 +655,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal say command received from %s containing invalid characters\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal say command received from %s containing invalid characters\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
return; return;
} }
} }

View file

@ -260,7 +260,7 @@ void K_UpdateMatchRaceBots(void)
--------------------------------------------------*/ --------------------------------------------------*/
boolean K_PlayerUsesBotMovement(player_t *player) boolean K_PlayerUsesBotMovement(player_t *player)
{ {
if (player->bot || player->exiting || player->quittime) if (player->bot || player->exiting)
return true; return true;
return false; return false;

View file

@ -90,7 +90,7 @@ deny:
CONS_Alert(CONS_WARNING, M_GetText("Illegal lua command received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal lua command received from %s\n"), player_names[playernum]);
if (server) if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); SendKick(playernum, KICK_MSG_CON_FAIL);
} }
// Wrapper for COM_AddCommand commands // Wrapper for COM_AddCommand commands

View file

@ -461,8 +461,6 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->jointime); lua_pushinteger(L, plr->jointime);
else if (fastcmp(field,"splitscreenindex")) else if (fastcmp(field,"splitscreenindex"))
lua_pushinteger(L, plr->splitscreenindex); lua_pushinteger(L, plr->splitscreenindex);
else if (fastcmp(field,"quittime"))
lua_pushinteger(L, plr->quittime);
#ifdef HWRENDER #ifdef HWRENDER
else if (fastcmp(field,"fovadd")) else if (fastcmp(field,"fovadd"))
lua_pushfixed(L, plr->fovadd); lua_pushfixed(L, plr->fovadd);

View file

@ -747,9 +747,6 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed
if (player->bot) if (player->bot)
continue; // ignore bots continue; // ignore bots
if (player->quittime)
continue; // Ignore uncontrolled bodies
if (dist > 0 if (dist > 0
&& P_AproxDistance(P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y), player->mo->z - actor->z) > dist) && P_AproxDistance(P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y), player->mo->z - actor->z) > dist)
continue; // Too far away continue; // Too far away

View file

@ -171,6 +171,15 @@ static void P_NetArchivePlayers(void)
WRITEUINT8(save_p, players[i].checkskip); WRITEUINT8(save_p, players[i].checkskip);
WRITEINT16(save_p, players[i].lastsidehit);
WRITEINT16(save_p, players[i].lastlinehit);
WRITEINT32(save_p, players[i].onconveyor);
WRITEUINT32(save_p, players[i].jointime);
WRITEUINT8(save_p, players[i].splitscreenindex);
if (players[i].awayviewmobj) if (players[i].awayviewmobj)
flags |= AWAYVIEW; flags |= AWAYVIEW;
@ -186,16 +195,6 @@ static void P_NetArchivePlayers(void)
if (players[i].skybox.centerpoint) if (players[i].skybox.centerpoint)
flags |= SKYBOXCENTER; flags |= SKYBOXCENTER;
WRITEINT16(save_p, players[i].lastsidehit);
WRITEINT16(save_p, players[i].lastlinehit);
WRITEINT32(save_p, players[i].onconveyor);
WRITEUINT32(save_p, players[i].jointime);
WRITEUINT32(save_p, players[i].quittime);
WRITEUINT8(save_p, players[i].splitscreenindex);
WRITEUINT16(save_p, flags); WRITEUINT16(save_p, flags);
if (flags & SKYBOXVIEW) if (flags & SKYBOXVIEW)
@ -342,6 +341,8 @@ static void P_NetArchivePlayers(void)
WRITEUINT8(save_p, players[i].kickstartaccel); WRITEUINT8(save_p, players[i].kickstartaccel);
WRITEUINT8(save_p, players[i].stairjank);
// respawnvars_t // respawnvars_t
WRITEUINT8(save_p, players[i].respawn.state); WRITEUINT8(save_p, players[i].respawn.state);
WRITEUINT32(save_p, K_GetWaypointHeapIndex(players[i].respawn.wp)); WRITEUINT32(save_p, K_GetWaypointHeapIndex(players[i].respawn.wp));
@ -406,7 +407,7 @@ static void P_NetUnArchivePlayers(void)
players[i].steering = READINT16(save_p); players[i].steering = READINT16(save_p);
players[i].angleturn = READANGLE(save_p); players[i].angleturn = READANGLE(save_p);
players[i].aiming = READANGLE(save_p); players[i].aiming = READANGLE(save_p);
players[i].drawangle = READANGLE(save_p); players[i].drawangle = players[i].old_drawangle = READANGLE(save_p);
players[i].viewrollangle = READANGLE(save_p); players[i].viewrollangle = READANGLE(save_p);
players[i].tilt = READANGLE(save_p); players[i].tilt = READANGLE(save_p);
players[i].awayviewaiming = READANGLE(save_p); players[i].awayviewaiming = READANGLE(save_p);
@ -455,7 +456,6 @@ static void P_NetUnArchivePlayers(void)
players[i].onconveyor = READINT32(save_p); players[i].onconveyor = READINT32(save_p);
players[i].jointime = READUINT32(save_p); players[i].jointime = READUINT32(save_p);
players[i].quittime = READUINT32(save_p);
players[i].splitscreenindex = READUINT8(save_p); players[i].splitscreenindex = READUINT8(save_p);
@ -606,6 +606,8 @@ static void P_NetUnArchivePlayers(void)
players[i].kickstartaccel = READUINT8(save_p); players[i].kickstartaccel = READUINT8(save_p);
players[i].stairjank = READUINT8(save_p);
// respawnvars_t // respawnvars_t
players[i].respawn.state = READUINT8(save_p); players[i].respawn.state = READUINT8(save_p);
players[i].respawn.wp = (waypoint_t *)(size_t)READUINT32(save_p); players[i].respawn.wp = (waypoint_t *)(size_t)READUINT32(save_p);
@ -1679,7 +1681,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
diff2 = 0; diff2 = 0;
// not the default but the most probable // not the default but the most probable
if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0) if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0 || mobj->pmomz != 0)
diff |= MD_MOM; diff |= MD_MOM;
if (mobj->radius != mobj->info->radius) if (mobj->radius != mobj->info->radius)
diff |= MD_RADIUS; diff |= MD_RADIUS;
@ -1864,6 +1866,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
WRITEFIXED(save_p, mobj->momx); WRITEFIXED(save_p, mobj->momx);
WRITEFIXED(save_p, mobj->momy); WRITEFIXED(save_p, mobj->momy);
WRITEFIXED(save_p, mobj->momz); WRITEFIXED(save_p, mobj->momz);
WRITEFIXED(save_p, mobj->pmomz);
} }
if (diff & MD_RADIUS) if (diff & MD_RADIUS)
WRITEFIXED(save_p, mobj->radius); WRITEFIXED(save_p, mobj->radius);
@ -2932,6 +2935,7 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
mobj->momx = READFIXED(save_p); mobj->momx = READFIXED(save_p);
mobj->momy = READFIXED(save_p); mobj->momy = READFIXED(save_p);
mobj->momz = READFIXED(save_p); mobj->momz = READFIXED(save_p);
mobj->pmomz = READFIXED(save_p);
} // otherwise they're zero, and the memset took care of it } // otherwise they're zero, and the memset took care of it
if (diff & MD_RADIUS) if (diff & MD_RADIUS)

View file

@ -4282,7 +4282,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
if (!fromnetsave) // uglier hack if (!fromnetsave) // uglier hack
{ // to make a newly loaded level start on the second frame. { // to make a newly loaded level start on the second frame.
INT32 buf = gametic % TICQUEUE; INT32 buf = gametic % BACKUPTICS;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (playeringame[i]) if (playeringame[i])

View file

@ -502,15 +502,6 @@ void P_Ticker(boolean run)
if (playeringame[i]) if (playeringame[i])
{ {
players[i].jointime++; players[i].jointime++;
if (players[i].quittime)
{
players[i].quittime++;
if (server && players[i].quittime >= (tic_t)FixedMul(cv_rejointimeout.value, 60 * TICRATE)
&& !(players[i].quittime % TICRATE))
SendKick(i, KICK_MSG_PLAYER_QUIT);
}
} }
if (objectplacing) if (objectplacing)