mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
tr2/game-flow: fix carrying final level stats
Resolves #2480 where the final level statistics were not being added to the overall cumulative stats. TR1 was not affected by this problem because it records the current statistics in the resume/start information for the current level, unlike TR2, which continues to store these statistics in a separate structure.
This commit is contained in:
parent
68d4e07b6e
commit
843f96305d
5 changed files with 28 additions and 12 deletions
|
@ -350,12 +350,12 @@
|
|||
{"type": "level_stats"},
|
||||
{"type": "play_fmv", "fmv_id": 10},
|
||||
{"type": "play_music", "music_track": 19},
|
||||
{"type": "level_complete"},
|
||||
{"type": "display_picture", "path": "data/images/end.webp", "display_time": 7.5, "fade_in_time": 1.0, "fade_out_time": 1.0},
|
||||
{"type": "display_picture", "path": "data/images/credits_1.webp", "display_time": 7.5, "fade_in_time": 1.0, "fade_out_time": 1.0},
|
||||
{"type": "display_picture", "path": "data/images/credits_2.webp", "display_time": 7.5, "fade_in_time": 1.0, "fade_out_time": 1.0},
|
||||
{"type": "display_picture", "path": "data/images/credits_3.webp", "display_time": 7.5, "fade_in_time": 1.0, "fade_out_time": 1.0},
|
||||
{"type": "total_stats", "background_path": "data/images/install.webp"},
|
||||
{"type": "level_complete"},
|
||||
],
|
||||
"injections": [
|
||||
"data/injections/pyramid_fd.bin",
|
||||
|
|
|
@ -344,6 +344,7 @@
|
|||
{"type": "remove_medipacks"},
|
||||
{"type": "loop_game"},
|
||||
{"type": "play_music", "music_track": 52},
|
||||
{"type": "level_complete"},
|
||||
{"type": "display_picture", "path": "data/credit01.pcx", "display_time": 15, "fade_in_time": 0.5, "fade_out_time": 0.5},
|
||||
{"type": "display_picture", "path": "data/credit02.pcx", "display_time": 15, "fade_in_time": 0.5, "fade_out_time": 0.5},
|
||||
{"type": "display_picture", "path": "data/credit03.pcx", "display_time": 15, "fade_in_time": 0.5, "fade_out_time": 0.5},
|
||||
|
@ -353,7 +354,6 @@
|
|||
{"type": "display_picture", "path": "data/credit07.pcx", "display_time": 15, "fade_in_time": 0.5, "fade_out_time": 0.5},
|
||||
{"type": "display_picture", "path": "data/credit08.pcx", "display_time": 15, "fade_in_time": 0.5, "fade_out_time": 0.5},
|
||||
{"type": "total_stats", "background_path": "data/end.pcx"},
|
||||
{"type": "level_complete"},
|
||||
],
|
||||
"injections": [
|
||||
"data/injections/house_itemrots.bin",
|
||||
|
|
|
@ -7,12 +7,21 @@
|
|||
static const GF_LEVEL *m_CurrentLevel = nullptr;
|
||||
static GF_COMMAND m_OverrideCommand = { .action = GF_NOOP };
|
||||
|
||||
static bool M_SkipLevel(const GF_LEVEL *level);
|
||||
static void M_FreeSequence(GF_SEQUENCE *sequence);
|
||||
static void M_FreeInjections(INJECTION_DATA *injections);
|
||||
static void M_FreeLevel(GF_LEVEL *level);
|
||||
static void M_FreeLevelTable(GF_LEVEL_TABLE *level_table);
|
||||
static void M_FreeFMVs(GAME_FLOW *gf);
|
||||
|
||||
static bool M_SkipLevel(const GF_LEVEL *const level)
|
||||
{
|
||||
#if TR_VERSION == 1
|
||||
return level->type == GFL_DUMMY || level->type == GFL_CURRENT;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
static void M_FreeSequence(GF_SEQUENCE *const sequence)
|
||||
{
|
||||
Memory_Free(sequence->events);
|
||||
|
@ -171,11 +180,9 @@ const GF_LEVEL *GF_GetLastLevel(void)
|
|||
if (level->type == GFL_GYM) {
|
||||
continue;
|
||||
}
|
||||
#if TR_VERSION == 1
|
||||
if (level->type == GFL_DUMMY || level->type == GFL_CURRENT) {
|
||||
if (M_SkipLevel(level)) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
result = level;
|
||||
}
|
||||
return result;
|
||||
|
@ -200,9 +207,13 @@ const GF_LEVEL *GF_GetLevelAfter(const GF_LEVEL *const level)
|
|||
GF_GetLevelTableType(level->type);
|
||||
const GF_LEVEL_TABLE *const level_table =
|
||||
GF_GetLevelTable(level_table_type);
|
||||
return level->num + 1 < level_table->count
|
||||
? &level_table->levels[level->num + 1]
|
||||
: nullptr;
|
||||
for (int32_t i = level->num + 1; i < level_table->count; i++) {
|
||||
const GF_LEVEL *const next_level = &level_table->levels[i];
|
||||
if (!M_SkipLevel(next_level)) {
|
||||
return next_level;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const GF_LEVEL *GF_GetLevelBefore(const GF_LEVEL *const level)
|
||||
|
@ -211,7 +222,13 @@ const GF_LEVEL *GF_GetLevelBefore(const GF_LEVEL *const level)
|
|||
GF_GetLevelTableType(level->type);
|
||||
const GF_LEVEL_TABLE *const level_table =
|
||||
GF_GetLevelTable(level_table_type);
|
||||
return level->num - 1 >= 0 ? &level_table->levels[level->num - 1] : nullptr;
|
||||
for (int32_t i = level->num - 1; i >= 0; i--) {
|
||||
const GF_LEVEL *const prev_level = &level_table->levels[i];
|
||||
if (!M_SkipLevel(prev_level)) {
|
||||
return prev_level;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GF_SetCurrentLevel(const GF_LEVEL *const level)
|
||||
|
|
|
@ -226,9 +226,8 @@ static DECLARE_GF_EVENT_HANDLER(M_HandleLevelComplete)
|
|||
};
|
||||
}
|
||||
|
||||
// missing level
|
||||
if (next_level == nullptr) {
|
||||
return (GF_COMMAND) { .action = GF_EXIT_TO_TITLE };
|
||||
return (GF_COMMAND) { .action = GF_NOOP };
|
||||
}
|
||||
|
||||
// carry info to the next level
|
||||
|
|
|
@ -167,7 +167,7 @@ static DECLARE_GF_EVENT_HANDLER(M_HandleLevelComplete)
|
|||
g_SaveGame.current_level = next_level->num;
|
||||
}
|
||||
if (next_level == nullptr) {
|
||||
return (GF_COMMAND) { .action = GF_EXIT_TO_TITLE };
|
||||
return (GF_COMMAND) { .action = GF_NOOP };
|
||||
}
|
||||
return (GF_COMMAND) {
|
||||
.action = GF_START_GAME,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue