From 638b3757c88cd58a170894adf08b8418f66f6c90 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 22 Apr 2025 09:26:27 +0200 Subject: [PATCH] move playeringame to player struct credits hanicef for that idea --- src/am_map.c | 7 ++-- src/d_clisrv.c | 84 ++++++++++++++++++++++++--------------------- src/d_net.c | 4 +-- src/d_netcmd.c | 48 ++++++++++++++------------ src/d_player.h | 3 +- src/dehacked.c | 4 +-- src/discord.c | 10 +++--- src/g_game.c | 69 +++++++++++++++++++++---------------- src/g_game.h | 1 - src/hu_stuff.c | 14 ++++---- src/k_director.c | 4 +-- src/k_kart.c | 62 ++++++++++++++++----------------- src/k_stats.c | 2 +- src/lua_playerlib.c | 9 ++--- src/lua_script.c | 4 +-- src/p_enemy.c | 48 +++++++++++++------------- src/p_floor.c | 6 ++-- src/p_inter.c | 30 ++++++++-------- src/p_map.c | 2 +- src/p_mobj.c | 32 ++++++++--------- src/p_saveg.c | 15 ++++---- src/p_setup.c | 8 ++--- src/p_spec.c | 6 ++-- src/p_telept.c | 2 +- src/p_tick.c | 16 ++++----- src/p_user.c | 30 ++++++++-------- src/r_main.c | 2 +- src/st_stuff.c | 2 +- src/y_inter.c | 18 +++++----- 29 files changed, 282 insertions(+), 260 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index f91273e8b..fa74ec540 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -312,12 +312,13 @@ static void AM_initVariables(void) m_h = FTOM(f_h); // find player to center on initially - if (!playeringame[pnum = consoleplayer]) + if (!players[pnum = consoleplayer].ingame) for (pnum = 0; pnum < MAXPLAYERS; pnum++) - if (playeringame[pnum]) + if (players[pnum].ingame) break; plr = &players[pnum]; + if (plr != NULL && plr->mo != NULL) { m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2; @@ -1227,7 +1228,7 @@ static inline void AM_drawPlayers(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e75eb7b33..777cb0bf7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -471,7 +471,7 @@ static void ExtraDataTicker(void) INT32 i; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] || i == 0) + if (players[i].ingame || i == 0) { UINT8 *bufferstart = D_GetExistingTextcmd(gametic, i); @@ -841,7 +841,7 @@ static void resynch_read_player(resynch_pak *rsp) players[i].splitscreenindex = rsp->splitscreenindex; //We get a packet for each player in game. - if (!playeringame[i]) + if (!players[i].ingame) return; //...but keep old mo even if it is corrupt or null! @@ -910,7 +910,7 @@ static inline void resynch_write_ctf(resynchend_pak *rst) // GF_REDFLAG is 1, GF_BLUEFLAG is 2 // redflag handling is i=0, blueflag is i=1 // so check for gotflag == (i+1) - if (!playeringame[j] || players[j].gotflag != (i+1)) + if (!players[j].ingame || players[j].gotflag != (i+1)) continue; rst->flagplayer[i] = (SINT8)j; break; @@ -943,7 +943,7 @@ static inline void resynch_read_ctf(resynchend_pak *p) ; // The server doesn't even know what happened to it... else if (p->flagplayer[0] != -1) // Held by a player { - if (!playeringame[p->flagplayer[0]]) + if (!players[p->flagplayer[0]].ingame) I_Error("Invalid red flag player %d who isn't in the game!", (INT32)p->flagplayer[0]); players[p->flagplayer[0]].gotflag = GF_REDFLAG; if (redflag) @@ -971,7 +971,7 @@ static inline void resynch_read_ctf(resynchend_pak *p) ; // The server doesn't even know what happened to it... else if (p->flagplayer[1] != -1) // Held by a player { - if (!playeringame[p->flagplayer[1]]) + if (!players[p->flagplayer[1]].ingame) I_Error("Invalid blue flag player %d who isn't in the game!", (INT32)p->flagplayer[1]); players[p->flagplayer[1]].gotflag = GF_BLUEFLAG; if (blueflag) @@ -1003,7 +1003,7 @@ static inline void resynch_write_others(resynchend_pak *rst) for (i = 0; i < MAXPLAYERS; ++i) { - if (!playeringame[i]) + if (!players[i].ingame) { rst->ctfteam[i] = 0; rst->score[i] = 0; @@ -1066,7 +1066,7 @@ static void SV_RequireResynch(INT32 node) memset(resynch_sent[node], 0, MAXPLAYERS); for (i = 0; i < MAXPLAYERS; ++i) { - if (!playeringame[i]) // Player not in game so just drop it from required synch + if (!players[i].ingame) // Player not in game so just drop it from required synch resynch_status[node] &= ~(1<u.playerinfo[i].node = 255; // This slot is empty. continue; @@ -1793,7 +1793,7 @@ static boolean SV_SendServerConfig(INT32 node) { netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; - if (!playeringame[i]) + if (!players[i].ingame) continue; netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; @@ -3301,7 +3301,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) { // Sanity check: exceptional cases (i.e. c-fails) can cause multiple // kick commands to be issued for the same player. - if (!playeringame[playernum]) + if (!players[playernum].ingame) return; demo_extradata[playernum] |= DXD_PLAYSTATE; @@ -3335,7 +3335,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) for (i = 0, count = 0; i < MAXPLAYERS; i++) { - if (playeringame[i]) + if (players[i].ingame) count++; } @@ -3345,7 +3345,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && i != playernum) + if (players[i].ingame && i != playernum) { if (rings < increment) P_GivePlayerRings(&players[i], rings); @@ -3366,9 +3366,9 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) CL_ClearPlayer(playernum); // remove avatar of player - playeringame[playernum] = false; + players[playernum].ingame = false; playernode[playernum] = UINT8_MAX; - while ((doomcom->numslots > 1) && !playeringame[doomcom->numslots-1]) + while ((doomcom->numslots > 1) && !players[doomcom->numslots-1].ingame) doomcom->numslots--; // Reset the name @@ -3394,7 +3394,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && !players[i].spectator) + if (players[i].ingame && !players[i].spectator) break; } @@ -3462,7 +3462,7 @@ static void Command_GetPlayerNum(void) INT32 i; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) + if (players[i].ingame) { if (serverplayer == i) CONS_Printf(M_GetText("num:%2d node:%2d %s\n"), i, playernode[i], player_names[i]); @@ -3485,14 +3485,14 @@ SINT8 nametonum(const char *name) if (playernum) { - if (playeringame[playernum]) + if (players[playernum].ingame) return (SINT8)playernum; else return -1; } for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !stricmp(player_names[i], name)) + if (players[i].ingame && !stricmp(player_names[i], name)) return (SINT8)i; CONS_Printf(M_GetText("There is no player named \"%s\"\n"), name); @@ -3513,13 +3513,13 @@ static void Command_Nodes(void) for (i = 0; i < MAXPLAYERS; i++) { const size_t plen = strlen(player_names[i]); - if (playeringame[i] && plen > maxlen) + if (players[i].ingame && plen > maxlen) maxlen = plen; } for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i]) + if (players[i].ingame) { CONS_Printf("%.2u: %*s", i, (int)maxlen, player_names[i]); CONS_Printf(" - %.2d", playernode[i]); @@ -3563,7 +3563,7 @@ static void Command_Listplayers(void) int n; for (i = 0; i < MAXPLAYERS; ++i) - if (playeringame[i]) + if (players[i].ingame) { n = strlen(player_names[i]); if (n > width) @@ -3584,7 +3584,7 @@ static void Command_Listplayers(void) } for (i = 0; i < MAXPLAYERS; ++i) - if (playeringame[i]) + if (players[i].ingame) { admin = IsPlayerAdmin(i); spectator = players[i].spectator; @@ -3941,7 +3941,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) continue; CONS_Printf("-------------------------------------\n"); CONS_Printf("Player %d: %s\n", i, player_names[i]); @@ -4333,7 +4333,9 @@ void SV_ResetServer(void) memset(player_name_changes, 0, sizeof player_name_changes); - memset(playeringame, false, sizeof playeringame); + for (INT32 j = 0; j < MAXPLAYERS; j++) + players[j].ingame = false; + memset(playernode, UINT8_MAX, sizeof playernode); pingmeasurecount = 1; @@ -4476,7 +4478,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) // Clear player before joining, lest some things get set incorrectly CL_ClearPlayer(newplayernum); - playeringame[newplayernum] = true; + players[newplayernum].ingame = true; G_AddPlayer(newplayernum); if (newplayernum+1 > doomcom->numslots) doomcom->numslots = (INT16)(newplayernum+1); @@ -4587,7 +4589,7 @@ static boolean SV_AddWaitingPlayers(void) newplayer = true; // search for a free playernum - // we can't use playeringame since it is not updated here + // we can't use players since it is not updated here for (; newplayernum < MAXPLAYERS; newplayernum++) { for (n = 0; n < MAXNETNODES; n++) @@ -4630,7 +4632,7 @@ static boolean SV_AddWaitingPlayers(void) SendNetXCmd(XD_ADDPLAYER, &buf, 2); DEBFILE(va("Server added player %d node %d\n", newplayernum, node)); - // use the next free slot (we can't put playeringame[newplayernum] = true here) + // use the next free slot (we can't put players[newplayernum].ingame = true here) newplayernum++; } } @@ -4752,7 +4754,7 @@ static size_t TotalTextCmdPerTic(tic_t tic) for (i = 0; i < MAXPLAYERS; i++) { UINT8 *textcmd = D_GetExistingTextcmd(tic, i); - if ((!i || playeringame[i]) && textcmd) + if ((!i || players[i].ingame) && textcmd) total += 2 + textcmd[0]; // "+2" for size and playernum } @@ -4773,7 +4775,7 @@ static void HandleConnect(SINT8 node) UINT8 connectedplayers = 0; for (UINT8 i = dedicated ? 1 : 0; i < MAXPLAYERS; i++) - if (playernode[i] != UINT8_MAX) // We use this to count players because it is affected by SV_AddWaitingPlayers when more than one client joins on the same tic, unlike playeringame and D_NumPlayers. UINT8_MAX denotes no node for that player + if (playernode[i] != UINT8_MAX) // We use this to count players because it is affected by SV_AddWaitingPlayers when more than one client joins on the same tic, unlike players and D_NumPlayers. UINT8_MAX denotes no node for that player connectedplayers++; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); @@ -5137,7 +5139,9 @@ static void PT_ServerCFG(SINT8 node) #ifdef SATURNPAK SendSaturnInfo(node); #endif - memset(playeringame, 0, sizeof(playeringame)); + + for (j = 0; j < MAXPLAYERS; j++) + players[j].ingame = false; for (j = 0; j < MAXPLAYERS; j++) { @@ -5145,7 +5149,7 @@ static void PT_ServerCFG(SINT8 node) && netbuffer->u.servercfg.playercolor[j] == 0xFF) continue; // not in game - playeringame[j] = true; + players[j].ingame = true; SetPlayerSkinByNum(j, (INT32)netbuffer->u.servercfg.playerskins[j]); players[j].skincolor = netbuffer->u.servercfg.playercolor[j]; } @@ -5648,7 +5652,7 @@ static void HandlePacketFromPlayer(SINT8 node) // nodeingame will be put false in the execution of kick command // this allow to send some packets to the quitting client to have their ack back nodewaiting[node] = 0; - if (netconsole != -1 && playeringame[netconsole]) + if (netconsole != -1 && players[netconsole].ingame) { SendKick(netconsole, (netbuffer->packettype == PT_NODETIMEOUT) ? KICK_MSG_TIMEOUT : KICK_MSG_PLAYER_QUIT); } @@ -5777,7 +5781,7 @@ static void HandlePacketFromPlayer(SINT8 node) { UINT8 i; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) + if (players[i].ingame) playerpingtable[i] = (tic_t)netbuffer->u.pingtable[i]; servermaxping = (tic_t)netbuffer->u.pingtable[MAXPLAYERS]; @@ -5907,7 +5911,7 @@ static INT16 Consistancy(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) ret ^= 0xCCCC; else if (!players[i].mo || gamestate != GS_LEVEL); else @@ -6320,7 +6324,7 @@ static void SV_SendTics(void) UINT8 *textcmd = D_GetExistingTextcmd(i, j); INT32 size = textcmd ? textcmd[0] : 0; - if ((!j || playeringame[j]) && size) + if ((!j || players[j].ingame) && size) { (*ntextcmd)++; WRITEUINT8(bufpos, j); @@ -6535,7 +6539,7 @@ static inline void PingUpdate(void) { for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || P_IsLocalPlayer(&players[i])) // should be P_IsMachineLocalPlayer for DRRR + if (!players[i].ingame || P_IsLocalPlayer(&players[i])) // should be P_IsMachineLocalPlayer for DRRR { pingtimeout[i] = 0; continue; @@ -6572,7 +6576,7 @@ static inline void PingUpdate(void) UINT8 minimumkicklevel = (nonlaggers > 0) ? PINGKICK_LIMIT : PINGKICK_TICQUEUE; for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || pingkick[i] < minimumkicklevel) + if (!players[i].ingame || pingkick[i] < minimumkicklevel) continue; if (pingkick[i] == PINGKICK_LIMIT) @@ -6634,7 +6638,7 @@ static void UpdatePingTable(void) // update node latency values so we can take an average later. for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && playernode[i] > 0 && playernode[i] != UINT8_MAX) + if (players[i].ingame && playernode[i] > 0 && playernode[i] != UINT8_MAX) { realpingtable[i] += GetLag(playernode[i]); @@ -6967,7 +6971,7 @@ INT32 D_NumPlayers(void) { INT32 num = 0, ix; for (ix = 0; ix < MAXPLAYERS; ix++) - if (playeringame[ix]) + if (players[ix].ingame) num++; return num; } diff --git a/src/d_net.c b/src/d_net.c index 180199ffc..b3d34ecd6 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1367,7 +1367,7 @@ void Command_Ping_f(void) pingc = 0; for (i = 1; i < MAXPLAYERS; ++i) { - if (playeringame[i]) + if (players[i].ingame) { INT32 ms; @@ -1416,7 +1416,7 @@ void Command_Ping_f(void) ms_width, pingv[i].ms); } - if (!server && playeringame[consoleplayer]) + if (!server && players[consoleplayer].ingame) { CONS_Printf("\nYour ping is %d frames (%d ms)\n", playerpingtable[consoleplayer], (INT32)(playerpingtable[consoleplayer] * (1000.00f / TICRATE))); } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c0a7bfb93..6e64de8b2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1260,7 +1260,7 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum) // Check if a player is currently using the name, case-insensitively. for (ix = 0; ix < MAXPLAYERS; ix++) { - if (ix != playernum && playeringame[ix] + if (ix != playernum && players[ix].ingame && strcasecmp(name, player_names[ix]) == 0) { // We shouldn't kick people out just because @@ -1377,7 +1377,7 @@ static void CleanupPlayerName(INT32 playernum, const char *newname) // no stealing another player's name for (i = 0; i < MAXPLAYERS; i++) { - if (i != playernum && playeringame[i] + if (i != playernum && players[i].ingame && strcasecmp(tmpname, player_names[i]) == 0) { break; @@ -1498,7 +1498,7 @@ static void ForceAllSkins(INT32 forcedskin) INT32 i; for (i = 0; i < MAXPLAYERS; ++i) { - if (!playeringame[i]) + if (!players[i].ingame) continue; SetPlayerSkinByNum(i, forcedskin); @@ -2160,7 +2160,7 @@ static INT32 LookupPlayer(const char *s) for (playernum = 0; playernum < MAXPLAYERS; ++playernum) { /* Match name case-insensitively: fully, or partially the start. */ - if (playeringame[playernum]) + if (players[playernum].ingame) if (strnicmp(player_names[playernum], s, strlen(s)) == 0) { return playernum; @@ -2173,13 +2173,13 @@ static INT32 FindPlayerByPlace(INT32 place) { INT32 playernum; for (playernum = 0; playernum < MAXPLAYERS; ++playernum) - if (playeringame[playernum]) - { - if (players[playernum].kartstuff[k_position] == place) + if (players[playernum].ingame) { - return playernum; + if (players[playernum].kartstuff[k_position] == place) + { + return playernum; + } } - } return -1; } @@ -2245,13 +2245,16 @@ static void Command_View_f(void) if (COM_Argc() > 1)/* switch to player */ { playerparam = COM_Argv(1); + if (playerparam[0] == '#')/* search by placement */ { placenum = atoi(&playerparam[1]); playernum = FindPlayerByPlace(placenum); + if (playernum == -1 || !G_CouldView(playernum)) { GetViewablePlayerPlaceRange(&firstplace, &lastplace); + if (playernum == -1) { CONS_Alert(CONS_WARNING, "There is no player in that place! "); @@ -2263,18 +2266,20 @@ static void Command_View_f(void) "The first player that you can view is \x82#%d\x80; ", firstplace); } + CONS_Printf("Last place is \x82#%d\x80.\n", lastplace); return; } } else { - if (( playernum = LookupPlayer(COM_Argv(1)) ) == -1) + if ((playernum = LookupPlayer(COM_Argv(1)) ) == -1) { CONS_Alert(CONS_WARNING, "There is no player by that name!\n"); return; } - if (!playeringame[playernum]) + + if (!players[playernum].ingame) { CONS_Alert(CONS_WARNING, "There is no player using that slot!\n"); return; @@ -2539,7 +2544,7 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r { //CL_RemoveSplitscreenPlayer(); botingame = false; - playeringame[1] = false; + players[1].ingame = false; } } else if (!botingame) @@ -2547,7 +2552,7 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r //CL_AddSplitscreenPlayer(); botingame = true; displayplayers[1] = 1; - playeringame[1] = true; + players[1].ingame = true; players[1].bot = 1; SendNameAndColor2(); } @@ -2615,8 +2620,9 @@ void D_PickVote(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; + if (votes[i] != -1) { temppicks[numvotes] = i; @@ -3682,7 +3688,7 @@ static void Command_ServerTeamChange_f(void) NetPacket.packet.playernum = atoi(COM_Argv(1)); - if (!playeringame[NetPacket.packet.playernum]) + if (!players[NetPacket.packet.playernum].ingame) { CONS_Alert(CONS_NOTICE, M_GetText("There is no player %d!\n"), NetPacket.packet.playernum); return; @@ -4196,7 +4202,7 @@ static void Command_Verify_f(void) WRITEUINT8(temp, playernum); - if (playeringame[playernum]) + if (players[playernum].ingame) SendNetXCmd(XD_VERIFIED, buf, 1); } @@ -4248,7 +4254,7 @@ static void Command_RemoveAdmin_f(void) WRITEUINT8(temp, playernum); - if (playeringame[playernum]) + if (players[playernum].ingame) SendNetXCmd(XD_DEMOTED, buf, 1); } @@ -4640,7 +4646,7 @@ static void Command_GLocalSkin (void) for (i = 0; i < MAXPLAYERS; ++i) { - if (!playeringame[i]) + if (!players[i].ingame) continue; SetLocalPlayerSkin(i, fuck, NULL); } @@ -5269,7 +5275,7 @@ void D_GameTypeChanged(INT32 lastgametype) { INT32 i; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) + if (players[i].ingame) players[i].ctfteam = 0; if (server || (IsPlayerAdmin(consoleplayer))) @@ -5378,7 +5384,7 @@ retryscramble: // Put each player's node in the array. for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && !players[i].spectator) + if (players[i].ingame && !players[i].spectator) { scrambleplayers[playercount] = i; playercount++; @@ -6184,7 +6190,7 @@ static void Command_ShowScores_f(void) for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i]) + if (players[i].ingame) // FIXME: %lu? what's wrong with %u? ~Callum (produces warnings...) CONS_Printf(M_GetText("%s's score is %u\n"), player_names[i], players[i].score); } diff --git a/src/d_player.h b/src/d_player.h index a1e4a0b20..64dee05a8 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -402,7 +402,7 @@ typedef struct player_s INT32 kartstuff[NUMKARTSTUFF]; angle_t frameangle; // for the player add the ability to have the sprite only face other angles angle_t old_frameangle, old_frameangle2; - + // SRB2Kart CEP: Sliptide rolling angle_t sliproll; @@ -537,6 +537,7 @@ typedef struct player_s INT32 awayviewtics; angle_t awayviewaiming; // Used for cut-away view + boolean ingame; boolean spectator; UINT8 bot; diff --git a/src/dehacked.c b/src/dehacked.c index 0ea6b8231..26a17a326 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8646,7 +8646,7 @@ static int lua_enumlib_modifiedgame_get(lua_State *L) static int lua_enumlib_server_get(lua_State *L) { - if ((!multiplayer || !(netgame || demo.playback)) && !playeringame[serverplayer]) + if ((!multiplayer || !(netgame || demo.playback)) && !players[serverplayer].ingame) return 0; LUA_PushUserdata(L, &players[serverplayer], META_PLAYER); return 1; @@ -8654,7 +8654,7 @@ static int lua_enumlib_server_get(lua_State *L) static int lua_enumlib_consoleplayer_get(lua_State *L) { - if (consoleplayer < 0 || !playeringame[consoleplayer]) + if (consoleplayer < 0 || !players[consoleplayer].ingame) return 0; LUA_PushUserdata(L, &players[consoleplayer], META_PLAYER); return 1; diff --git a/src/discord.c b/src/discord.c index e1cacdded..dc476f001 100644 --- a/src/discord.c +++ b/src/discord.c @@ -391,7 +391,7 @@ static void DRPC_GotServerIP(UINT32 address) --------------------------------------------------*/ static const char *DRPC_GetServerIP(void) { - const char *address; + const char *address; // If you're connected if (I_GetNodeAddress && (address = I_GetNodeAddress(servernode)) != NULL) @@ -466,13 +466,13 @@ static void DRPC_UpdateGameModes(void) append_to_string(gamemodes, "DriftNitro"); else if (techactive) append_to_string(gamemodes, "Tech"); - + if (weathermodactive && weathermodactive->value) append_to_string(gamemodes, "Weathermod"); if (friendmodactive && friendmodactive->value) append_to_string(gamemodes, "Friendmod"); - + if (eliminationactive && eliminationactive->value) append_to_string(gamemodes, "Elimination"); @@ -540,7 +540,7 @@ void DRPC_UpdatePresence(void) { #endif discordPresence.state = "Private"; -#ifdef MASTERSERVER +#ifdef MASTERSERVER } #endif @@ -655,7 +655,7 @@ void DRPC_UpdatePresence(void) } // Character info - if (Playing() && playeringame[consoleplayer] && !players[consoleplayer].spectator) + if (Playing() && players[consoleplayer].ingame && !players[consoleplayer].spectator) { // Supported skin names static const char *supportedSkins[] = { diff --git a/src/g_game.c b/src/g_game.c index 7acda852e..90bc895cc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -119,7 +119,6 @@ static tic_t demostarttime; // for comparative timing purposes boolean netgame; // only true if packets are broadcast boolean multiplayer; -boolean playeringame[MAXPLAYERS]; boolean addedtogame; player_t players[MAXPLAYERS]; @@ -1241,7 +1240,7 @@ static void G_DoLoadLevel(boolean resetplayer) for (i = 0; i < MAXPLAYERS; i++) { - if (resetplayer || (playeringame[i] && players[i].playerstate == PST_DEAD)) + if (resetplayer || (players[i].ingame && players[i].playerstate == PST_DEAD)) players[i].playerstate = PST_REBORN; } @@ -1607,7 +1606,7 @@ boolean G_CouldView(INT32 playernum) if (playernum < 0 || playernum > MAXPLAYERS-1) return false; - if (!playeringame[playernum]) + if (!players[playernum].ingame) return false; player = &players[playernum]; @@ -1641,7 +1640,7 @@ boolean G_CanView(INT32 playernum, UINT8 viewnum, boolean onlyactive) UINT8 viewd; INT32 *displayplayerp; - if (!(onlyactive ? G_CouldView(playernum) : (playeringame[playernum] && !players[playernum].spectator))) + if (!(onlyactive ? G_CouldView(playernum) : (players[playernum].ingame && !players[playernum].spectator))) return false; splits = splitscreen+1; @@ -1692,7 +1691,7 @@ INT32 G_CountPlayersPotentiallyViewable(boolean active) INT32 i; for (i = 0; i < MAXPLAYERS; ++i) { - if (active ? G_CouldView(i) : (playeringame[i] && !players[i].spectator)) + if (active ? G_CouldView(i) : (players[i].ingame && !players[i].spectator)) total++; } return total; @@ -1863,7 +1862,7 @@ void G_Ticker(boolean run) } for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].playerstate == PST_REBORN) + if (players[i].ingame && players[i].playerstate == PST_REBORN) G_DoReborn(i); } P_MapEnd(); @@ -1889,7 +1888,7 @@ void G_Ticker(boolean run) { cmd = &players[i].cmd; - if (!playeringame[i]) + if (!players[i].ingame) continue; //@TODO all this throwdir stuff shouldn't be here! But it stays for now to maintain 1.0.4 compat... @@ -2094,6 +2093,7 @@ void G_PlayerReborn(INT32 player) boolean skinlocal; tic_t jointime; UINT8 splitscreenindex; + boolean pingame; boolean spectator; INT16 bot; SINT8 pity; @@ -2129,6 +2129,7 @@ void G_PlayerReborn(INT32 player) exiting = players[player].exiting; jointime = players[player].jointime; splitscreenindex = players[player].splitscreenindex; + pingame = players[player].ingame; spectator = players[player].spectator; pflags = (players[player].pflags & (PF_TIMEOVER|PF_FLIPCAM|PF_TAGIT|PF_TAGGED|PF_ANALOGMODE|PF_WANTSTOJOIN)); @@ -2238,6 +2239,7 @@ void G_PlayerReborn(INT32 player) p->ctfteam = ctfteam; p->jointime = jointime; p->splitscreenindex = splitscreenindex; + p->ingame = pingame; p->spectator = spectator; // save player config truth reborn @@ -2372,7 +2374,7 @@ static boolean G_CheckSpot(INT32 playernum, mapthing_t *mthing) { // first spawn of level for (i = 0; i < playernum; i++) - if (playeringame[i] && players[i].mo + if (players[i].ingame && players[i].mo && players[i].mo->x == mthing->x << FRACBITS && players[i].mo->y == mthing->y << FRACBITS) { @@ -2403,7 +2405,7 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) { mapthing_t *spawnpoint; - if (!playeringame[playernum]) + if (!players[playernum].ingame) return; P_SpawnPlayer(playernum); @@ -2575,12 +2577,12 @@ mapthing_t *G_FindRaceStart(INT32 playernum) UINT8 pos = 0; // SRB2Kart: figure out player spawn pos from points - if (!playeringame[playernum] || players[playernum].spectator) + if (!players[playernum].ingame || players[playernum].spectator) return playerstarts[0]; // go to first spot if you're a spectator for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (i == playernum) continue; @@ -2592,7 +2594,7 @@ mapthing_t *G_FindRaceStart(INT32 playernum) for (j = 0; j < MAXPLAYERS; j++) // I hate similar loops inside loops... :< { - if (!playeringame[j] || players[j].spectator) + if (!players[j].ingame || players[j].spectator) continue; if (j == playernum) continue; @@ -3154,7 +3156,7 @@ static void G_DoCompleted(void) K_StatRound(); for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) + if (players[i].ingame) { // SRB2Kart: exitlevel shouldn't get you the points if (!players[i].exiting && !(players[i].pflags & PF_TIMEOVER)) @@ -3352,7 +3354,7 @@ void G_NextLevel(void) UINT8 i; for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && !players[i].spectator) + if (players[i].ingame && !players[i].spectator) { gameaction = ga_startvote; return; @@ -3945,7 +3947,7 @@ void G_SaveGame(UINT32 savegameslot) // // G_DeferedInitNew // Can be called by the startup code or the menu task, -// consoleplayer, displayplayers[], playeringame[] should be set. +// consoleplayer, displayplayers[], players[].ingame should be set. // void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar, UINT8 ssplayers, boolean FLS) { @@ -4611,10 +4613,10 @@ void G_ReadDemoExtraData(void) case DXD_PST_SPECTATING: players[p].pflags &= ~PF_WANTSTOJOIN; // double-fuck you - if (!playeringame[p]) + if (!players[p].ingame) { CL_ClearPlayer(p); - playeringame[p] = true; + players[p].ingame = true; G_AddPlayer(p); players[p].spectator = true; @@ -4727,7 +4729,7 @@ void G_WriteDemoExtraData(void) if (demo_extradata[i] & DXD_PLAYSTATE) { demo_writerng = 1; - if (!playeringame[i]) + if (!players[i].ingame) WRITEUINT8(demobuf.p, DXD_PST_LEFT); else if ( players[i].spectator && @@ -4951,7 +4953,7 @@ void G_WriteAllGhostTics(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) @@ -5680,7 +5682,7 @@ void G_StoreRewindInfo(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) { info->playerinfo[i].ingame = false; continue; @@ -5718,7 +5720,7 @@ void G_PreviewRewind(tic_t previewtime) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) { if (info->playerinfo[i].player.mo) { @@ -6202,8 +6204,10 @@ void G_BeginRecording(void) CV_SaveNetVars(&demobuf.p, true); // Now store some info for each in-game player - for (p = 0; p < MAXPLAYERS; p++) { - if (playeringame[p]) { + for (p = 0; p < MAXPLAYERS; p++) + { + if (players[p].ingame) + { player = &players[p]; WRITEUINT8(demobuf.p, p | (player->spectator ? DEMO_SPECTATOR : 0)); @@ -7300,8 +7304,10 @@ void G_DoPlayDemo(char *defdemoname) consoleplayer = 0; memset(displayplayers, 0, sizeof(displayplayers)); - memset(playeringame, 0, sizeof(playeringame)); - playeringame[0] = true; + + for (INT32 j = 0; j < MAXPLAYERS; j++) + players[j].ingame = false; + players[0].ingame = true; goto post_compat; } @@ -7346,9 +7352,12 @@ void G_DoPlayDemo(char *defdemoname) //LUA_HookInt(gamemap, HOOK(MapChange)); consoleplayer = 0; - memset(playeringame,0,sizeof(playeringame)); - memset(displayplayers,0,sizeof(displayplayers)); - memset(camera,0,sizeof(camera)); // reset freecam + + for (INT32 j = 0; j < MAXPLAYERS; j++) + players[j].ingame = false; + + memset(displayplayers, 0, sizeof(displayplayers)); + memset(camera, 0, sizeof(camera)); // reset freecam // Load players that were in-game when the map started p = READUINT8(demobuf.p); @@ -7381,10 +7390,10 @@ void G_DoPlayDemo(char *defdemoname) return; } - if (!playeringame[displayplayers[0]] || players[displayplayers[0]].spectator) + if (!players[displayplayers[0]].ingame || players[displayplayers[0]].spectator) displayplayers[0] = consoleplayer = serverplayer = p; - playeringame[p] = true; + players[p].ingame = true; players[p].spectator = spectator; // Name diff --git a/src/g_game.h b/src/g_game.h index e50557a9d..b374be216 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -32,7 +32,6 @@ extern char player_names[MAXPLAYERS][MAXPLAYERNAME+1]; extern INT32 player_name_changes[MAXPLAYERS]; extern player_t players[MAXPLAYERS]; -extern boolean playeringame[MAXPLAYERS]; extern savebuffer_t demobuf; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index b7984c1e5..bcb035f4c 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -658,7 +658,7 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) //CONS_Printf("%d\n", target); // check for target player, if it doesn't exist then we can't send the message! - if (target < MAXPLAYERS && playeringame[target]) // player exists + if (target < MAXPLAYERS && players[target].ingame) // player exists target++; // even though playernums are from 0 to 31, target is 1 to 32, so up that by 1 to have it work! else { @@ -1255,7 +1255,7 @@ static void HU_SendChatMessage(void) //CONS_Printf("%d\n", target); // check for target player, if it doesn't exist then we can't send the message! - if (target < MAXPLAYERS && playeringame[target]) // player exists + if (target < MAXPLAYERS && players[target].ingame) // player exists target++; // even though playernums are from 0 to 31, target is 1 to 32, so up that by 1 to have it work! else { @@ -1921,7 +1921,7 @@ static void HU_DrawChat(void) } } - if (playeringame[i]) + if (players[i].ingame) { char name[MAXPLAYERNAME+1]; strlcpy(name, player_names[i], 7); // shorten name to 7 characters. @@ -2506,7 +2506,7 @@ static inline void HU_DrawSpectatorTicker(void) INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].spectator) + if (players[i].ingame && players[i].spectator) totallength += (signed)strlen(player_names[i]) * 8 + 16; length -= (leveltime % (totallength + dupadjust+8)); @@ -2514,7 +2514,7 @@ static inline void HU_DrawSpectatorTicker(void) for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && players[i].spectator) + if (players[i].ingame && players[i].spectator) { char *pos; char initial[MAXPLAYERNAME+1]; @@ -2695,7 +2695,7 @@ static void HU_DrawRankings(void) tab[i].name = NULL; tab[i].count = INT32_MAX; - if (!playeringame[i] || players[i].spectator || !players[i].mo) + if (!players[i].ingame || players[i].spectator || !players[i].mo) continue; numplayersingame++; @@ -2706,7 +2706,7 @@ static void HU_DrawRankings(void) UINT8 lowestposition = MAXPLAYERS+1; for (i = 0; i < MAXPLAYERS; i++) { - if (completed[i] || !playeringame[i] || players[i].spectator || !players[i].mo) + if (completed[i] || !players[i].ingame|| players[i].spectator || !players[i].mo) continue; if (players[i].kartstuff[k_position] >= lowestposition) diff --git a/src/k_director.c b/src/k_director.c index 8fd5ab960..64f7666d9 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -49,7 +49,7 @@ static INT32 K_PlayersPlaying(void) INT32 num = 0, i; for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || !players[i].mo) + if (!players[i].ingame || players[i].spectator || !players[i].mo) continue; num++; @@ -179,7 +179,7 @@ static void K_UpdateDirectorPositions(void) target = &players[playernum]; - if (playeringame[playernum] && !target->spectator && target->kartstuff[k_position] > 0) + if (players[playernum].ingame && !target->spectator && target->kartstuff[k_position] > 0) { directorinfo.sortedplayers[target->kartstuff[k_position] - 1] = playernum; } diff --git a/src/k_kart.c b/src/k_kart.c index d1432289a..b777e0640 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -205,7 +205,7 @@ static void saltyhop_onchange(void) { player_t *player = &players[i]; - if (!player || !playeringame[i] || P_MobjWasRemoved(player->mo)) + if (!player || !players[i].ingame || P_MobjWasRemoved(player->mo)) continue; player->mo->salty_jump = false; @@ -1100,7 +1100,7 @@ boolean K_IsPlayerLosing(player_t *player) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (players[i].kartstuff[k_position] > pcount) pcount = players[i].kartstuff[k_position]; @@ -1301,7 +1301,7 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean sp for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!G_BattleGametype() || players[i].kartstuff[k_bumper]) @@ -1448,7 +1448,7 @@ static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT3 for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && !players[i].spectator && players[i].mo + if (players[i].ingame && !players[i].spectator && players[i].mo && players[i].kartstuff[k_position] != 0 && players[i].kartstuff[k_position] < player->kartstuff[k_position]) pdis += P_AproxDistance(P_AproxDistance(players[i].mo->x - player->mo->x, @@ -1550,7 +1550,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) // Gotta check how many players are active at this moment. for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; pingame++; if (players[i].exiting) @@ -2363,7 +2363,7 @@ static void K_HandleDelayedHitByEm(player_t *player) { mobj_t *victim = NULL; - if (player->hitemvictim < MAXPLAYERS && playeringame[player->hitemvictim]) + if (player->hitemvictim < MAXPLAYERS && players[player->hitemvictim].ingame) { player_t *victimPlayer = &players[player->hitemvictim]; @@ -3360,7 +3360,7 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I INT32 lasttarg = source->player->kartstuff[k_lastjawztarget]; th->cvmem = source->player->skincolor; if ((lasttarg >= 0 && lasttarg < MAXPLAYERS) - && playeringame[lasttarg] + && players[lasttarg].ingame && !players[lasttarg].spectator && players[lasttarg].mo) { @@ -4391,7 +4391,7 @@ static void K_DoHyudoroSteal(player_t *player) for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE + if (players[i].ingame && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE && player != &players[i] && !players[i].exiting && !players[i].spectator // Player in-game // Can steal from this player @@ -4519,7 +4519,7 @@ static void K_DoShrink(player_t *user) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || !players[i].mo) + if (!players[i].ingame || players[i].spectator || !players[i].mo) continue; if (&players[i] == user) continue; @@ -5379,7 +5379,7 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source) angle_t thisang; player_t *player; - if (!playeringame[i]) + if (!players[i].ingame) continue; player = &players[i]; @@ -5542,7 +5542,7 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd) UINT8 thisvol = 0; fixed_t dist; - if (!playeringame[i] || !players[i].mo) + if (!players[i].ingame || !players[i].mo) { // This player doesn't exist. continue; @@ -6003,7 +6003,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) eggsexplode = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SPBEXPLOSION); if (player->kartstuff[k_eggmanblame] >= 0 && player->kartstuff[k_eggmanblame] < MAXPLAYERS - && playeringame[player->kartstuff[k_eggmanblame]] + && players[player->kartstuff[k_eggmanblame]].ingame && !players[player->kartstuff[k_eggmanblame]].spectator && players[player->kartstuff[k_eggmanblame]].mo) P_SetTarget(&eggsexplode->target, players[player->kartstuff[k_eggmanblame]].mo); @@ -6078,7 +6078,7 @@ void K_KartPlayerAfterThink(player_t *player) player_t *targ; mobj_t *ret; - if (player->kartstuff[k_jawztargetdelay] && playeringame[lasttarg] && !players[lasttarg].spectator) + if (player->kartstuff[k_jawztargetdelay] && players[lasttarg].ingame && !players[lasttarg].spectator) { targ = &players[lasttarg]; player->kartstuff[k_jawztargetdelay]--; @@ -6129,7 +6129,7 @@ boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y) fixed_t p1radius = players[playernum].mo->radius; for (i = 0; i < MAXPLAYERS; i++) { - if (playernum == i || !playeringame[i] || players[i].spectator || !players[i].mo || players[i].mo->health <= 0 + if (playernum == i || !players[i].ingame || players[i].spectator || !players[i].mo || players[i].mo->health <= 0 || players[i].playerstate != PST_LIVE || (players[i].mo->flags & MF_NOCLIP) || (players[i].mo->flags & MF_NOCLIPTHING)) continue; @@ -6419,7 +6419,7 @@ void K_KartUpdatePosition(player_t *player) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || !players[i].mo) + if (!players[i].ingame || players[i].spectator || !players[i].mo) continue; if (G_RaceGametype()) @@ -6795,7 +6795,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) newitem = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_EGGMANITEM); if (player->kartstuff[k_eggmanblame] >= 0 && player->kartstuff[k_eggmanblame] < MAXPLAYERS - && playeringame[player->kartstuff[k_eggmanblame]] + && players[player->kartstuff[k_eggmanblame]].ingame && !players[player->kartstuff[k_eggmanblame]].spectator && players[player->kartstuff[k_eggmanblame]].mo) P_SetTarget(&newitem->target, players[player->kartstuff[k_eggmanblame]].mo); @@ -7475,7 +7475,7 @@ void K_CalculateBattleWanted(void) { UINT8 position = 1; - if (!playeringame[i] || players[i].spectator) // Not playing + if (!players[i].ingame || players[i].spectator) // Not playing continue; if (players[i].exiting) // We're done, don't calculate. @@ -7498,7 +7498,7 @@ void K_CalculateBattleWanted(void) for (j = 0; j < MAXPLAYERS; j++) { - if (!playeringame[j] || players[j].spectator) + if (!players[j].ingame || players[j].spectator) continue; if (players[j].kartstuff[k_bumper] <= 0) continue; @@ -7591,7 +7591,7 @@ void K_CheckBumpers(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) // not even in-game + if (!players[i].ingame || players[i].spectator) // not even in-game continue; if (players[i].exiting) // we're already exiting! stop! @@ -7612,7 +7612,7 @@ void K_CheckBumpers(void) if (numingame <= 1) return; - if (winnernum > -1 && playeringame[winnernum]) + if (winnernum > -1 && players[winnernum].ingame) { players[winnernum].marescore += winnerscoreadd; CONS_Printf(M_GetText("%s received %d point%s for winning!\n"), player_names[winnernum], winnerscoreadd, (winnerscoreadd == 1 ? "" : "s")); @@ -7634,7 +7634,7 @@ void K_CheckSpectateStatus(void) // Maintain spectate wait timer for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) continue; if (players[i].spectator && (players[i].pflags & PF_WANTSTOJOIN)) @@ -7655,7 +7655,7 @@ void K_CheckSpectateStatus(void) // Get the number of players in game, and the players to be de-spectated. for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) continue; if (!players[i].spectator) @@ -7773,7 +7773,7 @@ void K_UpdateSpectateGrief(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; numingame++; @@ -9520,7 +9520,7 @@ static boolean K_drawKartPositionFaces(void) { rankplayer[i] = -1; - if (!playeringame[i] || players[i].spectator || !players[i].mo) + if (!players[i].ingame || players[i].spectator || !players[i].mo) continue; numplayersingame++; @@ -9537,7 +9537,7 @@ static boolean K_drawKartPositionFaces(void) UINT8 lowestposition = MAXPLAYERS+1; for (i = 0; i < MAXPLAYERS; i++) { - if (completed[i] || !playeringame[i] || players[i].spectator || !players[i].mo) + if (completed[i] || !players[i].ingame || players[i].spectator || !players[i].mo) continue; if (players[i].kartstuff[k_position] >= lowestposition) @@ -9585,7 +9585,7 @@ static boolean K_drawKartPositionFaces(void) player_t *player; player = &players[rankplayer[i]]; - if (!playeringame[rankplayer[i]]) + if (!players[rankplayer[i]].ingame) continue; if (player->spectator) continue; @@ -10379,7 +10379,7 @@ static void K_drawNameTags(void) { if (i > PLAYERSMASK) continue; - if (P_MobjWasRemoved(players[i].mo) || players[i].spectator || !playeringame[i]) + if (P_MobjWasRemoved(players[i].mo) || players[i].spectator || !players[i].ingame) continue; if (i == displayplayers[stplyrnum] && !cv_showownnametag.value && !(leveltime < 130)) continue; @@ -10838,7 +10838,7 @@ static void K_drawKartPlayerCheck(void) if (&players[i] == stplyr) continue; - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) continue; @@ -11072,7 +11072,7 @@ static void K_drawKartMinimap(void) { for (i = MAXPLAYERS-1; i >= 0; i--) { - if (!playeringame[i]) + if (!players[i].ingame) continue; if (!players[i].mo || players[i].spectator) @@ -11331,7 +11331,7 @@ static void K_drawBattleFullscreen(void) { if (i == displayplayers[0]) continue; - if (playeringame[i] && !stplyr->spectator) + if (players[i].ingame && !stplyr->spectator) return; } @@ -11796,7 +11796,7 @@ static void K_drawDistributionDebugger(void) // The only code duplication from the Kart, just to avoid the actual item function from calculating pingame twice for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; pingame++; if (players[i].exiting) diff --git a/src/k_stats.c b/src/k_stats.c index 538b4e3e3..a895bd1d0 100644 --- a/src/k_stats.c +++ b/src/k_stats.c @@ -70,7 +70,7 @@ void K_StatRound(void) for (int i = 0; i < MAXPLAYERS; ++i) { - if (playeringame[i] && !players[i].spectator) + if (players[i].ingame && !players[i].spectator) ++numplayers; } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 0fd4be34e..04d388406 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -400,7 +400,7 @@ static int lib_iteratePlayers(lua_State *L) i = (INT32)(*((player_t **)luaL_checkudata(L, 1, META_PLAYER)) - players); for (i++; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) continue; if (!players[i].mo) continue; @@ -419,7 +419,7 @@ static int lib_getPlayer(lua_State *L) lua_Integer i = luaL_checkinteger(L, 2); if (i < 0 || i >= MAXPLAYERS) return luaL_error(L, "players[] index %d out of range (0 - %d)", i, MAXPLAYERS-1); - if (!playeringame[i]) + if (!players[i].ingame) return 0; if (!players[i].mo) return 0; @@ -480,11 +480,12 @@ static int lib_iterateDisplayplayers(lua_State *L) for (i++; i < MAXSPLITSCREENPLAYERS; i++) { - if (i > splitscreen || !playeringame[displayplayers[i]]) + if (i > splitscreen || !players[displayplayers[i]].ingame) return 0; // Stop! There are no more players for us to go through. There will never be a player gap in displayplayers. if (!players[displayplayers[i]].mo) continue; + LUA_PushUserdata(L, &players[displayplayers[i]], META_PLAYER); lua_pushinteger(L, i); // push this to recall what number we were on for the next function call. I suppose this also means you can retrieve the splitscreen player number with 'for p, n in displayplayers.iterate'! return 2; @@ -503,7 +504,7 @@ static int lib_getDisplayplayers(lua_State *L) return luaL_error(L, "displayplayers[] index %d out of range (0 - %d)", i, MAXSPLITSCREENPLAYERS-1); if (i > splitscreen) return 0; - if (!playeringame[displayplayers[i]]) + if (!players[displayplayers[i]].ingame) return 0; if (!players[displayplayers[i]].mo) return 0; diff --git a/src/lua_script.c b/src/lua_script.c index 5cc6f59e6..010904e92 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1297,7 +1297,7 @@ void LUA_Archive(savebuffer_t *save, boolean network) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] && i > 0) // NEVER skip player 0, this is for dedi servs. + if (!players[i].ingame && i > 0) // NEVER skip player 0, this is for dedi servs. continue; // all players in game will be archived, even if they just add a 0. ArchiveExtVars(&save->p, &players[i], "player"); @@ -1339,7 +1339,7 @@ void LUA_UnArchive(savebuffer_t *save, boolean network) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] && i > 0) // same here, this is to synch dediservs properly. + if (!players[i].ingame && i > 0) // same here, this is to synch dediservs properly. continue; UnArchiveExtVars(&save->p, &players[i], network); diff --git a/src/p_enemy.c b/src/p_enemy.c index a15dd44b2..dcce60644 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -655,7 +655,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed if (actor->lastlook == stop) return false; - if (!playeringame[actor->lastlook]) + if (!players[actor->lastlook].ingame) continue; if (c++ == 2) @@ -730,7 +730,7 @@ static boolean P_LookForShield(mobj_t *actor) if (actor->lastlook == stop) return false; - if (!playeringame[actor->lastlook]) + if (!players[actor->lastlook].ingame) continue; if (c++ == 2) @@ -1072,7 +1072,7 @@ void A_PointyThink(mobj_t *actor) // Find nearest player for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) @@ -2391,7 +2391,7 @@ void A_1upThinker(mobj_t *actor) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].bot || players[i].spectator) + if (!players[i].ingame || players[i].bot || players[i].spectator) continue; if (!players[i].mo) @@ -2614,7 +2614,7 @@ void A_BossDeath(mobj_t *mo) // make sure there is a player alive for victory for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && (players[i].health > 0 + if (players[i].ingame && (players[i].health > 0 || ((netgame || multiplayer) && (players[i].lives > 0 || players[i].continues > 0)))) break; @@ -3327,7 +3327,7 @@ void A_BubbleSpawn(mobj_t *actor) // Quick! Look through players! // Don't spawn bubbles unless a player is relatively close by (var2). for (i = 0; i < MAXPLAYERS; ++i) - if (playeringame[i] && players[i].mo + if (players[i].ingame && players[i].mo && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<lastlook == stop) return; - if (!playeringame[actor->lastlook]) + if (!players[actor->lastlook].ingame) continue; if (c++ == 2) @@ -5421,7 +5421,7 @@ void A_MixUp(mobj_t *actor) // Count the number of players in the game // and grab their xyz coords for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE + if (players[i].ingame && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE && !players[i].exiting && !players[i].powers[pw_super]) { if ((netgame || multiplayer) && players[i].spectator) // Ignore spectators @@ -5452,7 +5452,7 @@ void A_MixUp(mobj_t *actor) INT32 mflags2; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE + if (players[i].ingame && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE && !players[i].exiting && !players[i].powers[pw_super]) { if ((netgame || multiplayer) && players[i].spectator) // Ignore spectators @@ -5541,7 +5541,7 @@ void A_MixUp(mobj_t *actor) for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && players[i].playerstate == PST_LIVE + if (players[i].ingame && players[i].playerstate == PST_LIVE && players[i].mo && players[i].mo->health > 0 && !players[i].exiting && !players[i].powers[pw_super]) { if ((netgame || multiplayer) && players[i].spectator)// Ignore spectators @@ -5591,7 +5591,7 @@ void A_MixUp(mobj_t *actor) for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && players[i].playerstate == PST_LIVE + if (players[i].ingame && players[i].playerstate == PST_LIVE && players[i].mo && players[i].mo->health > 0 && !players[i].exiting && !players[i].powers[pw_super]) { if ((netgame || multiplayer) && players[i].spectator)// Ignore spectators @@ -5622,7 +5622,7 @@ void A_MixUp(mobj_t *actor) { if (teleported[i]) { - if (playeringame[i] && players[i].playerstate == PST_LIVE + if (players[i].ingame && players[i].playerstate == PST_LIVE && players[i].mo && players[i].mo->health > 0 && !players[i].exiting && !players[i].powers[pw_super]) { if ((netgame || multiplayer) && players[i].spectator)// Ignore spectators @@ -5671,7 +5671,7 @@ void A_RecyclePowers(mobj_t *actor) // Count the number of players in the game for (i = 0, j = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE + if (players[i].ingame && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE && !players[i].exiting && !((netgame || multiplayer) && players[i].spectator)) { if (players[i].powers[pw_super]) @@ -6106,7 +6106,7 @@ void A_Boss7Chase(mobj_t *actor) // Is a player on top of us? for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) @@ -6722,7 +6722,7 @@ void A_EggShield(mobj_t *actor) // Search for players to push for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; player = &players[i]; @@ -8093,7 +8093,7 @@ void A_SPBChase(mobj_t *actor) // Find the player with the best rank for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || players[i].exiting) + if (!players[i].ingame || players[i].spectator || players[i].exiting) continue; // not in-game /*if (!players[i].mo) @@ -8256,7 +8256,7 @@ void A_SPBChase(mobj_t *actor) actor->flags |= MF_NOCLIPTHING; if (actor->lastlook != -1 - && playeringame[actor->lastlook] + && players[actor->lastlook].ingame && !players[actor->lastlook].spectator && !players[actor->lastlook].exiting) { @@ -8405,7 +8405,7 @@ void A_FZBoomFlash(mobj_t *actor) for (i = 0; i < MAXPLAYERS; i++) { fixed_t dist; - if (!playeringame[i] || !players[i].mo) + if (!players[i].ingame || !players[i].mo) continue; dist = P_AproxDistance(P_AproxDistance(actor->x-players[i].mo->x, actor->y-players[i].mo->y), actor->z-players[i].mo->z); if (dist < 1536< 0 + if (players[i].ingame && (players[i].health > 0 || ((netgame || multiplayer) && (players[i].lives > 0 || players[i].continues > 0)))) break; } @@ -10309,7 +10309,7 @@ void A_VileTarget(mobj_t *actor) // Our "Archvile" here is actually Oprah. "YOU GET A TARGET! YOU GET A TARGET! YOU ALL GET A TARGET!" for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) @@ -10409,7 +10409,7 @@ void A_VileAttack(mobj_t *actor) // Oprahvile strikes again, but this time, she brings HOT PAIN for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) diff --git a/src/p_floor.c b/src/p_floor.c index 2aa9cf0f7..1eb16680c 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2151,7 +2151,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) for (j = 0; j < MAXPLAYERS; j++) { - if (!playeringame[j]) + if (!players[j].ingame) continue; if (!players[j].mo) @@ -2217,7 +2217,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) { for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) continue; if (!players[i].mo) @@ -2299,7 +2299,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) { for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) continue; if (!players[i].mo) diff --git a/src/p_inter.c b/src/p_inter.c index e7c38906c..f23ac2537 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -172,7 +172,7 @@ void P_DoNightsScore(player_t *player) { INT32 i; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) + if (players[i].ingame) { if (++players[i].linkcount > players[i].maxlink) players[i].maxlink = players[i].linkcount; @@ -439,7 +439,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || players[i].kartstuff[k_bumper] <= 0) + if (!players[i].ingame || players[i].spectator || players[i].kartstuff[k_bumper] <= 0) continue; numingame++; } @@ -501,7 +501,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || players[i].kartstuff[k_bumper] <= 0) + if (!players[i].ingame || players[i].spectator || players[i].kartstuff[k_bumper] <= 0) continue; numingame++; } @@ -529,7 +529,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (special->target->player->kartstuff[k_eggmanblame] >= 0 && special->target->player->kartstuff[k_eggmanblame] < MAXPLAYERS - && playeringame[special->target->player->kartstuff[k_eggmanblame]] + && players[special->target->player->kartstuff[k_eggmanblame]].ingame && !players[special->target->player->kartstuff[k_eggmanblame]].spectator) player->kartstuff[k_eggmanblame] = special->target->player->kartstuff[k_eggmanblame]; else @@ -774,7 +774,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; players[i].exiting = raceexittime+1; @@ -1005,7 +1005,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (G_IsSpecialStage(gamemap)) { for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) + if (players[i].ingame && players[i].pflags & PF_NIGHTSMODE) players[i].drillmeter += TICRATE/2; } else if (player->bot) @@ -1423,7 +1423,7 @@ void P_CheckTimeLimit(void) { if (players[i].exiting) return; - if (playeringame[i] && players[i].spectator) + if (players[i].ingame && players[i].spectator) spectators++; } @@ -1439,7 +1439,7 @@ void P_CheckTimeLimit(void) //Store the nodes of participating players in an array. for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && !players[i].spectator) + if (players[i].ingame && !players[i].spectator) { playerarray[playercount] = i; playercount++; @@ -1478,7 +1478,7 @@ void P_CheckTimeLimit(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (players[i].exiting) return; @@ -1507,14 +1507,14 @@ void P_CheckPointLimit(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if ((UINT32)cv_pointlimit.value <= players[i].marescore) { for (i = 0; i < MAXPLAYERS; i++) // AAAAA nested loop using the same iteration variable ;; { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (players[i].exiting) return; @@ -1534,7 +1534,7 @@ boolean P_CheckRacers(void) // Check if all the players in the race have finished. If so, end the level. for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || players[i].exiting || !players[i].lives) + if (!players[i].ingame || players[i].spectator || players[i].exiting || !players[i].lives) continue; break; @@ -1550,7 +1550,7 @@ boolean P_CheckRacers(void) { for (j = 0; j < MAXPLAYERS; j++) { - if (!playeringame[j] || players[j].spectator) + if (!players[j].ingame || players[j].spectator) continue; numplayersingame++; } @@ -1560,7 +1560,7 @@ boolean P_CheckRacers(void) // check if we just got unlucky and there was only one guy who was a problem for (j = i+1; j < MAXPLAYERS; j++) { - if (!playeringame[j] || players[j].spectator || players[j].exiting || !players[j].lives) + if (!players[j].ingame || players[j].spectator || players[j].exiting || !players[j].lives) continue; break; @@ -1582,7 +1582,7 @@ boolean P_CheckRacers(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; numingame++; if (players[i].exiting) diff --git a/src/p_map.c b/src/p_map.c index 1256e155f..f45fb5294 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1964,7 +1964,7 @@ void P_CheckHoopPosition(mobj_t *hoopthing, fixed_t x, fixed_t y, fixed_t z, fix (void)radius; //unused for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || !players[i].mo || players[i].spectator) + if (!players[i].ingame || !players[i].mo || players[i].spectator) continue; if (abs(players[i].mo->x - x) >= hoopblockdist || diff --git a/src/p_mobj.c b/src/p_mobj.c index ae9ba156e..a7a8f9c09 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3801,7 +3801,7 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest) else if (actor->lastlook == stop) return (closest && lastdist > 0); - if (!playeringame[actor->lastlook]) + if (!players[actor->lastlook].ingame) continue; if (!closest && c++ == 2) @@ -3845,7 +3845,7 @@ boolean P_SupermanLook4Players(mobj_t *actor) for (c = 0; c < MAXPLAYERS; c++) { - if (!playeringame[c]) + if (!players[c].ingame) continue; if (players[c].health <= 0) @@ -4042,7 +4042,7 @@ static void P_Boss3Thinker(mobj_t *mobj) // Shock the water for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) @@ -4084,7 +4084,7 @@ static void P_Boss3Thinker(mobj_t *mobj) // none of the players are in the water for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo || players[i].bot) @@ -4159,7 +4159,7 @@ static void P_Boss3Thinker(mobj_t *mobj) // Are there any players underwater? If so, shock them! for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo || players[i].bot) @@ -4712,7 +4712,7 @@ static void P_Boss7Thinker(mobj_t *mobj) // It was a team effort for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) continue; P_AddPlayerScore(&players[i], 1000); @@ -4742,7 +4742,7 @@ static void P_Boss7Thinker(mobj_t *mobj) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) @@ -4824,7 +4824,7 @@ static void P_Boss7Thinker(mobj_t *mobj) // Looks for players in goop. If you find one, try to jump on him. for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) @@ -4969,7 +4969,7 @@ static void P_Boss7Thinker(mobj_t *mobj) // Hurt player?? for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) @@ -7260,7 +7260,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || !players[i].mo) + if (!players[i].ingame || !players[i].mo) continue; if (players[i].mare != mobj->threshold) @@ -7446,7 +7446,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) INT32 i; boolean bonustime = false; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].bonustime) + if (players[i].ingame && players[i].bonustime) { bonustime = true; break; @@ -7481,7 +7481,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) boolean bonustime = false; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].bonustime) + if (players[i].ingame && players[i].bonustime) { bonustime = true; break; @@ -9489,7 +9489,7 @@ static void P_RandomAudienceThink(mobj_t *mobj) if (mobj->threshold >= 0) // not already happy or sad? { - if (!playeringame[mobj->threshold] || players[mobj->threshold].spectator) // focused on a valid player? + if (!players[mobj->threshold].ingame || players[mobj->threshold].spectator) // focused on a valid player? return; if (!(players[mobj->threshold].exiting) && !(players[mobj->threshold].pflags & PF_TIMEOVER)) // not finished yet? @@ -9850,7 +9850,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) continue; pnum[pcount] = i; @@ -10545,7 +10545,7 @@ void P_PrecipitationEffects(void) // Local effects from here on out! // If we're not in game fully yet, we don't worry about them. - if (!playeringame[displayplayers[0]] || !players[displayplayers[0]].mo) + if (!players[displayplayers[0]].ingame || !players[displayplayers[0]].mo) return; if (sound_disabled) @@ -10776,7 +10776,7 @@ void P_SpawnPlayer(INT32 playernum) { if (i == playernum) continue; - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (players[i].jointime <= 1) // Prevent splitscreen hosters/joiners from only adding 1 player at a time in empty servers continue; diff --git a/src/p_saveg.c b/src/p_saveg.c index b5f11cedb..f9c4cf65f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -119,7 +119,7 @@ static void P_NetArchivePlayers(savebuffer_t *save, boolean resending) if (resending) WRITESINT8(save->p, (SINT8)adminplayers[i]); - if (!playeringame[i]) + if (!players[i].ingame) continue; flags = 0; @@ -312,7 +312,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean reloading) // Do NOT memset player struct to 0 // other areas may initialize data elsewhere //memset(&players[i], 0, sizeof (player_t)); - if (!playeringame[i]) + if (!players[i].ingame) continue; // NOTE: sending tics should (hopefully) no longer be necessary @@ -3180,7 +3180,7 @@ static inline void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride) // gamemap changed; we assume that its map header is always valid, // so make it so - if(!mapheaderinfo[gamemap-1]) + if (!mapheaderinfo[gamemap-1]) P_AllocMapHeader(gamemap-1); lastmapsaved = gamemap; @@ -3203,8 +3203,9 @@ static inline void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride) I_Error("This save file is for a particular mod, it cannot be used with the regular game."); } - memset(playeringame, 0, sizeof(*playeringame)); - playeringame[consoleplayer] = true; + for (INT32 i = 0; i < MAXPLAYERS; i++) + players[i].ingame = false; + players[consoleplayer].ingame = true; } static void P_NetArchiveMisc(savebuffer_t *save, boolean resending) @@ -3228,7 +3229,7 @@ static void P_NetArchiveMisc(savebuffer_t *save, boolean resending) WRITEINT16(save->p, gametype); for (i = 0; i < MAXPLAYERS; i++) - pig |= (playeringame[i] != 0)<p, pig); WRITEUINT32(save->p, P_GetRandSeed()); @@ -3340,7 +3341,7 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, bool pig = READUINT32(save->p); for (i = 0; i < MAXPLAYERS; i++) { - playeringame[i] = (pig & (1<health < 1) @@ -3357,7 +3357,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers case 3: // Linedef executor requires all players present // Trigger Linedef Exec (Floor Touch, All Players) /// \todo check continues for proper splitscreen support? for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !players[i].bot && players[i].mo && (gametype != GT_COOP || players[i].lives > 0)) + if (players[i].ingame && !players[i].bot && players[i].mo && (gametype != GT_COOP || players[i].lives > 0)) { if (roversector) { @@ -3869,7 +3869,7 @@ DoneSection2: for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; nump++; } diff --git a/src/p_telept.c b/src/p_telept.c index ceed7dc93..128d20fb0 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -175,7 +175,7 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle INT32 p; // Search for any players you might be carrying, so you can get them off before they end up being taken with you! for (p = 0; p < MAXPLAYERS; p++) - if (playeringame[p] && players[p].mo && players[p].pflags & PF_CARRIED && players[p].mo->tracer == thing) + if (players[p].ingame && players[p].mo && players[p].pflags & PF_CARRIED && players[p].mo->tracer == thing) { players[p].pflags &= ~PF_CARRIED; break; diff --git a/src/p_tick.c b/src/p_tick.c index 184a6678a..dde028041 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -535,7 +535,7 @@ void P_Ticker(boolean run) // Increment jointime even if paused for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i]) + if (players[i].ingame) { players[i].jointime++; } @@ -588,7 +588,7 @@ void P_Ticker(boolean run) { G_WriteDemoExtraData(); for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) + if (players[i].ingame) G_WriteDemoTiccmd(&players[i].cmd, i); } if (demo.playback) @@ -604,7 +604,7 @@ void P_Ticker(boolean run) #endif G_ReadDemoExtraData(); for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) + if (players[i].ingame) { //@TODO all this throwdir stuff shouldn't be here! But it's added to maintain 1.0.4 compat for now... // Remove for 1.1! @@ -633,7 +633,7 @@ void P_Ticker(boolean run) PS_START_TIMING(ps_playerthink_time); for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) + if (players[i].ingame && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerThink(&players[i]); PS_STOP_TIMING(ps_playerthink_time); } @@ -653,7 +653,7 @@ void P_Ticker(boolean run) // Run any "after all the other thinkers" stuff for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) + if (players[i].ingame && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); // Apply rumble to local players @@ -691,7 +691,7 @@ void P_Ticker(boolean run) countdowntimeup = true; for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (!players[i].mo) @@ -828,7 +828,7 @@ void P_PreTicker(INT32 frames) for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) + if (players[i].ingame && players[i].mo && !P_MobjWasRemoved(players[i].mo)) { // stupid fucking cmd hack // if it isn't for this, players can move in preticker time @@ -853,7 +853,7 @@ void P_PreTicker(INT32 frames) // Run any "after all the other thinkers" stuff for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) continue; if (!players[i].mo || P_MobjWasRemoved(players[i].mo)) diff --git a/src/p_user.c b/src/p_user.c index 213aef1f2..c76fb3f69 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -242,7 +242,7 @@ void P_GiveEmerald(boolean spawnObj) if (spawnObj) { for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) + if (players[i].ingame) P_SetMobjState(P_SpawnMobj(players[i].mo->x, players[i].mo->y, players[i].mo->z + players[i].mo->info->height, MT_GOTEMERALD), mobjinfo[MT_GOTEMERALD].spawnstate + em); @@ -275,7 +275,7 @@ UINT8 P_FindLowestLap(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (lowest == 255) @@ -302,7 +302,7 @@ UINT8 P_FindHighestLap(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (players[i].laps > highest) @@ -589,7 +589,7 @@ static UINT8 getPlayerPos(player_t *player) UINT8 pos = 1; for (int i = 0; i < MAXPLAYERS; ++i) { - if (!playeringame[i] || players[i].spectator) continue; + if (!players[i].ingame || players[i].spectator) continue; if (players[i].marescore > player->marescore) ++pos; } @@ -607,7 +607,7 @@ static boolean isPlayerLosing(player_t *player) UINT8 maxpos = 1; for (int i = 0; i < MAXPLAYERS; ++i) { - if (!playeringame[i] || players[i].spectator) continue; + if (!players[i].ingame || players[i].spectator) continue; if (players[i].marescore > player->marescore) ++pos; maxpos = max(getPlayerPos(&players[i]), maxpos); } @@ -1293,7 +1293,7 @@ void P_DoPlayerExit(player_t *player) if (player == &players[consoleplayer]) demo.savebutton = leveltime; - /*if (playeringame[player-players] && netgame && !circuitmap) + /*if (players[player-players].ingame && netgame && !circuitmap) CONS_Printf(M_GetText("%s has completed the level.\n"), player_names[player-players]);*/ } @@ -2138,7 +2138,7 @@ void P_BlackOw(player_t *player) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!players[i].ingame) continue; if (P_AproxDistance(player->mo->x - players[i].mo->x, player->mo->y - players[i].mo->y) < 1536*FRACUNIT) @@ -2994,7 +2994,7 @@ static void CV_PlayerCam1_OnChange(void) if (gamestate != GS_LEVEL) return; - if (!playeringame[displayplayers[0]] || players[displayplayers[0]].spectator) + if (!players[displayplayers[0]].ingame || players[displayplayers[0]].spectator) return; // dont do stuff when cam speeen at map start @@ -3010,7 +3010,7 @@ static void CV_PlayerCam2_OnChange(void) if (gamestate != GS_LEVEL) return; - if (!playeringame[displayplayers[1]] || players[displayplayers[1]].spectator) + if (!players[displayplayers[1]].ingame || players[displayplayers[1]].spectator) return; // dont do stuff when cam speeen at map start @@ -3026,7 +3026,7 @@ static void CV_PlayerCam3_OnChange(void) if (gamestate != GS_LEVEL) return; - if (!playeringame[displayplayers[2]] || players[displayplayers[2]].spectator) + if (!players[displayplayers[2]].ingame || players[displayplayers[2]].spectator) return; // dont do stuff when cam speeen at map start @@ -3042,7 +3042,7 @@ static void CV_PlayerCam4_OnChange(void) if (gamestate != GS_LEVEL) return; - if (!playeringame[displayplayers[3]] || players[displayplayers[3]].spectator) + if (!players[displayplayers[3]].ingame || players[displayplayers[3]].spectator) return; // dont do stuff when cam speeen at map start @@ -4116,7 +4116,7 @@ boolean P_SpectatorJoinGame(player_t *player) //find a team by num players, score, or random if all else fails. for (z = 0; z < MAXPLAYERS; ++z) - if (playeringame[z]) + if (players[z].ingame) { if (players[z].ctfteam == 1) ++numplayersred; @@ -4589,7 +4589,7 @@ void P_PlayerThink(player_t *player) // Check if all the players in the race have finished. If so, end the level. for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && !players[i].spectator) + if (players[i].ingame && !players[i].spectator) { if (!players[i].exiting && players[i].lives > 0) break; @@ -4654,7 +4654,7 @@ void P_PlayerThink(player_t *player) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || players[i].bot) + if (!players[i].ingame || players[i].spectator || players[i].bot) continue; if (players[i].lives <= 0) continue; @@ -4740,7 +4740,7 @@ void P_PlayerThink(player_t *player) INT32 i; for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) continue; if (&players[i] == player) continue; diff --git a/src/r_main.c b/src/r_main.c index 4ff9a96ff..0b1458e5e 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -250,7 +250,7 @@ void SplitScreen_OnChange(void) for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && i != consoleplayer) + if (players[i].ingame && i != consoleplayer) { UINT8 j; for (j = 1; j < MAXSPLITSCREENPLAYERS; j++) diff --git a/src/st_stuff.c b/src/st_stuff.c index 5a09f61e8..3ad3d354e 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -624,7 +624,7 @@ static void ST_overlayDrawer(void) UINT8 i; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !players[i].spectator) + if (players[i].ingame && !players[i].spectator) numingame++; itemtxt = va("%s (%s: %d)", itemtxt, M_GetText("Slots left"), max(0, cv_ingamecap.value - numingame)); diff --git a/src/y_inter.c b/src/y_inter.c index 65871cc78..4e8d362d8 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -226,7 +226,7 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) { data.val[i] = UINT32_MAX; - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) { data.increase[i] = UINT8_MAX; continue; @@ -249,7 +249,7 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || completed[i]) + if (!players[i].ingame || players[i].spectator || completed[i]) continue; comparison(i); @@ -389,7 +389,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) if (pnum == MAXPLAYERS) ; - else if (!playeringame[pnum] || player->spectator) + else if (!players[pnum].ingame || player->spectator) standings->num[i] = MAXPLAYERS; // this should be the only field setting in this function else { @@ -1140,7 +1140,7 @@ void Y_VoteDrawer(void) player_t *player = &players[i]; - if ((playeringame[i] && !player->spectator) && votes[i] != -1) + if ((players[i].ingame && !player->spectator) && votes[i] != -1) { patch_t *pic; @@ -1276,7 +1276,7 @@ void Y_VoteTicker(void) for (i = 0; i < MAXPLAYERS; i++) // Correct votes as early as possible, before they're processed by the game at all { - if (!playeringame[i] || players[i].spectator) + if (!players[i].ingame || players[i].spectator) votes[i] = -1; // Spectators are the lower class, and have effectively no voice in the government. Democracy sucks. else if (pickedvote != -1 && votes[i] == -1) votes[i] = 3; // Slow people get random @@ -1386,7 +1386,7 @@ void Y_VoteTicker(void) if (voteclient.playerinfo[i].delay) voteclient.playerinfo[i].delay--; - if ((playeringame[p] && !players[p].spectator) + if ((players[p].ingame && !players[p].spectator) && !voteclient.playerinfo[i].delay && pickedvote == -1 && votes[p] == -1) { @@ -1427,7 +1427,7 @@ void Y_VoteTicker(void) { for (i = 0; i < MAXPLAYERS; i++) { - if ((playeringame[i] && !players[i].spectator) && votes[i] == -1) + if ((players[i].ingame && !players[i].spectator) && votes[i] == -1) votes[i] = 3; } } @@ -1435,7 +1435,7 @@ void Y_VoteTicker(void) { for (i = 0; i < MAXPLAYERS; i++) { - if ((playeringame[i] && !players[i].spectator) && votes[i] == -1) + if ((players[i].ingame && !players[i].spectator) && votes[i] == -1) return; } } @@ -1613,7 +1613,7 @@ void Y_SetupVoteFinish(SINT8 pick, SINT8 level) for (i = 0; i < MAXPLAYERS; i++) { - if ((playeringame[i] && !players[i].spectator) && votes[i] == -1) + if ((players[i].ingame && !players[i].spectator) && votes[i] == -1) votes[i] = 3; if (votes[i] == -1 || endtype > 1) // Don't need to go on