Fix death-use action on intermission screen (#1973)

* Clean up action/state variables

* Fix "use" on intermission screen
This commit is contained in:
ceski 2024-11-01 10:43:11 -07:00 committed by GitHub
parent 3d8ec36807
commit c94b994195
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 14 deletions

View File

@ -687,19 +687,21 @@ static void AdjustWeaponSelection(int *newweapon)
static boolean FilterDeathUseAction(void)
{
if (players[consoleplayer].playerstate & PST_DEAD)
if (players[consoleplayer].playerstate == PST_DEAD && gamestate == GS_LEVEL)
{
switch (death_use_action)
{
case death_use_nothing:
case DEATH_USE_ACTION_NOTHING:
return true;
case death_use_reload:
case DEATH_USE_ACTION_LAST_SAVE:
if (!demoplayback && !demorecording && !netgame
&& activate_death_use_reload == 0)
&& death_use_state == DEATH_USE_STATE_INACTIVE)
{
activate_death_use_reload = 2;
death_use_state = DEATH_USE_STATE_PENDING;
}
return true;
default:
break;
}
@ -1104,7 +1106,7 @@ static void G_DoLoadLevel(void)
// Set the initial listener parameters using the player's initial state.
S_InitListener(players[displayplayer].mo);
activate_death_use_reload = 0;
death_use_state = DEATH_USE_STATE_INACTIVE;
// clear cmd building stuff
memset (gamekeydown, 0, sizeof(gamekeydown));
@ -4847,7 +4849,7 @@ void G_BindGameVariables(void)
32, UL, UL, ss_none, wad_no,
"Maximum number of player corpses (< 0 = No limit)");
BIND_NUM_GENERAL(death_use_action, 0, 0, 2,
"Use-button action upon death (0 = Default; 1 = Load save; 2 = Nothing)");
"Use-button action upon death (0 = Default; 1 = Last Save; 2 = Nothing)");
BIND_BOOL_GENERAL(autosave, true,
"Auto save at the beginning of a map, after completing the previous one");
}

View File

@ -257,7 +257,7 @@ void P_MovePlayer (player_t* player)
#define ANG5 (ANG90/18)
death_use_action_t death_use_action;
int activate_death_use_reload;
death_use_state_t death_use_state;
//
// P_DeathThink
@ -318,9 +318,9 @@ void P_DeathThink (player_t* player)
player->playerstate = PST_REBORN;
}
if (activate_death_use_reload == 2)
if (death_use_state == DEATH_USE_STATE_PENDING)
{
activate_death_use_reload = 1;
death_use_state = DEATH_USE_STATE_ACTIVE;
if (!G_AutoSaveEnabled() || !G_LoadAutoSaveDeathUse())
{

View File

@ -35,13 +35,21 @@ void P_Thrust(struct player_s *player, angle_t angle, fixed_t move);
typedef enum
{
death_use_default,
death_use_reload,
death_use_nothing
DEATH_USE_ACTION_DEFAULT,
DEATH_USE_ACTION_LAST_SAVE,
DEATH_USE_ACTION_NOTHING
} death_use_action_t;
extern death_use_action_t death_use_action;
extern int activate_death_use_reload;
typedef enum
{
DEATH_USE_STATE_INACTIVE,
DEATH_USE_STATE_PENDING,
DEATH_USE_STATE_ACTIVE
} death_use_state_t;
extern death_use_state_t death_use_state;
extern boolean onground; // whether player is on ground or in air