Remove unused CUTSCENE_SYSTEM.userData scratch buffer
Nothing ever wrote to it - it only ever passed its own address through to onComplete/CUTSCENE_CALLBACK/modal-option callbacks, so every call site now passes NULL directly and the 8KB buffer is gone. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
@@ -253,7 +253,6 @@ void cutsceneSystemNext() {
|
|||||||
// by this function's own cleanup running after it - same reentrancy
|
// by this function's own cleanup running after it - same reentrancy
|
||||||
// hazard as uiFocusPop, see src/dusk/ui/focus/uifocus.c.
|
// hazard as uiFocusPop, see src/dusk/ui/focus/uifocus.c.
|
||||||
cutscenecallback_t onComplete = CUTSCENE_SYSTEM.onComplete;
|
cutscenecallback_t onComplete = CUTSCENE_SYSTEM.onComplete;
|
||||||
void *userData = CUTSCENE_SYSTEM.userData;
|
|
||||||
|
|
||||||
CUTSCENE_SYSTEM.scene = NULL;
|
CUTSCENE_SYSTEM.scene = NULL;
|
||||||
CUTSCENE_SYSTEM.currentItem = 0xFF;
|
CUTSCENE_SYSTEM.currentItem = 0xFF;
|
||||||
@@ -267,7 +266,7 @@ void cutsceneSystemNext() {
|
|||||||
CUTSCENE_SYSTEM.textCache[0] = '\0';
|
CUTSCENE_SYSTEM.textCache[0] = '\0';
|
||||||
CUTSCENE_SYSTEM.onComplete = NULL;
|
CUTSCENE_SYSTEM.onComplete = NULL;
|
||||||
|
|
||||||
if(onComplete != NULL) onComplete(userData);
|
if(onComplete != NULL) onComplete(NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ typedef struct entity_s entity_t;
|
|||||||
#define CUTSCENE_AREA_LAST_CREATED ((uint8_t)0xFF)
|
#define CUTSCENE_AREA_LAST_CREATED ((uint8_t)0xFF)
|
||||||
#define CUTSCENE_TEXT_MINI_LAST_CREATED ((uint8_t)0xFA)
|
#define CUTSCENE_TEXT_MINI_LAST_CREATED ((uint8_t)0xFA)
|
||||||
|
|
||||||
#define CUTSCENE_SYSTEM_SIZE_MAX 8192
|
|
||||||
#define CUTSCENE_TEXT_CACHE_MAX 64
|
#define CUTSCENE_TEXT_CACHE_MAX 64
|
||||||
#define CUTSCENE_LOADED_ITEMS_MAX 128
|
#define CUTSCENE_LOADED_ITEMS_MAX 128
|
||||||
|
|
||||||
@@ -48,16 +47,9 @@ typedef struct {
|
|||||||
// Runtime data for the current item.
|
// Runtime data for the current item.
|
||||||
cutsceneitemdata_t data;
|
cutsceneitemdata_t data;
|
||||||
|
|
||||||
// Custom user data for the running cutscene.
|
|
||||||
uint8_t userData[CUTSCENE_SYSTEM_SIZE_MAX];
|
|
||||||
|
|
||||||
// See cutsceneSystemSetOnComplete.
|
// See cutsceneSystemSetOnComplete.
|
||||||
cutscenecallback_t onComplete;
|
cutscenecallback_t onComplete;
|
||||||
|
|
||||||
// The fixed buffer/scene pair cutsceneSystemLoad/cutsceneCutsceneResolve
|
|
||||||
// parse a JSON-authored cutscene into - see CUTSCENE_LOADED_ITEMS_MAX
|
|
||||||
// above. loadedScene.items always points at loadedItems; loadedScene's
|
|
||||||
// itemCount/itemsMax/pause are overwritten on each load.
|
|
||||||
cutsceneitem_t loadedItems[CUTSCENE_LOADED_ITEMS_MAX];
|
cutsceneitem_t loadedItems[CUTSCENE_LOADED_ITEMS_MAX];
|
||||||
cutscene_t loadedScene;
|
cutscene_t loadedScene;
|
||||||
} cutscenesystem_t;
|
} cutscenesystem_t;
|
||||||
@@ -139,7 +131,7 @@ void cutsceneSystemStartCutsceneAndGoToMarker(
|
|||||||
* Then immediately advances into the first inserted item (see
|
* Then immediately advances into the first inserted item (see
|
||||||
* cutsceneSystemNext), so the splice takes effect within this same call.
|
* cutsceneSystemNext), so the splice takes effect within this same call.
|
||||||
* Deliberately does not touch pause flags, interact entities, "last
|
* Deliberately does not touch pause flags, interact entities, "last
|
||||||
* created" state, the text cache or userData - those all keep whatever the
|
* created" state, or the text cache - those all keep whatever the
|
||||||
* outer cutscene set, since this is meant to feel like pasting cutscene's
|
* outer cutscene set, since this is meant to feel like pasting cutscene's
|
||||||
* items in place rather than starting an independent cutscene. Because of
|
* items in place rather than starting an independent cutscene. Because of
|
||||||
* this, cutscene's own .pause is ignored. Asserts if no cutscene is
|
* this, cutscene's own .pause is ignored. Asserts if no cutscene is
|
||||||
@@ -194,7 +186,7 @@ void cutsceneRestart(void);
|
|||||||
* call this again after starting a new cutscene to arm it - but
|
* call this again after starting a new cutscene to arm it - but
|
||||||
* cutsceneRestart() preserves whatever was armed, since a restart (e.g.
|
* cutsceneRestart() preserves whatever was armed, since a restart (e.g.
|
||||||
* retrying a failed check) is the same logical run trying again, not a new
|
* retrying a failed check) is the same logical run trying again, not a new
|
||||||
* one. Invoked with CUTSCENE_SYSTEM.userData, same as CUTSCENE_CALLBACK.
|
* one. Invoked with NULL, same as CUTSCENE_CALLBACK.
|
||||||
*
|
*
|
||||||
* Exists so a runtime-loaded cutscene file (which can't store a native
|
* Exists so a runtime-loaded cutscene file (which can't store a native
|
||||||
* function pointer) can still hand off to native code once it's done,
|
* function pointer) can still hand off to native code once it's done,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ void cutsceneCallbackStart(
|
|||||||
const cutsceneitem_t *item,
|
const cutsceneitem_t *item,
|
||||||
cutsceneitemdata_t *data
|
cutsceneitemdata_t *data
|
||||||
) {
|
) {
|
||||||
if(item->callback != NULL) item->callback(CUTSCENE_SYSTEM.userData);
|
if(item->callback != NULL) item->callback(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool_t cutsceneCallbackUpdate(
|
bool_t cutsceneCallbackUpdate(
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ void cutsceneModalStart(
|
|||||||
modal->optionCount,
|
modal->optionCount,
|
||||||
modal->callback,
|
modal->callback,
|
||||||
NULL,
|
NULL,
|
||||||
CUTSCENE_SYSTEM.userData
|
NULL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
* (see uiMenuSetDisableBack), so it must be dismissed by picking one.
|
* (see uiMenuSetDisableBack), so it must be dismissed by picking one.
|
||||||
*
|
*
|
||||||
* @param optionIndex Index into the options array that was selected.
|
* @param optionIndex Index into the options array that was selected.
|
||||||
* @param userData CUTSCENE_SYSTEM.userData for the running cutscene.
|
* @param userData Unused - always NULL. Required by uiModalOpen's
|
||||||
|
* callback signature.
|
||||||
*/
|
*/
|
||||||
typedef void (*cutscenemodaloptioncallback_t)(
|
typedef void (*cutscenemodaloptioncallback_t)(
|
||||||
const uint8_t optionIndex, void *userData
|
const uint8_t optionIndex, void *userData
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void cutsceneModalOptionsMarkersStart(
|
|||||||
options->optionCount,
|
options->optionCount,
|
||||||
cutsceneModalOptionsMarkersCallback,
|
cutsceneModalOptionsMarkersCallback,
|
||||||
NULL,
|
NULL,
|
||||||
CUTSCENE_SYSTEM.userData
|
NULL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ static void recordCallback(void *userData) {
|
|||||||
callbackCallCount++;
|
callbackCallCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_cutsceneCallbackFiresOnStartWithUserData(void **state) {
|
static void test_cutsceneCallbackFiresOnStartWithNullUserData(void **state) {
|
||||||
|
|
||||||
callbackCallCount = 0;
|
callbackCallCount = 0;
|
||||||
lastUserData = NULL;
|
lastUserData = (void *)0x1;
|
||||||
|
|
||||||
cutsceneitem_t item =
|
cutsceneitem_t item =
|
||||||
{ .type = CUTSCENE_ITEM_TYPE_CALLBACK, .callback = recordCallback };
|
{ .type = CUTSCENE_ITEM_TYPE_CALLBACK, .callback = recordCallback };
|
||||||
@@ -44,7 +44,7 @@ static void test_cutsceneCallbackFiresOnStartWithUserData(void **state) {
|
|||||||
|
|
||||||
cutsceneCallbackStart(&item, &data);
|
cutsceneCallbackStart(&item, &data);
|
||||||
assert_int_equal(callbackCallCount, 1);
|
assert_int_equal(callbackCallCount, 1);
|
||||||
assert_ptr_equal(lastUserData, CUTSCENE_SYSTEM.userData);
|
assert_null(lastUserData);
|
||||||
|
|
||||||
// Callback items always complete immediately -- the effect already
|
// Callback items always complete immediately -- the effect already
|
||||||
// happened in Start, not Update.
|
// happened in Start, not Update.
|
||||||
@@ -161,7 +161,7 @@ static void test_cutsceneConcurrentCannotNest(void **state) {
|
|||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
const struct CMUnitTest tests[] = {
|
const struct CMUnitTest tests[] = {
|
||||||
cmocka_unit_test(test_cutsceneWaitCompletesAfterItsDuration),
|
cmocka_unit_test(test_cutsceneWaitCompletesAfterItsDuration),
|
||||||
cmocka_unit_test(test_cutsceneCallbackFiresOnStartWithUserData),
|
cmocka_unit_test(test_cutsceneCallbackFiresOnStartWithNullUserData),
|
||||||
cmocka_unit_test(test_cutsceneCallbackNullIsNoop),
|
cmocka_unit_test(test_cutsceneCallbackNullIsNoop),
|
||||||
cmocka_unit_test(test_cutsceneSetPauseAppliesImmediately),
|
cmocka_unit_test(test_cutsceneSetPauseAppliesImmediately),
|
||||||
cmocka_unit_test(test_cutsceneConcurrentCompletesOnceAllChildrenDo),
|
cmocka_unit_test(test_cutsceneConcurrentCompletesOnceAllChildrenDo),
|
||||||
|
|||||||
Reference in New Issue
Block a user