From 7bcad024f8a15a42bc75ffceec1d9c7bf2023c8d Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Tue, 19 Sep 2023 21:48:01 -0500 Subject: [PATCH] Only Award Bonuses / RA Emblems from Physically Beating a Level --- src/g_game.c | 11 ++++++----- src/lua_baselib.c | 3 ++- src/netcode/d_netcmd.c | 2 +- src/p_enemy.c | 4 ++-- src/p_local.h | 2 +- src/p_mobj.c | 2 +- src/p_spec.c | 8 ++++---- src/p_user.c | 12 ++++++++---- src/y_inter.c | 9 +++++++-- 9 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index fae311694..877a4c72e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3330,7 +3330,7 @@ void G_AddPlayer(INT32 playernum) p->lives = cv_startinglives.value; if ((countplayers && !notexiting) || G_IsSpecialStage(gamemap)) - P_DoPlayerExit(p); + P_DoPlayerExit(p, false); } boolean G_EnoughPlayersFinished(void) @@ -3863,12 +3863,13 @@ static INT16 RandMap(UINT32 tolflags, INT16 pprevmap) // // G_UpdateVisited // -static void G_UpdateVisited(gamedata_t *data, player_t *player, boolean silent) +static void G_UpdateVisited(gamedata_t *data, player_t *player, boolean global) { // Update visitation flags? if (!demoplayback && G_CoopGametype() // Campaign mode - && !stagefailed) // Did not fail the stage + && !stagefailed // Did not fail the stage + && (global || player->pflags & PF_FINISHED)) // Actually beat the stage { UINT8 earnedEmblems; UINT16 totalrings = 0; @@ -3906,12 +3907,12 @@ static void G_UpdateVisited(gamedata_t *data, player_t *player, boolean silent) data->mapvisited[gamemap-1] |= MV_ALLEMERALDS; } - if ((earnedEmblems = M_CompletionEmblems(data)) && !silent) + if ((earnedEmblems = M_CompletionEmblems(data)) && !global) { CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); } - if (silent) + if (global) { M_CheckLevelEmblems(data); } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 8cb6d185d..063c79dc4 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1546,11 +1546,12 @@ static int lib_pDoPlayerFinish(lua_State *L) static int lib_pDoPlayerExit(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + boolean finishedflag = lua_opttrueboolean(L, 2); NOHUD INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); - P_DoPlayerExit(player); + P_DoPlayerExit(player, finishedflag); return 0; } diff --git a/src/netcode/d_netcmd.c b/src/netcode/d_netcmd.c index 5afa95561..12c1b95c6 100644 --- a/src/netcode/d_netcmd.c +++ b/src/netcode/d_netcmd.c @@ -4035,7 +4035,7 @@ static void ExitMove_OnChange(void) if (players[i].mo->target && players[i].mo->target->type == MT_SIGN) P_SetTarget(&players[i].mo->target, NULL); - if (players[i].pflags & PF_FINISHED) + if (players[i].pflags & PF_FINISHED && !(players[i].exiting)) P_GiveFinishFlags(&players[i]); } diff --git a/src/p_enemy.c b/src/p_enemy.c index 93c828fbe..e210fe1e3 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3951,7 +3951,7 @@ static void P_DoBossVictory(mobj_t *mo) { if (!playeringame[i]) continue; - P_DoPlayerExit(&players[i]); + P_DoPlayerExit(&players[i], true); } } else @@ -10820,7 +10820,7 @@ void A_ForceWin(mobj_t *actor) { if (!playeringame[i]) continue; - P_DoPlayerExit(&players[i]); + P_DoPlayerExit(&players[i], true); } } diff --git a/src/p_local.h b/src/p_local.h index 4b330184b..84f33e54a 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -188,7 +188,7 @@ void P_DoPityCheck(player_t *player); void P_PlayerThink(player_t *player); void P_PlayerAfterThink(player_t *player); void P_DoPlayerFinish(player_t *player); -void P_DoPlayerExit(player_t *player); +void P_DoPlayerExit(player_t *player, boolean finishedflag); void P_NightserizePlayer(player_t *player, INT32 ptime); void P_InstaThrust(mobj_t *mo, angle_t angle, fixed_t move); diff --git a/src/p_mobj.c b/src/p_mobj.c index a81845918..03c992092 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11715,7 +11715,7 @@ void P_AfterPlayerSpawn(INT32 playernum) if (CheckForReverseGravity) P_CheckGravity(mobj, false); - if (p->pflags & PF_FINISHED) + if (p->pflags & PF_FINISHED && !(p->exiting)) P_GiveFinishFlags(p); } diff --git a/src/p_spec.c b/src/p_spec.c index 28ecc60f4..49b930947 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3662,7 +3662,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { if (!playeringame[i]) continue; - P_DoPlayerExit(&players[i]); + P_DoPlayerExit(&players[i], true); } } } @@ -3716,7 +3716,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { if (!playeringame[i]) continue; - P_DoPlayerExit(&players[i]); + P_DoPlayerExit(&players[i], true); } } } @@ -4477,7 +4477,7 @@ static void P_ProcessEggCapsule(player_t *player, sector_t *sector) { if (!playeringame[i]) continue; - P_DoPlayerExit(&players[i]); + P_DoPlayerExit(&players[i], true); } } @@ -4787,7 +4787,7 @@ static void P_ProcessFinishLine(player_t *player) HU_DoCEcho("FINISHED!"); } - P_DoPlayerExit(player); + P_DoPlayerExit(player, true); } } diff --git a/src/p_user.c b/src/p_user.c index 24e3f8111..e41f335cc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -892,7 +892,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) players[i].marescore = 0; players[i].spheres = players[i].rings = 0; - P_DoPlayerExit(&players[i]); + P_DoPlayerExit(&players[i], true); } } else if (oldmare != player->mare) @@ -2188,7 +2188,7 @@ void P_DoPlayerFinish(player_t *player) // P_DoPlayerExit // // Player exits the map via sector trigger -void P_DoPlayerExit(player_t *player) +void P_DoPlayerExit(player_t *player, boolean finishedflag) { if (player->exiting) return; @@ -2209,7 +2209,11 @@ void P_DoPlayerExit(player_t *player) player->exiting = (14*TICRATE)/5 + 1; } else + { player->exiting = (14*TICRATE)/5 + 2; // Accidental death safeguard??? + if (finishedflag) + player->pflags |= PF_FINISHED; // Give PF_FINISHED as proof of a true finish + } //player->pflags &= ~PF_GLIDING; if (player->climbing) @@ -11782,7 +11786,7 @@ void P_PlayerThink(player_t *player) if (((gametyperules & GTR_FRIENDLY) && cv_exitmove.value) && !G_EnoughPlayersFinished()) player->exiting = 0; else - P_DoPlayerExit(player); + P_DoPlayerExit(player, false); } // check water content, set stuff in mobj @@ -11831,7 +11835,7 @@ void P_PlayerThink(player_t *player) } // Synchronizes the "real" amount of time spent in the level. - if (!player->exiting && !stoppedclock) + if (!player->exiting && !(player->pflags & PF_FINISHED) && !stoppedclock) { if (gametyperules & GTR_RACE) { diff --git a/src/y_inter.c b/src/y_inter.c index 69dc931ba..453a9c461 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -2043,7 +2043,7 @@ static void Y_AwardCoopBonuses(void) y_bonus_t localbonuses[4]; // set score/total first - data.coop.total = players[consoleplayer].recordscore; + data.coop.total = (players[consoleplayer].pflags & PF_FINISHED) ? players[consoleplayer].recordscore : 0; data.coop.score = players[consoleplayer].score; data.coop.gotperfbonus = -1; memset(data.coop.bonuses, 0, sizeof(data.coop.bonuses)); @@ -2060,7 +2060,12 @@ static void Y_AwardCoopBonuses(void) for (j = 0; j < 4; ++j) // Set bonuses { - (bonuses_list[bonusnum][j])(&players[i], &localbonuses[j]); + //Set the bonus, but only if we actually finished + if (players[i].pflags & PF_FINISHED) + (bonuses_list[bonusnum][j])(&players[i], &localbonuses[j]); + else + Y_SetNullBonus(&players[i], &localbonuses[j]); + players[i].score += localbonuses[j].points; if (players[i].score > MAXSCORE) players[i].score = MAXSCORE;