Beginning a bit of cleanup
This commit is contained in:
@@ -28,21 +28,17 @@ typedef enum {
|
|||||||
BATTLE_RESULT_COUNT
|
BATTLE_RESULT_COUNT
|
||||||
} battleresult_t;
|
} 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 {
|
typedef enum {
|
||||||
BATTLE_STATE_NONE, // Battle inactive.
|
BATTLE_STATE_NONE,
|
||||||
|
|
||||||
BATTLE_STATE_OPENING, // Entered once by battleStart().
|
BATTLE_STATE_OPENING,
|
||||||
BATTLE_STATE_PRE_ROUND, // Rebuilds execution order, clears the action queue.
|
BATTLE_STATE_PRE_ROUND,
|
||||||
BATTLE_STATE_PLAYER_SELECTION, // Waits on battlePlayerAttack/Flee.
|
BATTLE_STATE_PLAYER_SELECTION,
|
||||||
BATTLE_STATE_AI_SELECTION, // Auto-queues every undecided AI fighter.
|
BATTLE_STATE_AI_SELECTION,
|
||||||
BATTLE_STATE_MOVES_EXECUTING, // Resolves one queued action per update.
|
BATTLE_STATE_MOVES_EXECUTING,
|
||||||
BATTLE_STATE_POST_ROUND, // Round wrap-up; loops back to PRE_ROUND.
|
BATTLE_STATE_POST_ROUND,
|
||||||
|
|
||||||
BATTLE_STATE_ENDED, // Terminal for WIN/LOSS/FLED alike -- see BATTLE.result.
|
BATTLE_STATE_ENDED,
|
||||||
|
|
||||||
BATTLE_STATE_COUNT
|
BATTLE_STATE_COUNT
|
||||||
} battlestate_t;
|
} battlestate_t;
|
||||||
|
|||||||
@@ -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));
|
memoryZero(items, itemCount * sizeof(cutsceneitem_t));
|
||||||
|
|
||||||
yyjson_arr_iter itemIter = yyjson_arr_iter_with(itemsArr);
|
yyjson_arr_iter itemIter = yyjson_arr_iter_with(itemsArr);
|
||||||
|
|||||||
@@ -104,10 +104,7 @@ void cutsceneSystemInsertCutscene(const cutscene_t *cutscene) {
|
|||||||
void cutsceneSystemLoad(const char_t *file) {
|
void cutsceneSystemLoad(const char_t *file) {
|
||||||
assertNotNull(file, "File cannot be NULL");
|
assertNotNull(file, "File cannot be NULL");
|
||||||
|
|
||||||
char_t path[ASSET_FILE_NAME_MAX];
|
assetentry_t *entry = assetLock(file, ASSET_LOADER_TYPE_JSON, NULL);
|
||||||
stringFormat(path, sizeof(path), "cutscenes/%s", file);
|
|
||||||
|
|
||||||
assetentry_t *entry = assetLock(path, ASSET_LOADER_TYPE_JSON, NULL);
|
|
||||||
errorret_t result = assetRequireLoaded(entry);
|
errorret_t result = assetRequireLoaded(entry);
|
||||||
if(errorIsNotOk(result)) {
|
if(errorIsNotOk(result)) {
|
||||||
assetUnlockEntry(entry);
|
assetUnlockEntry(entry);
|
||||||
@@ -141,20 +138,11 @@ void cutsceneRestart(void) {
|
|||||||
CUTSCENE_SYSTEM.scene, "cutsceneRestart called with no cutscene running"
|
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;
|
cutscenecallback_t onComplete = CUTSCENE_SYSTEM.onComplete;
|
||||||
entity_t *entityInteract = CUTSCENE_SYSTEM.entityInteract;
|
entity_t *entityInteract = CUTSCENE_SYSTEM.entityInteract;
|
||||||
entity_t *entityInteracted = CUTSCENE_SYSTEM.entityInteracted;
|
entity_t *entityInteracted = CUTSCENE_SYSTEM.entityInteracted;
|
||||||
|
|
||||||
if(CUTSCENE_SYSTEM.loadedFile[0] != '\0') {
|
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];
|
char_t file[ASSET_FILE_NAME_MAX];
|
||||||
stringCopy(file, CUTSCENE_SYSTEM.loadedFile, ASSET_FILE_NAME_MAX - 1);
|
stringCopy(file, CUTSCENE_SYSTEM.loadedFile, ASSET_FILE_NAME_MAX - 1);
|
||||||
cutsceneSystemLoad(file);
|
cutsceneSystemLoad(file);
|
||||||
|
|||||||
@@ -17,13 +17,8 @@ errorret_t sceneInitialInit(scenedata_t *sceneData) {
|
|||||||
assertNotNull(sceneData, "Scene data cannot be null");
|
assertNotNull(sceneData, "Scene data cannot be null");
|
||||||
memoryZero(&sceneData->initial, sizeof(sceneinitial_t));
|
memoryZero(&sceneData->initial, sizeof(sceneinitial_t));
|
||||||
|
|
||||||
// Set background color to black for the initial scene
|
|
||||||
SCREEN.background = COLOR_BLACK;
|
SCREEN.background = COLOR_BLACK;
|
||||||
|
cutsceneSystemLoad("cutscenes/initial.jsonc");
|
||||||
// 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");
|
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,18 +28,12 @@
|
|||||||
uimainmenu_t UI_MAIN_MENU;
|
uimainmenu_t UI_MAIN_MENU;
|
||||||
|
|
||||||
cutscene_t *uiMainMenuLoadCutscene(void) {
|
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");
|
return cutsceneCutsceneResolve("main_menu");
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiMainMenuSelectSaveResult(const uint8_t slotIndex, void *user) {
|
void uiMainMenuSelectSaveResult(const uint8_t slotIndex, void *user) {
|
||||||
if(slotIndex == UI_SELECT_SAVE_RESULT_NONE) {
|
if(slotIndex == UI_SELECT_SAVE_RESULT_NONE) {
|
||||||
cutsceneSystemLoad("main_menu.jsonc");
|
cutsceneSystemLoad("cutscene/main_menu.jsonc");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user