Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
TehRealSalt committed Feb 6, 2019
2 parents 258a426 + 8e41f09 commit 276e2d3
Show file tree
Hide file tree
Showing 42 changed files with 904 additions and 677 deletions.
112 changes: 95 additions & 17 deletions src/d_clisrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -4083,6 +4083,21 @@ FILESTAMP
else if (resynch_score[node])
--resynch_score[node];
break;
case PT_BASICKEEPALIVE:
if (client)
break;

// This should probably still timeout though, as the node should always have a player 1 number
if (netconsole == -1)
break;

// If a client sends this it should mean they are done receiving the savegame
sendingsavegame[node] = false;

// As long as clients send keep alives, the server can keep running, so reset the timeout
/// \todo Use a separate cvar for that kind of timeout?
freezetimeout[node] = I_GetTime() + connectiontimeout;
break;
case PT_TEXTCMD:
case PT_TEXTCMD2:
case PT_TEXTCMD3:
Expand Down Expand Up @@ -4586,6 +4601,15 @@ static INT16 Consistancy(void)
return (INT16)(ret & 0xFFFF);
}

// confusing, but this DOESN'T send PT_NODEKEEPALIVE, it sends PT_BASICKEEPALIVE
// used during wipes to tell the server that a node is still connected
static void CL_SendClientKeepAlive(void)
{
netbuffer->packettype = PT_BASICKEEPALIVE;

HSendPacket(servernode, false, 0, 0);
}

// send the client packet to the server
static void CL_SendClientCmd(void)
{
Expand Down Expand Up @@ -5032,9 +5056,77 @@ static inline void PingUpdate(void)
}
#endif

static tic_t gametime = 0;

#ifdef NEWPING
static void UpdatePingTable(void)
{
INT32 i;
if (server)
{
if (netgame && !(gametime % 255))
PingUpdate();
// update node latency values so we can take an average later.
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i])
realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i]));
pingmeasurecount++;
}
}
#endif

// Handle timeouts to prevent definitive freezes from happenning
static void HandleNodeTimeouts(void)
{
INT32 i;
if (server)
for (i = 1; i < MAXNETNODES; i++)
if (nodeingame[i] && freezetimeout[i] < I_GetTime())
Net_ConnectionTimeout(i);
}

// Keep the network alive while not advancing tics!
void NetKeepAlive(void)
{
tic_t nowtime;
INT32 realtics;

nowtime = I_GetTime();
realtics = nowtime - gametime;

// return if there's no time passed since the last call
if (realtics <= 0) // nothing new to update
return;

#ifdef NEWPING
UpdatePingTable();
#endif

if (server)
CL_SendClientKeepAlive();

// Sryder: What is FILESTAMP???
FILESTAMP
GetPackets();
FILESTAMP

MasterClient_Ticker();

if (client)
{
// send keep alive
CL_SendClientKeepAlive();
// No need to check for resynch because we aren't running any tics
}
// No else because no tics are being run and we can't resynch during this

Net_AckTicker();
HandleNodeTimeouts();
SV_FileSendTicker();
}

void NetUpdate(void)
{
static tic_t gametime = 0;
static tic_t resptime = 0;
tic_t nowtime;
INT32 i;
Expand All @@ -5056,16 +5148,7 @@ void NetUpdate(void)
gametime = nowtime;

#ifdef NEWPING
if (server)
{
if (netgame && !(gametime % 255))
PingUpdate();
// update node latency values so we can take an average later.
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i])
realpingtable[i] += G_TicsToMilliseconds(GetLag(playernode[i]));
pingmeasurecount++;
}
UpdatePingTable();
#endif

if (client)
Expand Down Expand Up @@ -5133,12 +5216,7 @@ FILESTAMP
}
}
Net_AckTicker();
// Handle timeouts to prevent definitive freezes from happenning
if (server)
for (i = 1; i < MAXNETNODES; i++)
if (nodeingame[i] && freezetimeout[i] < I_GetTime())
Net_ConnectionTimeout(i);
nowtime /= NEWTICRATERATIO;
HandleNodeTimeouts();
if (nowtime > resptime)
{
resptime = nowtime;
Expand Down
2 changes: 2 additions & 0 deletions src/d_clisrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ typedef enum
PT_CLIENT3MIS,
PT_CLIENT4CMD, // 4P
PT_CLIENT4MIS,
PT_BASICKEEPALIVE,// Keep the network alive during wipes, as tics aren't advanced and NetUpdate isn't called

PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL
// allows HSendPacket(*, true, *, *) to return false.
Expand Down Expand Up @@ -538,6 +539,7 @@ void SendNetXCmd3(netxcmd_t id, const void *param, size_t nparam); // splitsreen
void SendNetXCmd4(netxcmd_t id, const void *param, size_t nparam); // splitsreen4 player

// Create any new ticcmds and broadcast to other players.
void NetKeepAlive(void);
void NetUpdate(void);

void SV_StartSinglePlayerServer(void);
Expand Down
4 changes: 2 additions & 2 deletions src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ void D_SRB2Main(void)
if (s) // Check for NULL?
{
if (!W_VerifyNMUSlumps(s))
G_SetGameModified(true);
G_SetGameModified(true, false);
D_AddFile(s);
}
}
Expand All @@ -1189,7 +1189,7 @@ void D_SRB2Main(void)
else
{
if (!M_CheckParm("-server"))
G_SetGameModified(true);
G_SetGameModified(true, true);
autostart = true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/d_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,9 @@ static void DebugPrintpacket(const char *header)
(UINT32)ExpandTics(netbuffer->u.clientpak.client_tic),
(UINT32)ExpandTics (netbuffer->u.clientpak.resendfrom));
break;
case PT_BASICKEEPALIVE:
fprintf(debugfile, " keep alive\n");
break;
case PT_TEXTCMD:
case PT_TEXTCMD2:
case PT_TEXTCMD3:
Expand Down
46 changes: 32 additions & 14 deletions src/d_netcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ static consvar_t cv_dummyconsvar = {"dummyconsvar", "Off", CV_CALL|CV_NOSHOWHELP
consvar_t cv_restrictskinchange = {"restrictskinchange", "No", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_allowteamchange = {"allowteamchange", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};

static CV_PossibleValue_t ingamecap_cons_t[] = {{0, "MIN"}, {MAXPLAYERS-1, "MAX"}, {0, NULL}};
consvar_t cv_ingamecap = {"ingamecap", "0", CV_NETVAR, ingamecap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};

consvar_t cv_startinglives = {"startinglives", "3", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, startingliveslimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};

static CV_PossibleValue_t respawntime_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}};
Expand Down Expand Up @@ -642,6 +645,7 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_allowexitlevel);
CV_RegisterVar(&cv_restrictskinchange);
CV_RegisterVar(&cv_allowteamchange);
CV_RegisterVar(&cv_ingamecap);
CV_RegisterVar(&cv_respawntime);
CV_RegisterVar(&cv_killingdead);

Expand Down Expand Up @@ -2209,10 +2213,12 @@ static void Command_Map_f(void)
return;
}

if (!(netgame || multiplayer) && (!modifiedgame || savemoddata))
if (!(netgame || multiplayer) && !majormods)
{
if (COM_CheckParm("-force"))
G_SetGameModified(false);
{
G_SetGameModified(false, true);
}
else
{
CONS_Printf(M_GetText("Sorry, level change disabled in single player.\n"));
Expand Down Expand Up @@ -2496,6 +2502,12 @@ static void Command_Respawn(void)
return;
}

if (players[consoleplayer].mo && !P_IsObjectOnGround(players[consoleplayer].mo)) // KART: Nice try, but no, you won't be cheesing spb anymore.
{
CONS_Printf(M_GetText("You must be on the floor to use this.\n"));
return;
}

/*if (!G_RaceGametype()) // srb2kart: not necessary, respawning makes you lose a bumper in battle, so it's not desirable to use as a way to escape a hit
{
CONS_Printf(M_GetText("You may only use this in co-op, race, and competition!\n"));
Expand All @@ -2517,7 +2529,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum)
{
INT32 respawnplayer = READINT32(*cp);

// You can't respawn someone else. Nice try, there.
// You can't respawn someone else. Nice try, there.
if (respawnplayer != playernum) // srb2kart: "|| (!G_RaceGametype())"
{
CONS_Alert(CONS_WARNING, M_GetText("Illegal respawn command received from %s\n"), player_names[playernum]);
Expand All @@ -2532,6 +2544,10 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum)
return;
}

// incase the above checks were modified to allow sending a respawn on these occasions:
if (players[respawnplayer].mo && !P_IsObjectOnGround(players[respawnplayer].mo))
return;

if (players[respawnplayer].mo)
P_DamageMobj(players[respawnplayer].mo, NULL, NULL, 10000);
}
Expand Down Expand Up @@ -3781,7 +3797,7 @@ static void Command_RunSOC(void)
if (!P_RunSOC(fn))
CONS_Printf(M_GetText("Could not find SOC.\n"));
else
G_SetGameModified(multiplayer);
G_SetGameModified(multiplayer, false);
return;
}

Expand Down Expand Up @@ -3835,7 +3851,7 @@ static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum)
}

P_RunSOC(filename);
G_SetGameModified(true);
G_SetGameModified(true, false);
}

/** Adds a pwad at runtime.
Expand Down Expand Up @@ -3872,7 +3888,7 @@ static void Command_Addfile(void)
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
return;
}
G_SetGameModified(multiplayer);
G_SetGameModified(multiplayer, false);
}

// Add file on your client directly if it is trivial, or you aren't in a netgame.
Expand Down Expand Up @@ -4118,7 +4134,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
return;
}

G_SetGameModified(true);
G_SetGameModified(true, false);
}

static void Command_ListWADS_f(void)
Expand Down Expand Up @@ -4475,7 +4491,7 @@ static void Ringslinger_OnChange(void)
}

if (cv_ringslinger.value) // Only if it's been turned on
G_SetGameModified(multiplayer);
G_SetGameModified(multiplayer, true);
}

static void Gravity_OnChange(void)
Expand All @@ -4496,7 +4512,7 @@ static void Gravity_OnChange(void)
#endif

if (!CV_IsSetToDefault(&cv_gravity))
G_SetGameModified(multiplayer);
G_SetGameModified(multiplayer, true);
gravity = cv_gravity.value;
}

Expand Down Expand Up @@ -4892,7 +4908,7 @@ static void Fishcake_OnChange(void)
// so don't make modifiedgame always on!
if (cv_debug)
{
G_SetGameModified(multiplayer);
G_SetGameModified(multiplayer, true);
}

else if (cv_debug != cv_fishcake.value)
Expand All @@ -4908,12 +4924,14 @@ static void Fishcake_OnChange(void)
*/
static void Command_Isgamemodified_f(void)
{
if (savemoddata)
CONS_Printf(M_GetText("modifiedgame is true, but you can save medal and record data in this mod.\n"));
if (majormods)
CONS_Printf("The game has been modified with major add-ons, so you cannot play Record Attack.\n");
else if (savemoddata)
CONS_Printf("The game has been modified with an add-on with its own save data, so you can play Record Attack and earn medals.\n");
else if (modifiedgame)
CONS_Printf(M_GetText("modifiedgame is true, extras will not be unlocked\n"));
CONS_Printf("The game has been modified with only minor add-ons. You can play Record Attack, earn medals and unlock extras.\n");
else
CONS_Printf(M_GetText("modifiedgame is false, you can unlock extras\n"));
CONS_Printf("The game has not been modified. You can play Record Attack, earn medals and unlock extras.\n");
}

static void Command_Cheats_f(void)
Expand Down
2 changes: 1 addition & 1 deletion src/d_netcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ extern consvar_t cv_mute;
extern consvar_t cv_killingdead;
extern consvar_t cv_pause;

extern consvar_t cv_restrictskinchange, cv_allowteamchange, cv_respawntime;
extern consvar_t cv_restrictskinchange, cv_allowteamchange, cv_ingamecap, cv_respawntime;

/*extern consvar_t cv_teleporters, cv_superring, cv_supersneakers, cv_invincibility;
extern consvar_t cv_jumpshield, cv_watershield, cv_ringshield, cv_forceshield, cv_bombshield;
Expand Down
2 changes: 1 addition & 1 deletion src/d_netfil.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ void CL_LoadServerFiles(void)
else if (fileneeded[i].status == FS_FOUND)
{
P_AddWadFile(fileneeded[i].filename);
G_SetGameModified(true);
G_SetGameModified(true, false);
fileneeded[i].status = FS_OPEN;
}
else if (fileneeded[i].status == FS_MD5SUMBAD)
Expand Down
4 changes: 3 additions & 1 deletion src/d_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,12 @@ typedef enum
k_wanted, // Timer for determining WANTED status, lowers when hitting people, prevents the game turning into Camp Lazlo
k_yougotem, // "You Got Em" gfx when hitting someone as a karma player via a method that gets you back in the game instantly

// v1.0.2 vars
// v1.0.2+ vars
k_itemblink, // Item flashing after roulette, prevents Hyudoro stealing AND serves as a mashing indicator
k_itemblinkmode, // Type of flashing: 0 = white (normal), 1 = red (mashing), 2 = rainbow (enhanced items)
k_getsparks, // Disable drift sparks at low speed, JUST enough to give acceleration the actual headstart above speed
k_jawztargetdelay, // Delay for Jawz target switching, to make it less twitchy
k_spectatewait, // How long have you been waiting as a spectator

NUMKARTSTUFF
} kartstufftype_t;
Expand Down
Loading

0 comments on commit 276e2d3

Please sign in to comment.