Remove the C-authoring shorthand for declaring cutscenes
CUTSCENE(...)/CUTSCENE_REFERENCE/CUTSCENE_CUTSCENE/CUTSCENE_INSERT existed to build a cutscene_t and its item array directly in C; real cutscenes are now authored exclusively as .jsonc files parsed via cutsceneParseDoc, so these are dead weight in production. Deletes the demo scene that still used them (testcutscene.h, wired to NPC #3) along with its now-dead include in npc.c. test_cutscenesystem.c - the only other user, building cutscenes in-memory for tests - now writes the equivalent struct literals directly, matching the convention already used by test_battle.c/test_entityinteract.c. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
@@ -20,14 +20,27 @@ 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, NONE,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INNER_ITEMS[] = {
|
||||
CUTSCENE_CALLBACK(recordCallback)
|
||||
);
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INNER = {
|
||||
.items = CUTSCENE_TEST_INNER_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INNER_ITEMS) / sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
CUTSCENE(TEST_OUTER, DEFAULT,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_OUTER_ITEMS[] = {
|
||||
CUTSCENE_WAIT(0.5f),
|
||||
CUTSCENE_CUTSCENE(TEST_INNER)
|
||||
);
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_CUTSCENE,
|
||||
.cutsceneRef = { .cutscene = &CUTSCENE_TEST_INNER, .name = NULL }
|
||||
}
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_OUTER = {
|
||||
.items = CUTSCENE_TEST_OUTER_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_OUTER_ITEMS) / sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_DEFAULT
|
||||
};
|
||||
|
||||
static void test_cutsceneSystemStartSetsUpInitialItem(void **state) {
|
||||
|
||||
@@ -75,9 +88,14 @@ static void test_cutsceneSystemUpdateIsNoopWithNoActiveCutscene(void **state) {
|
||||
assert_null(CUTSCENE_SYSTEM.scene);
|
||||
}
|
||||
|
||||
CUTSCENE(TEST_SINGLE_WAIT, NONE,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_SINGLE_WAIT_ITEMS[] = {
|
||||
CUTSCENE_WAIT(1.0f)
|
||||
);
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_SINGLE_WAIT = {
|
||||
.items = CUTSCENE_TEST_SINGLE_WAIT_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_SINGLE_WAIT_ITEMS) / sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
static void test_cutsceneSystemStartWithSetsInteractEntities(void **state) {
|
||||
|
||||
@@ -188,19 +206,34 @@ 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, NONE,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_SNIPPET_ITEMS[] = {
|
||||
CUTSCENE_CALLBACK(recordOrderA),
|
||||
CUTSCENE_WAIT(2.0f),
|
||||
CUTSCENE_CALLBACK(recordOrderB)
|
||||
);
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_SNIPPET = {
|
||||
.items = CUTSCENE_TEST_INSERT_SNIPPET_ITEMS,
|
||||
.itemCount =
|
||||
sizeof(CUTSCENE_TEST_INSERT_SNIPPET_ITEMS) / sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
CUTSCENE(TEST_INSERT_OUTER, NONE,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_OUTER_ITEMS[] = {
|
||||
CUTSCENE_CALLBACK(recordOrder0),
|
||||
CUTSCENE_WAIT(1.0f),
|
||||
CUTSCENE_CALLBACK(recordOrder1),
|
||||
CUTSCENE_INSERT(TEST_INSERT_SNIPPET),
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT,
|
||||
.insert = { .cutscene = &CUTSCENE_TEST_INSERT_SNIPPET, .name = NULL }
|
||||
},
|
||||
CUTSCENE_CALLBACK(recordOrder2)
|
||||
);
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_OUTER = {
|
||||
.items = CUTSCENE_TEST_INSERT_OUTER_ITEMS,
|
||||
.itemCount =
|
||||
sizeof(CUTSCENE_TEST_INSERT_OUTER_ITEMS) / sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
static void test_cutsceneInsertSplicesItemsInPlaceThenResumes(void **state) {
|
||||
|
||||
@@ -230,14 +263,31 @@ static void test_cutsceneInsertSplicesItemsInPlaceThenResumes(void **state) {
|
||||
assert_memory_equal(insertOrderLog, expected, sizeof(expected));
|
||||
}
|
||||
|
||||
CUTSCENE(TEST_INSERT_AS_LAST_ITEM_SNIPPET, NONE,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_AS_LAST_ITEM_SNIPPET_ITEMS[] = {
|
||||
CUTSCENE_CALLBACK(recordOrderA)
|
||||
);
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_AS_LAST_ITEM_SNIPPET = {
|
||||
.items = CUTSCENE_TEST_INSERT_AS_LAST_ITEM_SNIPPET_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INSERT_AS_LAST_ITEM_SNIPPET_ITEMS) /
|
||||
sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
CUTSCENE(TEST_INSERT_AS_LAST_ITEM_OUTER, NONE,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_AS_LAST_ITEM_OUTER_ITEMS[] = {
|
||||
CUTSCENE_CALLBACK(recordOrder0),
|
||||
CUTSCENE_INSERT(TEST_INSERT_AS_LAST_ITEM_SNIPPET)
|
||||
);
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT,
|
||||
.insert = {
|
||||
.cutscene = &CUTSCENE_TEST_INSERT_AS_LAST_ITEM_SNIPPET, .name = NULL
|
||||
}
|
||||
}
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_AS_LAST_ITEM_OUTER = {
|
||||
.items = CUTSCENE_TEST_INSERT_AS_LAST_ITEM_OUTER_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INSERT_AS_LAST_ITEM_OUTER_ITEMS) /
|
||||
sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
static void test_cutsceneInsertAsLastItemEndsCutsceneNaturally(
|
||||
void **state
|
||||
@@ -263,23 +313,47 @@ static void test_cutsceneInsertAsLastItemEndsCutsceneNaturally(
|
||||
assert_memory_equal(insertOrderLog, expected, sizeof(expected));
|
||||
}
|
||||
|
||||
CUTSCENE(TEST_INSERT_NESTED_INNER, NONE,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_NESTED_INNER_ITEMS[] = {
|
||||
CUTSCENE_CALLBACK(recordOrderA)
|
||||
);
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_NESTED_INNER = {
|
||||
.items = CUTSCENE_TEST_INSERT_NESTED_INNER_ITEMS,
|
||||
.itemCount =
|
||||
sizeof(CUTSCENE_TEST_INSERT_NESTED_INNER_ITEMS) / sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
// 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, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_NESTED_INNER),
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_NESTED_MID_ITEMS[] = {
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT,
|
||||
.insert = { .cutscene = &CUTSCENE_TEST_INSERT_NESTED_INNER, .name = NULL }
|
||||
},
|
||||
CUTSCENE_CALLBACK(recordOrderB)
|
||||
);
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_NESTED_MID = {
|
||||
.items = CUTSCENE_TEST_INSERT_NESTED_MID_ITEMS,
|
||||
.itemCount =
|
||||
sizeof(CUTSCENE_TEST_INSERT_NESTED_MID_ITEMS) / sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
CUTSCENE(TEST_INSERT_NESTED_OUTER, NONE,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_NESTED_OUTER_ITEMS[] = {
|
||||
CUTSCENE_CALLBACK(recordOrder0),
|
||||
CUTSCENE_INSERT(TEST_INSERT_NESTED_MID),
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT,
|
||||
.insert = { .cutscene = &CUTSCENE_TEST_INSERT_NESTED_MID, .name = NULL }
|
||||
},
|
||||
CUTSCENE_CALLBACK(recordOrder2)
|
||||
);
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_NESTED_OUTER = {
|
||||
.items = CUTSCENE_TEST_INSERT_NESTED_OUTER_ITEMS,
|
||||
.itemCount =
|
||||
sizeof(CUTSCENE_TEST_INSERT_NESTED_OUTER_ITEMS) / sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
static void test_cutsceneInsertNestsThroughMultipleLevels(void **state) {
|
||||
|
||||
@@ -306,24 +380,75 @@ static void test_cutsceneInsertNestsThroughMultipleLevels(void **state) {
|
||||
assert_memory_equal(insertOrderLog, expected, sizeof(expected));
|
||||
}
|
||||
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL5, NONE,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL5_ITEMS[] = {
|
||||
CUTSCENE_CALLBACK(recordOrderA)
|
||||
);
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL4, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_OVERFLOW_LEVEL5)
|
||||
);
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL3, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_OVERFLOW_LEVEL4)
|
||||
);
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL2, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_OVERFLOW_LEVEL3)
|
||||
);
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL1, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_OVERFLOW_LEVEL2)
|
||||
);
|
||||
CUTSCENE(TEST_INSERT_OVERFLOW_LEVEL0, NONE,
|
||||
CUTSCENE_INSERT(TEST_INSERT_OVERFLOW_LEVEL1)
|
||||
);
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL5 = {
|
||||
.items = CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL5_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL5_ITEMS) /
|
||||
sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL4_ITEMS[] = {
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT,
|
||||
.insert = { .cutscene = &CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL5, .name = NULL }
|
||||
}
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL4 = {
|
||||
.items = CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL4_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL4_ITEMS) /
|
||||
sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL3_ITEMS[] = {
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT,
|
||||
.insert = { .cutscene = &CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL4, .name = NULL }
|
||||
}
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL3 = {
|
||||
.items = CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL3_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL3_ITEMS) /
|
||||
sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL2_ITEMS[] = {
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT,
|
||||
.insert = { .cutscene = &CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL3, .name = NULL }
|
||||
}
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL2 = {
|
||||
.items = CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL2_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL2_ITEMS) /
|
||||
sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL1_ITEMS[] = {
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT,
|
||||
.insert = { .cutscene = &CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL2, .name = NULL }
|
||||
}
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL1 = {
|
||||
.items = CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL1_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL1_ITEMS) /
|
||||
sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL0_ITEMS[] = {
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT,
|
||||
.insert = { .cutscene = &CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL1, .name = NULL }
|
||||
}
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL0 = {
|
||||
.items = CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL0_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INSERT_OVERFLOW_LEVEL0_ITEMS) /
|
||||
sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NONE
|
||||
};
|
||||
|
||||
static void test_cutsceneInsertAssertsWhenNestingExceedsStackMax(
|
||||
void **state
|
||||
@@ -341,13 +466,28 @@ static void test_cutsceneInsertAssertsWhenNestingExceedsStackMax(
|
||||
|
||||
static void noopInsertCallback(void *userData) {}
|
||||
|
||||
CUTSCENE(TEST_INSERT_PERSIST_SNIPPET, ALL,
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_PERSIST_SNIPPET_ITEMS[] = {
|
||||
CUTSCENE_CALLBACK(noopInsertCallback)
|
||||
);
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_PERSIST_SNIPPET = {
|
||||
.items = CUTSCENE_TEST_INSERT_PERSIST_SNIPPET_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INSERT_PERSIST_SNIPPET_ITEMS) /
|
||||
sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_ALL
|
||||
};
|
||||
|
||||
CUTSCENE(TEST_INSERT_PERSIST_OUTER, NPC,
|
||||
CUTSCENE_INSERT(TEST_INSERT_PERSIST_SNIPPET)
|
||||
);
|
||||
static const cutsceneitem_t CUTSCENE_TEST_INSERT_PERSIST_OUTER_ITEMS[] = {
|
||||
{
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT,
|
||||
.insert = { .cutscene = &CUTSCENE_TEST_INSERT_PERSIST_SNIPPET, .name = NULL }
|
||||
}
|
||||
};
|
||||
static const cutscene_t CUTSCENE_TEST_INSERT_PERSIST_OUTER = {
|
||||
.items = CUTSCENE_TEST_INSERT_PERSIST_OUTER_ITEMS,
|
||||
.itemCount = sizeof(CUTSCENE_TEST_INSERT_PERSIST_OUTER_ITEMS) /
|
||||
sizeof(cutsceneitem_t),
|
||||
.pause = CUTSCENE_PAUSE_NPC
|
||||
};
|
||||
|
||||
static void test_cutsceneInsertDoesNotResetPauseOrInteractEntities(
|
||||
void **state
|
||||
|
||||
Reference in New Issue
Block a user