Skip to content

Commit

Permalink
gameflow: fix regression in parsing console commands
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Jul 2, 2024
1 parent 0a7984f commit f44cbcf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
20 changes: 16 additions & 4 deletions src/game/console_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,19 @@ static COMMAND_RESULT Console_Cmd_Kill(const char *args)

static COMMAND_RESULT Console_Cmd_StartDemo(const char *args)
{
g_GameInfo.override_option = GF_START_DEMO;
g_GameInfo.override_gf_command = (GAMEFLOW_COMMAND) {
.command = GF_START_DEMO,
.param = 0,
};
return CR_SUCCESS;
}

static COMMAND_RESULT Console_Cmd_ExitToTitle(const char *args)
{
g_GameInfo.override_option = GF_EXIT_TO_TITLE;
g_GameInfo.override_gf_command = (GAMEFLOW_COMMAND) {
.command = GF_EXIT_TO_TITLE,
.param = 0,
};
return CR_SUCCESS;
}

Expand All @@ -714,7 +720,10 @@ static COMMAND_RESULT Console_Cmd_LoadGame(const char *args)
return CR_FAILURE;
}

g_GameInfo.override_option = GF_START_SAVED_GAME | slot_idx;
g_GameInfo.override_gf_command = (GAMEFLOW_COMMAND) {
.command = GF_START_SAVED_GAME,
.param = slot_idx,
};
Console_Log(GS(OSD_LOAD_GAME), slot_num);
return CR_SUCCESS;
}
Expand Down Expand Up @@ -782,7 +791,10 @@ static COMMAND_RESULT Console_Cmd_Level(const char *args)
}

if (level_to_load != -1) {
g_GameInfo.override_option = GF_SELECT_GAME | level_to_load;
g_GameInfo.override_gf_command = (GAMEFLOW_COMMAND) {
.command = GF_SELECT_GAME,
.param = level_to_load,
};
Console_Log(
GS(OSD_PLAY_LEVEL), g_GameFlow.levels[level_to_load].level_title);
return CR_SUCCESS;
Expand Down
10 changes: 5 additions & 5 deletions src/game/phase/phase.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ static void Phase_SetUnconditionally(const PHASE phase, void *arg);

static GAMEFLOW_COMMAND Phase_Control(int32_t nframes)
{
if (g_GameInfo.override_option != GF_PHASE_CONTINUE) {
const GAMEFLOW_OPTION override = g_GameInfo.override_option;
g_GameInfo.override_option = GF_PHASE_CONTINUE;
return (GAMEFLOW_COMMAND) {
.command = override,
if (g_GameInfo.override_gf_command.command != GF_PHASE_CONTINUE) {
const GAMEFLOW_COMMAND override = g_GameInfo.override_gf_command;
g_GameInfo.override_gf_command = (GAMEFLOW_COMMAND) {
.command = GF_PHASE_CONTINUE,
.param = 0,
};
return override;
}

if (m_Phaser && m_Phaser->control) {
Expand Down
2 changes: 1 addition & 1 deletion src/global/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ typedef struct GAME_INFO {
int32_t select_level_num;
bool death_counter_supported;
GAMEFLOW_LEVEL_TYPE current_level_type;
GAMEFLOW_OPTION override_option;
GAMEFLOW_COMMAND override_gf_command;
bool remove_guns;
bool remove_scions;
bool remove_ammo;
Expand Down
4 changes: 3 additions & 1 deletion src/global/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ MATRIX g_W2VMatrix = { 0 };
LARA_INFO g_Lara = { 0 };
ITEM_INFO *g_LaraItem = NULL;
CAMERA_INFO g_Camera = { 0 };
GAME_INFO g_GameInfo = { .override_option = GF_PHASE_CONTINUE, 0 };
GAME_INFO g_GameInfo = {
.override_gf_command = { .command = GF_PHASE_CONTINUE, .param = 0 }, 0
};
int32_t g_SavedGamesCount = 0;
int32_t g_SaveCounter = 0;
int16_t g_CurrentLevel = -1;
Expand Down

0 comments on commit f44cbcf

Please sign in to comment.