diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index fa7e701e4..515a4f565 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -224,7 +224,7 @@ void GameInterface::MenuOpened() screenpeek = myconnectindex; } - auto& gm = g_player[myconnectindex].ps->gm; + auto& gm = ps[myconnectindex].gm; if (gm & MODE_GAME) { gm |= MODE_MENU; @@ -258,7 +258,7 @@ void GameInterface::MenuSound(EMenuSounds snd) void GameInterface::MenuClosed() { - auto& gm = g_player[myconnectindex].ps->gm; + auto& gm = ps[myconnectindex].gm; if (gm & MODE_GAME) { if (gm & MODE_MENU) @@ -282,7 +282,7 @@ void GameInterface::MenuClosed() bool GameInterface::CanSave() { if (ud.recstat == 2) return false; - auto &myplayer = *g_player[myconnectindex].ps; + auto &myplayer = ps[myconnectindex]; if (sprite[myplayer.i].extra <= 0) { //P_DoQuote(QUOTE_SAVE_DEAD, &myplayer); // handled by the menu. @@ -358,7 +358,7 @@ void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *t void GameInterface::QuitToTitle() { - g_player[myconnectindex].ps->gm = MODE_DEMO; + ps[myconnectindex].gm = MODE_DEMO; artClearMapArt(); } diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index a5d7ac253..15533cb5d 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -76,17 +76,6 @@ extern int startrts(int lumpNum, int localPlayer); extern void G_MaybeAllocPlayer(int32_t pnum); -static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk) -{ - if (!((ud.multimode < 2 && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) || - ud.multimode > 1 || ud.recstat == 2) || ud.pause_on) - { - return 65536; - } - - return CalcSmoothRatio(totalclk, ototalclk, REALGAMETICSPERSEC); -} - static inline void G_NewGame_EnterLevel(MapRecord *map, int skill) { diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index ecfb05d4c..ee360f377 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -145,7 +145,7 @@ void checkcommandline() void gameexitfrommenu() { // MP scoreboard - if (playerswhenstarted > 1 && g_player[myconnectindex].ps->gm & MODE_GAME && !ud.coop) + if (playerswhenstarted > 1 && ps[myconnectindex].gm & MODE_GAME && !ud.coop) { dobonus(1); } @@ -269,7 +269,7 @@ void FTA(int q, struct player_struct* p) { if (q == 13) p->ftq = q; auto qu = quoteMgr.GetQuote(q); - if (p == g_player[screenpeek].ps && qu[0] != '\0') + if (p == &ps[screenpeek] && qu[0] != '\0') { if (q >= 70 && q <= 72 && hud_messages == 2) { @@ -293,7 +293,7 @@ void FTA(int q, struct player_struct* p) void drawbackground(void) { - if ((g_player[myconnectindex].ps->gm & MODE_GAME) == 0 && ud.recstat != 2) + if ((ps[myconnectindex].gm & MODE_GAME) == 0 && ud.recstat != 2) { twod->ClearScreen(); auto tex = tileGetTexture(TILE_MENUSCREEN); diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index efde4dde5..bbf741d19 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -157,6 +157,17 @@ inline void SetPlayerPal(player_struct* p, PalEntry pe) p->pals = pe; } +inline int calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk) +{ + if (!((ud.multimode < 2 && ((ps[myconnectindex].gm & MODE_MENU) == 0)) || + ud.multimode > 1 || ud.recstat == 2) || ud.pause_on) + { + return 65536; + } + return CalcSmoothRatio(totalclk, ototalclk, REALGAMETICSPERSEC); +} + + // These should be the only places converting between level numbers and volume/map pairs constexpr inline int levelnum(int vol, int map) { diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 2a4b427e5..537af6d4c 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -936,7 +936,7 @@ int enterlevel(MapRecord *mi, int gamemode) FX_StopAllSounds(); FX_SetReverb(0); - struct player_struct *const p = g_player[0].ps; + auto p = &ps[0]; /* diff --git a/source/games/duke/src/sbar_d.cpp b/source/games/duke/src/sbar_d.cpp index edb111398..5bd18c3d2 100644 --- a/source/games/duke/src/sbar_d.cpp +++ b/source/games/duke/src/sbar_d.cpp @@ -241,7 +241,7 @@ public: void DrawHud(int snum, int style) { - auto p = g_player[snum].ps; + auto p = &ps[snum]; BeginHUD(320, 200, 1.f, false); if (style == 1) { @@ -344,7 +344,7 @@ public: void Statusbar(int snum) { - auto p = g_player[snum].ps; + auto p = &ps[snum]; int h = tilesiz[TILE_BOTTOMSTATUSBAR].y; int top = 200 - h; BeginStatusBar(320, 200, h, true); diff --git a/source/games/duke/src/sbar_r.cpp b/source/games/duke/src/sbar_r.cpp index f3e4b86e6..5f13d15af 100644 --- a/source/games/duke/src/sbar_r.cpp +++ b/source/games/duke/src/sbar_r.cpp @@ -218,7 +218,7 @@ public: void DrawHud(int snum, int style) { - auto p = g_player[snum].ps; + auto p = &ps[snum]; BeginHUD(320, 200, 1.f, false); if (style == 1) { @@ -284,7 +284,7 @@ public: void Statusbar(int snum) { - auto p = g_player[snum].ps; + auto p = &ps[snum]; double h = tilesiz[BOTTOMSTATUSBAR].y * scale; double top = 200 - h; BeginStatusBar(320, 200, h, true); diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index b880d82fb..032a9fbc0 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -333,7 +333,7 @@ void S_Update(void) vec3_t* c; int32_t ca, cs; - auto& gm = g_player[myconnectindex].ps->gm; + auto& gm = ps[myconnectindex].gm; if (isRR() && !Mus_IsPlaying() && (gm && gm & MODE_GAME)) S_PlayRRMusic(); diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index 7bacdc142..1cf6fe34e 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -70,7 +70,7 @@ void clearfrags(void) for (int i = 0; i < ud.multimode; i++) { playerdata_t *const pPlayerData = &g_player[i]; - pPlayerData->ps->frag = pPlayerData->ps->fraggedself = 0; + ps[i].frag = ps[i].fraggedself = 0; memset(pPlayerData->frags, 0, sizeof(pPlayerData->frags)); } }