From 00cfdfef27341896b7fe71b2285f8a49c308144a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 14 Sep 2025 21:20:07 +0200 Subject: [PATCH] add P_GetLocalPlayerNumForNum and P_IsLocalPlayerNum and cleanup a bunch of splitscreen checks - P_GetLocalPlayerNumForNum returns the playernumber for a given index - P_IsLocalPlayerNum returns if a playernum is local to the maschine - replaced most if else chains from checking splitscreen things with loops using P_GetLocalPlayerNumForNum and P_GetLocalPlayerForNum --- src/g_game.c | 114 ++++++++++++++++++++++--------------------- src/hu_stuff.c | 20 +------- src/lua_baselib.c | 1 + src/lua_consolelib.c | 1 + src/lua_mobjlib.c | 17 ++++--- src/lua_playerlib.c | 16 +++--- src/p_inter.c | 47 ++++++++---------- src/p_local.h | 2 + src/p_mobj.c | 13 ++--- src/p_polyobj.c | 20 ++++---- src/p_saveg.c | 13 ++--- src/p_telept.c | 13 ++--- src/p_user.c | 106 +++++++++++++++++++++++----------------- src/r_skins.c | 4 +- src/y_inter.c | 16 +----- 15 files changed, 189 insertions(+), 214 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 5f375b188..00143fdc6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2405,23 +2405,23 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) { if (nummapthings) { - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the first mapthing!\n")); + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_ERROR, "No player spawns found, spawning at the first mapthing!\n"); + } + spawnpoint = &mapthings[0]; } else { - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the origin!\n")); - //P_MovePlayerToSpawn handles this fine if the spawnpoint is NULL. + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_ERROR, "No player spawns found, spawning at the origin!\n"); + //P_MovePlayerToSpawn handles this fine if the spawnpoint is NULL. + } } } + P_MovePlayerToSpawn(playernum, spawnpoint); LUA_HookPlayer(&players[playernum], HOOK(PlayerSpawn)); // Lua hook for player spawning :) @@ -2433,11 +2433,11 @@ mapthing_t *G_FindCTFStart(INT32 playernum) if (!numredctfstarts && !numbluectfstarts) //why even bother, eh? { - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_WARNING, M_GetText("No CTF starts in this map!\n")); + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_WARNING, "No CTF starts in this map!\n"); + } + return NULL; } @@ -2445,11 +2445,11 @@ mapthing_t *G_FindCTFStart(INT32 playernum) { if (!numredctfstarts) { - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_WARNING, M_GetText("No Red Team starts in this map!\n")); + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_WARNING, "No Red Team starts in this map!\n"); + } + return NULL; } @@ -2460,22 +2460,22 @@ mapthing_t *G_FindCTFStart(INT32 playernum) return redctfstarts[i]; } - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Red Team starts!\n")); + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_WARNING, "Could not spawn at any Red Team starts!\n"); + } + return NULL; } else if (!players[playernum].ctfteam || players[playernum].ctfteam == 2) //blue { if (!numbluectfstarts) { - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_WARNING, M_GetText("No Blue Team starts in this map!\n")); + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_WARNING, "No Blue Team starts in this map!\n"); + } + return NULL; } @@ -2485,11 +2485,12 @@ mapthing_t *G_FindCTFStart(INT32 playernum) if (G_CheckSpot(playernum, bluectfstarts[i])) return bluectfstarts[i]; } - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Blue Team starts!\n")); + + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_WARNING, "Could not spawn at any Blue Team starts!\n"); + } + return NULL; } //should never be reached but it gets stuff to shut up @@ -2508,19 +2509,20 @@ mapthing_t *G_FindMatchStart(INT32 playernum) if (G_CheckSpot(playernum, deathmatchstarts[i])) return deathmatchstarts[i]; } - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Deathmatch starts!\n")); + + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_WARNING, "Could not spawn at any Deathmatch starts!\n"); + } + return NULL; } - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_WARNING, M_GetText("No Deathmatch starts in this map!\n")); + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_WARNING, "No Deathmatch starts in this map!\n"); + } + return NULL; } @@ -2584,19 +2586,19 @@ mapthing_t *G_FindRaceStart(INT32 playernum) // Just spawn there. //return playerstarts[0]; - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Race starts!\n")); + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_WARNING, "Could not spawn at any Race starts!\n"); + } + return NULL; } - if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) - CONS_Alert(CONS_WARNING, M_GetText("No Race starts in this map!\n")); + if (P_IsLocalPlayerNum(playernum)) + { + CONS_Alert(CONS_WARNING, "No Race starts in this map!\n"); + } + return NULL; } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 47c71d8e8..df130d020 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -943,7 +943,6 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) // before we do anything, let's verify the guy isn't spamming, get this easier on us. - //if (stop_spamming[playernum] != 0 && cv_chatspamprotection.value && !(flags & HU_CSAY)) if (stop_spamming[playernum] != 0 && consoleplayer != playernum && cv_chatspamprotection.value && !(flags & HU_CSAY)) { CONS_Debug(DBG_NETPLAY,"Received SAY cmd too quickly from Player %d (%s), assuming as spam and blocking message.\n", playernum+1, player_names[playernum]); @@ -1039,6 +1038,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) tempchar = (char *)Z_Calloc(strlen(cstart) + strlen(adminchar) + 1, PU_STATIC, NULL); else if (IsPlayerAdmin(playernum)) tempchar = (char *)Z_Calloc(strlen(cstart) + strlen(remotechar) + 1, PU_STATIC, NULL); + if (tempchar) { if (playernum == serverplayer) @@ -1073,17 +1073,6 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) } else // To everyone or sayteam, it doesn't change anything. fmt2 = "%s<%s%s%s>\x80 %s%s"; - /*else // To your team - { - if (players[playernum].ctfteam == 1) // red - prefix = "\x85[TEAM]"; - else if (players[playernum].ctfteam == 2) // blue - prefix = "\x84[TEAM]"; - else - prefix = "\x83"; // makes sure this doesn't implode if you sayteam on non-team gamemodes - - fmt2 = "%s<%s%s>\x80%s %s%s"; - }*/ HU_AddChatText(va(fmt2, prefix, cstart, dispname, cend, textcolor, msg), cv_chatnotifications.value); // add to chat @@ -1847,12 +1836,6 @@ static void HU_DrawChat(void) if (teamtalk) { talk = ttalk; -#if 0 - if (players[consoleplayer].ctfteam == 1) - t = 0x500; // Red - else if (players[consoleplayer].ctfteam == 2) - t = 0x400; // Blue -#endif } if (CHAT_MUTE) @@ -2049,6 +2032,7 @@ static void HU_DrawChat(void) V_DrawSmallString(chatx + boxw + 4, p_dispy - (6*count), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, va("\x82%d\x80 - %s", i, player_names[i])); count++; } + if (count == 0) // no results. { V_DrawFillConsoleMap(chatx + boxw + 2, p_dispy - (6*count), 48, 6, 239 | V_SNAPTOBOTTOM | V_SNAPTOLEFT); // fill it like the chat so the text doesn't become hard to read because of the hud. diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 12045fcfa..fb2b7a36f 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -126,6 +126,7 @@ static int lib_chatprintf(lua_State *L) plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player if (!plr) return LUA_ErrInvalid(L, "player_t"); + if (plr != &players[consoleplayer]) return 0; diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index e1e246d28..36c3a6c45 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -136,6 +136,7 @@ void COM_Lua_f(void) lua_pop(gL, 1); // pop command info table return; // can't execute splitscreen command without player 2! } + playernum = displayplayers[1]; } diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 59190ee6a..5ffbcb34e 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -251,14 +251,15 @@ int mobj_angle_setter(lua_State *L) mobj_t *mo = GETMO(); mo->angle = luaL_checkangle(L, 2); - if (mo->player == &players[consoleplayer]) - localangle[0] = mo->angle; - else if (mo->player == &players[displayplayers[1]]) - localangle[1] = mo->angle; - else if (mo->player == &players[displayplayers[2]]) - localangle[2] = mo->angle; - else if (mo->player == &players[displayplayers[3]]) - localangle[3] = mo->angle; + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (mo->player == P_GetLocalPlayerForNum(i)) + { + localangle[i] = mo->angle; + break; + } + } + return 0; } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 79a6a4219..0309c1928 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -267,14 +267,14 @@ int player_aiming_setter(lua_State *L) player_t *plr = GETPLAYER(); plr->aiming = luaL_checkangle(L, 2); - if (plr == &players[consoleplayer]) - localaiming[0] = plr->aiming; - else if (plr == &players[displayplayers[1]]) - localaiming[1] = plr->aiming; - else if (plr == &players[displayplayers[2]]) - localaiming[2] = plr->aiming; - else if (plr == &players[displayplayers[3]]) - localaiming[3] = plr->aiming; + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (plr == P_GetLocalPlayerForNum(i)) + { + localangle[i] = plr->aiming; + break; + } + } return 0; } diff --git a/src/p_inter.c b/src/p_inter.c index 2138ad5ab..26c9111b9 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -802,10 +802,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!P_PlayerTouchingSectorSpecial(player, 4, 2 + flagteam)) { CONS_Printf(M_GetText("%s returned the %c%s%c to base.\n"), plname, flagcolor, flagtext, 0x80); - - // The fuse code plays this sound effect - //if (players[consoleplayer].ctfteam == player->ctfteam) - // S_StartSound(NULL, sfx_hoop1); } } } @@ -873,14 +869,14 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) toucher->angle = special->angle; - if (player == &players[consoleplayer]) - localangle[0] = toucher->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = toucher->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = toucher->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = toucher->angle; + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (player == P_GetLocalPlayerForNum(i)) + { + localangle[i] = toucher->angle; + break; + } + } P_ResetPlayer(player); @@ -1626,25 +1622,20 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) S_FadeOutStopMusic(cv_respawnfademusicout.value); } - if (target->player == &players[consoleplayer]) + for (UINT8 i = 0; i <= splitscreen; i++) { - // don't die in auto map, - // switch view prior to dying - if (automapactive) - AM_Stop(); + if (target->player == P_GetLocalPlayerForNum(i)) + { + // don't die in auto map, + // switch view prior to dying + if (i == 0 && automapactive) + AM_Stop(); - //added : 22-02-98: recenter view for next life... - localaiming[0] = 0; + // added : 22-02-98: recenter view for next life... + localaiming[i] = 0; + break; + } } - if (target->player == &players[displayplayers[1]]) - { - // added : 22-02-98: recenter view for next life... - localaiming[1] = 0; - } - if (target->player == &players[displayplayers[2]]) - localaiming[2] = 0; - if (target->player == &players[displayplayers[3]]) - localaiming[3] = 0; if (G_BattleGametype()) K_CheckBumpers(); diff --git a/src/p_local.h b/src/p_local.h index bfe662dad..dbe96ae14 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -185,7 +185,9 @@ boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); player_t *P_GetLocalPlayerForNum(UINT8 pnum); +INT32 P_GetLocalPlayerNumForNum(UINT8 pnum); boolean P_IsLocalPlayer(const player_t *player); +boolean P_IsLocalPlayerNum(UINT8 pnum); boolean P_IsDisplayPlayer(const player_t *player); boolean P_SpectatorJoinGame(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index 15b4bf489..1428412dc 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10752,17 +10752,12 @@ void P_SpawnPlayer(INT32 playernum) { if (!p->spectator) { - if (playernum == consoleplayer) - camera[0].freecam = false; - else if (splitscreen) + for (UINT8 i = 0; i <= splitscreen; i++) { - for (i = 1; i <= splitscreen; i++) + if (playernum == P_GetLocalPlayerNumForNum(i)) { - if (playernum == displayplayers[i]) - { - camera[i].freecam = false; - break; - } + camera[i].freecam = false; + break; } } } diff --git a/src/p_polyobj.c b/src/p_polyobj.c index d427930df..a12725b3f 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1382,16 +1382,18 @@ static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta, Polyobj_slideThing(mo, newxoff-oldxoff, newyoff-oldyoff); - if (turnthings == 2 || (turnthings == 1 && !mo->player)) { + if (turnthings == 2 || (turnthings == 1 && !mo->player)) + { mo->angle += delta; - if (mo->player == &players[consoleplayer]) - localangle[0] += delta; - else if (mo->player == &players[displayplayers[1]]) - localangle[1] += delta; - else if (mo->player == &players[displayplayers[2]]) - localangle[2] += delta; - else if (mo->player == &players[displayplayers[3]]) - localangle[3] += delta; + + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (mo->player == P_GetLocalPlayerForNum(i)) + { + localangle[i] += delta; + break; + } + } } } } diff --git a/src/p_saveg.c b/src/p_saveg.c index d3714c9b0..b71fd4159 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2122,15 +2122,12 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) i = READUINT8(save->p); mobj->player = &players[i]; mobj->player->mo = mobj; + // added for angle prediction - if (consoleplayer == i) - localangle[0] = mobj->angle; - if (displayplayers[1] == i) - localangle[1] = mobj->angle; - if (displayplayers[2] == i) - localangle[2] = mobj->angle; - if (displayplayers[3] == i) - localangle[3] = mobj->angle; + if (i == P_GetLocalPlayerNumForNum(i)) + { + localangle[i] = mobj->angle; + } } if (diff & MD_MOVEDIR) mobj->movedir = READANGLE(save->p); diff --git a/src/p_telept.c b/src/p_telept.c index ceed7dc93..539e0050b 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -65,17 +65,12 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, thing->reactiontime = TICRATE/2; // don't move for about half a second // absolute angle position - if (thing == players[consoleplayer].mo) - localangle[0] = angle; - else if (splitscreen) + for (i = 0; i <= splitscreen; i++) { - for (i = 1; i <= splitscreen; i++) + if (thing == P_GetLocalPlayerForNum(i)->mo) { - if (thing == players[displayplayers[i]].mo) - { - localangle[i] = angle; - break; - } + localangle[i] = angle; + break; } } diff --git a/src/p_user.c b/src/p_user.c index b5341badc..670db91d8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -980,7 +980,18 @@ fixed_t P_GetPlayerSpinHeight(player_t *player) // player_t *P_GetLocalPlayerForNum(UINT8 pnum) { - return (pnum == 0 ? &players[consoleplayer] : &players[displayplayers[pnum]]); + return (&players[P_GetLocalPlayerNumForNum(pnum)]); +} + +// +// P_GetLocalPlayerNumForNum +// +// Returns the player number +// on the local machine for given number. +// +INT32 P_GetLocalPlayerNumForNum(UINT8 pnum) +{ + return (pnum == 0 ? consoleplayer : displayplayers[pnum]); } // @@ -993,15 +1004,29 @@ boolean P_IsLocalPlayer(const player_t *player) { UINT8 i; - if (player == &players[consoleplayer]) - return true; - else if (splitscreen) + for (i = 0; i <= splitscreen; i++) { - for (i = 1; i <= splitscreen; i++) // Skip P1 - { - if (player == &players[displayplayers[i]]) - return true; - } + if (player == P_GetLocalPlayerForNum(i)) + return true; + } + + return false; +} + +// +// P_IsLocalPlayer +// +// Returns true if playernum is +// on the local machine. +// +boolean P_IsLocalPlayerNum(UINT8 pnum) +{ + UINT8 i; + + for (i = 0; i <= splitscreen; i++) + { + if (pnum == P_GetLocalPlayerNumForNum(i)) + return true; } return false; @@ -2575,14 +2600,14 @@ static void P_DoZoomTube(player_t *player) { player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, player->mo->tracer->x, player->mo->tracer->y); - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (player == P_GetLocalPlayerForNum(i)) + { + localangle[i] = player->mo->angle; + break; + } + } } } @@ -2768,14 +2793,14 @@ void P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target if (source->player) { - if (source->player == &players[consoleplayer]) - localangle[0] = source->angle; - else if (source->player == &players[displayplayers[1]]) - localangle[1] = source->angle; - else if (source->player == &players[displayplayers[2]]) - localangle[2] = source->angle; - else if (source->player == &players[displayplayers[3]]) - localangle[3] = source->angle; + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (source->player == P_GetLocalPlayerForNum(i)) + { + localangle[i] = source->angle; + break; + } + } } // change slope @@ -4115,19 +4140,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall void P_ResetLocalCamAiming(player_t *player) { - UINT8 i; - - if (player == &players[consoleplayer]) - localaiming[0] = 0; - else if (splitscreen) + for (UINT8 i = 0; i <= splitscreen; i++) { - for (i = 1; i <= splitscreen; i++) // Skip P1 + if (player == P_GetLocalPlayerForNum(i)) { - if (player == &players[displayplayers[i]]) - { - localaiming[i] = 0; - break; - } + localangle[i] = 0; + break; } } } @@ -5152,14 +5170,14 @@ void P_PlayerAfterThink(player_t *player) player->mo->tracer->target->health += cmd->sidemove; player->mo->angle += cmd->sidemove << ANGLETOFINESHIFT; // 2048 --> ANGLE_MAX - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; // Adjust the local control angle. - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (player == P_GetLocalPlayerForNum(i)) + { + localangle[i] = player->mo->angle; // Adjust the local control angle. + break; + } + } } } diff --git a/src/r_skins.c b/src/r_skins.c index f74a11e2d..c19e34a74 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -230,7 +230,7 @@ boolean SetPlayerSkin(INT32 playernum, const char *skinname) if (P_IsLocalPlayer(player)) CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); - else if(server || IsPlayerAdmin(consoleplayer)) + else if (server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); SetPlayerSkinByNum(playernum, 0); @@ -335,7 +335,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) if (P_IsLocalPlayer(player)) CONS_Alert(CONS_WARNING, M_GetText("Skin %d not found\n"), skinnum); - else if(server || IsPlayerAdmin(consoleplayer)) + else if (server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin diff --git a/src/y_inter.c b/src/y_inter.c index 7eee526f4..c22a3728d 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1369,21 +1369,7 @@ void Y_VoteTicker(void) UINT8 p; boolean pressed = false; - switch (i) - { - case 1: - p = displayplayers[1]; - break; - case 2: - p = displayplayers[2]; - break; - case 3: - p = displayplayers[3]; - break; - default: - p = consoleplayer; - break; - } + p = P_GetLocalPlayerNumForNum(i); if (voteclient.playerinfo[i].delay) voteclient.playerinfo[i].delay--;