Z-vote is now server-authoriative

- Only calls callback if you're the server (and not demo.playback, forward thinking for stored xcmd netreplays)
- G_GamestateUsesExitLevel() for homogenising the conditions that permit XD_EXITLEVEL to be dispatched and recieved
This commit is contained in:
toaster 2023-06-27 14:16:48 +01:00
parent 07fa5fff01
commit ec8a6247c2
3 changed files with 34 additions and 7 deletions

View file

@ -5646,6 +5646,22 @@ static void Command_Mapmd5_f(void)
CONS_Printf(M_GetText("You must be in a level to use this.\n")); CONS_Printf(M_GetText("You must be in a level to use this.\n"));
} }
boolean G_GamestateUsesExitLevel(void)
{
if (demo.playback)
return false;
switch (gamestate)
{
case GS_LEVEL:
case GS_CREDITS:
return true;
default:
return false;
}
}
static void Command_ExitLevel_f(void) static void Command_ExitLevel_f(void)
{ {
if (!(server || (IsPlayerAdmin(consoleplayer)))) if (!(server || (IsPlayerAdmin(consoleplayer))))
@ -5656,7 +5672,7 @@ static void Command_ExitLevel_f(void)
{ {
CONS_Printf(M_GetText("This cannot be used without cheats enabled.\n")); CONS_Printf(M_GetText("This cannot be used without cheats enabled.\n"));
} }
else if (( gamestate != GS_LEVEL && gamestate != GS_CREDITS ) || demo.playback) else if (G_GamestateUsesExitLevel() == false)
{ {
CONS_Printf(M_GetText("You must be in a level to use this.\n")); CONS_Printf(M_GetText("You must be in a level to use this.\n"));
} }
@ -5682,6 +5698,9 @@ static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum)
return; return;
} }
if (G_GamestateUsesExitLevel() == false)
return;
G_ExitLevel(); G_ExitLevel();
} }

View file

@ -241,6 +241,7 @@ void WeaponPref_Parse(UINT8 **cp, INT32 playernum);
void D_SendPlayerConfig(UINT8 n); void D_SendPlayerConfig(UINT8 n);
void Command_ExitGame_f(void); void Command_ExitGame_f(void);
void Command_Retry_f(void); void Command_Retry_f(void);
boolean G_GamestateUsesExitLevel(void);
void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore
void D_MapChange(UINT16 pmapnum, INT32 pgametype, boolean pencoremode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pforcespecialstage); void D_MapChange(UINT16 pmapnum, INT32 pgametype, boolean pencoremode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pforcespecialstage);
void D_SetupVote(void); void D_SetupVote(void);

View file

@ -57,10 +57,7 @@ static void K_MidVoteKick(void)
return; return;
} }
if (server) SendKick(g_midVote.victim - players, KICK_MSG_VOTE_KICK);
{
SendKick(g_midVote.victim - players, KICK_MSG_VOTE_KICK);
}
} }
/*-------------------------------------------------- /*--------------------------------------------------
@ -70,7 +67,13 @@ static void K_MidVoteKick(void)
--------------------------------------------------*/ --------------------------------------------------*/
static void K_MidVoteRockTheVote(void) static void K_MidVoteRockTheVote(void)
{ {
G_ExitLevel(); if (G_GamestateUsesExitLevel() == false)
{
return;
}
SendNetXCmd(XD_EXITLEVEL, NULL, 0);
}
} }
static midVoteTypeDef_t g_midVoteTypeDefs[MVT__MAX] = static midVoteTypeDef_t g_midVoteTypeDefs[MVT__MAX] =
@ -630,7 +633,11 @@ void K_MidVoteFinalize(fixed_t delayMul)
--------------------------------------------------*/ --------------------------------------------------*/
void K_MidVoteSuccess(void) void K_MidVoteSuccess(void)
{ {
if (g_midVoteTypeDefs[ g_midVote.type ].callback != NULL) if (
server == true
&& demo.playback == false
&& g_midVoteTypeDefs[ g_midVote.type ].callback != NULL
)
{ {
g_midVoteTypeDefs[ g_midVote.type ].callback(); g_midVoteTypeDefs[ g_midVote.type ].callback();
} }