Skip to content

Commit

Permalink
tr2/demo: test for missing demo data
Browse files Browse the repository at this point in the history
This uses the same logic as in TR1 to test if demo data is defined in a
level before running it.
  • Loading branch information
lahm86 committed Feb 7, 2025
1 parent 930cea3 commit f168f10
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/tr2/game/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool Demo_GetInput(void)
.step_left = demo_input.step_left,
.step_right = demo_input.step_right,
.roll = demo_input.roll,
.use_flare = demo_input.use_flare,
.use_flare = demo_input.use_flare,
.menu_confirm = demo_input.menu_confirm,
.menu_back = demo_input.menu_back,
.save = demo_input.save,
Expand All @@ -125,7 +125,13 @@ bool Demo_Start(const int32_t level_num)
ASSERT(p->level != nullptr);
ASSERT(GF_GetCurrentLevel() == p->level);

p->demo_ptr = Demo_GetData();
const uint32_t *const data = Demo_GetData();
if (data == nullptr) {
LOG_ERROR("Level '%s' has no demo data", p->level->path);
return false;
}

p->demo_ptr = data;

ITEM *const lara_item = Lara_GetItem();
lara_item->pos.x = *p->demo_ptr++;
Expand Down

0 comments on commit f168f10

Please sign in to comment.