tr1/game-flow: fix story so far showing up in UB
Some checks are pending
Run code linters / Run code linters (push) Waiting to run
Publish a pre-release / Build TR1 (push) Has been skipped
Publish a pre-release / Build TR2 (push) Has been skipped
Publish a pre-release / Create a prerelease (push) Has been skipped

Resolves #2611.
This commit is contained in:
Marcin Kurczewski 2025-04-18 12:06:23 +02:00
parent 1e53333864
commit 01b2d37fdc
4 changed files with 33 additions and 3 deletions

View file

@ -26,6 +26,7 @@
- fixed sprites missing the fog effect (regression from 4.9)
- fixed the camera going out of bounds in 60fps near specific invalid floor data (known as no-space) (#2764, regression from 4.9)
- fixed wrong PS1-style title bar color for the end of the level stats dialog (regression from 4.9)
- fixed Story So Far showing up even when there's nothing to play (#2611, regression from 2.10)
- improved bubble appearance (#2672)
- improved rendering performance
- improved pause exit dialog - it can now be canceled with escape
@ -83,7 +84,7 @@
## [4.8.2](https://github.com/LostArtefacts/TRX/compare/tr1-4.8.1...tr1-4.8.2) - 2025-02-15
- changed default FPS value to 60 (#2501)
- changed passport to be more responsive to player inputs (#1328)
- fixed story so far not skipping over levels (#2506, regression from 4.8)
- fixed Story So Far not skipping over levels (#2506, regression from 4.8)
- fixed resolving paths (especially to music files) on case-sensitive filesystems (#1934, #2504)
- improved memory usage by shedding ca. 100-110 MB on average
@ -741,7 +742,7 @@
- added a .NET-based installer
- added the option to make Lara revert to pistols on new level start (#557)
- added the PS1 style UI (#517)
- added the "Story so far..." option in the select level menu to view cutscenes and FMVs (#201)
- added the "Story So far..." option in the select level menu to view cutscenes and FMVs (#201)
## [2.9.1](https://github.com/LostArtefacts/TRX/compare/tr1-2.9...tr1-2.9.1) - 2022-06-03
- fixed crash on centaur hatch (#579, regression from 2.9)

View file

@ -6,4 +6,9 @@ void GF_InitSequencer(void);
GF_COMMAND GF_DoLevelSequence(
const GF_LEVEL *start_level, GF_SEQUENCE_CONTEXT seq_ctx);
GF_COMMAND GF_PlayAvailableStory(int32_t slot_num);
// Returns true if any story cutscenes or FMVs occur before gameplay in any
// main level up to the level in the specified save slot.
bool GF_HasAvailableStory(int32_t slot_num);

View file

@ -39,6 +39,30 @@ GF_COMMAND GF_PlayAvailableStory(const int32_t slot_num)
return (GF_COMMAND) { .action = GF_EXIT_TO_TITLE };
}
bool GF_HasAvailableStory(const int32_t slot_num)
{
const int32_t savegame_level = Savegame_GetLevelNumber(slot_num);
const GF_LEVEL_TABLE *const level_table = GF_GetLevelTable(GFLT_MAIN);
const int32_t max_level = MIN(savegame_level, level_table->count);
for (int32_t i = 0; i <= max_level; i++) {
const GF_LEVEL *const level = GF_GetLevel(GFLT_MAIN, i);
if (level->type == GFL_GYM) {
continue;
}
const GF_SEQUENCE *const seq = &level->sequence;
for (int32_t j = 0; j < seq->length; j++) {
const GF_SEQUENCE_EVENT *const ev = &seq->events[j];
if (ev->type == GFS_LOOP_GAME) {
break;
}
if (ev->type == GFS_PLAY_CUTSCENE || ev->type == GFS_PLAY_FMV) {
return true;
}
}
}
return false;
}
GF_COMMAND GF_DoLevelSequence(
const GF_LEVEL *const start_level, const GF_SEQUENCE_CONTEXT seq_ctx)
{

View file

@ -168,7 +168,7 @@ void Savegame_FillAvailableLevels(REQUEST_INFO *const req)
}
}
if (g_InvMode == INV_TITLE_MODE) {
if (g_InvMode == INV_TITLE_MODE && GF_HasAvailableStory(slot_num)) {
Requester_AddItem(req, false, "%s", GS(PASSPORT_STORY_SO_FAR));
}