Huge splitscreen refactor

Did not get to finish all refactoring or even compile this, I'll continue later
This commit is contained in:
TehRealSalt 2019-04-18 03:08:11 -04:00
parent c67c598df0
commit 1f61397545
39 changed files with 1144 additions and 1351 deletions

View file

@ -2369,7 +2369,7 @@ static void CL_ConnectToServer(boolean viams)
#endif #endif
DEBFILE(va("Synchronisation Finished\n")); DEBFILE(va("Synchronisation Finished\n"));
displayplayer = consoleplayer; displayplayers[0] = consoleplayer;
} }
#ifndef NONET #ifndef NONET
@ -2717,8 +2717,8 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason)
RemoveAdminPlayer(playernum); // don't stay admin after you're gone RemoveAdminPlayer(playernum); // don't stay admin after you're gone
} }
if (playernum == displayplayer && !demo.playback) if (playernum == displayplayers[0] && !demo.playback)
displayplayer = consoleplayer; // don't look through someone's view who isn't there displayplayers[0] = consoleplayer; // don't look through someone's view who isn't there
#ifdef HAVE_BLUA #ifdef HAVE_BLUA
LUA_InvalidatePlayer(&players[playernum]); LUA_InvalidatePlayer(&players[playernum]);
@ -3448,6 +3448,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
{ {
INT16 node, newplayernum; INT16 node, newplayernum;
UINT8 splitscreenplayer = 0; UINT8 splitscreenplayer = 0;
UINT8 i;
if (playernum != serverplayer && !IsPlayerAdmin(playernum)) if (playernum != serverplayer && !IsPlayerAdmin(playernum))
{ {
@ -3481,34 +3482,19 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
if (node == mynode) if (node == mynode)
{ {
playernode[newplayernum] = 0; // for information only playernode[newplayernum] = 0; // for information only
if (splitscreenplayer) if (splitscreenplayer)
{ {
if (splitscreenplayer == 1) displayplayers[splitscreenplayer] = newplayernum;
{ DEBFILE(va("spawning one of my sister number %d\n", splitscreenplayer));
secondarydisplayplayer = newplayernum; if (splitscreenplayer == 1 && botingame)
DEBFILE("spawning my brother\n");
if (botingame)
players[newplayernum].bot = 1; players[newplayernum].bot = 1;
// Same goes for player 2 when relevant
}
else if (splitscreenplayer == 2)
{
thirddisplayplayer = newplayernum;
DEBFILE("spawning my sister\n");
}
else if (splitscreenplayer == 3)
{
fourthdisplayplayer = newplayernum;
DEBFILE("spawning my trusty pet dog\n");
}
} }
else else
{ {
consoleplayer = newplayernum; consoleplayer = newplayernum;
displayplayer = newplayernum; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
secondarydisplayplayer = newplayernum; displayplayers[i] = newplayernum;
thirddisplayplayer = newplayernum;
fourthdisplayplayer = newplayernum;
DEBFILE("spawning me\n"); DEBFILE("spawning me\n");
} }
D_SendPlayerConfig(); D_SendPlayerConfig();

View file

@ -118,14 +118,8 @@ boolean devparm = false; // started game with -devparm
boolean singletics = false; // timedemo boolean singletics = false; // timedemo
boolean lastdraw = false; boolean lastdraw = false;
postimg_t postimgtype = postimg_none; postimg_t postimgtype[MAXSPLITSCREENPLAYERS];
INT32 postimgparam; INT32 postimgparam[MAXSPLITSCREENPLAYERS];
postimg_t postimgtype2 = postimg_none;
INT32 postimgparam2;
postimg_t postimgtype3 = postimg_none;
INT32 postimgparam3;
postimg_t postimgtype4 = postimg_none;
INT32 postimgparam4;
// These variables are only true if // These variables are only true if
// whether the respective sound system is disabled // whether the respective sound system is disabled
@ -280,6 +274,7 @@ static void D_Display(void)
boolean forcerefresh = false; boolean forcerefresh = false;
static boolean wipe = false; static boolean wipe = false;
INT32 wipedefindex = 0; INT32 wipedefindex = 0;
UINT8 i;
if (dedicated) if (dedicated)
return; return;
@ -428,32 +423,31 @@ static void D_Display(void)
// draw the view directly // draw the view directly
if (cv_renderview.value && !automapactive) if (cv_renderview.value && !automapactive)
{ {
if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD) for (i = 0; i <= splitscreen; i++)
{
if (players[displayplayers[i]].mo || players[displayplayers[i]].playerstate == PST_DEAD)
{
if (i == 0) // Initialize for P1
{ {
viewwindowy = 0; viewwindowy = 0;
viewwindowx = 0; viewwindowx = 0;
topleft = screens[0] + viewwindowy*vid.width + viewwindowx; topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
objectsdrawn = 0; objectsdrawn = 0;
#ifdef HWRENDER
if (rendermode != render_soft)
HWR_RenderPlayerView(0, &players[displayplayer]);
else
#endif
if (rendermode != render_none)
R_RenderPlayerView(&players[displayplayer]);
} }
// render the second screen
if (splitscreen && players[secondarydisplayplayer].mo)
{
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode != render_soft) if (rendermode != render_soft)
HWR_RenderPlayerView(1, &players[secondarydisplayplayer]); HWR_RenderPlayerView(i, &players[displayplayers[i]]);
else else
#endif #endif
if (rendermode != render_none) if (rendermode != render_none)
{ {
if (i > 0) // Splitscreen-specific
{
switch (i)
{
case 1:
if (splitscreen > 1) if (splitscreen > 1)
{ {
viewwindowx = viewwidth; viewwindowx = viewwidth;
@ -464,73 +458,40 @@ static void D_Display(void)
viewwindowx = 0; viewwindowx = 0;
viewwindowy = viewheight; viewwindowy = viewheight;
} }
M_Memcpy(ylookup, ylookup2, viewheight*sizeof (ylookup[0])); M_Memcpy(ylookup, ylookup2, viewheight*sizeof (ylookup[0]));
break;
topleft = screens[0] + viewwindowy*vid.width + viewwindowx; case 2:
R_RenderPlayerView(&players[secondarydisplayplayer]);
viewwindowy = 0;
M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0]));
}
}
// render the third screen
if (splitscreen > 1 && players[thirddisplayplayer].mo)
{
#ifdef HWRENDER
if (rendermode != render_soft)
HWR_RenderPlayerView(2, &players[thirddisplayplayer]);
else
#endif
if (rendermode != render_none)
{
viewwindowx = 0; viewwindowx = 0;
viewwindowy = viewheight; viewwindowy = viewheight;
M_Memcpy(ylookup, ylookup3, viewheight*sizeof (ylookup[0])); M_Memcpy(ylookup, ylookup3, viewheight*sizeof (ylookup[0]));
break;
topleft = screens[0] + viewwindowy*vid.width + viewwindowx; case 3:
R_RenderPlayerView(&players[thirddisplayplayer]);
viewwindowy = 0;
M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0]));
}
}
if (splitscreen > 2 && players[fourthdisplayplayer].mo) // render the fourth screen
{
#ifdef HWRENDER
if (rendermode != render_soft)
HWR_RenderPlayerView(3, &players[fourthdisplayplayer]);
else
#endif
if (rendermode != render_none)
{
viewwindowx = viewwidth; viewwindowx = viewwidth;
viewwindowy = viewheight; viewwindowy = viewheight;
M_Memcpy(ylookup, ylookup4, viewheight*sizeof (ylookup[0])); M_Memcpy(ylookup, ylookup4, viewheight*sizeof (ylookup[0]));
default:
break;
}
topleft = screens[0] + viewwindowy*vid.width + viewwindowx; topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
}
R_RenderPlayerView(&players[fourthdisplayplayer]); R_RenderPlayerView(&players[displayplayers[i]]);
viewwindowy = 0; if (i > 0)
M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0])); M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0]));
} }
} }
}
if (rendermode == render_soft) if (rendermode == render_soft)
{ {
if (postimgtype) for (i = 0; i <= splitscreen; i++)
V_DoPostProcessor(0, postimgtype, postimgparam); {
if (postimgtype2) if (postimgtype[i])
V_DoPostProcessor(1, postimgtype2, postimgparam2); V_DoPostProcessor(i, postimgtype[i], postimgparam[i]);
if (postimgtype3) }
V_DoPostProcessor(2, postimgtype3, postimgparam3);
if (postimgtype4)
V_DoPostProcessor(3, postimgtype4, postimgparam4);
} }
} }
@ -750,7 +711,7 @@ void D_SRB2Loop(void)
M_DoScreenShot(); M_DoScreenShot();
} }
// consoleplayer -> displayplayer (hear sounds from viewpoint) // consoleplayer -> displayplayers (hear sounds from viewpoint)
S_UpdateSounds(); // move positional sounds S_UpdateSounds(); // move positional sounds
// check for media change, loop music.. // check for media change, loop music..
@ -829,7 +790,8 @@ void D_StartTitle(void)
maptol = 0; maptol = 0;
gameaction = ga_nothing; gameaction = ga_nothing;
displayplayer = consoleplayer = 0; memset(displayplayers, 0, sizeof(displayplayers));
consoleplayer = 0;
//demosequence = -1; //demosequence = -1;
gametype = GT_RACE; // SRB2kart gametype = GT_RACE; // SRB2kart
paused = false; paused = false;

View file

@ -1145,11 +1145,11 @@ static void CleanupPlayerName(INT32 playernum, const char *newname)
// spaces may have been removed // spaces may have been removed
if (playernum == consoleplayer) if (playernum == consoleplayer)
CV_StealthSet(&cv_playername, tmpname); CV_StealthSet(&cv_playername, tmpname);
else if (playernum == secondarydisplayplayer || (!netgame && playernum == 1)) else if (playernum == displayplayers[1] || (!netgame && playernum == 1))
CV_StealthSet(&cv_playername2, tmpname); CV_StealthSet(&cv_playername2, tmpname);
else if (playernum == thirddisplayplayer || (!netgame && playernum == 2)) else if (playernum == displayplayers[2] || (!netgame && playernum == 2))
CV_StealthSet(&cv_playername3, tmpname); CV_StealthSet(&cv_playername3, tmpname);
else if (playernum == fourthdisplayplayer || (!netgame && playernum == 3)) else if (playernum == displayplayers[3] || (!netgame && playernum == 3))
CV_StealthSet(&cv_playername4, tmpname); CV_StealthSet(&cv_playername4, tmpname);
else I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); else I_Assert(((void)"CleanupPlayerName used on non-local player", 0));
@ -1257,11 +1257,11 @@ static void ForceAllSkins(INT32 forcedskin)
{ {
if (i == consoleplayer) if (i == consoleplayer)
CV_StealthSet(&cv_skin, skins[forcedskin].name); CV_StealthSet(&cv_skin, skins[forcedskin].name);
else if (i == secondarydisplayplayer) else if (i == displayplayers[1])
CV_StealthSet(&cv_skin2, skins[forcedskin].name); CV_StealthSet(&cv_skin2, skins[forcedskin].name);
else if (i == thirddisplayplayer) else if (i == displayplayers[2])
CV_StealthSet(&cv_skin3, skins[forcedskin].name); CV_StealthSet(&cv_skin3, skins[forcedskin].name);
else if (i == fourthdisplayplayer) else if (i == displayplayers[3])
CV_StealthSet(&cv_skin4, skins[forcedskin].name); CV_StealthSet(&cv_skin4, skins[forcedskin].name);
} }
} }
@ -1396,8 +1396,8 @@ static void SendNameAndColor2(void)
if (splitscreen < 1 && !botingame) if (splitscreen < 1 && !botingame)
return; // can happen if skin2/color2/name2 changed return; // can happen if skin2/color2/name2 changed
if (secondarydisplayplayer != consoleplayer) if (displayplayers[1] != consoleplayer)
secondplaya = secondarydisplayplayer; secondplaya = displayplayers[1];
else if (!netgame) // HACK else if (!netgame) // HACK
secondplaya = 1; secondplaya = 1;
@ -1446,7 +1446,7 @@ static void SendNameAndColor2(void)
CleanupPlayerName(secondplaya, cv_playername2.zstring); CleanupPlayerName(secondplaya, cv_playername2.zstring);
strcpy(player_names[secondplaya], cv_playername2.zstring); strcpy(player_names[secondplaya], cv_playername2.zstring);
// don't use secondarydisplayplayer: the second player must be 1 // don't use displayplayers[1]: the second player must be 1
players[secondplaya].skincolor = cv_playercolor2.value; players[secondplaya].skincolor = cv_playercolor2.value;
if (players[secondplaya].mo) if (players[secondplaya].mo)
players[secondplaya].mo->color = players[secondplaya].skincolor; players[secondplaya].mo->color = players[secondplaya].skincolor;
@ -1485,14 +1485,14 @@ static void SendNameAndColor2(void)
snac2pending++; snac2pending++;
// Don't change name if muted // Don't change name if muted
if (cv_mute.value && !(server || IsPlayerAdmin(secondarydisplayplayer))) if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1])))
CV_StealthSet(&cv_playername2, player_names[secondarydisplayplayer]); CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
else // Cleanup name if changing it else // Cleanup name if changing it
CleanupPlayerName(secondarydisplayplayer, cv_playername2.zstring); CleanupPlayerName(displayplayers[1], cv_playername2.zstring);
// Don't change skin if the server doesn't want you to. // Don't change skin if the server doesn't want you to.
if (!CanChangeSkin(secondarydisplayplayer)) if (!CanChangeSkin(displayplayers[1]))
CV_StealthSet(&cv_skin2, skins[players[secondarydisplayplayer].skin].name); CV_StealthSet(&cv_skin2, skins[players[displayplayers[1]].skin].name);
// check if player has the skin loaded (cv_skin2 may have // check if player has the skin loaded (cv_skin2 may have
// the name of a skin that was available in the previous game) // the name of a skin that was available in the previous game)
@ -1519,8 +1519,8 @@ static void SendNameAndColor3(void)
if (splitscreen < 2) if (splitscreen < 2)
return; // can happen if skin3/color3/name3 changed return; // can happen if skin3/color3/name3 changed
if (thirddisplayplayer != consoleplayer) if (displayplayers[2] != consoleplayer)
thirdplaya = thirddisplayplayer; thirdplaya = displayplayers[2];
else if (!netgame) // HACK else if (!netgame) // HACK
thirdplaya = 2; thirdplaya = 2;
@ -1561,7 +1561,7 @@ static void SendNameAndColor3(void)
CleanupPlayerName(thirdplaya, cv_playername3.zstring); CleanupPlayerName(thirdplaya, cv_playername3.zstring);
strcpy(player_names[thirdplaya], cv_playername3.zstring); strcpy(player_names[thirdplaya], cv_playername3.zstring);
// don't use thirddisplayplayer: the third player must be 2 // don't use displayplayers[2]: the third player must be 2
players[thirdplaya].skincolor = cv_playercolor3.value; players[thirdplaya].skincolor = cv_playercolor3.value;
if (players[thirdplaya].mo) if (players[thirdplaya].mo)
players[thirdplaya].mo->color = players[thirdplaya].skincolor; players[thirdplaya].mo->color = players[thirdplaya].skincolor;
@ -1600,14 +1600,14 @@ static void SendNameAndColor3(void)
snac3pending++; snac3pending++;
// Don't change name if muted // Don't change name if muted
if (cv_mute.value && !(server || IsPlayerAdmin(thirddisplayplayer))) if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2])))
CV_StealthSet(&cv_playername3, player_names[thirddisplayplayer]); CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
else // Cleanup name if changing it else // Cleanup name if changing it
CleanupPlayerName(thirddisplayplayer, cv_playername3.zstring); CleanupPlayerName(displayplayers[2], cv_playername3.zstring);
// Don't change skin if the server doesn't want you to. // Don't change skin if the server doesn't want you to.
if (!CanChangeSkin(thirddisplayplayer)) if (!CanChangeSkin(displayplayers[2]))
CV_StealthSet(&cv_skin3, skins[players[thirddisplayplayer].skin].name); CV_StealthSet(&cv_skin3, skins[players[displayplayers[2]].skin].name);
// check if player has the skin loaded (cv_skin3 may have // check if player has the skin loaded (cv_skin3 may have
// the name of a skin that was available in the previous game) // the name of a skin that was available in the previous game)
@ -1634,8 +1634,8 @@ static void SendNameAndColor4(void)
if (splitscreen < 3) if (splitscreen < 3)
return; // can happen if skin4/color4/name4 changed return; // can happen if skin4/color4/name4 changed
if (fourthdisplayplayer != consoleplayer) if (displayplayers[3] != consoleplayer)
fourthplaya = fourthdisplayplayer; fourthplaya = displayplayers[3];
else if (!netgame) // HACK else if (!netgame) // HACK
fourthplaya = 3; fourthplaya = 3;
@ -1684,7 +1684,7 @@ static void SendNameAndColor4(void)
CleanupPlayerName(fourthplaya, cv_playername4.zstring); CleanupPlayerName(fourthplaya, cv_playername4.zstring);
strcpy(player_names[fourthplaya], cv_playername4.zstring); strcpy(player_names[fourthplaya], cv_playername4.zstring);
// don't use fourthdisplayplayer: the second player must be 4 // don't use displayplayers[3]: the second player must be 4
players[fourthplaya].skincolor = cv_playercolor4.value; players[fourthplaya].skincolor = cv_playercolor4.value;
if (players[fourthplaya].mo) if (players[fourthplaya].mo)
players[fourthplaya].mo->color = players[fourthplaya].skincolor; players[fourthplaya].mo->color = players[fourthplaya].skincolor;
@ -1723,14 +1723,14 @@ static void SendNameAndColor4(void)
snac4pending++; snac4pending++;
// Don't change name if muted // Don't change name if muted
if (cv_mute.value && !(server || IsPlayerAdmin(fourthdisplayplayer))) if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3])))
CV_StealthSet(&cv_playername4, player_names[fourthdisplayplayer]); CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
else // Cleanup name if changing it else // Cleanup name if changing it
CleanupPlayerName(fourthdisplayplayer, cv_playername4.zstring); CleanupPlayerName(displayplayers[3], cv_playername4.zstring);
// Don't change skin if the server doesn't want you to. // Don't change skin if the server doesn't want you to.
if (!CanChangeSkin(fourthdisplayplayer)) if (!CanChangeSkin(displayplayers[3]))
CV_StealthSet(&cv_skin4, skins[players[fourthdisplayplayer].skin].name); CV_StealthSet(&cv_skin4, skins[players[displayplayers[3]].skin].name);
// check if player has the skin loaded (cv_skin4 may have // check if player has the skin loaded (cv_skin4 may have
// the name of a skin that was available in the previous game) // the name of a skin that was available in the previous game)
@ -1760,12 +1760,12 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
#endif #endif
if (playernum == consoleplayer) if (playernum == consoleplayer)
snacpending--; snacpending--; // TODO: make snacpending an array instead of 4 separate vars?
else if (playernum == secondarydisplayplayer) else if (playernum == displayplayers[1])
snac2pending--; snac2pending--;
else if (playernum == thirddisplayplayer) else if (playernum == displayplayers[2])
snac3pending--; snac3pending--;
else if (playernum == fourthdisplayplayer) else if (playernum == displayplayers[3])
snac4pending--; snac4pending--;
#ifdef PARANOIA #ifdef PARANOIA
@ -1788,8 +1788,8 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
demo_extradata[playernum] |= DXD_COLOR; demo_extradata[playernum] |= DXD_COLOR;
// normal player colors // normal player colors
if (server && (p != &players[consoleplayer] && p != &players[secondarydisplayplayer] if (server && (p != &players[consoleplayer] && p != &players[displayplayers[1]]
&& p != &players[thirddisplayplayer] && p != &players[fourthdisplayplayer])) && p != &players[displayplayers[2]] && p != &players[displayplayers[3]]))
{ {
boolean kick = false; boolean kick = false;
@ -1826,11 +1826,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
if (playernum == consoleplayer) if (playernum == consoleplayer)
CV_StealthSet(&cv_skin, skins[forcedskin].name); CV_StealthSet(&cv_skin, skins[forcedskin].name);
else if (playernum == secondarydisplayplayer) else if (playernum == displayplayers[1])
CV_StealthSet(&cv_skin2, skins[forcedskin].name); CV_StealthSet(&cv_skin2, skins[forcedskin].name);
else if (playernum == thirddisplayplayer) else if (playernum == displayplayers[2])
CV_StealthSet(&cv_skin3, skins[forcedskin].name); CV_StealthSet(&cv_skin3, skins[forcedskin].name);
else if (playernum == fourthdisplayplayer) else if (playernum == displayplayers[3])
CV_StealthSet(&cv_skin4, skins[forcedskin].name); CV_StealthSet(&cv_skin4, skins[forcedskin].name);
} }
else else
@ -1917,7 +1917,7 @@ void D_SendPlayerConfig(void)
// Only works for displayplayer, sorry! // Only works for displayplayer, sorry!
static void Command_ResetCamera_f(void) static void Command_ResetCamera_f(void)
{ {
P_ResetCamera(&players[displayplayer], &camera); P_ResetCamera(&players[displayplayers[0]], &camera[0]);
} }
/* Consider replacing nametonum with this */ /* Consider replacing nametonum with this */
@ -2014,7 +2014,7 @@ static void Command_View_f(void)
return; return;
} }
displayplayerp = G_GetDisplayplayerPtr(viewnum); displayplayerp = &displayplayers[viewnum];
if (COM_Argc() > 1)/* switch to player */ if (COM_Argc() > 1)/* switch to player */
{ {
@ -2302,7 +2302,7 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r
{ {
//CL_AddSplitscreenPlayer(); //CL_AddSplitscreenPlayer();
botingame = true; botingame = true;
secondarydisplayplayer = 1; displayplayers[1] = 1;
playeringame[1] = true; playeringame[1] = true;
players[1].bot = 1; players[1].bot = 1;
SendNameAndColor2(); SendNameAndColor2();
@ -2354,12 +2354,8 @@ void D_ModifyClientVote(SINT8 voted, UINT8 splitplayer)
char *p = buf; char *p = buf;
UINT8 player = consoleplayer; UINT8 player = consoleplayer;
if (splitplayer == 1) if (splitplayer > 0)
player = secondarydisplayplayer; player = displayplayers[splitplayer];
else if (splitplayer == 2)
player = thirddisplayplayer;
else if (splitplayer == 3)
player = fourthdisplayplayer;
WRITESINT8(p, voted); WRITESINT8(p, voted);
WRITEUINT8(p, player); WRITEUINT8(p, player);
@ -3006,11 +3002,11 @@ static void Command_Teamchange2_f(void)
return; return;
} }
if (players[secondarydisplayplayer].spectator) if (players[displayplayers[1]].spectator)
error = !(NetPacket.packet.newteam || (players[secondarydisplayplayer].pflags & PF_WANTSTOJOIN)); error = !(NetPacket.packet.newteam || (players[displayplayers[1]].pflags & PF_WANTSTOJOIN));
else if (G_GametypeHasTeams()) else if (G_GametypeHasTeams())
error = (NetPacket.packet.newteam == (unsigned)players[secondarydisplayplayer].ctfteam); error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[1]].ctfteam);
else if (G_GametypeHasSpectators() && !players[secondarydisplayplayer].spectator) else if (G_GametypeHasSpectators() && !players[displayplayers[1]].spectator)
error = (NetPacket.packet.newteam == 3); error = (NetPacket.packet.newteam == 3);
#ifdef PARANOIA #ifdef PARANOIA
else else
@ -3097,11 +3093,11 @@ static void Command_Teamchange3_f(void)
return; return;
} }
if (players[thirddisplayplayer].spectator) if (players[displayplayers[2]].spectator)
error = !(NetPacket.packet.newteam || (players[thirddisplayplayer].pflags & PF_WANTSTOJOIN)); error = !(NetPacket.packet.newteam || (players[displayplayers[2]].pflags & PF_WANTSTOJOIN));
else if (G_GametypeHasTeams()) else if (G_GametypeHasTeams())
error = (NetPacket.packet.newteam == (unsigned)players[thirddisplayplayer].ctfteam); error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[2]].ctfteam);
else if (G_GametypeHasSpectators() && !players[thirddisplayplayer].spectator) else if (G_GametypeHasSpectators() && !players[displayplayers[2]].spectator)
error = (NetPacket.packet.newteam == 3); error = (NetPacket.packet.newteam == 3);
#ifdef PARANOIA #ifdef PARANOIA
else else
@ -3188,11 +3184,11 @@ static void Command_Teamchange4_f(void)
return; return;
} }
if (players[fourthdisplayplayer].spectator) if (players[displayplayers[3]].spectator)
error = !(NetPacket.packet.newteam || (players[fourthdisplayplayer].pflags & PF_WANTSTOJOIN)); error = !(NetPacket.packet.newteam || (players[displayplayers[3]].pflags & PF_WANTSTOJOIN));
else if (G_GametypeHasTeams()) else if (G_GametypeHasTeams())
error = (NetPacket.packet.newteam == (unsigned)players[fourthdisplayplayer].ctfteam); error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[3]].ctfteam);
else if (G_GametypeHasSpectators() && !players[fourthdisplayplayer].spectator) else if (G_GametypeHasSpectators() && !players[displayplayers[3]].spectator)
error = (NetPacket.packet.newteam == 3); error = (NetPacket.packet.newteam == 3);
#ifdef PARANOIA #ifdef PARANOIA
else else
@ -3589,8 +3585,8 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
HU_AddChatText(va("\x82*%s became a spectator.", player_names[playernum]), false); // "entered the game" text was moved to P_SpectatorJoinGame HU_AddChatText(va("\x82*%s became a spectator.", player_names[playernum]), false); // "entered the game" text was moved to P_SpectatorJoinGame
//reset view if you are changed, or viewing someone who was changed. //reset view if you are changed, or viewing someone who was changed.
if (playernum == consoleplayer || displayplayer == playernum) if (playernum == consoleplayer || displayplayers[0] == playernum)
displayplayer = consoleplayer; displayplayers[0] = consoleplayer;
if (G_GametypeHasTeams()) if (G_GametypeHasTeams())
{ {
@ -3598,11 +3594,11 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
{ {
if (playernum == consoleplayer) //CTF and Team Match colors. if (playernum == consoleplayer) //CTF and Team Match colors.
CV_SetValue(&cv_playercolor, NetPacket.packet.newteam + 5); CV_SetValue(&cv_playercolor, NetPacket.packet.newteam + 5);
else if (playernum == secondarydisplayplayer) else if (playernum == displayplayers[1])
CV_SetValue(&cv_playercolor2, NetPacket.packet.newteam + 5); CV_SetValue(&cv_playercolor2, NetPacket.packet.newteam + 5);
else if (playernum == thirddisplayplayer) else if (playernum == displayplayers[2])
CV_SetValue(&cv_playercolor3, NetPacket.packet.newteam + 5); CV_SetValue(&cv_playercolor3, NetPacket.packet.newteam + 5);
else if (playernum == fourthdisplayplayer) else if (playernum == displayplayers[3])
CV_SetValue(&cv_playercolor4, NetPacket.packet.newteam + 5); CV_SetValue(&cv_playercolor4, NetPacket.packet.newteam + 5);
} }
} }
@ -5208,13 +5204,13 @@ static void Got_PickVotecmd(UINT8 **cp, INT32 playernum)
Y_SetupVoteFinish(pick, level); Y_SetupVoteFinish(pick, level);
} }
/** Prints the number of the displayplayer. /** Prints the number of displayplayers[0].
* *
* \todo Possibly remove this; it was useful for debugging at one point. * \todo Possibly remove this; it was useful for debugging at one point.
*/ */
static void Command_Displayplayer_f(void) static void Command_Displayplayer_f(void)
{ {
CONS_Printf(M_GetText("Displayplayer is %d\n"), displayplayer); CONS_Printf(M_GetText("Displayplayer is %d\n"), displayplayers[0]);
} }
/** Quits a game and returns to the title screen. /** Quits a game and returns to the title screen.
@ -5425,7 +5421,7 @@ static void Name2_OnChange(void)
if (cv_mute.value) //Secondary player can't be admin. if (cv_mute.value) //Secondary player can't be admin.
{ {
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
CV_StealthSet(&cv_playername2, player_names[secondarydisplayplayer]); CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
} }
else else
SendNameAndColor2(); SendNameAndColor2();
@ -5436,7 +5432,7 @@ static void Name3_OnChange(void)
if (cv_mute.value) //Third player can't be admin. if (cv_mute.value) //Third player can't be admin.
{ {
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
CV_StealthSet(&cv_playername3, player_names[thirddisplayplayer]); CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
} }
else else
SendNameAndColor3(); SendNameAndColor3();
@ -5447,7 +5443,7 @@ static void Name4_OnChange(void)
if (cv_mute.value) //Secondary player can't be admin. if (cv_mute.value) //Secondary player can't be admin.
{ {
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
CV_StealthSet(&cv_playername4, player_names[fourthdisplayplayer]); CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
} }
else else
SendNameAndColor4(); SendNameAndColor4();
@ -5488,12 +5484,12 @@ static void Skin2_OnChange(void)
if (!Playing() || !splitscreen) if (!Playing() || !splitscreen)
return; // do whatever you want return; // do whatever you want
if (CanChangeSkin(secondarydisplayplayer) && !P_PlayerMoving(secondarydisplayplayer)) if (CanChangeSkin(displayplayers[1]) && !P_PlayerMoving(displayplayers[1]))
SendNameAndColor2(); SendNameAndColor2();
else else
{ {
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
CV_StealthSet(&cv_skin2, skins[players[secondarydisplayplayer].skin].name); CV_StealthSet(&cv_skin2, skins[players[displayplayers[1]].skin].name);
} }
} }
@ -5502,12 +5498,12 @@ static void Skin3_OnChange(void)
if (!Playing() || splitscreen < 2) if (!Playing() || splitscreen < 2)
return; // do whatever you want return; // do whatever you want
if (CanChangeSkin(thirddisplayplayer) && !P_PlayerMoving(thirddisplayplayer)) if (CanChangeSkin(displayplayers[2]) && !P_PlayerMoving(displayplayers[2]))
SendNameAndColor3(); SendNameAndColor3();
else else
{ {
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
CV_StealthSet(&cv_skin3, skins[players[thirddisplayplayer].skin].name); CV_StealthSet(&cv_skin3, skins[players[displayplayers[2]].skin].name);
} }
} }
@ -5516,12 +5512,12 @@ static void Skin4_OnChange(void)
if (!Playing() || splitscreen < 3) if (!Playing() || splitscreen < 3)
return; // do whatever you want return; // do whatever you want
if (CanChangeSkin(fourthdisplayplayer) && !P_PlayerMoving(fourthdisplayplayer)) if (CanChangeSkin(displayplayers[3]) && !P_PlayerMoving(displayplayers[3]))
SendNameAndColor4(); SendNameAndColor4();
else else
{ {
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
CV_StealthSet(&cv_skin4, skins[players[fourthdisplayplayer].skin].name); CV_StealthSet(&cv_skin4, skins[players[displayplayers[3]].skin].name);
} }
} }
@ -5562,7 +5558,7 @@ static void Color2_OnChange(void)
if (!Playing() || !splitscreen) if (!Playing() || !splitscreen)
return; // do whatever you want return; // do whatever you want
if (!P_PlayerMoving(secondarydisplayplayer)) if (!P_PlayerMoving(displayplayers[1]))
{ {
// Color change menu scrolling fix is no longer necessary // Color change menu scrolling fix is no longer necessary
SendNameAndColor2(); SendNameAndColor2();
@ -5570,7 +5566,7 @@ static void Color2_OnChange(void)
else else
{ {
CV_StealthSetValue(&cv_playercolor2, CV_StealthSetValue(&cv_playercolor2,
players[secondarydisplayplayer].skincolor); players[displayplayers[1]].skincolor);
} }
} }
@ -5579,7 +5575,7 @@ static void Color3_OnChange(void)
if (!Playing() || splitscreen < 2) if (!Playing() || splitscreen < 2)
return; // do whatever you want return; // do whatever you want
if (!P_PlayerMoving(thirddisplayplayer)) if (!P_PlayerMoving(displayplayers[2]))
{ {
// Color change menu scrolling fix is no longer necessary // Color change menu scrolling fix is no longer necessary
SendNameAndColor3(); SendNameAndColor3();
@ -5587,7 +5583,7 @@ static void Color3_OnChange(void)
else else
{ {
CV_StealthSetValue(&cv_playercolor3, CV_StealthSetValue(&cv_playercolor3,
players[thirddisplayplayer].skincolor); players[displayplayers[2]].skincolor);
} }
} }
@ -5596,7 +5592,7 @@ static void Color4_OnChange(void)
if (!Playing() || splitscreen < 3) if (!Playing() || splitscreen < 3)
return; // do whatever you want return; // do whatever you want
if (!P_PlayerMoving(fourthdisplayplayer)) if (!P_PlayerMoving(displayplayers[3]))
{ {
// Color change menu scrolling fix is no longer necessary // Color change menu scrolling fix is no longer necessary
SendNameAndColor4(); SendNameAndColor4();
@ -5604,7 +5600,7 @@ static void Color4_OnChange(void)
else else
{ {
CV_StealthSetValue(&cv_playercolor4, CV_StealthSetValue(&cv_playercolor4,
players[fourthdisplayplayer].skincolor); players[displayplayers[3]].skincolor);
} }
} }

View file

@ -9799,7 +9799,7 @@ static inline int lib_getenum(lua_State *L)
// DYNAMIC variables too!! // DYNAMIC variables too!!
// Try not to add anything that would break netgames or timeattack replays here. // Try not to add anything that would break netgames or timeattack replays here.
// You know, like consoleplayer, displayplayer, secondarydisplayplayer, or gametime. // You know, like consoleplayer, displayplayers, or gametime.
if (fastcmp(word,"gamemap")) { if (fastcmp(word,"gamemap")) {
lua_pushinteger(L, gamemap); lua_pushinteger(L, gamemap);
return 1; return 1;

View file

@ -106,14 +106,8 @@ extern UINT8 window_notinfocus; // are we in focus? (backend independant -- hand
extern boolean nodrawers; extern boolean nodrawers;
extern boolean noblit; extern boolean noblit;
extern boolean lastdraw; extern boolean lastdraw;
extern postimg_t postimgtype; extern postimg_t postimgtype[MAXSPLITSCREENPLAYERS];
extern INT32 postimgparam; extern INT32 postimgparam[MAXSPLITSCREENPLAYERS];
extern postimg_t postimgtype2;
extern INT32 postimgparam2;
extern postimg_t postimgtype3;
extern INT32 postimgparam3;
extern postimg_t postimgtype4;
extern INT32 postimgparam4;
extern INT32 viewwindowx, viewwindowy; extern INT32 viewwindowx, viewwindowy;
extern INT32 viewwidth, scaledviewwidth; extern INT32 viewwidth, scaledviewwidth;
@ -122,10 +116,7 @@ extern boolean gamedataloaded;
// Player taking events, and displaying. // Player taking events, and displaying.
extern INT32 consoleplayer; extern INT32 consoleplayer;
extern INT32 displayplayer; extern INT32 displayplayers[MAXSPLITSCREENPLAYERS];
extern INT32 secondarydisplayplayer; // for splitscreen
extern INT32 thirddisplayplayer;
extern INT32 fourthdisplayplayer;
// Maps of special importance // Maps of special importance
extern INT16 spstage_start; extern INT16 spstage_start;

View file

@ -112,10 +112,7 @@ boolean addedtogame;
player_t players[MAXPLAYERS]; player_t players[MAXPLAYERS];
INT32 consoleplayer; // player taking events and displaying INT32 consoleplayer; // player taking events and displaying
INT32 displayplayer; // view being displayed INT32 displayplayers[MAXSPLITSCREENPLAYERS]; // view being displayed
INT32 secondarydisplayplayer; // for splitscreen
INT32 thirddisplayplayer;
INT32 fourthdisplayplayer;
tic_t gametic; tic_t gametic;
tic_t levelstarttic; // gametic at level start tic_t levelstarttic; // gametic at level start
@ -1220,9 +1217,9 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 p)
// //
// set secondaryplayer true to build player 2's ticcmd in splitscreen mode // set secondaryplayer true to build player 2's ticcmd in splitscreen mode
// //
INT32 localaiming, localaiming2, localaiming3, localaiming4; INT32 localaiming[MAXSPLITSCREENPLAYERS]; // TODO: convert these 3 into MAXSPLITSCREENPLAYERS arrays
angle_t localangle, localangle2, localangle3, localangle4; angle_t localangle[MAXSPLITSCREENPLAYERS];
boolean camspin, camspin2, camspin3, camspin4; boolean camspin[MAXSPLITSCREENPLAYERS];
static fixed_t forwardmove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16}; static fixed_t forwardmove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16};
static fixed_t sidemove[2] = {2<<FRACBITS>>16, 4<<FRACBITS>>16}; static fixed_t sidemove[2] = {2<<FRACBITS>>16, 4<<FRACBITS>>16};
@ -1239,53 +1236,36 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
camera_t *thiscam; camera_t *thiscam;
angle_t lang; angle_t lang;
static INT32 turnheld, turnheld2, turnheld3, turnheld4; // for accelerative turning static INT32 turnheld[MAXSPLITSCREENPLAYERS]; // for accelerative turning
static boolean keyboard_look, keyboard_look2, keyboard_look3, keyboard_look4; // true if lookup/down using keyboard static boolean keyboard_look[MAXSPLITSCREENPLAYERS]; // true if lookup/down using keyboard
static boolean resetdown, resetdown2, resetdown3, resetdown4; // don't cam reset every frame static boolean resetdown[MAXSPLITSCREENPLAYERS]; // don't cam reset every frame
if (demo.playback) return; if (demo.playback) return;
player = &players[displayplayers[ssplayer-1]];
if (ssplayer == 2)
thiscam = (player->bot == 2 ? &camera[0] : &camera[ssplayer-1]);
else
thiscam = &camera[ssplayer-1];
lang = localangle[ssplayer-1];
laim = localaiming[ssplayer-1];
th = turnheld[ssplayer-1];
kbl = keyboard_look[ssplayer-1];
rd = resetdown[ssplayer-1];
switch (ssplayer) switch (ssplayer)
{ {
case 2: case 2:
player = &players[secondarydisplayplayer];
thiscam = (player->bot == 2 ? &camera : &camera2);
lang = localangle2;
laim = localaiming2;
th = turnheld2;
kbl = keyboard_look2;
rd = resetdown2;
G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1);
break; break;
case 3: case 3:
player = &players[thirddisplayplayer];
thiscam = &camera3;
lang = localangle3;
laim = localaiming3;
th = turnheld3;
kbl = keyboard_look3;
rd = resetdown3;
G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1);
break; break;
case 4: case 4:
player = &players[fourthdisplayplayer];
thiscam = &camera4;
lang = localangle4;
laim = localaiming4;
th = turnheld4;
kbl = keyboard_look4;
rd = resetdown4;
G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1);
break; break;
case 1: case 1:
default: default:
player = &players[consoleplayer];
thiscam = &camera;
lang = localangle;
laim = localaiming;
th = turnheld;
kbl = keyboard_look;
rd = resetdown;
G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver
break; break;
} }
@ -1576,42 +1556,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
if (!hu_stopped) if (!hu_stopped)
{ {
switch (ssplayer) localangle[ssplayer-1] = lang;
{ localaiming[ssplayer-1] = laim;
case 2: keyboard_look[ssplayer-1] = kbl;
localangle2 = lang; turnheld[ssplayer-1] = th;
localaiming2 = laim; resetdown[ssplayer-1] = rd;
keyboard_look2 = kbl; camspin[ssplayer-1] = InputDown(gc_lookback, ssplayer);
turnheld2 = th;
resetdown2 = rd;
camspin2 = InputDown(gc_lookback, ssplayer);
break;
case 3:
localangle3 = lang;
localaiming3 = laim;
keyboard_look3 = kbl;
turnheld3 = th;
resetdown3 = rd;
camspin3 = InputDown(gc_lookback, ssplayer);
break;
case 4:
localangle4 = lang;
localaiming4 = laim;
keyboard_look4 = kbl;
turnheld4 = th;
resetdown4 = rd;
camspin4 = InputDown(gc_lookback, ssplayer);
break;
case 1:
default:
localangle = lang;
localaiming = laim;
keyboard_look = kbl;
turnheld = th;
resetdown = rd;
camspin = InputDown(gc_lookback, ssplayer);
break;
}
} }
/* Lua: Allow this hook to overwrite ticcmd. /* Lua: Allow this hook to overwrite ticcmd.
@ -1631,8 +1581,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
//Reset away view if a command is given. //Reset away view if a command is given.
if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) if ((cmd->forwardmove || cmd->sidemove || cmd->buttons)
&& displayplayer != consoleplayer && ssplayer == 1) && displayplayers[0] != consoleplayer && ssplayer == 1)
displayplayer = consoleplayer; displayplayers[0] = consoleplayer;
} }
@ -1784,27 +1734,24 @@ void G_DoLoadLevel(boolean resetplayer)
if (!resetplayer) if (!resetplayer)
P_FindEmerald(); P_FindEmerald();
displayplayer = consoleplayer; // view the guy you are playing displayplayers[0] = consoleplayer; // view the guy you are playing
if (!splitscreen && !botingame)
secondarydisplayplayer = consoleplayer; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
if (splitscreen < 2) {
thirddisplayplayer = consoleplayer; if (i > 0 && !(i == 1 && botingame) && splitscreen < i)
if (splitscreen < 3) displayplayers[i] = consoleplayer;
fourthdisplayplayer = consoleplayer; }
gameaction = ga_nothing; gameaction = ga_nothing;
#ifdef PARANOIA #ifdef PARANOIA
Z_CheckHeap(-2); Z_CheckHeap(-2);
#endif #endif
if (camera.chase) for (i = 0; i <= splitscreen; i++)
P_ResetCamera(&players[displayplayer], &camera); {
if (camera2.chase && splitscreen) if (camera[i].chase)
P_ResetCamera(&players[secondarydisplayplayer], &camera2); P_ResetCamera(&players[displayplayers[i]], &camera[i]);
if (camera3.chase && splitscreen > 1) }
P_ResetCamera(&players[thirddisplayplayer], &camera3);
if (camera4.chase && splitscreen > 2)
P_ResetCamera(&players[fourthdisplayplayer], &camera4);
// clear cmd building stuff // clear cmd building stuff
memset(gamekeydown, 0, sizeof (gamekeydown)); memset(gamekeydown, 0, sizeof (gamekeydown));
@ -1914,7 +1861,7 @@ boolean G_Responder(event_t *ev)
&& (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1]))
{ {
if (!demo.playback && (splitscreen || !netgame)) if (!demo.playback && (splitscreen || !netgame))
displayplayer = consoleplayer; displayplayers[0] = consoleplayer;
else else
{ {
G_AdjustView(1, 1, true); G_AdjustView(1, 1, true);
@ -2184,13 +2131,13 @@ boolean G_CanView(INT32 playernum, UINT8 viewnum, boolean onlyactive)
for (viewd = 1; viewd < viewnum; ++viewd) for (viewd = 1; viewd < viewnum; ++viewd)
{ {
displayplayerp = (G_GetDisplayplayerPtr(viewd)); displayplayerp = (&displayplayers[viewd-1]);
if ((*displayplayerp) == playernum) if ((*displayplayerp) == playernum)
return false; return false;
} }
for (viewd = viewnum + 1; viewd <= splits; ++viewd) for (viewd = viewnum + 1; viewd <= splits; ++viewd)
{ {
displayplayerp = (G_GetDisplayplayerPtr(viewd)); displayplayerp = (&displayplayers[viewd-1]);
if ((*displayplayerp) == playernum) if ((*displayplayerp) == playernum)
return false; return false;
} }
@ -2232,17 +2179,6 @@ INT32 G_CountPlayersPotentiallyViewable(boolean active)
return total; return total;
} }
INT32 *G_GetDisplayplayerPtr(UINT8 viewnum)
{
switch (viewnum)
{
case 2: return &secondarydisplayplayer;
case 3: return &thirddisplayplayer;
case 4: return &fourthdisplayplayer;
}
return &displayplayer;
}
// //
// G_ResetView // G_ResetView
// Correct a viewpoint to playernum or the next available, wraps forward. // Correct a viewpoint to playernum or the next available, wraps forward.
@ -2276,14 +2212,14 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
/* Prepare extra views for G_FindView to pass. */ /* Prepare extra views for G_FindView to pass. */
for (viewd = splits+1; viewd < viewnum; ++viewd) for (viewd = splits+1; viewd < viewnum; ++viewd)
{ {
displayplayerp = (G_GetDisplayplayerPtr(viewd)); displayplayerp = (&displayplayers[viewd-1]);
(*displayplayerp) = INT32_MAX; (*displayplayerp) = INT32_MAX;
} }
R_ExecuteSetViewSize(); R_ExecuteSetViewSize();
} }
displayplayerp = (G_GetDisplayplayerPtr(viewnum)); displayplayerp = (&displayplayers[viewnum-1]);
olddisplayplayer = (*displayplayerp); olddisplayplayer = (*displayplayerp);
/* Check if anyone is available to view. */ /* Check if anyone is available to view. */
@ -2294,7 +2230,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
(*displayplayerp) = playernum; (*displayplayerp) = playernum;
if ((*displayplayerp) != olddisplayplayer) if ((*displayplayerp) != olddisplayplayer)
{ {
camerap = (P_GetCameraPtr(viewnum)); camerap = &camera[viewnum-1];
P_ResetCamera(&players[(*displayplayerp)], camerap); P_ResetCamera(&players[(*displayplayerp)], camerap);
} }
@ -2302,8 +2238,8 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
{ {
for (viewd = splits+1; viewd < viewnum; ++viewd) for (viewd = splits+1; viewd < viewnum; ++viewd)
{ {
displayplayerp = (G_GetDisplayplayerPtr(viewd)); displayplayerp = (&displayplayers[viewd-1]);
camerap = (P_GetCameraPtr(viewd)); camerap = &camera[viewd];
(*displayplayerp) = G_FindView(0, viewd, onlyactive, false); (*displayplayerp) = G_FindView(0, viewd, onlyactive, false);
@ -2312,7 +2248,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
} }
if (viewnum == 1 && demo.playback) if (viewnum == 1 && demo.playback)
consoleplayer = displayplayer; consoleplayer = displayplayers[0];
} }
// //
@ -2323,7 +2259,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive) void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive)
{ {
INT32 *displayplayerp, oldview; INT32 *displayplayerp, oldview;
displayplayerp = G_GetDisplayplayerPtr(viewnum); displayplayerp = &displayplayers[viewnum-1];
oldview = (*displayplayerp); oldview = (*displayplayerp);
G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive); G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive);
@ -2864,22 +2800,22 @@ void G_PlayerReborn(INT32 player)
{ {
if (p == &players[consoleplayer]) if (p == &players[consoleplayer])
CV_SetValue(&cv_playercolor, skincolor_redteam); CV_SetValue(&cv_playercolor, skincolor_redteam);
else if (p == &players[secondarydisplayplayer]) else if (p == &players[displayplayers[1]])
CV_SetValue(&cv_playercolor2, skincolor_redteam); CV_SetValue(&cv_playercolor2, skincolor_redteam);
else if (p == &players[thirddisplayplayer]) else if (p == &players[displayplayers[2]])
CV_SetValue(&cv_playercolor3, skincolor_redteam); CV_SetValue(&cv_playercolor3, skincolor_redteam);
else if (p == &players[fourthdisplayplayer]) else if (p == &players[displayplayers[3]])
CV_SetValue(&cv_playercolor4, skincolor_redteam); CV_SetValue(&cv_playercolor4, skincolor_redteam);
} }
else if (p->ctfteam == 2 && p->skincolor != skincolor_blueteam) else if (p->ctfteam == 2 && p->skincolor != skincolor_blueteam)
{ {
if (p == &players[consoleplayer]) if (p == &players[consoleplayer])
CV_SetValue(&cv_playercolor, skincolor_blueteam); CV_SetValue(&cv_playercolor, skincolor_blueteam);
else if (p == &players[secondarydisplayplayer]) else if (p == &players[displayplayers[1]])
CV_SetValue(&cv_playercolor2, skincolor_blueteam); CV_SetValue(&cv_playercolor2, skincolor_blueteam);
else if (p == &players[thirddisplayplayer]) else if (p == &players[displayplayers[2]])
CV_SetValue(&cv_playercolor3, skincolor_blueteam); CV_SetValue(&cv_playercolor3, skincolor_blueteam);
else if (p == &players[fourthdisplayplayer]) else if (p == &players[displayplayers[3]])
CV_SetValue(&cv_playercolor4, skincolor_blueteam); CV_SetValue(&cv_playercolor4, skincolor_blueteam);
} }
}*/ }*/
@ -2984,18 +2920,18 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost)
if (nummapthings) if (nummapthings)
{ {
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the first mapthing!\n")); CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the first mapthing!\n"));
spawnpoint = &mapthings[0]; spawnpoint = &mapthings[0];
} }
else else
{ {
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the origin!\n")); 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. //P_MovePlayerToSpawn handles this fine if the spawnpoint is NULL.
} }
@ -3015,9 +2951,9 @@ mapthing_t *G_FindCTFStart(INT32 playernum)
if (!numredctfstarts && !numbluectfstarts) //why even bother, eh? if (!numredctfstarts && !numbluectfstarts) //why even bother, eh?
{ {
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_WARNING, M_GetText("No CTF starts in this map!\n")); CONS_Alert(CONS_WARNING, M_GetText("No CTF starts in this map!\n"));
return NULL; return NULL;
} }
@ -3027,9 +2963,9 @@ mapthing_t *G_FindCTFStart(INT32 playernum)
if (!numredctfstarts) if (!numredctfstarts)
{ {
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_WARNING, M_GetText("No Red Team starts in this map!\n")); CONS_Alert(CONS_WARNING, M_GetText("No Red Team starts in this map!\n"));
return NULL; return NULL;
} }
@ -3042,9 +2978,9 @@ mapthing_t *G_FindCTFStart(INT32 playernum)
} }
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Red Team starts!\n")); CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Red Team starts!\n"));
return NULL; return NULL;
} }
@ -3053,9 +2989,9 @@ mapthing_t *G_FindCTFStart(INT32 playernum)
if (!numbluectfstarts) if (!numbluectfstarts)
{ {
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_WARNING, M_GetText("No Blue Team starts in this map!\n")); CONS_Alert(CONS_WARNING, M_GetText("No Blue Team starts in this map!\n"));
return NULL; return NULL;
} }
@ -3067,9 +3003,9 @@ mapthing_t *G_FindCTFStart(INT32 playernum)
return bluectfstarts[i]; return bluectfstarts[i];
} }
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Blue Team starts!\n")); CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Blue Team starts!\n"));
return NULL; return NULL;
} }
@ -3090,17 +3026,17 @@ mapthing_t *G_FindMatchStart(INT32 playernum)
return deathmatchstarts[i]; return deathmatchstarts[i];
} }
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Deathmatch starts!\n")); CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Deathmatch starts!\n"));
return NULL; return NULL;
} }
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_WARNING, M_GetText("No Deathmatch starts in this map!\n")); CONS_Alert(CONS_WARNING, M_GetText("No Deathmatch starts in this map!\n"));
return NULL; return NULL;
} }
@ -3166,17 +3102,17 @@ mapthing_t *G_FindRaceStart(INT32 playernum)
//return playerstarts[0]; //return playerstarts[0];
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Race starts!\n")); CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Race starts!\n"));
return NULL; return NULL;
} }
if (playernum == consoleplayer if (playernum == consoleplayer
|| (splitscreen && playernum == secondarydisplayplayer) || (splitscreen && playernum == displayplayers[1])
|| (splitscreen > 1 && playernum == thirddisplayplayer) || (splitscreen > 1 && playernum == displayplayers[2])
|| (splitscreen > 2 && playernum == fourthdisplayplayer)) || (splitscreen > 2 && playernum == displayplayers[3]))
CONS_Alert(CONS_WARNING, M_GetText("No Race starts in this map!\n")); CONS_Alert(CONS_WARNING, M_GetText("No Race starts in this map!\n"));
return NULL; return NULL;
} }
@ -3268,14 +3204,11 @@ void G_DoReborn(INT32 playernum)
if (player->starpostnum) // SRB2kart if (player->starpostnum) // SRB2kart
starpost = true; starpost = true;
if (camera.chase) for (i = 0; i <= splitscreen; i++)
P_ResetCamera(&players[displayplayer], &camera); {
if (camera2.chase && splitscreen > 0) if (camera[i].chase)
P_ResetCamera(&players[secondarydisplayplayer], &camera2); P_ResetCamera(&players[displayplayers[i]], &camera[i]);
if (camera3.chase && splitscreen > 1) }
P_ResetCamera(&players[thirddisplayplayer], &camera3);
if (camera4.chase && splitscreen > 2)
P_ResetCamera(&players[fourthdisplayplayer], &camera4);
// clear cmd building stuff // clear cmd building stuff
memset(gamekeydown, 0, sizeof (gamekeydown)); memset(gamekeydown, 0, sizeof (gamekeydown));
@ -3297,8 +3230,8 @@ void G_DoReborn(INT32 playernum)
if (botingame) if (botingame)
{ // Bots respawn next to their master. { // Bots respawn next to their master.
players[secondarydisplayplayer].playerstate = PST_REBORN; players[displayplayers[1]].playerstate = PST_REBORN;
G_SpawnPlayer(secondarydisplayplayer, false); G_SpawnPlayer(displayplayers[1], false);
} }
} }
else else
@ -4418,7 +4351,7 @@ static void M_ForceLoadGameResponse(INT32 ch)
//set cursaveslot to -1 so nothing gets saved. //set cursaveslot to -1 so nothing gets saved.
cursaveslot = -1; cursaveslot = -1;
displayplayer = consoleplayer; displayplayers[0] = consoleplayer;
multiplayer = false; multiplayer = false;
splitscreen = 0; splitscreen = 0;
SplitScreen_OnChange(); // not needed? SplitScreen_OnChange(); // not needed?
@ -4508,7 +4441,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride)
// gameaction = ga_nothing; // gameaction = ga_nothing;
// G_SetGamestate(GS_LEVEL); // G_SetGamestate(GS_LEVEL);
displayplayer = consoleplayer; displayplayers[0] = consoleplayer;
multiplayer = false; multiplayer = false;
splitscreen = 0; splitscreen = 0;
SplitScreen_OnChange(); // not needed? SplitScreen_OnChange(); // not needed?
@ -4573,7 +4506,7 @@ void G_SaveGame(UINT32 savegameslot)
// //
// G_DeferedInitNew // G_DeferedInitNew
// Can be called by the startup code or the menu task, // Can be called by the startup code or the menu task,
// consoleplayer, displayplayer, playeringame[] should be set. // consoleplayer, displayplayers[], playeringame[] should be set.
// //
void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar, UINT8 ssplayers, boolean FLS) void G_DeferedInitNew(boolean pencoremode, const char *mapname, INT32 pickedchar, UINT8 ssplayers, boolean FLS)
{ {
@ -5167,12 +5100,12 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum)
G_CopyTiccmd(cmd, &oldcmd[playernum], 1); G_CopyTiccmd(cmd, &oldcmd[playernum], 1);
// SRB2kart: Copy-pasted from ticcmd building, removes that crappy demo cam // SRB2kart: Copy-pasted from ticcmd building, removes that crappy demo cam
if (((players[displayplayer].mo && players[displayplayer].speed > 0) // Moving if (((players[displayplayers[0]].mo && players[displayplayers[0]].speed > 0) // Moving
|| (leveltime > starttime && (cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE)) // Rubber-burn turn || (leveltime > starttime && (cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE)) // Rubber-burn turn
|| (players[displayplayer].kartstuff[k_respawn]) // Respawning || (players[displayplayers[0]].kartstuff[k_respawn]) // Respawning
|| (players[displayplayer].spectator || objectplacing)) // Not a physical player || (players[displayplayers[0]].spectator || objectplacing)) // Not a physical player
&& !(players[displayplayer].kartstuff[k_spinouttimer] && players[displayplayer].kartstuff[k_sneakertimer])) // Spinning and boosting cancels out spinout && !(players[displayplayers[0]].kartstuff[k_spinouttimer] && players[displayplayers[0]].kartstuff[k_sneakertimer])) // Spinning and boosting cancels out spinout
localangle += (cmd->angleturn<<16); localangle[0] += (cmd->angleturn<<16);
if (!(demoflags & DF_GHOST) && *demo_p == DEMOMARKER) if (!(demoflags & DF_GHOST) && *demo_p == DEMOMARKER)
{ {
@ -6073,7 +6006,7 @@ void G_PreviewRewind(tic_t previewtime)
} }
for (i = splitscreen+1; i > 0; i--) for (i = splitscreen+1; i > 0; i--)
P_ResetCamera(&players[(*G_GetDisplayplayerPtr(i))], P_GetCameraPtr(i)); P_ResetCamera(&players[displayplayers[i]], &camera[i]);
} }
void G_ConfirmRewind(tic_t rewindtime) void G_ConfirmRewind(tic_t rewindtime)
@ -6081,7 +6014,7 @@ void G_ConfirmRewind(tic_t rewindtime)
tic_t i; tic_t i;
boolean oldmenuactive = menuactive, oldsounddisabled = sound_disabled; boolean oldmenuactive = menuactive, oldsounddisabled = sound_disabled;
INT32 olddp1 = displayplayer, olddp2 = secondarydisplayplayer, olddp3 = thirddisplayplayer, olddp4 = fourthdisplayplayer; INT32 olddp1 = displayplayers[0], olddp2 = displayplayers[1], olddp3 = displayplayers[2], olddp4 = displayplayers[3];
UINT8 oldss = splitscreen; UINT8 oldss = splitscreen;
menuactive = false; // Prevent loops menuactive = false; // Prevent loops
@ -6113,15 +6046,15 @@ void G_ConfirmRewind(tic_t rewindtime)
COM_BufInsertText("renderview on\n"); COM_BufInsertText("renderview on\n");
splitscreen = oldss; splitscreen = oldss;
displayplayer = olddp1; displayplayers[0] = olddp1;
secondarydisplayplayer = olddp2; displayplayers[1] = olddp2;
thirddisplayplayer = olddp3; displayplayers[2] = olddp3;
fourthdisplayplayer = olddp4; displayplayers[3] = olddp4;
R_ExecuteSetViewSize(); R_ExecuteSetViewSize();
G_ResetViews(); G_ResetViews();
for (i = splitscreen+1; i > 0; i--) for (i = splitscreen+1; i > 0; i--)
P_ResetCamera(&players[(*G_GetDisplayplayerPtr(i))], P_GetCameraPtr(i)); P_ResetCamera(&players[displayplayers[i]], &camera[i]);
} }
void G_ReadMetalTic(mobj_t *metal) void G_ReadMetalTic(mobj_t *metal)
@ -7407,7 +7340,8 @@ void G_DoPlayDemo(char *defdemoname)
// didn't start recording right away. // didn't start recording right away.
demo.deferstart = false; demo.deferstart = false;
displayplayer = consoleplayer = 0; consoleplayer = 0;
memset(displayplayers, 0, sizeof(displayplayers));
memset(playeringame, 0, sizeof(playeringame)); memset(playeringame, 0, sizeof(playeringame));
playeringame[0] = true; playeringame[0] = true;
@ -7457,13 +7391,14 @@ void G_DoPlayDemo(char *defdemoname)
/*#ifdef HAVE_BLUA /*#ifdef HAVE_BLUA
LUAh_MapChange(gamemap); LUAh_MapChange(gamemap);
#endif*/ #endif*/
displayplayer = consoleplayer = 0; displayplayers[0] = consoleplayer = 0;
memset(playeringame,0,sizeof(playeringame)); memset(playeringame,0,sizeof(playeringame));
// Load players that were in-game when the map started // Load players that were in-game when the map started
p = READUINT8(demo_p); p = READUINT8(demo_p);
secondarydisplayplayer = thirddisplayplayer = fourthdisplayplayer = INT32_MAX; for (i = 1; i < MAXSPLITSCREENPLAYERS; i++);
displayplayers[i] = INT32_MAX;
while (p != 0xFF) while (p != 0xFF)
{ {
@ -7499,8 +7434,8 @@ void G_DoPlayDemo(char *defdemoname)
return; return;
} }
if (!playeringame[displayplayer] || players[displayplayer].spectator) if (!playeringame[displayplayers[0]] || players[displayplayers[0]].spectator)
displayplayer = consoleplayer = serverplayer = p; displayplayers[0] = consoleplayer = serverplayer = p;
playeringame[p] = true; playeringame[p] = true;
players[p].spectator = spectator; players[p].spectator = spectator;

View file

@ -152,9 +152,9 @@ INT16 G_SoftwareClipAimingPitch(INT32 *aiming);
boolean InputDown(INT32 gc, UINT8 p); boolean InputDown(INT32 gc, UINT8 p);
INT32 JoyAxis(axis_input_e axissel, UINT8 p); INT32 JoyAxis(axis_input_e axissel, UINT8 p);
extern angle_t localangle, localangle2, localangle3, localangle4; extern angle_t localangle[MAXSPLITSCREENPLAYERS];
extern INT32 localaiming, localaiming2, localaiming3, localaiming4; // should be an angle_t but signed extern INT32 localaiming[MAXSPLITSCREENPLAYERS]; // should be an angle_t but signed
extern boolean camspin, camspin2, camspin3, camspin4; // SRB2Kart extern boolean camspin[MAXSPLITSCREENPLAYERS]; // SRB2Kart
// //
// GAME // GAME
@ -297,8 +297,6 @@ void G_EndGame(void); // moved from y_inter.c/h and renamed
void G_Ticker(boolean run); void G_Ticker(boolean run);
boolean G_Responder(event_t *ev); boolean G_Responder(event_t *ev);
INT32 *G_GetDisplayplayerPtr(UINT8 viewnum);
boolean G_CouldView(INT32 playernum); boolean G_CouldView(INT32 playernum);
boolean G_CanView(INT32 playernum, UINT8 viewnum, boolean onlyactive); boolean G_CanView(INT32 playernum, UINT8 viewnum, boolean onlyactive);

View file

@ -39,7 +39,7 @@
#include "am_map.h" #include "am_map.h"
#include "d_main.h" #include "d_main.h"
#include "p_local.h" // camera, camera2, camera3, camera4 #include "p_local.h" // camera[]
#include "p_tick.h" #include "p_tick.h"
#ifdef HWRENDER #ifdef HWRENDER
@ -1987,7 +1987,7 @@ static void HU_DrawChat_Old(void)
if (!i) if (!i)
return; return;
if ((netgame || multiplayer) && players[displayplayer].spectator) if ((netgame || multiplayer) && players[displayplayers[0]].spectator)
return; return;
#ifdef HWRENDER #ifdef HWRENDER
@ -2014,7 +2014,7 @@ static inline void HU_DrawCrosshair2(void)
if (!i) if (!i)
return; return;
if ((netgame || multiplayer) && players[secondarydisplayplayer].spectator) if ((netgame || multiplayer) && players[displayplayers[1]].spectator)
return; return;
#ifdef HWRENDER #ifdef HWRENDER
@ -2061,7 +2061,7 @@ static inline void HU_DrawCrosshair3(void)
if (!i) if (!i)
return; return;
if ((netgame || multiplayer) && players[thirddisplayplayer].spectator) if ((netgame || multiplayer) && players[displayplayers[2]].spectator)
return; return;
#ifdef HWRENDER #ifdef HWRENDER
@ -2098,7 +2098,7 @@ static inline void HU_DrawCrosshair4(void)
if (!i) if (!i)
return; return;
if ((netgame || multiplayer) && players[fourthdisplayplayer].spectator) if ((netgame || multiplayer) && players[displayplayers[3]].spectator)
return; return;
#ifdef HWRENDER #ifdef HWRENDER
@ -2358,16 +2358,16 @@ void HU_Drawer(void)
// draw the crosshair, not when viewing demos nor with chasecam // draw the crosshair, not when viewing demos nor with chasecam
/*if (!automapactive && !demo.playback) /*if (!automapactive && !demo.playback)
{ {
if (cv_crosshair.value && !camera.chase && !players[displayplayer].spectator) if (cv_crosshair.value && !camera[0].chase && !players[displayplayers[0]].spectator)
HU_DrawCrosshair(); HU_DrawCrosshair();
if (cv_crosshair2.value && !camera2.chase && !players[secondarydisplayplayer].spectator) if (cv_crosshair2.value && !camera[1].chase && !players[displayplayers[1]].spectator)
HU_DrawCrosshair2(); HU_DrawCrosshair2();
if (cv_crosshair3.value && !camera3.chase && !players[thirddisplayplayer].spectator) if (cv_crosshair3.value && !camera[2].chase && !players[displayplayers[2]].spectator)
HU_DrawCrosshair3(); HU_DrawCrosshair3();
if (cv_crosshair4.value && !camera4.chase && !players[fourthdisplayplayer].spectator) if (cv_crosshair4.value && !camera[3].chase && !players[displayplayers[3]].spectator)
HU_DrawCrosshair4(); HU_DrawCrosshair4();
}*/ }*/
@ -3009,7 +3009,7 @@ static void HU_DrawRankings(void)
// When you play, you quickly see your score because your name is displayed in white. // When you play, you quickly see your score because your name is displayed in white.
// When playing back a demo, you quickly see who's the view. // When playing back a demo, you quickly see who's the view.
if (!splitscreen) if (!splitscreen)
whiteplayer = demo.playback ? displayplayer : consoleplayer; whiteplayer = demo.playback ? displayplayers[0] : consoleplayer;
scorelines = 0; scorelines = 0;
memset(completed, 0, sizeof (completed)); memset(completed, 0, sizeof (completed));

View file

@ -1027,34 +1027,14 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
} }
// This makes the roulette produce the random noises. // This makes the roulette produce the random noises.
if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsLocalPlayer(player)) if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player))
{ {
#define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8)); #define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8))
if (splitscreen) for (i = 0; i <= splitscreen; i++)
{ {
if (players[displayplayer].kartstuff[k_itemroulette]) if (player == &players[displayplayers[i]] && players[displayplayers[i]].kartstuff[k_itemroulette])
{
if (player == &players[displayplayer])
PLAYROULETTESND; PLAYROULETTESND;
} }
else if (players[secondarydisplayplayer].kartstuff[k_itemroulette])
{
if (player == &players[secondarydisplayplayer])
PLAYROULETTESND;
}
else if (players[thirddisplayplayer].kartstuff[k_itemroulette] && splitscreen > 1)
{
if (player == &players[thirddisplayplayer])
PLAYROULETTESND;
}
else if (players[fourthdisplayplayer].kartstuff[k_itemroulette] && splitscreen > 2)
{
if (player == &players[fourthdisplayplayer])
PLAYROULETTESND;
}
}
else
PLAYROULETTESND;
#undef PLAYROULETTESND #undef PLAYROULETTESND
} }
@ -1081,7 +1061,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
//player->kartstuff[k_itemblinkmode] = 1; //player->kartstuff[k_itemblinkmode] = 1;
player->kartstuff[k_itemroulette] = 0; player->kartstuff[k_itemroulette] = 0;
player->kartstuff[k_roulettetype] = 0; player->kartstuff[k_roulettetype] = 0;
if (P_IsLocalPlayer(player)) if (P_IsDisplayPlayer(player))
S_StartSound(NULL, sfx_itrole); S_StartSound(NULL, sfx_itrole);
return; return;
} }
@ -1094,7 +1074,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
player->kartstuff[k_itemblinkmode] = 2; player->kartstuff[k_itemblinkmode] = 2;
player->kartstuff[k_itemroulette] = 0; player->kartstuff[k_itemroulette] = 0;
player->kartstuff[k_roulettetype] = 0; player->kartstuff[k_roulettetype] = 0;
if (P_IsLocalPlayer(player)) if (P_IsDisplayPlayer(player))
S_StartSound(NULL, sfx_dbgsal); S_StartSound(NULL, sfx_dbgsal);
return; return;
} }
@ -1126,7 +1106,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
player->kartstuff[k_itemamount] = 1; player->kartstuff[k_itemamount] = 1;
} }
if (P_IsLocalPlayer(player)) if (P_IsDisplayPlayer(player))
S_StartSound(NULL, ((player->kartstuff[k_roulettetype] == 1) ? sfx_itrolk : (mashed ? sfx_itrolm : sfx_itrolf))); S_StartSound(NULL, ((player->kartstuff[k_roulettetype] == 1) ? sfx_itrolk : (mashed ? sfx_itrolm : sfx_itrolf)));
player->kartstuff[k_itemblink] = TICRATE; player->kartstuff[k_itemblink] = TICRATE;
@ -4331,10 +4311,7 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
if (!playeringame[i] || !players[i].mo || players[i].spectator || players[i].exiting) if (!playeringame[i] || !players[i].mo || players[i].spectator || players[i].exiting)
continue; continue;
if ((i == displayplayer) if (P_IsDisplayPlayer(&players[i]))
|| (i == secondarydisplayplayer && splitscreen)
|| (i == thirddisplayplayer && splitscreen > 1)
|| (i == fourthdisplayplayer && splitscreen > 2))
{ {
volumedampen += FRACUNIT; // We already know what this is gonna be, let's not waste our time. volumedampen += FRACUNIT; // We already know what this is gonna be, let's not waste our time.
continue; continue;
@ -5691,13 +5668,13 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
if (player->kartstuff[k_hyudorotimer] >= (1*TICRATE/2) && player->kartstuff[k_hyudorotimer] <= hyudorotime-(1*TICRATE/2)) if (player->kartstuff[k_hyudorotimer] >= (1*TICRATE/2) && player->kartstuff[k_hyudorotimer] <= hyudorotime-(1*TICRATE/2))
{ {
if (player == &players[secondarydisplayplayer]) if (player == &players[displayplayers[1]])
player->mo->eflags |= MFE_DRAWONLYFORP2; player->mo->eflags |= MFE_DRAWONLYFORP2;
else if (player == &players[thirddisplayplayer] && splitscreen > 1) else if (player == &players[displayplayers[2]] && splitscreen > 1)
player->mo->eflags |= MFE_DRAWONLYFORP3; player->mo->eflags |= MFE_DRAWONLYFORP3;
else if (player == &players[fourthdisplayplayer] && splitscreen > 2) else if (player == &players[displayplayers[3]] && splitscreen > 2)
player->mo->eflags |= MFE_DRAWONLYFORP4; player->mo->eflags |= MFE_DRAWONLYFORP4;
else if (player == &players[consoleplayer]) else if (player == &players[displayplayers[0]])
player->mo->eflags |= MFE_DRAWONLYFORP1; player->mo->eflags |= MFE_DRAWONLYFORP1;
else else
player->mo->flags2 |= MF2_DONTDRAW; player->mo->flags2 |= MF2_DONTDRAW;
@ -5707,8 +5684,8 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
} }
else else
{ {
if (player == &players[displayplayer] if (P_IsDisplayPlayer(player)
|| (player != &players[displayplayer] && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)))) || (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2))))
{ {
if (leveltime & 1) if (leveltime & 1)
player->mo->flags2 |= MF2_DONTDRAW; player->mo->flags2 |= MF2_DONTDRAW;
@ -5808,7 +5785,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
} }
// Play the starting countdown sounds // Play the starting countdown sounds
if (player == &players[displayplayer]) // Don't play louder in splitscreen if (player == &players[displayplayers[0]]) // Don't play louder in splitscreen
{ {
if ((leveltime == starttime-(3*TICRATE)) || (leveltime == starttime-(2*TICRATE)) || (leveltime == starttime-TICRATE)) if ((leveltime == starttime-(3*TICRATE)) || (leveltime == starttime-(2*TICRATE)) || (leveltime == starttime-TICRATE))
S_StartSound(NULL, sfx_s3ka7); S_StartSound(NULL, sfx_s3ka7);
@ -6693,17 +6670,17 @@ INT32 K_calcSplitFlags(INT32 snapflags)
if (splitscreen == 0) if (splitscreen == 0)
return snapflags; return snapflags;
if (stplyr != &players[displayplayer]) if (stplyr != &players[displayplayers[0]])
{ {
if (splitscreen == 1 && stplyr == &players[secondarydisplayplayer]) if (splitscreen == 1 && stplyr == &players[displayplayers[1]])
{ {
splitflags |= V_SPLITSCREEN; splitflags |= V_SPLITSCREEN;
} }
else if (splitscreen > 1) else if (splitscreen > 1)
{ {
if (stplyr == &players[thirddisplayplayer] || (splitscreen == 3 && stplyr == &players[fourthdisplayplayer])) if (stplyr == &players[displayplayers[2]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]]))
splitflags |= V_SPLITSCREEN; splitflags |= V_SPLITSCREEN;
if (stplyr == &players[secondarydisplayplayer] || (splitscreen == 3 && stplyr == &players[fourthdisplayplayer])) if (stplyr == &players[displayplayers[1]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]]))
splitflags |= V_HORZSCREEN; splitflags |= V_HORZSCREEN;
} }
} }
@ -6973,17 +6950,17 @@ static void K_drawKartItem(void)
} }
else // now we're having a fun game. else // now we're having a fun game.
{ {
if (stplyr == &players[displayplayer] || stplyr == &players[thirddisplayplayer]) // If we are P1 or P3... if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3...
{ {
fx = ITEM_X; fx = ITEM_X;
fy = ITEM_Y; fy = ITEM_Y;
fflags = V_SNAPTOLEFT|((stplyr == &players[thirddisplayplayer]) ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P3 to the bottom. fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P3 to the bottom.
} }
else // else, that means we're P2 or P4. else // else, that means we're P2 or P4.
{ {
fx = ITEM2_X; fx = ITEM2_X;
fy = ITEM2_Y; fy = ITEM2_Y;
fflags = V_SNAPTORIGHT|((stplyr == &players[fourthdisplayplayer]) ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P4 to the bottom fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN : V_SNAPTOTOP); // flip P4 to the bottom
flipamount = true; flipamount = true;
} }
} }
@ -7226,7 +7203,7 @@ static void K_DrawKartPositionNum(INT32 num)
else if (splitscreen == 1) // for this splitscreen, we'll use case by case because it's a bit different. else if (splitscreen == 1) // for this splitscreen, we'll use case by case because it's a bit different.
{ {
fx = POSI_X; fx = POSI_X;
if (stplyr == &players[displayplayer]) // for player 1: display this at the top right, above the minimap. if (stplyr == &players[displayplayers[0]]) // for player 1: display this at the top right, above the minimap.
{ {
fy = 30; fy = 30;
fflags = V_SNAPTOTOP|V_SNAPTORIGHT; fflags = V_SNAPTOTOP|V_SNAPTORIGHT;
@ -7241,11 +7218,11 @@ static void K_DrawKartPositionNum(INT32 num)
} }
else else
{ {
if (stplyr == &players[displayplayer] || stplyr == &players[thirddisplayplayer]) // If we are P1 or P3... if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3...
{ {
fx = POSI_X; fx = POSI_X;
fy = POSI_Y; fy = POSI_Y;
fflags = V_SNAPTOLEFT|((stplyr == &players[thirddisplayplayer]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom.
flipdraw = true; flipdraw = true;
if (num && num >= 10) if (num && num >= 10)
fx += W; // this seems dumb, but we need to do this in order for positions above 10 going off screen. fx += W; // this seems dumb, but we need to do this in order for positions above 10 going off screen.
@ -7254,7 +7231,7 @@ static void K_DrawKartPositionNum(INT32 num)
{ {
fx = POSI2_X; fx = POSI2_X;
fy = POSI2_Y; fy = POSI2_Y;
fflags = V_SNAPTORIGHT|((stplyr == &players[fourthdisplayplayer]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom
} }
} }
@ -7580,17 +7557,17 @@ static void K_drawKartLaps(void)
} }
else else
{ {
if (stplyr == &players[displayplayer] || stplyr == &players[thirddisplayplayer]) // If we are P1 or P3... if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3...
{ {
fx = LAPS_X; fx = LAPS_X;
fy = LAPS_Y; fy = LAPS_Y;
fflags = V_SNAPTOLEFT|((stplyr == &players[thirddisplayplayer]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom.
} }
else // else, that means we're P2 or P4. else // else, that means we're P2 or P4.
{ {
fx = LAPS2_X; fx = LAPS2_X;
fy = LAPS2_Y; fy = LAPS2_Y;
fflags = V_SNAPTORIGHT|((stplyr == &players[fourthdisplayplayer]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom
flipstring = true; // make the string right aligned and other shit flipstring = true; // make the string right aligned and other shit
} }
} }
@ -7662,17 +7639,17 @@ static void K_drawKartBumpersOrKarma(void)
// we will reuse lap coords here since it's essentially the same shit. // we will reuse lap coords here since it's essentially the same shit.
if (stplyr == &players[displayplayer] || stplyr == &players[thirddisplayplayer]) // If we are P1 or P3... if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3...
{ {
fx = LAPS_X; fx = LAPS_X;
fy = LAPS_Y; fy = LAPS_Y;
fflags = V_SNAPTOLEFT|((stplyr == &players[thirddisplayplayer]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom.
} }
else // else, that means we're P2 or P4. else // else, that means we're P2 or P4.
{ {
fx = LAPS2_X; fx = LAPS2_X;
fy = LAPS2_Y; fy = LAPS2_Y;
fflags = V_SNAPTORIGHT|((stplyr == &players[fourthdisplayplayer]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom
flipstring = true; flipstring = true;
} }
@ -7749,7 +7726,7 @@ static void K_drawKartWanted(void)
UINT8 *colormap = NULL; UINT8 *colormap = NULL;
INT32 basex = 0, basey = 0; INT32 basex = 0, basey = 0;
if (stplyr != &players[displayplayer]) if (stplyr != &players[displayplayers[0]])
return; return;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
@ -7829,7 +7806,7 @@ static void K_drawKartPlayerCheck(void)
if (stplyr->awayviewtics) if (stplyr->awayviewtics)
return; return;
if (camspin) if (camspin[0])
return; return;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
@ -7975,7 +7952,7 @@ static void K_drawKartMinimap(void)
if (gamestate != GS_LEVEL) if (gamestate != GS_LEVEL)
return; return;
if (stplyr != &players[displayplayer]) if (stplyr != &players[displayplayers[0]])
return; return;
lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap))); lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap)));
@ -8049,7 +8026,7 @@ static void K_drawKartMinimap(void)
if (!players[i].mo || players[i].spectator) if (!players[i].mo || players[i].spectator)
continue; continue;
if (i != displayplayer || splitscreen) if (i != displayplayers[0] || splitscreen)
{ {
if (G_BattleGametype() && players[i].kartstuff[k_bumper] <= 0) if (G_BattleGametype() && players[i].kartstuff[k_bumper] <= 0)
continue; continue;
@ -8063,7 +8040,7 @@ static void K_drawKartMinimap(void)
} }
} }
if (i == displayplayer || i == secondarydisplayplayer || i == thirddisplayplayer || i == fourthdisplayplayer) if (P_IsDisplayPlayer(&players[i]))
{ {
// Draw display players on top of everything else // Draw display players on top of everything else
localplayers[numlocalplayers] = i; localplayers[numlocalplayers] = i;
@ -8133,7 +8110,7 @@ static void K_drawKartFinish(void)
xval = (SHORT(kp_racefinish[pnum]->width)<<FRACBITS); xval = (SHORT(kp_racefinish[pnum]->width)<<FRACBITS);
x = ((TICRATE - stplyr->kartstuff[k_cardanimation])*(xval > x ? xval : x))/TICRATE; x = ((TICRATE - stplyr->kartstuff[k_cardanimation])*(xval > x ? xval : x))/TICRATE;
if (splitscreen && stplyr == &players[secondarydisplayplayer]) if (splitscreen && stplyr == &players[displayplayers[1]])
x = -x; x = -x;
V_DrawFixedPatch(x + (STCD_X<<FRACBITS) - (xval>>1), V_DrawFixedPatch(x + (STCD_X<<FRACBITS) - (xval>>1),
@ -8152,9 +8129,9 @@ static void K_drawBattleFullscreen(void)
if (splitscreen) if (splitscreen)
{ {
if ((splitscreen == 1 && stplyr == &players[secondarydisplayplayer]) if ((splitscreen == 1 && stplyr == &players[displayplayers[1]])
|| (splitscreen > 1 && (stplyr == &players[thirddisplayplayer] || (splitscreen > 1 && (stplyr == &players[displayplayers[2]]
|| (stplyr == &players[fourthdisplayplayer] && splitscreen > 2)))) || (stplyr == &players[displayplayers[3]] && splitscreen > 2))))
{ {
y = 232-(stplyr->kartstuff[k_cardanimation]/2); y = 232-(stplyr->kartstuff[k_cardanimation]/2);
splitflags = V_SNAPTOBOTTOM; splitflags = V_SNAPTOBOTTOM;
@ -8166,8 +8143,8 @@ static void K_drawBattleFullscreen(void)
{ {
scale /= 2; scale /= 2;
if (stplyr == &players[secondarydisplayplayer] if (stplyr == &players[displayplayers[1]]
|| (stplyr == &players[fourthdisplayplayer] && splitscreen > 2)) || (stplyr == &players[displayplayers[3]] && splitscreen > 2))
x = 3*BASEVIDWIDTH/4; x = 3*BASEVIDWIDTH/4;
else else
x = BASEVIDWIDTH/4; x = BASEVIDWIDTH/4;
@ -8176,7 +8153,7 @@ static void K_drawBattleFullscreen(void)
{ {
if (stplyr->exiting) if (stplyr->exiting)
{ {
if (stplyr == &players[secondarydisplayplayer]) if (stplyr == &players[displayplayers[1]])
x = BASEVIDWIDTH-96; x = BASEVIDWIDTH-96;
else else
x = 96; x = 96;
@ -8188,7 +8165,7 @@ static void K_drawBattleFullscreen(void)
if (stplyr->exiting) if (stplyr->exiting)
{ {
if (stplyr == &players[displayplayer]) if (stplyr == &players[displayplayers[0]])
V_DrawFadeScreen(0xFF00, 16); V_DrawFadeScreen(0xFF00, 16);
if (stplyr->exiting < 6*TICRATE && !stplyr->spectator) if (stplyr->exiting < 6*TICRATE && !stplyr->spectator)
{ {
@ -8218,9 +8195,9 @@ static void K_drawBattleFullscreen(void)
{ {
if (splitscreen > 1) if (splitscreen > 1)
ty = (BASEVIDHEIGHT/4)+33; ty = (BASEVIDHEIGHT/4)+33;
if ((splitscreen == 1 && stplyr == &players[secondarydisplayplayer]) if ((splitscreen == 1 && stplyr == &players[displayplayers[1]])
|| (stplyr == &players[thirddisplayplayer] && splitscreen > 1) || (stplyr == &players[displayplayers[2]] && splitscreen > 1)
|| (stplyr == &players[fourthdisplayplayer] && splitscreen > 2)) || (stplyr == &players[displayplayers[3]] && splitscreen > 2))
ty += (BASEVIDHEIGHT/2); ty += (BASEVIDHEIGHT/2);
} }
else else
@ -8273,11 +8250,11 @@ static void K_drawKartFirstPerson(void)
if (stplyr->spectator || !stplyr->mo || (stplyr->mo->flags2 & MF2_DONTDRAW)) if (stplyr->spectator || !stplyr->mo || (stplyr->mo->flags2 & MF2_DONTDRAW))
return; return;
if (stplyr == &players[secondarydisplayplayer] && splitscreen) if (stplyr == &players[displayplayers[1]] && splitscreen)
{ pn = pnum[1]; tn = turn[1]; dr = drift[1]; } { pn = pnum[1]; tn = turn[1]; dr = drift[1]; }
else if (stplyr == &players[thirddisplayplayer] && splitscreen > 1) else if (stplyr == &players[displayplayers[2]] && splitscreen > 1)
{ pn = pnum[2]; tn = turn[2]; dr = drift[2]; } { pn = pnum[2]; tn = turn[2]; dr = drift[2]; }
else if (stplyr == &players[fourthdisplayplayer] && splitscreen > 2) else if (stplyr == &players[displayplayers[3]] && splitscreen > 2)
{ pn = pnum[3]; tn = turn[3]; dr = drift[3]; } { pn = pnum[3]; tn = turn[3]; dr = drift[3]; }
else else
{ pn = pnum[0]; tn = turn[0]; dr = drift[0]; } { pn = pnum[0]; tn = turn[0]; dr = drift[0]; }
@ -8402,11 +8379,11 @@ 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[secondarydisplayplayer] && splitscreen) if (stplyr == &players[displayplayers[1]] && splitscreen)
{ pnum[1] = pn; turn[1] = tn; drift[1] = dr; } { pnum[1] = pn; turn[1] = tn; drift[1] = dr; }
else if (stplyr == &players[thirddisplayplayer] && splitscreen > 1) else if (stplyr == &players[displayplayers[2]] && splitscreen > 1)
{ pnum[2] = pn; turn[2] = tn; drift[2] = dr; } { pnum[2] = pn; turn[2] = tn; drift[2] = dr; }
else if (stplyr == &players[fourthdisplayplayer] && splitscreen > 2) else if (stplyr == &players[displayplayers[3]] && splitscreen > 2)
{ pnum[3] = pn; turn[3] = tn; drift[3] = dr; } { pnum[3] = pn; turn[3] = tn; drift[3] = dr; }
else else
{ pnum[0] = pn; turn[0] = tn; drift[0] = dr; } { pnum[0] = pn; turn[0] = tn; drift[0] = dr; }
@ -8627,7 +8604,7 @@ static void K_drawDistributionDebugger(void)
boolean dontforcespb = false; boolean dontforcespb = false;
boolean spbrush = false; boolean spbrush = false;
if (stplyr != &players[displayplayer]) // only for p1 if (stplyr != &players[displayplayers[0]]) // only for p1
return; return;
// The only code duplication from the Kart, just to avoid the actual item function from calculating pingame twice // The only code duplication from the Kart, just to avoid the actual item function from calculating pingame twice
@ -8691,7 +8668,7 @@ static void K_drawDistributionDebugger(void)
static void K_drawCheckpointDebugger(void) static void K_drawCheckpointDebugger(void)
{ {
if (stplyr != &players[displayplayer]) // only for p1 if (stplyr != &players[displayplayers[0]]) // only for p1
return; return;
if (stplyr->starpostnum >= (numstarposts - (numstarposts/2))) if (stplyr->starpostnum >= (numstarposts - (numstarposts/2)))
@ -8705,20 +8682,21 @@ void K_drawKartHUD(void)
{ {
boolean isfreeplay = false; boolean isfreeplay = false;
boolean battlefullscreen = false; boolean battlefullscreen = false;
UINT8 i;
// Define the X and Y for each drawn object // Define the X and Y for each drawn object
// This is handled by console/menu values // This is handled by console/menu values
K_initKartHUD(); K_initKartHUD();
// Draw that fun first person HUD! Drawn ASAP so it looks more "real". // Draw that fun first person HUD! Drawn ASAP so it looks more "real".
if ((stplyr == &players[displayplayer] && !camera.chase) for (i = 0; i <= splitscreen; i++)
|| ((splitscreen && stplyr == &players[secondarydisplayplayer]) && !camera2.chase) {
|| ((splitscreen > 1 && stplyr == &players[thirddisplayplayer]) && !camera3.chase) if (stplyr == &players[displayplayers[i]] && !camera[i].chase)
|| ((splitscreen > 2 && stplyr == &players[fourthdisplayplayer]) && !camera4.chase))
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[displayplayer]) if (mapreset && stplyr == &players[displayplayers[0]])
{ {
K_drawChallengerScreen(); K_drawChallengerScreen();
return; return;
@ -8734,7 +8712,7 @@ void K_drawKartHUD(void)
if (!demo.title && (!battlefullscreen || splitscreen)) if (!demo.title && (!battlefullscreen || splitscreen))
{ {
// Draw the CHECK indicator before the other items, so it's overlapped by everything else // Draw the CHECK indicator before the other items, so it's overlapped by everything else
if (cv_kartcheck.value && !splitscreen && !players[displayplayer].exiting) if (cv_kartcheck.value && !splitscreen && !players[displayplayers[0]].exiting)
K_drawKartPlayerCheck(); K_drawKartPlayerCheck();
// Draw WANTED status // Draw WANTED status

View file

@ -118,14 +118,14 @@ void COM_Lua_f(void)
flags = (UINT8)lua_tointeger(gL, -1); flags = (UINT8)lua_tointeger(gL, -1);
lua_pop(gL, 1); // pop flags lua_pop(gL, 1); // pop flags
if (flags & 2) // flag 2: splitscreen player command. if (flags & 2) // flag 2: splitscreen player command. TODO: support 4P
{ {
if (!splitscreen) if (!splitscreen)
{ {
lua_pop(gL, 1); // pop command info table lua_pop(gL, 1); // pop command info table
return; // can't execute splitscreen command without player 2! return; // can't execute splitscreen command without player 2!
} }
playernum = secondarydisplayplayer; playernum = displayplayers[1];
} }
if (netgame) if (netgame)

View file

@ -797,24 +797,24 @@ void LUAh_GameHUD(player_t *stplayr)
lua_remove(gL, -3); // pop HUD lua_remove(gL, -3); // pop HUD
LUA_PushUserdata(gL, stplayr, META_PLAYER); LUA_PushUserdata(gL, stplayr, META_PLAYER);
if (splitscreen > 2 && stplayr == &players[fourthdisplayplayer]) if (splitscreen > 2 && stplayr == &players[displayplayers[3]])
{ {
LUA_PushUserdata(gL, &camera4, META_CAMERA); LUA_PushUserdata(gL, &camera[3], META_CAMERA);
camnum = 4; camnum = 4;
} }
else if (splitscreen > 1 && stplayr == &players[thirddisplayplayer]) else if (splitscreen > 1 && stplayr == &players[displayplayers[2]])
{ {
LUA_PushUserdata(gL, &camera3, META_CAMERA); LUA_PushUserdata(gL, &camera[2], META_CAMERA);
camnum = 3; camnum = 3;
} }
else if (splitscreen && stplayr == &players[secondarydisplayplayer]) else if (splitscreen && stplayr == &players[displayplayers[1]])
{ {
LUA_PushUserdata(gL, &camera2, META_CAMERA); LUA_PushUserdata(gL, &camera[1], META_CAMERA);
camnum = 2; camnum = 2;
} }
else else
{ {
LUA_PushUserdata(gL, &camera, META_CAMERA); LUA_PushUserdata(gL, &camera[0], META_CAMERA);
camnum = 1; camnum = 1;
} }

View file

@ -421,13 +421,13 @@ static int mobj_set(lua_State *L)
case mobj_angle: case mobj_angle:
mo->angle = luaL_checkangle(L, 3); mo->angle = luaL_checkangle(L, 3);
if (mo->player == &players[consoleplayer]) if (mo->player == &players[consoleplayer])
localangle = mo->angle; localangle[0] = mo->angle;
else if (mo->player == &players[secondarydisplayplayer]) else if (mo->player == &players[displayplayers[1]])
localangle2 = mo->angle; localangle[1] = mo->angle;
else if (mo->player == &players[thirddisplayplayer]) else if (mo->player == &players[displayplayers[2]])
localangle3 = mo->angle; localangle[2] = mo->angle;
else if (mo->player == &players[fourthdisplayplayer]) else if (mo->player == &players[displayplayers[3]])
localangle4 = mo->angle; localangle[3] = mo->angle;
break; break;
case mobj_sprite: case mobj_sprite:
mo->sprite = luaL_checkinteger(L, 3); mo->sprite = luaL_checkinteger(L, 3);

View file

@ -382,13 +382,13 @@ static int player_set(lua_State *L)
else if (fastcmp(field,"aiming")) { else if (fastcmp(field,"aiming")) {
plr->aiming = luaL_checkangle(L, 3); plr->aiming = luaL_checkangle(L, 3);
if (plr == &players[consoleplayer]) if (plr == &players[consoleplayer])
localaiming = plr->aiming; localaiming[0] = plr->aiming;
else if (plr == &players[secondarydisplayplayer]) else if (plr == &players[displayplayers[1]])
localaiming2 = plr->aiming; localaiming[1] = plr->aiming;
else if (plr == &players[thirddisplayplayer]) else if (plr == &players[displayplayers[2]])
localaiming3 = plr->aiming; localaiming[2] = plr->aiming;
else if (plr == &players[fourthdisplayplayer]) else if (plr == &players[displayplayers[3]])
localaiming4 = plr->aiming; localaiming[3] = plr->aiming;
} }
else if (fastcmp(field,"health")) else if (fastcmp(field,"health"))
plr->health = (INT32)luaL_checkinteger(L, 3); plr->health = (INT32)luaL_checkinteger(L, 3);

View file

@ -5787,7 +5787,7 @@ static void M_DrawPlaybackMenu(void)
if (splitscreen >= i - playback_view1) if (splitscreen >= i - playback_view1)
{ {
INT32 ply = *G_GetDisplayplayerPtr(i - playback_view1 + 1); INT32 ply = displayplayers[i - playback_view1 + 1];
icon = facerankprefix[players[ply].skin]; icon = facerankprefix[players[ply].skin];
if (i != itemOn) if (i != itemOn)
@ -5836,19 +5836,10 @@ static void M_DrawPlaybackMenu(void)
break; break;
case playback_view1: case playback_view1:
str = player_names[displayplayer];
break;
case playback_view2: case playback_view2:
str = player_names[secondarydisplayplayer];
break;
case playback_view3: case playback_view3:
str = player_names[thirddisplayplayer];
break;
case playback_view4: case playback_view4:
str = player_names[fourthdisplayplayer]; str = player_names[displayplayers[i - playback_view1]]; // 0 to 3
break; break;
default: // shouldn't ever be reached but whatever default: // shouldn't ever be reached but whatever
@ -9472,7 +9463,7 @@ static void M_SetupMultiPlayer2(INT32 choice)
strcpy (setupm_name, cv_playername2.string); strcpy (setupm_name, cv_playername2.string);
// set for splitscreen secondary player // set for splitscreen secondary player
setupm_player = &players[secondarydisplayplayer]; setupm_player = &players[displayplayers[1]];
setupm_cvskin = &cv_skin2; setupm_cvskin = &cv_skin2;
setupm_cvcolor = &cv_playercolor2; setupm_cvcolor = &cv_playercolor2;
setupm_cvname = &cv_playername2; setupm_cvname = &cv_playername2;
@ -9484,7 +9475,7 @@ static void M_SetupMultiPlayer2(INT32 choice)
setupm_fakecolor = setupm_cvcolor->value; setupm_fakecolor = setupm_cvcolor->value;
// disable skin changes if we can't actually change skins // disable skin changes if we can't actually change skins
if (splitscreen && !CanChangeSkin(secondarydisplayplayer)) if (splitscreen && !CanChangeSkin(displayplayers[1]))
MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT);
else else
MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING); MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING);
@ -9503,7 +9494,7 @@ static void M_SetupMultiPlayer3(INT32 choice)
strcpy(setupm_name, cv_playername3.string); strcpy(setupm_name, cv_playername3.string);
// set for splitscreen third player // set for splitscreen third player
setupm_player = &players[thirddisplayplayer]; setupm_player = &players[displayplayers[2]];
setupm_cvskin = &cv_skin3; setupm_cvskin = &cv_skin3;
setupm_cvcolor = &cv_playercolor3; setupm_cvcolor = &cv_playercolor3;
setupm_cvname = &cv_playername3; setupm_cvname = &cv_playername3;
@ -9515,7 +9506,7 @@ static void M_SetupMultiPlayer3(INT32 choice)
setupm_fakecolor = setupm_cvcolor->value; setupm_fakecolor = setupm_cvcolor->value;
// disable skin changes if we can't actually change skins // disable skin changes if we can't actually change skins
if (splitscreen > 1 && !CanChangeSkin(thirddisplayplayer)) if (splitscreen > 1 && !CanChangeSkin(displayplayers[2]))
MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT);
else else
MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING); MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING);
@ -9534,7 +9525,7 @@ static void M_SetupMultiPlayer4(INT32 choice)
strcpy(setupm_name, cv_playername4.string); strcpy(setupm_name, cv_playername4.string);
// set for splitscreen fourth player // set for splitscreen fourth player
setupm_player = &players[fourthdisplayplayer]; setupm_player = &players[displayplayers[3]];
setupm_cvskin = &cv_skin4; setupm_cvskin = &cv_skin4;
setupm_cvcolor = &cv_playercolor4; setupm_cvcolor = &cv_playercolor4;
setupm_cvname = &cv_playername4; setupm_cvname = &cv_playername4;
@ -9546,7 +9537,7 @@ static void M_SetupMultiPlayer4(INT32 choice)
setupm_fakecolor = setupm_cvcolor->value; setupm_fakecolor = setupm_cvcolor->value;
// disable skin changes if we can't actually change skins // disable skin changes if we can't actually change skins
if (splitscreen > 2 && !CanChangeSkin(fourthdisplayplayer)) if (splitscreen > 2 && !CanChangeSkin(displayplayers[3]))
MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT);
else else
MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING); MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING);

View file

@ -743,12 +743,12 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png
else else
snprintf(lvlttltext, 48, "Unknown"); snprintf(lvlttltext, 48, "Unknown");
if (gamestate == GS_LEVEL && &players[displayplayer] && players[displayplayer].mo) if (gamestate == GS_LEVEL && &players[displayplayers[0]] && players[displayplayers[0]].mo)
snprintf(locationtxt, 40, "X:%d Y:%d Z:%d A:%d", snprintf(locationtxt, 40, "X:%d Y:%d Z:%d A:%d",
players[displayplayer].mo->x>>FRACBITS, players[displayplayers[0]].mo->x>>FRACBITS,
players[displayplayer].mo->y>>FRACBITS, players[displayplayers[0]].mo->y>>FRACBITS,
players[displayplayer].mo->z>>FRACBITS, players[displayplayers[0]].mo->z>>FRACBITS,
FixedInt(AngleFixed(players[displayplayer].mo->angle))); FixedInt(AngleFixed(players[displayplayers[0]].mo->angle)));
else else
snprintf(locationtxt, 40, "Unknown"); snprintf(locationtxt, 40, "Unknown");

View file

@ -4174,12 +4174,12 @@ void A_OverlayThink(mobj_t *actor)
{ {
angle_t viewingangle; angle_t viewingangle;
if (players[displayplayer].awayviewtics) if (players[displayplayers[0]].awayviewtics)
viewingangle = R_PointToAngle2(actor->target->x, actor->target->y, players[displayplayer].awayviewmobj->x, players[displayplayer].awayviewmobj->y); viewingangle = R_PointToAngle2(actor->target->x, actor->target->y, players[displayplayers[0]].awayviewmobj->x, players[displayplayers[0]].awayviewmobj->y);
else if (!camera.chase && players[displayplayer].mo) else if (!camera[0].chase && players[displayplayers[0]].mo)
viewingangle = R_PointToAngle2(actor->target->x, actor->target->y, players[displayplayer].mo->x, players[displayplayer].mo->y); viewingangle = R_PointToAngle2(actor->target->x, actor->target->y, players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y);
else else
viewingangle = R_PointToAngle2(actor->target->x, actor->target->y, camera.x, camera.y); viewingangle = R_PointToAngle2(actor->target->x, actor->target->y, camera[0].x, camera[0].y);
destx = actor->target->x + P_ReturnThrustX(actor->target, viewingangle, FixedMul(FRACUNIT, actor->scale)); destx = actor->target->x + P_ReturnThrustX(actor->target, viewingangle, FixedMul(FRACUNIT, actor->scale));
desty = actor->target->y + P_ReturnThrustY(actor->target, viewingangle, FixedMul(FRACUNIT, actor->scale)); desty = actor->target->y + P_ReturnThrustY(actor->target, viewingangle, FixedMul(FRACUNIT, actor->scale));

View file

@ -2536,9 +2536,9 @@ void T_CameraScanner(elevator_t *elevator)
lastleveltime = leveltime; lastleveltime = leveltime;
} }
if (players[displayplayer].mo) if (players[displayplayers[0]].mo)
{ {
if (players[displayplayer].mo->subsector->sector == elevator->actionsector) if (players[displayplayers[0]].mo->subsector->sector == elevator->actionsector)
{ {
if (t_cam_dist == -42) if (t_cam_dist == -42)
t_cam_dist = cv_cam_dist.value; t_cam_dist = cv_cam_dist.value;
@ -2564,9 +2564,9 @@ void T_CameraScanner(elevator_t *elevator)
} }
} }
if (splitscreen && players[secondarydisplayplayer].mo) if (splitscreen && players[displayplayers[1]].mo)
{ {
if (players[secondarydisplayplayer].mo->subsector->sector == elevator->actionsector) if (players[displayplayers[1]].mo->subsector->sector == elevator->actionsector)
{ {
if (t_cam2_rotate == -42) if (t_cam2_rotate == -42)
t_cam2_dist = cv_cam2_dist.value; t_cam2_dist = cv_cam2_dist.value;
@ -2592,9 +2592,9 @@ void T_CameraScanner(elevator_t *elevator)
} }
} }
if (splitscreen > 1 && players[thirddisplayplayer].mo) if (splitscreen > 1 && players[displayplayers[2]].mo)
{ {
if (players[thirddisplayplayer].mo->subsector->sector == elevator->actionsector) if (players[displayplayers[2]].mo->subsector->sector == elevator->actionsector)
{ {
if (t_cam3_rotate == -42) if (t_cam3_rotate == -42)
t_cam3_dist = cv_cam3_dist.value; t_cam3_dist = cv_cam3_dist.value;
@ -2620,9 +2620,9 @@ void T_CameraScanner(elevator_t *elevator)
} }
} }
if (splitscreen > 2 && players[fourthdisplayplayer].mo) if (splitscreen > 2 && players[displayplayers[3]].mo)
{ {
if (players[fourthdisplayplayer].mo->subsector->sector == elevator->actionsector) if (players[displayplayers[3]].mo->subsector->sector == elevator->actionsector)
{ {
if (t_cam4_rotate == -42) if (t_cam4_rotate == -42)
t_cam4_dist = cv_cam4_dist.value; t_cam4_dist = cv_cam4_dist.value;

View file

@ -62,11 +62,11 @@ void P_ForceConstant(const BasicFF_t *FFInfo)
ConstantQuake.Magnitude = FFInfo->Magnitude; ConstantQuake.Magnitude = FFInfo->Magnitude;
if (FFInfo->player == &players[consoleplayer]) if (FFInfo->player == &players[consoleplayer])
I_Tactile(ConstantForce, &ConstantQuake); I_Tactile(ConstantForce, &ConstantQuake);
else if (splitscreen && FFInfo->player == &players[secondarydisplayplayer]) else if (splitscreen && FFInfo->player == &players[displayplayers[1]])
I_Tactile2(ConstantForce, &ConstantQuake); I_Tactile2(ConstantForce, &ConstantQuake);
else if (splitscreen > 1 && FFInfo->player == &players[thirddisplayplayer]) else if (splitscreen > 1 && FFInfo->player == &players[displayplayers[2]])
I_Tactile3(ConstantForce, &ConstantQuake); I_Tactile3(ConstantForce, &ConstantQuake);
else if (splitscreen > 2 && FFInfo->player == &players[fourthdisplayplayer]) else if (splitscreen > 2 && FFInfo->player == &players[displayplayers[3]])
I_Tactile4(ConstantForce, &ConstantQuake); I_Tactile4(ConstantForce, &ConstantQuake);
} }
void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End) void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End)
@ -83,11 +83,11 @@ void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End)
RampQuake.End = End; RampQuake.End = End;
if (FFInfo->player == &players[consoleplayer]) if (FFInfo->player == &players[consoleplayer])
I_Tactile(ConstantForce, &RampQuake); I_Tactile(ConstantForce, &RampQuake);
else if (splitscreen && FFInfo->player == &players[secondarydisplayplayer]) else if (splitscreen && FFInfo->player == &players[displayplayers[1]])
I_Tactile2(ConstantForce, &RampQuake); I_Tactile2(ConstantForce, &RampQuake);
else if (splitscreen > 1 && FFInfo->player == &players[thirddisplayplayer]) else if (splitscreen > 1 && FFInfo->player == &players[displayplayers[2]])
I_Tactile3(ConstantForce, &RampQuake); I_Tactile3(ConstantForce, &RampQuake);
else if (splitscreen > 2 && FFInfo->player == &players[fourthdisplayplayer]) else if (splitscreen > 2 && FFInfo->player == &players[displayplayers[3]])
I_Tactile4(ConstantForce, &RampQuake); I_Tactile4(ConstantForce, &RampQuake);
} }
@ -218,7 +218,7 @@ void P_DoNightsScore(player_t *player)
dummymo->fuse = 3*TICRATE; dummymo->fuse = 3*TICRATE;
// What?! NO, don't use the camera! Scale up instead! // What?! NO, don't use the camera! Scale up instead!
//P_InstaThrust(dummymo, R_PointToAngle2(dummymo->x, dummymo->y, camera.x, camera.y), 3*FRACUNIT); //P_InstaThrust(dummymo, R_PointToAngle2(dummymo->x, dummymo->y, camera[0].x, camera[0].y), 3*FRACUNIT);
dummymo->scalespeed = FRACUNIT/25; dummymo->scalespeed = FRACUNIT/25;
dummymo->destscale = 2*FRACUNIT; dummymo->destscale = 2*FRACUNIT;
} }
@ -1180,13 +1180,13 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
toucher->angle = special->angle; toucher->angle = special->angle;
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localangle = toucher->angle; localangle[0] = toucher->angle;
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localangle2 = toucher->angle; localangle[1] = toucher->angle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localangle3 = toucher->angle; localangle[2] = toucher->angle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localangle4 = toucher->angle; localangle[3] = toucher->angle;
P_ResetPlayer(player); P_ResetPlayer(player);
@ -1209,7 +1209,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
} }
// CECHO showing you what this item is // CECHO showing you what this item is
if (player == &players[displayplayer] || G_IsSpecialStage(gamemap)) if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap))
{ {
HU_SetCEchoFlags(V_AUTOFADEOUT); HU_SetCEchoFlags(V_AUTOFADEOUT);
HU_SetCEchoDuration(4); HU_SetCEchoDuration(4);
@ -1231,7 +1231,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
} }
// CECHO showing you what this item is // CECHO showing you what this item is
if (player == &players[displayplayer] || G_IsSpecialStage(gamemap)) if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap))
{ {
HU_SetCEchoFlags(V_AUTOFADEOUT); HU_SetCEchoFlags(V_AUTOFADEOUT);
HU_SetCEchoDuration(4); HU_SetCEchoDuration(4);
@ -1263,7 +1263,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
} }
// CECHO showing you what this item is // CECHO showing you what this item is
if (player == &players[displayplayer] || G_IsSpecialStage(gamemap)) if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap))
{ {
HU_SetCEchoFlags(V_AUTOFADEOUT); HU_SetCEchoFlags(V_AUTOFADEOUT);
HU_SetCEchoDuration(4); HU_SetCEchoDuration(4);
@ -1293,7 +1293,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
} }
// CECHO showing you what this item is // CECHO showing you what this item is
if (player == &players[displayplayer] || G_IsSpecialStage(gamemap)) if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap))
{ {
HU_SetCEchoFlags(V_AUTOFADEOUT); HU_SetCEchoFlags(V_AUTOFADEOUT);
HU_SetCEchoDuration(4); HU_SetCEchoDuration(4);
@ -1321,7 +1321,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
} }
// CECHO showing you what this item is // CECHO showing you what this item is
if (player == &players[displayplayer] || G_IsSpecialStage(gamemap)) if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap))
{ {
HU_SetCEchoFlags(V_AUTOFADEOUT); HU_SetCEchoFlags(V_AUTOFADEOUT);
HU_SetCEchoDuration(4); HU_SetCEchoDuration(4);
@ -2324,17 +2324,17 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
AM_Stop(); AM_Stop();
//added : 22-02-98: recenter view for next life... //added : 22-02-98: recenter view for next life...
localaiming = 0; localaiming[0] = 0;
} }
if (target->player == &players[secondarydisplayplayer]) if (target->player == &players[displayplayers[1]])
{ {
// added : 22-02-98: recenter view for next life... // added : 22-02-98: recenter view for next life...
localaiming2 = 0; localaiming[1] = 0;
} }
if (target->player == &players[thirddisplayplayer]) if (target->player == &players[displayplayers[2]])
localaiming3 = 0; localaiming[2] = 0;
if (target->player == &players[fourthdisplayplayer]) if (target->player == &players[displayplayers[3]])
localaiming4 = 0; localaiming[3] = 0;
//tag deaths handled differently in suicide cases. Don't count spectators! //tag deaths handled differently in suicide cases. Don't count spectators!
/*if (G_TagGametype() /*if (G_TagGametype()

View file

@ -108,7 +108,7 @@ typedef struct camera_s
fixed_t pan; fixed_t pan;
} camera_t; } camera_t;
extern camera_t camera, camera2, camera3, camera4; extern camera_t camera[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_cam_dist, cv_cam_still, cv_cam_height; extern consvar_t cv_cam_dist, cv_cam_still, cv_cam_height;
extern consvar_t cv_cam_speed, cv_cam_rotate, cv_cam_rotspeed; extern consvar_t cv_cam_speed, cv_cam_rotate, cv_cam_rotspeed;
@ -126,8 +126,6 @@ extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate;
extern fixed_t t_cam3_dist, t_cam3_height, t_cam3_rotate; extern fixed_t t_cam3_dist, t_cam3_height, t_cam3_rotate;
extern fixed_t t_cam4_dist, t_cam4_height, t_cam4_rotate; extern fixed_t t_cam4_dist, t_cam4_height, t_cam4_rotate;
camera_t *P_GetCameraPtr(UINT8 viewnum);
fixed_t P_GetPlayerHeight(player_t *player); fixed_t P_GetPlayerHeight(player_t *player);
fixed_t P_GetPlayerSpinHeight(player_t *player); fixed_t P_GetPlayerSpinHeight(player_t *player);
void P_AddPlayerScore(player_t *player, UINT32 amount); void P_AddPlayerScore(player_t *player, UINT32 amount);

View file

@ -215,13 +215,13 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object)
if (!demo.playback || P_AnalogMove(object->player)) if (!demo.playback || P_AnalogMove(object->player))
{ {
if (object->player == &players[consoleplayer]) if (object->player == &players[consoleplayer])
localangle = spring->angle; localangle[0] = spring->angle;
else if (object->player == &players[secondarydisplayplayer]) else if (object->player == &players[displayplayers[1]])
localangle2 = spring->angle; localangle[1] = spring->angle;
else if (object->player == &players[thirddisplayplayer]) else if (object->player == &players[displayplayers[2]])
localangle3 = spring->angle; localangle[2] = spring->angle;
else if (object->player == &players[fourthdisplayplayer]) else if (object->player == &players[displayplayers[3]])
localangle4 = spring->angle; localangle[3] = spring->angle;
} }
} }
@ -1267,13 +1267,13 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (!demo.playback || P_AnalogMove(thing->player)) if (!demo.playback || P_AnalogMove(thing->player))
{ {
if (thing->player == &players[consoleplayer]) if (thing->player == &players[consoleplayer])
localangle = thing->angle; localangle[0] = thing->angle;
else if (thing->player == &players[secondarydisplayplayer]) else if (thing->player == &players[displayplayers[1]])
localangle2 = thing->angle; localangle[1] = thing->angle;
else if (thing->player == &players[thirddisplayplayer]) else if (thing->player == &players[displayplayers[2]])
localangle3 = thing->angle; localangle[2] = thing->angle;
else if (thing->player == &players[fourthdisplayplayer]) else if (thing->player == &players[displayplayers[3]])
localangle4 = thing->angle; localangle[3] = thing->angle;
} }
return true; return true;
@ -2504,34 +2504,38 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
subsector_t *s = R_PointInSubsector(x, y); subsector_t *s = R_PointInSubsector(x, y);
boolean retval = true; boolean retval = true;
boolean itsatwodlevel = false; boolean itsatwodlevel = false;
UINT8 i;
floatok = false; floatok = false;
if (twodlevel if (twodlevel)
|| (thiscam == &camera && players[displayplayer].mo && (players[displayplayer].mo->flags2 & MF2_TWOD))
|| (thiscam == &camera2 && players[secondarydisplayplayer].mo && (players[secondarydisplayplayer].mo->flags2 & MF2_TWOD))
|| (thiscam == &camera3 && players[thirddisplayplayer].mo && (players[thirddisplayplayer].mo->flags2 & MF2_TWOD))
|| (thiscam == &camera4 && players[fourthdisplayplayer].mo && (players[fourthdisplayplayer].mo->flags2 & MF2_TWOD)))
itsatwodlevel = true; itsatwodlevel = true;
else
{
for (i = 0; i <= splitscreen; i++)
{
if (thiscam == &camera[i] && players[displayplayers[i]].mo
&& (players[displayplayers[i]].mo->flags2 & MF2_TWOD))
{
itsatwodlevel = true;
break;
}
}
}
if (!itsatwodlevel && players[displayplayer].mo) if (!itsatwodlevel && players[displayplayers[0]].mo)
{ {
fixed_t tryx = thiscam->x; fixed_t tryx = thiscam->x;
fixed_t tryy = thiscam->y; fixed_t tryy = thiscam->y;
for (i = 0; i <= splitscreen; i++)
{
#ifndef NOCLIPCAM #ifndef NOCLIPCAM
if ((thiscam == &camera && (players[displayplayer].pflags & PF_NOCLIP)) if ((thiscam == &camera[i] && (players[displayplayers[i]].pflags & PF_NOCLIP)) || (leveltime < introtime)) // Noclipping player camera noclips too!!
|| (thiscam == &camera2 && (players[secondarydisplayplayer].pflags & PF_NOCLIP))
|| (thiscam == &camera3 && (players[thirddisplayplayer].pflags & PF_NOCLIP))
|| (thiscam == &camera4 && (players[fourthdisplayplayer].pflags & PF_NOCLIP))
|| (leveltime < introtime))
#else #else
if ((thiscam == &camera && !(players[displayplayer].pflags & PF_TIMEOVER)) if (thiscam == &camera[i] && !(players[displayplayers[i]].pflags & PF_TIMEOVER)) // Time Over should not clip through walls
|| (thiscam == &camera2 && !(players[secondarydisplayplayer].pflags & PF_TIMEOVER))
|| (thiscam == &camera3 && !(players[thirddisplayplayer].pflags & PF_TIMEOVER))
|| (thiscam == &camera4 && !(players[fourthdisplayplayer].pflags & PF_TIMEOVER)))
#endif #endif
{ // Noclipping player camera noclips too!! {
floatok = true; floatok = true;
thiscam->floorz = thiscam->z; thiscam->floorz = thiscam->z;
thiscam->ceilingz = thiscam->z + thiscam->height; thiscam->ceilingz = thiscam->z + thiscam->height;
@ -2540,6 +2544,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
thiscam->subsector = s; thiscam->subsector = s;
return true; return true;
} }
}
do { do {
if (x-tryx > MAXRADIUS) if (x-tryx > MAXRADIUS)

View file

@ -339,9 +339,9 @@ void P_CameraLineOpening(line_t *linedef)
frontceiling = sectors[front->camsec].ceilingheight; frontceiling = sectors[front->camsec].ceilingheight;
#ifdef ESLOPE #ifdef ESLOPE
if (sectors[front->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) if (sectors[front->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[front->camsec].f_slope, camera.x, camera.y); frontfloor = P_GetZAt(sectors[front->camsec].f_slope, camera[0].x, camera[0].y);
if (sectors[front->camsec].c_slope) if (sectors[front->camsec].c_slope)
frontceiling = P_GetZAt(sectors[front->camsec].c_slope, camera.x, camera.y); frontceiling = P_GetZAt(sectors[front->camsec].c_slope, camera[0].x, camera[0].y);
#endif #endif
} }
@ -351,9 +351,9 @@ void P_CameraLineOpening(line_t *linedef)
frontceiling = sectors[front->heightsec].ceilingheight; frontceiling = sectors[front->heightsec].ceilingheight;
#ifdef ESLOPE #ifdef ESLOPE
if (sectors[front->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) if (sectors[front->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[front->heightsec].f_slope, camera.x, camera.y); frontfloor = P_GetZAt(sectors[front->heightsec].f_slope, camera[0].x, camera[0].y);
if (sectors[front->heightsec].c_slope) if (sectors[front->heightsec].c_slope)
frontceiling = P_GetZAt(sectors[front->heightsec].c_slope, camera.x, camera.y); frontceiling = P_GetZAt(sectors[front->heightsec].c_slope, camera[0].x, camera[0].y);
#endif #endif
} }
else else
@ -367,9 +367,9 @@ void P_CameraLineOpening(line_t *linedef)
backceiling = sectors[back->camsec].ceilingheight; backceiling = sectors[back->camsec].ceilingheight;
#ifdef ESLOPE #ifdef ESLOPE
if (sectors[back->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) if (sectors[back->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[back->camsec].f_slope, camera.x, camera.y); frontfloor = P_GetZAt(sectors[back->camsec].f_slope, camera[0].x, camera[0].y);
if (sectors[back->camsec].c_slope) if (sectors[back->camsec].c_slope)
frontceiling = P_GetZAt(sectors[back->camsec].c_slope, camera.x, camera.y); frontceiling = P_GetZAt(sectors[back->camsec].c_slope, camera[0].x, camera[0].y);
#endif #endif
} }
else if (back->heightsec >= 0) else if (back->heightsec >= 0)
@ -378,9 +378,9 @@ void P_CameraLineOpening(line_t *linedef)
backceiling = sectors[back->heightsec].ceilingheight; backceiling = sectors[back->heightsec].ceilingheight;
#ifdef ESLOPE #ifdef ESLOPE
if (sectors[back->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) if (sectors[back->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope)
frontfloor = P_GetZAt(sectors[back->heightsec].f_slope, camera.x, camera.y); frontfloor = P_GetZAt(sectors[back->heightsec].f_slope, camera[0].x, camera[0].y);
if (sectors[back->heightsec].c_slope) if (sectors[back->heightsec].c_slope)
frontceiling = P_GetZAt(sectors[back->heightsec].c_slope, camera.x, camera.y); frontceiling = P_GetZAt(sectors[back->heightsec].c_slope, camera[0].x, camera[0].y);
#endif #endif
} }
else else

View file

@ -1136,45 +1136,19 @@ static void P_PlayerFlip(mobj_t *mo)
else if (mo->player->pflags & PF_FLIPCAM) else if (mo->player->pflags & PF_FLIPCAM)
{ {
mo->player->aiming = InvAngle(mo->player->aiming); mo->player->aiming = InvAngle(mo->player->aiming);
if (mo->player-players == displayplayer)
for (i = 0; i <= splitscreen; i++)
{ {
localaiming = mo->player->aiming; if (mo->player-players == displayplayers[i])
if (camera.chase) {
camera.aiming = InvAngle(camera.aiming);
camera.z = mo->z - camera.z + mo->z;
if (mo->eflags & MFE_VERTICALFLIP)
camera.z += FixedMul(20*FRACUNIT, mo->scale);
}
}
else if (mo->player-players == secondarydisplayplayer)
{ {
localaiming2 = mo->player->aiming; localaiming[i] = mo->player->aiming;
if (camera2.chase) { if (camera[i].chase) {
camera2.aiming = InvAngle(camera2.aiming); camera[i].aiming = InvAngle(camera[i].aiming);
camera2.z = mo->z - camera2.z + mo->z; camera[i].z = mo->z - camera[i].z + mo->z;
if (mo->eflags & MFE_VERTICALFLIP) if (mo->eflags & MFE_VERTICALFLIP)
camera2.z += FixedMul(20*FRACUNIT, mo->scale); camera[i].z += FixedMul(20*FRACUNIT, mo->scale);
} }
} }
else if (mo->player-players == thirddisplayplayer)
{
localaiming3 = mo->player->aiming;
if (camera3.chase) {
camera3.aiming = InvAngle(camera3.aiming);
camera3.z = mo->z - camera3.z + mo->z;
if (mo->eflags & MFE_VERTICALFLIP)
camera3.z += FixedMul(20*FRACUNIT, mo->scale);
}
}
else if (mo->player-players == fourthdisplayplayer)
{
localaiming4 = mo->player->aiming;
if (camera4.chase) {
camera4.aiming = InvAngle(camera4.aiming);
camera4.z = mo->z - camera4.z + mo->z;
if (mo->eflags & MFE_VERTICALFLIP)
camera4.z += FixedMul(20*FRACUNIT, mo->scale);
}
} }
} }
} }
@ -3546,17 +3520,26 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
{ {
boolean itsatwodlevel = false; boolean itsatwodlevel = false;
postimg_t postimg = postimg_none; postimg_t postimg = postimg_none;
UINT8 i;
// This can happen when joining // This can happen when joining
if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL)
return true; return true;
if (twodlevel if (twodlevel)
|| (thiscam == &camera && players[displayplayer].mo && (players[displayplayer].mo->flags2 & MF2_TWOD))
|| (thiscam == &camera2 && players[secondarydisplayplayer].mo && (players[secondarydisplayplayer].mo->flags2 & MF2_TWOD))
|| (thiscam == &camera3 && players[thirddisplayplayer].mo && (players[thirddisplayplayer].mo->flags2 & MF2_TWOD))
|| (thiscam == &camera4 && players[fourthdisplayplayer].mo && (players[fourthdisplayplayer].mo->flags2 & MF2_TWOD)))
itsatwodlevel = true; itsatwodlevel = true;
else
{
for (i = 0; i <= splitscreen; i++)
{
if (thiscam == &camera[i] && players[displayplayers[i]].mo
&& (players[displayplayers[i]].mo->flags2 & MF2_TWOD))
{
itsatwodlevel = true;
break;
}
}
}
if (encoremode) if (encoremode)
postimg = postimg_mirror; postimg = postimg_mirror;
@ -3588,14 +3571,11 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
if (postimg != postimg_none) if (postimg != postimg_none)
{ {
if (splitscreen && player == &players[secondarydisplayplayer]) for (i = 0; i <= splitscreen; i++)
postimgtype2 = postimg; {
else if (splitscreen > 1 && player == &players[thirddisplayplayer]) if (player == &players[displayplayers[i]])
postimgtype3 = postimg; postimgtype[i] = postimg;
else if (splitscreen > 2 && player == &players[fourthdisplayplayer]) }
postimgtype4 = postimg;
else
postimgtype = postimg;
} }
if (thiscam->momx || thiscam->momy) if (thiscam->momx || thiscam->momy)
@ -3641,11 +3621,11 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
fixed_t cam_height = cv_cam_height.value; fixed_t cam_height = cv_cam_height.value;
thiscam->z = thiscam->floorz; thiscam->z = thiscam->floorz;
if (player == &players[secondarydisplayplayer]) if (player == &players[displayplayers[1]])
cam_height = cv_cam2_height.value; cam_height = cv_cam2_height.value;
if (player == &players[thirddisplayplayer]) if (player == &players[displayplayers[2]])
cam_height = cv_cam3_height.value; cam_height = cv_cam3_height.value;
if (player == &players[fourthdisplayplayer]) if (player == &players[displayplayers[3]])
cam_height = cv_cam4_height.value; cam_height = cv_cam4_height.value;
if (thiscam->z > player->mo->z + player->mo->height + FixedMul(cam_height*FRACUNIT + 16*FRACUNIT, player->mo->scale)) if (thiscam->z > player->mo->z + player->mo->height + FixedMul(cam_height*FRACUNIT + 16*FRACUNIT, player->mo->scale))
{ {
@ -6101,12 +6081,12 @@ void P_RunOverlays(void)
{ {
angle_t viewingangle; angle_t viewingangle;
if (players[displayplayer].awayviewtics) if (players[displayplayers[0]].awayviewtics)
viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, players[displayplayer].awayviewmobj->x, players[displayplayer].awayviewmobj->y); viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, players[displayplayers[0]].awayviewmobj->x, players[displayplayers[0]].awayviewmobj->y);
else if (!camera.chase && players[displayplayer].mo) else if (!camera[0].chase && players[displayplayers[0]].mo)
viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, players[displayplayer].mo->x, players[displayplayer].mo->y); viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y);
else else
viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, camera.x, camera.y); viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, camera[0].x, camera[0].y);
if (!(mo->state->frame & FF_ANIMATE) && mo->state->var1) if (!(mo->state->frame & FF_ANIMATE) && mo->state->var1)
viewingangle += ANGLE_180; viewingangle += ANGLE_180;
@ -6680,7 +6660,7 @@ void P_MobjThinker(mobj_t *mobj)
if (mobj->target && mobj->target->health if (mobj->target && mobj->target->health
&& mobj->target->player && !mobj->target->player->spectator && mobj->target->player && !mobj->target->player->spectator
&& mobj->target->player->health && mobj->target->player->playerstate != PST_DEAD && mobj->target->player->health && mobj->target->player->playerstate != PST_DEAD
/*&& players[displayplayer].mo && !players[displayplayer].spectator*/) /*&& players[displayplayers[0]].mo && !players[displayplayers[0]].spectator*/)
{ {
fixed_t scale = 3*mobj->target->scale; fixed_t scale = 3*mobj->target->scale;
mobj->color = mobj->target->color; mobj->color = mobj->target->color;
@ -6688,7 +6668,7 @@ void P_MobjThinker(mobj_t *mobj)
if ((G_RaceGametype() || mobj->target->player->kartstuff[k_bumper] <= 0) if ((G_RaceGametype() || mobj->target->player->kartstuff[k_bumper] <= 0)
#if 1 // Set to 0 to test without needing to host #if 1 // Set to 0 to test without needing to host
|| ((mobj->target->player == &players[displayplayer]) || P_IsLocalPlayer(mobj->target->player)) || ((mobj->target->player == &players[displayplayers[0]]) || P_IsLocalPlayer(mobj->target->player))
#endif #endif
) )
mobj->flags2 |= MF2_DONTDRAW; mobj->flags2 |= MF2_DONTDRAW;
@ -6699,10 +6679,10 @@ void P_MobjThinker(mobj_t *mobj)
mobj->angle = R_PointToAngle(mobj->x, mobj->y) + ANGLE_90; // literally only happened because i wanted to ^L^R the SPR_ITEM's mobj->angle = R_PointToAngle(mobj->x, mobj->y) + ANGLE_90; // literally only happened because i wanted to ^L^R the SPR_ITEM's
if (!splitscreen && players[displayplayer].mo) if (!splitscreen && players[displayplayers[0]].mo)
{ {
scale = mobj->target->scale + FixedMul(FixedDiv(abs(P_AproxDistance(players[displayplayer].mo->x-mobj->target->x, scale = mobj->target->scale + FixedMul(FixedDiv(abs(P_AproxDistance(players[displayplayers[0]].mo->x-mobj->target->x,
players[displayplayer].mo->y-mobj->target->y)), RING_DIST), mobj->target->scale); players[displayplayers[0]].mo->y-mobj->target->y)), RING_DIST), mobj->target->scale);
if (scale > 16*mobj->target->scale) if (scale > 16*mobj->target->scale)
scale = 16*mobj->target->scale; scale = 16*mobj->target->scale;
} }
@ -6887,7 +6867,7 @@ void P_MobjThinker(mobj_t *mobj)
if (mobj->target && mobj->target->health && mobj->tracer if (mobj->target && mobj->target->health && mobj->tracer
&& mobj->target->player && !mobj->target->player->spectator && mobj->target->player && !mobj->target->player->spectator
&& mobj->target->player->health && mobj->target->player->playerstate != PST_DEAD && mobj->target->player->health && mobj->target->player->playerstate != PST_DEAD
&& players[displayplayer].mo && !players[displayplayer].spectator) && players[displayplayers[0]].mo && !players[displayplayers[0]].spectator)
{ {
fixed_t scale = 3*mobj->target->scale; fixed_t scale = 3*mobj->target->scale;
@ -6909,8 +6889,8 @@ void P_MobjThinker(mobj_t *mobj)
if (!splitscreen) if (!splitscreen)
{ {
scale = mobj->target->scale + FixedMul(FixedDiv(abs(P_AproxDistance(players[displayplayer].mo->x-mobj->target->x, scale = mobj->target->scale + FixedMul(FixedDiv(abs(P_AproxDistance(players[displayplayers[0]].mo->x-mobj->target->x,
players[displayplayer].mo->y-mobj->target->y)), RING_DIST), mobj->target->scale); players[displayplayers[0]].mo->y-mobj->target->y)), RING_DIST), mobj->target->scale);
if (scale > 16*mobj->target->scale) if (scale > 16*mobj->target->scale)
scale = 16*mobj->target->scale; scale = 16*mobj->target->scale;
} }
@ -8296,12 +8276,12 @@ void P_MobjThinker(mobj_t *mobj)
angle_t viewingangle; angle_t viewingangle;
statenum_t curstate = ((mobj->tics == 1) ? (mobj->state->nextstate) : ((statenum_t)(mobj->state-states))); statenum_t curstate = ((mobj->tics == 1) ? (mobj->state->nextstate) : ((statenum_t)(mobj->state-states)));
if (players[displayplayer].awayviewtics) if (players[displayplayers[0]].awayviewtics)
viewingangle = R_PointToAngle2(mobj->target->x, mobj->target->y, players[displayplayer].awayviewmobj->x, players[displayplayer].awayviewmobj->y); viewingangle = R_PointToAngle2(mobj->target->x, mobj->target->y, players[displayplayers[0]].awayviewmobj->x, players[displayplayers[0]].awayviewmobj->y);
else if (!camera.chase && players[displayplayer].mo) else if (!camera[0].chase && players[displayplayers[0]].mo)
viewingangle = R_PointToAngle2(mobj->target->x, mobj->target->y, players[displayplayer].mo->x, players[displayplayer].mo->y); viewingangle = R_PointToAngle2(mobj->target->x, mobj->target->y, players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y);
else else
viewingangle = R_PointToAngle2(mobj->target->x, mobj->target->y, camera.x, camera.y); viewingangle = R_PointToAngle2(mobj->target->x, mobj->target->y, camera[0].x, camera[0].y);
if (curstate > S_THUNDERSHIELD15) if (curstate > S_THUNDERSHIELD15)
viewingangle += ANGLE_180; viewingangle += ANGLE_180;
@ -10562,13 +10542,13 @@ void P_PrecipitationEffects(void)
// Local effects from here on out! // Local effects from here on out!
// If we're not in game fully yet, we don't worry about them. // If we're not in game fully yet, we don't worry about them.
if (!playeringame[displayplayer] || !players[displayplayer].mo) if (!playeringame[displayplayers[0]] || !players[displayplayers[0]].mo)
return; return;
if (sound_disabled) if (sound_disabled)
return; // Sound off? D'aw, no fun. return; // Sound off? D'aw, no fun.
if (players[displayplayer].mo->subsector->sector->ceilingpic == skyflatnum) if (players[displayplayers[0]].mo->subsector->sector->ceilingpic == skyflatnum)
volume = 255; // Sky above? We get it full blast. volume = 255; // Sky above? We get it full blast.
else else
{ {
@ -10576,17 +10556,17 @@ void P_PrecipitationEffects(void)
fixed_t closedist, newdist; fixed_t closedist, newdist;
// Essentially check in a 1024 unit radius of the player for an outdoor area. // Essentially check in a 1024 unit radius of the player for an outdoor area.
yl = players[displayplayer].mo->y - 1024*FRACUNIT; yl = players[displayplayers[0]].mo->y - 1024*FRACUNIT;
yh = players[displayplayer].mo->y + 1024*FRACUNIT; yh = players[displayplayers[0]].mo->y + 1024*FRACUNIT;
xl = players[displayplayer].mo->x - 1024*FRACUNIT; xl = players[displayplayers[0]].mo->x - 1024*FRACUNIT;
xh = players[displayplayer].mo->x + 1024*FRACUNIT; xh = players[displayplayers[0]].mo->x + 1024*FRACUNIT;
closedist = 2048*FRACUNIT; closedist = 2048*FRACUNIT;
for (y = yl; y <= yh; y += FRACUNIT*64) for (y = yl; y <= yh; y += FRACUNIT*64)
for (x = xl; x <= xh; x += FRACUNIT*64) for (x = xl; x <= xh; x += FRACUNIT*64)
{ {
if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) // Found the outdoors! if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) // Found the outdoors!
{ {
newdist = S_CalculateSoundDistance(players[displayplayer].mo->x, players[displayplayer].mo->y, 0, x, y, 0); newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, x, y, 0);
if (newdist < closedist) if (newdist < closedist)
closedist = newdist; closedist = newdist;
} }
@ -10601,7 +10581,7 @@ void P_PrecipitationEffects(void)
volume = 255; volume = 255;
if (sounds_rain && (!leveltime || leveltime % 80 == 1)) if (sounds_rain && (!leveltime || leveltime % 80 == 1))
S_StartSoundAtVolume(players[displayplayer].mo, sfx_rainin, volume); S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_rainin, volume);
if (!sounds_thunder) if (!sounds_thunder)
return; return;
@ -10609,7 +10589,7 @@ void P_PrecipitationEffects(void)
if (effects_lightning && lightningStrike && volume) if (effects_lightning && lightningStrike && volume)
{ {
// Large, close thunder sounds to go with our lightning. // Large, close thunder sounds to go with our lightning.
S_StartSoundAtVolume(players[displayplayer].mo, sfx_litng1 + M_RandomKey(4), volume); S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_litng1 + M_RandomKey(4), volume);
} }
else if (thunderchance < 20) else if (thunderchance < 20)
{ {
@ -10617,7 +10597,7 @@ void P_PrecipitationEffects(void)
if (volume < 80) if (volume < 80)
volume = 80; volume = 80;
S_StartSoundAtVolume(players[displayplayer].mo, sfx_athun1 + M_RandomKey(2), volume); S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_athun1 + M_RandomKey(2), volume);
} }
} }
@ -10924,15 +10904,21 @@ void P_AfterPlayerSpawn(INT32 playernum)
{ {
player_t *p = &players[playernum]; player_t *p = &players[playernum];
mobj_t *mobj = p->mo; mobj_t *mobj = p->mo;
UINT8 i;
if (playernum == consoleplayer) if (playernum == consoleplayer)
localangle = mobj->angle; localangle[0] = mobj->angle;
else if (playernum == secondarydisplayplayer) else if (splitscreen)
localangle2 = mobj->angle; {
else if (playernum == thirddisplayplayer) for (i = 1; i <= splitscreen; i++)
localangle3 = mobj->angle; {
else if (playernum == fourthdisplayplayer) if (playernum == displayplayers[i])
localangle4 = mobj->angle; {
localangle[i] = mobj->angle;
break;
}
}
}
p->viewheight = 32<<FRACBITS; p->viewheight = 32<<FRACBITS;
@ -10954,25 +10940,13 @@ void P_AfterPlayerSpawn(INT32 playernum)
SV_SpawnPlayer(playernum, mobj->x, mobj->y, mobj->angle); SV_SpawnPlayer(playernum, mobj->x, mobj->y, mobj->angle);
if (camera.chase) for (i = 0; i <= splitscreen; i++)
{ {
if (displayplayer == playernum) if (camera[i].chase)
P_ResetCamera(p, &camera); {
if (displayplayers[i] == playernum)
P_ResetCamera(p, &camera[i]);
} }
if (camera2.chase && splitscreen)
{
if (secondarydisplayplayer == playernum)
P_ResetCamera(p, &camera2);
}
if (camera3.chase && splitscreen > 1)
{
if (thirddisplayplayer == playernum)
P_ResetCamera(p, &camera3);
}
if (camera4.chase && splitscreen > 2)
{
if (fourthdisplayplayer == playernum)
P_ResetCamera(p, &camera4);
} }
if (CheckForReverseGravity) if (CheckForReverseGravity)

View file

@ -1336,13 +1336,13 @@ static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta,
if (turnthings == 2 || (turnthings == 1 && !mo->player)) { if (turnthings == 2 || (turnthings == 1 && !mo->player)) {
mo->angle += delta; mo->angle += delta;
if (mo->player == &players[consoleplayer]) if (mo->player == &players[consoleplayer])
localangle = mo->angle; localangle[0] = mo->angle;
else if (mo->player == &players[secondarydisplayplayer]) else if (mo->player == &players[displayplayers[1]])
localangle2 = mo->angle; localangle[1] = mo->angle;
else if (mo->player == &players[thirddisplayplayer]) else if (mo->player == &players[displayplayers[2]])
localangle3 = mo->angle; localangle[2] = mo->angle;
else if (mo->player == &players[fourthdisplayplayer]) else if (mo->player == &players[displayplayers[3]])
localangle4 = mo->angle; localangle[3] = mo->angle;
} }
} }
} }

View file

@ -2106,13 +2106,13 @@ static void LoadMobjThinker(actionf_p1 thinker)
mobj->player->mo = mobj; mobj->player->mo = mobj;
// added for angle prediction // added for angle prediction
if (consoleplayer == i) if (consoleplayer == i)
localangle = mobj->angle; localangle[0] = mobj->angle;
if (secondarydisplayplayer == i) if (displayplayers[1] == i)
localangle2 = mobj->angle; localangle[1] = mobj->angle;
if (thirddisplayplayer == i) if (displayplayers[2] == i)
localangle3 = mobj->angle; localangle[2] = mobj->angle;
if (fourthdisplayplayer == i) if (displayplayers[3] == i)
localangle4 = mobj->angle; localangle[3] = mobj->angle;
} }
if (diff & MD_MOVEDIR) if (diff & MD_MOVEDIR)
mobj->movedir = READANGLE(save_p); mobj->movedir = READANGLE(save_p);

View file

@ -2269,7 +2269,7 @@ static void P_LevelInitStuff(void)
leveltime = 0; leveltime = 0;
localaiming = localaiming2 = localaiming3 = localaiming4 = 0; memset(localaiming, 0, sizeof(localaiming));
// map object scale // map object scale
mapobjectscale = mapheaderinfo[gamemap-1]->mobj_scale; mapobjectscale = mapheaderinfo[gamemap-1]->mobj_scale;
@ -2536,29 +2536,29 @@ static void P_ForceCharacter(const char *forcecharskin)
{ {
if (splitscreen) if (splitscreen)
{ {
SetPlayerSkin(secondarydisplayplayer, forcecharskin); SetPlayerSkin(displayplayers[1], forcecharskin);
if ((unsigned)cv_playercolor2.value != skins[players[secondarydisplayplayer].skin].prefcolor && !modeattacking) if ((unsigned)cv_playercolor2.value != skins[players[displayplayers[1]].skin].prefcolor && !modeattacking)
{ {
CV_StealthSetValue(&cv_playercolor2, skins[players[secondarydisplayplayer].skin].prefcolor); CV_StealthSetValue(&cv_playercolor2, skins[players[displayplayers[1]].skin].prefcolor);
players[secondarydisplayplayer].skincolor = skins[players[secondarydisplayplayer].skin].prefcolor; players[displayplayers[1]].skincolor = skins[players[displayplayers[1]].skin].prefcolor;
} }
if (splitscreen > 1) if (splitscreen > 1)
{ {
SetPlayerSkin(thirddisplayplayer, forcecharskin); SetPlayerSkin(displayplayers[2], forcecharskin);
if ((unsigned)cv_playercolor3.value != skins[players[thirddisplayplayer].skin].prefcolor && !modeattacking) if ((unsigned)cv_playercolor3.value != skins[players[displayplayers[2]].skin].prefcolor && !modeattacking)
{ {
CV_StealthSetValue(&cv_playercolor3, skins[players[thirddisplayplayer].skin].prefcolor); CV_StealthSetValue(&cv_playercolor3, skins[players[displayplayers[2]].skin].prefcolor);
players[thirddisplayplayer].skincolor = skins[players[thirddisplayplayer].skin].prefcolor; players[displayplayers[2]].skincolor = skins[players[displayplayers[2]].skin].prefcolor;
} }
if (splitscreen > 2) if (splitscreen > 2)
{ {
SetPlayerSkin(fourthdisplayplayer, forcecharskin); SetPlayerSkin(displayplayers[3], forcecharskin);
if ((unsigned)cv_playercolor4.value != skins[players[fourthdisplayplayer].skin].prefcolor && !modeattacking) if ((unsigned)cv_playercolor4.value != skins[players[displayplayers[3]].skin].prefcolor && !modeattacking)
{ {
CV_StealthSetValue(&cv_playercolor4, skins[players[fourthdisplayplayer].skin].prefcolor); CV_StealthSetValue(&cv_playercolor4, skins[players[displayplayers[3]].skin].prefcolor);
players[fourthdisplayplayer].skincolor = skins[players[fourthdisplayplayer].skin].prefcolor; players[displayplayers[3]].skincolor = skins[players[displayplayers[3]].skin].prefcolor;
} }
} }
} }
@ -2793,7 +2793,8 @@ boolean P_SetupLevel(boolean skipprecip)
P_LevelInitStuff(); P_LevelInitStuff();
postimgtype = postimgtype2 = postimgtype3 = postimgtype4 = postimg_none; for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none;
if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0'
&& atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255)
@ -3180,19 +3181,8 @@ boolean P_SetupLevel(boolean skipprecip)
if (!dedicated) if (!dedicated)
{ {
P_SetupCamera(displayplayer, &camera); for (i = 0; i <= splitscreen; i++)
if (splitscreen) P_SetupCamera(displayplayers[i], &camera[i]);
{
P_SetupCamera(secondarydisplayplayer, &camera2);
if (splitscreen > 1)
{
P_SetupCamera(thirddisplayplayer, &camera3);
if (splitscreen > 2)
{
P_SetupCamera(fourthdisplayplayer, &camera4);
}
}
}
// Salt: CV_ClearChangedFlags() messes with your settings :( // Salt: CV_ClearChangedFlags() messes with your settings :(
/*if (!cv_cam_height.changed) /*if (!cv_cam_height.changed)
@ -3233,7 +3223,7 @@ boolean P_SetupLevel(boolean skipprecip)
/*if (rendermode != render_none) /*if (rendermode != render_none)
CV_Set(&cv_fov, cv_fov.defaultvalue);*/ CV_Set(&cv_fov, cv_fov.defaultvalue);*/
displayplayer = consoleplayer; // Start with your OWN view, please! displayplayers[0] = consoleplayer; // Start with your OWN view, please!
} }
/*if (cv_useranalog.value) /*if (cv_useranalog.value)
@ -3312,7 +3302,10 @@ boolean P_SetupLevel(boolean skipprecip)
savedata.lives = 0; savedata.lives = 0;
} }
skyVisible = skyVisible1 = skyVisible2 = skyVisible3 = skyVisible4 = true; // assume the skybox is visible on level load. // assume the skybox is visible on level load.
skyVisible = true;
memset(skyVisiblePerPlayer, true, sizeof(skyVisiblePerPlayer));
if (loadprecip) // uglier hack if (loadprecip) // uglier hack
{ // to make a newly loaded level start on the second frame. { // to make a newly loaded level start on the second frame.
INT32 buf = gametic % BACKUPTICS; INT32 buf = gametic % BACKUPTICS;

View file

@ -2243,7 +2243,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
I_Assert(!mo || !P_MobjWasRemoved(mo)); // If mo is there, mo must be valid! I_Assert(!mo || !P_MobjWasRemoved(mo)); // If mo is there, mo must be valid!
if (mo && mo->player && botingame) if (mo && mo->player && botingame)
bot = players[secondarydisplayplayer].mo; bot = players[displayplayers[1]].mo;
// note: only commands with linedef types >= 400 && < 500 can be used // note: only commands with linedef types >= 400 && < 500 can be used
switch (line->special) switch (line->special)
@ -2383,33 +2383,17 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{ {
if (bot) // This might put poor Tails in a wall if he's too far behind! D: But okay, whatever! >:3 if (bot) // This might put poor Tails in a wall if he's too far behind! D: But okay, whatever! >:3
P_TeleportMove(bot, bot->x + x, bot->y + y, bot->z + z); P_TeleportMove(bot, bot->x + x, bot->y + y, bot->z + z);
if (splitscreen > 2 && mo->player == &players[fourthdisplayplayer] && camera4.chase)
for (i = 0; i <= splitscreen; i++)
{ {
camera4.x += x; if (mo->player == &players[displayplayers[i]] && camera[i].chase)
camera4.y += y; {
camera4.z += z; camera[i].x += x;
camera4.subsector = R_PointInSubsector(camera4.x, camera4.y); camera[i].y += y;
camera[i].z += z;
camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y);
break;
} }
else if (splitscreen > 1 && mo->player == &players[thirddisplayplayer] && camera3.chase)
{
camera3.x += x;
camera3.y += y;
camera3.z += z;
camera3.subsector = R_PointInSubsector(camera3.x, camera3.y);
}
else if (splitscreen && mo->player == &players[secondarydisplayplayer] && camera2.chase)
{
camera2.x += x;
camera2.y += y;
camera2.z += z;
camera2.subsector = R_PointInSubsector(camera2.x, camera2.y);
}
else if (camera.chase && mo->player == &players[displayplayer])
{
camera.x += x;
camera.y += y;
camera.z += z;
camera.subsector = R_PointInSubsector(camera.x, camera.y);
} }
} }
} }
@ -2515,8 +2499,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (line->flags & ML_NOCLIMB) if (line->flags & ML_NOCLIMB)
{ {
// play the sound from nowhere, but only if display player triggered it // play the sound from nowhere, but only if display player triggered it
if (mo && mo->player && (mo->player == &players[displayplayer] || mo->player == &players[secondarydisplayplayer] if (mo && mo->player && P_IsDisplayPlayer(mo->player))
|| mo->player == &players[thirddisplayplayer] || mo->player == &players[fourthdisplayplayer]))
S_StartSound(NULL, sfxnum); S_StartSound(NULL, sfxnum);
} }
else if (line->flags & ML_EFFECT4) else if (line->flags & ML_EFFECT4)
@ -3837,13 +3820,13 @@ DoneSection2:
if (!demo.playback || P_AnalogMove(player)) if (!demo.playback || P_AnalogMove(player))
{ {
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localangle = player->mo->angle; localangle[0] = player->mo->angle;
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localangle2 = player->mo->angle; localangle[1] = player->mo->angle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localangle3 = player->mo->angle; localangle[2] = player->mo->angle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localangle4 = player->mo->angle; localangle[3] = player->mo->angle;
} }
if (!(lines[i].flags & ML_EFFECT4)) if (!(lines[i].flags & ML_EFFECT4))
@ -7845,40 +7828,40 @@ void T_Pusher(pusher_t *p)
{ {
if (thing->player == &players[consoleplayer]) if (thing->player == &players[consoleplayer])
{ {
if (thing->angle - localangle > ANGLE_180) if (thing->angle - localangle[0] > ANGLE_180)
localangle -= (localangle - thing->angle) / 8; localangle[0] -= (localangle[0] - thing->angle) / 8;
else else
localangle += (thing->angle - localangle) / 8; localangle[0] += (thing->angle - localangle[0]) / 8;
} }
else if (thing->player == &players[secondarydisplayplayer]) else if (thing->player == &players[displayplayers[1]])
{ {
if (thing->angle - localangle2 > ANGLE_180) if (thing->angle - localangle[1] > ANGLE_180)
localangle2 -= (localangle2 - thing->angle) / 8; localangle[1] -= (localangle[1] - thing->angle) / 8;
else else
localangle2 += (thing->angle - localangle2) / 8; localangle[1] += (thing->angle - localangle[1]) / 8;
} }
else if (thing->player == &players[thirddisplayplayer]) else if (thing->player == &players[displayplayers[2]])
{ {
if (thing->angle - localangle3 > ANGLE_180) if (thing->angle - localangle[2] > ANGLE_180)
localangle3 -= (localangle3 - thing->angle) / 8; localangle[2] -= (localangle[2] - thing->angle) / 8;
else else
localangle3 += (thing->angle - localangle3) / 8; localangle[2] += (thing->angle - localangle[2]) / 8;
} }
else if (thing->player == &players[fourthdisplayplayer]) else if (thing->player == &players[displayplayers[3]])
{ {
if (thing->angle - localangle4 > ANGLE_180) if (thing->angle - localangle[3] > ANGLE_180)
localangle4 -= (localangle4 - thing->angle) / 8; localangle[3] -= (localangle[3] - thing->angle) / 8;
else else
localangle4 += (thing->angle - localangle4) / 8; localangle[3] += (thing->angle - localangle[3]) / 8;
} }
/*if (thing->player == &players[consoleplayer]) /*if (thing->player == &players[consoleplayer])
localangle = thing->angle; localangle[0] = thing->angle;
else if (thing->player == &players[secondarydisplayplayer]) else if (thing->player == &players[displayplayers[1]])
localangle2 = thing->angle; localangle[1] = thing->angle;
else if (thing->player == &players[thirddisplayplayer]) else if (thing->player == &players[displayplayers[2]])
localangle3 = thing->angle; localangle[2] = thing->angle;
else if (thing->player == &players[fourthdisplayplayer]) else if (thing->player == &players[displayplayers[3]])
localangle4 = thing->angle;*/ localangle[3] = thing->angle;*/
} }
} }

View file

@ -36,6 +36,7 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
INT32 flags2) INT32 flags2)
{ {
const INT32 takeflags2 = MF2_TWOD|MF2_OBJECTFLIP; const INT32 takeflags2 = MF2_TWOD|MF2_OBJECTFLIP;
UINT8 i;
// the move is ok, // the move is ok,
// so link the thing into its new position // so link the thing into its new position
@ -64,23 +65,25 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
// absolute angle position // absolute angle position
if (thing == players[consoleplayer].mo) if (thing == players[consoleplayer].mo)
localangle = angle; localangle[0] = angle;
if (thing == players[secondarydisplayplayer].mo) else if (splitscreen)
localangle2 = angle; {
if (thing == players[thirddisplayplayer].mo) for (i = 1; i <= splitscreen; i++)
localangle3 = angle; {
if (thing == players[fourthdisplayplayer].mo) if (thing == players[displayplayers[i]].mo)
localangle4 = angle; {
localangle[i] = angle;
break;
}
}
}
// move chasecam at new player location // move chasecam at new player location
if (splitscreen > 2 && camera4.chase && thing->player == &players[fourthdisplayplayer]) for (i = 0; i <= splitscreen; i++)
P_ResetCamera(thing->player, &camera4); {
else if (splitscreen > 1 && camera3.chase && thing->player == &players[thirddisplayplayer]) if (thing->player == &players[displayplayers[i]] && camera[i].chase)
P_ResetCamera(thing->player, &camera3); P_ResetCamera(thing->player, &camera[i]);
else if (splitscreen && camera2.chase && thing->player == &players[secondarydisplayplayer]) }
P_ResetCamera(thing->player, &camera2);
else if (camera.chase && thing->player == &players[displayplayer])
P_ResetCamera(thing->player, &camera);
// don't run in place after a teleport // don't run in place after a teleport
thing->player->cmomx = thing->player->cmomy = 0; thing->player->cmomx = thing->player->cmomy = 0;
@ -123,6 +126,8 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
*/ */
boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, boolean flash, boolean dontstopmove) boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, boolean flash, boolean dontstopmove)
{ {
UINT8 i;
if (!P_TeleportMove(thing, x, y, z)) if (!P_TeleportMove(thing, x, y, z))
return false; return false;
@ -144,24 +149,26 @@ boolean P_Teleport(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 thing->reactiontime = TICRATE/2; // don't move for about half a second
// absolute angle position // absolute angle position
if (thing->player == &players[consoleplayer]) if (thing == players[consoleplayer].mo)
localangle = angle; localangle[0] = angle;
if (thing->player == &players[secondarydisplayplayer]) else if (splitscreen)
localangle2 = angle; {
if (thing->player == &players[thirddisplayplayer]) for (i = 1; i <= splitscreen; i++)
localangle3 = angle; {
if (thing->player == &players[fourthdisplayplayer]) if (thing == players[displayplayers[i]].mo)
localangle4 = angle; {
localangle[i] = angle;
break;
}
}
}
// move chasecam at new player location // move chasecam at new player location
if (splitscreen > 2 && camera4.chase && thing->player == &players[fourthdisplayplayer]) for (i = 0; i <= splitscreen; i++)
P_ResetCamera(thing->player, &camera4); {
else if (splitscreen > 1 && camera3.chase && thing->player == &players[thirddisplayplayer]) if (thing->player == &players[displayplayers[i]] && camera[i].chase)
P_ResetCamera(thing->player, &camera3); P_ResetCamera(thing->player, &camera[i]);
else if (splitscreen && camera2.chase && thing->player == &players[secondarydisplayplayer]) }
P_ResetCamera(thing->player, &camera2);
else if (camera.chase && thing->player == &players[displayplayer])
P_ResetCamera(thing->player, &camera);
// don't run in place after a teleport // don't run in place after a teleport
if (!dontstopmove) if (!dontstopmove)

View file

@ -583,7 +583,7 @@ void P_Ticker(boolean run)
{ {
P_MapStart(); P_MapStart();
OP_ObjectplaceMovement(&players[0]); OP_ObjectplaceMovement(&players[0]);
P_MoveChaseCamera(&players[0], &camera, false); P_MoveChaseCamera(&players[0], &camera[0], false);
P_MapEnd(); P_MapEnd();
return; return;
} }
@ -601,7 +601,8 @@ void P_Ticker(boolean run)
return; return;
} }
postimgtype = postimgtype2 = postimgtype3 = postimgtype4 = postimg_none; for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none;
P_MapStart(); P_MapStart();
@ -776,14 +777,11 @@ void P_Ticker(boolean run)
} }
// Always move the camera. // Always move the camera.
if (camera.chase) for (i = 0; i <= splitscreen; i++)
P_MoveChaseCamera(&players[displayplayer], &camera, false); {
if (splitscreen && camera2.chase) if (camera[i].chase)
P_MoveChaseCamera(&players[secondarydisplayplayer], &camera2, false); P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false);
if (splitscreen > 1 && camera3.chase) }
P_MoveChaseCamera(&players[thirddisplayplayer], &camera3, false);
if (splitscreen > 2 && camera4.chase)
P_MoveChaseCamera(&players[fourthdisplayplayer], &camera4, false);
P_MapEnd(); P_MapEnd();
@ -799,7 +797,8 @@ void P_PreTicker(INT32 frames)
INT32 i,framecnt; INT32 i,framecnt;
ticcmd_t temptic; ticcmd_t temptic;
postimgtype = postimgtype2 = postimgtype3 = postimgtype4 = postimg_none; for (i = 0; i <= splitscreen; i++)
postimgtype[i] = postimg_none;
for (framecnt = 0; framecnt < frames; ++framecnt) for (framecnt = 0; framecnt < frames; ++framecnt)
{ {

View file

@ -654,13 +654,13 @@ static void P_DeNightserizePlayer(player_t *player)
// Restore aiming angle // Restore aiming angle
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localaiming = 0; localaiming[0] = 0;
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localaiming2 = 0; localaiming[1] = 0;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localaiming3 = 0; localaiming[2] = 0;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localaiming4 = 0; localaiming[3] = 0;
if (player->mo->tracer) if (player->mo->tracer)
P_RemoveMobj(player->mo->tracer); P_RemoveMobj(player->mo->tracer);
@ -1154,25 +1154,25 @@ boolean P_EndingMusic(player_t *player)
// Check for if this is valid or not // Check for if this is valid or not
if (splitscreen) if (splitscreen)
{ {
if (!((players[displayplayer].exiting || (players[displayplayer].pflags & PF_TIMEOVER)) if (!((players[displayplayers[0]].exiting || (players[displayplayers[0]].pflags & PF_TIMEOVER))
|| (players[secondarydisplayplayer].exiting || (players[secondarydisplayplayer].pflags & PF_TIMEOVER)) || (players[displayplayers[1]].exiting || (players[displayplayers[1]].pflags & PF_TIMEOVER))
|| ((splitscreen < 2) && (players[thirddisplayplayer].exiting || (players[thirddisplayplayer].pflags & PF_TIMEOVER))) || ((splitscreen < 2) && (players[displayplayers[2]].exiting || (players[displayplayers[2]].pflags & PF_TIMEOVER)))
|| ((splitscreen < 3) && (players[fourthdisplayplayer].exiting || (players[fourthdisplayplayer].pflags & PF_TIMEOVER))))) || ((splitscreen < 3) && (players[displayplayers[3]].exiting || (players[displayplayers[3]].pflags & PF_TIMEOVER)))))
return false; return false;
bestlocalplayer = &players[displayplayer]; bestlocalplayer = &players[displayplayers[0]];
bestlocalpos = ((players[displayplayer].pflags & PF_TIMEOVER) ? MAXPLAYERS+1 : players[displayplayer].kartstuff[k_position]); bestlocalpos = ((players[displayplayers[0]].pflags & PF_TIMEOVER) ? MAXPLAYERS+1 : players[displayplayers[0]].kartstuff[k_position]);
#define setbests(p) \ #define setbests(p) \
if (((players[p].pflags & PF_TIMEOVER) ? MAXPLAYERS+1 : players[p].kartstuff[k_position]) < bestlocalpos) \ if (((players[p].pflags & PF_TIMEOVER) ? MAXPLAYERS+1 : players[p].kartstuff[k_position]) < bestlocalpos) \
{ \ { \
bestlocalplayer = &players[p]; \ bestlocalplayer = &players[p]; \
bestlocalpos = ((players[p].pflags & PF_TIMEOVER) ? MAXPLAYERS+1 : players[p].kartstuff[k_position]); \ bestlocalpos = ((players[p].pflags & PF_TIMEOVER) ? MAXPLAYERS+1 : players[p].kartstuff[k_position]); \
} }
setbests(secondarydisplayplayer); setbests(displayplayers[1]);
if (splitscreen > 1) if (splitscreen > 1)
setbests(thirddisplayplayer); setbests(displayplayers[2]);
if (splitscreen > 2) if (splitscreen > 2)
setbests(fourthdisplayplayer); setbests(displayplayers[3]);
#undef setbests #undef setbests
} }
else else
@ -1253,12 +1253,12 @@ void P_RestoreMusic(player_t *player)
else if (players[p].kartstuff[k_invincibilitytimer] > bestlocaltimer) \ else if (players[p].kartstuff[k_invincibilitytimer] > bestlocaltimer) \
{ wantedmus = 1; bestlocaltimer = players[p].kartstuff[k_invincibilitytimer]; } \ { wantedmus = 1; bestlocaltimer = players[p].kartstuff[k_invincibilitytimer]; } \
} }
setbests(displayplayer); setbests(displayplayers[0]);
setbests(secondarydisplayplayer); setbests(displayplayers[1]);
if (splitscreen > 1) if (splitscreen > 1)
setbests(thirddisplayplayer); setbests(displayplayers[2]);
if (splitscreen > 2) if (splitscreen > 2)
setbests(fourthdisplayplayer); setbests(displayplayers[3]);
#undef setbests #undef setbests
} }
else else
@ -1516,10 +1516,39 @@ fixed_t P_GetPlayerSpinHeight(player_t *player)
// //
boolean P_IsLocalPlayer(player_t *player) boolean P_IsLocalPlayer(player_t *player)
{ {
return ((splitscreen > 2 && player == &players[fourthdisplayplayer]) UINT8 i;
|| (splitscreen > 1 && player == &players[thirddisplayplayer])
|| (splitscreen && player == &players[secondarydisplayplayer]) if (player == &players[consoleplayer])
|| player == &players[consoleplayer]); return true;
else if (splitscreen)
{
for (i = 1; i <= splitscreen; i++) // Skip P1
{
if (player == &players[displayplayers[i]])
return true;
}
}
return false;
}
//
// P_IsDisplayPlayer
//
// Returns true if player is
// currently being watched.
//
boolean P_IsDisplayPlayer(player_t *player)
{
UINT8 i;
for (i = 0; i <= splitscreen; i++) // DON'T skip P1
{
if (player == &players[displayplayers[i]])
return true;
}
return false;
} }
// //
@ -1772,11 +1801,7 @@ void P_DoPlayerExit(player_t *player)
if (player->exiting || mapreset) if (player->exiting || mapreset)
return; return;
if ((player == &players[consoleplayer] if (P_IsLocalPlayer(player) && (!player->spectator && !demo.playback))
|| (splitscreen && player == &players[secondarydisplayplayer])
|| (splitscreen > 1 && player == &players[thirddisplayplayer])
|| (splitscreen > 2 && player == &players[fourthdisplayplayer]))
&& (!player->spectator && !demo.playback))
legitimateexit = true; legitimateexit = true;
if (G_RaceGametype()) // If in Race Mode, allow if (G_RaceGametype()) // If in Race Mode, allow
@ -2515,8 +2540,7 @@ static void P_DoPlayerHeadSigns(player_t *player)
// If you're "IT", show a big "IT" over your head for others to see. // If you're "IT", show a big "IT" over your head for others to see.
if (player->pflags & PF_TAGIT) if (player->pflags & PF_TAGIT)
{ {
if (!(player == &players[consoleplayer] || player == &players[displayplayer] || player == &players[secondarydisplayplayer] if (!P_IsDisplayPlayer(player)) // Don't display it on your own view.
|| player == &players[thirddisplayplayer] || player == &players[fourthdisplayplayer])) // Don't display it on your own view.
{ {
if (!(player->mo->eflags & MFE_VERTICALFLIP)) if (!(player->mo->eflags & MFE_VERTICALFLIP))
P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height, MT_TAG); P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height, MT_TAG);
@ -3004,13 +3028,13 @@ static void P_DoClimbing(player_t *player) // SRB2kart - unused
} }
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localangle = player->mo->angle; localangle[0] = player->mo->angle;
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localangle2 = player->mo->angle; localangle[1] = player->mo->angle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localangle3 = player->mo->angle; localangle[2] = player->mo->angle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localangle4 = player->mo->angle; localangle[3] = player->mo->angle;
if (player->climbing == 0) if (player->climbing == 0)
P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); P_SetPlayerMobjState(player->mo, S_PLAY_ATK1);
@ -3675,13 +3699,13 @@ void P_DoJump(player_t *player, boolean soundandstate)
player->mo->angle = player->mo->angle - ANGLE_180; // Turn around from the wall you were climbing. player->mo->angle = player->mo->angle - ANGLE_180; // Turn around from the wall you were climbing.
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localangle = player->mo->angle; // Adjust the local control angle. localangle[0] = player->mo->angle; // Adjust the local control angle.
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localangle2 = player->mo->angle; localangle[1] = player->mo->angle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localangle3 = player->mo->angle; localangle[2] = player->mo->angle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localangle4 = player->mo->angle; localangle[3] = player->mo->angle;
player->climbing = 0; // Stop climbing, duh! player->climbing = 0; // Stop climbing, duh!
P_InstaThrust(player->mo, player->mo->angle, FixedMul(6*FRACUNIT, player->mo->scale)); // Jump off the wall. P_InstaThrust(player->mo, player->mo->angle, FixedMul(6*FRACUNIT, player->mo->scale)); // Jump off the wall.
@ -4365,14 +4389,14 @@ boolean P_AnalogMove(player_t *player)
fixed_t tempx = 0, tempy = 0; fixed_t tempx = 0, tempy = 0;
angle_t tempangle, origtempangle; angle_t tempangle, origtempangle;
if (splitscreen > 2 && player == &players[fourthdisplayplayer]) if (splitscreen > 2 && player == &players[displayplayers[3]])
thiscam = &camera4; thiscam = &camera[3];
else if (splitscreen > 1 && player == &players[thirddisplayplayer]) else if (splitscreen > 1 && player == &players[displayplayers[2]])
thiscam = &camera3; thiscam = &camera[2];
else if (splitscreen && player == &players[secondarydisplayplayer]) else if (splitscreen && player == &players[displayplayers[1]])
thiscam = &camera2; thiscam = &camera[1];
else else
thiscam = &camera; thiscam = &camera[0];
if (!cmd->forwardmove && !cmd->sidemove) if (!cmd->forwardmove && !cmd->sidemove)
return 0; return 0;
@ -4513,13 +4537,13 @@ static void P_2dMovement(player_t *player)
} }
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localangle = player->mo->angle; localangle[0] = player->mo->angle;
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localangle2 = player->mo->angle; localangle[1] = player->mo->angle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localangle3 = player->mo->angle; localangle[2] = player->mo->angle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localangle4 = player->mo->angle; localangle[3] = player->mo->angle;
if (player->pflags & PF_GLIDING) if (player->pflags & PF_GLIDING)
movepushangle = player->mo->angle; movepushangle = player->mo->angle;
@ -6049,13 +6073,13 @@ static void P_NiGHTSMovement(player_t *player)
P_SetMobjStateNF(player->mo->tracer, leveltime & 1 ? flystate : flystate+1); P_SetMobjStateNF(player->mo->tracer, leveltime & 1 ? flystate : flystate+1);
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localangle = player->mo->angle; localangle[0] = player->mo->angle;
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localangle2 = player->mo->angle; localangle[1] = player->mo->angle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localangle3 = player->mo->angle; localangle[2] = player->mo->angle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localangle4 = player->mo->angle; localangle[3] = player->mo->angle;
if (still) if (still)
{ {
@ -6082,13 +6106,13 @@ static void P_NiGHTSMovement(player_t *player)
movingangle = InvAngle(movingangle); movingangle = InvAngle(movingangle);
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localaiming = movingangle; localaiming[0] = movingangle;
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localaiming2 = movingangle; localaiming[1] = movingangle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localaiming3 = movingangle; localaiming[2] = movingangle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localaiming4 = movingangle; localaiming[3] = movingangle;
player->mo->tracer->angle = player->mo->angle; player->mo->tracer->angle = player->mo->angle;
@ -6352,7 +6376,7 @@ static void P_MovePlayer(player_t *player)
{ {
if (G_IsSpecialStage(gamemap)) if (G_IsSpecialStage(gamemap))
{ {
if (player == &players[displayplayer]) // only play the sound for yourself landing if (player == &players[displayplayers[0]]) // only play the sound for yourself landing
S_StartSound(NULL, sfx_s3k6a); S_StartSound(NULL, sfx_s3k6a);
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i]) if (playeringame[i])
@ -6865,13 +6889,13 @@ static void P_MovePlayer(player_t *player)
// Update the local angle control. // Update the local angle control.
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localangle = player->mo->angle; localangle[0] = player->mo->angle;
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localangle2 = player->mo->angle; localangle[1] = player->mo->angle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localangle3 = player->mo->angle; localangle[2] = player->mo->angle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localangle4 = player->mo->angle; localangle[3] = player->mo->angle;
} }
#endif #endif
@ -7193,13 +7217,13 @@ 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); player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, player->mo->tracer->x, player->mo->tracer->y);
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localangle = player->mo->angle; localangle[0] = player->mo->angle;
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localangle2 = player->mo->angle; localangle[1] = player->mo->angle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localangle3 = player->mo->angle; localangle[2] = player->mo->angle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localangle4 = player->mo->angle; localangle[3] = player->mo->angle;
} }
#if 0 #if 0
if (player->mo->state != &states[S_KART_SPIN]) if (player->mo->state != &states[S_KART_SPIN])
@ -7589,13 +7613,13 @@ void P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target
if (source->player) if (source->player)
{ {
if (source->player == &players[consoleplayer]) if (source->player == &players[consoleplayer])
localangle = source->angle; localangle[0] = source->angle;
else if (source->player == &players[secondarydisplayplayer]) else if (source->player == &players[displayplayers[1]])
localangle2 = source->angle; localangle[1] = source->angle;
else if (source->player == &players[thirddisplayplayer]) else if (source->player == &players[displayplayers[2]])
localangle3 = source->angle; localangle[2] = source->angle;
else if (source->player == &players[fourthdisplayplayer]) else if (source->player == &players[displayplayers[3]])
localangle4 = source->angle; localangle[3] = source->angle;
} }
// change slope // change slope
@ -7728,7 +7752,7 @@ notrealplayer:
// P_MoveCamera: make sure the camera is not outside the world and looks at the player avatar // P_MoveCamera: make sure the camera is not outside the world and looks at the player avatar
// //
camera_t camera, camera2, camera3, camera4; // Four cameras, three for splitscreen camera_t camera[MAXSPLITSCREENPLAYERS]; // Four cameras, three for splitscreen
static void CV_CamRotate_OnChange(void) static void CV_CamRotate_OnChange(void)
{ {
@ -7809,17 +7833,6 @@ fixed_t t_cam4_rotate = -42;
#define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode) #define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode)
camera_t *P_GetCameraPtr(UINT8 viewnum)
{
switch (viewnum)
{
case 2: return &camera2;
case 3: return &camera3;
case 4: return &camera4;
}
return &camera;
}
void P_ResetCamera(player_t *player, camera_t *thiscam) void P_ResetCamera(player_t *player, camera_t *thiscam)
{ {
tic_t tries = 0; tic_t tries = 0;
@ -7844,10 +7857,10 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
thiscam->y = y; thiscam->y = y;
thiscam->z = z; thiscam->z = z;
if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value)) if (!(thiscam == &camera[0] && (cv_cam_still.value || cv_analog.value))
&& !(thiscam == &camera2 && (cv_cam2_still.value || cv_analog2.value)) && !(thiscam == &camera[1] && (cv_cam2_still.value || cv_analog2.value))
&& !(thiscam == &camera3 && (cv_cam3_still.value || cv_analog3.value)) && !(thiscam == &camera[2] && (cv_cam3_still.value || cv_analog3.value))
&& !(thiscam == &camera4 && (cv_cam4_still.value || cv_analog4.value))) && !(thiscam == &camera[3] && (cv_cam4_still.value || cv_analog4.value)))
{ {
thiscam->angle = player->mo->angle; thiscam->angle = player->mo->angle;
thiscam->aiming = 0; thiscam->aiming = 0;
@ -7905,31 +7918,32 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (player->spectator) // force cam off for spectators if (player->spectator) // force cam off for spectators
return true; return true;
if (!cv_chasecam.value && thiscam == &camera) if (!cv_chasecam.value && thiscam == &camera[0])
return true; return true;
if (!cv_chasecam2.value && thiscam == &camera2) if (!cv_chasecam2.value && thiscam == &camera[1])
return true; return true;
if (!cv_chasecam3.value && thiscam == &camera3) if (!cv_chasecam3.value && thiscam == &camera[2])
return true; return true;
if (!cv_chasecam4.value && thiscam == &camera4) if (!cv_chasecam4.value && thiscam == &camera[3])
return true; return true;
} }
if (!thiscam->chase && !resetcalled) if (!thiscam->chase && !resetcalled)
{ {
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
focusangle = localangle; focusangle = localangle[0];
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
focusangle = localangle2; focusangle = localangle[1];
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
focusangle = localangle3; focusangle = localangle[2];
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
focusangle = localangle4; focusangle = localangle[3];
else else
focusangle = mo->angle; focusangle = mo->angle;
if (thiscam == &camera) if (thiscam == &camera)
camrotate = cv_cam_rotate.value; camrotate = cv_cam_rotate.value;
else if (thiscam == &camera2) else if (thiscam == &camera2)
@ -7940,11 +7954,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
camrotate = cv_cam4_rotate.value; camrotate = cv_cam4_rotate.value;
else else
camrotate = 0; camrotate = 0;
if (leveltime < introtime) // Whoooshy camera! if (leveltime < introtime) // Whoooshy camera!
{ {
const INT32 introcam = (introtime - leveltime); const INT32 introcam = (introtime - leveltime);
camrotate += introcam*5; camrotate += introcam*5;
} }
thiscam->angle = focusangle + FixedAngle(camrotate*FRACUNIT); thiscam->angle = focusangle + FixedAngle(camrotate*FRACUNIT);
P_ResetCamera(player, thiscam); P_ResetCamera(player, thiscam);
return true; return true;
@ -7965,23 +7981,23 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
} }
else if (player == &players[consoleplayer]) else if (player == &players[consoleplayer])
{ {
focusangle = localangle; focusangle = localangle[0];
focusaiming = localaiming; focusaiming = localaiming[0];
} }
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
{ {
focusangle = localangle2; focusangle = localangle[1];
focusaiming = localaiming2; focusaiming = localaiming[1];
} }
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
{ {
focusangle = localangle3; focusangle = localangle[2];
focusaiming = localaiming3; focusaiming = localaiming[2];
} }
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
{ {
focusangle = localangle4; focusangle = localangle[3];
focusaiming = localaiming4; focusaiming = localaiming[3];
} }
else else
{ {
@ -7992,17 +8008,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (P_CameraThinker(player, thiscam, resetcalled)) if (P_CameraThinker(player, thiscam, resetcalled))
return true; return true;
if (thiscam == &camera)
{ if (thiscam == &camera[1]) // Camera 2
num = 0;
camspeed = cv_cam_speed.value;
camstill = cv_cam_still.value;
camrotate = cv_cam_rotate.value;
camdist = FixedMul(cv_cam_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam_height.value, mapobjectscale);
lookback = camspin;
}
else if (thiscam == &camera2) // Camera 2
{ {
num = 1; num = 1;
camspeed = cv_cam2_speed.value; camspeed = cv_cam2_speed.value;
@ -8010,9 +8017,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
camrotate = cv_cam2_rotate.value; camrotate = cv_cam2_rotate.value;
camdist = FixedMul(cv_cam2_dist.value, mapobjectscale); camdist = FixedMul(cv_cam2_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam2_height.value, mapobjectscale); camheight = FixedMul(cv_cam2_height.value, mapobjectscale);
lookback = camspin2; lookback = camspin[1];
} }
else if (thiscam == &camera3) // Camera 3 else if (thiscam == &camera[2]) // Camera 3
{ {
num = 2; num = 2;
camspeed = cv_cam3_speed.value; camspeed = cv_cam3_speed.value;
@ -8020,9 +8027,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
camrotate = cv_cam3_rotate.value; camrotate = cv_cam3_rotate.value;
camdist = FixedMul(cv_cam3_dist.value, mapobjectscale); camdist = FixedMul(cv_cam3_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam3_height.value, mapobjectscale); camheight = FixedMul(cv_cam3_height.value, mapobjectscale);
lookback = camspin3; lookback = camspin[2];
} }
else // Camera 4 else if (thiscam == &camera[3]) // Camera 4
{ {
num = 3; num = 3;
camspeed = cv_cam4_speed.value; camspeed = cv_cam4_speed.value;
@ -8030,7 +8037,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
camrotate = cv_cam4_rotate.value; camrotate = cv_cam4_rotate.value;
camdist = FixedMul(cv_cam4_dist.value, mapobjectscale); camdist = FixedMul(cv_cam4_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam4_height.value, mapobjectscale); camheight = FixedMul(cv_cam4_height.value, mapobjectscale);
lookback = camspin4; lookback = camspin[3];
}
else // Camera 1
{
num = 0;
camspeed = cv_cam_speed.value;
camstill = cv_cam_still.value;
camrotate = cv_cam_rotate.value;
camdist = FixedMul(cv_cam_dist.value, mapobjectscale);
camheight = FixedMul(cv_cam_height.value, mapobjectscale);
lookback = camspin[0];
} }
if (timeover) if (timeover)
@ -8091,10 +8108,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
} }
if (!resetcalled && (leveltime > starttime && timeover != 2) if (!resetcalled && (leveltime > starttime && timeover != 2)
&& ((thiscam == &camera && t_cam_rotate != -42) && ((thiscam == &camera[0] && t_cam_rotate != -42)
|| (thiscam == &camera2 && t_cam2_rotate != -42) || (thiscam == &camera[1] && t_cam2_rotate != -42)
|| (thiscam == &camera3 && t_cam3_rotate != -42) || (thiscam == &camera[2] && t_cam3_rotate != -42)
|| (thiscam == &camera4 && t_cam4_rotate != -42))) || (thiscam == &camera[3] && t_cam4_rotate != -42)))
{ {
angle = FixedAngle(camrotate*FRACUNIT); angle = FixedAngle(camrotate*FRACUNIT);
thiscam->angle = angle; thiscam->angle = angle;
@ -8489,8 +8506,8 @@ boolean P_SpectatorJoinGame(player_t *player)
player->playerstate = PST_REBORN; player->playerstate = PST_REBORN;
//Reset away view //Reset away view
if (P_IsLocalPlayer(player) && displayplayer != consoleplayer) if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer)
displayplayer = consoleplayer; displayplayers[0] = consoleplayer;
if (changeto == 1) if (changeto == 1)
CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x85', M_GetText("Red team"), '\x80'); CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x85', M_GetText("Red team"), '\x80');
@ -8513,8 +8530,8 @@ boolean P_SpectatorJoinGame(player_t *player)
player->playerstate = PST_REBORN; player->playerstate = PST_REBORN;
//Reset away view //Reset away view
if (P_IsLocalPlayer(player) && displayplayer != consoleplayer) if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer)
displayplayer = consoleplayer; displayplayers[0] = consoleplayer;
HU_AddChatText(va(M_GetText("\x82*%s entered the game."), player_names[player-players]), false); HU_AddChatText(va(M_GetText("\x82*%s entered the game."), player_names[player-players]), false);
return true; // no more player->mo, cannot continue. return true; // no more player->mo, cannot continue.
@ -8528,6 +8545,7 @@ static void P_CalcPostImg(player_t *player)
postimg_t *type; postimg_t *type;
INT32 *param; INT32 *param;
fixed_t pviewheight; fixed_t pviewheight;
UINT8 i;
if (player->mo->eflags & MFE_VERTICALFLIP) if (player->mo->eflags & MFE_VERTICALFLIP)
pviewheight = player->mo->z + player->mo->height - player->viewheight; pviewheight = player->mo->z + player->mo->height - player->viewheight;
@ -8540,25 +8558,14 @@ static void P_CalcPostImg(player_t *player)
pviewheight = player->awayviewmobj->z + 20*FRACUNIT; pviewheight = player->awayviewmobj->z + 20*FRACUNIT;
} }
if (splitscreen > 2 && player == &players[fourthdisplayplayer]) for (i = 0; i <= splitscreen; i++)
{ {
type = &postimgtype4; if (player == &players[displayplayers[i]])
param = &postimgparam4; {
type = &postimgtype[i];
param = &postimgparam[i];
break;
} }
else if (splitscreen > 1 && player == &players[thirddisplayplayer])
{
type = &postimgtype3;
param = &postimgparam3;
}
else if (splitscreen && player == &players[secondarydisplayplayer])
{
type = &postimgtype2;
param = &postimgparam2;
}
else
{
type = &postimgtype;
param = &postimgparam;
} }
// see if we are in heat (no, not THAT kind of heat...) // see if we are in heat (no, not THAT kind of heat...)
@ -8666,11 +8673,7 @@ void P_DoTimeOver(player_t *player)
player->pflags |= PF_TIMEOVER; player->pflags |= PF_TIMEOVER;
if ((player == &players[consoleplayer] if (P_IsLocalPlayer(player) && !demo.playback)
|| (splitscreen && player == &players[secondarydisplayplayer])
|| (splitscreen > 1 && player == &players[thirddisplayplayer])
|| (splitscreen > 2 && player == &players[fourthdisplayplayer]))
&& !demo.playback)
legitimateexit = true; // SRB2kart: losing a race is still seeing it through to the end :p legitimateexit = true; // SRB2kart: losing a race is still seeing it through to the end :p
if (player->mo) if (player->mo)
@ -8717,7 +8720,7 @@ void P_PlayerThink(player_t *player)
} }
#ifdef SEENAMES #ifdef SEENAMES
if (netgame && player == &players[displayplayer] && !(leveltime % (TICRATE/5)) && !splitscreen) if (netgame && player == &players[displayplayers[0]] && !(leveltime % (TICRATE/5)) && !splitscreen)
{ {
seenplayer = NULL; seenplayer = NULL;
@ -9064,7 +9067,9 @@ void P_PlayerThink(player_t *player)
|| player->kartstuff[k_driftboost] || player->kartstuff[k_sneakertimer] || player->kartstuff[k_startboost]) && !player->kartstuff[k_invincibilitytimer] // SRB2kart || player->kartstuff[k_driftboost] || player->kartstuff[k_sneakertimer] || player->kartstuff[k_startboost]) && !player->kartstuff[k_invincibilitytimer] // SRB2kart
&& (player->speed + abs(player->mo->momz)) > FixedMul(20*FRACUNIT,player->mo->scale)) && (player->speed + abs(player->mo->momz)) > FixedMul(20*FRACUNIT,player->mo->scale))
{ {
UINT8 i;
mobj_t *gmobj = P_SpawnGhostMobj(player->mo); mobj_t *gmobj = P_SpawnGhostMobj(player->mo);
gmobj->fuse = 2; gmobj->fuse = 2;
if (leveltime & 1) if (leveltime & 1)
{ {
@ -9072,15 +9077,17 @@ void P_PlayerThink(player_t *player)
gmobj->frame |= tr_trans70<<FF_TRANSSHIFT; gmobj->frame |= tr_trans70<<FF_TRANSSHIFT;
} }
// Hide the mobj from our sights if we're the displayplayer and chasecam is off, // Hide the mobj from our sights if we're the displayplayer and chasecam is off.
// or secondarydisplayplayer and chasecam2 is off.
// Why not just not spawn the mobj? Well, I'd rather only flirt with // Why not just not spawn the mobj? Well, I'd rather only flirt with
// consistency so much... // consistency so much...
if ((player == &players[displayplayer] && !camera.chase) for (i = 0; i <= splitscreen; i++)
|| (splitscreen && player == &players[secondarydisplayplayer] && !camera2.chase) {
|| (splitscreen > 1 && player == &players[thirddisplayplayer] && !camera3.chase) if (player == &players[displayplayers[i]] && !camera[i].chase)
|| (splitscreen > 2 && player == &players[fourthdisplayplayer] && !camera4.chase)) {
gmobj->flags2 |= MF2_DONTDRAW; gmobj->flags2 |= MF2_DONTDRAW;
break;
}
}
} }
#endif #endif
@ -9280,6 +9287,7 @@ void P_PlayerAfterThink(player_t *player)
ticcmd_t *cmd; ticcmd_t *cmd;
//INT32 oldweapon = player->currentweapon; // SRB2kart - unused //INT32 oldweapon = player->currentweapon; // SRB2kart - unused
camera_t *thiscam = NULL; // if not one of the displayed players, just don't bother camera_t *thiscam = NULL; // if not one of the displayed players, just don't bother
UINT8 i;
#ifdef PARANOIA #ifdef PARANOIA
if (!player->mo) if (!player->mo)
@ -9302,14 +9310,14 @@ void P_PlayerAfterThink(player_t *player)
P_PlayerInSpecialSector(player); P_PlayerInSpecialSector(player);
#endif #endif
if (splitscreen > 2 && player == &players[fourthdisplayplayer]) for (i = 0; i <= splitscreen; i++)
thiscam = &camera4; {
else if (splitscreen > 1 && player == &players[thirddisplayplayer]) if (player == &players[displayplayers[i]])
thiscam = &camera3; {
else if (splitscreen && player == &players[secondarydisplayplayer]) thiscam = &camera[i];
thiscam = &camera2; break;
else if (player == &players[displayplayer]) }
thiscam = &camera; }
if (player->playerstate == PST_DEAD) if (player->playerstate == PST_DEAD)
{ {
@ -9494,13 +9502,13 @@ void P_PlayerAfterThink(player_t *player)
player->mo->angle = player->mo->tracer->angle; player->mo->angle = player->mo->tracer->angle;
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localangle = player->mo->angle; localangle[0] = player->mo->angle;
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localangle2 = player->mo->angle; localangle[1] = player->mo->angle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localangle3 = player->mo->angle; localangle[2] = player->mo->angle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localangle4 = player->mo->angle; localangle[3] = player->mo->angle;
} }
if (P_AproxDistance(player->mo->x - player->mo->tracer->x, player->mo->y - player->mo->tracer->y) > player->mo->radius) if (P_AproxDistance(player->mo->x - player->mo->tracer->x, player->mo->y - player->mo->tracer->y) > player->mo->radius)
@ -9568,13 +9576,13 @@ void P_PlayerAfterThink(player_t *player)
player->mo->angle += cmd->sidemove<<ANGLETOFINESHIFT; // 2048 --> ANGLE_MAX player->mo->angle += cmd->sidemove<<ANGLETOFINESHIFT; // 2048 --> ANGLE_MAX
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
localangle = player->mo->angle; // Adjust the local control angle. localangle[0] = player->mo->angle; // Adjust the local control angle.
else if (player == &players[secondarydisplayplayer]) else if (player == &players[displayplayers[1]])
localangle2 = player->mo->angle; localangle[1] = player->mo->angle;
else if (player == &players[thirddisplayplayer]) else if (player == &players[displayplayers[2]])
localangle3 = player->mo->angle; localangle[2] = player->mo->angle;
else if (player == &players[fourthdisplayplayer]) else if (player == &players[displayplayers[3]])
localangle4 = player->mo->angle; localangle[3] = player->mo->angle;
} }
} }

View file

@ -252,20 +252,23 @@ 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;
if (splitscreen > 2 && viewplayer == &players[fourthdisplayplayer] && camera4.chase) for (i = 0; i <= splitscreen; i++)
heightsec = R_PointInSubsector(camera4.x, camera4.y)->sector->heightsec; {
else if (splitscreen > 1 && viewplayer == &players[thirddisplayplayer] && camera3.chase) if (viewplayer == &players[displayplayers[i]] && camera[i].chase)
heightsec = R_PointInSubsector(camera3.x, camera3.y)->sector->heightsec; {
else if (splitscreen && viewplayer == &players[secondarydisplayplayer] && camera2.chase) heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec;
heightsec = R_PointInSubsector(camera2.x, camera2.y)->sector->heightsec; break;
else if (camera.chase && viewplayer == &players[displayplayer]) }
heightsec = R_PointInSubsector(camera.x, camera.y)->sector->heightsec; }
else if (viewmobj)
if (i > 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;
underwater = heightsec != -1 && viewz <= sectors[heightsec].floorheight;
underwater = (heightsec != -1 && viewz <= sectors[heightsec].floorheight);
// Replace sector being drawn, with a copy to be hacked // Replace sector being drawn, with a copy to be hacked
*tempsec = *sec; *tempsec = *sec;
@ -827,7 +830,7 @@ static void R_AddPolyObjects(subsector_t *sub)
drawseg_t *firstseg; drawseg_t *firstseg;
static void R_Subsector(size_t num, UINT8 viewnumber) static void R_Subsector(size_t num)
{ {
INT32 count, floorlightlevel, ceilinglightlevel, light; INT32 count, floorlightlevel, ceilinglightlevel, light;
seg_t *line; seg_t *line;
@ -1149,7 +1152,7 @@ static void R_Subsector(size_t num, UINT8 viewnumber)
// Either you must pass the fake sector and handle validcount here, on the // Either you must pass the fake sector and handle validcount here, on the
// real sector, or you must account for the lighting in some other way, // real sector, or you must account for the lighting in some other way,
// like passing it as an argument. // like passing it as an argument.
R_AddSprites(sub->sector, (floorlightlevel+ceilinglightlevel)/2, viewnumber); R_AddSprites(sub->sector, (floorlightlevel+ceilinglightlevel)/2);
firstseg = NULL; firstseg = NULL;
@ -1355,7 +1358,7 @@ INT32 R_GetPlaneLight(sector_t *sector, fixed_t planeheight, boolean underside)
// //
// killough 5/2/98: reformatted, removed tail recursion // killough 5/2/98: reformatted, removed tail recursion
void R_RenderBSPNode(INT32 bspnum, UINT8 viewnumber) void R_RenderBSPNode(INT32 bspnum)
{ {
node_t *bsp; node_t *bsp;
INT32 side; INT32 side;
@ -1366,7 +1369,7 @@ void R_RenderBSPNode(INT32 bspnum, UINT8 viewnumber)
// Decide which side the view point is on. // Decide which side the view point is on.
side = R_PointOnSide(viewx, viewy, bsp); side = R_PointOnSide(viewx, viewy, bsp);
// Recursively divide front space. // Recursively divide front space.
R_RenderBSPNode(bsp->children[side], viewnumber); R_RenderBSPNode(bsp->children[side]);
// Possibly divide back space. // Possibly divide back space.
@ -1384,5 +1387,5 @@ void R_RenderBSPNode(INT32 bspnum, UINT8 viewnumber)
portalcullsector = NULL; portalcullsector = NULL;
} }
R_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR, viewnumber); R_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR);
} }

View file

@ -37,7 +37,7 @@ extern INT32 doorclosed;
void R_ClearClipSegs(void); void R_ClearClipSegs(void);
void R_PortalClearClipSegs(INT32 start, INT32 end); void R_PortalClearClipSegs(INT32 start, INT32 end);
void R_ClearDrawSegs(void); void R_ClearDrawSegs(void);
void R_RenderBSPNode(INT32 bspnum, UINT8 viewnumber); void R_RenderBSPNode(INT32 bspnum);
void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2); void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2);
#ifdef POLYOBJECTS #ifdef POLYOBJECTS

View file

@ -65,9 +65,10 @@ size_t loopcount;
fixed_t viewx, viewy, viewz; fixed_t viewx, viewy, viewz;
angle_t viewangle, aimingangle; angle_t viewangle, aimingangle;
UINT8 viewnumber;
fixed_t viewcos, viewsin; fixed_t viewcos, viewsin;
boolean viewsky, skyVisible; boolean viewsky, skyVisible;
boolean skyVisible1, skyVisible2, skyVisible3, skyVisible4; // saved values of skyVisible for P1/P2/P3/P4, for splitscreen boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible for each splitscreen player
sector_t *viewsector; sector_t *viewsector;
player_t *viewplayer; player_t *viewplayer;
@ -195,17 +196,10 @@ void SplitScreen_OnChange(void)
if (!demo.playback && !botingame) if (!demo.playback && !botingame)
{ {
for (i = 1; i < 3; i++) for (i = 1; i < MAXSPLITSCREENPLAYERS; i++)
{ {
if (i > splitscreen) if (i > splitscreen)
{ CL_RemoveSplitscreenPlayer(displayplayers[i]);
if (i == 1)
CL_RemoveSplitscreenPlayer(secondarydisplayplayer);
else if (i == 2)
CL_RemoveSplitscreenPlayer(thirddisplayplayer);
else if (i == 3)
CL_RemoveSplitscreenPlayer(fourthdisplayplayer);
}
else else
CL_AddSplitscreenPlayer(); CL_AddSplitscreenPlayer();
} }
@ -215,22 +209,28 @@ void SplitScreen_OnChange(void)
} }
else else
{ {
secondarydisplayplayer = consoleplayer; for (i = 1; i < MAXSPLITSCREENPLAYERS; i++)
thirddisplayplayer = consoleplayer; displayplayers[i] = consoleplayer;
fourthdisplayplayer = consoleplayer;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && i != consoleplayer) if (playeringame[i] && i != consoleplayer)
{ {
if (secondarydisplayplayer == consoleplayer) UINT8 j;
secondarydisplayplayer = i; for (j = 1; j < MAXSPLITSCREENPLAYERS; j++)
else if (thirddisplayplayer == consoleplayer) {
thirddisplayplayer = i; if (displayplayers[j] == consoleplayer)
else if (fourthdisplayplayer == consoleplayer) {
fourthdisplayplayer = i; displayplayers[j] = i;
else
break; break;
} }
} }
if (j == MAXSPLITSCREENPLAYERS)
break;
}
}
}
} }
static void Fov_OnChange(void) static void Fov_OnChange(void)
{ {
@ -844,16 +844,20 @@ static void R_SetupFreelook(void)
void R_SkyboxFrame(player_t *player) void R_SkyboxFrame(player_t *player)
{ {
camera_t *thiscam; camera_t *thiscam = &camera[0];
UINT8 i;
if (splitscreen > 2 && player == &players[fourthdisplayplayer]) if (splitscreen)
thiscam = &camera4; {
else if (splitscreen > 1 && player == &players[thirddisplayplayer]) for (i = 1; i <= splitscreen; i++)
thiscam = &camera3; {
else if (splitscreen && player == &players[secondarydisplayplayer]) if (player == &players[i])
thiscam = &camera2; {
else thiscam = &camera[i];
thiscam = &camera; break;
}
}
}
// cut-away view stuff // cut-away view stuff
viewsky = true; viewsky = true;
@ -883,23 +887,20 @@ void R_SkyboxFrame(player_t *player)
{ {
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
{ {
viewangle = localangle; // WARNING: camera uses this viewangle = localangle[0]; // WARNING: camera uses this
aimingangle = localaiming; aimingangle = localaiming[0];
} }
else if (player == &players[secondarydisplayplayer]) else if (splitscreen)
{ {
viewangle = localangle2; for (i = 1; i <= splitscreen; i++)
aimingangle = localaiming2; {
if (player == &players[displayplayers[i]])
{
viewangle = localangle[i];
aimingangle = localaiming[i];
break;
} }
else if (player == &players[thirddisplayplayer])
{
viewangle = localangle3;
aimingangle = localaiming3;
} }
else if (player == &players[fourthdisplayplayer])
{
viewangle = localangle4;
aimingangle = localaiming4;
} }
} }
} }
@ -1078,24 +1079,24 @@ void R_SetupFrame(player_t *player, boolean skybox)
camera_t *thiscam; camera_t *thiscam;
boolean chasecam = false; boolean chasecam = false;
if (splitscreen > 2 && player == &players[fourthdisplayplayer]) if (splitscreen > 2 && player == &players[displayplayers[3]])
{ {
thiscam = &camera4; thiscam = &camera[3];
chasecam = (cv_chasecam4.value != 0); chasecam = (cv_chasecam4.value != 0);
} }
else if (splitscreen > 1 && player == &players[thirddisplayplayer]) else if (splitscreen > 1 && player == &players[displayplayers[2]])
{ {
thiscam = &camera3; thiscam = &camera[2];
chasecam = (cv_chasecam3.value != 0); chasecam = (cv_chasecam3.value != 0);
} }
else if (splitscreen && player == &players[secondarydisplayplayer]) else if (splitscreen && player == &players[displayplayers[1]])
{ {
thiscam = &camera2; thiscam = &camera[1];
chasecam = (cv_chasecam2.value != 0); chasecam = (cv_chasecam2.value != 0);
} }
else else
{ {
thiscam = &camera; thiscam = &camera[0];
chasecam = (cv_chasecam.value != 0); chasecam = (cv_chasecam.value != 0);
} }
@ -1145,23 +1146,20 @@ void R_SetupFrame(player_t *player, boolean skybox)
{ {
if (player == &players[consoleplayer]) if (player == &players[consoleplayer])
{ {
viewangle = localangle; // WARNING: camera uses this viewangle = localangle[0]; // WARNING: camera uses this
aimingangle = localaiming; aimingangle = localaiming[0];
} }
else if (player == &players[secondarydisplayplayer]) else if (splitscreen)
{ {
viewangle = localangle2; for (i = 1; i <= splitscreen; i++)
aimingangle = localaiming2; {
if (player == &players[displayplayers[i]])
{
viewangle = localangle[i];
aimingangle = localaiming[i];
break;
} }
else if (player == &players[thirddisplayplayer])
{
viewangle = localangle3;
aimingangle = localaiming3;
} }
else if (player == &players[fourthdisplayplayer])
{
viewangle = localangle4;
aimingangle = localaiming4;
} }
} }
} }
@ -1323,19 +1321,24 @@ void R_RenderPlayerView(player_t *player)
{ {
portal_pair *portal; portal_pair *portal;
const boolean skybox = (skyboxmo[0] && cv_skybox.value); const boolean skybox = (skyboxmo[0] && cv_skybox.value);
UINT8 viewnumber; UINT8 i;
if (player == &players[secondarydisplayplayer] && splitscreen) viewnumber = 0; // default
viewnumber = 1;
else if (player == &players[thirddisplayplayer] && splitscreen > 1) if (splitscreen)
viewnumber = 2; {
else if (player == &players[fourthdisplayplayer] && splitscreen > 2) for (i = 1; i <= splitscreen; i++)
viewnumber = 3; {
else if (player == &players[i])
viewnumber = 0; {
viewnumber = i;
break;
}
}
}
// if this is display player 1 // if this is display player 1
if (cv_homremoval.value && player == &players[displayplayer]) if (cv_homremoval.value && player == &players[displayplayers[0]])
{ {
if (cv_homremoval.value == 1) if (cv_homremoval.value == 1)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // No HOM effect! V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // No HOM effect!
@ -1343,7 +1346,7 @@ void R_RenderPlayerView(player_t *player)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 128+(timeinmap&15)); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 128+(timeinmap&15));
} }
// Draw over the fourth screen so you don't have to stare at a HOM :V // Draw over the fourth screen so you don't have to stare at a HOM :V
else if (splitscreen == 2 && player == &players[thirddisplayplayer]) else if (splitscreen == 2 && player == &players[displayplayers[2]])
#if 1 #if 1
{ {
// V_DrawPatchFill, but for the fourth screen only // V_DrawPatchFill, but for the fourth screen only
@ -1362,14 +1365,14 @@ void R_RenderPlayerView(player_t *player)
#endif #endif
// load previous saved value of skyVisible for the player // load previous saved value of skyVisible for the player
if (splitscreen > 2 && player == &players[fourthdisplayplayer]) for (i = 0; i <= splitscreen; i++)
skyVisible = skyVisible4; {
else if (splitscreen > 1 && player == &players[thirddisplayplayer]) if (player == &players[displayplayers[i]]
skyVisible = skyVisible3; {
else if (splitscreen && player == &players[secondarydisplayplayer]) skyVisible = skyVisiblePerPlayer[i];
skyVisible = skyVisible2; break;
else }
skyVisible = skyVisible1; }
portalrender = 0; portalrender = 0;
portal_base = portal_cap = NULL; portal_base = portal_cap = NULL;
@ -1386,7 +1389,7 @@ void R_RenderPlayerView(player_t *player)
R_ClearVisibleFloorSplats(); R_ClearVisibleFloorSplats();
#endif #endif
R_RenderBSPNode((INT32)numnodes - 1, viewnumber); R_RenderBSPNode((INT32)numnodes - 1);
R_ClipSprites(); R_ClipSprites();
R_DrawPlanes(); R_DrawPlanes();
#ifdef FLOORSPLATS #ifdef FLOORSPLATS
@ -1419,7 +1422,7 @@ void R_RenderPlayerView(player_t *player)
mytotal = 0; mytotal = 0;
ProfZeroTimer(); ProfZeroTimer();
#endif #endif
R_RenderBSPNode((INT32)numnodes - 1, viewnumber); R_RenderBSPNode((INT32)numnodes - 1);
R_ClipSprites(); R_ClipSprites();
#ifdef TIMING #ifdef TIMING
RDMSR(0x10, &mycount); RDMSR(0x10, &mycount);
@ -1444,7 +1447,7 @@ void R_RenderPlayerView(player_t *player)
validcount++; validcount++;
R_RenderBSPNode((INT32)numnodes - 1, viewnumber); R_RenderBSPNode((INT32)numnodes - 1);
R_ClipSprites(); R_ClipSprites();
//R_DrawPlanes(); //R_DrawPlanes();
//R_DrawMasked(); //R_DrawMasked();
@ -1470,16 +1473,16 @@ void R_RenderPlayerView(player_t *player)
// Check for new console commands. // Check for new console commands.
NetUpdate(); NetUpdate();
// save value to skyVisible1 or skyVisible2 // save value to skyVisiblePerPlayer
// this is so that P1 can't affect whether P2 can see a skybox or not, or vice versa // this is so that P1 can't affect whether P2 can see a skybox or not, or vice versa
if (splitscreen > 2 && player == &players[fourthdisplayplayer]) for (i = 0; i <= splitscreen; i++)
skyVisible4 = skyVisible; {
else if (splitscreen > 1 && player == &players[thirddisplayplayer]) if (player == &players[displayplayers[i]])
skyVisible3 = skyVisible; {
else if (splitscreen && player == &players[secondarydisplayplayer]) skyVisiblePerPlayer[i] = skyVisible;
skyVisible2 = skyVisible; break;
else }
skyVisible1 = skyVisible; }
} }
// ========================================================================= // =========================================================================

View file

@ -883,12 +883,12 @@ void R_DrawSinglePlane(visplane_t *pl)
if (bottom > vid.height) if (bottom > vid.height)
bottom = vid.height; bottom = vid.height;
if (splitscreen > 2 && viewplayer == &players[fourthdisplayplayer]) // Only copy the part of the screen we need if (splitscreen > 2 && viewplayer == &players[displayplayers[3]]) // Only copy the part of the screen we need
scr = (screens[0] + (top+(viewheight))*vid.width + viewwidth); scr = (screens[0] + (top+(viewheight))*vid.width + viewwidth);
else if ((splitscreen == 1 && viewplayer == &players[secondarydisplayplayer]) else if ((splitscreen == 1 && viewplayer == &players[displayplayers[1]])
|| (splitscreen > 1 && viewplayer == &players[thirddisplayplayer])) || (splitscreen > 1 && viewplayer == &players[displayplayers[2]]))
scr = (screens[0] + (top+(viewheight))*vid.width); scr = (screens[0] + (top+(viewheight))*vid.width);
else if (splitscreen > 1 && viewplayer == &players[secondarydisplayplayer]) else if (splitscreen > 1 && viewplayer == &players[displayplayers[1]])
scr = (screens[0] + ((top)*vid.width) + viewwidth); scr = (screens[0] + ((top)*vid.width) + viewwidth);
else else
scr = (screens[0] + ((top)*vid.width)); scr = (screens[0] + ((top)*vid.width));

View file

@ -88,8 +88,9 @@ extern side_t *sides;
// //
extern fixed_t viewx, viewy, viewz; extern fixed_t viewx, viewy, viewz;
extern angle_t viewangle, aimingangle; extern angle_t viewangle, aimingangle;
extern UINT8 viewnumber; // splitscreen view number
extern boolean viewsky, skyVisible; extern boolean viewsky, skyVisible;
extern boolean skyVisible1, skyVisible2, skyVisible3, skyVisible4; // saved values of skyVisible for P1 and P2, for splitscreen extern boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible of each splitscreen player
extern sector_t *viewsector; extern sector_t *viewsector;
extern player_t *viewplayer; extern player_t *viewplayer;
extern UINT8 portalrender; extern UINT8 portalrender;

View file

@ -1702,7 +1702,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
// R_AddSprites // R_AddSprites
// During BSP traversal, this adds sprites by sector. // During BSP traversal, this adds sprites by sector.
// //
void R_AddSprites(sector_t *sec, INT32 lightlevel, UINT8 viewnumber) void R_AddSprites(sector_t *sec, INT32 lightlevel)
{ {
mobj_t *thing; mobj_t *thing;
precipmobj_t *precipthing; // Tails 08-25-2002 precipmobj_t *precipthing; // Tails 08-25-2002
@ -2664,11 +2664,11 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
{ {
if (playernum == consoleplayer) if (playernum == consoleplayer)
CV_StealthSetValue(&cv_playercolor, skin->prefcolor); CV_StealthSetValue(&cv_playercolor, skin->prefcolor);
else if (playernum == secondarydisplayplayer) else if (playernum == displayplayers[1])
CV_StealthSetValue(&cv_playercolor2, skin->prefcolor); CV_StealthSetValue(&cv_playercolor2, skin->prefcolor);
else if (playernum == thirddisplayplayer) else if (playernum == displayplayers[2])
CV_StealthSetValue(&cv_playercolor3, skin->prefcolor); CV_StealthSetValue(&cv_playercolor3, skin->prefcolor);
else if (playernum == fourthdisplayplayer) else if (playernum == displayplayers[3])
CV_StealthSetValue(&cv_playercolor4, skin->prefcolor); CV_StealthSetValue(&cv_playercolor4, skin->prefcolor);
player->skincolor = skin->prefcolor; player->skincolor = skin->prefcolor;
if (player->mo) if (player->mo)

View file

@ -55,7 +55,7 @@ void R_DelSpriteDefs(UINT16 wadnum);
#endif #endif
//SoM: 6/5/2000: Light sprites correctly! //SoM: 6/5/2000: Light sprites correctly!
void R_AddSprites(sector_t *sec, INT32 lightlevel, UINT8 viewnumber); void R_AddSprites(sector_t *sec, INT32 lightlevel);
void R_InitSprites(void); void R_InitSprites(void);
void R_ClearSprites(void); void R_ClearSprites(void);
void R_ClipSprites(void); void R_ClipSprites(void);

View file

@ -438,7 +438,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
listener_t listener3 = {0,0,0,0}; listener_t listener3 = {0,0,0,0};
listener_t listener4 = {0,0,0,0}; listener_t listener4 = {0,0,0,0};
mobj_t *listenmobj = players[displayplayer].mo; mobj_t *listenmobj = players[displayplayers[0]].mo;
mobj_t *listenmobj2 = NULL; mobj_t *listenmobj2 = NULL;
mobj_t *listenmobj3 = NULL; mobj_t *listenmobj3 = NULL;
mobj_t *listenmobj4 = NULL; mobj_t *listenmobj4 = NULL;
@ -450,26 +450,26 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
if (sfx_id == sfx_None) if (sfx_id == sfx_None)
return; return;
if (players[displayplayer].awayviewtics) if (players[displayplayers[0]].awayviewtics)
listenmobj = players[displayplayer].awayviewmobj; listenmobj = players[displayplayers[0]].awayviewmobj;
if (splitscreen) if (splitscreen)
{ {
listenmobj2 = players[secondarydisplayplayer].mo; listenmobj2 = players[displayplayers[1]].mo;
if (players[secondarydisplayplayer].awayviewtics) if (players[displayplayers[1]].awayviewtics)
listenmobj2 = players[secondarydisplayplayer].awayviewmobj; listenmobj2 = players[displayplayers[1]].awayviewmobj;
if (splitscreen > 1) if (splitscreen > 1)
{ {
listenmobj3 = players[thirddisplayplayer].mo; listenmobj3 = players[displayplayers[2]].mo;
if (players[thirddisplayplayer].awayviewtics) if (players[displayplayers[2]].awayviewtics)
listenmobj3 = players[thirddisplayplayer].awayviewmobj; listenmobj3 = players[displayplayers[2]].awayviewmobj;
if (splitscreen > 2) if (splitscreen > 2)
{ {
listenmobj4 = players[fourthdisplayplayer].mo; listenmobj4 = players[displayplayers[3]].mo;
if (players[fourthdisplayplayer].awayviewtics) if (players[displayplayers[3]].awayviewtics)
listenmobj4 = players[fourthdisplayplayer].awayviewmobj; listenmobj4 = players[displayplayers[3]].awayviewmobj;
} }
} }
} }
@ -482,12 +482,12 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
}; };
#endif #endif
if (camera.chase && !players[displayplayer].awayviewtics) if (camera[0].chase && !players[displayplayers[0]].awayviewtics)
{ {
listener.x = camera.x; listener.x = camera[0].x;
listener.y = camera.y; listener.y = camera[0].y;
listener.z = camera.z; listener.z = camera[0].z;
listener.angle = camera.angle; listener.angle = camera[0].angle;
} }
else if (listenmobj) else if (listenmobj)
{ {
@ -501,12 +501,12 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
if (listenmobj2) if (listenmobj2)
{ {
if (camera2.chase && !players[secondarydisplayplayer].awayviewtics) if (camera[1].chase && !players[displayplayers[1]].awayviewtics)
{ {
listener2.x = camera2.x; listener2.x = camera[1].x;
listener2.y = camera2.y; listener2.y = camera[1].y;
listener2.z = camera2.z; listener2.z = camera[1].z;
listener2.angle = camera2.angle; listener2.angle = camera[1].angle;
} }
else else
{ {
@ -519,12 +519,12 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
if (listenmobj3) if (listenmobj3)
{ {
if (camera3.chase && !players[thirddisplayplayer].awayviewtics) if (camera[2].chase && !players[displayplayers[2]].awayviewtics)
{ {
listener3.x = camera3.x; listener3.x = camera[2].x;
listener3.y = camera3.y; listener3.y = camera[2].y;
listener3.z = camera3.z; listener3.z = camera[2].z;
listener3.angle = camera3.angle; listener3.angle = camera[2].angle;
} }
else else
{ {
@ -537,12 +537,12 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
if (listenmobj4) if (listenmobj4)
{ {
if (camera4.chase && !players[fourthdisplayplayer].awayviewtics) if (camera[3].chase && !players[displayplayers[3]].awayviewtics)
{ {
listener4.x = camera4.x; listener4.x = camera[3].x;
listener4.y = camera4.y; listener4.y = camera[3].y;
listener4.z = camera4.z; listener4.z = camera[3].z;
listener4.angle = camera4.angle; listener4.angle = camera[3].angle;
} }
else else
{ {
@ -899,7 +899,7 @@ void S_UpdateSounds(void)
listener_t listener3; listener_t listener3;
listener_t listener4; listener_t listener4;
mobj_t *listenmobj = players[displayplayer].mo; mobj_t *listenmobj = players[displayplayers[0]].mo;
mobj_t *listenmobj2 = NULL; mobj_t *listenmobj2 = NULL;
mobj_t *listenmobj3 = NULL; mobj_t *listenmobj3 = NULL;
mobj_t *listenmobj4 = NULL; mobj_t *listenmobj4 = NULL;
@ -940,31 +940,31 @@ void S_UpdateSounds(void)
if (splitscreen) if (splitscreen)
{ {
listenmobj2 = players[secondarydisplayplayer].mo; listenmobj2 = players[displayplayers[1]].mo;
if (players[secondarydisplayplayer].awayviewtics) if (players[displayplayers[1]].awayviewtics)
listenmobj2 = players[secondarydisplayplayer].awayviewmobj; listenmobj2 = players[displayplayers[1]].awayviewmobj;
if (splitscreen > 1) if (splitscreen > 1)
{ {
listenmobj3 = players[thirddisplayplayer].mo; listenmobj3 = players[displayplayers[2]].mo;
if (players[thirddisplayplayer].awayviewtics) if (players[displayplayers[2]].awayviewtics)
listenmobj3 = players[thirddisplayplayer].awayviewmobj; listenmobj3 = players[displayplayers[2]].awayviewmobj;
if (splitscreen > 2) if (splitscreen > 2)
{ {
listenmobj4 = players[fourthdisplayplayer].mo; listenmobj4 = players[displayplayers[3]].mo;
if (players[fourthdisplayplayer].awayviewtics) if (players[displayplayers[3]].awayviewtics)
listenmobj4 = players[fourthdisplayplayer].awayviewmobj; listenmobj4 = players[displayplayers[3]].awayviewmobj;
} }
} }
} }
if (camera.chase && !players[displayplayer].awayviewtics) if (camera[0].chase && !players[displayplayers[0]].awayviewtics)
{ {
listener.x = camera.x; listener.x = camera[0].x;
listener.y = camera.y; listener.y = camera[0].y;
listener.z = camera.z; listener.z = camera[0].z;
listener.angle = camera.angle; listener.angle = camera[0].angle;
} }
else if (listenmobj) else if (listenmobj)
{ {
@ -989,12 +989,12 @@ void S_UpdateSounds(void)
if (listenmobj2) if (listenmobj2)
{ {
if (camera2.chase && !players[secondarydisplayplayer].awayviewtics) if (camera[1].chase && !players[displayplayers[1]].awayviewtics)
{ {
listener2.x = camera2.x; listener2.x = camera[1].x;
listener2.y = camera2.y; listener2.y = camera[1].y;
listener2.z = camera2.z; listener2.z = camera[1].z;
listener2.angle = camera2.angle; listener2.angle = camera[1].angle;
} }
else else
{ {
@ -1007,12 +1007,12 @@ void S_UpdateSounds(void)
if (listenmobj3) if (listenmobj3)
{ {
if (camera3.chase && !players[thirddisplayplayer].awayviewtics) if (camera[2].chase && !players[displayplayers[2]].awayviewtics)
{ {
listener3.x = camera3.x; listener3.x = camera[2].x;
listener3.y = camera3.y; listener3.y = camera[2].y;
listener3.z = camera3.z; listener3.z = camera[2].z;
listener3.angle = camera3.angle; listener3.angle = camera[2].angle;
} }
else else
{ {
@ -1025,12 +1025,12 @@ void S_UpdateSounds(void)
if (listenmobj4) if (listenmobj4)
{ {
if (camera4.chase && !players[fourthdisplayplayer].awayviewtics) if (camera[3].chase && !players[displayplayers[3]].awayviewtics)
{ {
listener4.x = camera4.x; listener4.x = camera[3].x;
listener4.y = camera4.y; listener4.y = camera[3].y;
listener4.z = camera4.z; listener4.z = camera[3].z;
listener4.angle = camera4.angle; listener4.angle = camera[3].angle;
} }
else else
{ {
@ -1060,9 +1060,9 @@ void S_UpdateSounds(void)
// check non-local sounds for distance clipping // check non-local sounds for distance clipping
// or modify their params // or modify their params
if (c->origin && ((c->origin != players[consoleplayer].mo) if (c->origin && ((c->origin != players[consoleplayer].mo)
|| (splitscreen && c->origin != players[secondarydisplayplayer].mo) || (splitscreen && c->origin != players[displayplayers[1]].mo)
|| (splitscreen > 1 && c->origin != players[thirddisplayplayer].mo) || (splitscreen > 1 && c->origin != players[displayplayers[2]].mo)
|| (splitscreen > 2 && c->origin != players[fourthdisplayplayer].mo))) || (splitscreen > 2 && c->origin != players[displayplayers[3]].mo)))
{ {
// Whomever is closer gets the sound, but only in splitscreen. // Whomever is closer gets the sound, but only in splitscreen.
if (splitscreen) if (splitscreen)
@ -1071,13 +1071,10 @@ void S_UpdateSounds(void)
fixed_t recdist = -1; fixed_t recdist = -1;
INT32 i, p = -1; INT32 i, p = -1;
for (i = 0; i < 4; i++) for (i = 0; i <= splitscreen; i++)
{ {
fixed_t thisdist = -1; fixed_t thisdist = -1;
if (i > splitscreen)
break;
if (i == 0 && listenmobj) if (i == 0 && listenmobj)
thisdist = P_AproxDistance(listener.x-soundmobj->x, listener.y-soundmobj->y); thisdist = P_AproxDistance(listener.x-soundmobj->x, listener.y-soundmobj->y);
else if (i == 1 && listenmobj2) else if (i == 1 && listenmobj2)
@ -1250,33 +1247,33 @@ INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *v
if (!listener) if (!listener)
return false; return false;
if (listener == players[displayplayer].mo && camera.chase) if (listener == players[displayplayers[0]].mo && camera[0].chase)
{ {
listensource.x = camera.x; listensource.x = camera[0].x;
listensource.y = camera.y; listensource.y = camera[0].y;
listensource.z = camera.z; listensource.z = camera[0].z;
listensource.angle = camera.angle; listensource.angle = camera[0].angle;
} }
else if (splitscreen && listener == players[secondarydisplayplayer].mo && camera2.chase) else if (splitscreen && listener == players[displayplayers[1]].mo && camera[1].chase)
{ {
listensource.x = camera2.x; listensource.x = camera[1].x;
listensource.y = camera2.y; listensource.y = camera[1].y;
listensource.z = camera2.z; listensource.z = camera[1].z;
listensource.angle = camera2.angle; listensource.angle = camera[1].angle;
} }
else if (splitscreen > 1 && listener == players[thirddisplayplayer].mo && camera3.chase) else if (splitscreen > 1 && listener == players[displayplayers[2]].mo && camera[2].chase)
{ {
listensource.x = camera3.x; listensource.x = camera[2].x;
listensource.y = camera3.y; listensource.y = camera[2].y;
listensource.z = camera3.z; listensource.z = camera[2].z;
listensource.angle = camera3.angle; listensource.angle = camera[2].angle;
} }
else if (splitscreen > 2 && listener == players[fourthdisplayplayer].mo && camera4.chase) else if (splitscreen > 2 && listener == players[displayplayers[3]].mo && camera[3].chase)
{ {
listensource.x = camera4.x; listensource.x = camera[3].x;
listensource.y = camera4.y; listensource.y = camera[3].y;
listensource.z = camera4.z; listensource.z = camera[3].z;
listensource.angle = camera4.angle; listensource.angle = camera[3].angle;
} }
else else
{ {

View file

@ -372,7 +372,7 @@ static inline void ST_InitData(void)
// 'link' the statusbar display to a player, which could be // 'link' the statusbar display to a player, which could be
// another player than consoleplayer, for example, when you // another player than consoleplayer, for example, when you
// change the view in a multiplayer demo with F12. // change the view in a multiplayer demo with F12.
stplyr = &players[displayplayer]; stplyr = &players[displayplayers[0]];
st_palette = -1; st_palette = -1;
} }
@ -442,7 +442,7 @@ static INT32 SCY(INT32 y)
if (splitscreen) if (splitscreen)
{ {
y >>= 1; y >>= 1;
if (stplyr != &players[displayplayer]) if (stplyr != &players[displayplayers[0]])
y += vid.height / 2; y += vid.height / 2;
} }
return y; return y;
@ -458,7 +458,7 @@ static INT32 STRINGY(INT32 y)
if (splitscreen) if (splitscreen)
{ {
y >>= 1; y >>= 1;
if (stplyr != &players[displayplayer]) if (stplyr != &players[displayplayers[0]])
y += BASEVIDHEIGHT / 2; y += BASEVIDHEIGHT / 2;
} }
return y; return y;
@ -471,7 +471,7 @@ static INT32 SPLITFLAGS(INT32 f)
// Pass this V_SNAPTO(TOP|BOTTOM) and it'll trim them to account for splitscreen! -Red // Pass this V_SNAPTO(TOP|BOTTOM) and it'll trim them to account for splitscreen! -Red
if (splitscreen) if (splitscreen)
{ {
if (stplyr != &players[displayplayer]) if (stplyr != &players[displayplayers[0]])
f &= ~V_SNAPTOTOP; f &= ~V_SNAPTOTOP;
else else
f &= ~V_SNAPTOBOTTOM; f &= ~V_SNAPTOBOTTOM;
@ -498,7 +498,7 @@ static INT32 SCR(INT32 r)
if (splitscreen) if (splitscreen)
{ {
y >>= 1; y >>= 1;
if (stplyr != &players[displayplayer]) if (stplyr != &players[displayplayers[0]])
y += vid.height / 2; y += vid.height / 2;
} }
return FixedInt(FixedDiv(y, vid.fdupy)); return FixedInt(FixedDiv(y, vid.fdupy));
@ -701,7 +701,7 @@ static inline void ST_drawRings(void) // SRB2kart - unused.
/* /*
static void ST_drawLives(void) // SRB2kart - unused. static void ST_drawLives(void) // SRB2kart - unused.
{ {
const INT32 v_splitflag = (splitscreen && stplyr == &players[displayplayer] ? V_SPLITSCREEN : 0); const INT32 v_splitflag = (splitscreen && stplyr == &players[displayplayers[0]] ? V_SPLITSCREEN : 0);
if (!stplyr->skincolor) if (!stplyr->skincolor)
return; // Just joined a server, skin isn't loaded yet! return; // Just joined a server, skin isn't loaded yet!
@ -1019,7 +1019,7 @@ static void ST_drawNiGHTSHUD(void) // SRB2kart - unused.
if (G_IsSpecialStage(gamemap)) if (G_IsSpecialStage(gamemap))
{ // Since special stages share score, time, rings, etc. { // Since special stages share score, time, rings, etc.
// disable splitscreen mode for its HUD. // disable splitscreen mode for its HUD.
if (stplyr != &players[displayplayer]) if (stplyr != &players[displayplayers[0]])
return; return;
nosshack = splitscreen; nosshack = splitscreen;
splitscreen = 0; splitscreen = 0;
@ -1124,7 +1124,7 @@ static void ST_drawNiGHTSHUD(void) // SRB2kart - unused.
V_DrawScaledPatch(locx, STRINGY(locy)-3, V_HUDTRANS, drillbar); V_DrawScaledPatch(locx, STRINGY(locy)-3, V_HUDTRANS, drillbar);
for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill)
V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), V_HUDTRANS, drillfill[fillpatch]); V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), V_HUDTRANS, drillfill[fillpatch]);
stplyr = &players[secondarydisplayplayer]; stplyr = &players[displayplayers[1]];
if (stplyr->pflags & PF_DRILLING) if (stplyr->pflags & PF_DRILLING)
fillpatch = (stplyr->drillmeter & 1) + 1; fillpatch = (stplyr->drillmeter & 1) + 1;
else else
@ -1132,7 +1132,7 @@ static void ST_drawNiGHTSHUD(void) // SRB2kart - unused.
V_DrawScaledPatch(locx, STRINGY(locy-3), V_SNAPTOBOTTOM|V_HUDTRANS, drillbar); V_DrawScaledPatch(locx, STRINGY(locy-3), V_SNAPTOBOTTOM|V_HUDTRANS, drillbar);
for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill)
V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), V_SNAPTOBOTTOM|V_HUDTRANS, drillfill[fillpatch]); V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), V_SNAPTOBOTTOM|V_HUDTRANS, drillfill[fillpatch]);
stplyr = &players[displayplayer]; stplyr = &players[displayplayers[0]];
splitscreen = 0; splitscreen = 0;
} }
else else
@ -1881,7 +1881,7 @@ static void ST_overlayDrawer(void)
ST_drawTeamName(); ST_drawTeamName();
// Special Stage HUD // Special Stage HUD
if (!useNightsSS && G_IsSpecialStage(gamemap) && stplyr == &players[displayplayer]) if (!useNightsSS && G_IsSpecialStage(gamemap) && stplyr == &players[displayplayers[0]])
ST_drawSpecialStageHUD(); ST_drawSpecialStageHUD();
// Emerald Hunt Indicators // Emerald Hunt Indicators
@ -1919,7 +1919,7 @@ static void ST_overlayDrawer(void)
{ {
char name[MAXPLAYERNAME+12]; char name[MAXPLAYERNAME+12];
INT32 y = (stplyr == &players[displayplayer]) ? 4 : BASEVIDHEIGHT/2-12; INT32 y = (stplyr == &players[displayplayers[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_ALLOWLOWERCASE|K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOBOTTOM|V_SNAPTORIGHT), name); V_DrawRightAlignedThinString(BASEVIDWIDTH-40, y, V_HUDTRANSHALF|V_ALLOWLOWERCASE|K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOBOTTOM|V_SNAPTORIGHT), name);
} }
@ -1930,10 +1930,10 @@ static void ST_overlayDrawer(void)
} }
// This is where we draw all the fun cheese if you have the chasecam off! // This is where we draw all the fun cheese if you have the chasecam off!
/*if ((stplyr == &players[displayplayer] && !camera.chase) /*if ((stplyr == &players[displayplayers[0]] && !camera[0].chase)
|| ((splitscreen && stplyr == &players[secondarydisplayplayer]) && !camera2.chase) || ((splitscreen && stplyr == &players[displayplayers[1]]) && !camera[1].chase)
|| ((splitscreen > 1 && stplyr == &players[thirddisplayplayer]) && !camera3.chase) || ((splitscreen > 1 && stplyr == &players[displayplayers[2]]) && !camera[2].chase)
|| ((splitscreen > 2 && stplyr == &players[fourthdisplayplayer]) && !camera4.chase)) || ((splitscreen > 2 && stplyr == &players[displayplayers[3]]) && !camera[3].chase))
{ {
ST_drawFirstPersonHUD(); ST_drawFirstPersonHUD();
}*/ }*/
@ -2086,8 +2086,10 @@ static void ST_MayonakaStatic(void)
void ST_Drawer(void) void ST_Drawer(void)
{ {
UINT8 i;
#ifdef SEENAMES #ifdef SEENAMES
if (cv_seenames.value && cv_allowseenames.value && displayplayer == consoleplayer && seenplayer && seenplayer->mo && !mapreset) if (cv_seenames.value && cv_allowseenames.value && displayplayers[0] == consoleplayer && seenplayer && seenplayer->mo && !mapreset)
{ {
if (cv_seenames.value == 1) if (cv_seenames.value == 1)
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, player_names[seenplayer-players]); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, player_names[seenplayer-players]);
@ -2121,26 +2123,12 @@ void ST_Drawer(void)
if (st_overlay) if (st_overlay)
{ {
// No deadview! // No deadview!
stplyr = &players[displayplayer]; for (i = 0; i <= splitscreen; i++)
ST_overlayDrawer();
if (splitscreen)
{ {
stplyr = &players[secondarydisplayplayer]; stplyr = &players[displayplayers[i]];
ST_overlayDrawer();
if (splitscreen > 1)
{
stplyr = &players[thirddisplayplayer];
ST_overlayDrawer();
if (splitscreen > 2)
{
stplyr = &players[fourthdisplayplayer];
ST_overlayDrawer(); ST_overlayDrawer();
} }
}
}
// draw Midnight Channel's overlay ontop // draw Midnight Channel's overlay ontop
if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff. if (mapheaderinfo[gamemap-1]->typeoflevel & TOL_TV) // Very specific Midnight Channel stuff.
ST_MayonakaStatic(); ST_MayonakaStatic();

View file

@ -360,7 +360,7 @@ void Y_IntermissionDrawer(void)
V_DrawFadeScreen(0xFF00, 22); V_DrawFadeScreen(0xFF00, 22);
if (!splitscreen) if (!splitscreen)
whiteplayer = demo.playback ? displayplayer : consoleplayer; whiteplayer = demo.playback ? displayplayers[0] : consoleplayer;
if (cons_menuhighlight.value) if (cons_menuhighlight.value)
hilicol = cons_menuhighlight.value; hilicol = cons_menuhighlight.value;
@ -1051,19 +1051,19 @@ void Y_VoteDrawer(void)
{ {
case 1: case 1:
thiscurs = cursor2; thiscurs = cursor2;
p = secondarydisplayplayer; p = displayplayers[1];
break; break;
case 2: case 2:
thiscurs = cursor3; thiscurs = cursor3;
p = thirddisplayplayer; p = displayplayers[2];
break; break;
case 3: case 3:
thiscurs = cursor4; thiscurs = cursor4;
p = fourthdisplayplayer; p = displayplayers[3];
break; break;
default: default:
thiscurs = cursor1; thiscurs = cursor1;
p = displayplayer; p = displayplayers[0];
break; break;
} }
@ -1218,10 +1218,7 @@ static void Y_VoteStops(SINT8 pick, SINT8 level)
S_StartSound(NULL, sfx_noooo2); // gasp S_StartSound(NULL, sfx_noooo2); // gasp
else if (mapheaderinfo[nextmap] && (mapheaderinfo[nextmap]->menuflags & LF2_HIDEINMENU)) else if (mapheaderinfo[nextmap] && (mapheaderinfo[nextmap]->menuflags & LF2_HIDEINMENU))
S_StartSound(NULL, sfx_noooo1); // this is bad S_StartSound(NULL, sfx_noooo1); // this is bad
else if (netgame && (pick == consoleplayer else if (netgame && P_IsLocalPlayer(&players[pick]))
|| pick == secondarydisplayplayer
|| pick == thirddisplayplayer
|| pick == fourthdisplayplayer))
S_StartSound(NULL, sfx_yeeeah); // yeeeah! S_StartSound(NULL, sfx_yeeeah); // yeeeah!
else else
S_StartSound(NULL, sfx_kc48); // just a cool sound S_StartSound(NULL, sfx_kc48); // just a cool sound
@ -1354,13 +1351,13 @@ void Y_VoteTicker(void)
switch (i) switch (i)
{ {
case 1: case 1:
p = secondarydisplayplayer; p = displayplayers[1];
break; break;
case 2: case 2:
p = thirddisplayplayer; p = displayplayers[2];
break; break;
case 3: case 3:
p = fourthdisplayplayer; p = displayplayers[3];
break; break;
default: default:
p = consoleplayer; p = consoleplayer;