mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Reimplement midgame Pause Menu flow for Spectate status change
- Currently no console command, as "teamchange" no longer applies... relatively simple to add one if needed though - Change the "Team Change" warning when allowteamchange is false to say "Joining Play"
This commit is contained in:
parent
27f5da1fd5
commit
b62892ba1c
3 changed files with 41 additions and 47 deletions
|
|
@ -3480,10 +3480,18 @@ void P_SetPlayerSpectator(INT32 playernum)
|
||||||
static void Got_Spectate(const UINT8 **cp, INT32 playernum)
|
static void Got_Spectate(const UINT8 **cp, INT32 playernum)
|
||||||
{
|
{
|
||||||
UINT8 edit_player = READUINT8(*cp);
|
UINT8 edit_player = READUINT8(*cp);
|
||||||
|
UINT8 desired_state = READUINT8(*cp);
|
||||||
|
|
||||||
if (playernum != serverplayer && IsPlayerAdmin(playernum) == false)
|
if (playeringame[edit_player] == false)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playernum != playerconsole[edit_player]
|
||||||
|
&& playernum != serverplayer
|
||||||
|
&& IsPlayerAdmin(playernum) == false)
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_WARNING, M_GetText("Illegal spectate command received from player %s\n"), player_names[playernum]);
|
||||||
if (server)
|
if (server)
|
||||||
{
|
{
|
||||||
SendKick(playernum, KICK_MSG_CON_FAIL);
|
SendKick(playernum, KICK_MSG_CON_FAIL);
|
||||||
|
|
@ -3497,14 +3505,8 @@ static void Got_Spectate(const UINT8 **cp, INT32 playernum)
|
||||||
}
|
}
|
||||||
|
|
||||||
player_t *const player = &players[edit_player];
|
player_t *const player = &players[edit_player];
|
||||||
if (player->spectator == true && (player->pflags & PF_WANTSTOJOIN) == 0)
|
|
||||||
{
|
|
||||||
// No change would occur.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Safety first!
|
// Safety first!
|
||||||
// (not respawning spectators here...)
|
|
||||||
const boolean was_spectator = (player->spectator == true);
|
const boolean was_spectator = (player->spectator == true);
|
||||||
if (was_spectator == false)
|
if (was_spectator == false)
|
||||||
{
|
{
|
||||||
|
|
@ -3519,7 +3521,14 @@ static void Got_Spectate(const UINT8 **cp, INT32 playernum)
|
||||||
HU_AddChatText(va("\x82*%s became a spectator.", player_names[edit_player]), false);
|
HU_AddChatText(va("\x82*%s became a spectator.", player_names[edit_player]), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
player->pflags &= ~PF_WANTSTOJOIN;
|
if (desired_state != 0)
|
||||||
|
{
|
||||||
|
player->pflags |= PF_WANTSTOJOIN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player->pflags &= ~PF_WANTSTOJOIN;
|
||||||
|
}
|
||||||
|
|
||||||
if (gamestate != GS_LEVEL || was_spectator == true)
|
if (gamestate != GS_LEVEL || was_spectator == true)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
/// \file menus/transient/pause-game.c
|
/// \file menus/transient/pause-game.c
|
||||||
/// \brief In-game/pause menus
|
/// \brief In-game/pause menus
|
||||||
|
|
||||||
|
#include "../../byteptr.h"
|
||||||
#include "../../d_netcmd.h"
|
#include "../../d_netcmd.h"
|
||||||
#include "../../i_time.h"
|
#include "../../i_time.h"
|
||||||
#include "../../k_menu.h"
|
#include "../../k_menu.h"
|
||||||
|
|
@ -478,50 +479,33 @@ void M_HandleSpectateToggle(INT32 choice)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean tospectator = false;
|
// Identify relevant spectator state of pausemenu.splitscreenfocusid.
|
||||||
|
// See also M_DrawPause.
|
||||||
|
|
||||||
|
const UINT8 splitspecid =
|
||||||
|
g_localplayers[pausemenu.splitscreenfocusid];
|
||||||
|
|
||||||
|
const UINT8 joingame = (
|
||||||
|
players[splitspecid].spectator == true
|
||||||
|
&& ((players[splitspecid].pflags & PF_WANTSTOJOIN) == 0)
|
||||||
|
) ? 1 : 0;
|
||||||
|
|
||||||
|
if (joingame && !cv_allowteamchange.value)
|
||||||
{
|
{
|
||||||
// Identify relevant spectator state of pausemenu.splitscreenfocusid.
|
M_StartMessage("Joining Play", M_GetText("The server is not allowing\njoining play at this time.\n"), NULL, MM_NOTHING, NULL, NULL);
|
||||||
// See also M_DrawPause.
|
|
||||||
|
|
||||||
const UINT8 splitspecid =
|
|
||||||
g_localplayers[pausemenu.splitscreenfocusid];
|
|
||||||
|
|
||||||
tospectator = (
|
|
||||||
players[splitspecid].spectator == false
|
|
||||||
|| (players[splitspecid].pflags & PF_WANTSTOJOIN)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tospectator && !cv_allowteamchange.value)
|
|
||||||
{
|
|
||||||
M_StartMessage("Team Change", M_GetText("The server is not allowing\nteam changes at this time.\n"), NULL, MM_NOTHING, NULL, NULL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
M_QuitPauseMenu(-1);
|
M_QuitPauseMenu(-1);
|
||||||
|
|
||||||
const char *destinationstate = tospectator ? "spectator" : "playing";
|
// Send spectate
|
||||||
|
UINT8 buf[2];
|
||||||
|
UINT8 *p = buf;
|
||||||
|
|
||||||
// These console command names...
|
WRITEUINT8(p, splitspecid);
|
||||||
if (pausemenu.splitscreenfocusid == 0)
|
WRITEUINT8(p, joingame);
|
||||||
{
|
|
||||||
COM_ImmedExecute(
|
SendNetXCmd(XD_SPECTATE, &buf, p - buf);
|
||||||
va(
|
|
||||||
"changeteam %s",
|
|
||||||
destinationstate
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
COM_ImmedExecute(
|
|
||||||
va(
|
|
||||||
"changeteam%u %s",
|
|
||||||
pausemenu.splitscreenfocusid + 1,
|
|
||||||
destinationstate
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4866,10 +4866,11 @@ void P_CheckRaceGriefing(player_t *player, boolean dopunishment)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Send spectate
|
// Send spectate
|
||||||
UINT8 buf[1];
|
UINT8 buf[2];
|
||||||
UINT8 *p = buf;
|
UINT8 *p = buf;
|
||||||
|
|
||||||
WRITEUINT8(p, n);
|
WRITEUINT8(p, n);
|
||||||
|
WRITEUINT8(p, 0);
|
||||||
|
|
||||||
SendNetXCmd(XD_SPECTATE, &buf, p - buf);
|
SendNetXCmd(XD_SPECTATE, &buf, p - buf);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue