mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'servers-16' into 'master'
Server ports from 1.6 + general Dedicated repair See merge request KartKrew/Kart!760
This commit is contained in:
commit
45604a05c3
4 changed files with 139 additions and 80 deletions
139
src/d_clisrv.c
139
src/d_clisrv.c
|
|
@ -5578,53 +5578,56 @@ static INT32 pingtimeout[MAXPLAYERS];
|
|||
static inline void PingUpdate(void)
|
||||
{
|
||||
INT32 i;
|
||||
boolean laggers[MAXPLAYERS];
|
||||
UINT8 numlaggers = 0;
|
||||
memset(laggers, 0, sizeof(boolean) * MAXPLAYERS);
|
||||
boolean pingkick[MAXPLAYERS];
|
||||
UINT8 nonlaggers = 0;
|
||||
memset(pingkick, 0, sizeof(pingkick));
|
||||
|
||||
netbuffer->packettype = PT_PING;
|
||||
|
||||
//check for ping limit breakage.
|
||||
if (cv_maxping.value)
|
||||
{
|
||||
for (i = 1; i < MAXPLAYERS; i++)
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (playeringame[i]
|
||||
&& (realpingtable[i] / pingmeasurecount > (unsigned)cv_maxping.value))
|
||||
if (!playeringame[i] || P_IsMachineLocalPlayer(&players[i]))
|
||||
{
|
||||
if (players[i].jointime > 30 * TICRATE)
|
||||
laggers[i] = true;
|
||||
numlaggers++;
|
||||
pingtimeout[i] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((cv_maxping.value)
|
||||
&& (realpingtable[i] / pingmeasurecount > (unsigned)cv_maxping.value))
|
||||
{
|
||||
if (players[i].jointime > 10 * TICRATE)
|
||||
{
|
||||
pingkick[i] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
pingtimeout[i] = 0;
|
||||
{
|
||||
nonlaggers++;
|
||||
|
||||
// you aren't lagging, but you aren't free yet. In case you'll keep spiking, we just make the timer go back down. (Very unstable net must still get kicked).
|
||||
if (pingtimeout[i] > 0)
|
||||
pingtimeout[i]--;
|
||||
}
|
||||
}
|
||||
|
||||
//kick lagging players... unless everyone but the server's ping sucks.
|
||||
//in that case, it is probably the server's fault.
|
||||
if (numlaggers < D_NumPlayers() - 1)
|
||||
if (nonlaggers > 0)
|
||||
{
|
||||
for (i = 1; i < MAXPLAYERS; i++)
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (playeringame[i] && laggers[i])
|
||||
{
|
||||
pingtimeout[i]++;
|
||||
if (!playeringame[i] || !pingkick[i])
|
||||
continue;
|
||||
|
||||
// ok your net has been bad for too long, you deserve to die.
|
||||
if (pingtimeout[i] > cv_pingtimeout.value)
|
||||
{
|
||||
pingtimeout[i] = 0;
|
||||
SendKick(i, KICK_MSG_PING_HIGH);
|
||||
}
|
||||
}
|
||||
/*
|
||||
you aren't lagging,
|
||||
but you aren't free yet.
|
||||
In case you'll keep spiking,
|
||||
we just make the timer go back down. (Very unstable net must still get kicked).
|
||||
*/
|
||||
else
|
||||
pingtimeout[i] = (pingtimeout[i] == 0 ? 0 : pingtimeout[i]-1);
|
||||
// Don't kick on ping alone if we haven't reached our threshold yet.
|
||||
if (++pingtimeout[i] < cv_pingtimeout.value)
|
||||
continue;
|
||||
|
||||
pingtimeout[i] = 0;
|
||||
SendKick(i, KICK_MSG_PING_HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5805,6 +5808,9 @@ void NetKeepAlive(void)
|
|||
FileSendTicker();
|
||||
}
|
||||
|
||||
// If a tree falls in the forest but nobody is around to hear it, does it make a tic?
|
||||
#define DEDICATEDIDLETIME (10*TICRATE)
|
||||
|
||||
void NetUpdate(void)
|
||||
{
|
||||
static tic_t resptime = 0;
|
||||
|
|
@ -5817,6 +5823,7 @@ void NetUpdate(void)
|
|||
|
||||
if (realtics <= 0) // nothing new to update
|
||||
return;
|
||||
|
||||
if (realtics > 5)
|
||||
{
|
||||
if (server)
|
||||
|
|
@ -5825,6 +5832,55 @@ void NetUpdate(void)
|
|||
realtics = 5;
|
||||
}
|
||||
|
||||
#ifdef DEDICATEDIDLETIME
|
||||
if (server && dedicated && gamestate == GS_LEVEL)
|
||||
{
|
||||
static tic_t dedicatedidle = 0;
|
||||
|
||||
for (i = 1; i < MAXNETNODES; ++i)
|
||||
if (nodeingame[i])
|
||||
{
|
||||
if (dedicatedidle == DEDICATEDIDLETIME)
|
||||
{
|
||||
CONS_Printf("DEDICATED: Awakening from idle (Node %d detected...)\n", i);
|
||||
dedicatedidle = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == MAXNETNODES)
|
||||
{
|
||||
if (leveltime == 2)
|
||||
{
|
||||
// On next tick...
|
||||
dedicatedidle = DEDICATEDIDLETIME-1;
|
||||
}
|
||||
else if (dedicatedidle == DEDICATEDIDLETIME)
|
||||
{
|
||||
if (D_GetExistingTextcmd(gametic, 0) || D_GetExistingTextcmd(gametic+1, 0))
|
||||
{
|
||||
CONS_Printf("DEDICATED: Awakening from idle (Netxcmd detected...)\n");
|
||||
dedicatedidle = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
realtics = 0;
|
||||
}
|
||||
}
|
||||
else if ((dedicatedidle += realtics) >= DEDICATEDIDLETIME)
|
||||
{
|
||||
const char *idlereason = "at round start";
|
||||
if (leveltime > 3)
|
||||
idlereason = va("for %d seconds", dedicatedidle/TICRATE);
|
||||
|
||||
CONS_Printf("DEDICATED: No nodes %s, idling...\n", idlereason);
|
||||
realtics = 0;
|
||||
dedicatedidle = DEDICATEDIDLETIME;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
gametime = nowtime;
|
||||
|
||||
UpdatePingTable();
|
||||
|
|
@ -5862,25 +5918,26 @@ void NetUpdate(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!demo.playback)
|
||||
if (!demo.playback && realtics > 0)
|
||||
{
|
||||
INT32 counts;
|
||||
|
||||
hu_redownloadinggamestate = false;
|
||||
|
||||
firstticstosend = gametic;
|
||||
for (i = 0; i < MAXNETNODES; i++)
|
||||
if (nodeingame[i] && nettics[i] < firstticstosend)
|
||||
{
|
||||
firstticstosend = nettics[i];
|
||||
|
||||
if (maketic + 1 >= nettics[i] + BACKUPTICS)
|
||||
Net_ConnectionTimeout(i);
|
||||
}
|
||||
|
||||
// Don't erase tics not acknowledged
|
||||
counts = realtics;
|
||||
|
||||
firstticstosend = gametic;
|
||||
for (i = 0; i < MAXNETNODES; i++)
|
||||
{
|
||||
if (!nodeingame[i])
|
||||
continue;
|
||||
if (nettics[i] < firstticstosend)
|
||||
firstticstosend = nettics[i];
|
||||
if (maketic + counts >= nettics[i] + (BACKUPTICS - TICRATE))
|
||||
Net_ConnectionTimeout(i);
|
||||
}
|
||||
|
||||
if (maketic + counts >= firstticstosend + BACKUPTICS)
|
||||
counts = firstticstosend+BACKUPTICS-maketic-1;
|
||||
|
||||
|
|
|
|||
29
src/d_main.c
29
src/d_main.c
|
|
@ -1203,8 +1203,7 @@ D_ConvertVersionNumbers (void)
|
|||
void D_SRB2Main(void)
|
||||
{
|
||||
INT32 i, p;
|
||||
|
||||
INT32 pstartmap = 1;
|
||||
INT32 pstartmap = 0;
|
||||
boolean autostart = false;
|
||||
|
||||
/* break the version string into version numbers, for netplay */
|
||||
|
|
@ -1756,11 +1755,14 @@ void D_SRB2Main(void)
|
|||
|
||||
// Has to be done before anything else so skin, color, etc in command buffer has an affect.
|
||||
// ttlprofilen used because it's roughly equivalent in functionality - a QoL aid for quickly getting from startup to action
|
||||
PR_ApplyProfile(cv_ttlprofilen.value, 0);
|
||||
|
||||
for (i = 1; i < cv_splitplayers.value; i++)
|
||||
if (!dedicated)
|
||||
{
|
||||
PR_ApplyProfile(cv_lastprofile[i].value, i);
|
||||
PR_ApplyProfile(cv_ttlprofilen.value, 0);
|
||||
|
||||
for (i = 1; i < cv_splitplayers.value; i++)
|
||||
{
|
||||
PR_ApplyProfile(cv_lastprofile[i].value, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (autostart || netgame)
|
||||
|
|
@ -1842,8 +1844,13 @@ void D_SRB2Main(void)
|
|||
CV_SetValue(&cv_kartspeed, newskill);
|
||||
}
|
||||
|
||||
if (server && !M_CheckParm("+map"))
|
||||
if (server && (dedicated || !M_CheckParm("+map")))
|
||||
{
|
||||
if (!pstartmap && (pstartmap = G_GetFirstMapOfGametype(gametype)+1) > nummapheaders)
|
||||
{
|
||||
I_Error("Can't get first map of gametype\n");
|
||||
}
|
||||
|
||||
if (M_MapLocked(pstartmap))
|
||||
{
|
||||
G_SetUsedCheats();
|
||||
|
|
@ -1865,14 +1872,6 @@ void D_SRB2Main(void)
|
|||
|
||||
CON_ToggleOff();
|
||||
|
||||
if (dedicated && server)
|
||||
{
|
||||
levelstarttic = gametic;
|
||||
G_SetGamestate(GS_LEVEL);
|
||||
if (!P_LoadLevel(false, false))
|
||||
I_Quit(); // fail so reset game stuff
|
||||
}
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
if (! dedicated)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -801,8 +801,6 @@ void D_RegisterServerCommands(void)
|
|||
CV_RegisterVar(&cv_pingmeasurement);
|
||||
CV_RegisterVar(&cv_showviewpointtext);
|
||||
|
||||
CV_RegisterVar(&cv_director);
|
||||
|
||||
CV_RegisterVar(&cv_schedule);
|
||||
CV_RegisterVar(&cv_automate);
|
||||
CV_RegisterVar(&cv_livestudioaudience);
|
||||
|
|
@ -815,6 +813,23 @@ void D_RegisterServerCommands(void)
|
|||
|
||||
CV_RegisterVar(&cv_discordinvites);
|
||||
RegisterNetXCmd(XD_DISCORD, Got_DiscordInfo);
|
||||
|
||||
COM_AddCommand("numthinkers", Command_Numthinkers_f);
|
||||
COM_AddCommand("countmobjs", Command_CountMobjs_f);
|
||||
|
||||
CV_RegisterVar(&cv_recordmultiplayerdemos);
|
||||
CV_RegisterVar(&cv_netdemosyncquality);
|
||||
|
||||
CV_RegisterVar(&cv_shoutname);
|
||||
CV_RegisterVar(&cv_shoutcolor);
|
||||
CV_RegisterVar(&cv_autoshout);
|
||||
|
||||
#ifdef _DEBUG
|
||||
COM_AddCommand("causecfail", Command_CauseCfail_f);
|
||||
#endif
|
||||
#ifdef LUA_ALLOW_BYTECODE
|
||||
COM_AddCommand("dumplua", Command_Dumplua_f);
|
||||
#endif
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
|
@ -838,9 +853,6 @@ void D_RegisterClientCommands(void)
|
|||
if (dedicated)
|
||||
return;
|
||||
|
||||
COM_AddCommand("numthinkers", Command_Numthinkers_f);
|
||||
COM_AddCommand("countmobjs", Command_CountMobjs_f);
|
||||
|
||||
COM_AddCommand("changeteam", Command_Teamchange_f);
|
||||
COM_AddCommand("changeteam2", Command_Teamchange2_f);
|
||||
COM_AddCommand("changeteam3", Command_Teamchange3_f);
|
||||
|
|
@ -936,9 +948,6 @@ void D_RegisterClientCommands(void)
|
|||
|
||||
COM_AddCommand("displayplayer", Command_Displayplayer_f);
|
||||
|
||||
CV_RegisterVar(&cv_recordmultiplayerdemos);
|
||||
CV_RegisterVar(&cv_netdemosyncquality);
|
||||
|
||||
// FIXME: not to be here.. but needs be done for config loading
|
||||
CV_RegisterVar(&cv_globalgamma);
|
||||
CV_RegisterVar(&cv_globalsaturation);
|
||||
|
|
@ -977,10 +986,6 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_chatnotifications);
|
||||
CV_RegisterVar(&cv_chatbacktint);
|
||||
|
||||
CV_RegisterVar(&cv_shoutname);
|
||||
CV_RegisterVar(&cv_shoutcolor);
|
||||
CV_RegisterVar(&cv_autoshout);
|
||||
|
||||
CV_RegisterVar(&cv_songcredits);
|
||||
CV_RegisterVar(&cv_tutorialprompt);
|
||||
CV_RegisterVar(&cv_showfocuslost);
|
||||
|
|
@ -1028,7 +1033,6 @@ void D_RegisterClientCommands(void)
|
|||
// screen.c
|
||||
CV_RegisterVar(&cv_fullscreen);
|
||||
CV_RegisterVar(&cv_renderview);
|
||||
CV_RegisterVar(&cv_renderhitbox);
|
||||
CV_RegisterVar(&cv_vhseffect);
|
||||
CV_RegisterVar(&cv_shittyscreen);
|
||||
CV_RegisterVar(&cv_renderer);
|
||||
|
|
@ -1036,6 +1040,8 @@ void D_RegisterClientCommands(void)
|
|||
CV_RegisterVar(&cv_scr_width);
|
||||
CV_RegisterVar(&cv_scr_height);
|
||||
|
||||
CV_RegisterVar(&cv_director);
|
||||
|
||||
CV_RegisterVar(&cv_soundtest);
|
||||
|
||||
CV_RegisterVar(&cv_invincmusicfade);
|
||||
|
|
@ -1056,7 +1062,7 @@ void D_RegisterClientCommands(void)
|
|||
// CV_RegisterVar(&cv_grid);
|
||||
// CV_RegisterVar(&cv_snapto);
|
||||
|
||||
// add cheat commands
|
||||
// add cheats
|
||||
COM_AddCommand("noclip", Command_CheatNoClip_f);
|
||||
COM_AddCommand("god", Command_CheatGod_f);
|
||||
COM_AddCommand("setrings", Command_Setrings_f);
|
||||
|
|
@ -1071,12 +1077,7 @@ void D_RegisterClientCommands(void)
|
|||
COM_AddCommand("skynum", Command_Skynum_f);
|
||||
COM_AddCommand("weather", Command_Weather_f);
|
||||
COM_AddCommand("grayscale", Command_Grayscale_f);
|
||||
#ifdef _DEBUG
|
||||
COM_AddCommand("causecfail", Command_CauseCfail_f);
|
||||
#endif
|
||||
#ifdef LUA_ALLOW_BYTECODE
|
||||
COM_AddCommand("dumplua", Command_Dumplua_f);
|
||||
#endif
|
||||
CV_RegisterVar(&cv_renderhitbox);
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
CV_RegisterVar(&cv_discordrp);
|
||||
|
|
|
|||
|
|
@ -449,9 +449,10 @@ void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum)
|
|||
profile_t *p = PR_GetProfile(profilenum);
|
||||
|
||||
// this CAN happen!!
|
||||
if (p == NULL)
|
||||
if (dedicated || p == NULL)
|
||||
{
|
||||
CONS_Printf("Profile '%d' could not be loaded as it does not exist. Guest Profile will be loaded instead.\n", profilenum);
|
||||
if (!dedicated)
|
||||
CONS_Printf("Profile '%d' could not be loaded as it does not exist. Guest Profile will be loaded instead.\n", profilenum);
|
||||
profilenum = 0; // make sure to set this so that the cvar is set properly.
|
||||
p = PR_GetProfile(profilenum);
|
||||
}
|
||||
|
|
@ -481,9 +482,10 @@ void PR_ApplyProfilePretend(UINT8 profilenum, UINT8 playernum)
|
|||
profile_t *p = PR_GetProfile(profilenum);
|
||||
|
||||
// this CAN happen!!
|
||||
if (p == NULL)
|
||||
if (dedicated || p == NULL)
|
||||
{
|
||||
CONS_Printf("Profile '%d' could not be loaded as it does not exist. Guest Profile will be loaded instead.\n", profilenum);
|
||||
if (!dedicated)
|
||||
CONS_Printf("Profile '%d' could not be loaded as it does not exist. Guest Profile will be loaded instead.\n", profilenum);
|
||||
profilenum = 0; // make sure to set this so that the cvar is set properly.
|
||||
p = PR_GetProfile(profilenum);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue