From 1967ee2dd59a917221e275c7dd7a4f53fadf047b Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 2 Mar 2019 22:39:42 +0100 Subject: [PATCH] Fix splitscreen, offline and death --- src/d_netcmd.c | 19 +++++++++++++++++++ src/m_menu.c | 6 +++--- src/p_user.c | 10 +++++----- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f73a53ce..3a1c3fa2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1317,6 +1317,10 @@ static void SendNameAndColor(void) if (players[consoleplayer].mo) players[consoleplayer].mo->color = players[consoleplayer].skincolor; + // Update follower for local games: + if (cv_follower.value >= 0 && cv_follower.value != players[consoleplayer].followerskin) + SetFollower(consoleplayer, cv_follower.value); + if (metalrecording) { // Metal Sonic is Sonic, obviously. SetPlayerSkinByNum(consoleplayer, 0); @@ -1453,6 +1457,10 @@ static void SendNameAndColor2(void) if (players[secondplaya].mo) players[secondplaya].mo->color = players[secondplaya].skincolor; + // Update follower for local games: + if (cv_follower2.value >= 0 && cv_follower2.value != players[secondplaya].followerskin) + SetFollower(secondplaya, cv_follower2.value); + if ((foundskin = R_SkinAvailable(cv_skin2.string)) != -1) { //boolean notsame; @@ -1573,6 +1581,10 @@ static void SendNameAndColor3(void) if (players[thirdplaya].mo) players[thirdplaya].mo->color = players[thirdplaya].skincolor; + // Update follower for local games: + if (cv_follower3.value >= 0 && cv_follower3.value != players[thirdplaya].followerskin) + SetFollower(thirdplaya, cv_follower3.value); + if ((foundskin = R_SkinAvailable(cv_skin3.string)) != -1) { //boolean notsame; @@ -1701,6 +1713,10 @@ static void SendNameAndColor4(void) if (players[fourthplaya].mo) players[fourthplaya].mo->color = players[fourthplaya].skincolor; + // Update follower for local games: + if (cv_follower4.value >= 0 && cv_follower4.value != players[fourthplaya].followerskin) + SetFollower(fourthplaya, cv_follower4.value); + if ((foundskin = R_SkinAvailable(cv_skin4.string)) != -1) { //boolean notsame; @@ -2129,6 +2145,9 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r } chmappending++; + + // send infos. This seems very dumb but we use this for offline games and followers as some kind of band aid + if (netgame) WRITEUINT32(buf_p, M_RandomizedSeed()); // random seed SendNetXCmd(XD_MAP, buf, buf_p - buf); diff --git a/src/m_menu.c b/src/m_menu.c index 2c69cc70..0db7d12a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8576,7 +8576,7 @@ static void M_SetupMultiPlayer2(INT32 choice) setupm_cvskin = &cv_skin2; setupm_cvcolor = &cv_playercolor2; setupm_cvname = &cv_playername2; - setupm_cvfollower = &cv_follower; + setupm_cvfollower = &cv_follower2; setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value @@ -8616,7 +8616,7 @@ static void M_SetupMultiPlayer3(INT32 choice) setupm_cvskin = &cv_skin3; setupm_cvcolor = &cv_playercolor3; setupm_cvname = &cv_playername3; - setupm_cvfollower = &cv_follower; + setupm_cvfollower = &cv_follower3; setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value @@ -8656,7 +8656,7 @@ static void M_SetupMultiPlayer4(INT32 choice) setupm_cvskin = &cv_skin4; setupm_cvcolor = &cv_playercolor4; setupm_cvname = &cv_playername4; - setupm_cvfollower = &cv_follower; + setupm_cvfollower = &cv_follower4; setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value diff --git a/src/p_user.c b/src/p_user.c index 7ee0c2d6..43dc5663 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9044,8 +9044,8 @@ static void P_HandleFollower(player_t *player) player->follower->extravalue1 = 2; P_SetFollowerState(player->follower, fl.hurtstate); } - if (player->mo->health <= 0) // if dead, snap to z pos - player->follower->z = sz; + if (player->mo->health <= 0) // if dead, follow the player's z momentum exactly so they both look like they die at the same speed. + player->follower->momz = player->mo->momz; } else if (player->speed > 10*player->mo->scale) { @@ -9151,6 +9151,9 @@ void P_PlayerThink(player_t *player) player->awayviewtics = 0; // reset to zero } + // Run followes here. We need them to run even when we're dead to follow through what we're doing. + P_HandleFollower(player); + /* if (player->pflags & PF_GLIDING) { @@ -9622,9 +9625,6 @@ void P_PlayerThink(player_t *player) K_KartPlayerThink(player, cmd); // SRB2kart - // we're done doing all of this, now take care of followers... - P_HandleFollower(player); - /* // Colormap verification {