Use references in G_UpdatePlayerFromMenu() and G_BackToMenu() for readability

git-svn-id: https://svn.eduke32.com/eduke32@7184 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-11-18 18:09:09 +00:00
parent 89fe17e673
commit 9c0ee3d557
1 changed files with 21 additions and 19 deletions

View File

@ -5985,23 +5985,25 @@ void G_UpdatePlayerFromMenu(void)
if (ud.recstat != 0) if (ud.recstat != 0)
return; return;
auto &p = *g_player[myconnectindex].ps;
if (numplayers > 1) if (numplayers > 1)
{ {
Net_SendClientInfo(); Net_SendClientInfo();
if (sprite[g_player[myconnectindex].ps->i].picnum == APLAYER && sprite[g_player[myconnectindex].ps->i].pal != 1) if (sprite[p.i].picnum == APLAYER && sprite[p.i].pal != 1)
sprite[g_player[myconnectindex].ps->i].pal = g_player[myconnectindex].pcolor; sprite[p.i].pal = g_player[myconnectindex].pcolor;
} }
else else
{ {
/*int32_t j = g_player[myconnectindex].ps->team;*/ /*int32_t j = p.team;*/
P_SetupMiscInputSettings(); P_SetupMiscInputSettings();
g_player[myconnectindex].ps->palookup = g_player[myconnectindex].pcolor = ud.color; p.palookup = g_player[myconnectindex].pcolor = ud.color;
g_player[myconnectindex].pteam = ud.team; g_player[myconnectindex].pteam = ud.team;
if (sprite[g_player[myconnectindex].ps->i].picnum == APLAYER && sprite[g_player[myconnectindex].ps->i].pal != 1) if (sprite[p.i].picnum == APLAYER && sprite[p.i].pal != 1)
sprite[g_player[myconnectindex].ps->i].pal = g_player[myconnectindex].pcolor; sprite[p.i].pal = g_player[myconnectindex].pcolor;
} }
} }
@ -6019,26 +6021,26 @@ void G_BackToMenu(void)
static int G_EndOfLevel(void) static int G_EndOfLevel(void)
{ {
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0); auto &p = *g_player[myconnectindex].ps;
P_UpdateScreenPal(g_player[myconnectindex].ps);
if (g_player[myconnectindex].ps->gm&MODE_EOL) P_SetGamePalette(&p, BASEPAL, 0);
P_UpdateScreenPal(&p);
if (p.gm & MODE_EOL)
{ {
G_CloseDemoWrite(); G_CloseDemoWrite();
ready2send = 0; ready2send = 0;
if (g_player[myconnectindex].ps->player_par > 0 && (g_player[myconnectindex].ps->player_par < ud.playerbest || ud.playerbest < 0) && if (p.player_par > 0 && (p.player_par < ud.playerbest || ud.playerbest < 0) && ud.display_bonus_screen == 1)
ud.display_bonus_screen == 1) CONFIG_SetMapBestTime(g_loadedMapHack.md4, p.player_par);
CONFIG_SetMapBestTime(g_loadedMapHack.md4, g_player[myconnectindex].ps->player_par);
if ((VM_OnEventWithReturn(EVENT_ENDLEVELSCREEN, g_player[myconnectindex].ps->i, myconnectindex, 0)) == 0 && if ((VM_OnEventWithReturn(EVENT_ENDLEVELSCREEN, p.i, myconnectindex, 0)) == 0 && ud.display_bonus_screen == 1)
ud.display_bonus_screen == 1)
{ {
int32_t i = ud.screen_size; int const ssize = ud.screen_size;
ud.screen_size = 0; ud.screen_size = 0;
G_UpdateScreenArea(); G_UpdateScreenArea();
ud.screen_size = i; ud.screen_size = ssize;
G_BonusScreen(0); G_BonusScreen(0);
} }
@ -6054,7 +6056,7 @@ static int G_EndOfLevel(void)
if (!VOLUMEALL) if (!VOLUMEALL)
G_DoOrderScreen(); G_DoOrderScreen();
#endif #endif
g_player[myconnectindex].ps->gm = 0; p.gm = 0;
Menu_Open(myconnectindex); Menu_Open(myconnectindex);
Menu_Change(MENU_MAIN); Menu_Change(MENU_MAIN);
return 2; return 2;
@ -6071,9 +6073,9 @@ static int G_EndOfLevel(void)
ready2send = 0; ready2send = 0;
if (numplayers > 1) if (numplayers > 1)
g_player[myconnectindex].ps->gm = MODE_GAME; p.gm = MODE_GAME;
if (G_EnterLevel(g_player[myconnectindex].ps->gm)) if (G_EnterLevel(p.gm))
{ {
G_BackToMenu(); G_BackToMenu();
return 2; return 2;