First pass cleaning cutscene system.

This commit is contained in:
2026-09-25 09:57:48 -05:00
parent fed04b66b8
commit 6c180372fe
24 changed files with 203 additions and 237 deletions
+14 -14
View File
@@ -111,8 +111,8 @@ static void test_cutsceneSystemStartWithSetsInteractEntities(void **state) {
&CUTSCENE_TEST_SINGLE_WAIT, &ENTITIES[0], &ENTITIES[1]
);
assert_ptr_equal(CUTSCENE_SYSTEM.entityInteract, &ENTITIES[0]);
assert_ptr_equal(CUTSCENE_SYSTEM.entityInteracted, &ENTITIES[1]);
assert_ptr_equal(CUTSCENE_SYSTEM.refs.entityInteract, &ENTITIES[0]);
assert_ptr_equal(CUTSCENE_SYSTEM.refs.entityInteracted, &ENTITIES[1]);
assert_ptr_equal(
cutsceneSystemGetEntity(CUTSCENE_ENTITY_INTERACT), &ENTITIES[0]
);
@@ -122,8 +122,8 @@ static void test_cutsceneSystemStartWithSetsInteractEntities(void **state) {
TIME.delta = 2.0f;
cutsceneSystemUpdate();// ends the cutscene
assert_null(CUTSCENE_SYSTEM.entityInteract);// reset on end
assert_null(CUTSCENE_SYSTEM.entityInteracted);
assert_null(CUTSCENE_SYSTEM.refs.entityInteract);// reset on end
assert_null(CUTSCENE_SYSTEM.refs.entityInteracted);
}
static void test_cutsceneSystemGetEntitySentinelsRequireBeingSet(
@@ -158,26 +158,26 @@ static void test_cutsceneSystemGetAreaId(void **state) {
cutsceneSystemInit();
// cutsceneSystemInit() zero-inits the field -- only actually starting a
// cutscene sets it to the "nothing created yet" sentinel.
CUTSCENE_SYSTEM.areaLastCreated = CUTSCENE_AREA_LAST_CREATED;
CUTSCENE_SYSTEM.refs.areaLastCreated = CUTSCENE_AREA_LAST_CREATED;
expect_assert_failure(cutsceneSystemGetAreaId(CUTSCENE_AREA_LAST_CREATED));
assert_int_equal(cutsceneSystemGetAreaId(5), 5);// direct IDs pass through
CUTSCENE_SYSTEM.areaLastCreated = 3;
CUTSCENE_SYSTEM.refs.areaLastCreated = 3;
assert_int_equal(cutsceneSystemGetAreaId(CUTSCENE_AREA_LAST_CREATED), 3);
}
static void test_cutsceneSystemGetTextMiniId(void **state) {
cutsceneSystemInit();
CUTSCENE_SYSTEM.textMiniLastCreated = CUTSCENE_TEXT_MINI_LAST_CREATED;
CUTSCENE_SYSTEM.refs.textMiniLastCreated = CUTSCENE_TEXT_MINI_LAST_CREATED;
expect_assert_failure(
cutsceneSystemGetTextMiniId(CUTSCENE_TEXT_MINI_LAST_CREATED)
);
assert_int_equal(cutsceneSystemGetTextMiniId(4), 4);
CUTSCENE_SYSTEM.textMiniLastCreated = 1;
CUTSCENE_SYSTEM.refs.textMiniLastCreated = 1;
assert_int_equal(
cutsceneSystemGetTextMiniId(CUTSCENE_TEXT_MINI_LAST_CREATED), 1
);
@@ -195,15 +195,15 @@ static void test_cutsceneSystemDisposeResetsState(void **state) {
assert_null(CUTSCENE_SYSTEM.scene);
assert_int_equal(CUTSCENE_SYSTEM.currentItem, 0xFF);
assert_int_equal(CUTSCENE_SYSTEM.pause, CUTSCENE_PAUSE_NONE);
assert_null(CUTSCENE_SYSTEM.entityInteract);
assert_null(CUTSCENE_SYSTEM.entityInteracted);
assert_null(CUTSCENE_SYSTEM.refs.entityInteract);
assert_null(CUTSCENE_SYSTEM.refs.entityInteracted);
}
// --- loadedFile survival across cutsceneSystemPrepare -------------------
//
// cutsceneCutsceneResolve (and cutsceneSystemLoad) stamp
// CUTSCENE_SYSTEM.loadedFile with what they just parsed loadedScene from
// - cutsceneGoTo needs that to survive so it can reload the same source
// - cutsceneSystemGoTo needs that to survive so it can reload the same source
// later. cutsceneCutsceneResolve's caller stamps it BEFORE calling
// cutsceneSystemStartCutscene(&CUTSCENE_SYSTEM.loadedScene), so
// cutsceneSystemPrepare must not blindly clear loadedFile on every
@@ -212,7 +212,7 @@ static void test_cutsceneSystemDisposeResetsState(void **state) {
// regression-tests the exact bug hit via initial.jsonc's CUTSCENE item
// into main_menu.jsonc: cutsceneCutsceneResolve stamped loadedFile, then
// the immediately following cutsceneSystemStartCutscene call wiped it
// straight back out, so a later cutsceneGoTo on the still-running
// straight back out, so a later cutsceneSystemGoTo on the still-running
// cutscene had nothing to reload from.
static void test_cutsceneSystemPrepareKeepsLoadedFileWhenReenteringLoadedScene(
void **state
@@ -551,8 +551,8 @@ static void test_cutsceneInsertDoesNotResetPauseOrInteractEntities(
// been popped off the front, only the snippet's one item is left.
assert_ptr_equal(CUTSCENE_SYSTEM.scene, &CUTSCENE_TEST_INSERT_PERSIST_OUTER);
assert_int_equal(CUTSCENE_SYSTEM.scene->itemCount, 1);
assert_ptr_equal(CUTSCENE_SYSTEM.entityInteract, &ENTITIES[3]);
assert_ptr_equal(CUTSCENE_SYSTEM.entityInteracted, &ENTITIES[4]);
assert_ptr_equal(CUTSCENE_SYSTEM.refs.entityInteract, &ENTITIES[3]);
assert_ptr_equal(CUTSCENE_SYSTEM.refs.entityInteracted, &ENTITIES[4]);
// The snippet declares ALL, but INSERT doesn't apply it -- the outer
// cutscene's NPC pause, already in effect, stands.
assert_int_equal(CUTSCENE_SYSTEM.pause, CUTSCENE_PAUSE_NPC);