- battleStateSelectionAiDecide: AI-controlled fighters now actually
queue a basic attack against the first living enemy instead of doing
nothing every round.
- battleStateEndingInit: disposes the battle and switches back to
SCENE_TYPE_OVERWORLD instead of leaving the game stuck in the battle
scene forever.
- cutsceneSystemNext now pops each finished item off the front of the
running cutscene (cutsceneRemoveFront) instead of leaving it in place
forever, so a long-running cutscene (many battle rounds splicing
items in repeatedly) no longer grows scene->items unboundedly.
- cutsceneGoTo reworked to match: since consumed items are evicted, a
marker behind the current position can't be found in the live queue
anymore, so it now re-parses the cutscene fresh from its source file
(cutsceneLoadParse, into a persistent scratch buffer, not the stack)
and replaces the live queue with marker-onward from that fresh parse.
Only supported when the running cutscene is the one
cutsceneSystemLoad/cutsceneCutsceneResolve populated.
- Fixed a real bug this surfaced: cutsceneSystemPrepare unconditionally
cleared loadedFile, which ran *after* cutsceneCutsceneResolve had
just stamped it but *before* the cutscene started - wiping it out
immediately and breaking cutsceneGoTo for any cutscene entered via a
CUTSCENE item or cutsceneCutsceneResolve (e.g. the main menu's
NEW_GAME/OPTIONS/QUIT navigation). Now only cleared when switching
away from loadedScene entirely.
- Added cutsceneLoadParse, the shared "lock asset, require loaded,
parse items, unlock" sequence, replacing four near-identical copies
across cutsceneSystemLoad/cutsceneCutsceneResolve/
cutsceneInsertResolveAndSplice/battleStateExecutingInit. Each call
site handles its own fatal-error display; cutsceneLoadParse itself
just propagates.
- Added test_cutscene.c (cutsceneRemoveFront) and a regression test for
the loadedFile bug. Writing the zero-count RemoveFront test caught a
real self-move bug (count == 0 passed dest == src into memoryMove).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
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]>
Replaces the separate insert buffer/scene and insertStack return-frame
mechanism with cutsceneAppend/cutsceneAppendNext, so an inserted
cutscene's items become part of the running scene's own array instead
of a jump-and-return. Moves the loaded-items buffer/scene from file-scope
globals into cutscenesystem_t, and extracts shared start-cutscene setup
into cutsceneSystemPrepare.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
cutsceneAppend adds items to the end of a cutscene_t's item array;
cutsceneAppendNext inserts them at a given index instead (e.g.
CUTSCENE_SYSTEM.currentItem + 1, to run immediately after the
currently-executing item), shifting everything from that index
onward to make room. Both are capacity-bounded against the caller-
supplied itemsMax, matching cutsceneParseDoc's convention of never
assuming ownership of the backing buffer's size.
cutscene_t.items drops its const qualifier to allow this in-place
mutation; cutsceneitem_t backing arrays in the test fixtures that get
assigned into a mutable cutscene_t.items are no longer declared const
either, since a const source would otherwise silently violate the
field's new type.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Every CUTSCENE_XXX(...) shorthand (CUTSCENE_WAIT, CUTSCENE_TEXT,
CUTSCENE_ENTITY_WALK_TO, etc.) existed to build a cutsceneitem_t literal
in C; real cutscenes are now authored exclusively as .jsonc files, and
the only other users were test fixtures. Deletes all ~55 of these
macros (and the shared CUTSCENE_ITEM(...) helper they built on) along
with their doc comments, leaving each item's struct/enum/Start/Update/
Load declarations untouched.
test_battle.c, test_cutscenecontrol.c, test_cutscenemaparea.c,
test_cutscenesystem.c and test_entityinteract.c now build their
cutsceneitem_t fixtures as plain struct literals instead.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
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]>
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]>
Splicing a JSON-authored INSERT target by name previously resolved
through the same shared CUTSCENE_LOADED_ITEMS/POOL buffer as whatever
outer cutscene was currently running, so loading it would clobber the
outer cutscene's own items mid-playback - that's why it was reverted.
Gives INSERT its own smaller CUTSCENE_INSERT_ITEMS/POOL buffer and lets
the cutscene asset loader be told which buffer set to parse into, so an
INSERT's dynamic load no longer stomps the running cutscene.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Unlike CUTSCENE (a one-way jump that replaces the running cutscene),
INSERT splices a referenced cutscene's items into the running one and
resumes right after itself once they run out. Backed by a small return
stack on CUTSCENE_SYSTEM so inserts can nest.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Pure whitespace/line-break reformatting (braces, newlines, and line
continuations matching this codebase's existing wrap conventions) - no
logic, string content, or identifiers changed anywhere. Confirmed via
diff against the pre-change tree and by rebuilding + re-running the
affected test suites, which produce identical pass/fail results.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
- keyframeGetValue now returns the last keyframe's value for times at or
beyond it, fixes a missing util/math.h include, and asserts keyframes are
sorted by time; adds test/animation/test_keyframe.c
- Adds mainmenu scene/UI and a battle HUD UI frame
- Adds save autosave-related fields and battle scene tweaks
- Adds headless test coverage for cutscenes, entities, and map areas