Skip to content

Commit

Permalink
make death use action demo compatible (#1910)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfomin authored Sep 16, 2024
1 parent e87ac53 commit 58b7bdd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
28 changes: 26 additions & 2 deletions src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,28 @@ void G_PrepGyroTiccmd(void)
}
}

static boolean FilterDeathUseAction(void)
{
if (players[consoleplayer].playerstate & PST_DEAD)
{
switch (death_use_action)
{
case death_use_nothing:
return true;
case death_use_reload:
if (!demoplayback && !demorecording && !netgame)
{
activate_death_use_reload = true;
}
return true;
default:
break;
}
}

return false;
}

//
// G_BuildTiccmd
// Builds a ticcmd from all of the available inputs
Expand Down Expand Up @@ -703,7 +725,8 @@ void G_BuildTiccmd(ticcmd_t* cmd)

if (M_InputGameActive(input_use)) // [FG] mouse button for "use"
{
cmd->buttons |= BT_USE;
if (!FilterDeathUseAction())
cmd->buttons |= BT_USE;
// clear double clicks if hit use button
dclick = false;
}
Expand Down Expand Up @@ -811,7 +834,8 @@ void G_BuildTiccmd(ticcmd_t* cmd)
if (dclick)
{
dclick = false;
cmd->buttons |= BT_USE;
if (!FilterDeathUseAction())
cmd->buttons |= BT_USE;
}

// special buttons
Expand Down
37 changes: 14 additions & 23 deletions src/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@
#include "hu_stuff.h"
#include "info.h"
#include "m_cheat.h"
#include "m_input.h"
#include "p_map.h"
#include "p_mobj.h"
#include "p_pspr.h"
#include "p_spec.h"
#include "p_user.h"
#include "r_defs.h"
#include "r_main.h"
#include "r_state.h"
#include "st_stuff.h"

static fixed_t PlayerSlope(player_t *player)
Expand Down Expand Up @@ -259,6 +257,7 @@ void P_MovePlayer (player_t* player)
#define ANG5 (ANG90/18)

death_use_action_t death_use_action;
boolean activate_death_use_reload;

//
// P_DeathThink
Expand Down Expand Up @@ -316,29 +315,21 @@ void P_DeathThink (player_t* player)

if (player->cmd.buttons & BT_USE)
{
if (demorecording || demoplayback || netgame)
player->playerstate = PST_REBORN;
else switch(death_use_action)
player->playerstate = PST_REBORN;
}

if (activate_death_use_reload)
{
activate_death_use_reload = false;

if (savegameslot >= 0)
{
case death_use_default:
player->playerstate = PST_REBORN;
break;
case death_use_reload:
if (savegameslot >= 0)
{
char *file = G_SaveGameName(savegameslot);
G_LoadGame(file, savegameslot, false);
free(file);
// [Woof!] prevent on-death-action reloads from activating specials
M_InputGameDeactivate(input_use);
}
else
player->playerstate = PST_REBORN;
break;
case death_use_nothing:
default:
break;
char *file = G_SaveGameName(savegameslot);
G_LoadGame(file, savegameslot, false);
free(file);
}
else
player->playerstate = PST_REBORN;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/p_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typedef enum
} death_use_action_t;

extern death_use_action_t death_use_action;
extern boolean activate_death_use_reload;

extern boolean onground; // whether player is on ground or in air

Expand Down

0 comments on commit 58b7bdd

Please sign in to comment.