Sunset the dedicated cutscene asset loader and the item pool
Cutscenes now load through the generic ASSET_LOADER_TYPE_JSON loader and parse straight into fixed static buffers via new cutsceneParseDoc/ cutsceneParseItem/cutsceneCountItems helpers (cutscene.c), removing the bespoke ASSET_LOADER_TYPE_CUTSCENE pipeline entirely. Only one cutscene (plus one INSERT target) is ever resident, so each resolve locks, steals the parsed doc, unlocks, and force-reaps immediately - fixing a stale-cache-reuse bug where revisiting a cutscene name after a different one could return data from the shared buffer's previous occupant. ENTITY_WALK_TO and MAP_AREA_WAIT now store their waypoints/area ids in fixed-size arrays inline on their own item struct instead of a shared bump-allocated pool, so pool/poolOffset are gone from every item type's Load callback. cutscene_t.dataSize (and the CUTSCENE(...) macro's SIZE parameter) is removed along with it - it sized entries out of that same now-deleted pool and had no other reader. NPC #4's battletest cutscene and the main menu's cutscene now resolve their target by name on interact instead of eagerly at init, so a resolved-once pointer is never held past the point its backing buffer can be reused for something else. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
@@ -24,8 +24,7 @@ static const cutsceneitem_t CUTSCENE_TEST_SCRATCH_ITEMS[] = {
|
||||
static const cutscene_t CUTSCENE_TEST_SCRATCH = {
|
||||
.items = CUTSCENE_TEST_SCRATCH_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_SCRATCH_ITEMS) / sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE,
|
||||
.dataSize = 0
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
static battlefighter_t *addFighter(
|
||||
|
||||
@@ -20,11 +20,11 @@ static void recordCallback(void *userData) {
|
||||
// the "nested cutscene is a one-way jump" behavior: cutsceneCutsceneStart
|
||||
// replaces CUTSCENE_SYSTEM.scene outright, and the callback item's effect
|
||||
// fires in Start, not Update, so it fires the same frame the jump happens.
|
||||
CUTSCENE(TEST_INNER, 0, NONE,
|
||||
CUTSCENE(TEST_INNER, NONE,
|
||||
CUTSCENE_CALLBACK(recordCallback)
|
||||
);
|
||||
|
||||
CUTSCENE(TEST_OUTER, 0, DEFAULT,
|
||||
CUTSCENE(TEST_OUTER, DEFAULT,
|
||||
CUTSCENE_WAIT(0.5f),
|
||||
CUTSCENE_CUTSCENE(TEST_INNER)
|
||||
);
|
||||
@@ -75,7 +75,7 @@ static void test_cutsceneSystemUpdateIsNoopWithNoActiveCutscene(void **state) {
|
||||
assert_null(CUTSCENE_SYSTEM.scene);
|
||||
}
|
||||
|
||||
CUTSCENE(TEST_SINGLE_WAIT, 0, NONE,
|
||||
CUTSCENE(TEST_SINGLE_WAIT, NONE,
|
||||
CUTSCENE_WAIT(1.0f)
|
||||
);
|
||||
|
||||
@@ -188,13 +188,13 @@ static void recordOrder2(void *userData) { insertOrderLog[insertOrderLogCount++]
|
||||
static void recordOrderA(void *userData) { insertOrderLog[insertOrderLogCount++] = 3; }
|
||||
static void recordOrderB(void *userData) { insertOrderLog[insertOrderLogCount++] = 4; }
|
||||
|
||||
CUTSCENE(TEST_INSERT_SNIPPET, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_SNIPPET, NONE,
|
||||
CUTSCENE_CALLBACK(recordOrderA),
|
||||
CUTSCENE_WAIT(2.0f),
|
||||
CUTSCENE_CALLBACK(recordOrderB)
|
||||
);
|
||||
|
||||
CUTSCENE(TEST_INSERT_OUTER, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_OUTER, NONE,
|
||||
CUTSCENE_CALLBACK(recordOrder0),
|
||||
CUTSCENE_WAIT(1.0f),
|
||||
CUTSCENE_CALLBACK(recordOrder1),
|
||||
@@ -230,11 +230,11 @@ static void test_cutsceneInsertSplicesItemsInPlaceThenResumes(void **state) {
|
||||
assert_memory_equal(insertOrderLog, expected, sizeof(expected));
|
||||
}
|
||||
|
||||
CUTSCENE(TEST_INSERT_AS_LAST_ITEM_SNIPPET, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_AS_LAST_ITEM_SNIPPET, NONE,
|
||||
CUTSCENE_CALLBACK(recordOrderA)
|
||||
);
|
||||
|
||||
CUTSCENE(TEST_INSERT_AS_LAST_ITEM_OUTER, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_AS_LAST_ITEM_OUTER, NONE,
|
||||
CUTSCENE_CALLBACK(recordOrder0),
|
||||
CUTSCENE_INSERT(TEST_INSERT_AS_LAST_ITEM_SNIPPET)
|
||||
);
|
||||
@@ -263,19 +263,19 @@ static void test_cutsceneInsertAsLastItemEndsCutsceneNaturally(
|
||||
assert_memory_equal(insertOrderLog, expected, sizeof(expected));
|
||||
}
|
||||
|
||||
CUTSCENE(TEST_INSERT_NESTED_INNER, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_NESTED_INNER, NONE,
|
||||
CUTSCENE_CALLBACK(recordOrderA)
|
||||
);
|
||||
|
||||
// INSERT is MID's first item, so entering MID (from OUTER) cascades
|
||||
// straight through into INNER within the same Start chain, one level
|
||||
// deeper than a single insert.
|
||||
CUTSCENE(TEST_INSERT_NESTED_MID, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_NESTED_MID, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_NESTED_INNER),
|
||||
CUTSCENE_CALLBACK(recordOrderB)
|
||||
);
|
||||
|
||||
CUTSCENE(TEST_INSERT_NESTED_OUTER, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_NESTED_OUTER, NONE,
|
||||
CUTSCENE_CALLBACK(recordOrder0),
|
||||
CUTSCENE_INSERT(TEST_INSERT_NESTED_MID),
|
||||
CUTSCENE_CALLBACK(recordOrder2)
|
||||
@@ -306,22 +306,22 @@ static void test_cutsceneInsertNestsThroughMultipleLevels(void **state) {
|
||||
assert_memory_equal(insertOrderLog, expected, sizeof(expected));
|
||||
}
|
||||
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL5, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL5, NONE,
|
||||
CUTSCENE_CALLBACK(recordOrderA)
|
||||
);
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL4, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL4, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_OVERFLOW_LEVEL5)
|
||||
);
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL3, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL3, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_OVERFLOW_LEVEL4)
|
||||
);
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL2, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL2, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_OVERFLOW_LEVEL3)
|
||||
);
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL1, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL1, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_OVERFLOW_LEVEL2)
|
||||
);
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL0, 0, NONE,
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL0, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_OVERFLOW_LEVEL1)
|
||||
);
|
||||
|
||||
@@ -341,11 +341,11 @@ static void test_cutsceneInsertAssertsWhenNestingExceedsStackMax(
|
||||
|
||||
static void noopInsertCallback(void *userData) {}
|
||||
|
||||
CUTSCENE(TEST_INSERT_PERSIST_SNIPPET, 0, ALL,
|
||||
CUTSCENE(TEST_INSERT_PERSIST_SNIPPET, ALL,
|
||||
CUTSCENE_CALLBACK(noopInsertCallback)
|
||||
);
|
||||
|
||||
CUTSCENE(TEST_INSERT_PERSIST_OUTER, 0, NPC,
|
||||
CUTSCENE(TEST_INSERT_PERSIST_OUTER, NPC,
|
||||
CUTSCENE_INSERT(TEST_INSERT_PERSIST_SNIPPET)
|
||||
);
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ static const cutsceneitem_t CUTSCENE_TEST_INTERACT_ITEMS[] = {
|
||||
static const cutscene_t CUTSCENE_TEST_INTERACT = {
|
||||
.items = CUTSCENE_TEST_INTERACT_ITEMS,
|
||||
.itemCount = 1,
|
||||
.pause = CUTSCENE_PAUSE_NONE,
|
||||
.dataSize = 0
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
static entity_t *player;
|
||||
|
||||
Reference in New Issue
Block a user