Skip to content

Commit

Permalink
tr1/game-flow: fix crash when starting demo and there are no demos
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Jan 23, 2025
1 parent 59d31d8 commit 2429301
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- fixed health bar continuing to show when the inventory ring rotates (#1991, regression from 4.0)
- fixed header and arrows disappearing when the inventory ring rotates (#2352, regression from 4.4)
- fixed Story So Far feature not playing opening FMVs from the current level (#2360, regression from 4.2)
- fixed `/demo` command crashing the game if no demos are present (regression from 4.1)
- improved pause screen compatibility with PS1 (#2248)

## [4.7.1](https://github.com/LostArtefacts/TRX/compare/tr1-4.7...tr1-4.7.1) - 2024-12-21
Expand Down
10 changes: 10 additions & 0 deletions src/tr1/game/game_flow/sequencer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "game/game_flow/sequencer.h"

#include "game/demo.h"
#include "game/fmv.h"
#include "game/game.h"
#include "game/game_flow/vars.h"
Expand Down Expand Up @@ -418,3 +419,12 @@ GAME_FLOW_COMMAND GF_PlayCutscene(const int32_t level_num)
Phase_Cutscene_Destroy(phase);
return gf_cmd;
}

GAME_FLOW_COMMAND GF_DoDemoSequence(int32_t demo_num)
{
const int32_t level_num = Demo_ChooseLevel(demo_num);
if (level_num < 0) {
return (GAME_FLOW_COMMAND) { .action = GF_EXIT_TO_TITLE };
}
return GF_InterpretSequence(level_num, GFL_DEMO);
}
1 change: 1 addition & 0 deletions src/tr1/game/game_flow/sequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

GAME_FLOW_COMMAND
GF_InterpretSequence(int32_t level_num, GAME_FLOW_LEVEL_TYPE level_type);
GAME_FLOW_COMMAND GF_DoDemoSequence(int32_t demo_num);
GAME_FLOW_COMMAND
GF_StorySoFar(const GAME_FLOW_SEQUENCE *sequence, int32_t savegame_level);
GAME_FLOW_COMMAND GF_PlayAvailableStory(int32_t slot_num);
Expand Down
4 changes: 1 addition & 3 deletions src/tr1/game/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "game/clock.h"
#include "game/console/common.h"
#include "game/demo.h"
#include "game/fmv.h"
#include "game/game.h"
#include "game/game_flow.h"
Expand Down Expand Up @@ -244,8 +243,7 @@ void Shell_Main(void)
break;

case GF_START_DEMO: {
const int32_t level_num = Demo_ChooseLevel(command.param);
command = GF_InterpretSequence(level_num, GFL_DEMO);
command = GF_DoDemoSequence(command.param);
break;
}

Expand Down

0 comments on commit 2429301

Please sign in to comment.