Fix many instances of splitscreen view number if there are duplicate displayplayers

- Avoid iterating displayplayers to find view number and
  prefer R_GetViewNumber.
- Iterate over all matching displayplayers if necessary,
  instead of stopping at the first match.
This commit is contained in:
James R. 2023-10-01 03:22:30 -07:00 committed by James R
parent d5bac57409
commit 7b3010c93d
17 changed files with 133 additions and 218 deletions

View file

@ -206,7 +206,15 @@ class TiccmdBuilder
else else
#endif #endif
{ {
localangle[viewnum] += angleChange; int p = g_localplayers[forplayer()];
for (int i = 0; i <= r_splitscreen; ++i)
{
if (displayplayers[i] == p)
{
localangle[i] += angleChange;
}
}
} }
} }

View file

@ -5398,17 +5398,7 @@ static void HWR_DrawSkyBackground(player_t *player)
{ {
FTransform dometransform; FTransform dometransform;
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd); const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd);
postimg_t *type = &postimgtype[0]; postimg_t *type = &postimgtype[R_GetViewNumber()];
SINT8 i;
for (i = r_splitscreen; i >= 0; i--)
{
if (player == &players[displayplayers[i]])
{
type = &postimgtype[i];
break;
}
}
memset(&dometransform, 0x00, sizeof(FTransform)); memset(&dometransform, 0x00, sizeof(FTransform));
@ -6104,20 +6094,10 @@ INT32 HWR_GetTextureUsed(void)
void HWR_DoPostProcessor(player_t *player) void HWR_DoPostProcessor(player_t *player)
{ {
postimg_t *type = &postimgtype[0]; postimg_t *type = &postimgtype[R_GetViewNumber()];
SINT8 i;
HWD.pfnUnSetShader(); HWD.pfnUnSetShader();
for (i = r_splitscreen; i >= 0; i--)
{
if (player == &players[displayplayers[i]])
{
type = &postimgtype[i];
break;
}
}
// Armageddon Blast Flash! // Armageddon Blast Flash!
// Could this even be considered postprocessor? // Could this even be considered postprocessor?
if (player->flashcount) if (player->flashcount)

View file

@ -4,6 +4,7 @@
#include "../g_game.h" #include "../g_game.h"
#include "../k_hud.h" #include "../k_hud.h"
#include "../p_local.h" #include "../p_local.h"
#include "../r_fps.h"
#include "../v_draw.hpp" #include "../v_draw.hpp"
using srb2::Draw; using srb2::Draw;
@ -24,7 +25,7 @@ void K_drawKart2PTimestamp(void)
{ {
auto get_row = [] auto get_row = []
{ {
if (stplyr == &players[displayplayers[0]]) if (R_GetViewNumber() == 0)
{ {
return Draw(286, 31).flags(V_SNAPTOTOP); return Draw(286, 31).flags(V_SNAPTOTOP);
} }

View file

@ -1481,7 +1481,7 @@ static void K_drawKartItem(void)
// pain and suffering defined below // pain and suffering defined below
if (offset) if (offset)
{ {
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... if (!(R_GetViewNumber() & 1)) // If we are P1 or P3...
{ {
fx = ITEM_X; fx = ITEM_X;
fy = ITEM_Y; fy = ITEM_Y;
@ -1622,7 +1622,7 @@ static void K_drawKartItem(void)
{ {
xo++; xo++;
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // Flip for P1 and P3 (yes, that's correct) if (!(R_GetViewNumber() & 1)) // Flip for P1 and P3 (yes, that's correct)
{ {
xo -= 62; xo -= 62;
flip = V_FLIP; flip = V_FLIP;
@ -1730,7 +1730,7 @@ static void K_drawKartSlotMachine(void)
if (offset) if (offset)
{ {
boxoffx -= 4; boxoffx -= 4;
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... if (!(R_GetViewNumber() & 1)) // If we are P1 or P3...
{ {
fx = ITEM_X + 10; fx = ITEM_X + 10;
fy = ITEM_Y + 10; fy = ITEM_Y + 10;
@ -2052,7 +2052,7 @@ static void K_DrawKartPositionNum(UINT8 num)
{ {
fx = BASEVIDWIDTH << FRACBITS; fx = BASEVIDWIDTH << FRACBITS;
if (stplyr == &players[displayplayers[0]]) if (R_GetViewNumber() == 0)
{ {
// for player 1: display this at the top right, above the minimap. // for player 1: display this at the top right, above the minimap.
fy = 0; fy = 0;
@ -2071,8 +2071,7 @@ static void K_DrawKartPositionNum(UINT8 num)
{ {
fy = BASEVIDHEIGHT << FRACBITS; fy = BASEVIDHEIGHT << FRACBITS;
if (stplyr == &players[displayplayers[0]] if (!(R_GetViewNumber() & 1)) // If we are P1 or P3...
|| stplyr == &players[displayplayers[2]])
{ {
// If we are P1 or P3... // If we are P1 or P3...
fx = 0; fx = 0;
@ -2512,7 +2511,7 @@ static void K_drawKartEmeralds(void)
if (r_splitscreen < 2) if (r_splitscreen < 2)
{ {
startx -= 8; startx -= 8;
if (r_splitscreen == 1 && stplyr == &players[displayplayers[0]]) if (r_splitscreen == 1 && R_GetViewNumber() == 0)
{ {
starty = 1; starty = 1;
} }
@ -2522,7 +2521,7 @@ static void K_drawKartEmeralds(void)
{ {
xindex = 2; xindex = 2;
starty -= 15; starty -= 15;
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... if (!(R_GetViewNumber() & 1)) // If we are P1 or P3...
{ {
startx = LAPS_X; startx = LAPS_X;
splitflags = V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_SPLITSCREEN; splitflags = V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_SPLITSCREEN;
@ -2586,7 +2585,7 @@ static void K_drawKartLaps(void)
} }
else else
{ {
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... if (!(R_GetViewNumber() & 1)) // If we are P1 or P3...
{ {
fx = LAPS_X; fx = LAPS_X;
fy = LAPS_Y; fy = LAPS_Y;
@ -2693,7 +2692,7 @@ static void K_drawRingCounter(boolean gametypeinfoshown)
} }
else else
{ {
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... if (!(R_GetViewNumber() & 1)) // If we are P1 or P3...
{ {
fx = LAPS_X; fx = LAPS_X;
fy = LAPS_Y; fy = LAPS_Y;
@ -2833,7 +2832,7 @@ static void K_drawKartAccessibilityIcons(boolean gametypeinfoshown, INT32 fx)
{ {
fx = LAPS_X+44; fx = LAPS_X+44;
fy = LAPS_Y; fy = LAPS_Y;
if (!(stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]])) // If we are not P1 or P3... if (R_GetViewNumber() & 1) // If we are not P1 or P3...
{ {
splitflags ^= (V_SNAPTOLEFT|V_SNAPTORIGHT); splitflags ^= (V_SNAPTOLEFT|V_SNAPTORIGHT);
fx = (BASEVIDWIDTH/2) - fx; fx = (BASEVIDWIDTH/2) - fx;
@ -2992,7 +2991,7 @@ static void K_drawBlueSphereMeter(boolean gametypeinfoshown)
else else
{ {
xstep = 8; xstep = 8;
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... if (!(R_GetViewNumber() & 1)) // If we are P1 or P3...
{ {
fx = LAPS_X-2; fx = LAPS_X-2;
fy = LAPS_Y; fy = LAPS_Y;
@ -3077,7 +3076,7 @@ static void K_drawKartBumpersOrKarma(void)
} }
else else
{ {
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... if (!(R_GetViewNumber() & 1)) // If we are P1 or P3...
{ {
fx = LAPS_X; fx = LAPS_X;
fy = LAPS_Y; fy = LAPS_Y;
@ -3704,20 +3703,10 @@ static void K_drawKartNameTags(void)
if (result.onScreen == true) if (result.onScreen == true)
{ {
if (!(demo.playback == true && demo.freecam == true)) if (!(demo.playback == true && demo.freecam == true) && P_IsDisplayPlayer(ntplayer) &&
ntplayer != &players[displayplayers[cnum]])
{ {
for (j = 0; j <= (unsigned)r_splitscreen; j++) localindicator = G_PartyPosition(ntplayer - players);
{
if (ntplayer == &players[displayplayers[j]])
{
break;
}
}
if (j <= (unsigned)r_splitscreen && j != cnum)
{
localindicator = j;
}
} }
if (localindicator >= 0) if (localindicator >= 0)
@ -3896,7 +3885,7 @@ static void K_drawKartMinimap(void)
// Only draw for the first player // Only draw for the first player
// Maybe move this somewhere else where this won't be a concern? // Maybe move this somewhere else where this won't be a concern?
if (stplyr != &players[displayplayers[0]]) if (R_GetViewNumber() != 0)
return; return;
if (specialstageinfo.valid == true) if (specialstageinfo.valid == true)
@ -4431,7 +4420,7 @@ static void K_drawKartFinish(boolean finish)
interpx = R_InterpolateFixed(ox, x); interpx = R_InterpolateFixed(ox, x);
if (r_splitscreen && stplyr == &players[displayplayers[1]]) if (r_splitscreen && R_GetViewNumber() == 1)
interpx = -interpx; interpx = -interpx;
V_DrawFixedPatch(interpx + (STCD_X<<FRACBITS) - (pwidth / 2), V_DrawFixedPatch(interpx + (STCD_X<<FRACBITS) - (pwidth / 2),
@ -4669,14 +4658,12 @@ static void K_drawKartFirstPerson(void)
if (stplyr->spectator || !stplyr->mo || (stplyr->mo->renderflags & RF_DONTDRAW)) if (stplyr->spectator || !stplyr->mo || (stplyr->mo->renderflags & RF_DONTDRAW))
return; return;
if (stplyr == &players[displayplayers[1]] && r_splitscreen) {
{ pn = pnum[1]; tn = turn[1]; dr = drift[1]; } UINT8 view = R_GetViewNumber();
else if (stplyr == &players[displayplayers[2]] && r_splitscreen > 1) pn = pnum[view];
{ pn = pnum[2]; tn = turn[2]; dr = drift[2]; } tn = turn[view];
else if (stplyr == &players[displayplayers[3]] && r_splitscreen > 2) dr = drift[view];
{ pn = pnum[3]; tn = turn[3]; dr = drift[3]; } }
else
{ pn = pnum[0]; tn = turn[0]; dr = drift[0]; }
if (r_splitscreen) if (r_splitscreen)
{ {
@ -4805,14 +4792,12 @@ static void K_drawKartFirstPerson(void)
V_DrawFixedPatch(x, y, scale, splitflags, kp_fpview[target], colmap); V_DrawFixedPatch(x, y, scale, splitflags, kp_fpview[target], colmap);
if (stplyr == &players[displayplayers[1]] && r_splitscreen) {
{ pnum[1] = pn; turn[1] = tn; drift[1] = dr; } UINT8 view = R_GetViewNumber();
else if (stplyr == &players[displayplayers[2]] && r_splitscreen > 1) pnum[view] = pn;
{ pnum[2] = pn; turn[2] = tn; drift[2] = dr; } turn[view] = tn;
else if (stplyr == &players[displayplayers[3]] && r_splitscreen > 2) drift[view] = dr;
{ pnum[3] = pn; turn[3] = tn; drift[3] = dr; } }
else
{ pnum[0] = pn; turn[0] = tn; drift[0] = dr; }
} }
// doesn't need to ever support 4p // doesn't need to ever support 4p
@ -5093,26 +5078,19 @@ static void
K_drawMiniPing (void) K_drawMiniPing (void)
{ {
UINT32 f = V_SNAPTORIGHT; UINT32 f = V_SNAPTORIGHT;
UINT8 i; UINT8 i = R_GetViewNumber();
if (!cv_showping.value) if (!cv_showping.value)
{ {
return; return;
} }
for (i = 0; i <= r_splitscreen; i++) if (r_splitscreen > 1 && !(i & 1))
{ {
if (stplyr == &players[displayplayers[i]]) f = V_SNAPTOLEFT;
{
if (r_splitscreen > 1 && !(i & 1))
{
f = V_SNAPTOLEFT;
}
Draw_party_ping(i, f);
break;
}
} }
Draw_party_ping(i, f);
} }
void K_drawButton(fixed_t x, fixed_t y, INT32 flags, patch_t *button[2], boolean pressed) void K_drawButton(fixed_t x, fixed_t y, INT32 flags, patch_t *button[2], boolean pressed)
@ -5210,7 +5188,7 @@ static void K_drawDistributionDebugger(void)
fixed_t y = -pad; fixed_t y = -pad;
size_t i; size_t i;
if (stplyr != &players[displayplayers[0]]) // only for p1 if (R_GetViewNumber() != 0) // only for p1
{ {
return; return;
} }
@ -5268,7 +5246,7 @@ static void K_DrawWaypointDebugger(void)
if (cv_kartdebugwaypoints.value == 0) if (cv_kartdebugwaypoints.value == 0)
return; return;
if (stplyr != &players[displayplayers[0]]) // only for p1 if (R_GetViewNumber() != 0) // only for p1
return; return;
if (netgame) if (netgame)
@ -5298,7 +5276,7 @@ static void K_DrawBotDebugger(void)
return; return;
} }
if (stplyr != &players[displayplayers[0]]) // only for p1 if (R_GetViewNumber() != 0) // only for p1
{ {
return; return;
} }
@ -5368,7 +5346,7 @@ static void K_DrawGPRankDebugger(void)
return; return;
} }
if (stplyr != &players[displayplayers[0]]) // only for p1 if (R_GetViewNumber() != 0) // only for p1
{ {
return; return;
} }
@ -5425,7 +5403,7 @@ void K_drawKartHUD(void)
K_drawKartFirstPerson(); K_drawKartFirstPerson();
// Draw full screen stuff that turns off the rest of the HUD // Draw full screen stuff that turns off the rest of the HUD
if (mapreset && stplyr == &players[displayplayers[0]]) if (mapreset && R_GetViewNumber() == 0)
{ {
K_drawChallengerScreen(); K_drawChallengerScreen();
return; return;

View file

@ -264,13 +264,13 @@ UINT32 K_GetPlayerDontDrawFlag(player_t *player)
return flag; return flag;
if (player == &players[displayplayers[0]]) if (player == &players[displayplayers[0]])
flag = RF_DONTDRAWP1; flag |= RF_DONTDRAWP1;
else if (r_splitscreen >= 1 && player == &players[displayplayers[1]]) if (r_splitscreen >= 1 && player == &players[displayplayers[1]])
flag = RF_DONTDRAWP2; flag |= RF_DONTDRAWP2;
else if (r_splitscreen >= 2 && player == &players[displayplayers[2]]) if (r_splitscreen >= 2 && player == &players[displayplayers[2]])
flag = RF_DONTDRAWP3; flag |= RF_DONTDRAWP3;
else if (r_splitscreen >= 3 && player == &players[displayplayers[3]]) if (r_splitscreen >= 3 && player == &players[displayplayers[3]])
flag = RF_DONTDRAWP4; flag |= RF_DONTDRAWP4;
return flag; return flag;
} }

View file

@ -33,6 +33,7 @@
#include "m_easing.h" #include "m_easing.h"
#include "s_sound.h" #include "s_sound.h"
#include "st_stuff.h" #include "st_stuff.h"
#include "r_fps.h"
boolean level_tally_t::UseBonuses(void) boolean level_tally_t::UseBonuses(void)
{ {
@ -883,14 +884,14 @@ void level_tally_t::Draw(void)
SINT8 h_transition_sign = 1; SINT8 h_transition_sign = 1;
if (r_splitscreen > 1) if (r_splitscreen > 1)
{ {
if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) if (!(R_GetViewNumber() & 1))
{ {
h_transition_sign = -h_transition_sign; h_transition_sign = -h_transition_sign;
} }
} }
else if (r_splitscreen > 0) else if (r_splitscreen > 0)
{ {
if (stplyr == &players[displayplayers[1]]) if (R_GetViewNumber() == 1)
{ {
h_transition_sign = -h_transition_sign; h_transition_sign = -h_transition_sign;
} }

View file

@ -662,7 +662,7 @@ static int libd_drawOnMinimap(lua_State *L)
if (gamestate != GS_LEVEL) if (gamestate != GS_LEVEL)
return 0; return 0;
if (stplyr != &players[displayplayers[0]]) if (R_GetViewNumber() != 0)
return 0; return 0;
AutomapPic = mapheaderinfo[gamemap-1]->minimapPic; AutomapPic = mapheaderinfo[gamemap-1]->minimapPic;

View file

@ -599,7 +599,6 @@ static int player_set(lua_State *L)
if (plr == &players[displayplayers[i]]) if (plr == &players[displayplayers[i]])
{ {
localaiming[i] = plr->aiming; localaiming[i] = plr->aiming;
break;
} }
} }
} }

View file

@ -1439,7 +1439,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
if (target->player == &players[displayplayers[i]]) if (target->player == &players[displayplayers[i]])
{ {
localaiming[i] = 0; localaiming[i] = 0;
break;
} }
} }

View file

@ -167,7 +167,6 @@ boolean P_IsMachineLocalPlayer(player_t *player);
boolean P_IsDisplayPlayer(player_t *player); boolean P_IsDisplayPlayer(player_t *player);
void P_SetPlayerAngle(player_t *player, angle_t angle); void P_SetPlayerAngle(player_t *player, angle_t angle);
angle_t P_GetLocalAngle(player_t *player);
void P_ForceLocalAngle(player_t *player, angle_t angle); void P_ForceLocalAngle(player_t *player, angle_t angle);
boolean P_PlayerFullbright(player_t *player); boolean P_PlayerFullbright(player_t *player);

View file

@ -2867,7 +2867,6 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha
camera[i].z += z; camera[i].z += z;
camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y); camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y);
R_RelativeTeleportViewInterpolation(i, x, y, z, 0); R_RelativeTeleportViewInterpolation(i, x, y, z, 0);
break;
} }
} }
} }

View file

@ -79,7 +79,6 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
if (camera[i].chase) if (camera[i].chase)
P_ResetCamera(thing->player, &camera[i]); P_ResetCamera(thing->player, &camera[i]);
R_ResetViewInterpolation(i + 1); R_ResetViewInterpolation(i + 1);
break;
} }
// don't run in place after a teleport // don't run in place after a teleport
@ -170,8 +169,6 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle
} }
R_ResetViewInterpolation(1 + i); R_ResetViewInterpolation(1 + i);
break;
} }
} }

View file

@ -3544,19 +3544,10 @@ boolean P_SpectatorJoinGame(player_t *player)
player->enteredGame = true; player->enteredGame = true;
// Reset away view (some code referenced from Got_Teamchange) // Reset away view (some code referenced from Got_Teamchange)
if (G_IsPartyLocal(player - players))
{ {
UINT8 i = 0; LUA_HookViewpointSwitch(player, player, true);
const UINT8 *localplayertable = G_PartyArray(consoleplayer); displayplayers[G_PartyPosition(player - players)] = (player-players);
for (i = 0; i <= r_splitscreen; i++)
{
if (localplayertable[i] == (player-players))
{
LUA_HookViewpointSwitch(player, player, true);
displayplayers[i] = (player-players);
break;
}
}
} }
// a surprise tool that will help us later... // a surprise tool that will help us later...
@ -3572,11 +3563,11 @@ boolean P_SpectatorJoinGame(player_t *player)
} }
// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam // the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam
static void P_CalcPostImg(player_t *player) static void P_CalcPostImg(player_t *player, size_t viewnum)
{ {
sector_t *sector = player->mo->subsector->sector; sector_t *sector = player->mo->subsector->sector;
postimg_t *type = NULL; postimg_t *type = &postimgtype[viewnum];
INT32 *param; INT32 *param = &postimgparam[viewnum];
fixed_t pviewheight; fixed_t pviewheight;
size_t i; size_t i;
@ -3591,16 +3582,6 @@ static void P_CalcPostImg(player_t *player)
pviewheight = player->awayview.mobj->z; pviewheight = player->awayview.mobj->z;
} }
for (i = 0; i <= (unsigned)r_splitscreen; i++)
{
if (player == &players[displayplayers[i]])
{
type = &postimgtype[i];
param = &postimgparam[i];
break;
}
}
// see if we are in heat (no, not THAT kind of heat...) // see if we are in heat (no, not THAT kind of heat...)
for (i = 0; i < sector->tags.count; i++) for (i = 0; i < sector->tags.count; i++)
{ {
@ -4400,7 +4381,6 @@ void P_PlayerThink(player_t *player)
// //
void P_PlayerAfterThink(player_t *player) void P_PlayerAfterThink(player_t *player)
{ {
camera_t *thiscam = NULL; // if not one of the displayed players, just don't bother
UINT8 i; UINT8 i;
#ifdef PARANOIA #ifdef PARANOIA
@ -4425,15 +4405,6 @@ void P_PlayerAfterThink(player_t *player)
P_PlayerInSpecialSector(player); P_PlayerInSpecialSector(player);
#endif #endif
for (i = 0; i <= r_splitscreen; i++)
{
if (player == &players[displayplayers[i]])
{
thiscam = &camera[i];
break;
}
}
if (player->playerstate == PST_DEAD) if (player->playerstate == PST_DEAD)
{ {
// Followers need handled while dead. // Followers need handled while dead.
@ -4448,12 +4419,20 @@ void P_PlayerAfterThink(player_t *player)
return; return;
} }
if (thiscam)
{ {
if (!thiscam->chase) // bob view only if looking through the player's eyes boolean chase = true;
for (i = 0; i <= r_splitscreen; i++)
{
if (player == &players[displayplayers[i]] && !camera[i].chase)
{
chase = false;
}
}
if (!chase) // bob view only if looking through the player's eyes
{ {
P_CalcHeight(player); P_CalcHeight(player);
P_CalcPostImg(player);
} }
else else
{ {
@ -4466,6 +4445,14 @@ void P_PlayerAfterThink(player_t *player)
else else
player->viewz = player->mo->z + player->viewheight; player->viewz = player->mo->z + player->viewheight;
} }
for (i = 0; i <= r_splitscreen; i++)
{
if (player == &players[displayplayers[i]] && !camera[i].chase)
{
P_CalcPostImg(player, i);
}
}
} }
// spectator invisibility and nogravity. // spectator invisibility and nogravity.
@ -4530,10 +4517,15 @@ void P_PlayerAfterThink(player_t *player)
K_UpdateBotGameplayVars(player); K_UpdateBotGameplayVars(player);
} }
if (thiscam) for (i = 0; i <= r_splitscreen; i++)
{ {
if (player != &players[displayplayers[i]])
{
continue;
}
// Store before it gets 0'd out // Store before it gets 0'd out
thiscam->pmomz = player->mo->pmomz; camera[i].pmomz = player->mo->pmomz;
} }
if (P_IsObjectOnGround(player->mo)) if (P_IsObjectOnGround(player->mo))
@ -4632,21 +4624,6 @@ void P_SetPlayerAngle(player_t *player, angle_t angle)
player->angleturn = angle; player->angleturn = angle;
} }
angle_t P_GetLocalAngle(player_t *player)
{
// this function is from vanilla srb2. can you tell?
// (hint: they have separate variables for all of this shit instead of arrays)
UINT8 i;
for (i = 0; i <= r_splitscreen; i++)
{
if (player == &players[displayplayers[i]])
return localangle[i];
}
return 0;
}
void P_ForceLocalAngle(player_t *player, angle_t angle) void P_ForceLocalAngle(player_t *player, angle_t angle)
{ {
UINT8 i; UINT8 i;
@ -4658,8 +4635,6 @@ void P_ForceLocalAngle(player_t *player, angle_t angle)
if (player == &players[displayplayers[i]]) if (player == &players[displayplayers[i]])
{ {
localangle[i] = angle; localangle[i] = angle;
break;
} }
} }

View file

@ -20,6 +20,7 @@
#include "r_local.h" #include "r_local.h"
#include "r_state.h" #include "r_state.h"
#include "r_portal.h" // Add seg portals #include "r_portal.h" // Add seg portals
#include "r_fps.h"
#include "r_splats.h" #include "r_splats.h"
#include "p_local.h" // camera #include "p_local.h" // camera
@ -276,18 +277,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
mobj_t *viewmobj = viewplayer->mo; mobj_t *viewmobj = viewplayer->mo;
INT32 heightsec; INT32 heightsec;
boolean underwater; boolean underwater;
UINT8 i; UINT8 i = R_GetViewNumber();
for (i = 0; i <= r_splitscreen; i++) if (camera[i].chase)
{ heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec;
if (viewplayer == &players[displayplayers[i]] && camera[i].chase) else if (i > r_splitscreen && viewmobj)
{
heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec;
break;
}
}
if (i > r_splitscreen && viewmobj)
heightsec = R_PointInSubsector(viewmobj->x, viewmobj->y)->sector->heightsec; heightsec = R_PointInSubsector(viewmobj->x, viewmobj->y)->sector->heightsec;
else else
return sec; return sec;

View file

@ -20,6 +20,7 @@
#include "g_game.h" #include "g_game.h"
#include "p_setup.h" // levelflats #include "p_setup.h" // levelflats
#include "p_slopes.h" #include "p_slopes.h"
#include "r_fps.h"
#include "r_data.h" #include "r_data.h"
#include "r_textures.h" #include "r_textures.h"
#include "r_local.h" #include "r_local.h"
@ -963,8 +964,6 @@ void R_DrawSinglePlane(visplane_t *pl)
planeripple.active = true; planeripple.active = true;
if (spanfunctype == SPANDRAWFUNC_TRANS) if (spanfunctype == SPANDRAWFUNC_TRANS)
{ {
UINT8 i;
spanfunctype = SPANDRAWFUNC_WATER; spanfunctype = SPANDRAWFUNC_WATER;
// Copy the current scene, ugh // Copy the current scene, ugh
@ -977,43 +976,38 @@ void R_DrawSinglePlane(visplane_t *pl)
bottom = viewheight; bottom = viewheight;
// Only copy the part of the screen we need // Only copy the part of the screen we need
for (i = 0; i <= r_splitscreen; i++) UINT8 i = R_GetViewNumber();
INT32 scrx = 0;
INT32 scry = top;
INT32 offset;
if (r_splitscreen == 1)
{ {
if (viewplayer == &players[displayplayers[i]]) if (i & 1)
{ {
INT32 scrx = 0; scry += viewheight;
INT32 scry = top;
INT32 offset;
if (r_splitscreen == 1)
{
if (i & 1)
{
scry += viewheight;
}
}
else
{
if (i & 1)
{
scrx += viewwidth;
}
if (i / 2)
{
scry += viewheight;
}
}
offset = (scry*vid.width) + scrx;
// No idea if this works
VID_BlitLinearScreen(screens[0] + offset,
screens[1] + (top*vid.width), // intentionally not +offset
viewwidth, bottom-top,
vid.width, vid.width);
} }
} }
else
{
if (i & 1)
{
scrx += viewwidth;
}
if (i / 2)
{
scry += viewheight;
}
}
offset = (scry*vid.width) + scrx;
// No idea if this works
VID_BlitLinearScreen(screens[0] + offset,
screens[1] + (top*vid.width), // intentionally not +offset
viewwidth, bottom-top,
vid.width, vid.width);
} }
} }
#endif #endif

View file

@ -1203,7 +1203,7 @@ static void ST_overlayDrawer(void)
{ {
char name[MAXPLAYERNAME+12]; char name[MAXPLAYERNAME+12];
INT32 y = (stplyr == &players[displayplayers[0]]) ? 4 : BASEVIDHEIGHT/2-12; INT32 y = (viewnum == 0) ? 4 : BASEVIDHEIGHT/2-12;
sprintf(name, "VIEWPOINT: %s", player_names[stplyr-players]); sprintf(name, "VIEWPOINT: %s", player_names[stplyr-players]);
V_DrawRightAlignedThinString(BASEVIDWIDTH-40, y, V_HUDTRANSHALF|V_SNAPTOTOP|V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN, name); V_DrawRightAlignedThinString(BASEVIDWIDTH-40, y, V_HUDTRANSHALF|V_SNAPTOTOP|V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN, name);
} }

View file

@ -27,6 +27,7 @@
#include "f_finale.h" #include "f_finale.h"
#include "r_draw.h" #include "r_draw.h"
#include "console.h" #include "console.h"
#include "r_fps.h"
#include "i_video.h" // rendermode #include "i_video.h" // rendermode
#include "z_zone.h" #include "z_zone.h"
@ -513,8 +514,7 @@ void V_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 du
INT32 screenheight = vid.height; INT32 screenheight = vid.height;
INT32 basewidth = BASEVIDWIDTH * dupx; INT32 basewidth = BASEVIDWIDTH * dupx;
INT32 baseheight = BASEVIDHEIGHT * dupy; INT32 baseheight = BASEVIDHEIGHT * dupy;
SINT8 player = -1; SINT8 player = R_GetViewNumber();
UINT8 i;
if (options & V_SPLITSCREEN) if (options & V_SPLITSCREEN)
{ {
@ -531,15 +531,6 @@ void V_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 du
} }
} }
for (i = 0; i <= r_splitscreen; i++)
{
if (stplyr == &players[displayplayers[i]])
{
player = i;
break;
}
}
if (vid.width != (BASEVIDWIDTH * dupx)) if (vid.width != (BASEVIDWIDTH * dupx))
{ {
if (options & V_SNAPTORIGHT) if (options & V_SNAPTORIGHT)
@ -586,7 +577,7 @@ void V_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 du
if (r_splitscreen > 1) if (r_splitscreen > 1)
{ {
if (stplyr == &players[displayplayers[1]] || stplyr == &players[displayplayers[3]]) if (player & 1)
slidefromright = true; slidefromright = true;
} }