mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add a minimum delay between connections
This commit is contained in:
parent
8fb68b025f
commit
ccf4bbe194
3 changed files with 24 additions and 1 deletions
|
|
@ -85,6 +85,10 @@ tic_t jointimeout = (10*TICRATE);
|
||||||
static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame?
|
static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame?
|
||||||
static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout?
|
static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout?
|
||||||
|
|
||||||
|
// Incremented by cv_joindelay when a client joins, decremented each tic.
|
||||||
|
// If higher than cv_joindelay * 2 (3 joins in a short timespan), joins are temporarily disabled.
|
||||||
|
static tic_t joindelay = 0;
|
||||||
|
|
||||||
UINT16 pingmeasurecount = 1;
|
UINT16 pingmeasurecount = 1;
|
||||||
UINT32 realpingtable[MAXPLAYERS]; //the base table of ping where an average will be sent to everyone.
|
UINT32 realpingtable[MAXPLAYERS]; //the base table of ping where an average will be sent to everyone.
|
||||||
UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values.
|
UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values.
|
||||||
|
|
@ -3077,6 +3081,8 @@ consvar_t cv_allownewplayer = {"allowjoin", "On", CV_NETVAR, CV_OnOff, NULL, 0,
|
||||||
consvar_t cv_joinnextround = {"joinnextround", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done
|
consvar_t cv_joinnextround = {"joinnextround", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done
|
||||||
static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}};
|
static CV_PossibleValue_t maxplayers_cons_t[] = {{2, "MIN"}, {32, "MAX"}, {0, NULL}};
|
||||||
consvar_t cv_maxplayers = {"maxplayers", "8", CV_SAVE, maxplayers_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_maxplayers = {"maxplayers", "8", CV_SAVE, maxplayers_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
static CV_PossibleValue_t joindelay_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, "Off"}, {0, NULL}};
|
||||||
|
consvar_t cv_joindelay = {"joindelay", "10", CV_SAVE, joindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
static CV_PossibleValue_t rejointimeout_cons_t[] = {{1, "MIN"}, {60 * FRACUNIT, "MAX"}, {0, "Off"}, {0, NULL}};
|
static CV_PossibleValue_t rejointimeout_cons_t[] = {{1, "MIN"}, {60 * FRACUNIT, "MAX"}, {0, "Off"}, {0, NULL}};
|
||||||
consvar_t cv_rejointimeout = {"rejointimeout", "Off", CV_SAVE|CV_FLOAT, rejointimeout_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_rejointimeout = {"rejointimeout", "Off", CV_SAVE|CV_FLOAT, rejointimeout_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
|
@ -3164,6 +3170,8 @@ void SV_ResetServer(void)
|
||||||
neededtic = maketic;
|
neededtic = maketic;
|
||||||
tictoclear = maketic;
|
tictoclear = maketic;
|
||||||
|
|
||||||
|
joindelay = 0;
|
||||||
|
|
||||||
for (i = 0; i < MAXNETNODES; i++)
|
for (i = 0; i < MAXNETNODES; i++)
|
||||||
ResetNode(i);
|
ResetNode(i);
|
||||||
|
|
||||||
|
|
@ -3613,6 +3621,9 @@ static void HandleConnect(SINT8 node)
|
||||||
SV_SendRefuse(node, M_GetText("No players from\nthis node."));
|
SV_SendRefuse(node, M_GetText("No players from\nthis node."));
|
||||||
else if (luafiletransfers)
|
else if (luafiletransfers)
|
||||||
SV_SendRefuse(node, M_GetText("The server is broadcasting a file\nrequested by a Lua script.\nPlease wait a bit and then\ntry rejoining."));
|
SV_SendRefuse(node, M_GetText("The server is broadcasting a file\nrequested by a Lua script.\nPlease wait a bit and then\ntry rejoining."));
|
||||||
|
else if (netgame && joindelay > 2 * (tic_t)cv_joindelay.value * TICRATE)
|
||||||
|
SV_SendRefuse(node, va(M_GetText("Too many people are connecting.\nPlease wait %d seconds and then\ntry rejoining."),
|
||||||
|
(joindelay - 2 * cv_joindelay.value * TICRATE) / TICRATE));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
|
|
@ -3670,6 +3681,7 @@ static void HandleConnect(SINT8 node)
|
||||||
DEBFILE("send savegame\n");
|
DEBFILE("send savegame\n");
|
||||||
}
|
}
|
||||||
SV_AddWaitingPlayers(names[0], names[1]);
|
SV_AddWaitingPlayers(names[0], names[1]);
|
||||||
|
joindelay += cv_joindelay.value * TICRATE;
|
||||||
player_joining = true;
|
player_joining = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
@ -5038,12 +5050,21 @@ void NetUpdate(void)
|
||||||
hu_resynching = true;
|
hu_resynching = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Net_AckTicker();
|
Net_AckTicker();
|
||||||
|
|
||||||
// Handle timeouts to prevent definitive freezes from happenning
|
// Handle timeouts to prevent definitive freezes from happenning
|
||||||
if (server)
|
if (server)
|
||||||
|
{
|
||||||
for (i = 1; i < MAXNETNODES; i++)
|
for (i = 1; i < MAXNETNODES; i++)
|
||||||
if (nodeingame[i] && freezetimeout[i] < I_GetTime())
|
if (nodeingame[i] && freezetimeout[i] < I_GetTime())
|
||||||
Net_ConnectionTimeout(i);
|
Net_ConnectionTimeout(i);
|
||||||
|
|
||||||
|
// In case the cvar value was lowered
|
||||||
|
if (joindelay)
|
||||||
|
joindelay = min(joindelay - 1, 3 * cv_joindelay.value * TICRATE);
|
||||||
|
}
|
||||||
|
|
||||||
nowtime /= NEWTICRATERATIO;
|
nowtime /= NEWTICRATERATIO;
|
||||||
if (nowtime > resptime)
|
if (nowtime > resptime)
|
||||||
{
|
{
|
||||||
|
|
@ -5051,6 +5072,7 @@ void NetUpdate(void)
|
||||||
M_Ticker();
|
M_Ticker();
|
||||||
CON_Ticker();
|
CON_Ticker();
|
||||||
}
|
}
|
||||||
|
|
||||||
SV_FileSendTicker();
|
SV_FileSendTicker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -515,7 +515,7 @@ extern UINT32 realpingtable[MAXPLAYERS];
|
||||||
extern UINT32 playerpingtable[MAXPLAYERS];
|
extern UINT32 playerpingtable[MAXPLAYERS];
|
||||||
extern tic_t servermaxping;
|
extern tic_t servermaxping;
|
||||||
|
|
||||||
extern consvar_t cv_allownewplayer, cv_joinnextround, cv_maxplayers, cv_rejointimeout;
|
extern consvar_t cv_allownewplayer, cv_joinnextround, cv_maxplayers, cv_joindelay, cv_rejointimeout;
|
||||||
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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -573,6 +573,7 @@ void D_RegisterServerCommands(void)
|
||||||
|
|
||||||
// d_clisrv
|
// d_clisrv
|
||||||
CV_RegisterVar(&cv_maxplayers);
|
CV_RegisterVar(&cv_maxplayers);
|
||||||
|
CV_RegisterVar(&cv_joindelay);
|
||||||
CV_RegisterVar(&cv_rejointimeout);
|
CV_RegisterVar(&cv_rejointimeout);
|
||||||
CV_RegisterVar(&cv_resynchattempts);
|
CV_RegisterVar(&cv_resynchattempts);
|
||||||
CV_RegisterVar(&cv_maxsend);
|
CV_RegisterVar(&cv_maxsend);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue