From f164320c8817ae96c48ba149a2b01368c5cff49d Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Feb 2020 21:46:55 -0800 Subject: [PATCH 01/36] Make the order of displayplayers irrelevant and split splitscreen into splitscreen and r_splitscreen --- src/d_clisrv.c | 8 ++- src/d_main.c | 7 +- src/d_netcmd.c | 140 +++++++++++++++++++-------------------- src/doomstat.h | 3 + src/g_game.c | 69 +++++++++---------- src/hu_stuff.c | 26 ++++---- src/k_kart.c | 154 +++++++++++++++++++++---------------------- src/lua_consolelib.c | 2 +- src/lua_hudlib.c | 16 ++--- src/m_menu.c | 32 ++++----- src/m_misc.c | 10 +-- src/p_enemy.c | 2 +- src/p_floor.c | 16 ++--- src/p_inter.c | 12 ++-- src/p_map.c | 4 +- src/p_mobj.c | 50 +++++++------- src/p_setup.c | 30 ++++----- src/p_spec.c | 2 +- src/p_telept.c | 12 ++-- src/p_tick.c | 6 +- src/p_user.c | 30 ++++----- src/r_bsp.c | 4 +- src/r_draw.c | 2 +- src/r_main.c | 38 ++++++----- src/r_plane.c | 8 +-- src/r_sky.c | 2 +- src/r_things.c | 12 ++-- src/s_sound.c | 50 +++++++------- src/st_stuff.c | 22 +++---- src/v_video.c | 6 +- src/y_inter.c | 16 ++--- 31 files changed, 404 insertions(+), 387 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1dacabd9f..a53a61cf0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2718,8 +2718,8 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) RemoveAdminPlayer(playernum); // don't stay admin after you're gone } - if (playernum == displayplayers[0] && !demo.playback) - displayplayers[0] = consoleplayer; // don't look through someone's view who isn't there + if (playernum == displayplayers[localdisplayplayers[0]] && !demo.playback) + displayplayers[localdisplayplayers[0]] = consoleplayer; // don't look through someone's view who isn't there #ifdef HAVE_BLUA LUA_InvalidatePlayer(&players[playernum]); @@ -3503,7 +3503,10 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) { consoleplayer = newplayernum; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { displayplayers[i] = newplayernum; + localdisplayplayers[i] = i; + } DEBFILE("spawning me\n"); } @@ -3705,6 +3708,7 @@ void SV_StopServer(void) D_Clearticcmd(i); consoleplayer = 0; + localdisplayplayers[0] = 0; cl_mode = CL_SEARCHING; maketic = gametic+1; neededtic = maketic; diff --git a/src/d_main.c b/src/d_main.c index dee752107..e0ba654ad 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -416,7 +416,7 @@ static void D_Display(void) // draw the view directly if (cv_renderview.value && !automapactive) { - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (players[displayplayers[i]].mo || players[displayplayers[i]].playerstate == PST_DEAD) { @@ -443,7 +443,7 @@ static void D_Display(void) switch (i) { case 1: - if (splitscreen > 1) + if (r_splitscreen > 1) { viewwindowx = viewwidth; viewwindowy = 0; @@ -482,7 +482,7 @@ static void D_Display(void) if (rendermode == render_soft) { - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (postimgtype[i]) V_DoPostProcessor(i, postimgtype[i], postimgparam[i]); @@ -780,6 +780,7 @@ void D_StartTitle(void) gameaction = ga_nothing; memset(displayplayers, 0, sizeof(displayplayers)); + memset(localdisplayplayers, 0, sizeof localdisplayplayers); consoleplayer = 0; //demosequence = -1; gametype = GT_RACE; // SRB2kart diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 70dff2fcf..334509389 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1180,11 +1180,11 @@ static void CleanupPlayerName(INT32 playernum, const char *newname) // spaces may have been removed if (playernum == consoleplayer) CV_StealthSet(&cv_playername, tmpname); - else if (playernum == displayplayers[1] || (!netgame && playernum == 1)) + else if (playernum == displayplayers[localdisplayplayers[1]] || (!netgame && playernum == 1)) CV_StealthSet(&cv_playername2, tmpname); - else if (playernum == displayplayers[2] || (!netgame && playernum == 2)) + else if (playernum == displayplayers[localdisplayplayers[2]] || (!netgame && playernum == 2)) CV_StealthSet(&cv_playername3, tmpname); - else if (playernum == displayplayers[3] || (!netgame && playernum == 3)) + else if (playernum == displayplayers[localdisplayplayers[3]] || (!netgame && playernum == 3)) CV_StealthSet(&cv_playername4, tmpname); else I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); @@ -1292,11 +1292,11 @@ static void ForceAllSkins(INT32 forcedskin) { if (i == consoleplayer) CV_StealthSet(&cv_skin, skins[forcedskin].name); - else if (i == displayplayers[1]) + else if (i == displayplayers[localdisplayplayers[1]]) CV_StealthSet(&cv_skin2, skins[forcedskin].name); - else if (i == displayplayers[2]) + else if (i == displayplayers[localdisplayplayers[2]]) CV_StealthSet(&cv_skin3, skins[forcedskin].name); - else if (i == displayplayers[3]) + else if (i == displayplayers[localdisplayplayers[3]]) CV_StealthSet(&cv_skin4, skins[forcedskin].name); } } @@ -1431,8 +1431,8 @@ static void SendNameAndColor2(void) if (splitscreen < 1 && !botingame) return; // can happen if skin2/color2/name2 changed - if (displayplayers[1] != consoleplayer) - secondplaya = displayplayers[1]; + if (displayplayers[localdisplayplayers[1]] != consoleplayer) + secondplaya = displayplayers[localdisplayplayers[1]]; else if (!netgame) // HACK secondplaya = 1; @@ -1520,14 +1520,14 @@ static void SendNameAndColor2(void) snac2pending++; // Don't change name if muted - if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1]))) - CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]); + if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[localdisplayplayers[1]]))) + CV_StealthSet(&cv_playername2, player_names[displayplayers[localdisplayplayers[1]]]); else // Cleanup name if changing it - CleanupPlayerName(displayplayers[1], cv_playername2.zstring); + CleanupPlayerName(displayplayers[localdisplayplayers[1]], cv_playername2.zstring); // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(displayplayers[1])) - CV_StealthSet(&cv_skin2, skins[players[displayplayers[1]].skin].name); + if (!CanChangeSkin(displayplayers[localdisplayplayers[1]])) + CV_StealthSet(&cv_skin2, skins[players[displayplayers[localdisplayplayers[1]]].skin].name); // check if player has the skin loaded (cv_skin2 may have // the name of a skin that was available in the previous game) @@ -1554,8 +1554,8 @@ static void SendNameAndColor3(void) if (splitscreen < 2) return; // can happen if skin3/color3/name3 changed - if (displayplayers[2] != consoleplayer) - thirdplaya = displayplayers[2]; + if (displayplayers[localdisplayplayers[2]] != consoleplayer) + thirdplaya = displayplayers[localdisplayplayers[2]]; else if (!netgame) // HACK thirdplaya = 2; @@ -1635,14 +1635,14 @@ static void SendNameAndColor3(void) snac3pending++; // Don't change name if muted - if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2]))) - CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]); + if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[localdisplayplayers[2]]))) + CV_StealthSet(&cv_playername3, player_names[displayplayers[localdisplayplayers[2]]]); else // Cleanup name if changing it - CleanupPlayerName(displayplayers[2], cv_playername3.zstring); + CleanupPlayerName(displayplayers[localdisplayplayers[2]], cv_playername3.zstring); // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(displayplayers[2])) - CV_StealthSet(&cv_skin3, skins[players[displayplayers[2]].skin].name); + if (!CanChangeSkin(displayplayers[localdisplayplayers[2]])) + CV_StealthSet(&cv_skin3, skins[players[displayplayers[localdisplayplayers[2]]].skin].name); // check if player has the skin loaded (cv_skin3 may have // the name of a skin that was available in the previous game) @@ -1669,8 +1669,8 @@ static void SendNameAndColor4(void) if (splitscreen < 3) return; // can happen if skin4/color4/name4 changed - if (displayplayers[3] != consoleplayer) - fourthplaya = displayplayers[3]; + if (displayplayers[localdisplayplayers[3]] != consoleplayer) + fourthplaya = displayplayers[localdisplayplayers[3]]; else if (!netgame) // HACK fourthplaya = 3; @@ -1758,14 +1758,14 @@ static void SendNameAndColor4(void) snac4pending++; // Don't change name if muted - if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3]))) - CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]); + if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[localdisplayplayers[3]]))) + CV_StealthSet(&cv_playername4, player_names[displayplayers[localdisplayplayers[3]]]); else // Cleanup name if changing it - CleanupPlayerName(displayplayers[3], cv_playername4.zstring); + CleanupPlayerName(displayplayers[localdisplayplayers[3]], cv_playername4.zstring); // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(displayplayers[3])) - CV_StealthSet(&cv_skin4, skins[players[displayplayers[3]].skin].name); + if (!CanChangeSkin(displayplayers[localdisplayplayers[3]])) + CV_StealthSet(&cv_skin4, skins[players[displayplayers[localdisplayplayers[3]]].skin].name); // check if player has the skin loaded (cv_skin4 may have // the name of a skin that was available in the previous game) @@ -1796,11 +1796,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) if (playernum == consoleplayer) snacpending--; // TODO: make snacpending an array instead of 4 separate vars? - else if (playernum == displayplayers[1]) + else if (playernum == displayplayers[localdisplayplayers[1]]) snac2pending--; - else if (playernum == displayplayers[2]) + else if (playernum == displayplayers[localdisplayplayers[2]]) snac3pending--; - else if (playernum == displayplayers[3]) + else if (playernum == displayplayers[localdisplayplayers[3]]) snac4pending--; #ifdef PARANOIA @@ -1823,8 +1823,8 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) demo_extradata[playernum] |= DXD_COLOR; // normal player colors - if (server && (p != &players[consoleplayer] && p != &players[displayplayers[1]] - && p != &players[displayplayers[2]] && p != &players[displayplayers[3]])) + if (server && (p != &players[consoleplayer] && p != &players[displayplayers[localdisplayplayers[1]]] + && p != &players[displayplayers[localdisplayplayers[2]]] && p != &players[displayplayers[localdisplayplayers[3]]])) { boolean kick = false; @@ -1861,11 +1861,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) if (playernum == consoleplayer) CV_StealthSet(&cv_skin, skins[forcedskin].name); - else if (playernum == displayplayers[1]) + else if (playernum == displayplayers[localdisplayplayers[1]]) CV_StealthSet(&cv_skin2, skins[forcedskin].name); - else if (playernum == displayplayers[2]) + else if (playernum == displayplayers[localdisplayplayers[2]]) CV_StealthSet(&cv_skin3, skins[forcedskin].name); - else if (playernum == displayplayers[3]) + else if (playernum == displayplayers[localdisplayplayers[3]]) CV_StealthSet(&cv_skin4, skins[forcedskin].name); } else @@ -1988,7 +1988,7 @@ void D_SendPlayerConfig(void) // Only works for displayplayer, sorry! static void Command_ResetCamera_f(void) { - P_ResetCamera(&players[displayplayers[0]], &camera[0]); + P_ResetCamera(&players[displayplayers[localdisplayplayers[0]]], &camera[0]); } /* Consider replacing nametonum with this */ @@ -2144,7 +2144,7 @@ static void Command_View_f(void) } else/* print current view */ { - if (splitscreen < viewnum-1)/* We can't see those guys! */ + if (r_splitscreen < viewnum-1)/* We can't see those guys! */ return; PRINTVIEWPOINT ("Currently ",) } @@ -2169,7 +2169,7 @@ static void Command_SetViews_f(void) return; } - splits = splitscreen+1; + splits = r_splitscreen+1; newsplits = atoi(COM_Argv(1)); newsplits = min(max(newsplits, 1), 4); @@ -2177,7 +2177,7 @@ static void Command_SetViews_f(void) G_AdjustView(newsplits, 0, true); else { - splitscreen = newsplits-1; + r_splitscreen = newsplits-1; R_ExecuteSetViewSize(); } } @@ -2426,7 +2426,7 @@ void D_ModifyClientVote(SINT8 voted, UINT8 splitplayer) UINT8 player = consoleplayer; if (splitplayer > 0) - player = displayplayers[splitplayer]; + player = displayplayers[localdisplayplayers[splitplayer]]; WRITESINT8(p, voted); WRITEUINT8(p, player); @@ -3078,11 +3078,11 @@ static void Command_Teamchange2_f(void) return; } - if (players[displayplayers[1]].spectator) - error = !(NetPacket.packet.newteam || (players[displayplayers[1]].pflags & PF_WANTSTOJOIN)); + if (players[displayplayers[localdisplayplayers[1]]].spectator) + error = !(NetPacket.packet.newteam || (players[displayplayers[localdisplayplayers[1]]].pflags & PF_WANTSTOJOIN)); else if (G_GametypeHasTeams()) - error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[1]].ctfteam); - else if (G_GametypeHasSpectators() && !players[displayplayers[1]].spectator) + error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[localdisplayplayers[1]]].ctfteam); + else if (G_GametypeHasSpectators() && !players[displayplayers[localdisplayplayers[1]]].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA else @@ -3169,11 +3169,11 @@ static void Command_Teamchange3_f(void) return; } - if (players[displayplayers[2]].spectator) - error = !(NetPacket.packet.newteam || (players[displayplayers[2]].pflags & PF_WANTSTOJOIN)); + if (players[displayplayers[localdisplayplayers[2]]].spectator) + error = !(NetPacket.packet.newteam || (players[displayplayers[localdisplayplayers[2]]].pflags & PF_WANTSTOJOIN)); else if (G_GametypeHasTeams()) - error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[2]].ctfteam); - else if (G_GametypeHasSpectators() && !players[displayplayers[2]].spectator) + error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[localdisplayplayers[2]]].ctfteam); + else if (G_GametypeHasSpectators() && !players[displayplayers[localdisplayplayers[2]]].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA else @@ -3260,11 +3260,11 @@ static void Command_Teamchange4_f(void) return; } - if (players[displayplayers[3]].spectator) - error = !(NetPacket.packet.newteam || (players[displayplayers[3]].pflags & PF_WANTSTOJOIN)); + if (players[displayplayers[localdisplayplayers[3]]].spectator) + error = !(NetPacket.packet.newteam || (players[displayplayers[localdisplayplayers[3]]].pflags & PF_WANTSTOJOIN)); else if (G_GametypeHasTeams()) - error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[3]].ctfteam); - else if (G_GametypeHasSpectators() && !players[displayplayers[3]].spectator) + error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[localdisplayplayers[3]]].ctfteam); + else if (G_GametypeHasSpectators() && !players[displayplayers[localdisplayplayers[3]]].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA else @@ -3661,8 +3661,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 //reset view if you are changed, or viewing someone who was changed. - if (playernum == consoleplayer || displayplayers[0] == playernum) - displayplayers[0] = consoleplayer; + if (playernum == consoleplayer || displayplayers[localdisplayplayers[0]] == playernum) + displayplayers[localdisplayplayers[0]] = consoleplayer; if (G_GametypeHasTeams()) { @@ -5299,7 +5299,7 @@ static void Got_PickVotecmd(UINT8 **cp, INT32 playernum) */ static void Command_Displayplayer_f(void) { - CONS_Printf(M_GetText("Displayplayer is %d\n"), displayplayers[0]); + CONS_Printf(M_GetText("Displayplayer is %d\n"), displayplayers[localdisplayplayers[0]]); } /** Quits a game and returns to the title screen. @@ -5494,7 +5494,7 @@ static void Name2_OnChange(void) 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")); - CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]); + CV_StealthSet(&cv_playername2, player_names[displayplayers[localdisplayplayers[1]]]); } else SendNameAndColor2(); @@ -5505,7 +5505,7 @@ static void Name3_OnChange(void) 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")); - CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]); + CV_StealthSet(&cv_playername3, player_names[displayplayers[localdisplayplayers[2]]]); } else SendNameAndColor3(); @@ -5516,7 +5516,7 @@ static void Name4_OnChange(void) 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")); - CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]); + CV_StealthSet(&cv_playername4, player_names[displayplayers[localdisplayplayers[3]]]); } else SendNameAndColor4(); @@ -5557,12 +5557,12 @@ static void Skin2_OnChange(void) if (!Playing() || !splitscreen) return; // do whatever you want - if (CanChangeSkin(displayplayers[1]) && !P_PlayerMoving(displayplayers[1])) + if (CanChangeSkin(displayplayers[localdisplayplayers[1]]) && !P_PlayerMoving(displayplayers[localdisplayplayers[1]])) SendNameAndColor2(); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); - CV_StealthSet(&cv_skin2, skins[players[displayplayers[1]].skin].name); + CV_StealthSet(&cv_skin2, skins[players[displayplayers[localdisplayplayers[1]]].skin].name); } } @@ -5571,12 +5571,12 @@ static void Skin3_OnChange(void) if (!Playing() || splitscreen < 2) return; // do whatever you want - if (CanChangeSkin(displayplayers[2]) && !P_PlayerMoving(displayplayers[2])) + if (CanChangeSkin(displayplayers[localdisplayplayers[2]]) && !P_PlayerMoving(displayplayers[localdisplayplayers[2]])) SendNameAndColor3(); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); - CV_StealthSet(&cv_skin3, skins[players[displayplayers[2]].skin].name); + CV_StealthSet(&cv_skin3, skins[players[displayplayers[localdisplayplayers[2]]].skin].name); } } @@ -5585,12 +5585,12 @@ static void Skin4_OnChange(void) if (!Playing() || splitscreen < 3) return; // do whatever you want - if (CanChangeSkin(displayplayers[3]) && !P_PlayerMoving(displayplayers[3])) + if (CanChangeSkin(displayplayers[localdisplayplayers[3]]) && !P_PlayerMoving(displayplayers[localdisplayplayers[3]])) SendNameAndColor4(); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); - CV_StealthSet(&cv_skin4, skins[players[displayplayers[3]].skin].name); + CV_StealthSet(&cv_skin4, skins[players[displayplayers[localdisplayplayers[3]]].skin].name); } } @@ -5631,7 +5631,7 @@ static void Color2_OnChange(void) if (!Playing() || !splitscreen) return; // do whatever you want - if (!P_PlayerMoving(displayplayers[1])) + if (!P_PlayerMoving(displayplayers[localdisplayplayers[1]])) { // Color change menu scrolling fix is no longer necessary SendNameAndColor2(); @@ -5639,7 +5639,7 @@ static void Color2_OnChange(void) else { CV_StealthSetValue(&cv_playercolor2, - players[displayplayers[1]].skincolor); + players[displayplayers[localdisplayplayers[1]]].skincolor); } } @@ -5648,7 +5648,7 @@ static void Color3_OnChange(void) if (!Playing() || splitscreen < 2) return; // do whatever you want - if (!P_PlayerMoving(displayplayers[2])) + if (!P_PlayerMoving(displayplayers[localdisplayplayers[2]])) { // Color change menu scrolling fix is no longer necessary SendNameAndColor3(); @@ -5656,7 +5656,7 @@ static void Color3_OnChange(void) else { CV_StealthSetValue(&cv_playercolor3, - players[displayplayers[2]].skincolor); + players[displayplayers[localdisplayplayers[2]]].skincolor); } } @@ -5665,7 +5665,7 @@ static void Color4_OnChange(void) if (!Playing() || splitscreen < 3) return; // do whatever you want - if (!P_PlayerMoving(displayplayers[3])) + if (!P_PlayerMoving(displayplayers[localdisplayplayers[3]])) { // Color change menu scrolling fix is no longer necessary SendNameAndColor4(); @@ -5673,7 +5673,7 @@ static void Color4_OnChange(void) else { CV_StealthSetValue(&cv_playercolor4, - players[displayplayers[3]].skincolor); + players[displayplayers[localdisplayplayers[3]]].skincolor); } } diff --git a/src/doomstat.h b/src/doomstat.h index 59e2bd5c4..1d43b4986 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -82,6 +82,7 @@ extern INT16 gametype; #define MAXSPLITSCREENPLAYERS 4 // Max number of players on a single computer extern UINT8 splitscreen; +extern int r_splitscreen; extern boolean circuitmap; // Does this level have 'circuit mode'? extern boolean fromlevelselect; @@ -122,6 +123,8 @@ extern boolean gamedataloaded; // Player taking events, and displaying. extern INT32 consoleplayer; extern INT32 displayplayers[MAXSPLITSCREENPLAYERS]; +/* displayplayers[localdisplayplayers[0]] = consoleplayer */ +extern INT32 localdisplayplayers[MAXSPLITSCREENPLAYERS]; // Maps of special importance extern INT16 spstage_start; diff --git a/src/g_game.c b/src/g_game.c index d4d48f7c2..871eafaab 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -115,6 +115,7 @@ player_t players[MAXPLAYERS]; INT32 consoleplayer; // player taking events and displaying INT32 displayplayers[MAXSPLITSCREENPLAYERS]; // view being displayed +INT32 localdisplayplayers[MAXSPLITSCREENPLAYERS]; tic_t gametic; tic_t levelstarttic; // gametic at level start @@ -1256,7 +1257,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (ssplayer == 1) player = &players[consoleplayer]; else - player = &players[displayplayers[ssplayer-1]]; + player = &players[displayplayers[localdisplayplayers[ssplayer-1]]]; if (ssplayer == 2) thiscam = (player->bot == 2 ? &camera[0] : &camera[ssplayer-1]); @@ -1595,8 +1596,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) //Reset away view if a command is given. if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) - && displayplayers[0] != consoleplayer && ssplayer == 1) - displayplayers[0] = consoleplayer; + && displayplayers[localdisplayplayers[0]] != consoleplayer && ssplayer == 1) + displayplayers[localdisplayplayers[0]] = consoleplayer; } @@ -1748,12 +1749,12 @@ void G_DoLoadLevel(boolean resetplayer) if (!resetplayer) P_FindEmerald(); - displayplayers[0] = consoleplayer; // view the guy you are playing + displayplayers[localdisplayplayers[0]] = consoleplayer; // view the guy you are playing for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - if (i > 0 && !(i == 1 && botingame) && splitscreen < i) - displayplayers[i] = consoleplayer; + if (i > 0 && !(i == 1 && botingame) && r_splitscreen < i) + displayplayers[localdisplayplayers[i]] = consoleplayer; } gameaction = ga_nothing; @@ -1761,10 +1762,10 @@ void G_DoLoadLevel(boolean resetplayer) Z_CheckHeap(-2); #endif - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (camera[i].chase) - P_ResetCamera(&players[displayplayers[i]], &camera[i]); + P_ResetCamera(&players[displayplayers[localdisplayplayers[i]]], &camera[i]); } // clear cmd building stuff @@ -1874,8 +1875,8 @@ boolean G_Responder(event_t *ev) if (gamestate == GS_LEVEL && ev->type == ev_keydown && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) { - if (!demo.playback && (splitscreen || !netgame)) - displayplayers[0] = consoleplayer; + if (!demo.playback && (r_splitscreen || !netgame)) + displayplayers[localdisplayplayers[0]] = consoleplayer; else { G_AdjustView(1, 1, true); @@ -2139,7 +2140,7 @@ boolean G_CanView(INT32 playernum, UINT8 viewnum, boolean onlyactive) if (!(onlyactive ? G_CouldView(playernum) : (playeringame[playernum] && !players[playernum].spectator))) return false; - splits = splitscreen+1; + splits = r_splitscreen+1; if (viewnum > splits) viewnum = splits; @@ -2210,7 +2211,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) INT32 olddisplayplayer; INT32 playersviewable; - splits = splitscreen+1; + splits = r_splitscreen+1; /* Promote splits */ if (viewnum > splits) @@ -2221,7 +2222,7 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) if (viewnum > playersviewable) viewnum = playersviewable; - splitscreen = viewnum-1; + r_splitscreen = viewnum-1; /* Prepare extra views for G_FindView to pass. */ for (viewd = splits+1; viewd < viewnum; ++viewd) @@ -2294,14 +2295,14 @@ void G_ResetViews(void) INT32 playersviewable; - splits = splitscreen+1; + splits = r_splitscreen+1; playersviewable = G_CountPlayersPotentiallyViewable(false); /* Demote splits */ if (playersviewable < splits) { splits = playersviewable; - splitscreen = max(splits-1, 0); + r_splitscreen = max(splits-1, 0); R_ExecuteSetViewSize(); } @@ -2884,18 +2885,18 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) if (nummapthings) { if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) + || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) + || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) + || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the first mapthing!\n")); spawnpoint = &mapthings[0]; } else { if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) + || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) + || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) + || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the origin!\n")); //P_MovePlayerToSpawn handles this fine if the spawnpoint is NULL. } @@ -2990,17 +2991,17 @@ mapthing_t *G_FindMatchStart(INT32 playernum) return deathmatchstarts[i]; } if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) + || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) + || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) + || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Deathmatch starts!\n")); return NULL; } if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) + || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) + || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) + || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) CONS_Alert(CONS_WARNING, M_GetText("No Deathmatch starts in this map!\n")); return NULL; } @@ -3088,17 +3089,17 @@ mapthing_t *G_FindRaceStart(INT32 playernum) //return playerstarts[0]; if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) + || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) + || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) + || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Race starts!\n")); return NULL; } if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[1]) - || (splitscreen > 1 && playernum == displayplayers[2]) - || (splitscreen > 2 && playernum == displayplayers[3])) + || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) + || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) + || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) CONS_Alert(CONS_WARNING, M_GetText("No Race starts in this map!\n")); return NULL; } @@ -3712,7 +3713,7 @@ static void G_DoCompleted(void) } // play some generic music if there's no win/cool/lose music going on (for exitlevel commands) - if (G_RaceGametype() && ((multiplayer && demo.playback) || j == splitscreen+1) && (cv_inttime.value > 0)) + if (G_RaceGametype() && ((multiplayer && demo.playback) || j == r_splitscreen+1) && (cv_inttime.value > 0)) S_ChangeMusicInternal("racent", true); if (automapactive) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 1afa133b3..ad64552d8 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1477,7 +1477,7 @@ static void HU_drawMiniChat(void) if (!chat_nummsg_min) return; // needless to say it's useless to do anything if we don't have anything to draw. - if (splitscreen > 1) + if (r_splitscreen > 1) boxw = max(64, boxw/2); for (; i>0; i--) @@ -1529,10 +1529,10 @@ static void HU_drawMiniChat(void) y = chaty - charheight*(msglines+1); #ifdef NETSPLITSCREEN - if (splitscreen) + if (r_splitscreen) { y -= BASEVIDHEIGHT/2; - if (splitscreen > 1) + if (r_splitscreen > 1) y += 16; } else @@ -1620,10 +1620,10 @@ static void HU_drawChatLog(INT32 offset) chat_scroll = chat_maxscroll; #ifdef NETSPLITSCREEN - if (splitscreen) + if (r_splitscreen) { boxh = max(6, boxh/2); - if (splitscreen > 1) + if (r_splitscreen > 1) boxw = max(64, boxw/2); } #endif @@ -1631,10 +1631,10 @@ static void HU_drawChatLog(INT32 offset) y = chaty - offset*charheight - (chat_scroll*charheight) - boxh*charheight - 12; #ifdef NETSPLITSCREEN - if (splitscreen) + if (r_splitscreen) { y -= BASEVIDHEIGHT/2; - if (splitscreen > 1) + if (r_splitscreen > 1) y += 16; } else @@ -1739,10 +1739,10 @@ static void HU_DrawChat(void) const char *mute = "Chat has been muted."; #ifdef NETSPLITSCREEN - if (splitscreen) + if (r_splitscreen) { y -= BASEVIDHEIGHT/2; - if (splitscreen > 1) + if (r_splitscreen > 1) { y += 16; boxw = max(64, boxw/2); @@ -1836,10 +1836,10 @@ static void HU_DrawChat(void) INT32 count = 0; INT32 p_dispy = chaty - charheight -1; #ifdef NETSPLITSCREEN - if (splitscreen) + if (r_splitscreen) { p_dispy -= BASEVIDHEIGHT/2; - if (splitscreen > 1) + if (r_splitscreen > 1) p_dispy += 16; } else @@ -2250,7 +2250,7 @@ void HU_DrawSongCredits(void) { char *str; INT32 len, destx; - INT32 y = (splitscreen ? (BASEVIDHEIGHT/2)-4 : 32); + INT32 y = (r_splitscreen ? (BASEVIDHEIGHT/2)-4 : 32); INT32 bgt; if (!cursongcredit.def) // No def @@ -3022,7 +3022,7 @@ static void HU_DrawRankings(void) // 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. - if (!splitscreen) + if (!r_splitscreen) whiteplayer = demo.playback ? displayplayers[0] : consoleplayer; scorelines = 0; diff --git a/src/k_kart.c b/src/k_kart.c index 230662d2a..ebce1458e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1058,7 +1058,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player)) { #define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8)) - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (player == &players[displayplayers[i]] && players[displayplayers[i]].kartstuff[k_itemroulette]) PLAYROULETTESND; @@ -3925,7 +3925,7 @@ static void K_DoHyudoroSteal(player_t *player) players[stealplayer].kartstuff[k_itemamount] = 0; players[stealplayer].kartstuff[k_itemheld] = 0; - if (P_IsDisplayPlayer(&players[stealplayer]) && !splitscreen) + if (P_IsDisplayPlayer(&players[stealplayer]) && !r_splitscreen) S_StartSound(NULL, sfx_s3k92); } } @@ -6500,7 +6500,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (player->kartstuff[k_hyudorotimer] > 0) { - if (splitscreen) + if (r_splitscreen) { if (leveltime & 1) player->mo->flags2 |= MF2_DONTDRAW; @@ -6511,9 +6511,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { if (player == &players[displayplayers[1]]) player->mo->eflags |= MFE_DRAWONLYFORP2; - else if (player == &players[displayplayers[2]] && splitscreen > 1) + else if (player == &players[displayplayers[2]] && r_splitscreen > 1) player->mo->eflags |= MFE_DRAWONLYFORP3; - else if (player == &players[displayplayers[3]] && splitscreen > 2) + else if (player == &players[displayplayers[3]] && r_splitscreen > 2) player->mo->eflags |= MFE_DRAWONLYFORP4; else if (player == &players[displayplayers[0]]) player->mo->eflags |= MFE_DRAWONLYFORP1; @@ -6635,7 +6635,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } // Play the starting countdown sounds - if (player == &players[displayplayers[0]]) // Don't play louder in splitscreen + if (player == &players[displayplayers[localdisplayplayers[0]]]) // Don't play louder in splitscreen { if ((leveltime == starttime-(3*TICRATE)) || (leveltime == starttime-(2*TICRATE)) || (leveltime == starttime-TICRATE)) S_StartSound(NULL, sfx_s3ka7); @@ -7521,7 +7521,7 @@ static void K_initKartHUD(void) WANT_X = BASEVIDWIDTH - 55; // 270 WANT_Y = BASEVIDHEIGHT- 71; // 176 - if (splitscreen) // Splitscreen + if (r_splitscreen) // Splitscreen { ITEM_X = 5; ITEM_Y = 3; @@ -7534,7 +7534,7 @@ static void K_initKartHUD(void) MINI_Y = (BASEVIDHEIGHT/2); - if (splitscreen > 1) // 3P/4P Small Splitscreen + if (r_splitscreen > 1) // 3P/4P Small Splitscreen { // 1P (top left) ITEM_X = -9; @@ -7563,7 +7563,7 @@ static void K_initKartHUD(void) MINI_X = (3*BASEVIDWIDTH/4); MINI_Y = (3*BASEVIDHEIGHT/4); - if (splitscreen > 2) // 4P-only + if (r_splitscreen > 2) // 4P-only { MINI_X = (BASEVIDWIDTH/2); MINI_Y = (BASEVIDHEIGHT/2); @@ -7583,20 +7583,20 @@ INT32 K_calcSplitFlags(INT32 snapflags) { INT32 splitflags = 0; - if (splitscreen == 0) + if (r_splitscreen == 0) return snapflags; if (stplyr != &players[displayplayers[0]]) { - if (splitscreen == 1 && stplyr == &players[displayplayers[1]]) + if (r_splitscreen == 1 && stplyr == &players[displayplayers[1]]) { splitflags |= V_SPLITSCREEN; } - else if (splitscreen > 1) + else if (r_splitscreen > 1) { - if (stplyr == &players[displayplayers[2]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]])) + if (stplyr == &players[displayplayers[2]] || (r_splitscreen == 3 && stplyr == &players[displayplayers[3]])) splitflags |= V_SPLITSCREEN; - if (stplyr == &players[displayplayers[1]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]])) + if (stplyr == &players[displayplayers[1]] || (r_splitscreen == 3 && stplyr == &players[displayplayers[3]])) splitflags |= V_HORZSCREEN; } } @@ -7606,7 +7606,7 @@ INT32 K_calcSplitFlags(INT32 snapflags) else snapflags &= ~V_SNAPTOBOTTOM; - if (splitscreen > 1) + if (r_splitscreen > 1) { if (splitflags & V_HORZSCREEN) snapflags &= ~V_SNAPTOLEFT; @@ -7624,7 +7624,7 @@ static void K_drawKartItem(void) // Why write V_DrawScaledPatch calls over and over when they're all the same? // Set to 'no item' just in case. - const UINT8 offset = ((splitscreen > 1) ? 1 : 0); + const UINT8 offset = ((r_splitscreen > 1) ? 1 : 0); patch_t *localpatch = kp_nodraw; patch_t *localbg = ((offset) ? kp_itembg[2] : kp_itembg[0]); patch_t *localinv = ((offset) ? kp_invincibility[((leveltime % (6*3)) / 3) + 7] : kp_invincibility[(leveltime % (7*3)) / 3]); @@ -7633,7 +7633,7 @@ static void K_drawKartItem(void) const INT32 numberdisplaymin = ((!offset && stplyr->kartstuff[k_itemtype] == KITEM_ORBINAUT) ? 5 : 2); INT32 itembar = 0; INT32 maxl = 0; // itembar's normal highest value - const INT32 barlength = (splitscreen > 1 ? 12 : 26); + const INT32 barlength = (r_splitscreen > 1 ? 12 : 26); UINT8 localcolor = SKINCOLOR_NONE; SINT8 colormode = TC_RAINBOW; UINT8 *colmap = NULL; @@ -7865,7 +7865,7 @@ static void K_drawKartItem(void) } // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. + if (r_splitscreen < 2) // don't change shit for THIS splitscreen. { fx = ITEM_X; fy = ITEM_Y; @@ -8110,19 +8110,19 @@ static void K_DrawKartPositionNum(INT32 num) scale *= 2; overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw. } - if (splitscreen) + if (r_splitscreen) scale /= 2; W = FixedMul(W<>FRACBITS; // pain and suffering defined below - if (!splitscreen) + if (!r_splitscreen) { fx = POSI_X; fy = BASEVIDHEIGHT - 8; fflags = V_SNAPTOBOTTOM|V_SNAPTORIGHT; } - else if (splitscreen == 1) // for this splitscreen, we'll use case by case because it's a bit different. + else if (r_splitscreen == 1) // for this splitscreen, we'll use case by case because it's a bit different. { fx = POSI_X; if (stplyr == &players[displayplayers[0]]) // for player 1: display this at the top right, above the minimap. @@ -8487,16 +8487,16 @@ static void K_drawKartLapsAndRings(void) { ringflip = V_FLIP; ringanim_realframe = RINGANIM_NUMFRAMES-stplyr->karthud[khud_ringframe]; - ringx += SHORT((splitscreen > 1) ? kp_smallring[ringanim_realframe]->width : kp_ring[ringanim_realframe]->width); + ringx += SHORT((r_splitscreen > 1) ? kp_smallring[ringanim_realframe]->width : kp_ring[ringanim_realframe]->width); } - if (splitscreen > 1) + if (r_splitscreen > 1) { INT32 fx = 0, fy = 0, fr = 0; INT32 flipflag = 0; // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. + if (r_splitscreen < 2) // don't change shit for THIS splitscreen. { fx = LAPS_X; fy = LAPS_Y; @@ -8679,13 +8679,13 @@ static void K_drawKartBumpersOrKarma(void) UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, stplyr->skincolor, GTC_CACHE); INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); - if (splitscreen > 1) + if (r_splitscreen > 1) { INT32 fx = 0, fy = 0; INT32 flipflag = 0; // pain and suffering defined below - if (splitscreen < 2) // don't change shit for THIS splitscreen. + if (r_splitscreen < 2) // don't change shit for THIS splitscreen. { fx = LAPS_X; fy = LAPS_Y; @@ -8782,7 +8782,7 @@ static fixed_t K_FindCheckX(fixed_t px, fixed_t py, angle_t ang, fixed_t mx, fix if (encoremode) x = 320-x; - if (splitscreen > 1) + if (r_splitscreen > 1) x /= 2; return x; @@ -8808,17 +8808,17 @@ static void K_drawKartWanted(void) return; // set X/Y coords depending on splitscreen. - if (splitscreen < 3) // 1P and 2P use the same code. + if (r_splitscreen < 3) // 1P and 2P use the same code. { basex = WANT_X; basey = WANT_Y; - if (splitscreen == 2) + if (r_splitscreen == 2) { basey += 16; // slight adjust for 3P basex -= 6; } } - else if (splitscreen == 3) // 4P splitscreen... + else if (r_splitscreen == 3) // 4P splitscreen... { basex = BASEVIDWIDTH/2 - (SHORT(kp_wantedsplit->width)/2); // center on screen basey = BASEVIDHEIGHT - 55; @@ -8827,13 +8827,13 @@ static void K_drawKartWanted(void) if (battlewanted[0] != -1) colormap = R_GetTranslationColormap(0, players[battlewanted[0]].skincolor, GTC_CACHE); - V_DrawFixedPatch(basex< 1 ? kp_wantedsplit : kp_wanted), colormap); + V_DrawFixedPatch(basex< 1 ? kp_wantedsplit : kp_wanted), colormap); /*if (basey2) V_DrawFixedPatch(basex< 1 ? 13 : 8), y = basey+(splitscreen > 1 ? 16 : 21); + INT32 x = basex+(r_splitscreen > 1 ? 13 : 8), y = basey+(r_splitscreen > 1 ? 16 : 21); fixed_t scale = FRACUNIT/2; player_t *p = &players[battlewanted[i]]; @@ -8853,7 +8853,7 @@ static void K_drawKartWanted(void) if (players[battlewanted[i]].skincolor) { colormap = R_GetTranslationColormap(TC_RAINBOW, p->skincolor, GTC_CACHE); - V_DrawFixedPatch(x<skin] : facerankprefix[p->skin]), colormap); + V_DrawFixedPatch(x<skin] : facerankprefix[p->skin]), colormap); /*if (basey2) // again with 4p stuff V_DrawFixedPatch(x<skin] : facerankprefix[p->skin]), colormap);*/ } @@ -8990,7 +8990,7 @@ static void K_drawKartMinimap(void) patch_t *AutomapPic; INT32 i = 0; INT32 x, y; - INT32 minimaptrans, splitflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) + INT32 minimaptrans, splitflags = (r_splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) UINT8 skin = 0; UINT8 *colormap = NULL; SINT8 localplayers[4]; @@ -9035,7 +9035,7 @@ static void K_drawKartMinimap(void) else V_DrawScaledPatch(x, y, splitflags, AutomapPic); - if (!(splitscreen == 2)) + if (!(r_splitscreen == 2)) { splitflags &= ~minimaptrans; splitflags |= V_HUDTRANSHALF; @@ -9104,7 +9104,7 @@ static void K_drawKartMinimap(void) if (!players[i].mo || players[i].spectator) continue; - if (i != displayplayers[0] || splitscreen) + if (i != displayplayers[0] || r_splitscreen) { if (G_BattleGametype() && players[i].kartstuff[k_bumper] <= 0) continue; @@ -9194,7 +9194,7 @@ static void K_drawKartStartCountdown(void) pnum++; if ((leveltime % (2*5)) / 5) // blink pnum += 4; - if (splitscreen) // splitscreen + if (r_splitscreen) // splitscreen pnum += 8; V_DrawScaledPatch(STCD_X - (SHORT(kp_startcountdown[pnum]->width)/2), STCD_Y - (SHORT(kp_startcountdown[pnum]->height)/2), splitflags, kp_startcountdown[pnum]); @@ -9210,7 +9210,7 @@ static void K_drawKartFinish(void) if ((stplyr->karthud[khud_cardanimation] % (2*5)) / 5) // blink pnum = 1; - if (splitscreen > 1) // 3/4p, stationary FIN + if (r_splitscreen > 1) // 3/4p, stationary FIN { pnum += 2; V_DrawScaledPatch(STCD_X - (SHORT(kp_racefinish[pnum]->width)/2), STCD_Y - (SHORT(kp_racefinish[pnum]->height)/2), splitflags, kp_racefinish[pnum]); @@ -9221,14 +9221,14 @@ static void K_drawKartFinish(void) { INT32 x, xval; - if (splitscreen) // wide splitscreen + if (r_splitscreen) // wide splitscreen pnum += 4; x = ((vid.width<width)<karthud[khud_cardanimation])*(xval > x ? xval : x))/TICRATE; - if (splitscreen && stplyr == &players[displayplayers[1]]) + if (r_splitscreen && stplyr == &players[displayplayers[1]]) x = -x; V_DrawFixedPatch(x + (STCD_X<>1), @@ -9250,11 +9250,11 @@ static void K_drawBattleFullscreen(void) drawcomebacktimer = false; #endif - if (splitscreen) + if (r_splitscreen) { - if ((splitscreen == 1 && stplyr == &players[displayplayers[1]]) - || (splitscreen > 1 && (stplyr == &players[displayplayers[2]] - || (stplyr == &players[displayplayers[3]] && splitscreen > 2)))) + if ((r_splitscreen == 1 && stplyr == &players[displayplayers[1]]) + || (r_splitscreen > 1 && (stplyr == &players[displayplayers[2]] + || (stplyr == &players[displayplayers[3]] && r_splitscreen > 2)))) { y = 232-(stplyr->karthud[khud_cardanimation]/2); splitflags = V_SNAPTOBOTTOM; @@ -9262,12 +9262,12 @@ static void K_drawBattleFullscreen(void) else y = -32+(stplyr->karthud[khud_cardanimation]/2); - if (splitscreen > 1) + if (r_splitscreen > 1) { scale /= 2; if (stplyr == &players[displayplayers[1]] - || (stplyr == &players[displayplayers[3]] && splitscreen > 2)) + || (stplyr == &players[displayplayers[3]] && r_splitscreen > 2)) x = 3*BASEVIDWIDTH/4; else x = BASEVIDWIDTH/4; @@ -9303,7 +9303,7 @@ static void K_drawBattleFullscreen(void) else if (stplyr->kartstuff[k_bumper] <= 0 && stplyr->kartstuff[k_comebacktimer] && comeback && !stplyr->spectator && drawcomebacktimer) { UINT16 t = stplyr->kartstuff[k_comebacktimer]/(10*TICRATE); - INT32 txoff, adjust = (splitscreen > 1) ? 4 : 6; // normal string is 8, kart string is 12, half of that for ease + INT32 txoff, adjust = (r_splitscreen > 1) ? 4 : 6; // normal string is 8, kart string is 12, half of that for ease INT32 ty = (BASEVIDHEIGHT/2)+66; txoff = adjust; @@ -9314,13 +9314,13 @@ static void K_drawBattleFullscreen(void) t /= 10; } - if (splitscreen) + if (r_splitscreen) { - if (splitscreen > 1) + if (r_splitscreen > 1) ty = (BASEVIDHEIGHT/4)+33; - if ((splitscreen == 1 && stplyr == &players[displayplayers[1]]) - || (stplyr == &players[displayplayers[2]] && splitscreen > 1) - || (stplyr == &players[displayplayers[3]] && splitscreen > 2)) + if ((r_splitscreen == 1 && stplyr == &players[displayplayers[1]]) + || (stplyr == &players[displayplayers[2]] && r_splitscreen > 1) + || (stplyr == &players[displayplayers[3]] && r_splitscreen > 2)) ty += (BASEVIDHEIGHT/2); } else @@ -9331,7 +9331,7 @@ static void K_drawBattleFullscreen(void) else V_DrawFixedPatch(x< 1) + if (r_splitscreen > 1) V_DrawString(x-txoff, ty, 0, va("%d", stplyr->kartstuff[k_comebacktimer]/TICRATE)); else { @@ -9373,24 +9373,24 @@ static void K_drawKartFirstPerson(void) if (stplyr->spectator || !stplyr->mo || (stplyr->mo->flags2 & MF2_DONTDRAW)) return; - if (stplyr == &players[displayplayers[1]] && splitscreen) + if (stplyr == &players[displayplayers[1]] && r_splitscreen) { pn = pnum[1]; tn = turn[1]; dr = drift[1]; } - else if (stplyr == &players[displayplayers[2]] && splitscreen > 1) + else if (stplyr == &players[displayplayers[2]] && r_splitscreen > 1) { pn = pnum[2]; tn = turn[2]; dr = drift[2]; } - else if (stplyr == &players[displayplayers[3]] && splitscreen > 2) + else if (stplyr == &players[displayplayers[3]] && r_splitscreen > 2) { pn = pnum[3]; tn = turn[3]; dr = drift[3]; } else { pn = pnum[0]; tn = turn[0]; dr = drift[0]; } - if (splitscreen) + if (r_splitscreen) { y >>= 1; - if (splitscreen > 1) + if (r_splitscreen > 1) x >>= 1; } { - if (stplyr->speed < (20*stplyr->mo->scale) && (leveltime & 1) && !splitscreen) + if (stplyr->speed < (20*stplyr->mo->scale) && (leveltime & 1) && !r_splitscreen) y++; // the following isn't EXPLICITLY right, it just gets the result we want, but i'm too lazy to look up the right way to do it if (stplyr->mo->flags2 & MF2_SHADOW) @@ -9434,12 +9434,12 @@ static void K_drawKartFirstPerson(void) if (dr != stplyr->kartstuff[k_drift]*16) dr -= (dr - (stplyr->kartstuff[k_drift]*16))/8; - if (splitscreen == 1) + if (r_splitscreen == 1) { scale = (2*FRACUNIT)/3; y += FRACUNIT/(vid.dupx < vid.dupy ? vid.dupx : vid.dupy); // correct a one-pixel gap on the screen view (not the basevid view) } - else if (splitscreen) + else if (r_splitscreen) scale = FRACUNIT/2; else scale = FRACUNIT; @@ -9457,7 +9457,7 @@ static void K_drawKartFirstPerson(void) fixed_t xoffs = -P_ReturnThrustY(stplyr->mo, ang, (BASEVIDWIDTH<<(FRACBITS-2))/2); fixed_t yoffs = -(P_ReturnThrustX(stplyr->mo, ang, 4*FRACUNIT) - 4*FRACUNIT); - if (splitscreen) + if (r_splitscreen) xoffs = FixedMul(xoffs, scale); xoffs -= (tn)*scale; @@ -9470,7 +9470,7 @@ static void K_drawKartFirstPerson(void) if (mag < FRACUNIT) { xoffs = FixedMul(xoffs, mag); - if (!splitscreen) + if (!r_splitscreen) yoffs = FixedMul(yoffs, mag); } } @@ -9482,7 +9482,7 @@ static void K_drawKartFirstPerson(void) x -= xoffs; else x += xoffs; - if (!splitscreen) + if (!r_splitscreen) y += yoffs; } @@ -9502,11 +9502,11 @@ static void K_drawKartFirstPerson(void) V_DrawFixedPatch(x, y, scale, splitflags, kp_fpview[target], colmap); - if (stplyr == &players[displayplayers[1]] && splitscreen) + if (stplyr == &players[displayplayers[1]] && r_splitscreen) { pnum[1] = pn; turn[1] = tn; drift[1] = dr; } - else if (stplyr == &players[displayplayers[2]] && splitscreen > 1) + else if (stplyr == &players[displayplayers[2]] && r_splitscreen > 1) { pnum[2] = pn; turn[2] = tn; drift[2] = dr; } - else if (stplyr == &players[displayplayers[3]] && splitscreen > 2) + else if (stplyr == &players[displayplayers[3]] && r_splitscreen > 2) { pnum[3] = pn; turn[3] = tn; drift[3] = dr; } else { pnum[0] = pn; turn[0] = tn; drift[0] = dr; } @@ -9832,7 +9832,7 @@ void K_drawKartHUD(void) K_initKartHUD(); // Draw that fun first person HUD! Drawn ASAP so it looks more "real". - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (stplyr == &players[displayplayers[i]] && !camera[i].chase) K_drawKartFirstPerson(); @@ -9852,10 +9852,10 @@ void K_drawKartHUD(void) && comeback && stplyr->playerstate == PST_LIVE))); - if (!demo.title && (!battlefullscreen || splitscreen)) + if (!demo.title && (!battlefullscreen || r_splitscreen)) { // Draw the CHECK indicator before the other items, so it's overlapped by everything else - if (cv_kartcheck.value && !splitscreen && !players[displayplayers[0]].exiting) + if (cv_kartcheck.value && !r_splitscreen && !players[displayplayers[0]].exiting) K_drawKartPlayerCheck(); // Draw WANTED status @@ -9892,7 +9892,7 @@ void K_drawKartHUD(void) K_drawKartItem(); // If not splitscreen, draw... - if (!splitscreen && !demo.title) + if (!r_splitscreen && !demo.title) { // Draw the timestamp #ifdef HAVE_BLUA @@ -9913,7 +9913,7 @@ void K_drawKartHUD(void) if (!stplyr->spectator) // Bottom of the screen elements, don't need in spectate mode { // Draw the speedometer - if (cv_kartspeedometer.value && !splitscreen) + if (cv_kartspeedometer.value && !r_splitscreen) { #ifdef HAVE_BLUA if (LUA_HudEnabled(hud_speedometer)) @@ -9925,7 +9925,7 @@ void K_drawKartHUD(void) { INT32 x = BASEVIDWIDTH - 32, y = 128, offs; - if (splitscreen == 3) + if (r_splitscreen == 3) { x = BASEVIDWIDTH/2 + 10; y = BASEVIDHEIGHT/2 - 30; @@ -9984,11 +9984,11 @@ void K_drawKartHUD(void) if (leveltime >= starttime-(3*TICRATE) && leveltime < starttime+TICRATE) K_drawKartStartCountdown(); - else if (countdown && (!splitscreen || !stplyr->exiting)) + else if (countdown && (!r_splitscreen || !stplyr->exiting)) { char *countstr = va("%d", countdown/TICRATE); - if (splitscreen > 1) + if (r_splitscreen > 1) V_DrawCenteredString(BASEVIDWIDTH/4, LAPS_Y+1, K_calcSplitFlags(0), countstr); else { @@ -10002,14 +10002,14 @@ void K_drawKartHUD(void) { if (stplyr->exiting) K_drawKartFinish(); - else if (stplyr->karthud[khud_lapanimation] && !splitscreen) + else if (stplyr->karthud[khud_lapanimation] && !r_splitscreen) K_drawLapStartAnim(); } if (modeattacking) // everything after here is MP and debug only return; - if (G_BattleGametype() && !splitscreen && (stplyr->karthud[khud_yougotem] % 2)) // * YOU GOT EM * + if (G_BattleGametype() && !r_splitscreen && (stplyr->karthud[khud_yougotem] % 2)) // * YOU GOT EM * V_DrawScaledPatch(BASEVIDWIDTH/2 - (SHORT(kp_yougotem->width)/2), 32, V_HUDTRANS, kp_yougotem); // Draw FREE PLAY. diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 299870e00..2ce3e89ae 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -125,7 +125,7 @@ void COM_Lua_f(void) lua_pop(gL, 1); // pop command info table return; // can't execute splitscreen command without player 2! } - playernum = displayplayers[1]; + playernum = displayplayers[localdisplayplayers[1]]; } if (netgame) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index ec76552d1..d10a8dd0a 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -426,15 +426,15 @@ static int libd_drawOnMinimap(lua_State *L) // first, check what position the mmap is supposed to be in (pasted from k_kart.c): MM_X = BASEVIDWIDTH - 50; // 270 MM_Y = (BASEVIDHEIGHT/2)-16; // 84 - if (splitscreen) + if (r_splitscreen) { MM_Y = (BASEVIDHEIGHT/2); - if (splitscreen > 1) // 3P : bottom right + if (r_splitscreen > 1) // 3P : bottom right { MM_X = (3*BASEVIDWIDTH/4); MM_Y = (3*BASEVIDHEIGHT/4); - if (splitscreen > 2) // 4P: centered + if (r_splitscreen > 2) // 4P: centered { MM_X = (BASEVIDWIDTH/2); MM_Y = (BASEVIDHEIGHT/2); @@ -443,7 +443,7 @@ static int libd_drawOnMinimap(lua_State *L) } // splitscreen flags - splitflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) + splitflags = (r_splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) // translucency: if (timeinmap > 105) @@ -461,7 +461,7 @@ static int libd_drawOnMinimap(lua_State *L) minimaptrans = ((10-minimaptrans)< 2 && stplayr == &players[displayplayers[3]]) + if (r_splitscreen > 2 && stplayr == &players[displayplayers[3]]) { LUA_PushUserdata(gL, &camera[3], META_CAMERA); camnum = 4; } - else if (splitscreen > 1 && stplayr == &players[displayplayers[2]]) + else if (r_splitscreen > 1 && stplayr == &players[displayplayers[2]]) { LUA_PushUserdata(gL, &camera[2], META_CAMERA); camnum = 3; } - else if (splitscreen && stplayr == &players[displayplayers[1]]) + else if (r_splitscreen && stplayr == &players[displayplayers[1]]) { LUA_PushUserdata(gL, &camera[1], META_CAMERA); camnum = 2; diff --git a/src/m_menu.c b/src/m_menu.c index d5084dff2..3fe0198df 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5789,9 +5789,9 @@ static void M_DrawPlaybackMenu(void) { PlaybackMenu[playback_viewcount].status = IT_ARROWS|IT_STRING; - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) PlaybackMenu[playback_view1+i].status = IT_ARROWS|IT_STRING; - for (i = splitscreen+1; i < 4; i++) + for (i = r_splitscreen+1; i < 4; i++) PlaybackMenu[playback_view1+i].status = IT_DISABLED; //PlaybackMenu[playback_moreoptions].alphaKey = 156; @@ -5814,7 +5814,7 @@ static void M_DrawPlaybackMenu(void) { if (modeattacking) continue; - if (splitscreen >= i - playback_view1) + if (r_splitscreen >= i - playback_view1) { INT32 ply = displayplayers[i - playback_view1]; @@ -5850,18 +5850,18 @@ static void M_DrawPlaybackMenu(void) { char *str; - if (!(i == playback_viewcount && splitscreen == 3)) + if (!(i == playback_viewcount && r_splitscreen == 3)) V_DrawCharacter(BASEVIDWIDTH/2 - 4, currentMenu->y + 28 - (skullAnimCounter/5), '\x1A' | V_SNAPTOTOP|highlightflags, false); // up arrow - if (!(i == playback_viewcount && splitscreen == 0)) + if (!(i == playback_viewcount && r_splitscreen == 0)) V_DrawCharacter(BASEVIDWIDTH/2 - 4, currentMenu->y + 48 + (skullAnimCounter/5), '\x1B' | V_SNAPTOTOP|highlightflags, false); // down arrow switch (i) { case playback_viewcount: - str = va("%d", splitscreen+1); + str = va("%d", r_splitscreen+1); break; case playback_view1: @@ -5954,12 +5954,12 @@ static void M_PlaybackSetViews(INT32 choice) { if (choice > 0) { - if (splitscreen < 3) - G_AdjustView(splitscreen + 2, 0, true); + if (r_splitscreen < 3) + G_AdjustView(r_splitscreen + 2, 0, true); } - else if (splitscreen) + else if (r_splitscreen) { - splitscreen--; + r_splitscreen--; R_ExecuteSetViewSize(); } } @@ -9525,7 +9525,7 @@ static void M_SetupMultiPlayer2(INT32 choice) strcpy (setupm_name, cv_playername2.string); // set for splitscreen secondary player - setupm_player = &players[displayplayers[1]]; + setupm_player = &players[displayplayers[localdisplayplayers[1]]]; setupm_cvskin = &cv_skin2; setupm_cvcolor = &cv_playercolor2; setupm_cvname = &cv_playername2; @@ -9537,7 +9537,7 @@ static void M_SetupMultiPlayer2(INT32 choice) setupm_fakecolor = setupm_cvcolor->value; // disable skin changes if we can't actually change skins - if (splitscreen && !CanChangeSkin(displayplayers[1])) + if (splitscreen && !CanChangeSkin(displayplayers[localdisplayplayers[1]])) MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); else MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING); @@ -9556,7 +9556,7 @@ static void M_SetupMultiPlayer3(INT32 choice) strcpy(setupm_name, cv_playername3.string); // set for splitscreen third player - setupm_player = &players[displayplayers[2]]; + setupm_player = &players[displayplayers[localdisplayplayers[2]]]; setupm_cvskin = &cv_skin3; setupm_cvcolor = &cv_playercolor3; setupm_cvname = &cv_playername3; @@ -9568,7 +9568,7 @@ static void M_SetupMultiPlayer3(INT32 choice) setupm_fakecolor = setupm_cvcolor->value; // disable skin changes if we can't actually change skins - if (splitscreen > 1 && !CanChangeSkin(displayplayers[2])) + if (splitscreen > 1 && !CanChangeSkin(displayplayers[localdisplayplayers[2]])) MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); else MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING); @@ -9587,7 +9587,7 @@ static void M_SetupMultiPlayer4(INT32 choice) strcpy(setupm_name, cv_playername4.string); // set for splitscreen fourth player - setupm_player = &players[displayplayers[3]]; + setupm_player = &players[displayplayers[localdisplayplayers[3]]]; setupm_cvskin = &cv_skin4; setupm_cvcolor = &cv_playercolor4; setupm_cvname = &cv_playername4; @@ -9599,7 +9599,7 @@ static void M_SetupMultiPlayer4(INT32 choice) setupm_fakecolor = setupm_cvcolor->value; // disable skin changes if we can't actually change skins - if (splitscreen > 2 && !CanChangeSkin(displayplayers[3])) + if (splitscreen > 2 && !CanChangeSkin(displayplayers[localdisplayplayers[3]])) MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); else MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING); diff --git a/src/m_misc.c b/src/m_misc.c index f4a4ec291..b232bce9a 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -743,12 +743,12 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png else snprintf(lvlttltext, 48, "Unknown"); - if (gamestate == GS_LEVEL && &players[displayplayers[0]] && players[displayplayers[0]].mo) + if (gamestate == GS_LEVEL && &players[displayplayers[localdisplayplayers[0]]] && players[displayplayers[localdisplayplayers[0]]].mo) snprintf(locationtxt, 40, "X:%d Y:%d Z:%d A:%d", - players[displayplayers[0]].mo->x>>FRACBITS, - players[displayplayers[0]].mo->y>>FRACBITS, - players[displayplayers[0]].mo->z>>FRACBITS, - FixedInt(AngleFixed(players[displayplayers[0]].mo->angle))); + players[displayplayers[localdisplayplayers[0]]].mo->x>>FRACBITS, + players[displayplayers[localdisplayplayers[0]]].mo->y>>FRACBITS, + players[displayplayers[localdisplayplayers[0]]].mo->z>>FRACBITS, + FixedInt(AngleFixed(players[displayplayers[localdisplayplayers[0]]].mo->angle))); else snprintf(locationtxt, 40, "Unknown"); diff --git a/src/p_enemy.c b/src/p_enemy.c index 76f6b3159..a9b8d30b3 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -4229,7 +4229,7 @@ void A_OverlayThink(mobj_t *actor) if (!actor->target) return; - if (!splitscreen && rendermode != render_soft) + if (!r_splitscreen && rendermode != render_soft) { angle_t viewingangle; diff --git a/src/p_floor.c b/src/p_floor.c index ccbfd6eae..a6419b409 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2536,9 +2536,9 @@ void T_CameraScanner(elevator_t *elevator) lastleveltime = leveltime; } - if (players[displayplayers[0]].mo) + if (players[displayplayers[localdisplayplayers[0]]].mo) { - if (players[displayplayers[0]].mo->subsector->sector == elevator->actionsector) + if (players[displayplayers[localdisplayplayers[0]]].mo->subsector->sector == elevator->actionsector) { if (t_cam_dist == -42) t_cam_dist = cv_cam_dist.value; @@ -2564,9 +2564,9 @@ void T_CameraScanner(elevator_t *elevator) } } - if (splitscreen && players[displayplayers[1]].mo) + if (splitscreen && players[displayplayers[localdisplayplayers[1]]].mo) { - if (players[displayplayers[1]].mo->subsector->sector == elevator->actionsector) + if (players[displayplayers[localdisplayplayers[1]]].mo->subsector->sector == elevator->actionsector) { if (t_cam2_rotate == -42) t_cam2_dist = cv_cam2_dist.value; @@ -2592,9 +2592,9 @@ void T_CameraScanner(elevator_t *elevator) } } - if (splitscreen > 1 && players[displayplayers[2]].mo) + if (splitscreen > 1 && players[displayplayers[localdisplayplayers[2]]].mo) { - if (players[displayplayers[2]].mo->subsector->sector == elevator->actionsector) + if (players[displayplayers[localdisplayplayers[2]]].mo->subsector->sector == elevator->actionsector) { if (t_cam3_rotate == -42) t_cam3_dist = cv_cam3_dist.value; @@ -2620,9 +2620,9 @@ void T_CameraScanner(elevator_t *elevator) } } - if (splitscreen > 2 && players[displayplayers[3]].mo) + if (splitscreen > 2 && players[displayplayers[localdisplayplayers[3]]].mo) { - if (players[displayplayers[3]].mo->subsector->sector == elevator->actionsector) + if (players[displayplayers[localdisplayplayers[3]]].mo->subsector->sector == elevator->actionsector) { if (t_cam4_rotate == -42) t_cam4_dist = cv_cam4_dist.value; diff --git a/src/p_inter.c b/src/p_inter.c index 7a975951c..d53423a46 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -63,11 +63,11 @@ void P_ForceConstant(const BasicFF_t *FFInfo) ConstantQuake.Magnitude = FFInfo->Magnitude; if (FFInfo->player == &players[consoleplayer]) I_Tactile(ConstantForce, &ConstantQuake); - else if (splitscreen && FFInfo->player == &players[displayplayers[1]]) + else if (splitscreen && FFInfo->player == &players[displayplayers[localdisplayplayers[1]]]) I_Tactile2(ConstantForce, &ConstantQuake); - else if (splitscreen > 1 && FFInfo->player == &players[displayplayers[2]]) + else if (splitscreen > 1 && FFInfo->player == &players[displayplayers[localdisplayplayers[2]]]) I_Tactile3(ConstantForce, &ConstantQuake); - else if (splitscreen > 2 && FFInfo->player == &players[displayplayers[3]]) + else if (splitscreen > 2 && FFInfo->player == &players[displayplayers[localdisplayplayers[3]]]) I_Tactile4(ConstantForce, &ConstantQuake); } void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End) @@ -84,11 +84,11 @@ void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End) RampQuake.End = End; if (FFInfo->player == &players[consoleplayer]) I_Tactile(ConstantForce, &RampQuake); - else if (splitscreen && FFInfo->player == &players[displayplayers[1]]) + else if (splitscreen && FFInfo->player == &players[displayplayers[localdisplayplayers[1]]]) I_Tactile2(ConstantForce, &RampQuake); - else if (splitscreen > 1 && FFInfo->player == &players[displayplayers[2]]) + else if (splitscreen > 1 && FFInfo->player == &players[displayplayers[localdisplayplayers[2]]]) I_Tactile3(ConstantForce, &RampQuake); - else if (splitscreen > 2 && FFInfo->player == &players[displayplayers[3]]) + else if (splitscreen > 2 && FFInfo->player == &players[displayplayers[localdisplayplayers[3]]]) I_Tactile4(ConstantForce, &RampQuake); } diff --git a/src/p_map.c b/src/p_map.c index e9bc95712..253be0955 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2568,7 +2568,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) itsatwodlevel = true; else { - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (thiscam == &camera[i] && players[displayplayers[i]].mo && (players[displayplayers[i]].mo->flags2 & MF2_TWOD)) @@ -2584,7 +2584,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) fixed_t tryx = thiscam->x; fixed_t tryy = thiscam->y; - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { #ifndef NOCLIPCAM if ((thiscam == &camera[i] && (players[displayplayers[i]].pflags & PF_NOCLIP)) || (leveltime < introtime)) // Noclipping player camera noclips too!! diff --git a/src/p_mobj.c b/src/p_mobj.c index b220ff4e6..d648ff0f3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1171,7 +1171,7 @@ static void P_PlayerFlip(mobj_t *mo) mo->player->aiming = InvAngle(mo->player->aiming); - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (mo->player-players == displayplayers[i]) { @@ -3565,7 +3565,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled itsatwodlevel = true; else { - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (thiscam == &camera[i] && players[displayplayers[i]].mo && (players[displayplayers[i]].mo->flags2 & MF2_TWOD)) @@ -3606,7 +3606,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled if (postimg != postimg_none) { - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (player == &players[displayplayers[i]]) postimgtype[i] = postimg; @@ -3656,11 +3656,11 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled fixed_t cam_height = cv_cam_height.value; thiscam->z = thiscam->floorz; - if (player == &players[displayplayers[1]]) + if (player == &players[displayplayers[localdisplayplayers[1]]]) cam_height = cv_cam2_height.value; - if (player == &players[displayplayers[2]]) + if (player == &players[displayplayers[localdisplayplayers[2]]]) cam_height = cv_cam3_height.value; - if (player == &players[displayplayers[3]]) + if (player == &players[displayplayers[localdisplayplayers[3]]]) cam_height = cv_cam4_height.value; if (thiscam->z > player->mo->z + player->mo->height + FixedMul(cam_height*FRACUNIT + 16*FRACUNIT, player->mo->scale)) { @@ -6112,7 +6112,7 @@ void P_RunOverlays(void) if (!mo->target) continue; - if (!splitscreen /*&& rendermode != render_soft*/) + if (!r_splitscreen /*&& rendermode != render_soft*/) { angle_t viewingangle; @@ -6635,7 +6635,7 @@ void P_RunBattleOvertime(void) { UINT8 transparency = tr_trans50; - if (!splitscreen && players[displayplayers[0]].mo) + if (!r_splitscreen && players[displayplayers[0]].mo) { INT32 dist = P_AproxDistance(battleovertime.x-players[displayplayers[0]].mo->x, battleovertime.y-players[displayplayers[0]].mo->y); transparency = max(0, NUMTRANSMAPS - ((256 + (dist>>FRACBITS)) / 256)); @@ -7094,7 +7094,7 @@ 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 - if (!splitscreen && players[displayplayers[0]].mo) + if (!r_splitscreen && players[displayplayers[0]].mo) { scale = mobj->target->scale + FixedMul(FixedDiv(abs(P_AproxDistance(players[displayplayers[0]].mo->x-mobj->target->x, players[displayplayers[0]].mo->y-mobj->target->y)), RING_DIST), mobj->target->scale); @@ -7282,7 +7282,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->target && mobj->target->health && mobj->tracer && mobj->target->player && !mobj->target->player->spectator && mobj->target->player->health && mobj->target->player->playerstate != PST_DEAD - && players[displayplayers[0]].mo && !players[displayplayers[0]].spectator) + && players[displayplayers[localdisplayplayers[0]]].mo && !players[displayplayers[localdisplayplayers[0]]].spectator) { fixed_t scale = 3*mobj->target->scale; @@ -7302,7 +7302,7 @@ void P_MobjThinker(mobj_t *mobj) mobj->x = mobj->target->x; mobj->y = mobj->target->y; - if (!splitscreen && players[displayplayers[0]].mo) + if (!r_splitscreen && players[displayplayers[0]].mo) { scale = mobj->target->scale + FixedMul(FixedDiv(abs(P_AproxDistance(players[displayplayers[0]].mo->x-mobj->target->x, players[displayplayers[0]].mo->y-mobj->target->y)), RING_DIST), mobj->target->scale); @@ -8807,7 +8807,7 @@ void P_MobjThinker(mobj_t *mobj) } P_SetScale(mobj, (mobj->destscale = (5*mobj->target->destscale)>>2)); - if (!splitscreen /*&& rendermode != render_soft*/) + if (!r_splitscreen /*&& rendermode != render_soft*/) { angle_t viewingangle; statenum_t curstate = ((mobj->tics == 1) ? (mobj->state->nextstate) : ((statenum_t)(mobj->state-states))); @@ -11136,13 +11136,13 @@ void P_PrecipitationEffects(void) // Local effects from here on out! // If we're not in game fully yet, we don't worry about them. - if (!playeringame[displayplayers[0]] || !players[displayplayers[0]].mo) + if (!playeringame[displayplayers[localdisplayplayers[0]]] || !players[displayplayers[localdisplayplayers[0]]].mo) return; if (sound_disabled) return; // Sound off? D'aw, no fun. - if (players[displayplayers[0]].mo->subsector->sector->ceilingpic == skyflatnum) + if (players[displayplayers[localdisplayplayers[0]]].mo->subsector->sector->ceilingpic == skyflatnum) volume = 255; // Sky above? We get it full blast. else { @@ -11150,17 +11150,17 @@ void P_PrecipitationEffects(void) fixed_t closedist, newdist; // Essentially check in a 1024 unit radius of the player for an outdoor area. - yl = players[displayplayers[0]].mo->y - 1024*FRACUNIT; - yh = players[displayplayers[0]].mo->y + 1024*FRACUNIT; - xl = players[displayplayers[0]].mo->x - 1024*FRACUNIT; - xh = players[displayplayers[0]].mo->x + 1024*FRACUNIT; + yl = players[displayplayers[localdisplayplayers[0]]].mo->y - 1024*FRACUNIT; + yh = players[displayplayers[localdisplayplayers[0]]].mo->y + 1024*FRACUNIT; + xl = players[displayplayers[localdisplayplayers[0]]].mo->x - 1024*FRACUNIT; + xh = players[displayplayers[localdisplayplayers[0]]].mo->x + 1024*FRACUNIT; closedist = 2048*FRACUNIT; for (y = yl; y <= yh; y += FRACUNIT*64) for (x = xl; x <= xh; x += FRACUNIT*64) { if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) // Found the outdoors! { - newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, x, y, 0); + newdist = S_CalculateSoundDistance(players[displayplayers[localdisplayplayers[0]]].mo->x, players[displayplayers[localdisplayplayers[0]]].mo->y, 0, x, y, 0); if (newdist < closedist) closedist = newdist; } @@ -11175,7 +11175,7 @@ void P_PrecipitationEffects(void) volume = 255; if (sounds_rain && (!leveltime || leveltime % 80 == 1)) - S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_rainin, volume); + S_StartSoundAtVolume(players[displayplayers[localdisplayplayers[0]]].mo, sfx_rainin, volume); if (!sounds_thunder) return; @@ -11183,7 +11183,7 @@ void P_PrecipitationEffects(void) if (effects_lightning && lightningStrike && volume) { // Large, close thunder sounds to go with our lightning. - S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_litng1 + M_RandomKey(4), volume); + S_StartSoundAtVolume(players[displayplayers[localdisplayplayers[0]]].mo, sfx_litng1 + M_RandomKey(4), volume); } else if (thunderchance < 20) { @@ -11191,7 +11191,7 @@ void P_PrecipitationEffects(void) if (volume < 80) volume = 80; - S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_athun1 + M_RandomKey(2), volume); + S_StartSoundAtVolume(players[displayplayers[localdisplayplayers[0]]].mo, sfx_athun1 + M_RandomKey(2), volume); } } @@ -11525,9 +11525,9 @@ void P_AfterPlayerSpawn(INT32 playernum) if (playernum == consoleplayer) localangle[0] = mobj->angle; - else if (splitscreen) + else if (r_splitscreen) { - for (i = 1; i <= splitscreen; i++) + for (i = 1; i <= r_splitscreen; i++) { if (playernum == displayplayers[i]) { @@ -11557,7 +11557,7 @@ void P_AfterPlayerSpawn(INT32 playernum) SV_SpawnPlayer(playernum, mobj->x, mobj->y, mobj->angle); - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (camera[i].chase) { diff --git a/src/p_setup.c b/src/p_setup.c index 5acc72746..491127d5b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2567,29 +2567,29 @@ static void P_ForceCharacter(const char *forcecharskin) { if (splitscreen) { - SetPlayerSkin(displayplayers[1], forcecharskin); - if ((unsigned)cv_playercolor2.value != skins[players[displayplayers[1]].skin].prefcolor && !modeattacking) + SetPlayerSkin(displayplayers[localdisplayplayers[1]], forcecharskin); + if ((unsigned)cv_playercolor2.value != skins[players[displayplayers[localdisplayplayers[1]]].skin].prefcolor && !modeattacking) { - CV_StealthSetValue(&cv_playercolor2, skins[players[displayplayers[1]].skin].prefcolor); - players[displayplayers[1]].skincolor = skins[players[displayplayers[1]].skin].prefcolor; + CV_StealthSetValue(&cv_playercolor2, skins[players[displayplayers[localdisplayplayers[1]]].skin].prefcolor); + players[displayplayers[localdisplayplayers[1]]].skincolor = skins[players[displayplayers[localdisplayplayers[1]]].skin].prefcolor; } if (splitscreen > 1) { - SetPlayerSkin(displayplayers[2], forcecharskin); - if ((unsigned)cv_playercolor3.value != skins[players[displayplayers[2]].skin].prefcolor && !modeattacking) + SetPlayerSkin(displayplayers[localdisplayplayers[2]], forcecharskin); + if ((unsigned)cv_playercolor3.value != skins[players[displayplayers[localdisplayplayers[2]]].skin].prefcolor && !modeattacking) { - CV_StealthSetValue(&cv_playercolor3, skins[players[displayplayers[2]].skin].prefcolor); - players[displayplayers[2]].skincolor = skins[players[displayplayers[2]].skin].prefcolor; + CV_StealthSetValue(&cv_playercolor3, skins[players[displayplayers[localdisplayplayers[2]]].skin].prefcolor); + players[displayplayers[localdisplayplayers[2]]].skincolor = skins[players[displayplayers[localdisplayplayers[2]]].skin].prefcolor; } if (splitscreen > 2) { - SetPlayerSkin(displayplayers[3], forcecharskin); - if ((unsigned)cv_playercolor4.value != skins[players[displayplayers[3]].skin].prefcolor && !modeattacking) + SetPlayerSkin(displayplayers[localdisplayplayers[3]], forcecharskin); + if ((unsigned)cv_playercolor4.value != skins[players[displayplayers[localdisplayplayers[3]]].skin].prefcolor && !modeattacking) { - CV_StealthSetValue(&cv_playercolor4, skins[players[displayplayers[3]].skin].prefcolor); - players[displayplayers[3]].skincolor = skins[players[displayplayers[3]].skin].prefcolor; + CV_StealthSetValue(&cv_playercolor4, skins[players[displayplayers[localdisplayplayers[3]]].skin].prefcolor); + players[displayplayers[localdisplayplayers[3]]].skincolor = skins[players[displayplayers[localdisplayplayers[3]]].skin].prefcolor; } } } @@ -2824,7 +2824,7 @@ boolean P_SetupLevel(boolean skipprecip) P_LevelInitStuff(); - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) postimgtype[i] = postimg_none; if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0') @@ -3228,7 +3228,7 @@ boolean P_SetupLevel(boolean skipprecip) if (!dedicated) { - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) P_SetupCamera(displayplayers[i], &camera[i]); // Salt: CV_ClearChangedFlags() messes with your settings :( @@ -3270,7 +3270,7 @@ boolean P_SetupLevel(boolean skipprecip) /*if (rendermode != render_none) CV_Set(&cv_fov, cv_fov.defaultvalue);*/ - displayplayers[0] = consoleplayer; // Start with your OWN view, please! + displayplayers[localdisplayplayers[0]] = consoleplayer; // Start with your OWN view, please! } /*if (cv_useranalog.value) diff --git a/src/p_spec.c b/src/p_spec.c index 93e88e2ce..e62f1410c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2386,7 +2386,7 @@ 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 P_TeleportMove(bot, bot->x + x, bot->y + y, bot->z + z); - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (mo->player == &players[displayplayers[i]] && camera[i].chase) { diff --git a/src/p_telept.c b/src/p_telept.c index 74f9d462c..8c2f8ed70 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -66,9 +66,9 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, // absolute angle position if (thing == players[consoleplayer].mo) localangle[0] = angle; - else if (splitscreen) + else if (r_splitscreen) { - for (i = 1; i <= splitscreen; i++) + for (i = 1; i <= r_splitscreen; i++) { if (thing == players[displayplayers[i]].mo) { @@ -79,7 +79,7 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, } // move chasecam at new player location - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (thing->player == &players[displayplayers[i]] && camera[i].chase) P_ResetCamera(thing->player, &camera[i]); @@ -151,9 +151,9 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle // absolute angle position if (thing == players[consoleplayer].mo) localangle[0] = angle; - else if (splitscreen) + else if (r_splitscreen) { - for (i = 1; i <= splitscreen; i++) + for (i = 1; i <= r_splitscreen; i++) { if (thing == players[displayplayers[i]].mo) { @@ -164,7 +164,7 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle } // move chasecam at new player location - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (thing->player == &players[displayplayers[i]] && camera[i].chase) P_ResetCamera(thing->player, &camera[i]); diff --git a/src/p_tick.c b/src/p_tick.c index b285c35d0..a5214a5ab 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -601,7 +601,7 @@ void P_Ticker(boolean run) return; } - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) postimgtype[i] = postimg_none; P_MapStart(); @@ -751,7 +751,7 @@ void P_Ticker(boolean run) } // Always move the camera. - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (camera[i].chase) P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); @@ -771,7 +771,7 @@ void P_PreTicker(INT32 frames) INT32 i,framecnt; ticcmd_t temptic; - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) postimgtype[i] = postimg_none; for (framecnt = 0; framecnt < frames; ++framecnt) diff --git a/src/p_user.c b/src/p_user.c index 8185667a0..bb9eae095 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1122,12 +1122,12 @@ boolean P_EndingMusic(player_t *player) // Event - Level Finish // Check for if this is valid or not - if (splitscreen) + if (r_splitscreen) { if (!((players[displayplayers[0]].exiting || (players[displayplayers[0]].pflags & PF_TIMEOVER)) || (players[displayplayers[1]].exiting || (players[displayplayers[1]].pflags & PF_TIMEOVER)) - || ((splitscreen < 2) && (players[displayplayers[2]].exiting || (players[displayplayers[2]].pflags & PF_TIMEOVER))) - || ((splitscreen < 3) && (players[displayplayers[3]].exiting || (players[displayplayers[3]].pflags & PF_TIMEOVER))))) + || ((r_splitscreen < 2) && (players[displayplayers[2]].exiting || (players[displayplayers[2]].pflags & PF_TIMEOVER))) + || ((r_splitscreen < 3) && (players[displayplayers[3]].exiting || (players[displayplayers[3]].pflags & PF_TIMEOVER))))) return false; bestlocalplayer = &players[displayplayers[0]]; @@ -1139,9 +1139,9 @@ boolean P_EndingMusic(player_t *player) bestlocalpos = ((players[p].pflags & PF_TIMEOVER) ? MAXPLAYERS+1 : players[p].kartstuff[k_position]); \ } setbests(displayplayers[1]); - if (splitscreen > 1) + if (r_splitscreen > 1) setbests(displayplayers[2]); - if (splitscreen > 2) + if (r_splitscreen > 2) setbests(displayplayers[3]); #undef setbests } @@ -1211,7 +1211,7 @@ void P_RestoreMusic(player_t *player) { INT32 wantedmus = 0; // 0 is level music, 1 is invincibility, 2 is grow - if (splitscreen) + if (r_splitscreen) { INT32 bestlocaltimer = 1; @@ -1225,9 +1225,9 @@ void P_RestoreMusic(player_t *player) } setbests(displayplayers[0]); setbests(displayplayers[1]); - if (splitscreen > 1) + if (r_splitscreen > 1) setbests(displayplayers[2]); - if (splitscreen > 2) + if (r_splitscreen > 2) setbests(displayplayers[3]); #undef setbests } @@ -1490,9 +1490,9 @@ boolean P_IsLocalPlayer(player_t *player) if (player == &players[consoleplayer]) return true; - else if (splitscreen) + else if (r_splitscreen) { - for (i = 1; i <= splitscreen; i++) // Skip P1 + for (i = 1; i <= r_splitscreen; i++) // Skip P1 { if (player == &players[displayplayers[i]]) return true; @@ -1512,7 +1512,7 @@ boolean P_IsDisplayPlayer(player_t *player) { UINT8 i; - for (i = 0; i <= splitscreen; i++) // DON'T skip P1 + for (i = 0; i <= r_splitscreen; i++) // DON'T skip P1 { if (player == &players[displayplayers[i]]) return true; @@ -7913,7 +7913,7 @@ static void P_CalcPostImg(player_t *player) pviewheight = player->awayviewmobj->z + 20*FRACUNIT; } - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (player == &players[displayplayers[i]]) { @@ -8078,7 +8078,7 @@ void P_PlayerThink(player_t *player) } #ifdef SEENAMES - if (netgame && player == &players[displayplayers[0]] && !(leveltime % (TICRATE/5)) && !splitscreen) + if (netgame && player == &players[displayplayers[0]] && !(leveltime % (TICRATE/5)) && !r_splitscreen) { seenplayer = NULL; @@ -8434,7 +8434,7 @@ void P_PlayerThink(player_t *player) // Hide the mobj from our sights if we're the displayplayer and chasecam is off. // Why not just not spawn the mobj? Well, I'd rather only flirt with // consistency so much... - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (player == &players[displayplayers[i]] && !camera[i].chase) { @@ -8664,7 +8664,7 @@ void P_PlayerAfterThink(player_t *player) P_PlayerInSpecialSector(player); #endif - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (player == &players[displayplayers[i]]) { diff --git a/src/r_bsp.c b/src/r_bsp.c index 296cbbe87..d7641838e 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -254,7 +254,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, boolean underwater; UINT8 i; - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (viewplayer == &players[displayplayers[i]] && camera[i].chase) { @@ -263,7 +263,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, } } - if (i > splitscreen && viewmobj) + if (i > r_splitscreen && viewmobj) heightsec = R_PointInSubsector(viewmobj->x, viewmobj->y)->sector->heightsec; else return sec; diff --git a/src/r_draw.c b/src/r_draw.c index 1931ce6ee..70e487342 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -299,7 +299,7 @@ void R_InitViewBuffer(INT32 width, INT32 height) for (i = 0; i < height; i++) { ylookup[i] = ylookup1[i] = screens[0] + i*vid.width*bytesperpixel; - if (splitscreen == 1) + if (r_splitscreen == 1) ylookup2[i] = screens[0] + (i+viewheight)*vid.width*bytesperpixel; else ylookup2[i] = screens[0] + i*vid.width*bytesperpixel + (viewwidth*bytesperpixel); diff --git a/src/r_main.c b/src/r_main.c index 0d14bed73..cf16802cb 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -73,6 +73,8 @@ boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisibl sector_t *viewsector; player_t *viewplayer; +int r_splitscreen; + // PORTALS! // You can thank and/or curse JTE for these. UINT8 portalrender; @@ -192,6 +194,12 @@ void SplitScreen_OnChange(void) { UINT8 i; + /* + local splitscreen is updated before you're in a game, + so this is the first value for renderer splitscreen + */ + r_splitscreen = splitscreen; + // recompute screen size R_ExecuteSetViewSize(); @@ -659,12 +667,12 @@ void R_ExecuteSetViewSize(void) scaledviewwidth = vid.width; viewheight = vid.height; - if (splitscreen) + if (r_splitscreen) viewheight >>= 1; viewwidth = scaledviewwidth; - if (splitscreen > 1) + if (r_splitscreen > 1) { viewwidth >>= 1; scaledviewwidth >>= 1; @@ -677,7 +685,7 @@ void R_ExecuteSetViewSize(void) fov = FixedAngle(cv_fov.value/2) + ANGLE_90; fovtan = FINETANGENT(fov >> ANGLETOFINESHIFT); - if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view + if (r_splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view fovtan = 17*fovtan/10; projection = projectiony = FixedDiv(centerxfrac, fovtan); @@ -848,9 +856,9 @@ void R_SkyboxFrame(player_t *player) camera_t *thiscam = &camera[0]; UINT8 i; - if (splitscreen) + if (r_splitscreen) { - for (i = 1; i <= splitscreen; i++) + for (i = 1; i <= r_splitscreen; i++) { if (player == &players[displayplayers[i]]) { @@ -891,9 +899,9 @@ void R_SkyboxFrame(player_t *player) viewangle = localangle[0]; // WARNING: camera uses this aimingangle = localaiming[0]; } - else if (splitscreen) + else if (r_splitscreen) { - for (i = 1; i <= splitscreen; i++) + for (i = 1; i <= r_splitscreen; i++) { if (player == &players[displayplayers[i]]) { @@ -1080,17 +1088,17 @@ void R_SetupFrame(player_t *player, boolean skybox) camera_t *thiscam; boolean chasecam = false; - if (splitscreen > 2 && player == &players[displayplayers[3]]) + if (r_splitscreen > 2 && player == &players[displayplayers[3]]) { thiscam = &camera[3]; chasecam = (cv_chasecam4.value != 0); } - else if (splitscreen > 1 && player == &players[displayplayers[2]]) + else if (r_splitscreen > 1 && player == &players[displayplayers[2]]) { thiscam = &camera[2]; chasecam = (cv_chasecam3.value != 0); } - else if (splitscreen && player == &players[displayplayers[1]]) + else if (r_splitscreen && player == &players[displayplayers[1]]) { thiscam = &camera[1]; chasecam = (cv_chasecam2.value != 0); @@ -1150,10 +1158,10 @@ void R_SetupFrame(player_t *player, boolean skybox) viewangle = localangle[0]; // WARNING: camera uses this aimingangle = localaiming[0]; } - else if (splitscreen) + else if (r_splitscreen) { UINT8 i; - for (i = 1; i <= splitscreen; i++) + for (i = 1; i <= r_splitscreen; i++) { if (player == &players[displayplayers[i]]) { @@ -1334,7 +1342,7 @@ void R_RenderPlayerView(player_t *player) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 32+(timeinmap&15)); } // Draw over the fourth screen so you don't have to stare at a HOM :V - else if (splitscreen == 2 && player == &players[displayplayers[2]]) + else if (r_splitscreen == 2 && player == &players[displayplayers[2]]) #if 1 { // V_DrawPatchFill, but for the fourth screen only @@ -1353,7 +1361,7 @@ void R_RenderPlayerView(player_t *player) #endif // load previous saved value of skyVisible for the player - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (player == &players[displayplayers[i]]) { @@ -1463,7 +1471,7 @@ void R_RenderPlayerView(player_t *player) // save value to skyVisiblePerPlayer // this is so that P1 can't affect whether P2 can see a skybox or not, or vice versa - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { if (player == &players[displayplayers[i]]) { diff --git a/src/r_plane.c b/src/r_plane.c index ec105bf75..08a449e6c 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -883,12 +883,12 @@ void R_DrawSinglePlane(visplane_t *pl) if (bottom > vid.height) bottom = vid.height; - if (splitscreen > 2 && viewplayer == &players[displayplayers[3]]) // Only copy the part of the screen we need + if (r_splitscreen > 2 && viewplayer == &players[displayplayers[3]]) // Only copy the part of the screen we need scr = (screens[0] + (top+(viewheight))*vid.width + viewwidth); - else if ((splitscreen == 1 && viewplayer == &players[displayplayers[1]]) - || (splitscreen > 1 && viewplayer == &players[displayplayers[2]])) + else if ((r_splitscreen == 1 && viewplayer == &players[displayplayers[1]]) + || (r_splitscreen > 1 && viewplayer == &players[displayplayers[2]])) scr = (screens[0] + (top+(viewheight))*vid.width); - else if (splitscreen > 1 && viewplayer == &players[displayplayers[1]]) + else if (r_splitscreen > 1 && viewplayer == &players[displayplayers[1]]) scr = (screens[0] + ((top)*vid.width) + viewwidth); else scr = (screens[0] + ((top)*vid.width)); diff --git a/src/r_sky.c b/src/r_sky.c index 1fe0fe0e6..3904eba3a 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -81,7 +81,7 @@ void R_SetSkyScale(void) { fixed_t difference = vid.fdupx-(vid.dupx< 1) + if (r_splitscreen > 1) scr *= 2; skyscale = FixedDiv(scr, vid.fdupx+difference); } diff --git a/src/r_things.c b/src/r_things.c index 1afbb125c..239c9def0 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1761,7 +1761,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) continue; - if (splitscreen) + if (r_splitscreen) { if (thing->eflags & MFE_DRAWONLYFORP1) if (viewssnum != 0) @@ -1771,11 +1771,11 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) if (viewssnum != 1) continue; - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) + if (thing->eflags & MFE_DRAWONLYFORP3 && r_splitscreen > 1) if (viewssnum != 2) continue; - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) + if (thing->eflags & MFE_DRAWONLYFORP4 && r_splitscreen > 2) if (viewssnum != 3) continue; } @@ -1796,7 +1796,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) continue; - if (splitscreen) + if (r_splitscreen) { if (thing->eflags & MFE_DRAWONLYFORP1) if (viewssnum != 0) @@ -1806,11 +1806,11 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) if (viewssnum != 1) continue; - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) + if (thing->eflags & MFE_DRAWONLYFORP3 && r_splitscreen > 1) if (viewssnum != 2) continue; - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) + if (thing->eflags & MFE_DRAWONLYFORP4 && r_splitscreen > 2) if (viewssnum != 3) continue; } diff --git a/src/s_sound.c b/src/s_sound.c index 21b668f28..82435d3dc 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -457,19 +457,19 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) if (players[displayplayers[0]].awayviewtics) listenmobj = players[displayplayers[0]].awayviewmobj; - if (splitscreen) + if (r_splitscreen) { listenmobj2 = players[displayplayers[1]].mo; if (players[displayplayers[1]].awayviewtics) listenmobj2 = players[displayplayers[1]].awayviewmobj; - if (splitscreen > 1) + if (r_splitscreen > 1) { listenmobj3 = players[displayplayers[2]].mo; if (players[displayplayers[2]].awayviewtics) listenmobj3 = players[displayplayers[2]].awayviewmobj; - if (splitscreen > 2) + if (r_splitscreen > 2) { listenmobj4 = players[displayplayers[3]].mo; if (players[displayplayers[3]].awayviewtics) @@ -574,10 +574,10 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) pitch = NORM_PITCH; priority = NORM_PRIORITY; - if (splitscreen && origin) - volume = FixedDiv(volume<>FRACBITS; + if (r_splitscreen && origin) + volume = FixedDiv(volume<>FRACBITS; - if (splitscreen && listenmobj2) // Copy the sound for the split player + if (r_splitscreen && listenmobj2) // Copy the sound for the split player { // Check to see if it is audible, and if not, modify the params if (origin && origin != listenmobj2) @@ -633,7 +633,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) dontplay: - if (splitscreen > 1 && listenmobj3) // Copy the sound for the third player + if (r_splitscreen > 1 && listenmobj3) // Copy the sound for the third player { // Check to see if it is audible, and if not, modify the params if (origin && origin != listenmobj3) @@ -689,7 +689,7 @@ dontplay: dontplay3: - if (splitscreen > 2 && listenmobj4) // Copy the sound for the split player + if (r_splitscreen > 2 && listenmobj4) // Copy the sound for the split player { // Check to see if it is audible, and if not, modify the params if (origin && origin != listenmobj4) @@ -942,19 +942,19 @@ void S_UpdateSounds(void) if (players[displayplayers[0]].awayviewtics) listenmobj = players[displayplayers[0]].awayviewmobj; - if (splitscreen) + if (r_splitscreen) { listenmobj2 = players[displayplayers[1]].mo; if (players[displayplayers[1]].awayviewtics) listenmobj2 = players[displayplayers[1]].awayviewmobj; - if (splitscreen > 1) + if (r_splitscreen > 1) { listenmobj3 = players[displayplayers[2]].mo; if (players[displayplayers[2]].awayviewtics) listenmobj3 = players[displayplayers[2]].awayviewmobj; - if (splitscreen > 2) + if (r_splitscreen > 2) { listenmobj4 = players[displayplayers[3]].mo; if (players[displayplayers[3]].awayviewtics) @@ -1058,24 +1058,24 @@ void S_UpdateSounds(void) pitch = NORM_PITCH; sep = NORM_SEP; - if (splitscreen && c->origin) - volume = FixedDiv(volume<>FRACBITS; + if (r_splitscreen && c->origin) + volume = FixedDiv(volume<>FRACBITS; // check non-local sounds for distance clipping // or modify their params - if (c->origin && ((c->origin != players[consoleplayer].mo) - || (splitscreen && c->origin != players[displayplayers[1]].mo) - || (splitscreen > 1 && c->origin != players[displayplayers[2]].mo) - || (splitscreen > 2 && c->origin != players[displayplayers[3]].mo))) + if (c->origin && ((c->origin != players[displayplayers[0]].mo) + || (r_splitscreen && c->origin != players[displayplayers[1]].mo) + || (r_splitscreen > 1 && c->origin != players[displayplayers[2]].mo) + || (r_splitscreen > 2 && c->origin != players[displayplayers[3]].mo))) { // Whomever is closer gets the sound, but only in splitscreen. - if (splitscreen) + if (r_splitscreen) { const mobj_t *soundmobj = c->origin; fixed_t recdist = -1; INT32 i, p = -1; - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { fixed_t thisdist = -1; @@ -1130,7 +1130,7 @@ void S_UpdateSounds(void) S_StopChannel(cnum); } } - else if (listenmobj && !splitscreen) + else if (listenmobj && !r_splitscreen) { // In the case of a single player, he or she always should get updated sound. audible = S_AdjustSoundParams(listenmobj, c->origin, &volume, &sep, &pitch, @@ -1258,21 +1258,21 @@ INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *v listensource.z = camera[0].z; listensource.angle = camera[0].angle; } - else if (splitscreen && listener == players[displayplayers[1]].mo && camera[1].chase) + else if (r_splitscreen && listener == players[displayplayers[1]].mo && camera[1].chase) { listensource.x = camera[1].x; listensource.y = camera[1].y; listensource.z = camera[1].z; listensource.angle = camera[1].angle; } - else if (splitscreen > 1 && listener == players[displayplayers[2]].mo && camera[2].chase) + else if (r_splitscreen > 1 && listener == players[displayplayers[2]].mo && camera[2].chase) { listensource.x = camera[2].x; listensource.y = camera[2].y; listensource.z = camera[2].z; listensource.angle = camera[2].angle; } - else if (splitscreen > 2 && listener == players[displayplayers[3]].mo && camera[3].chase) + else if (r_splitscreen > 2 && listener == players[displayplayers[3]].mo && camera[3].chase) { listensource.x = camera[3].x; listensource.y = camera[3].y; @@ -1372,8 +1372,8 @@ INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *v *vol = (15 * ((S_CLIPPING_DIST - approx_dist)>>FRACBITS)) / S_ATTENUATOR; } - if (splitscreen) - *vol = FixedDiv((*vol)<>FRACBITS; + if (r_splitscreen) + *vol = FixedDiv((*vol)<>FRACBITS; return (*vol > 0); } diff --git a/src/st_stuff.c b/src/st_stuff.c index caed81f3e..280984ca7 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -230,7 +230,7 @@ void ST_doPaletteStuff(void) if (rendermode != render_none) { //V_SetPaletteLump(GetPalette()); // Reset the palette -- is this needed? - if (!splitscreen) + if (!r_splitscreen) V_SetPalette(palette); } } @@ -515,9 +515,9 @@ static INT32 SCR(INT32 r) #define ST_DrawNumFromHud(h,n) V_DrawTallNum(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART|V_HUDTRANS, n) #define ST_DrawPadNumFromHud(h,n,q) V_DrawPaddedTallNum(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART|V_HUDTRANS, n, q) #define ST_DrawPatchFromHud(h,p) V_DrawScaledPatch(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART|V_HUDTRANS, p) -#define ST_DrawNumFromHudWS(h,n) V_DrawTallNum(SCX(hudinfo[h+!!splitscreen].x), SCY(hudinfo[h+!!splitscreen].y), V_NOSCALESTART|V_HUDTRANS, n) -#define ST_DrawPadNumFromHudWS(h,n,q) V_DrawPaddedTallNum(SCX(hudinfo[h+!!splitscreen].x), SCY(hudinfo[h+!!splitscreen].y), V_NOSCALESTART|V_HUDTRANS, n, q) -#define ST_DrawPatchFromHudWS(h,p) V_DrawScaledPatch(SCX(hudinfo[h+!!splitscreen].x), SCY(hudinfo[h+!!splitscreen].y), V_NOSCALESTART|V_HUDTRANS, p) +#define ST_DrawNumFromHudWS(h,n) V_DrawTallNum(SCX(hudinfo[h+!!r_splitscreen].x), SCY(hudinfo[h+!!r_splitscreen].y), V_NOSCALESTART|V_HUDTRANS, n) +#define ST_DrawPadNumFromHudWS(h,n,q) V_DrawPaddedTallNum(SCX(hudinfo[h+!!r_splitscreen].x), SCY(hudinfo[h+!!r_splitscreen].y), V_NOSCALESTART|V_HUDTRANS, n, q) +#define ST_DrawPatchFromHudWS(h,p) V_DrawScaledPatch(SCX(hudinfo[h+!!r_splitscreen].x), SCY(hudinfo[h+!!r_splitscreen].y), V_NOSCALESTART|V_HUDTRANS, p) /* // Draw a number, scaled, over the view, maybe with set translucency @@ -757,7 +757,7 @@ static void ST_drawLevelTitle(void) INT32 dupcalc = (vid.width/vid.dupx); UINT8 gtc = G_GetGametypeColor(gametype); INT32 sub = 0; - INT32 bary = (splitscreen) + INT32 bary = (r_splitscreen) ? BASEVIDHEIGHT/2 : 163; INT32 lvlw; @@ -1910,12 +1910,12 @@ static void ST_overlayDrawer(void) else if (!demo.title) { - if (!splitscreen) + if (!r_splitscreen) { V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-40, V_HUDTRANSHALF, M_GetText("Viewpoint:")); V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_HUDTRANSHALF|V_ALLOWLOWERCASE, player_names[stplyr-players]); } - else if (splitscreen == 1) + else if (r_splitscreen == 1) { char name[MAXPLAYERNAME+12]; @@ -1923,7 +1923,7 @@ static void ST_overlayDrawer(void) 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); } - else if (splitscreen) + else if (r_splitscreen) { V_DrawCenteredThinString((vid.width/vid.dupx)/4, BASEVIDHEIGHT/2 - 12, V_HUDTRANSHALF|V_ALLOWLOWERCASE|K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT), player_names[stplyr-players]); } @@ -1998,7 +1998,7 @@ static void ST_overlayDrawer(void) } // SRB2kart: changed positions & text - if (splitscreen) + if (r_splitscreen) { INT32 splitflags = K_calcSplitFlags(0); V_DrawThinString(2, (BASEVIDHEIGHT/2)-20, V_YELLOWMAP|V_HUDTRANSHALF|splitflags, M_GetText("- SPECTATING -")); @@ -2089,7 +2089,7 @@ void ST_Drawer(void) UINT8 i; #ifdef SEENAMES - if (cv_seenames.value && cv_allowseenames.value && displayplayers[0] == consoleplayer && seenplayer && seenplayer->mo && !mapreset) + if (cv_seenames.value && cv_allowseenames.value && displayplayers[localdisplayplayers[0]] == consoleplayer && seenplayer && seenplayer->mo && !mapreset) { if (cv_seenames.value == 1) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, player_names[seenplayer-players]); @@ -2123,7 +2123,7 @@ void ST_Drawer(void) if (st_overlay) { // No deadview! - for (i = 0; i <= splitscreen; i++) + for (i = 0; i <= r_splitscreen; i++) { stplyr = &players[displayplayers[i]]; ST_overlayDrawer(); diff --git a/src/v_video.c b/src/v_video.c index 297eae9c4..55e8e7b90 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2503,15 +2503,15 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) return; #endif - if (view < 0 || view > 3 || view > splitscreen) + if (view < 0 || view > 3 || view > r_splitscreen) return; - if ((view == 1 && splitscreen == 1) || view >= 2) + if ((view == 1 && r_splitscreen == 1) || view >= 2) yoffset = viewheight; else yoffset = 0; - if ((view == 1 || view == 3) && splitscreen > 1) + if ((view == 1 || view == 3) && r_splitscreen > 1) xoffset = viewwidth; else xoffset = 0; diff --git a/src/y_inter.c b/src/y_inter.c index f5380d565..e27289b87 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -366,7 +366,7 @@ void Y_IntermissionDrawer(void) if (usebuffer) // Fade everything out V_DrawFadeScreen(0xFF00, 22); - if (!splitscreen) + if (!r_splitscreen) whiteplayer = demo.playback ? displayplayers[0] : consoleplayer; if (cons_menuhighlight.value) @@ -1263,19 +1263,19 @@ void Y_VoteDrawer(void) { case 1: thiscurs = cursor2; - p = displayplayers[1]; + p = displayplayers[localdisplayplayers[1]]; break; case 2: thiscurs = cursor3; - p = displayplayers[2]; + p = displayplayers[localdisplayplayers[2]]; break; case 3: thiscurs = cursor4; - p = displayplayers[3]; + p = displayplayers[localdisplayplayers[3]]; break; default: thiscurs = cursor1; - p = displayplayers[0]; + p = displayplayers[localdisplayplayers[0]]; break; } @@ -1563,13 +1563,13 @@ void Y_VoteTicker(void) switch (i) { case 1: - p = displayplayers[1]; + p = displayplayers[localdisplayplayers[1]]; break; case 2: - p = displayplayers[2]; + p = displayplayers[localdisplayplayers[2]]; break; case 3: - p = displayplayers[3]; + p = displayplayers[localdisplayplayers[3]]; break; default: p = consoleplayer; From 46ac563eaf50c3e287d6e64a93da0c78052658b3 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 22 Feb 2020 03:15:44 -0800 Subject: [PATCH 02/36] Implement big bad parties (splitscreen with network players) Use the 'invite' command to invite another player to your party. If that player accepts, via the 'acceptinvite' command, they and any splitscreen players on their machine will be added after the players in your party. They may also use the 'rejectinvite' command. Use the 'leaveparty' command to leave a party. You and any splitscreen players on your machine will be removed from the party. Players after you will be shifted to take your place on the splitscreen. --- src/Makefile | 1 + src/d_clisrv.c | 58 +++++++++++- src/d_clisrv.h | 10 ++ src/d_netcmd.c | 217 +++++++++++++++++++++++++++++++++++++++++++- src/d_netcmd.h | 7 +- src/doomdef.h | 1 + src/doomstat.h | 13 ++- src/g_game.h | 3 + src/g_splitscreen.c | 209 ++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 513 insertions(+), 6 deletions(-) create mode 100644 src/g_splitscreen.c diff --git a/src/Makefile b/src/Makefile index fee849d6c..d0e66e269 100644 --- a/src/Makefile +++ b/src/Makefile @@ -487,6 +487,7 @@ OBJS:=$(i_main_o) \ $(OBJDIR)/f_wipe.o \ $(OBJDIR)/g_game.o \ $(OBJDIR)/g_input.o \ + $(OBJDIR)/g_splitscreen.o\ $(OBJDIR)/am_map.o \ $(OBJDIR)/command.o \ $(OBJDIR)/console.o \ diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a53a61cf0..b397c83ae 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -84,6 +84,8 @@ static boolean serverrunning = false; INT32 serverplayer = 0; char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support) +int playerconsole[MAXPLAYERS]; + // Server specific vars UINT8 playernode[MAXPLAYERS]; @@ -1505,6 +1507,8 @@ static boolean SV_SendServerConfig(INT32 node) UINT8 *p, *op; boolean waspacketsent; + memset(&netbuffer->u.servercfg, 0, sizeof netbuffer->u.servercfg); + netbuffer->packettype = PT_SERVERCFG; netbuffer->u.servercfg.version = VERSION; @@ -1524,7 +1528,6 @@ static boolean SV_SendServerConfig(INT32 node) memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor)); memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers)); - memset(netbuffer->u.servercfg.powerlevels, 0, sizeof(netbuffer->u.servercfg.powerlevels)); for (i = 0; i < MAXPLAYERS; i++) { @@ -1535,6 +1538,19 @@ static boolean SV_SendServerConfig(INT32 node) if (!playeringame[i]) continue; + netbuffer->u.servercfg.consoleplayers[i] = playerconsole[i]; + netbuffer->u.servercfg.invitations[i] = splitscreen_invitations[i]; + netbuffer->u.servercfg.party_size[i] = splitscreen_party_size[i]; + netbuffer->u.servercfg.original_party_size[i] = + splitscreen_original_party_size[i]; + + for (j = 0; j < MAXSPLITSCREENPLAYERS; ++j) + { + netbuffer->u.servercfg.party[i][j] = splitscreen_party[i][j]; + netbuffer->u.servercfg.original_party[i][j] = + splitscreen_original_party[i][j]; + } + netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; } @@ -2619,6 +2635,8 @@ static void ResetNode(INT32 node); // void CL_ClearPlayer(INT32 playernum) { + int i; + if (players[playernum].mo) { // Don't leave a NiGHTS ghost! @@ -2626,6 +2644,16 @@ void CL_ClearPlayer(INT32 playernum) P_RemoveMobj(players[playernum].mo->tracer); P_RemoveMobj(players[playernum].mo); } + + for (i = 0; i < MAXPLAYERS; ++i) + { + if (splitscreen_invitations[i] == playernum) + splitscreen_invitations[i] = -1; + } + + splitscreen_invitations[playernum] = -1; + splitscreen_partied[playernum] = false; + memset(&players[playernum], 0, sizeof (player_t)); } @@ -3351,6 +3379,7 @@ void SV_ResetServer(void) sprintf(player_names[i], "Player %d", i + 1); adminplayers[i] = -1; // Populate the entire adminplayers array with -1. K_ClearClientPowerLevels(); + splitscreen_invitations[i] = -1; } mynode = 0; @@ -3455,6 +3484,7 @@ static inline void SV_AddNode(INT32 node) static void Got_AddPlayer(UINT8 **p, INT32 playernum) { INT16 node, newplayernum; + int console; UINT8 splitscreenplayer = 0; UINT8 i; @@ -3475,6 +3505,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) node = (UINT8)READUINT8(*p); newplayernum = (UINT8)READUINT8(*p); + console = (UINT8)READUINT8(*p); splitscreenplayer = (UINT8)READUINT8(*p); CONS_Debug(DBG_NETPLAY, "addplayer: %d %d %d\n", node, newplayernum, splitscreenplayer); @@ -3507,6 +3538,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) displayplayers[i] = newplayernum; localdisplayplayers[i] = i; } + splitscreen_partied[newplayernum] = true; DEBFILE("spawning me\n"); } @@ -3516,6 +3548,12 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) players[newplayernum].splitscreenindex = splitscreenplayer; + playerconsole[newplayernum] = console; + splitscreen_original_party_size[console] = + ++splitscreen_party_size[console]; + splitscreen_original_party[console][splitscreenplayer] = + splitscreen_party[console][splitscreenplayer] = newplayernum; + if (netgame) { if (server && cv_showjoinaddress.value) @@ -3577,7 +3615,7 @@ static boolean SV_AddWaitingPlayers(void) // splitscreen can allow 2+ players in one node for (; nodewaiting[node] > 0; nodewaiting[node]--) { - UINT8 buf[3]; + UINT8 buf[4]; UINT8 *buf_p = buf; newplayer = true; @@ -3614,6 +3652,7 @@ static boolean SV_AddWaitingPlayers(void) else if (playerpernode[node] < 4) nodetoplayer4[node] = newplayernum; + WRITEUINT8(buf_p, nodetoplayer[node]); // consoleplayer WRITEUINT8(buf_p, playerpernode[node]); // splitscreen num playerpernode[node]++; @@ -4141,6 +4180,21 @@ static void HandlePacketFromAwayNode(SINT8 node) adminplayers[j] = netbuffer->u.servercfg.adminplayers[j]; for (k = 0; k < PWRLV_NUMTYPES; k++) clientpowerlevels[j][k] = netbuffer->u.servercfg.powerlevels[j][k]; + + /* all spitscreen related */ + playerconsole[j] = netbuffer->u.servercfg.consoleplayers[j]; + splitscreen_invitations[j] = netbuffer->u.servercfg.invitations[j]; + splitscreen_original_party_size[j] = + netbuffer->u.servercfg.original_party_size[j]; + splitscreen_party_size[j] = + netbuffer->u.servercfg.party_size[j]; + for (k = 0; k < MAXSPLITSCREENPLAYERS; ++k) + { + splitscreen_original_party[j][k] = + netbuffer->u.servercfg.original_party[j][k]; + splitscreen_party[j][k] = + netbuffer->u.servercfg.party[j][k]; + } } memcpy(server_context, netbuffer->u.servercfg.server_context, 8); } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 0bd85b614..c13df4f5e 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -328,6 +328,14 @@ typedef struct SINT8 adminplayers[MAXPLAYERS]; // Needs to be signed UINT16 powerlevels[MAXPLAYERS][PWRLV_NUMTYPES]; // SRB2kart: player power levels + UINT8 consoleplayers[MAXPLAYERS]; + /* splitscreen */ + SINT8 invitations[MAXPLAYERS]; + UINT8 party_size[MAXPLAYERS]; + UINT8 party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; + UINT8 original_party_size[MAXPLAYERS]; + UINT8 original_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; + char server_context[8]; // Unique context id, generated at server startup. UINT8 varlengthinputs[0]; // Playernames and netvars @@ -599,6 +607,8 @@ SINT8 nametonum(const char *name); extern char motd[254], server_context[8]; extern UINT8 playernode[MAXPLAYERS]; +/* consoleplayer of this player (splitscreen) */ +extern int playerconsole[MAXPLAYERS]; INT32 D_NumPlayers(void); void D_ResetTiccmds(void); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 334509389..51a4b822d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -63,6 +63,9 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum); static void Got_WeaponPref(UINT8 **cp, INT32 playernum); static void Got_PowerLevel(UINT8 **cp, INT32 playernum); +static void Got_PartyInvite(UINT8 **cp, INT32 playernum); +static void Got_AcceptPartyInvite(UINT8 **cp, INT32 playernum); +static void Got_LeaveParty(UINT8 **cp, INT32 playernum); static void Got_Mapcmd(UINT8 **cp, INT32 playernum); static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum); static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum); @@ -134,6 +137,11 @@ static void Command_ResetCamera_f(void); static void Command_View_f (void); static void Command_SetViews_f(void); +static void Command_Invite_f(void); +static void Command_AcceptInvite_f(void); +static void Command_RejectInvite_f(void); +static void Command_LeaveParty_f(void); + static void Command_Addfile(void); static void Command_ListWADS_f(void); #ifdef DELFILE @@ -544,6 +552,9 @@ void D_RegisterServerCommands(void) RegisterNetXCmd(XD_NAMEANDCOLOR, Got_NameAndColor); RegisterNetXCmd(XD_WEAPONPREF, Got_WeaponPref); RegisterNetXCmd(XD_POWERLEVEL, Got_PowerLevel); + RegisterNetXCmd(XD_PARTYINVITE, Got_PartyInvite); + RegisterNetXCmd(XD_ACCEPTPARTYINVITE, Got_AcceptPartyInvite); + RegisterNetXCmd(XD_LEAVEPARTY, Got_LeaveParty); RegisterNetXCmd(XD_MAP, Got_Mapcmd); RegisterNetXCmd(XD_EXITLEVEL, Got_ExitLevelcmd); RegisterNetXCmd(XD_ADDFILE, Got_Addfilecmd); @@ -753,6 +764,11 @@ void D_RegisterClientCommands(void) COM_AddCommand("changeteam3", Command_Teamchange3_f); COM_AddCommand("changeteam4", Command_Teamchange4_f); + COM_AddCommand("invite", Command_Invite_f); + COM_AddCommand("acceptinvite", Command_AcceptInvite_f); + COM_AddCommand("rejectinvite", Command_RejectInvite_f); + COM_AddCommand("leaveparty", Command_LeaveParty_f); + COM_AddCommand("playdemo", Command_Playdemo_f); COM_AddCommand("timedemo", Command_Timedemo_f); COM_AddCommand("stopdemo", Command_Stopdemo_f); @@ -1942,6 +1958,104 @@ static void Got_PowerLevel(UINT8 **cp,INT32 playernum) CONS_Debug(DBG_GAMELOGIC, "set player %d to power %d\n", playernum, race); } +static void Got_PartyInvite(UINT8 **cp,INT32 playernum) +{ + int invitee; + + boolean kick = false; + + invitee = READUINT8 (*cp); + + if ( + invitee >= 0 && + invitee < MAXPLAYERS && + playeringame[invitee] && + playerconsole[playernum] == playernum/* only consoleplayer may! */ + ){ + invitee = playerconsole[invitee]; + /* you cannot invite yourself or your computer */ + if (invitee == playernum) + kick = true; + } + else + kick = true; + + if (kick) + { + CONS_Alert(CONS_WARNING, M_GetText("Illegal splitscreen invitation received from %s\n"), player_names[playernum]); + if (server) + { + XBOXSTATIC UINT8 buf[2]; + + buf[0] = (UINT8)playernum; + buf[1] = KICK_MSG_CON_FAIL; + SendNetXCmd(XD_KICK, &buf, 2); + } + return; + } + + if (splitscreen_invitations[invitee] < 0) + { + splitscreen_invitations[invitee] = playernum; + + if (invitee == consoleplayer)/* hey that's me! */ + { + CONS_Printf( + "You have been invited to join %s", + player_names[playernum] + ); + if (splitscreen_party_size[playernum] > 1) + { + CONS_Printf( + " and %d others", + ( splitscreen_party_size[playernum] - 1 ) + ); + } + CONS_Printf(".\n"); + } + } +} + +static void Got_AcceptPartyInvite(UINT8 **cp,INT32 playernum) +{ + int invitation; + int old_party_size; + int views; + + if (playerconsole[playernum] != playernum) + { + CONS_Alert(CONS_WARNING, M_GetText("Illegal accept splitscreen invite received from %s\n"), player_names[playernum]); + if (server) + { + XBOXSTATIC UINT8 buf[2]; + + buf[0] = (UINT8)playernum; + buf[1] = KICK_MSG_CON_FAIL; + SendNetXCmd(XD_KICK, &buf, 2); + } + return; + } + + invitation = splitscreen_invitations[playernum]; + + if (invitation >= 0) + { + old_party_size = splitscreen_party_size[invitation]; + views = splitscreen_original_party_size[playernum]; + + if (( old_party_size + views ) <= MAXSPLITSCREENPLAYERS) + { + G_RemovePartyMember(playernum); + G_AddPartyMember(invitation, playernum); + } + } +} + +static void Got_LeaveParty(UINT8 **cp,INT32 playernum) +{ + splitscreen_invitations[playernum] = -1; +} + void D_SendPlayerConfig(void) { SendNameAndColor(); @@ -2182,6 +2296,85 @@ static void Command_SetViews_f(void) } } +static void +Command_Invite_f (void) +{ + UINT8 invitee; + + if (COM_Argc() != 2) + { + CONS_Printf("invite : Invite a player to your party.\n"); + return; + } + + if (r_splitscreen >= MAXSPLITSCREENPLAYERS) + { + CONS_Alert(CONS_WARNING, "Your party is full!\n"); + return; + } + + invitee = LookupPlayer(COM_Argv(1)); + + if (invitee == -1) + { + CONS_Alert(CONS_WARNING, "There is no player by that name!\n"); + return; + } + if (!playeringame[invitee]) + { + CONS_Alert(CONS_WARNING, "There is no player using that slot!\n"); + return; + } + + if (invitee == consoleplayer) + { + CONS_Alert(CONS_WARNING, "You cannot invite yourself! Bruh!\n"); + return; + } + + if (splitscreen_invitations[invitee] >= 0) + { + CONS_Alert(CONS_WARNING, + "That player has already been invited to join another party.\n"); + } + + SendNetXCmd(XD_PARTYINVITE, &invitee, 1); +} + +static boolean +CheckPartyInvite (void) +{ + if (splitscreen_invitations[consoleplayer] < 0) + { + CONS_Alert(CONS_WARNING, "There is no open party invitation.\n"); + return false; + } + return true; +} + +static void +Command_AcceptInvite_f (void) +{ + if (CheckPartyInvite()) + SendNetXCmd(XD_ACCEPTPARTYINVITE, NULL, 0); +} + +static void +Command_RejectInvite_f (void) +{ + if (CheckPartyInvite()) + SendNetXCmd(XD_LEAVEPARTY, NULL, 0); +} + +static void +Command_LeaveParty_f (void) +{ + if (r_splitscreen > splitscreen) + { + SendNetXCmd(XD_LEAVEPARTY, NULL, 0); + } +} + // ======================================================================== // play a demo, add .lmp for external demos @@ -5299,7 +5492,29 @@ static void Got_PickVotecmd(UINT8 **cp, INT32 playernum) */ static void Command_Displayplayer_f(void) { - CONS_Printf(M_GetText("Displayplayer is %d\n"), displayplayers[localdisplayplayers[0]]); + int playernum; + int i; + for (i = 0; i <= splitscreen; ++i) + { + playernum = displayplayers[localdisplayplayers[i]]; + CONS_Printf( + "local player %d: \x84(%d) \x83%s\x80\n", + i, + playernum, + player_names[playernum] + ); + } + CONS_Printf("\x83----------------------------------------\x80\n"); + for (i = 0; i <= r_splitscreen; ++i) + { + playernum = displayplayers[i]; + CONS_Printf( + "display player %d: \x84(%d) \x83%s\x80\n", + i, + playernum, + player_names[playernum] + ); + } } /** Quits a game and returns to the title screen. diff --git a/src/d_netcmd.h b/src/d_netcmd.h index d1f28665c..fe1f59ad2 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -179,9 +179,12 @@ typedef enum XD_PICKVOTE, // 24 XD_REMOVEPLAYER,// 25 XD_POWERLEVEL, // 26 + XD_PARTYINVITE, // 27 + XD_ACCEPTPARTYINVITE, // 28 + XD_LEAVEPARTY, // 29 #ifdef HAVE_BLUA - XD_LUACMD, // 27 - XD_LUAVAR, // 28 + XD_LUACMD, // 30 + XD_LUAVAR, // 31 #endif MAXNETXCMD } netxcmd_t; diff --git a/src/doomdef.h b/src/doomdef.h index e1e9ab13d..2aa505744 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -242,6 +242,7 @@ extern FILE *logstream; // NOTE: it needs more than this to increase the number of players... #define MAXPLAYERS 16 +#define MAXSPLITSCREENPLAYERS 4 // Max number of players on a single computer #define MAXSKINS 128 #define PLAYERSMASK (MAXPLAYERS-1) #define MAXPLAYERNAME 21 diff --git a/src/doomstat.h b/src/doomstat.h index 1d43b4986..fbda4df2a 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -80,7 +80,6 @@ extern boolean multiplayer; extern INT16 gametype; -#define MAXSPLITSCREENPLAYERS 4 // Max number of players on a single computer extern UINT8 splitscreen; extern int r_splitscreen; @@ -126,6 +125,18 @@ extern INT32 displayplayers[MAXSPLITSCREENPLAYERS]; /* displayplayers[localdisplayplayers[0]] = consoleplayer */ extern INT32 localdisplayplayers[MAXSPLITSCREENPLAYERS]; +/* spitscreen players sync */ +extern int splitscreen_original_party_size[MAXPLAYERS]; +extern int splitscreen_original_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; + +/* parties */ +extern int splitscreen_invitations[MAXPLAYERS]; +extern int splitscreen_party_size[MAXPLAYERS]; +extern int splitscreen_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; + +/* the only local one */ +extern boolean splitscreen_partied[MAXPLAYERS]; + // Maps of special importance extern INT16 spstage_start; extern INT16 sstage_start; diff --git a/src/g_game.h b/src/g_game.h index de482fe7f..e96c0d480 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -308,6 +308,9 @@ void G_ResetViews(void); void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive); void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive); +void G_AddPartyMember (int party_member, int new_party_member); +void G_RemovePartyMember (int party_member); + void G_AddPlayer(INT32 playernum); void G_SetExitGameFlag(void); diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c new file mode 100644 index 000000000..271a83569 --- /dev/null +++ b/src/g_splitscreen.c @@ -0,0 +1,209 @@ +// SONIC ROBO BLAST 2 KART +//----------------------------------------------------------------------------- +// Copyright (C) 2020 by James R. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file g_splitscreen.c +/// \brief some splitscreen stuff + +#include "doomdef.h" +#include "g_game.h" +#include "r_local.h" + +int splitscreen_original_party_size[MAXPLAYERS]; +int splitscreen_original_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; + +int splitscreen_invitations[MAXPLAYERS]; +int splitscreen_party_size[MAXPLAYERS]; +int splitscreen_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; + +boolean splitscreen_partied[MAXPLAYERS]; + +static void +ResetParty (int playernum) +{ + INT32 old_displayplayers[MAXSPLITSCREENPLAYERS]; + + int i; + + splitscreen_party_size[playernum] = + splitscreen_original_party_size[playernum]; + + memcpy(splitscreen_party[playernum], splitscreen_original_party[playernum], + sizeof splitscreen_party[playernum]); + + if (playernum == consoleplayer) + { + memset(splitscreen_partied, 0, sizeof splitscreen_partied); + splitscreen_partied[consoleplayer] = true; + + memcpy(old_displayplayers, displayplayers, sizeof old_displayplayers); + + /* easier to just rebuild displayplayers with local players */ + for (i = 0; i <= splitscreen; ++i) + { + displayplayers[i] = old_displayplayers[localdisplayplayers[i]]; + localdisplayplayers[i] = i; + } + while (i < MAXSPLITSCREENPLAYERS) + { + displayplayers[i] = consoleplayer; + localdisplayplayers[i] = i; + + i++; + } + + r_splitscreen = splitscreen; + + R_ExecuteSetViewSize(); + } +} + +void +G_RemovePartyMember (int playernum) +{ + int old_party[MAXSPLITSCREENPLAYERS]; + int new_party[MAXSPLITSCREENPLAYERS]; + + int old_party_size; + int before; + int after; + int views; + + int i; + int n; + + old_party_size = splitscreen_party_size[playernum]; + + for (i = 0; i < old_party_size; ++i) + { + /* exploit that splitscreen players keep order */ + if (splitscreen_party[playernum][i] == playernum) + { + before = i; + + views = splitscreen_original_party_size[playernum]; + after = ( before + views ); + + memcpy(old_party, splitscreen_party[playernum], sizeof old_party); + memcpy(new_party, old_party, before * sizeof *old_party); + + while (i < after) + { + splitscreen_partied[old_party[i]] = false; + + i++; + } + + memcpy(&new_party[before], &old_party[after], + ( old_party_size - after ) * sizeof *new_party); + + views = ( old_party_size - views ); + + for (i = 0; i < old_party_size; ++i) + { + n = old_party[i]; + if (n != playernum && playerconsole[n] == n) + { + splitscreen_party_size[n] = views; + memcpy(splitscreen_party[n], new_party, + sizeof splitscreen_party[n]); + } + } + + ResetParty(playernum); + + if (playernum != consoleplayer && splitscreen_partied[playernum]) + { + splitscreen_partied[playernum] = false; + + for (i = 0; i < views; ++i) + { + displayplayers[i] = new_party[i]; + } + while (i < MAXSPLITSCREENPLAYERS) + { + displayplayers[i] = consoleplayer; + + i++; + } + + r_splitscreen = ( views - 1 ); + + R_ExecuteSetViewSize(); + } + + break; + } + } +} + +void +G_AddPartyMember (int invitation, int playernum) +{ + int * party; + int *add_party; + + int old_party_size; + int new_party_size; + + int views; + + int i; + int n; + + views = splitscreen_original_party_size[playernum]; + + old_party_size = splitscreen_party_size[invitation]; + new_party_size = ( old_party_size + views ); + + party = splitscreen_party[invitation]; + add_party = splitscreen_original_party[playernum]; + + for (i = 0; i < old_party_size; ++i) + { + n = party[i]; + if (playerconsole[n] == n) + { + splitscreen_party_size[n] = new_party_size; + memcpy(&splitscreen_party[n][old_party_size], add_party, + views * sizeof *splitscreen_party[n]); + } + } + + splitscreen_party_size[playernum] = new_party_size; + memcpy(splitscreen_party[playernum], party, + sizeof splitscreen_party[playernum]); + + /* in my party or adding me? */ + if (splitscreen_partied[invitation]) + { + for (i = old_party_size; i < new_party_size; ++i) + { + displayplayers[i] = party[i]; + } + + r_splitscreen += views; + + R_ExecuteSetViewSize(); + } + else if (playernum == consoleplayer) + { + for (i = 0; i <= splitscreen; ++i) + { + localdisplayplayers[i] = ( old_party_size + i ); + displayplayers[i] = party[i]; + } + while (++i < new_party_size) + { + displayplayers[i] = party[i]; + } + + r_splitscreen = ( new_party_size - 1 ); + + R_ExecuteSetViewSize(); + } +} From 02757eac82e90a3bca5afc8497ca21f6c05eba3b Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 22 Feb 2020 04:14:28 -0800 Subject: [PATCH 03/36] Fix and fully implement leaving parties --- src/d_clisrv.c | 5 ++++- src/d_netcmd.c | 20 ++++++++++++++++++++ src/g_game.h | 1 + src/g_splitscreen.c | 25 ++++++++++++++----------- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b397c83ae..aad0f9b1a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2652,7 +2652,6 @@ void CL_ClearPlayer(INT32 playernum) } splitscreen_invitations[playernum] = -1; - splitscreen_partied[playernum] = false; memset(&players[playernum], 0, sizeof (player_t)); } @@ -2746,6 +2745,8 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) RemoveAdminPlayer(playernum); // don't stay admin after you're gone } + G_RemovePartyMember(playernum); + if (playernum == displayplayers[localdisplayplayers[0]] && !demo.playback) displayplayers[localdisplayplayers[0]] = consoleplayer; // don't look through someone's view who isn't there @@ -3382,6 +3383,8 @@ void SV_ResetServer(void) splitscreen_invitations[i] = -1; } + memset(splitscreen_partied, 0, sizeof splitscreen_partied); + mynode = 0; cl_packetmissed = false; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 51a4b822d..e1603bff0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2053,7 +2053,27 @@ static void Got_AcceptPartyInvite(UINT8 **cp,INT32 playernum) static void Got_LeaveParty(UINT8 **cp,INT32 playernum) { + if (playerconsole[playernum] != playernum) + { + CONS_Alert(CONS_WARNING, M_GetText("Illegal accept splitscreen invite received from %s\n"), player_names[playernum]); + if (server) + { + XBOXSTATIC UINT8 buf[2]; + + buf[0] = (UINT8)playernum; + buf[1] = KICK_MSG_CON_FAIL; + SendNetXCmd(XD_KICK, &buf, 2); + } + return; + } + splitscreen_invitations[playernum] = -1; + if (splitscreen_party_size[playernum] > + splitscreen_original_party_size[playernum]) + { + G_RemovePartyMember(playernum); + G_ResetSplitscreen(playernum); + } } void D_SendPlayerConfig(void) diff --git a/src/g_game.h b/src/g_game.h index e96c0d480..de88d6bdc 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -310,6 +310,7 @@ void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive); void G_AddPartyMember (int party_member, int new_party_member); void G_RemovePartyMember (int party_member); +void G_ResetSplitscreen (int playernum); void G_AddPlayer(INT32 playernum); diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c index 271a83569..3ff71e627 100644 --- a/src/g_splitscreen.c +++ b/src/g_splitscreen.c @@ -22,8 +22,8 @@ int splitscreen_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; boolean splitscreen_partied[MAXPLAYERS]; -static void -ResetParty (int playernum) +void +G_ResetSplitscreen (int playernum) { INT32 old_displayplayers[MAXSPLITSCREENPLAYERS]; @@ -91,16 +91,16 @@ G_RemovePartyMember (int playernum) memcpy(old_party, splitscreen_party[playernum], sizeof old_party); memcpy(new_party, old_party, before * sizeof *old_party); - while (i < after) - { - splitscreen_partied[old_party[i]] = false; - - i++; - } - memcpy(&new_party[before], &old_party[after], ( old_party_size - after ) * sizeof *new_party); + if (splitscreen_partied[playernum] && + localdisplayplayers[0] >= after) + { + for (i = 0; i < MAXSPLITSCREENPLAYERS; ++i) + localdisplayplayers[i] -= views; + } + views = ( old_party_size - views ); for (i = 0; i < old_party_size; ++i) @@ -114,8 +114,7 @@ G_RemovePartyMember (int playernum) } } - ResetParty(playernum); - + /* don't want to remove yourself from your own screen! */ if (playernum != consoleplayer && splitscreen_partied[playernum]) { splitscreen_partied[playernum] = false; @@ -181,6 +180,8 @@ G_AddPartyMember (int invitation, int playernum) /* in my party or adding me? */ if (splitscreen_partied[invitation]) { + splitscreen_partied[playernum] = true; + for (i = old_party_size; i < new_party_size; ++i) { displayplayers[i] = party[i]; @@ -192,6 +193,8 @@ G_AddPartyMember (int invitation, int playernum) } else if (playernum == consoleplayer) { + splitscreen_partied[invitation] = true; + for (i = 0; i <= splitscreen; ++i) { localdisplayplayers[i] = ( old_party_size + i ); From 110871c3b6a8c76339aaaca94881aad640609a1c Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 22 Feb 2020 04:16:08 -0800 Subject: [PATCH 04/36] Void the party invitation once its accepted --- src/d_netcmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e1603bff0..8c9be30d6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2048,6 +2048,8 @@ static void Got_AcceptPartyInvite(UINT8 **cp,INT32 playernum) G_RemovePartyMember(playernum); G_AddPartyMember(invitation, playernum); } + + splitscreen_invitations[playernum] = -1; } } @@ -2068,6 +2070,7 @@ static void Got_LeaveParty(UINT8 **cp,INT32 playernum) } splitscreen_invitations[playernum] = -1; + if (splitscreen_party_size[playernum] > splitscreen_original_party_size[playernum]) { From e235267f1d625e88caf593874be51dc291f32a7b Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 22 Feb 2020 04:59:21 -0800 Subject: [PATCH 05/36] Improve feedback on party invitations --- src/d_netcmd.c | 103 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 91 insertions(+), 12 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8c9be30d6..a2e566d63 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1318,6 +1318,38 @@ static void ForceAllSkins(INT32 forcedskin) } } +static const char * +VaguePartyDescription (int playernum, int *party_sizes, int default_color) +{ + static char description[1 + MAXPLAYERNAME + 1 + sizeof " and x others"]; + const char *name; + int size; + name = player_names[playernum]; + size = party_sizes[playernum]; + /* + less than check for the dumb compiler because I KNOW it'll + complain about "writing x bytes into an area of y bytes"!!! + */ + if (size > 1 && size <= MAXSPLITSCREENPLAYERS) + { + sprintf(description, + "\x83%s%c and %d others", + name, + ( size - 1 ), + default_color + ); + } + else + { + sprintf(description, + "\x83%s%c", + name, + default_color + ); + } + return description; +} + static INT32 snacpending = 0, snac2pending = 0, snac3pending = 0, snac4pending = 0, chmappending = 0; // name, color, or skin has changed @@ -2000,18 +2032,11 @@ static void Got_PartyInvite(UINT8 **cp,INT32 playernum) if (invitee == consoleplayer)/* hey that's me! */ { - CONS_Printf( - "You have been invited to join %s", - player_names[playernum] - ); - if (splitscreen_party_size[playernum] > 1) - { - CONS_Printf( - " and %d others", - ( splitscreen_party_size[playernum] - 1 ) - ); - } - CONS_Printf(".\n"); + HU_AddChatText(va( + "\x82*You have been invited to join %s.", + VaguePartyDescription( + playernum, splitscreen_party_size, '\x82') + ), true); } } } @@ -2040,6 +2065,23 @@ static void Got_AcceptPartyInvite(UINT8 **cp,INT32 playernum) if (invitation >= 0) { + if (splitscreen_partied[invitation]) + { + HU_AddChatText(va( + "\x82*%s has joined your party!", + VaguePartyDescription( + playernum, splitscreen_original_party_size, '\x82') + ), true); + } + else if (playernum == consoleplayer) + { + HU_AddChatText(va( + "\x82*You joined %s's party!", + VaguePartyDescription( + invitation, splitscreen_party_size, '\x82') + ), true); + } + old_party_size = splitscreen_party_size[invitation]; views = splitscreen_original_party_size[playernum]; @@ -2069,11 +2111,28 @@ static void Got_LeaveParty(UINT8 **cp,INT32 playernum) return; } + if (consoleplayer == splitscreen_invitations[playernum]) + { + HU_AddChatText(va( + "\x85*\x83%s\x85 rejected your invitation.", + player_names[playernum] + ), true); + } + splitscreen_invitations[playernum] = -1; if (splitscreen_party_size[playernum] > splitscreen_original_party_size[playernum]) { + if (splitscreen_partied[playernum] && playernum != consoleplayer) + { + HU_AddChatText(va( + "\x85*%s left your party.", + VaguePartyDescription( + playernum, splitscreen_original_party_size, '\x85') + ), true); + } + G_RemovePartyMember(playernum); G_ResetSplitscreen(playernum); } @@ -2361,6 +2420,20 @@ Command_Invite_f (void) "That player has already been invited to join another party.\n"); } + if (( splitscreen_party_size[consoleplayer] + + splitscreen_original_party_size[invitee] ) > MAXSPLITSCREENPLAYERS) + { + CONS_Alert(CONS_WARNING, + "That player joined with too many " + "splitscreen players for your party.\n"); + } + + CONS_Printf( + "Inviting %s...\n", + VaguePartyDescription( + invitee, splitscreen_original_party_size, '\x80') + ); + SendNetXCmd(XD_PARTYINVITE, &invitee, 1); } @@ -2386,7 +2459,11 @@ static void Command_RejectInvite_f (void) { if (CheckPartyInvite()) + { + CONS_Printf("\x85Rejecting invite...\n"); + SendNetXCmd(XD_LEAVEPARTY, NULL, 0); + } } static void @@ -2394,6 +2471,8 @@ Command_LeaveParty_f (void) { if (r_splitscreen > splitscreen) { + CONS_Printf("\x85Leaving party...\n"); + SendNetXCmd(XD_LEAVEPARTY, NULL, 0); } } From 06cee4a0b75e334fffb36e929c3fa5ba7fc4df44 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 22 Feb 2020 05:12:29 -0800 Subject: [PATCH 06/36] Fix camera angle of party players --- src/d_clisrv.c | 3 ++- src/g_splitscreen.c | 3 ++- src/p_user.c | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index aad0f9b1a..7c3f1aa30 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3529,6 +3529,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) if (splitscreenplayer) { displayplayers[splitscreenplayer] = newplayernum; + localdisplayplayers[splitscreenplayer] = splitscreenplayer; DEBFILE(va("spawning sister # %d\n", splitscreenplayer)); if (splitscreenplayer == 1 && botingame) players[newplayernum].bot = 1; @@ -3539,7 +3540,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { displayplayers[i] = newplayernum; - localdisplayplayers[i] = i; + localdisplayplayers[i] = 0; } splitscreen_partied[newplayernum] = true; DEBFILE("spawning me\n"); diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c index 3ff71e627..039eb02bf 100644 --- a/src/g_splitscreen.c +++ b/src/g_splitscreen.c @@ -51,7 +51,7 @@ G_ResetSplitscreen (int playernum) while (i < MAXSPLITSCREENPLAYERS) { displayplayers[i] = consoleplayer; - localdisplayplayers[i] = i; + localdisplayplayers[i] = 0; i++; } @@ -203,6 +203,7 @@ G_AddPartyMember (int invitation, int playernum) while (++i < new_party_size) { displayplayers[i] = party[i]; + localdisplayplayers[i] = old_party_size; } r_splitscreen = ( new_party_size - 1 ); diff --git a/src/p_user.c b/src/p_user.c index bb9eae095..581085d75 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7339,17 +7339,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall focusangle = localangle[0]; focusaiming = localaiming[0]; } - else if (player == &players[displayplayers[1]]) + else if (player == &players[displayplayers[localdisplayplayers[1]]]) { focusangle = localangle[1]; focusaiming = localaiming[1]; } - else if (player == &players[displayplayers[2]]) + else if (player == &players[displayplayers[localdisplayplayers[2]]]) { focusangle = localangle[2]; focusaiming = localaiming[2]; } - else if (player == &players[displayplayers[3]]) + else if (player == &players[displayplayers[localdisplayplayers[3]]]) { focusangle = localangle[3]; focusaiming = localaiming[3]; From a55ccbe52c9eeb7707d5eac256b3bcea42c3f37b Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 16:04:40 -0800 Subject: [PATCH 07/36] Maybe fix incorrect displayplayers after adding/removing from party --- src/g_splitscreen.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c index 039eb02bf..6f5a69297 100644 --- a/src/g_splitscreen.c +++ b/src/g_splitscreen.c @@ -94,11 +94,13 @@ G_RemovePartyMember (int playernum) memcpy(&new_party[before], &old_party[after], ( old_party_size - after ) * sizeof *new_party); - if (splitscreen_partied[playernum] && - localdisplayplayers[0] >= after) + if (splitscreen_partied[playernum]) { - for (i = 0; i < MAXSPLITSCREENPLAYERS; ++i) + for (i = 0; i < MAXSPLITSCREENPLAYERS && + localdisplayplayers[i] >= after; ++i) + { localdisplayplayers[i] -= views; + } } views = ( old_party_size - views ); @@ -205,6 +207,13 @@ G_AddPartyMember (int invitation, int playernum) displayplayers[i] = party[i]; localdisplayplayers[i] = old_party_size; } + while (i < MAXSPLITSCREENPLAYERS) + { + displayplayers[i] = consoleplayer; + localdisplayplayers[i] = old_party_size; + + i++; + } r_splitscreen = ( new_party_size - 1 ); From c8524b47e7ba15dd323e803bbabca30d801b5bf2 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 16:05:22 -0800 Subject: [PATCH 08/36] Fix VIEWPOINT annotation showing up in parties --- src/p_user.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 581085d75..f7477ecfc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1488,11 +1488,19 @@ boolean P_IsLocalPlayer(player_t *player) { UINT8 i; - if (player == &players[consoleplayer]) - return true; - else if (r_splitscreen) + if (r_splitscreen > splitscreen) { - for (i = 1; i <= r_splitscreen; i++) // Skip P1 + for (i = 0; i <= r_splitscreen; ++i) + { + if (player == &players[displayplayers[i]]) + return true; + } + } + else if (player == &players[consoleplayer]) + return true; + else if (splitscreen) + { + for (i = 1; i <= splitscreen; i++) // Skip P1 { if (player == &players[displayplayers[i]]) return true; From 1e89d512a73b9bcf055d94d6f678c072732a8609 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 18:06:48 -0800 Subject: [PATCH 09/36] Fix spectator join black screen --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index f7477ecfc..6a660f20f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7893,8 +7893,8 @@ boolean P_SpectatorJoinGame(player_t *player) player->playerstate = PST_REBORN; //Reset away view - if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) - displayplayers[0] = consoleplayer; + if (P_IsLocalPlayer(player) && displayplayers[localdisplayplayers[0]] != consoleplayer) + displayplayers[localdisplayplayers[0]] = consoleplayer; HU_AddChatText(va(M_GetText("\x82*%s entered the game."), player_names[player-players]), false); return true; // no more player->mo, cannot continue. From 4f40edaf01ce104265b4b942ba8182e1e113f6a2 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 18:20:55 -0800 Subject: [PATCH 10/36] Maybe localdisplayplayers is a bad idea --- src/d_clisrv.c | 9 ++- src/d_main.c | 2 +- src/d_netcmd.c | 134 +++++++++++++++++++++---------------------- src/doomstat.h | 4 +- src/g_game.c | 52 ++++++++--------- src/g_splitscreen.c | 22 +------ src/k_kart.c | 2 +- src/lua_consolelib.c | 2 +- src/m_menu.c | 12 ++-- src/m_misc.c | 10 ++-- src/p_floor.c | 16 +++--- src/p_inter.c | 12 ++-- src/p_mobj.c | 28 ++++----- src/p_setup.c | 26 ++++----- src/p_user.c | 10 ++-- src/st_stuff.c | 2 +- src/y_inter.c | 14 ++--- 17 files changed, 169 insertions(+), 188 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7c3f1aa30..a6190a0dc 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2747,8 +2747,8 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) G_RemovePartyMember(playernum); - if (playernum == displayplayers[localdisplayplayers[0]] && !demo.playback) - displayplayers[localdisplayplayers[0]] = consoleplayer; // don't look through someone's view who isn't there + if (playernum == g_localplayers[0] && !demo.playback) + g_localplayers[0] = consoleplayer; // don't look through someone's view who isn't there #ifdef HAVE_BLUA LUA_InvalidatePlayer(&players[playernum]); @@ -3529,7 +3529,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) if (splitscreenplayer) { displayplayers[splitscreenplayer] = newplayernum; - localdisplayplayers[splitscreenplayer] = splitscreenplayer; + g_localplayers[splitscreenplayer] = newplayernum; DEBFILE(va("spawning sister # %d\n", splitscreenplayer)); if (splitscreenplayer == 1 && botingame) players[newplayernum].bot = 1; @@ -3540,7 +3540,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { displayplayers[i] = newplayernum; - localdisplayplayers[i] = 0; + g_localplayers[i] = newplayernum; } splitscreen_partied[newplayernum] = true; DEBFILE("spawning me\n"); @@ -3751,7 +3751,6 @@ void SV_StopServer(void) D_Clearticcmd(i); consoleplayer = 0; - localdisplayplayers[0] = 0; cl_mode = CL_SEARCHING; maketic = gametic+1; neededtic = maketic; diff --git a/src/d_main.c b/src/d_main.c index e0ba654ad..8a01ec45e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -780,7 +780,7 @@ void D_StartTitle(void) gameaction = ga_nothing; memset(displayplayers, 0, sizeof(displayplayers)); - memset(localdisplayplayers, 0, sizeof localdisplayplayers); + memset(g_localplayers, 0, sizeof g_localplayers); consoleplayer = 0; //demosequence = -1; gametype = GT_RACE; // SRB2kart diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a2e566d63..fa10c1640 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1196,11 +1196,11 @@ static void CleanupPlayerName(INT32 playernum, const char *newname) // spaces may have been removed if (playernum == consoleplayer) CV_StealthSet(&cv_playername, tmpname); - else if (playernum == displayplayers[localdisplayplayers[1]] || (!netgame && playernum == 1)) + else if (playernum == g_localplayers[1] || (!netgame && playernum == 1)) CV_StealthSet(&cv_playername2, tmpname); - else if (playernum == displayplayers[localdisplayplayers[2]] || (!netgame && playernum == 2)) + else if (playernum == g_localplayers[2] || (!netgame && playernum == 2)) CV_StealthSet(&cv_playername3, tmpname); - else if (playernum == displayplayers[localdisplayplayers[3]] || (!netgame && playernum == 3)) + else if (playernum == g_localplayers[3] || (!netgame && playernum == 3)) CV_StealthSet(&cv_playername4, tmpname); else I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); @@ -1308,11 +1308,11 @@ static void ForceAllSkins(INT32 forcedskin) { if (i == consoleplayer) CV_StealthSet(&cv_skin, skins[forcedskin].name); - else if (i == displayplayers[localdisplayplayers[1]]) + else if (i == g_localplayers[1]) CV_StealthSet(&cv_skin2, skins[forcedskin].name); - else if (i == displayplayers[localdisplayplayers[2]]) + else if (i == g_localplayers[2]) CV_StealthSet(&cv_skin3, skins[forcedskin].name); - else if (i == displayplayers[localdisplayplayers[3]]) + else if (i == g_localplayers[3]) CV_StealthSet(&cv_skin4, skins[forcedskin].name); } } @@ -1479,8 +1479,8 @@ static void SendNameAndColor2(void) if (splitscreen < 1 && !botingame) return; // can happen if skin2/color2/name2 changed - if (displayplayers[localdisplayplayers[1]] != consoleplayer) - secondplaya = displayplayers[localdisplayplayers[1]]; + if (g_localplayers[1] != consoleplayer) + secondplaya = g_localplayers[1]; else if (!netgame) // HACK secondplaya = 1; @@ -1568,14 +1568,14 @@ static void SendNameAndColor2(void) snac2pending++; // Don't change name if muted - if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[localdisplayplayers[1]]))) - CV_StealthSet(&cv_playername2, player_names[displayplayers[localdisplayplayers[1]]]); + if (cv_mute.value && !(server || IsPlayerAdmin(g_localplayers[1]))) + CV_StealthSet(&cv_playername2, player_names[g_localplayers[1]]); else // Cleanup name if changing it - CleanupPlayerName(displayplayers[localdisplayplayers[1]], cv_playername2.zstring); + CleanupPlayerName(g_localplayers[1], cv_playername2.zstring); // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(displayplayers[localdisplayplayers[1]])) - CV_StealthSet(&cv_skin2, skins[players[displayplayers[localdisplayplayers[1]]].skin].name); + if (!CanChangeSkin(g_localplayers[1])) + CV_StealthSet(&cv_skin2, skins[players[g_localplayers[1]].skin].name); // check if player has the skin loaded (cv_skin2 may have // the name of a skin that was available in the previous game) @@ -1602,8 +1602,8 @@ static void SendNameAndColor3(void) if (splitscreen < 2) return; // can happen if skin3/color3/name3 changed - if (displayplayers[localdisplayplayers[2]] != consoleplayer) - thirdplaya = displayplayers[localdisplayplayers[2]]; + if (g_localplayers[2] != consoleplayer) + thirdplaya = g_localplayers[2]; else if (!netgame) // HACK thirdplaya = 2; @@ -1683,14 +1683,14 @@ static void SendNameAndColor3(void) snac3pending++; // Don't change name if muted - if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[localdisplayplayers[2]]))) - CV_StealthSet(&cv_playername3, player_names[displayplayers[localdisplayplayers[2]]]); + if (cv_mute.value && !(server || IsPlayerAdmin(g_localplayers[2]))) + CV_StealthSet(&cv_playername3, player_names[g_localplayers[2]]); else // Cleanup name if changing it - CleanupPlayerName(displayplayers[localdisplayplayers[2]], cv_playername3.zstring); + CleanupPlayerName(g_localplayers[2], cv_playername3.zstring); // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(displayplayers[localdisplayplayers[2]])) - CV_StealthSet(&cv_skin3, skins[players[displayplayers[localdisplayplayers[2]]].skin].name); + if (!CanChangeSkin(g_localplayers[2])) + CV_StealthSet(&cv_skin3, skins[players[g_localplayers[2]].skin].name); // check if player has the skin loaded (cv_skin3 may have // the name of a skin that was available in the previous game) @@ -1717,8 +1717,8 @@ static void SendNameAndColor4(void) if (splitscreen < 3) return; // can happen if skin4/color4/name4 changed - if (displayplayers[localdisplayplayers[3]] != consoleplayer) - fourthplaya = displayplayers[localdisplayplayers[3]]; + if (g_localplayers[3] != consoleplayer) + fourthplaya = g_localplayers[3]; else if (!netgame) // HACK fourthplaya = 3; @@ -1806,14 +1806,14 @@ static void SendNameAndColor4(void) snac4pending++; // Don't change name if muted - if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[localdisplayplayers[3]]))) - CV_StealthSet(&cv_playername4, player_names[displayplayers[localdisplayplayers[3]]]); + if (cv_mute.value && !(server || IsPlayerAdmin(g_localplayers[3]))) + CV_StealthSet(&cv_playername4, player_names[g_localplayers[3]]); else // Cleanup name if changing it - CleanupPlayerName(displayplayers[localdisplayplayers[3]], cv_playername4.zstring); + CleanupPlayerName(g_localplayers[3], cv_playername4.zstring); // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(displayplayers[localdisplayplayers[3]])) - CV_StealthSet(&cv_skin4, skins[players[displayplayers[localdisplayplayers[3]]].skin].name); + if (!CanChangeSkin(g_localplayers[3])) + CV_StealthSet(&cv_skin4, skins[players[g_localplayers[3]].skin].name); // check if player has the skin loaded (cv_skin4 may have // the name of a skin that was available in the previous game) @@ -1844,11 +1844,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) if (playernum == consoleplayer) snacpending--; // TODO: make snacpending an array instead of 4 separate vars? - else if (playernum == displayplayers[localdisplayplayers[1]]) + else if (playernum == g_localplayers[1]) snac2pending--; - else if (playernum == displayplayers[localdisplayplayers[2]]) + else if (playernum == g_localplayers[2]) snac3pending--; - else if (playernum == displayplayers[localdisplayplayers[3]]) + else if (playernum == g_localplayers[3]) snac4pending--; #ifdef PARANOIA @@ -1871,8 +1871,8 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) demo_extradata[playernum] |= DXD_COLOR; // normal player colors - if (server && (p != &players[consoleplayer] && p != &players[displayplayers[localdisplayplayers[1]]] - && p != &players[displayplayers[localdisplayplayers[2]]] && p != &players[displayplayers[localdisplayplayers[3]]])) + if (server && (p != &players[consoleplayer] && p != &players[g_localplayers[1]] + && p != &players[g_localplayers[2]] && p != &players[g_localplayers[3]])) { boolean kick = false; @@ -1909,11 +1909,11 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) if (playernum == consoleplayer) CV_StealthSet(&cv_skin, skins[forcedskin].name); - else if (playernum == displayplayers[localdisplayplayers[1]]) + else if (playernum == g_localplayers[1]) CV_StealthSet(&cv_skin2, skins[forcedskin].name); - else if (playernum == displayplayers[localdisplayplayers[2]]) + else if (playernum == g_localplayers[2]) CV_StealthSet(&cv_skin3, skins[forcedskin].name); - else if (playernum == displayplayers[localdisplayplayers[3]]) + else if (playernum == g_localplayers[3]) CV_StealthSet(&cv_skin4, skins[forcedskin].name); } else @@ -2184,7 +2184,7 @@ void D_SendPlayerConfig(void) // Only works for displayplayer, sorry! static void Command_ResetCamera_f(void) { - P_ResetCamera(&players[displayplayers[localdisplayplayers[0]]], &camera[0]); + P_ResetCamera(&players[g_localplayers[0]], &camera[0]); } /* Consider replacing nametonum with this */ @@ -2721,7 +2721,7 @@ void D_ModifyClientVote(SINT8 voted, UINT8 splitplayer) UINT8 player = consoleplayer; if (splitplayer > 0) - player = displayplayers[localdisplayplayers[splitplayer]]; + player = g_localplayers[splitplayer]; WRITESINT8(p, voted); WRITEUINT8(p, player); @@ -3373,11 +3373,11 @@ static void Command_Teamchange2_f(void) return; } - if (players[displayplayers[localdisplayplayers[1]]].spectator) - error = !(NetPacket.packet.newteam || (players[displayplayers[localdisplayplayers[1]]].pflags & PF_WANTSTOJOIN)); + if (players[g_localplayers[1]].spectator) + error = !(NetPacket.packet.newteam || (players[g_localplayers[1]].pflags & PF_WANTSTOJOIN)); else if (G_GametypeHasTeams()) - error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[localdisplayplayers[1]]].ctfteam); - else if (G_GametypeHasSpectators() && !players[displayplayers[localdisplayplayers[1]]].spectator) + error = (NetPacket.packet.newteam == (unsigned)players[g_localplayers[1]].ctfteam); + else if (G_GametypeHasSpectators() && !players[g_localplayers[1]].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA else @@ -3464,11 +3464,11 @@ static void Command_Teamchange3_f(void) return; } - if (players[displayplayers[localdisplayplayers[2]]].spectator) - error = !(NetPacket.packet.newteam || (players[displayplayers[localdisplayplayers[2]]].pflags & PF_WANTSTOJOIN)); + if (players[g_localplayers[2]].spectator) + error = !(NetPacket.packet.newteam || (players[g_localplayers[2]].pflags & PF_WANTSTOJOIN)); else if (G_GametypeHasTeams()) - error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[localdisplayplayers[2]]].ctfteam); - else if (G_GametypeHasSpectators() && !players[displayplayers[localdisplayplayers[2]]].spectator) + error = (NetPacket.packet.newteam == (unsigned)players[g_localplayers[2]].ctfteam); + else if (G_GametypeHasSpectators() && !players[g_localplayers[2]].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA else @@ -3555,11 +3555,11 @@ static void Command_Teamchange4_f(void) return; } - if (players[displayplayers[localdisplayplayers[3]]].spectator) - error = !(NetPacket.packet.newteam || (players[displayplayers[localdisplayplayers[3]]].pflags & PF_WANTSTOJOIN)); + if (players[g_localplayers[3]].spectator) + error = !(NetPacket.packet.newteam || (players[g_localplayers[3]].pflags & PF_WANTSTOJOIN)); else if (G_GametypeHasTeams()) - error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[localdisplayplayers[3]]].ctfteam); - else if (G_GametypeHasSpectators() && !players[displayplayers[localdisplayplayers[3]]].spectator) + error = (NetPacket.packet.newteam == (unsigned)players[g_localplayers[3]].ctfteam); + else if (G_GametypeHasSpectators() && !players[g_localplayers[3]].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA else @@ -3956,8 +3956,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 //reset view if you are changed, or viewing someone who was changed. - if (playernum == consoleplayer || displayplayers[localdisplayplayers[0]] == playernum) - displayplayers[localdisplayplayers[0]] = consoleplayer; + if (playernum == consoleplayer || g_localplayers[0] == playernum) + g_localplayers[0] = consoleplayer; if (G_GametypeHasTeams()) { @@ -5598,7 +5598,7 @@ static void Command_Displayplayer_f(void) int i; for (i = 0; i <= splitscreen; ++i) { - playernum = displayplayers[localdisplayplayers[i]]; + playernum = g_localplayers[i]; CONS_Printf( "local player %d: \x84(%d) \x83%s\x80\n", i, @@ -5811,7 +5811,7 @@ static void Name2_OnChange(void) 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")); - CV_StealthSet(&cv_playername2, player_names[displayplayers[localdisplayplayers[1]]]); + CV_StealthSet(&cv_playername2, player_names[g_localplayers[1]]); } else SendNameAndColor2(); @@ -5822,7 +5822,7 @@ static void Name3_OnChange(void) 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")); - CV_StealthSet(&cv_playername3, player_names[displayplayers[localdisplayplayers[2]]]); + CV_StealthSet(&cv_playername3, player_names[g_localplayers[2]]); } else SendNameAndColor3(); @@ -5833,7 +5833,7 @@ static void Name4_OnChange(void) 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")); - CV_StealthSet(&cv_playername4, player_names[displayplayers[localdisplayplayers[3]]]); + CV_StealthSet(&cv_playername4, player_names[g_localplayers[3]]); } else SendNameAndColor4(); @@ -5874,12 +5874,12 @@ static void Skin2_OnChange(void) if (!Playing() || !splitscreen) return; // do whatever you want - if (CanChangeSkin(displayplayers[localdisplayplayers[1]]) && !P_PlayerMoving(displayplayers[localdisplayplayers[1]])) + if (CanChangeSkin(g_localplayers[1]) && !P_PlayerMoving(g_localplayers[1])) SendNameAndColor2(); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); - CV_StealthSet(&cv_skin2, skins[players[displayplayers[localdisplayplayers[1]]].skin].name); + CV_StealthSet(&cv_skin2, skins[players[g_localplayers[1]].skin].name); } } @@ -5888,12 +5888,12 @@ static void Skin3_OnChange(void) if (!Playing() || splitscreen < 2) return; // do whatever you want - if (CanChangeSkin(displayplayers[localdisplayplayers[2]]) && !P_PlayerMoving(displayplayers[localdisplayplayers[2]])) + if (CanChangeSkin(g_localplayers[2]) && !P_PlayerMoving(g_localplayers[2])) SendNameAndColor3(); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); - CV_StealthSet(&cv_skin3, skins[players[displayplayers[localdisplayplayers[2]]].skin].name); + CV_StealthSet(&cv_skin3, skins[players[g_localplayers[2]].skin].name); } } @@ -5902,12 +5902,12 @@ static void Skin4_OnChange(void) if (!Playing() || splitscreen < 3) return; // do whatever you want - if (CanChangeSkin(displayplayers[localdisplayplayers[3]]) && !P_PlayerMoving(displayplayers[localdisplayplayers[3]])) + if (CanChangeSkin(g_localplayers[3]) && !P_PlayerMoving(g_localplayers[3])) SendNameAndColor4(); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); - CV_StealthSet(&cv_skin4, skins[players[displayplayers[localdisplayplayers[3]]].skin].name); + CV_StealthSet(&cv_skin4, skins[players[g_localplayers[3]].skin].name); } } @@ -5948,7 +5948,7 @@ static void Color2_OnChange(void) if (!Playing() || !splitscreen) return; // do whatever you want - if (!P_PlayerMoving(displayplayers[localdisplayplayers[1]])) + if (!P_PlayerMoving(g_localplayers[1])) { // Color change menu scrolling fix is no longer necessary SendNameAndColor2(); @@ -5956,7 +5956,7 @@ static void Color2_OnChange(void) else { CV_StealthSetValue(&cv_playercolor2, - players[displayplayers[localdisplayplayers[1]]].skincolor); + players[g_localplayers[1]].skincolor); } } @@ -5965,7 +5965,7 @@ static void Color3_OnChange(void) if (!Playing() || splitscreen < 2) return; // do whatever you want - if (!P_PlayerMoving(displayplayers[localdisplayplayers[2]])) + if (!P_PlayerMoving(g_localplayers[2])) { // Color change menu scrolling fix is no longer necessary SendNameAndColor3(); @@ -5973,7 +5973,7 @@ static void Color3_OnChange(void) else { CV_StealthSetValue(&cv_playercolor3, - players[displayplayers[localdisplayplayers[2]]].skincolor); + players[g_localplayers[2]].skincolor); } } @@ -5982,7 +5982,7 @@ static void Color4_OnChange(void) if (!Playing() || splitscreen < 3) return; // do whatever you want - if (!P_PlayerMoving(displayplayers[localdisplayplayers[3]])) + if (!P_PlayerMoving(g_localplayers[3])) { // Color change menu scrolling fix is no longer necessary SendNameAndColor4(); @@ -5990,7 +5990,7 @@ static void Color4_OnChange(void) else { CV_StealthSetValue(&cv_playercolor4, - players[displayplayers[localdisplayplayers[3]]].skincolor); + players[g_localplayers[3]].skincolor); } } diff --git a/src/doomstat.h b/src/doomstat.h index fbda4df2a..675f79d38 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -122,8 +122,8 @@ extern boolean gamedataloaded; // Player taking events, and displaying. extern INT32 consoleplayer; extern INT32 displayplayers[MAXSPLITSCREENPLAYERS]; -/* displayplayers[localdisplayplayers[0]] = consoleplayer */ -extern INT32 localdisplayplayers[MAXSPLITSCREENPLAYERS]; +/* g_localplayers[0] = consoleplayer */ +extern INT32 g_localplayers[MAXSPLITSCREENPLAYERS]; /* spitscreen players sync */ extern int splitscreen_original_party_size[MAXPLAYERS]; diff --git a/src/g_game.c b/src/g_game.c index 871eafaab..ffb75f3fb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -115,7 +115,7 @@ player_t players[MAXPLAYERS]; INT32 consoleplayer; // player taking events and displaying INT32 displayplayers[MAXSPLITSCREENPLAYERS]; // view being displayed -INT32 localdisplayplayers[MAXSPLITSCREENPLAYERS]; +INT32 g_localplayers[MAXSPLITSCREENPLAYERS]; tic_t gametic; tic_t levelstarttic; // gametic at level start @@ -1257,7 +1257,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (ssplayer == 1) player = &players[consoleplayer]; else - player = &players[displayplayers[localdisplayplayers[ssplayer-1]]]; + player = &players[g_localplayers[ssplayer-1]]; if (ssplayer == 2) thiscam = (player->bot == 2 ? &camera[0] : &camera[ssplayer-1]); @@ -1596,8 +1596,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) //Reset away view if a command is given. if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) - && displayplayers[localdisplayplayers[0]] != consoleplayer && ssplayer == 1) - displayplayers[localdisplayplayers[0]] = consoleplayer; + && g_localplayers[0] != consoleplayer && ssplayer == 1) + g_localplayers[0] = consoleplayer; } @@ -1749,12 +1749,12 @@ void G_DoLoadLevel(boolean resetplayer) if (!resetplayer) P_FindEmerald(); - displayplayers[localdisplayplayers[0]] = consoleplayer; // view the guy you are playing + g_localplayers[0] = consoleplayer; // view the guy you are playing for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { if (i > 0 && !(i == 1 && botingame) && r_splitscreen < i) - displayplayers[localdisplayplayers[i]] = consoleplayer; + g_localplayers[i] = consoleplayer; } gameaction = ga_nothing; @@ -1765,7 +1765,7 @@ void G_DoLoadLevel(boolean resetplayer) for (i = 0; i <= r_splitscreen; i++) { if (camera[i].chase) - P_ResetCamera(&players[displayplayers[localdisplayplayers[i]]], &camera[i]); + P_ResetCamera(&players[g_localplayers[i]], &camera[i]); } // clear cmd building stuff @@ -1876,7 +1876,7 @@ boolean G_Responder(event_t *ev) && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) { if (!demo.playback && (r_splitscreen || !netgame)) - displayplayers[localdisplayplayers[0]] = consoleplayer; + g_localplayers[0] = consoleplayer; else { G_AdjustView(1, 1, true); @@ -2885,18 +2885,18 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) if (nummapthings) { if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) - || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) - || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) + || (splitscreen && playernum == g_localplayers[1]) + || (splitscreen > 1 && playernum == g_localplayers[2]) + || (splitscreen > 2 && playernum == g_localplayers[3])) CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the first mapthing!\n")); spawnpoint = &mapthings[0]; } else { if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) - || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) - || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) + || (splitscreen && playernum == g_localplayers[1]) + || (splitscreen > 1 && playernum == g_localplayers[2]) + || (splitscreen > 2 && playernum == g_localplayers[3])) CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the origin!\n")); //P_MovePlayerToSpawn handles this fine if the spawnpoint is NULL. } @@ -2991,17 +2991,17 @@ mapthing_t *G_FindMatchStart(INT32 playernum) return deathmatchstarts[i]; } if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) - || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) - || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) + || (splitscreen && playernum == g_localplayers[1]) + || (splitscreen > 1 && playernum == g_localplayers[2]) + || (splitscreen > 2 && playernum == g_localplayers[3])) CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Deathmatch starts!\n")); return NULL; } if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) - || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) - || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) + || (splitscreen && playernum == g_localplayers[1]) + || (splitscreen > 1 && playernum == g_localplayers[2]) + || (splitscreen > 2 && playernum == g_localplayers[3])) CONS_Alert(CONS_WARNING, M_GetText("No Deathmatch starts in this map!\n")); return NULL; } @@ -3089,17 +3089,17 @@ mapthing_t *G_FindRaceStart(INT32 playernum) //return playerstarts[0]; if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) - || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) - || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) + || (splitscreen && playernum == g_localplayers[1]) + || (splitscreen > 1 && playernum == g_localplayers[2]) + || (splitscreen > 2 && playernum == g_localplayers[3])) CONS_Alert(CONS_WARNING, M_GetText("Could not spawn at any Race starts!\n")); return NULL; } if (playernum == consoleplayer - || (splitscreen && playernum == displayplayers[localdisplayplayers[1]]) - || (splitscreen > 1 && playernum == displayplayers[localdisplayplayers[2]]) - || (splitscreen > 2 && playernum == displayplayers[localdisplayplayers[3]])) + || (splitscreen && playernum == g_localplayers[1]) + || (splitscreen > 1 && playernum == g_localplayers[2]) + || (splitscreen > 2 && playernum == g_localplayers[3])) CONS_Alert(CONS_WARNING, M_GetText("No Race starts in this map!\n")); return NULL; } diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c index 6f5a69297..d99f85ea3 100644 --- a/src/g_splitscreen.c +++ b/src/g_splitscreen.c @@ -45,13 +45,11 @@ G_ResetSplitscreen (int playernum) /* easier to just rebuild displayplayers with local players */ for (i = 0; i <= splitscreen; ++i) { - displayplayers[i] = old_displayplayers[localdisplayplayers[i]]; - localdisplayplayers[i] = i; + displayplayers[i] = g_localplayers[i]; } while (i < MAXSPLITSCREENPLAYERS) { displayplayers[i] = consoleplayer; - localdisplayplayers[i] = 0; i++; } @@ -94,15 +92,6 @@ G_RemovePartyMember (int playernum) memcpy(&new_party[before], &old_party[after], ( old_party_size - after ) * sizeof *new_party); - if (splitscreen_partied[playernum]) - { - for (i = 0; i < MAXSPLITSCREENPLAYERS && - localdisplayplayers[i] >= after; ++i) - { - localdisplayplayers[i] -= views; - } - } - views = ( old_party_size - views ); for (i = 0; i < old_party_size; ++i) @@ -197,20 +186,13 @@ G_AddPartyMember (int invitation, int playernum) { splitscreen_partied[invitation] = true; - for (i = 0; i <= splitscreen; ++i) - { - localdisplayplayers[i] = ( old_party_size + i ); - displayplayers[i] = party[i]; - } - while (++i < new_party_size) + for (i = 0; i < new_party_size; ++i) { displayplayers[i] = party[i]; - localdisplayplayers[i] = old_party_size; } while (i < MAXSPLITSCREENPLAYERS) { displayplayers[i] = consoleplayer; - localdisplayplayers[i] = old_party_size; i++; } diff --git a/src/k_kart.c b/src/k_kart.c index ebce1458e..8fdc61529 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6635,7 +6635,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } // Play the starting countdown sounds - if (player == &players[displayplayers[localdisplayplayers[0]]]) // Don't play louder in splitscreen + if (player == &players[g_localplayers[0]]) // Don't play louder in splitscreen { if ((leveltime == starttime-(3*TICRATE)) || (leveltime == starttime-(2*TICRATE)) || (leveltime == starttime-TICRATE)) S_StartSound(NULL, sfx_s3ka7); diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 2ce3e89ae..4e75ca8f7 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -125,7 +125,7 @@ void COM_Lua_f(void) lua_pop(gL, 1); // pop command info table return; // can't execute splitscreen command without player 2! } - playernum = displayplayers[localdisplayplayers[1]]; + playernum = g_localplayers[1]; } if (netgame) diff --git a/src/m_menu.c b/src/m_menu.c index 3fe0198df..df4e2ed39 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9525,7 +9525,7 @@ static void M_SetupMultiPlayer2(INT32 choice) strcpy (setupm_name, cv_playername2.string); // set for splitscreen secondary player - setupm_player = &players[displayplayers[localdisplayplayers[1]]]; + setupm_player = &players[g_localplayers[1]]; setupm_cvskin = &cv_skin2; setupm_cvcolor = &cv_playercolor2; setupm_cvname = &cv_playername2; @@ -9537,7 +9537,7 @@ static void M_SetupMultiPlayer2(INT32 choice) setupm_fakecolor = setupm_cvcolor->value; // disable skin changes if we can't actually change skins - if (splitscreen && !CanChangeSkin(displayplayers[localdisplayplayers[1]])) + if (splitscreen && !CanChangeSkin(g_localplayers[1])) MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); else MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING); @@ -9556,7 +9556,7 @@ static void M_SetupMultiPlayer3(INT32 choice) strcpy(setupm_name, cv_playername3.string); // set for splitscreen third player - setupm_player = &players[displayplayers[localdisplayplayers[2]]]; + setupm_player = &players[g_localplayers[2]]; setupm_cvskin = &cv_skin3; setupm_cvcolor = &cv_playercolor3; setupm_cvname = &cv_playername3; @@ -9568,7 +9568,7 @@ static void M_SetupMultiPlayer3(INT32 choice) setupm_fakecolor = setupm_cvcolor->value; // disable skin changes if we can't actually change skins - if (splitscreen > 1 && !CanChangeSkin(displayplayers[localdisplayplayers[2]])) + if (splitscreen > 1 && !CanChangeSkin(g_localplayers[2])) MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); else MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING); @@ -9587,7 +9587,7 @@ static void M_SetupMultiPlayer4(INT32 choice) strcpy(setupm_name, cv_playername4.string); // set for splitscreen fourth player - setupm_player = &players[displayplayers[localdisplayplayers[3]]]; + setupm_player = &players[g_localplayers[3]]; setupm_cvskin = &cv_skin4; setupm_cvcolor = &cv_playercolor4; setupm_cvname = &cv_playername4; @@ -9599,7 +9599,7 @@ static void M_SetupMultiPlayer4(INT32 choice) setupm_fakecolor = setupm_cvcolor->value; // disable skin changes if we can't actually change skins - if (splitscreen > 2 && !CanChangeSkin(displayplayers[localdisplayplayers[3]])) + if (splitscreen > 2 && !CanChangeSkin(g_localplayers[3])) MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); else MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING); diff --git a/src/m_misc.c b/src/m_misc.c index b232bce9a..c3b8776b0 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -743,12 +743,12 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png else snprintf(lvlttltext, 48, "Unknown"); - if (gamestate == GS_LEVEL && &players[displayplayers[localdisplayplayers[0]]] && players[displayplayers[localdisplayplayers[0]]].mo) + if (gamestate == GS_LEVEL && &players[g_localplayers[0]] && players[g_localplayers[0]].mo) snprintf(locationtxt, 40, "X:%d Y:%d Z:%d A:%d", - players[displayplayers[localdisplayplayers[0]]].mo->x>>FRACBITS, - players[displayplayers[localdisplayplayers[0]]].mo->y>>FRACBITS, - players[displayplayers[localdisplayplayers[0]]].mo->z>>FRACBITS, - FixedInt(AngleFixed(players[displayplayers[localdisplayplayers[0]]].mo->angle))); + players[g_localplayers[0]].mo->x>>FRACBITS, + players[g_localplayers[0]].mo->y>>FRACBITS, + players[g_localplayers[0]].mo->z>>FRACBITS, + FixedInt(AngleFixed(players[g_localplayers[0]].mo->angle))); else snprintf(locationtxt, 40, "Unknown"); diff --git a/src/p_floor.c b/src/p_floor.c index a6419b409..510832b90 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2536,9 +2536,9 @@ void T_CameraScanner(elevator_t *elevator) lastleveltime = leveltime; } - if (players[displayplayers[localdisplayplayers[0]]].mo) + if (players[g_localplayers[0]].mo) { - if (players[displayplayers[localdisplayplayers[0]]].mo->subsector->sector == elevator->actionsector) + if (players[g_localplayers[0]].mo->subsector->sector == elevator->actionsector) { if (t_cam_dist == -42) t_cam_dist = cv_cam_dist.value; @@ -2564,9 +2564,9 @@ void T_CameraScanner(elevator_t *elevator) } } - if (splitscreen && players[displayplayers[localdisplayplayers[1]]].mo) + if (splitscreen && players[g_localplayers[1]].mo) { - if (players[displayplayers[localdisplayplayers[1]]].mo->subsector->sector == elevator->actionsector) + if (players[g_localplayers[1]].mo->subsector->sector == elevator->actionsector) { if (t_cam2_rotate == -42) t_cam2_dist = cv_cam2_dist.value; @@ -2592,9 +2592,9 @@ void T_CameraScanner(elevator_t *elevator) } } - if (splitscreen > 1 && players[displayplayers[localdisplayplayers[2]]].mo) + if (splitscreen > 1 && players[g_localplayers[2]].mo) { - if (players[displayplayers[localdisplayplayers[2]]].mo->subsector->sector == elevator->actionsector) + if (players[g_localplayers[2]].mo->subsector->sector == elevator->actionsector) { if (t_cam3_rotate == -42) t_cam3_dist = cv_cam3_dist.value; @@ -2620,9 +2620,9 @@ void T_CameraScanner(elevator_t *elevator) } } - if (splitscreen > 2 && players[displayplayers[localdisplayplayers[3]]].mo) + if (splitscreen > 2 && players[g_localplayers[3]].mo) { - if (players[displayplayers[localdisplayplayers[3]]].mo->subsector->sector == elevator->actionsector) + if (players[g_localplayers[3]].mo->subsector->sector == elevator->actionsector) { if (t_cam4_rotate == -42) t_cam4_dist = cv_cam4_dist.value; diff --git a/src/p_inter.c b/src/p_inter.c index d53423a46..81240d72f 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -63,11 +63,11 @@ void P_ForceConstant(const BasicFF_t *FFInfo) ConstantQuake.Magnitude = FFInfo->Magnitude; if (FFInfo->player == &players[consoleplayer]) I_Tactile(ConstantForce, &ConstantQuake); - else if (splitscreen && FFInfo->player == &players[displayplayers[localdisplayplayers[1]]]) + else if (splitscreen && FFInfo->player == &players[g_localplayers[1]]) I_Tactile2(ConstantForce, &ConstantQuake); - else if (splitscreen > 1 && FFInfo->player == &players[displayplayers[localdisplayplayers[2]]]) + else if (splitscreen > 1 && FFInfo->player == &players[g_localplayers[2]]) I_Tactile3(ConstantForce, &ConstantQuake); - else if (splitscreen > 2 && FFInfo->player == &players[displayplayers[localdisplayplayers[3]]]) + else if (splitscreen > 2 && FFInfo->player == &players[g_localplayers[3]]) I_Tactile4(ConstantForce, &ConstantQuake); } void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End) @@ -84,11 +84,11 @@ void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End) RampQuake.End = End; if (FFInfo->player == &players[consoleplayer]) I_Tactile(ConstantForce, &RampQuake); - else if (splitscreen && FFInfo->player == &players[displayplayers[localdisplayplayers[1]]]) + else if (splitscreen && FFInfo->player == &players[g_localplayers[1]]) I_Tactile2(ConstantForce, &RampQuake); - else if (splitscreen > 1 && FFInfo->player == &players[displayplayers[localdisplayplayers[2]]]) + else if (splitscreen > 1 && FFInfo->player == &players[g_localplayers[2]]) I_Tactile3(ConstantForce, &RampQuake); - else if (splitscreen > 2 && FFInfo->player == &players[displayplayers[localdisplayplayers[3]]]) + else if (splitscreen > 2 && FFInfo->player == &players[g_localplayers[3]]) I_Tactile4(ConstantForce, &RampQuake); } diff --git a/src/p_mobj.c b/src/p_mobj.c index d648ff0f3..b0c8f43cb 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3656,11 +3656,11 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled fixed_t cam_height = cv_cam_height.value; thiscam->z = thiscam->floorz; - if (player == &players[displayplayers[localdisplayplayers[1]]]) + if (player == &players[g_localplayers[1]]) cam_height = cv_cam2_height.value; - if (player == &players[displayplayers[localdisplayplayers[2]]]) + if (player == &players[g_localplayers[2]]) cam_height = cv_cam3_height.value; - if (player == &players[displayplayers[localdisplayplayers[3]]]) + if (player == &players[g_localplayers[3]]) cam_height = cv_cam4_height.value; if (thiscam->z > player->mo->z + player->mo->height + FixedMul(cam_height*FRACUNIT + 16*FRACUNIT, player->mo->scale)) { @@ -7282,7 +7282,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->target && mobj->target->health && mobj->tracer && mobj->target->player && !mobj->target->player->spectator && mobj->target->player->health && mobj->target->player->playerstate != PST_DEAD - && players[displayplayers[localdisplayplayers[0]]].mo && !players[displayplayers[localdisplayplayers[0]]].spectator) + && players[g_localplayers[0]].mo && !players[g_localplayers[0]].spectator) { fixed_t scale = 3*mobj->target->scale; @@ -11136,13 +11136,13 @@ void P_PrecipitationEffects(void) // Local effects from here on out! // If we're not in game fully yet, we don't worry about them. - if (!playeringame[displayplayers[localdisplayplayers[0]]] || !players[displayplayers[localdisplayplayers[0]]].mo) + if (!playeringame[g_localplayers[0]] || !players[g_localplayers[0]].mo) return; if (sound_disabled) return; // Sound off? D'aw, no fun. - if (players[displayplayers[localdisplayplayers[0]]].mo->subsector->sector->ceilingpic == skyflatnum) + if (players[g_localplayers[0]].mo->subsector->sector->ceilingpic == skyflatnum) volume = 255; // Sky above? We get it full blast. else { @@ -11150,17 +11150,17 @@ void P_PrecipitationEffects(void) fixed_t closedist, newdist; // Essentially check in a 1024 unit radius of the player for an outdoor area. - yl = players[displayplayers[localdisplayplayers[0]]].mo->y - 1024*FRACUNIT; - yh = players[displayplayers[localdisplayplayers[0]]].mo->y + 1024*FRACUNIT; - xl = players[displayplayers[localdisplayplayers[0]]].mo->x - 1024*FRACUNIT; - xh = players[displayplayers[localdisplayplayers[0]]].mo->x + 1024*FRACUNIT; + yl = players[g_localplayers[0]].mo->y - 1024*FRACUNIT; + yh = players[g_localplayers[0]].mo->y + 1024*FRACUNIT; + xl = players[g_localplayers[0]].mo->x - 1024*FRACUNIT; + xh = players[g_localplayers[0]].mo->x + 1024*FRACUNIT; closedist = 2048*FRACUNIT; for (y = yl; y <= yh; y += FRACUNIT*64) for (x = xl; x <= xh; x += FRACUNIT*64) { if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) // Found the outdoors! { - newdist = S_CalculateSoundDistance(players[displayplayers[localdisplayplayers[0]]].mo->x, players[displayplayers[localdisplayplayers[0]]].mo->y, 0, x, y, 0); + newdist = S_CalculateSoundDistance(players[g_localplayers[0]].mo->x, players[g_localplayers[0]].mo->y, 0, x, y, 0); if (newdist < closedist) closedist = newdist; } @@ -11175,7 +11175,7 @@ void P_PrecipitationEffects(void) volume = 255; if (sounds_rain && (!leveltime || leveltime % 80 == 1)) - S_StartSoundAtVolume(players[displayplayers[localdisplayplayers[0]]].mo, sfx_rainin, volume); + S_StartSoundAtVolume(players[g_localplayers[0]].mo, sfx_rainin, volume); if (!sounds_thunder) return; @@ -11183,7 +11183,7 @@ void P_PrecipitationEffects(void) if (effects_lightning && lightningStrike && volume) { // Large, close thunder sounds to go with our lightning. - S_StartSoundAtVolume(players[displayplayers[localdisplayplayers[0]]].mo, sfx_litng1 + M_RandomKey(4), volume); + S_StartSoundAtVolume(players[g_localplayers[0]].mo, sfx_litng1 + M_RandomKey(4), volume); } else if (thunderchance < 20) { @@ -11191,7 +11191,7 @@ void P_PrecipitationEffects(void) if (volume < 80) volume = 80; - S_StartSoundAtVolume(players[displayplayers[localdisplayplayers[0]]].mo, sfx_athun1 + M_RandomKey(2), volume); + S_StartSoundAtVolume(players[g_localplayers[0]].mo, sfx_athun1 + M_RandomKey(2), volume); } } diff --git a/src/p_setup.c b/src/p_setup.c index 491127d5b..0b237c520 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2567,29 +2567,29 @@ static void P_ForceCharacter(const char *forcecharskin) { if (splitscreen) { - SetPlayerSkin(displayplayers[localdisplayplayers[1]], forcecharskin); - if ((unsigned)cv_playercolor2.value != skins[players[displayplayers[localdisplayplayers[1]]].skin].prefcolor && !modeattacking) + SetPlayerSkin(g_localplayers[1], forcecharskin); + if ((unsigned)cv_playercolor2.value != skins[players[g_localplayers[1]].skin].prefcolor && !modeattacking) { - CV_StealthSetValue(&cv_playercolor2, skins[players[displayplayers[localdisplayplayers[1]]].skin].prefcolor); - players[displayplayers[localdisplayplayers[1]]].skincolor = skins[players[displayplayers[localdisplayplayers[1]]].skin].prefcolor; + CV_StealthSetValue(&cv_playercolor2, skins[players[g_localplayers[1]].skin].prefcolor); + players[g_localplayers[1]].skincolor = skins[players[g_localplayers[1]].skin].prefcolor; } if (splitscreen > 1) { - SetPlayerSkin(displayplayers[localdisplayplayers[2]], forcecharskin); - if ((unsigned)cv_playercolor3.value != skins[players[displayplayers[localdisplayplayers[2]]].skin].prefcolor && !modeattacking) + SetPlayerSkin(g_localplayers[2], forcecharskin); + if ((unsigned)cv_playercolor3.value != skins[players[g_localplayers[2]].skin].prefcolor && !modeattacking) { - CV_StealthSetValue(&cv_playercolor3, skins[players[displayplayers[localdisplayplayers[2]]].skin].prefcolor); - players[displayplayers[localdisplayplayers[2]]].skincolor = skins[players[displayplayers[localdisplayplayers[2]]].skin].prefcolor; + CV_StealthSetValue(&cv_playercolor3, skins[players[g_localplayers[2]].skin].prefcolor); + players[g_localplayers[2]].skincolor = skins[players[g_localplayers[2]].skin].prefcolor; } if (splitscreen > 2) { - SetPlayerSkin(displayplayers[localdisplayplayers[3]], forcecharskin); - if ((unsigned)cv_playercolor4.value != skins[players[displayplayers[localdisplayplayers[3]]].skin].prefcolor && !modeattacking) + SetPlayerSkin(g_localplayers[3], forcecharskin); + if ((unsigned)cv_playercolor4.value != skins[players[g_localplayers[3]].skin].prefcolor && !modeattacking) { - CV_StealthSetValue(&cv_playercolor4, skins[players[displayplayers[localdisplayplayers[3]]].skin].prefcolor); - players[displayplayers[localdisplayplayers[3]]].skincolor = skins[players[displayplayers[localdisplayplayers[3]]].skin].prefcolor; + CV_StealthSetValue(&cv_playercolor4, skins[players[g_localplayers[3]].skin].prefcolor); + players[g_localplayers[3]].skincolor = skins[players[g_localplayers[3]].skin].prefcolor; } } } @@ -3270,7 +3270,7 @@ boolean P_SetupLevel(boolean skipprecip) /*if (rendermode != render_none) CV_Set(&cv_fov, cv_fov.defaultvalue);*/ - displayplayers[localdisplayplayers[0]] = consoleplayer; // Start with your OWN view, please! + g_localplayers[0] = consoleplayer; // Start with your OWN view, please! } /*if (cv_useranalog.value) diff --git a/src/p_user.c b/src/p_user.c index 6a660f20f..193d597b5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7347,17 +7347,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall focusangle = localangle[0]; focusaiming = localaiming[0]; } - else if (player == &players[displayplayers[localdisplayplayers[1]]]) + else if (player == &players[g_localplayers[1]]) { focusangle = localangle[1]; focusaiming = localaiming[1]; } - else if (player == &players[displayplayers[localdisplayplayers[2]]]) + else if (player == &players[g_localplayers[2]]) { focusangle = localangle[2]; focusaiming = localaiming[2]; } - else if (player == &players[displayplayers[localdisplayplayers[3]]]) + else if (player == &players[g_localplayers[3]]) { focusangle = localangle[3]; focusaiming = localaiming[3]; @@ -7893,8 +7893,8 @@ boolean P_SpectatorJoinGame(player_t *player) player->playerstate = PST_REBORN; //Reset away view - if (P_IsLocalPlayer(player) && displayplayers[localdisplayplayers[0]] != consoleplayer) - displayplayers[localdisplayplayers[0]] = consoleplayer; + if (P_IsLocalPlayer(player) && g_localplayers[0] != consoleplayer) + g_localplayers[0] = consoleplayer; HU_AddChatText(va(M_GetText("\x82*%s entered the game."), player_names[player-players]), false); return true; // no more player->mo, cannot continue. diff --git a/src/st_stuff.c b/src/st_stuff.c index 280984ca7..02c4fe445 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2089,7 +2089,7 @@ void ST_Drawer(void) UINT8 i; #ifdef SEENAMES - if (cv_seenames.value && cv_allowseenames.value && displayplayers[localdisplayplayers[0]] == consoleplayer && seenplayer && seenplayer->mo && !mapreset) + if (cv_seenames.value && cv_allowseenames.value && g_localplayers[0] == consoleplayer && seenplayer && seenplayer->mo && !mapreset) { if (cv_seenames.value == 1) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, player_names[seenplayer-players]); diff --git a/src/y_inter.c b/src/y_inter.c index e27289b87..85bfcad06 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1263,19 +1263,19 @@ void Y_VoteDrawer(void) { case 1: thiscurs = cursor2; - p = displayplayers[localdisplayplayers[1]]; + p = g_localplayers[1]; break; case 2: thiscurs = cursor3; - p = displayplayers[localdisplayplayers[2]]; + p = g_localplayers[2]; break; case 3: thiscurs = cursor4; - p = displayplayers[localdisplayplayers[3]]; + p = g_localplayers[3]; break; default: thiscurs = cursor1; - p = displayplayers[localdisplayplayers[0]]; + p = g_localplayers[0]; break; } @@ -1563,13 +1563,13 @@ void Y_VoteTicker(void) switch (i) { case 1: - p = displayplayers[localdisplayplayers[1]]; + p = g_localplayers[1]; break; case 2: - p = displayplayers[localdisplayplayers[2]]; + p = g_localplayers[2]; break; case 3: - p = displayplayers[localdisplayplayers[3]]; + p = g_localplayers[3]; break; default: p = consoleplayer; From fc1e4b5cc524f667f9a771f3ba3647256c570fb3 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 18:22:45 -0800 Subject: [PATCH 11/36] Just say "joined" so to not worry about plurals --- src/d_netcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index fa10c1640..e044b3be0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2068,7 +2068,7 @@ static void Got_AcceptPartyInvite(UINT8 **cp,INT32 playernum) if (splitscreen_partied[invitation]) { HU_AddChatText(va( - "\x82*%s has joined your party!", + "\x82*%s joined your party!", VaguePartyDescription( playernum, splitscreen_original_party_size, '\x82') ), true); From dfe6d62d7658c4dd1b18db98d02176ec80925fd6 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 18:28:30 -0800 Subject: [PATCH 12/36] bruh --- src/d_netcmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e044b3be0..2c2f67250 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1335,8 +1335,8 @@ VaguePartyDescription (int playernum, int *party_sizes, int default_color) sprintf(description, "\x83%s%c and %d others", name, - ( size - 1 ), - default_color + default_color, + ( size - 1 ) ); } else From 7fe61a99dfb178272c549b2b4e7d6b06c1e133fc Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 18:29:45 -0800 Subject: [PATCH 13/36] More plurals --- src/d_netcmd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 2c2f67250..53bc3e928 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1333,10 +1333,11 @@ VaguePartyDescription (int playernum, int *party_sizes, int default_color) if (size > 1 && size <= MAXSPLITSCREENPLAYERS) { sprintf(description, - "\x83%s%c and %d others", + "\x83%s%c and %d other%s", name, default_color, - ( size - 1 ) + ( size - 1 ), + ( (size > 2) ? "s" : "" ) ); } else From 70bb244dd63be4665c6eba00fbd132a333e18897 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 18:35:47 -0800 Subject: [PATCH 14/36] Reset camera when party changes --- src/g_splitscreen.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c index d99f85ea3..9127bd18a 100644 --- a/src/g_splitscreen.c +++ b/src/g_splitscreen.c @@ -11,6 +11,7 @@ #include "doomdef.h" #include "g_game.h" +#include "p_local.h" #include "r_local.h" int splitscreen_original_party_size[MAXPLAYERS]; @@ -46,6 +47,7 @@ G_ResetSplitscreen (int playernum) for (i = 0; i <= splitscreen; ++i) { displayplayers[i] = g_localplayers[i]; + P_ResetCamera(&players[displayplayers[i]], &camera[i]); } while (i < MAXSPLITSCREENPLAYERS) { @@ -113,6 +115,7 @@ G_RemovePartyMember (int playernum) for (i = 0; i < views; ++i) { displayplayers[i] = new_party[i]; + P_ResetCamera(&players[displayplayers[i]], &camera[i]); } while (i < MAXSPLITSCREENPLAYERS) { @@ -176,6 +179,7 @@ G_AddPartyMember (int invitation, int playernum) for (i = old_party_size; i < new_party_size; ++i) { displayplayers[i] = party[i]; + P_ResetCamera(&players[displayplayers[i]], &camera[i]); } r_splitscreen += views; @@ -189,6 +193,7 @@ G_AddPartyMember (int invitation, int playernum) for (i = 0; i < new_party_size; ++i) { displayplayers[i] = party[i]; + P_ResetCamera(&players[displayplayers[i]], &camera[i]); } while (i < MAXSPLITSCREENPLAYERS) { From e593b5297a4a745f8271ba5a0d7bc0bba6077819 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 19:17:56 -0800 Subject: [PATCH 15/36] Reset party size --- src/d_clisrv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a6190a0dc..b5b8c8143 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2652,6 +2652,8 @@ void CL_ClearPlayer(INT32 playernum) } splitscreen_invitations[playernum] = -1; + splitscreen_party_size[playernum] = 0; + splitscreen_original_party_size[playernum] = 0; memset(&players[playernum], 0, sizeof (player_t)); } @@ -2728,6 +2730,8 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) (void)reason; #endif + G_RemovePartyMember(playernum); + // Reset player data CL_ClearPlayer(playernum); @@ -2745,8 +2749,6 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) RemoveAdminPlayer(playernum); // don't stay admin after you're gone } - G_RemovePartyMember(playernum); - if (playernum == g_localplayers[0] && !demo.playback) g_localplayers[0] = consoleplayer; // don't look through someone's view who isn't there From 7961ac9d955474d44c3217ca353a7f7e7a3aa019 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 22:01:42 -0800 Subject: [PATCH 16/36] Fix moving while viewing another player not resetting the viewpoint --- src/g_game.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ffb75f3fb..22ded1c93 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1596,8 +1596,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) //Reset away view if a command is given. if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) - && g_localplayers[0] != consoleplayer && ssplayer == 1) - g_localplayers[0] = consoleplayer; + && ! r_splitscreen && displayplayers[0] != consoleplayer && ssplayer == 1) + displayplayers[0] = consoleplayer; } From 0c814ce42dd3fcbc609b1bab6cf2d7a92b19fc68 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 22:14:14 -0800 Subject: [PATCH 17/36] Sync look back Also fixes look back applying to the first player in parties instead of locally. --- src/d_ticcmd.h | 3 ++- src/g_game.c | 7 +++++-- src/g_game.h | 2 +- src/k_kart.c | 2 +- src/p_user.c | 5 +---- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index dab758f8d..c73c161b5 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -32,8 +32,9 @@ typedef enum BT_ATTACK = 1<<4, // Use Item BT_FORWARD = 1<<5, // Aim Item Forward BT_BACKWARD = 1<<6, // Aim Item Backward + BT_LOOKBACK = 1<<7, // Look Backward - // free: 1<<7 to 1<<12 + // free: 1<<8 to 1<<12 // Lua garbage BT_CUSTOM1 = 1<<13, diff --git a/src/g_game.c b/src/g_game.c index 22ded1c93..551261de8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1231,7 +1231,6 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 p) // INT32 localaiming[MAXSPLITSCREENPLAYERS]; angle_t localangle[MAXSPLITSCREENPLAYERS]; -boolean camspin[MAXSPLITSCREENPLAYERS]; static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; @@ -1456,6 +1455,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (InputDown(gc_drift, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_DRIFT; + // rear view with any button/key + axis = JoyAxis(AXISLOOKBACK, ssplayer); + if (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_LOOKBACK; + // Lua scriptable buttons if (InputDown(gc_custom1, ssplayer)) cmd->buttons |= BT_CUSTOM1; @@ -1576,7 +1580,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) keyboard_look[ssplayer-1] = kbl; turnheld[ssplayer-1] = th; resetdown[ssplayer-1] = rd; - camspin[ssplayer-1] = InputDown(gc_lookback, ssplayer); } /* Lua: Allow this hook to overwrite ticcmd. diff --git a/src/g_game.h b/src/g_game.h index de88d6bdc..9d4a3e4d9 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -129,6 +129,7 @@ typedef enum AXISDEAD, //Axises that don't want deadzones AXISFIRE, AXISDRIFT, + AXISLOOKBACK, } axis_input_e; // mouseaiming (looking up/down with the mouse or keyboard) @@ -154,7 +155,6 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 p); extern angle_t localangle[MAXSPLITSCREENPLAYERS]; extern INT32 localaiming[MAXSPLITSCREENPLAYERS]; // should be an angle_t but signed -extern boolean camspin[MAXSPLITSCREENPLAYERS]; // SRB2Kart // // GAME diff --git a/src/k_kart.c b/src/k_kart.c index 8fdc61529..9ffe143fd 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8874,7 +8874,7 @@ static void K_drawKartPlayerCheck(void) if (stplyr->awayviewtics) return; - if (camspin[0]) + if (( stplyr->cmd.buttons & BT_LOOKBACK )) return; for (i = 0; i < MAXPLAYERS; i++) diff --git a/src/p_user.c b/src/p_user.c index 193d597b5..035979c75 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7371,6 +7371,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (P_CameraThinker(player, thiscam, resetcalled)) return true; + lookback = ( player->cmd.buttons & BT_LOOKBACK ); if (thiscam == &camera[1]) // Camera 2 { @@ -7380,7 +7381,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam2_rotate.value; camdist = FixedMul(cv_cam2_dist.value, mapobjectscale); camheight = FixedMul(cv_cam2_height.value, mapobjectscale); - lookback = camspin[1]; } else if (thiscam == &camera[2]) // Camera 3 { @@ -7390,7 +7390,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam3_rotate.value; camdist = FixedMul(cv_cam3_dist.value, mapobjectscale); camheight = FixedMul(cv_cam3_height.value, mapobjectscale); - lookback = camspin[2]; } else if (thiscam == &camera[3]) // Camera 4 { @@ -7400,7 +7399,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam4_rotate.value; camdist = FixedMul(cv_cam4_dist.value, mapobjectscale); camheight = FixedMul(cv_cam4_height.value, mapobjectscale); - lookback = camspin[3]; } else // Camera 1 { @@ -7410,7 +7408,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camrotate = cv_cam_rotate.value; camdist = FixedMul(cv_cam_dist.value, mapobjectscale); camheight = FixedMul(cv_cam_height.value, mapobjectscale); - lookback = camspin[0]; } if (timeover) From 8619ec4d0f01b914598f036769489329473eed45 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Feb 2020 22:19:11 -0800 Subject: [PATCH 18/36] Fix first person camera angle in parties --- src/r_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index cf16802cb..fb5ae220d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -899,11 +899,11 @@ void R_SkyboxFrame(player_t *player) viewangle = localangle[0]; // WARNING: camera uses this aimingangle = localaiming[0]; } - else if (r_splitscreen) + else if (splitscreen) { - for (i = 1; i <= r_splitscreen; i++) + for (i = 1; i <= splitscreen; i++) { - if (player == &players[displayplayers[i]]) + if (player == &players[g_localplayers[i]]) { viewangle = localangle[i]; aimingangle = localaiming[i]; @@ -1158,12 +1158,12 @@ void R_SetupFrame(player_t *player, boolean skybox) viewangle = localangle[0]; // WARNING: camera uses this aimingangle = localaiming[0]; } - else if (r_splitscreen) + else if (splitscreen) { UINT8 i; - for (i = 1; i <= r_splitscreen; i++) + for (i = 1; i <= splitscreen; i++) { - if (player == &players[displayplayers[i]]) + if (player == &players[g_localplayers[i]]) { viewangle = localangle[i]; aimingangle = localaiming[i]; From ea8fd7348f448e4a0170d1d24a37901f967e0ab5 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 22 Feb 2020 19:12:35 -0800 Subject: [PATCH 19/36] Show lagless for all the host's splitscreen players --- src/k_kart.c | 2 +- src/y_inter.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 23bb15761..7deaa08a1 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8406,7 +8406,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I y2 = y; - if (tab[i].num == 0 && server_lagless) + if (playerconsole[tab[i].num] == 0 && server_lagless) { y2 = ( y - 4 ); diff --git a/src/y_inter.c b/src/y_inter.c index 44ffdd70a..444e0bd7d 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -495,7 +495,7 @@ void Y_IntermissionDrawer(void) y2 = y; - if (data.match.num[i] == 0 && server_lagless) + if (playerconsole[data.match.num[i]] == 0 && server_lagless) { static int alagles_timer = 0; patch_t *alagles; From ac75b30400744a2d9a34e604f87f5c809d298f73 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 2 Mar 2020 21:09:12 -0800 Subject: [PATCH 20/36] r_splitscreen for opengl --- src/hardware/hw_main.c | 56 +++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 659af386d..9dd84cddd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4144,11 +4144,11 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t angle_t shadowdir; // Set direction - if (splitscreen && stplyr == &players[displayplayers[1]]) + if (r_splitscreen && stplyr == &players[displayplayers[1]]) shadowdir = localangle[1] + FixedAngle(cv_cam2_rotate.value); - else if (splitscreen > 1 && stplyr == &players[displayplayers[2]]) + else if (r_splitscreen > 1 && stplyr == &players[displayplayers[2]]) shadowdir = localangle[2] + FixedAngle(cv_cam3_rotate.value); - else if (splitscreen > 2 && stplyr == &players[displayplayers[3]]) + else if (r_splitscreen > 2 && stplyr == &players[displayplayers[3]]) shadowdir = localangle[3] + FixedAngle(cv_cam4_rotate.value); else shadowdir = localangle[0] + FixedAngle(cv_cam_rotate.value); @@ -5485,7 +5485,7 @@ static void HWR_AddSprites(sector_t *sec) if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) continue; - if (splitscreen) + if (r_splitscreen) { if (thing->eflags & MFE_DRAWONLYFORP1) if (viewssnum != 0) @@ -5495,11 +5495,11 @@ static void HWR_AddSprites(sector_t *sec) if (viewssnum != 1) continue; - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) + if (thing->eflags & MFE_DRAWONLYFORP3 && r_splitscreen > 1) if (viewssnum != 2) continue; - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) + if (thing->eflags & MFE_DRAWONLYFORP4 && r_splitscreen > 2) if (viewssnum != 3) continue; } @@ -5520,7 +5520,7 @@ static void HWR_AddSprites(sector_t *sec) if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) continue; - if (splitscreen) + if (r_splitscreen) { if (thing->eflags & MFE_DRAWONLYFORP1) if (viewssnum != 0) @@ -5530,11 +5530,11 @@ static void HWR_AddSprites(sector_t *sec) if (viewssnum != 1) continue; - if (thing->eflags & MFE_DRAWONLYFORP3 && splitscreen > 1) + if (thing->eflags & MFE_DRAWONLYFORP3 && r_splitscreen > 1) if (viewssnum != 2) continue; - if (thing->eflags & MFE_DRAWONLYFORP4 && splitscreen > 2) + if (thing->eflags & MFE_DRAWONLYFORP4 && r_splitscreen > 2) if (viewssnum != 3) continue; } @@ -5971,7 +5971,7 @@ static void HWR_DrawSkyBackground(void) dimensionmultiply = ((float)tex->height/(128.0f*aspectratio)); - if (splitscreen == 1) + if (r_splitscreen == 1) { dimensionmultiply *= 2; angle *= 2; @@ -6043,10 +6043,10 @@ void HWR_SetViewSize(void) gr_viewwidth = (float)vid.width; gr_viewheight = (float)vid.height; - if (splitscreen) + if (r_splitscreen) gr_viewheight /= 2; - if (splitscreen > 1) + if (r_splitscreen > 1) gr_viewwidth /= 2; gr_basecenterx = gr_viewwidth / 2; @@ -6102,13 +6102,13 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) gr_viewwindowy = gr_baseviewwindowy; gr_windowcentery = gr_basewindowcentery; - if ((splitscreen == 1 && viewnumber == 1) || (splitscreen > 1 && viewnumber > 1)) + if ((r_splitscreen == 1 && viewnumber == 1) || (r_splitscreen > 1 && viewnumber > 1)) { gr_viewwindowy += gr_viewheight; gr_windowcentery += gr_viewheight; } - if (splitscreen > 1 && viewnumber & 1) + if (r_splitscreen > 1 && viewnumber & 1) { gr_viewwindowx += gr_viewwidth; gr_windowcenterx += gr_viewwidth; @@ -6150,7 +6150,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) atransform.scalez = 1; atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails - atransform.splitscreen = splitscreen; + atransform.splitscreen = r_splitscreen; gr_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); @@ -6169,7 +6169,7 @@ if (0) HWR_DrawSkyBackground(); //Hurdler: it doesn't work in splitscreen mode - drawsky = splitscreen; + drawsky = r_splitscreen; HWR_ClearSprites(); @@ -6202,11 +6202,11 @@ if (0) // Make a viewangle int so we can render things based on mouselook if (player == &players[consoleplayer]) viewangle = localaiming[0]; - else if (splitscreen && player == &players[displayplayers[1]]) + else if (r_splitscreen && player == &players[displayplayers[1]]) viewangle = localaiming[1]; - else if (splitscreen > 1 && player == &players[displayplayers[2]]) + else if (r_splitscreen > 1 && player == &players[displayplayers[2]]) viewangle = localaiming[2]; - else if (splitscreen > 2 && player == &players[displayplayers[3]]) + else if (r_splitscreen > 2 && player == &players[displayplayers[3]]) viewangle = localaiming[3]; // Handle stuff when you are looking farther up or down. @@ -6336,13 +6336,13 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) gr_viewwindowy = gr_baseviewwindowy; gr_windowcentery = gr_basewindowcentery; - if ((splitscreen == 1 && viewnumber == 1) || (splitscreen > 1 && viewnumber > 1)) + if ((r_splitscreen == 1 && viewnumber == 1) || (r_splitscreen > 1 && viewnumber > 1)) { gr_viewwindowy += gr_viewheight; gr_windowcentery += gr_viewheight; } - if (splitscreen > 1 && viewnumber & 1) + if (r_splitscreen > 1 && viewnumber & 1) { gr_viewwindowx += gr_viewwidth; gr_windowcenterx += gr_viewwidth; @@ -6384,7 +6384,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) atransform.scalez = 1; atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails - atransform.splitscreen = splitscreen; + atransform.splitscreen = r_splitscreen; gr_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); @@ -6403,7 +6403,7 @@ if (0) HWR_DrawSkyBackground(); //Hurdler: it doesn't work in splitscreen mode - drawsky = splitscreen; + drawsky = r_splitscreen; HWR_ClearSprites(); @@ -6436,11 +6436,11 @@ if (0) // Make a viewangle int so we can render things based on mouselook if (player == &players[consoleplayer]) viewangle = localaiming[0]; - else if (splitscreen && player == &players[displayplayers[1]]) + else if (r_splitscreen && player == &players[displayplayers[1]]) viewangle = localaiming[1]; - else if (splitscreen > 1 && player == &players[displayplayers[2]]) + else if (r_splitscreen > 1 && player == &players[displayplayers[2]]) viewangle = localaiming[2]; - else if (splitscreen > 2 && player == &players[displayplayers[3]]) + else if (r_splitscreen > 2 && player == &players[displayplayers[3]]) viewangle = localaiming[3]; // Handle stuff when you are looking farther up or down. @@ -6920,7 +6920,7 @@ void HWR_DoPostProcessor(player_t *player) postimg_t *type = &postimgtype[0]; UINT8 i; - for (i = splitscreen; i > 0; i--) + for (i = r_splitscreen; i > 0; i--) { if (player == &players[displayplayers[i]]) { @@ -6958,7 +6958,7 @@ void HWR_DoPostProcessor(player_t *player) if(gamestate != GS_INTERMISSION) HWD.pfnMakeScreenTexture(); - if (splitscreen) // Not supported in splitscreen - someone want to add support? + if (r_splitscreen) // Not supported in splitscreen - someone want to add support? return; // Drunken vision! WooOOooo~ From 9b239e82523640ae7da1f30915f13d101261a65a Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 3 Mar 2020 18:49:26 -0800 Subject: [PATCH 21/36] Set extra displayplayers to displayplayers[0] instead of splitscreen for parties This fixes P2's HUD drawing in P4's area in a 3P party, when the first local player was P2. --- src/g_splitscreen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c index 9127bd18a..939eacef0 100644 --- a/src/g_splitscreen.c +++ b/src/g_splitscreen.c @@ -119,7 +119,7 @@ G_RemovePartyMember (int playernum) } while (i < MAXSPLITSCREENPLAYERS) { - displayplayers[i] = consoleplayer; + displayplayers[i] = displayplayers[0]; i++; } @@ -197,7 +197,7 @@ G_AddPartyMember (int invitation, int playernum) } while (i < MAXSPLITSCREENPLAYERS) { - displayplayers[i] = consoleplayer; + displayplayers[i] = displayplayers[0]; i++; } From dd29a44ecc61906a7b2ba13a734ed0fc0228d29c Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 3 Mar 2020 19:17:27 -0800 Subject: [PATCH 22/36] cancelinvite command to rescind a party invitation --- src/d_netcmd.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/d_netcmd.h | 5 ++-- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 53bc3e928..ce3f9b290 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -65,6 +65,7 @@ static void Got_WeaponPref(UINT8 **cp, INT32 playernum); static void Got_PowerLevel(UINT8 **cp, INT32 playernum); static void Got_PartyInvite(UINT8 **cp, INT32 playernum); static void Got_AcceptPartyInvite(UINT8 **cp, INT32 playernum); +static void Got_CancelPartyInvite(UINT8 **cp, INT32 playernum); static void Got_LeaveParty(UINT8 **cp, INT32 playernum); static void Got_Mapcmd(UINT8 **cp, INT32 playernum); static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum); @@ -138,6 +139,7 @@ static void Command_View_f (void); static void Command_SetViews_f(void); static void Command_Invite_f(void); +static void Command_CancelInvite_f(void); static void Command_AcceptInvite_f(void); static void Command_RejectInvite_f(void); static void Command_LeaveParty_f(void); @@ -554,6 +556,7 @@ void D_RegisterServerCommands(void) RegisterNetXCmd(XD_POWERLEVEL, Got_PowerLevel); RegisterNetXCmd(XD_PARTYINVITE, Got_PartyInvite); RegisterNetXCmd(XD_ACCEPTPARTYINVITE, Got_AcceptPartyInvite); + RegisterNetXCmd(XD_CANCELPARTYINVITE, Got_CancelPartyInvite); RegisterNetXCmd(XD_LEAVEPARTY, Got_LeaveParty); RegisterNetXCmd(XD_MAP, Got_Mapcmd); RegisterNetXCmd(XD_EXITLEVEL, Got_ExitLevelcmd); @@ -765,6 +768,7 @@ void D_RegisterClientCommands(void) COM_AddCommand("changeteam4", Command_Teamchange4_f); COM_AddCommand("invite", Command_Invite_f); + COM_AddCommand("cancelinvite", Command_CancelInvite_f); COM_AddCommand("acceptinvite", Command_AcceptInvite_f); COM_AddCommand("rejectinvite", Command_RejectInvite_f); COM_AddCommand("leaveparty", Command_LeaveParty_f); @@ -2096,6 +2100,43 @@ static void Got_AcceptPartyInvite(UINT8 **cp,INT32 playernum) } } +static void Got_CancelPartyInvite(UINT8 **cp,INT32 playernum) +{ + UINT8 invitee; + + invitee = READUINT8 (*cp); + + if ( + invitee >= 0 && + invitee < MAXPLAYERS && + playeringame[invitee] + ){ + invitee = playerconsole[invitee]; + + if (splitscreen_invitations[invitee] == playerconsole[playernum]) + { + splitscreen_invitations[invitee] = -1; + + if (consoleplayer == invitee) + { + HU_AddChatText("\x85*Your invitation has been rescinded.", true); + } + } + } + else + { + CONS_Alert(CONS_WARNING, M_GetText("Illegal cancel splitscreen invite received from %s\n"), player_names[playernum]); + if (server) + { + XBOXSTATIC UINT8 buf[2]; + + buf[0] = (UINT8)playernum; + buf[1] = KICK_MSG_CON_FAIL; + SendNetXCmd(XD_KICK, &buf, 2); + } + } +} + static void Got_LeaveParty(UINT8 **cp,INT32 playernum) { if (playerconsole[playernum] != playernum) @@ -2438,6 +2479,45 @@ Command_Invite_f (void) SendNetXCmd(XD_PARTYINVITE, &invitee, 1); } +static void +Command_CancelInvite_f (void) +{ + UINT8 invitee; + + if (COM_Argc() != 2) + { + CONS_Printf("cancelinvite : Rescind a party invitation.\n"); + return; + } + + invitee = LookupPlayer(COM_Argv(1)); + + if (invitee == -1) + { + CONS_Alert(CONS_WARNING, "There is no player by that name!\n"); + return; + } + if (!playeringame[invitee]) + { + CONS_Alert(CONS_WARNING, "There is no player using that slot!\n"); + return; + } + + if (splitscreen_invitations[invitee] != consoleplayer) + { + CONS_Alert(CONS_WARNING, + "You have not invited this player!\n"); + } + + CONS_Printf( + "Rescinding invite to %s...\n", + VaguePartyDescription( + invitee, splitscreen_original_party_size, '\x80') + ); + + SendNetXCmd(XD_CANCELPARTYINVITE, &invitee, 1); +} + static boolean CheckPartyInvite (void) { diff --git a/src/d_netcmd.h b/src/d_netcmd.h index fe1f59ad2..b18dfa59c 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -182,9 +182,10 @@ typedef enum XD_PARTYINVITE, // 27 XD_ACCEPTPARTYINVITE, // 28 XD_LEAVEPARTY, // 29 + XD_CANCELPARTYINVITE, // 30 #ifdef HAVE_BLUA - XD_LUACMD, // 30 - XD_LUAVAR, // 31 + XD_LUACMD, // 31 + XD_LUAVAR, // 32 #endif MAXNETXCMD } netxcmd_t; From 74f47f83f2fb2f902c4e2d62f490e3157613d5d1 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 3 Mar 2020 19:22:32 -0800 Subject: [PATCH 23/36] Party yourself with ALL party members when being added to a party --- src/g_splitscreen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c index 939eacef0..7aec3f159 100644 --- a/src/g_splitscreen.c +++ b/src/g_splitscreen.c @@ -188,10 +188,10 @@ G_AddPartyMember (int invitation, int playernum) } else if (playernum == consoleplayer) { - splitscreen_partied[invitation] = true; - for (i = 0; i < new_party_size; ++i) { + splitscreen_partied[playerconsole[party[i]]] = true; + displayplayers[i] = party[i]; P_ResetCamera(&players[displayplayers[i]], &camera[i]); } From 26794eef469e4e17687c73c5317b3a2e7b7abe04 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 18 Mar 2020 19:42:13 -0700 Subject: [PATCH 24/36] Draw mini ping counter in splitscreen --- src/hu_stuff.c | 42 +++++++++++++++++++++++++++++++++--------- src/hu_stuff.h | 1 + src/k_kart.c | 34 ++++++++++++++++++++++++++++++++++ src/screen.c | 2 +- 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index ad64552d8..c9fb7f45e 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -78,6 +78,7 @@ patch_t *cred_font[CRED_FONTSIZE]; // Note: I'd like to adress that at this point we might *REALLY* want to work towards a common drawString function that can take any font we want because this is really turning into a MESS. :V -Lat' patch_t *pingnum[10]; patch_t *pinggfx[5]; // small ping graphic +patch_t *mping[5]; // smaller ping graphic patch_t *framecounter; patch_t *frameslash; // framerate stuff. Used in screen.c @@ -311,6 +312,8 @@ void HU_LoadGraphics(void) { sprintf(buffer, "PINGGFX%d", i+1); pinggfx[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + sprintf(buffer, "MPING%d", i+1); + mping[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } // fps stuff @@ -2480,22 +2483,30 @@ void HU_Erase(void) // IN-LEVEL MULTIPLAYER RANKINGS //====================================================================== +static int +Ping_gfx_num (int ping) +{ + if (ping < 76) + return 0; + else if (ping < 137) + return 1; + else if (ping < 256) + return 2; + else if (ping < 500) + return 3; + else + return 4; +} + // // HU_drawPing // void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags) { - INT32 gfxnum = 4; // gfx to draw + INT32 gfxnum; // gfx to draw UINT8 const *colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SALMON, GTC_CACHE); - if (ping < 76) - gfxnum = 0; - else if (ping < 137) - gfxnum = 1; - else if (ping < 256) - gfxnum = 2; - else if (ping < 500) - gfxnum = 3; + gfxnum = Ping_gfx_num(ping); V_DrawScaledPatch(x, y, flags, pinggfx[gfxnum]); if (servermaxping && ping > servermaxping && hu_tick < 4) // flash ping red if too high @@ -2504,6 +2515,19 @@ void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags) V_DrawPingNum(x, y+9, flags, ping, NULL); } +void +HU_drawMiniPing (INT32 x, INT32 y, UINT32 ping, INT32 flags) +{ + patch_t *patch; + + patch = mping[Ping_gfx_num(ping)]; + + if (( flags & V_SNAPTORIGHT )) + x += ( BASEVIDWIDTH - SHORT (patch->width) ); + + V_DrawScaledPatch(x, y, flags, patch); +} + // // HU_DrawTabRankings -- moved to k_kart.c // diff --git a/src/hu_stuff.h b/src/hu_stuff.h index be6798a82..c3da1d2a2 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -115,6 +115,7 @@ char HU_dequeueChatChar(void); void HU_Erase(void); void HU_clearChatChars(void); void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); // Lat': Ping drawer for scoreboard. +void HU_drawMiniPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); //void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); //void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol); diff --git a/src/k_kart.c b/src/k_kart.c index 4b482772f..0f540943f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9884,6 +9884,35 @@ void K_drawKartFreePlay(UINT32 flashtime) LAPS_Y+3, V_HUDTRANS|V_SNAPTOBOTTOM|V_SNAPTORIGHT, "FREE PLAY"); } +static void +Draw_party_ping (int ss, INT32 snap) +{ + HU_drawMiniPing(0, 0, playerpingtable[displayplayers[ss]], V_HUDTRANS|snap); +} + +static void +K_drawMiniPing (void) +{ + if (cv_showping.value) + { + switch (r_splitscreen) + { + case 3: + Draw_party_ping(3, V_SNAPTORIGHT|V_SPLITSCREEN); + /*FALLTHRU*/ + case 2: + Draw_party_ping(2, V_SPLITSCREEN); + Draw_party_ping(1, V_SNAPTORIGHT); + Draw_party_ping(0, 0); + break; + case 1: + Draw_party_ping(1, V_SNAPTORIGHT|V_SPLITSCREEN); + Draw_party_ping(0, V_SNAPTORIGHT); + break; + } + } +} + static void K_drawDistributionDebugger(void) { patch_t *items[NUMKARTRESULTS] = { @@ -10212,6 +10241,11 @@ void K_drawKartHUD(void) K_drawKartFreePlay(leveltime); } + if (netgame && r_splitscreen) + { + K_drawMiniPing(); + } + if (cv_kartdebugdistribution.value) K_drawDistributionDebugger(); diff --git a/src/screen.c b/src/screen.c index 96a78ae8e..5b38f82db 100644 --- a/src/screen.c +++ b/src/screen.c @@ -445,7 +445,7 @@ void SCR_DisplayTicRate(void) void SCR_DisplayLocalPing(void) { UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P - if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level + if (! r_splitscreen && ( cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping) )) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = cv_ticrate.value ? 160 : 181; HU_drawPing(307, dispy, ping, V_SNAPTORIGHT | V_SNAPTOBOTTOM | V_HUDTRANS); From b1db9077a41ae22e589b0e9919378178d213c828 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 21 Mar 2020 12:48:51 -0700 Subject: [PATCH 25/36] splitscreen -> r_splitscreen --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 85f93602b..e7bdb5aa6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7513,7 +7513,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall else distxy = dist; distz = -FixedMul(dist, FINESINE((pitch>>ANGLETOFINESHIFT) & FINEMASK)); - if (splitscreen == 1) // 2 player is weird, this helps keep players on screen + if (r_splitscreen == 1) // 2 player is weird, this helps keep players on screen distz = 3*distz/5; x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy); From 29ebf7ee607f723730b73a8a2fb462200faf3e55 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 21 Mar 2020 13:07:22 -0700 Subject: [PATCH 26/36] Attempt to fix Sal's compiler warnings --- src/d_netcmd.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index aec247108..fbd51ebd1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1333,7 +1333,8 @@ static void ForceAllSkins(INT32 forcedskin) static const char * VaguePartyDescription (int playernum, int *party_sizes, int default_color) { - static char description[1 + MAXPLAYERNAME + 1 + sizeof " and x others"]; + static char party_description + [1 + MAXPLAYERNAME + 1 + sizeof " and x others"]; const char *name; int size; name = player_names[playernum]; @@ -1344,7 +1345,7 @@ VaguePartyDescription (int playernum, int *party_sizes, int default_color) */ if (size > 1 && size <= MAXSPLITSCREENPLAYERS) { - sprintf(description, + sprintf(party_description, "\x83%s%c and %d other%s", name, default_color, @@ -1354,13 +1355,13 @@ VaguePartyDescription (int playernum, int *party_sizes, int default_color) } else { - sprintf(description, + sprintf(party_description, "\x83%s%c", name, default_color ); } - return description; + return party_description; } static INT32 snacpending = 0, snac2pending = 0, snac3pending = 0, snac4pending = 0, chmappending = 0; @@ -2060,6 +2061,8 @@ static void Got_AcceptPartyInvite(UINT8 **cp,INT32 playernum) int old_party_size; int views; + (void)cp; + if (playerconsole[playernum] != playernum) { CONS_Alert(CONS_WARNING, M_GetText("Illegal accept splitscreen invite received from %s\n"), player_names[playernum]); @@ -2115,7 +2118,6 @@ static void Got_CancelPartyInvite(UINT8 **cp,INT32 playernum) invitee = READUINT8 (*cp); if ( - invitee >= 0 && invitee < MAXPLAYERS && playeringame[invitee] ){ @@ -2147,6 +2149,8 @@ static void Got_CancelPartyInvite(UINT8 **cp,INT32 playernum) static void Got_LeaveParty(UINT8 **cp,INT32 playernum) { + (void)cp; + if (playerconsole[playernum] != playernum) { CONS_Alert(CONS_WARNING, M_GetText("Illegal accept splitscreen invite received from %s\n"), player_names[playernum]); @@ -2431,7 +2435,9 @@ static void Command_SetViews_f(void) static void Command_Invite_f (void) { - UINT8 invitee; + UINT8 buffer[1]; + + int invitee; if (COM_Argc() != 2) { @@ -2484,13 +2490,17 @@ Command_Invite_f (void) invitee, splitscreen_original_party_size, '\x80') ); - SendNetXCmd(XD_PARTYINVITE, &invitee, 1); + buffer[0] = invitee; + + SendNetXCmd(XD_PARTYINVITE, buffer, sizeof buffer); } static void Command_CancelInvite_f (void) { - UINT8 invitee; + UINT8 buffer[1]; + + int invitee; if (COM_Argc() != 2) { @@ -2523,7 +2533,9 @@ Command_CancelInvite_f (void) invitee, splitscreen_original_party_size, '\x80') ); - SendNetXCmd(XD_CANCELPARTYINVITE, &invitee, 1); + buffer[0] = invitee; + + SendNetXCmd(XD_CANCELPARTYINVITE, buffer, sizeof buffer); } static boolean From 8a28d3cfe5ebefae04b67548b26048e95b6d0ac4 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 21 Mar 2020 13:12:50 -0700 Subject: [PATCH 27/36] Replace some instances of int with fixed width types --- src/d_clisrv.c | 4 ++-- src/d_netcmd.c | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 98476fe50..eadff6726 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -84,7 +84,7 @@ static boolean serverrunning = false; INT32 serverplayer = 0; char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support) -int playerconsole[MAXPLAYERS]; +UINT8 playerconsole[MAXPLAYERS]; // Server specific vars UINT8 playernode[MAXPLAYERS]; @@ -3491,7 +3491,7 @@ static inline void SV_AddNode(INT32 node) static void Got_AddPlayer(UINT8 **p, INT32 playernum) { INT16 node, newplayernum; - int console; + UINT8 console; UINT8 splitscreenplayer = 0; UINT8 i; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index fbd51ebd1..6814bacce 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2006,12 +2006,10 @@ static void Got_PowerLevel(UINT8 **cp,INT32 playernum) static void Got_PartyInvite(UINT8 **cp,INT32 playernum) { - int invitee; + UINT8 invitee; boolean kick = false; - invitee = READUINT8 (*cp); - if ( invitee >= 0 && invitee < MAXPLAYERS && From 52fa738ef8cca52e051651e226f6057ba40c96a7 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 21 Mar 2020 13:18:17 -0700 Subject: [PATCH 28/36] Replace even more ints with INT32 --- src/g_game.h | 6 +++--- src/g_splitscreen.c | 48 ++++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 9d4a3e4d9..08af3a2b5 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -308,9 +308,9 @@ void G_ResetViews(void); void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive); void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive); -void G_AddPartyMember (int party_member, int new_party_member); -void G_RemovePartyMember (int party_member); -void G_ResetSplitscreen (int playernum); +void G_AddPartyMember (INT32 party_member, INT32 new_party_member); +void G_RemovePartyMember (INT32 party_member); +void G_ResetSplitscreen (INT32 playernum); void G_AddPlayer(INT32 playernum); diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c index 7aec3f159..ffc548147 100644 --- a/src/g_splitscreen.c +++ b/src/g_splitscreen.c @@ -14,21 +14,21 @@ #include "p_local.h" #include "r_local.h" -int splitscreen_original_party_size[MAXPLAYERS]; -int splitscreen_original_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; +INT32 splitscreen_original_party_size[MAXPLAYERS]; +INT32 splitscreen_original_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; -int splitscreen_invitations[MAXPLAYERS]; -int splitscreen_party_size[MAXPLAYERS]; -int splitscreen_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; +INT32 splitscreen_invitations[MAXPLAYERS]; +INT32 splitscreen_party_size[MAXPLAYERS]; +INT32 splitscreen_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; boolean splitscreen_partied[MAXPLAYERS]; void -G_ResetSplitscreen (int playernum) +G_ResetSplitscreen (INT32 playernum) { INT32 old_displayplayers[MAXSPLITSCREENPLAYERS]; - int i; + INT32 i; splitscreen_party_size[playernum] = splitscreen_original_party_size[playernum]; @@ -63,18 +63,18 @@ G_ResetSplitscreen (int playernum) } void -G_RemovePartyMember (int playernum) +G_RemovePartyMember (INT32 playernum) { - int old_party[MAXSPLITSCREENPLAYERS]; - int new_party[MAXSPLITSCREENPLAYERS]; + INT32 old_party[MAXSPLITSCREENPLAYERS]; + INT32 new_party[MAXSPLITSCREENPLAYERS]; - int old_party_size; - int before; - int after; - int views; + INT32 old_party_size; + INT32 before; + INT32 after; + INT32 views; - int i; - int n; + INT32 i; + INT32 n; old_party_size = splitscreen_party_size[playernum]; @@ -135,18 +135,18 @@ G_RemovePartyMember (int playernum) } void -G_AddPartyMember (int invitation, int playernum) +G_AddPartyMember (INT32 invitation, INT32 playernum) { - int * party; - int *add_party; + INT32 * party; + INT32 *add_party; - int old_party_size; - int new_party_size; + INT32 old_party_size; + INT32 new_party_size; - int views; + INT32 views; - int i; - int n; + INT32 i; + INT32 n; views = splitscreen_original_party_size[playernum]; From 58df481cd3795bdb2c7e43943ce956541f010d69 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sat, 21 Mar 2020 19:08:59 -0400 Subject: [PATCH 29/36] Replace "Block Enemies" with "Block Players" We don't need the ability to make invisible walls for enemies as often as we've needed invisible walls for players that don't block their thrown items. --- src/dehacked.c | 4 ++-- src/doomdata.h | 6 +++--- src/p_ceilng.c | 2 +- src/p_floor.c | 2 +- src/p_map.c | 10 +++++----- src/p_mobj.c | 2 +- src/p_spec.c | 32 ++++++++++++++++---------------- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 8a8a159db..7f5b7037f 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8175,8 +8175,8 @@ static const char *const PLAYERFLAG_LIST[] = { #ifdef HAVE_BLUA // Linedef flags static const char *const ML_LIST[16] = { - "IMPASSIBLE", - "BLOCKMONSTERS", + "IMPASSABLE", + "BLOCKPLAYERS", "TWOSIDED", "DONTPEGTOP", "DONTPEGBOTTOM", diff --git a/src/doomdata.h b/src/doomdata.h index 6319238b7..5e6324ec9 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -94,10 +94,10 @@ typedef struct // // Solid, is an obstacle. -#define ML_IMPASSIBLE 1 +#define ML_IMPASSABLE 1 -// Blocks monsters only. -#define ML_BLOCKMONSTERS 2 +// SRB2Kart: Blocks players only; items can be thrown through these. +#define ML_BLOCKPLAYERS 2 // Backside will not be present at all if not two sided. #define ML_TWOSIDED 4 diff --git a/src/p_ceilng.c b/src/p_ceilng.c index 757edebae..a2db42b2d 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -484,7 +484,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) } // chained linedef executing ability - if (line->flags & ML_BLOCKMONSTERS) + if (line->flags & ML_BLOCKPLAYERS) { // only set it on ONE of the moving sectors (the smallest numbered) // and front side x offset must be positive diff --git a/src/p_floor.c b/src/p_floor.c index 737a8810b..b6296090b 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2747,7 +2747,7 @@ INT32 EV_DoFloor(line_t *line, floor_e floortype) dofloor->direction = -1; // down // chained linedef executing ability - if (line->flags & ML_BLOCKMONSTERS) + if (line->flags & ML_BLOCKPLAYERS) { // Only set it on one of the moving sectors (the // smallest numbered) and only if the front side diff --git a/src/p_map.c b/src/p_map.c index 9e34e04d9..cf6670806 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2006,10 +2006,10 @@ if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a // missiles can cross uncrossable lines if (!(tmthing->flags & MF_MISSILE)) { - if (ld->flags & ML_IMPASSIBLE) // block objects from moving through this linedef. + if (ld->flags & ML_IMPASSABLE) // block objects from moving through this linedef. return false; - if ((tmthing->flags & (MF_ENEMY|MF_BOSS)) && ld->flags & ML_BLOCKMONSTERS) - return false; // block monsters only + if (tmthing->player && ld->flags & ML_BLOCKPLAYERS) + return false; // SRB2Kart: Only block players, not items } // set openrange, opentop, openbottom @@ -3328,10 +3328,10 @@ static boolean PTR_SlideTraverse(intercept_t *in) if (!(slidemo->flags & MF_MISSILE)) { - if (li->flags & ML_IMPASSIBLE) + if (li->flags & ML_IMPASSABLE) goto isblocking; - if ((slidemo->flags & (MF_ENEMY|MF_BOSS)) && li->flags & ML_BLOCKMONSTERS) + if (slidemo->player && li->flags & ML_BLOCKPLAYERS) goto isblocking; } diff --git a/src/p_mobj.c b/src/p_mobj.c index a532dddc5..a728e5ed6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2179,7 +2179,7 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover) *rover->topheight; if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3 - && !(rover->master->flags & ML_BLOCKMONSTERS) + && !(rover->master->flags & ML_BLOCKPLAYERS) && ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > topheight - FixedMul(16*FRACUNIT, mo->scale))) return true; } diff --git a/src/p_spec.c b/src/p_spec.c index bfbdf6228..a2ed7eb71 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1651,7 +1651,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (rings > dist) return false; } - else if (triggerline->flags & ML_BLOCKMONSTERS) + else if (triggerline->flags & ML_BLOCKPLAYERS) { if (rings < dist) return false; @@ -1729,7 +1729,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (lap < (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) return false; } - else if (triggerline->flags & ML_BLOCKMONSTERS) // Need lower than or equal to + else if (triggerline->flags & ML_BLOCKPLAYERS) // Need lower than or equal to { if (lap > (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) return false; @@ -2298,8 +2298,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) return; if (bot) - P_Teleport(bot, dest->x, dest->y, dest->z, (line->flags & ML_NOCLIMB) ? mo->angle : dest->angle, (line->flags & ML_BLOCKMONSTERS) == 0, (line->flags & ML_EFFECT4) == ML_EFFECT4); - if (line->flags & ML_BLOCKMONSTERS) + P_Teleport(bot, dest->x, dest->y, dest->z, (line->flags & ML_NOCLIMB) ? mo->angle : dest->angle, (line->flags & ML_BLOCKPLAYERS) == 0, (line->flags & ML_EFFECT4) == ML_EFFECT4); + if (line->flags & ML_BLOCKPLAYERS) P_Teleport(mo, dest->x, dest->y, dest->z, (line->flags & ML_NOCLIMB) ? mo->angle : dest->angle, false, (line->flags & ML_EFFECT4) == ML_EFFECT4); else { @@ -2361,7 +2361,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) mapmusname[6] = 0; mapmusflags = tracknum & MUSIC_TRACKMASK; - if (!(line->flags & ML_BLOCKMONSTERS)) + if (!(line->flags & ML_BLOCKPLAYERS)) mapmusflags |= MUSIC_RELOADRESET; if (line->flags & ML_BOUNCY) mapmusflags |= MUSIC_FORCERESET; @@ -2381,7 +2381,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } } - // Except, you can use the ML_BLOCKMONSTERS flag to change this behavior. + // Except, you can use the ML_BLOCKPLAYERS flag to change this behavior. // if (mapmusflags & MUSIC_RELOADRESET) then it will reset the music in G_PlayerReborn. } break; @@ -2451,7 +2451,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // play the sound from nowhere S_StartSound(NULL, sfxnum); } - else if (line->flags & ML_BLOCKMONSTERS) + else if (line->flags & ML_BLOCKPLAYERS) { // play the sound from calling sector's soundorg if (callsec) @@ -2800,7 +2800,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) var1 = sides[line->sidenum[0]].toptexture; //(line->dx>>FRACBITS)-1; - if (line->sidenum[1] != 0xffff && line->flags & ML_BLOCKMONSTERS) // read power from back sidedef + if (line->sidenum[1] != 0xffff && line->flags & ML_BLOCKPLAYERS) // read power from back sidedef var2 = sides[line->sidenum[1]].toptexture; else if (line->flags & ML_NOCLIMB) // 'Infinite' var2 = UINT16_MAX; @@ -3956,7 +3956,7 @@ DoneSection2: if (gametype == GT_COOP && lineindex != -1) // Custom exit! { // Special goodies with the block monsters flag depending on emeralds collected - if ((lines[lineindex].flags & ML_BLOCKMONSTERS) && ALL7EMERALDS(emeralds)) + if ((lines[lineindex].flags & ML_BLOCKPLAYERS) && ALL7EMERALDS(emeralds)) nextmapoverride = (INT16)(lines[lineindex].frontsector->ceilingheight>>FRACBITS); else nextmapoverride = (INT16)(lines[lineindex].frontsector->floorheight>>FRACBITS); @@ -5349,7 +5349,7 @@ static void P_AddRaiseThinker(sector_t *sec, line_t *sourceline) raise->thinker.function.acp1 = (actionf_p1)T_RaiseSector; - if (sourceline->flags & ML_BLOCKMONSTERS) + if (sourceline->flags & ML_BLOCKPLAYERS) raise->vars[0] = 1; else raise->vars[0] = 0; @@ -5408,7 +5408,7 @@ static void P_AddOldAirbob(sector_t *sec, line_t *sourceline, boolean noadjust) airbob->vars[3] = airbob->vars[2]; - if (sourceline->flags & ML_BLOCKMONSTERS) + if (sourceline->flags & ML_BLOCKPLAYERS) airbob->vars[0] = 1; else airbob->vars[0] = 0; @@ -5989,7 +5989,7 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 64: // Appearing/Disappearing FOF option - if (lines[i].flags & ML_BLOCKMONSTERS) { // Find FOFs by control sector tag + if (lines[i].flags & ML_BLOCKPLAYERS) { // Find FOFs by control sector tag for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) @@ -6217,7 +6217,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 150: // Air bobbing platform case 151: // Adjustable air bobbing platform P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); - lines[i].flags |= ML_BLOCKMONSTERS; + lines[i].flags |= ML_BLOCKPLAYERS; P_AddOldAirbob(lines[i].frontsector, lines + i, (lines[i].special != 151)); break; case 152: // Adjustable air bobbing platform in reverse @@ -6272,14 +6272,14 @@ void P_SpawnSpecials(INT32 fromnetsave) case 176: // Air bobbing platform that will crumble and bob on the water when it falls and hits P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_FLOATBOB|FF_CRUMBLE, secthinkers); - lines[i].flags |= ML_BLOCKMONSTERS; + lines[i].flags |= ML_BLOCKPLAYERS; P_AddOldAirbob(lines[i].frontsector, lines + i, true); break; case 177: // Air bobbing platform that will crumble and bob on // the water when it falls and hits, then never return P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_FLOATBOB|FF_CRUMBLE|FF_NORETURN, secthinkers); - lines[i].flags |= ML_BLOCKMONSTERS; + lines[i].flags |= ML_BLOCKPLAYERS; P_AddOldAirbob(lines[i].frontsector, lines + i, true); break; @@ -6293,7 +6293,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 180: // Air bobbing platform that will crumble P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_CRUMBLE, secthinkers); - lines[i].flags |= ML_BLOCKMONSTERS; + lines[i].flags |= ML_BLOCKPLAYERS; P_AddOldAirbob(lines[i].frontsector, lines + i, true); break; From 22702f88bc32135be0bf30928e40e9956205b655 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sat, 21 Mar 2020 19:54:24 -0400 Subject: [PATCH 30/36] "Delete items" sector type --- src/p_mobj.c | 38 ++++++++++++++++++++++++++++++++++++++ src/p_spec.c | 6 +----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index a728e5ed6..9609a8713 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8014,6 +8014,13 @@ void P_MobjThinker(mobj_t *mobj) case MT_ORBINAUT: { boolean grounded = P_IsObjectOnGround(mobj); + + if (P_MobjTouchingSectorSpecial(mobj, 4, 7, true)) + { + P_RemoveMobj(mobj); + return; + } + if (mobj->flags2 & MF2_AMBUSH) { if (grounded && (mobj->flags & MF_NOCLIPTHING)) @@ -8084,6 +8091,12 @@ void P_MobjThinker(mobj_t *mobj) { mobj_t *ghost = P_SpawnGhostMobj(mobj); + if (P_MobjTouchingSectorSpecial(mobj, 4, 7, true)) + { + P_RemoveMobj(mobj); + return; + } + if (mobj->target && !P_MobjWasRemoved(mobj->target) && mobj->target->player) { ghost->color = mobj->target->player->skincolor; @@ -8107,6 +8120,13 @@ void P_MobjThinker(mobj_t *mobj) case MT_JAWZ_DUD: { boolean grounded = P_IsObjectOnGround(mobj); + + if (P_MobjTouchingSectorSpecial(mobj, 4, 7, true)) + { + P_RemoveMobj(mobj); + return; + } + if (mobj->flags2 & MF2_AMBUSH) { if (grounded && (mobj->flags & MF_NOCLIPTHING)) @@ -8167,6 +8187,12 @@ void P_MobjThinker(mobj_t *mobj) case MT_EGGMANITEM: mobj->friction = ORIG_FRICTION/4; + if (P_MobjTouchingSectorSpecial(mobj, 4, 7, true)) + { + P_RemoveMobj(mobj); + return; + } + if (mobj->momx || mobj->momy) { mobj_t *ghost = P_SpawnGhostMobj(mobj); @@ -8196,6 +8222,12 @@ void P_MobjThinker(mobj_t *mobj) mobj_t *ghost = P_SpawnGhostMobj(mobj); ghost->fuse = 3; + if (P_MobjTouchingSectorSpecial(mobj, 4, 7, true)) + { + P_RemoveMobj(mobj); + return; + } + if (mobj->target && !P_MobjWasRemoved(mobj->target) && mobj->target->player) { ghost->color = mobj->target->player->skincolor; @@ -8228,6 +8260,12 @@ void P_MobjThinker(mobj_t *mobj) mobj->threshold--; break; case MT_SSMINE: + if (P_MobjTouchingSectorSpecial(mobj, 4, 7, true)) + { + P_RemoveMobj(mobj); + return; + } + if (mobj->target && mobj->target->player) mobj->color = mobj->target->player->skincolor; else diff --git a/src/p_spec.c b/src/p_spec.c index a2ed7eb71..279bbf755 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4055,11 +4055,7 @@ DoneSection2: } break; - case 7: // SRB2kart 190117 - Oil Slick (deprecated) - if (roversector || P_MobjReadyToTrigger(player->mo, sector)) - { - K_SpinPlayer(player, NULL, 0, NULL, false); - } + case 7: // SRB2Kart: Destroy items break; case 8: // Zoom Tube Start From c9cff6ccc28ca2f26bd5729cf7aec5d69ce5c4f9 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sat, 21 Mar 2020 22:06:01 -0400 Subject: [PATCH 31/36] P_MobjTouchingSectorSpecial checks polyobjects This means polyobjects can have effects like offroad --- src/p_spec.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 279bbf755..73b97632e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3401,6 +3401,97 @@ sector_t *P_MobjTouchingSectorSpecial(mobj_t *mo, INT32 section, INT32 number, b return rover->master->frontsector; } +#ifdef POLYOBJECTS + // Allow sector specials to be applied to polyobjects! + if (mo->subsector->polyList) + { + polyobj_t *po = mo->subsector->polyList; + sector_t *polysec; + boolean touching = false; + boolean inside = false; + + while (po) + { + if (po->flags & POF_NOSPECIALS) + { + po = (polyobj_t *)(po->link.next); + continue; + } + + polysec = po->lines[0]->backsector; + + if (GETSECSPECIAL(polysec->special, section) != number) + { + po = (polyobj_t *)(po->link.next); + continue; + } + + if ((polysec->flags & SF_TRIGGERSPECIAL_TOUCH)) + touching = P_MobjTouchingPolyobj(po, mo); + else + touching = false; + + inside = P_MobjInsidePolyobj(po, mo); + + if (!(inside || touching)) + { + po = (polyobj_t *)(po->link.next); + continue; + } + + topheight = polysec->ceilingheight; + bottomheight = polysec->floorheight; + + // We're inside it! Yess... + if (!(po->flags & POF_TESTHEIGHT)) // Don't do height checking + { + } + else if (po->flags & POF_SOLID) + { + // Thing must be on top of the floor to be affected... + if ((polysec->flags & SF_FLIPSPECIAL_FLOOR) + && !(polysec->flags & SF_FLIPSPECIAL_CEILING)) + { + if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != topheight) + { + po = (polyobj_t *)(po->link.next); + continue; + } + } + else if ((polysec->flags & SF_FLIPSPECIAL_CEILING) + && !(polysec->flags & SF_FLIPSPECIAL_FLOOR)) + { + if (!(mo->eflags & MFE_VERTICALFLIP) || mo->z + mo->height != bottomheight) + { + po = (polyobj_t *)(po->link.next); + continue; + } + } + else if (polysec->flags & SF_FLIPSPECIAL_BOTH) + { + if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == bottomheight) + || (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == topheight))) + { + po = (polyobj_t *)(po->link.next); + continue; + } + } + } + else + { + // Water and DEATH FOG!!! heh + if (mo->z > topheight || (mo->z + mo->height) < bottomheight) + { + po = (polyobj_t *)(po->link.next); + continue; + } + } + + return polysec; + } + } +#endif + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (GETSECSPECIAL(node->m_sector->special, section) == number) @@ -3461,8 +3552,7 @@ sector_t *P_MobjTouchingSectorSpecial(mobj_t *mo, INT32 section, INT32 number, b else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)) { - if (!(mo->eflags & MFE_VERTICALFLIP) - || mo->z + mo->height != bottomheight) + if (!(mo->eflags & MFE_VERTICALFLIP) || mo->z + mo->height != bottomheight) continue; } else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH) From 65bd0da11de7e340c917bd7bb364b3d28d048d2b Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sat, 21 Mar 2020 23:01:51 -0400 Subject: [PATCH 32/36] Use PWRLVRECORD_START instead of PWRLVRECORD_DEF to encourage more spread --- src/k_pwrlv.c | 2 +- src/k_pwrlv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_pwrlv.c b/src/k_pwrlv.c index 94bdb13a4..b219043c0 100644 --- a/src/k_pwrlv.c +++ b/src/k_pwrlv.c @@ -48,7 +48,7 @@ INT16 K_CalculatePowerLevelInc(INT16 diff) diff = -MAXDIFF; #undef MAXDIFF - x = ((diff-2)< Date: Sun, 22 Mar 2020 14:39:16 -0700 Subject: [PATCH 33/36] EXTERN --- src/d_clisrv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index c8d8693f1..49945de7c 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -610,7 +610,7 @@ SINT8 nametonum(const char *name); extern char motd[254], server_context[8]; extern UINT8 playernode[MAXPLAYERS]; /* consoleplayer of this player (splitscreen) */ -extern int playerconsole[MAXPLAYERS]; +extern UINT8 playerconsole[MAXPLAYERS]; INT32 D_NumPlayers(void); void D_ResetTiccmds(void); From 0ee74567081de4b5fced74db4153a8774746e9b5 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 22 Mar 2020 14:45:21 -0700 Subject: [PATCH 34/36] Fix shit --- src/d_netcmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 545010112..f553538c2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2002,8 +2002,9 @@ static void Got_PartyInvite(UINT8 **cp,INT32 playernum) boolean kick = false; + invitee = READUINT8 (*cp); + if ( - invitee >= 0 && invitee < MAXPLAYERS && playeringame[invitee] && playerconsole[playernum] == playernum/* only consoleplayer may! */ From 90d415ccc02ace3ce627efd6adfc407fbf74ce40 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 22 Mar 2020 18:55:28 -0700 Subject: [PATCH 35/36] Ignore spectators for gentlemen's ping --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 087fa663d..e0db3c31c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5455,7 +5455,7 @@ static void UpdatePingTable(void) { if (playeringame[i] && playernode[i] > 0) { - if (! server_lagless && playernode[i] > 0) + if (! server_lagless && playernode[i] > 0 && !players[i].spectator) { lag = GetLag(playernode[i]); realpingtable[i] += G_TicsToMilliseconds(lag); From 14fdc8a90af61c2849e63dfc8dd91c835a8f82a5 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 25 Mar 2020 05:36:46 -0400 Subject: [PATCH 36/36] Savegame is a stupid term for this --- src/p_saveg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index ee2dc62ea..ccae035ee 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2018,7 +2018,7 @@ static void LoadMobjThinker(actionf_p1 thinker) CONS_Alert(CONS_ERROR, "Found mobj with unknown map thing type %d\n", mobj->spawnpoint->type); else CONS_Alert(CONS_ERROR, "Found mobj with unknown map thing type NULL\n"); - I_Error("Savegame corrupted"); + I_Error("Netsave corrupted"); } mobj->type = i; }