Skip to content

Commit

Permalink
tr1/game-flow: fix story so far exiting early
Browse files Browse the repository at this point in the history
Resolves #2360.
  • Loading branch information
rr- committed Jan 22, 2025
1 parent 34894e8 commit e4baa12
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- fixed `/kill all` command destroying Scion and causing a soft lock in The Great Pyramid (#2329, regression from 4.4)
- 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 2.10)
- 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
20 changes: 8 additions & 12 deletions src/tr1/game/game_flow/sequencer.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,10 @@ GF_InterpretSequence(int32_t level_num, GAME_FLOW_LEVEL_TYPE level_type)
}

GAME_FLOW_COMMAND
GF_StorySoFar(int32_t level_num, int32_t savegame_level)
GF_StorySoFar(const GAME_FLOW_SEQUENCE *const sequence, int32_t savegame_level)
{
LOG_INFO("%d", level_num);

GAME_FLOW_COMMAND command = { .action = GF_EXIT_TO_TITLE };

const GAME_FLOW_SEQUENCE *const sequence =
&g_GameFlow.levels[level_num].sequence;
for (int32_t i = 0; i < sequence->length; i++) {
const GAME_FLOW_SEQUENCE_EVENT *const event = &sequence->events[i];
LOG_INFO("event %d %d", event->type, event->data);
Expand All @@ -320,15 +316,16 @@ GF_StorySoFar(int32_t level_num, int32_t savegame_level)
break;

case GFS_START_GAME:
if (level_num == savegame_level) {
if ((int32_t)(intptr_t)event->data == savegame_level) {
return (GAME_FLOW_COMMAND) { .action = GF_EXIT_TO_TITLE };
}
break;

case GFS_START_CINE:
command =
GF_LoadLevel((int32_t)(intptr_t)event->data, GFL_CUTSCENE);
if (command.action != GF_NOOP) {
if (command.action != GF_NOOP
&& command.action != GF_LEVEL_COMPLETE) {
return command;
}
break;
Expand Down Expand Up @@ -404,11 +401,10 @@ GAME_FLOW_COMMAND GF_PlayAvailableStory(int32_t slot_num)

const int32_t savegame_level = Savegame_GetLevelNumber(slot_num);
while (1) {
command = GF_StorySoFar(command.param, savegame_level);

if ((g_GameFlow.levels[command.param].level_type == GFL_NORMAL
|| g_GameFlow.levels[command.param].level_type == GFL_BONUS)
&& command.param >= savegame_level) {
command = GF_StorySoFar(
&g_GameFlow.levels[command.param].sequence, savegame_level);
if (command.action == GF_EXIT_TO_TITLE
|| command.action == GF_EXIT_GAME) {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tr1/game/game_flow/sequencer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
GAME_FLOW_COMMAND
GF_InterpretSequence(int32_t level_num, GAME_FLOW_LEVEL_TYPE level_type);
GAME_FLOW_COMMAND
GF_StorySoFar(int32_t level_num, int32_t savegame_level);
GF_StorySoFar(const GAME_FLOW_SEQUENCE *sequence, int32_t savegame_level);
GAME_FLOW_COMMAND GF_PlayAvailableStory(int32_t slot_num);

GAME_FLOW_COMMAND GF_LoadLevel(
Expand Down

0 comments on commit e4baa12

Please sign in to comment.