From 2abd5b0c3c3895b635bab5464c663320d4566a10 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sat, 19 Sep 2026 21:17:11 -0500 Subject: [PATCH] Beginning a bit of cleanup --- src/dusk/rpg/battle/battle.h | 20 ++++++++------------ src/dusk/rpg/cutscene/cutscene.c | 7 ------- src/dusk/rpg/cutscene/cutscenesystem.c | 14 +------------- src/dusk/scene/initial/sceneinitial.c | 7 +------ src/dusk/ui/screen/mainmenu/uimainmenu.c | 8 +------- 5 files changed, 11 insertions(+), 45 deletions(-) diff --git a/src/dusk/rpg/battle/battle.h b/src/dusk/rpg/battle/battle.h index eb7910d6..6bdfee25 100644 --- a/src/dusk/rpg/battle/battle.h +++ b/src/dusk/rpg/battle/battle.h @@ -28,21 +28,17 @@ typedef enum { BATTLE_RESULT_COUNT } battleresult_t; -// Where BATTLE currently is within a round. A cutscene can pause progression -// (CUTSCENE_PAUSE_BATTLE) and use CUTSCENE_BATTLE_WAIT_STATE to synchronize -// with any of these, or CUTSCENE_BATTLE_FORCE_ACTION to decide a fighter's -// action ahead of PLAYER_SELECTION/AI_SELECTION reaching them. typedef enum { - BATTLE_STATE_NONE, // Battle inactive. + BATTLE_STATE_NONE, - BATTLE_STATE_OPENING, // Entered once by battleStart(). - BATTLE_STATE_PRE_ROUND, // Rebuilds execution order, clears the action queue. - BATTLE_STATE_PLAYER_SELECTION, // Waits on battlePlayerAttack/Flee. - BATTLE_STATE_AI_SELECTION, // Auto-queues every undecided AI fighter. - BATTLE_STATE_MOVES_EXECUTING, // Resolves one queued action per update. - BATTLE_STATE_POST_ROUND, // Round wrap-up; loops back to PRE_ROUND. + BATTLE_STATE_OPENING, + BATTLE_STATE_PRE_ROUND, + BATTLE_STATE_PLAYER_SELECTION, + BATTLE_STATE_AI_SELECTION, + BATTLE_STATE_MOVES_EXECUTING, + BATTLE_STATE_POST_ROUND, - BATTLE_STATE_ENDED, // Terminal for WIN/LOSS/FLED alike -- see BATTLE.result. + BATTLE_STATE_ENDED, BATTLE_STATE_COUNT } battlestate_t; diff --git a/src/dusk/rpg/cutscene/cutscene.c b/src/dusk/rpg/cutscene/cutscene.c index 8ff7715b..710d188e 100644 --- a/src/dusk/rpg/cutscene/cutscene.c +++ b/src/dusk/rpg/cutscene/cutscene.c @@ -83,13 +83,6 @@ errorret_t cutsceneParseDoc( } } - // Everything structural has validated by this point, so it's safe to - // start overwriting items - a per-item parse failure past this point - // still leaves it partially overwritten, but that's fine: any load - // failure here already sends the game into the fatal-error overlay (see - // cutsceneSystemLoad/cutsceneCutsceneResolve/ - // cutsceneInsertResolveAndSplice), so nothing keeps running against - // stale data. memoryZero(items, itemCount * sizeof(cutsceneitem_t)); yyjson_arr_iter itemIter = yyjson_arr_iter_with(itemsArr); diff --git a/src/dusk/rpg/cutscene/cutscenesystem.c b/src/dusk/rpg/cutscene/cutscenesystem.c index c9dce79f..f7d6cfba 100644 --- a/src/dusk/rpg/cutscene/cutscenesystem.c +++ b/src/dusk/rpg/cutscene/cutscenesystem.c @@ -104,10 +104,7 @@ void cutsceneSystemInsertCutscene(const cutscene_t *cutscene) { void cutsceneSystemLoad(const char_t *file) { assertNotNull(file, "File cannot be NULL"); - char_t path[ASSET_FILE_NAME_MAX]; - stringFormat(path, sizeof(path), "cutscenes/%s", file); - - assetentry_t *entry = assetLock(path, ASSET_LOADER_TYPE_JSON, NULL); + assetentry_t *entry = assetLock(file, ASSET_LOADER_TYPE_JSON, NULL); errorret_t result = assetRequireLoaded(entry); if(errorIsNotOk(result)) { assetUnlockEntry(entry); @@ -141,20 +138,11 @@ void cutsceneRestart(void) { CUTSCENE_SYSTEM.scene, "cutsceneRestart called with no cutscene running" ); - // A restart is the same logical run trying again (e.g. retrying a failed - // save-device check), not a fresh unrelated start, so it should not - // silently drop a completion callback the caller already armed, or the - // entities that triggered it - both cutsceneSystemStartCutsceneWith and - // cutsceneSystemLoad (via cutsceneSystemPrepare) forget them. cutscenecallback_t onComplete = CUTSCENE_SYSTEM.onComplete; entity_t *entityInteract = CUTSCENE_SYSTEM.entityInteract; entity_t *entityInteracted = CUTSCENE_SYSTEM.entityInteracted; if(CUTSCENE_SYSTEM.loadedFile[0] != '\0') { - // Came from a cutscene asset - re-read+re-parse it from scratch - // rather than just rerunning whatever's still resident in - // loadedScene/loadedItems, so a restart always reflects the file's - // current contents. char_t file[ASSET_FILE_NAME_MAX]; stringCopy(file, CUTSCENE_SYSTEM.loadedFile, ASSET_FILE_NAME_MAX - 1); cutsceneSystemLoad(file); diff --git a/src/dusk/scene/initial/sceneinitial.c b/src/dusk/scene/initial/sceneinitial.c index 2242f142..29fada88 100644 --- a/src/dusk/scene/initial/sceneinitial.c +++ b/src/dusk/scene/initial/sceneinitial.c @@ -17,13 +17,8 @@ errorret_t sceneInitialInit(scenedata_t *sceneData) { assertNotNull(sceneData, "Scene data cannot be null"); memoryZero(&sceneData->initial, sizeof(sceneinitial_t)); - // Set background color to black for the initial scene SCREEN.background = COLOR_BLACK; - - // Runtime-loaded from assets/cutscenes/initial.jsonc, parsed directly at - // load time (no separate compile step) - checks for a save device, - // retrying on failure, then hands off to the main menu. - cutsceneSystemLoad("initial.jsonc"); + cutsceneSystemLoad("cutscenes/initial.jsonc"); errorOk(); } diff --git a/src/dusk/ui/screen/mainmenu/uimainmenu.c b/src/dusk/ui/screen/mainmenu/uimainmenu.c index 6e8eb8e3..5e302994 100644 --- a/src/dusk/ui/screen/mainmenu/uimainmenu.c +++ b/src/dusk/ui/screen/mainmenu/uimainmenu.c @@ -28,18 +28,12 @@ uimainmenu_t UI_MAIN_MENU; cutscene_t *uiMainMenuLoadCutscene(void) { - // Delegates entirely to cutsceneCutsceneResolve rather than keeping our - // own locked-forever entry, since only one JSON-authored cutscene is - // ever resident at a time (see CUTSCENE_LOADED_ITEMS_MAX's doc comment - // in cutscenesystem.h) - caching an entry pointer here across calls - // would go stale the moment any other cutscene loads in the meantime. - // May return NULL on failure (already reported via uiFatalErrorOpen). return cutsceneCutsceneResolve("main_menu"); } void uiMainMenuSelectSaveResult(const uint8_t slotIndex, void *user) { if(slotIndex == UI_SELECT_SAVE_RESULT_NONE) { - cutsceneSystemLoad("main_menu.jsonc"); + cutsceneSystemLoad("cutscene/main_menu.jsonc"); return; }