cube_game #6

Open
P7MJ wants to merge 0 commits from cube_game into main
Owner

How about we put this maintained one as main

How about we put this maintained one as main
P7MJ added 112 commits 2026-10-29 02:30:18 +00:00
- src/sound.c/h: scans music-file-definitions/, loads audio streams, plays
  looping background music, volume follows the sound_volume slider, degrades
  gracefully when no audio device or no music files
- settings.h/c + options.c: new music_enabled key persisted in options.txt
- menu Sound tab: Music checkbox + Now playing line, applies on leaving Options
- CAScript: playmusic()/stopmusic() builtins (docs updated in CAScript.md)
- todo.txt: sound-system item removed (done)

Also includes the previously staged batch: unified options.txt (settings +
keybinds + migration from legacy files), CAScript for loop / postfix ++-- /
compound assignment / 9 new builtins, debug cursor back-chunk line, block
name readout, docs/CAScript.md, levels/template.cas boilerplate.
Unified entity-index API (player = index 0), 1000 HP cubes with KO (no
permanent death), combat mode toggle, bump damage (both sides fighting),
weapons from weapon-*-definitions/ (stick 0.5 scale = 2 world units,
bamboo pole 1.0 = 4 units; assets keyed to stats-file base name),
inventory (16 slots, E, equip/drop/destroy), swing/thrust/pull/fire
animations, per-cell weapon collision (solid = full, soft = half),
attack cooldown + durability, debug-mode maroon HP/index readouts,
CAScript combat builtins, and regen: 5 HP per 10 s after 60 s out of
combat (KO'd on the same schedule).

EXPERIMENTAL: balance, damage numbers, regen timings and the weapon
scale convention are provisional and likely to change.
Gameplay:
- Dropped/thrown items now BOUNCE off hard surfaces when their impact
  speed clears BOUNCE_MIN_SPEED, keeping the weapon's bounce stat (0..1,
  added to stick/bamboo_pole as 0.3) as the fraction of energy kept after
  each bounce. A bounce reflects the hitting axis and scales the other,
  so a thrown weapon keeps flying (still airborne, can still hit) with
  no durability cost - durability only drops when it finally STOPS.
- Items next to a wall now LEAN against it instead of always lying flat
  (rotated ~58 deg, lower end grounded, nudged to touch the wall face).
- spawnitem(name, x, y) now returns the dropped-item INDEX (0..63, -1 on
  failure) and a new removeitem(index) builtin deletes a dropped item -
  documented in docs/CAScript.md. selftest updated for the index API.
- Removed dripping-when-out-of-water (kept the swim splash): WET_TIME/
  DRIP_INTERVAL/g_dripSpawns/SpawnDripDrops and the entity fields are
  gone, plus the two selftest drip checks.

Fixes + UI:
- Debug cursor no longer shows "unknown unknown": blocks.txt (now living
  in block-texture-definitions/) is loaded from its new home, with the
  legacy root path as fallback.
- Removed "(game paused)" from the inventory screen.
- Removed "all options are stored to options.txt" from the Options >
  Control screen, and nudged the Video/Sound/Control tab row + indicators
  slightly up.
- todo.txt: item-type note ("weapons but not for attack"), spawnitem/
  removeitem marked done.

Includes the uncommitted session backlog (CAScript console, hint()
overlay, swim + splash, combat additions, level select save button, pot
item assets, CALinter.py) and the user's map/level renames.
- Interactables redesigned as a class of items: one spawninteractable("item", x, y) { code } (item textures only, no collision/gravity, returns index), setinteractablefollow (snap to cube/item, inherit shape for the yellow outline), removeinteractable, magic vars interactable/interactor; src/interactable.c/h
- Item class ("weapons but not for attack"): hard/brittle types, put_in_inventory, shield slot, write overlay (whiteboard), pot + whiteboard + quest_book assets; src/writeboard.c/h
- KO rework: ragdoll physics removed - a KO'd cube lies in place with a slight dark tint and drops its equipped weapon + shield as pickup-able items; regen/revive unchanged
- ESC now skips an active hint()/dialogue box instead of opening the pause menu
- Physics: extreme-velocity safety net (snap-back ~1s) for entities and dropped items; dropped-item bounce on total impact + wall-lean; setitemunpickable builtin; pickup range raised to 1 chunk
- Options > Control: 2-column centered keybinds (7 per column), smaller Change buttons, Charge / Attack-Pick renames
- Tooling: selftest.sh runner (windowed + -f11), self-test grown to 82 checks incl. ko-drop/no-bounce/revive/tint; CALinter updated; docs/CAS-Reference.txt cheat sheet + CAScript.md refreshed
- todo.txt updated with designed-not-built sections (save system, two-tier dialogue, quest book)

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
- mchint(position, icon, l1, l2, ["A","B",...]) builtin: up to 4 reply
  buttons under the hint box; the level script suspends until the player
  clicks one (or ESC/Space = -1), then the picked index is returned into
  the statement so if/else chains branch on the answer. Inline ["a","b"]
  array literals in call args; CALinter understands them too.
- Hint box now renders misc-texture-definitions/hintbox.png (70x13: 1px
  frame + beige fill + transparent corners) as a plain uniform stretch -
  the texture and box share a 5.38:1 ratio, so the frame scales up ~8x
  and the corner cutouts become visible rounded corners at any window
  size. Nine-patch remains the tool for size-varying textures.
- Selftest: mchint-show/mchint-return checks, hint-overlay pixel check
  samples the new beige box. 84 PASS windowed and F11.
- Docs + todo updated.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
- dialogue(index, text, position): bubble chatter anchored to any cube,
  your chatter-*x6-* texture art (smallest size that fits, ... truncation),
  regional toggle (2 chunks), bubbles hidden off-region
- Weight/encumbrance: CarriedWeight + WeightSpeedFactor (10/20 thresholds),
  physics speed clamp for all entities, jump/charge blocked when stuck,
  debug HUD "W:" readout
- Title menu (Cube A): New Save / Load Save / Options / Credits / Quit,
  replaces the level-select-as-title stand-in
- Save system (src/savefile.c/h): saves/Save_XXX folders +
  save_metadata.txt (name/created/last_played/score), pause-menu Save Game
  button writes gamestate.txt + inventory.txt (whiteboard lines travel
  with items), Option A load (script first, then saved player state),
  manual-only saving, nested git repo rollback (git_rollback.sh)
- New Save boots the start level from newsavefile.txt; Load Save is a
  scrollable metadata list
- Selftest: save-roundtrip + save-load checks replace the old placeholder
  save-btn check (91 PASS)

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
- Title screen now shows a living background level (levels/title_bg.cas, configurable
  via title_screen_level) with hopping cubes driven by the engine; Return to Title
  reboots it via EnterTitleScreen()
- Load Save: right-click a save to delete it (confirm modal, SaveDelete() recursive
  removal); scrollable list got a scissor-window frame, smooth non-inverted scrolling,
  Last played nudged right, Back button moved up
- CAScript: jump(index) + walk(index, time[, dir]) builtins; walk driven by physics
  pass so it works on any cube and outlives the script
- Music: octo-title.mp3 -> octo-new-beginnings.mp3 (default + title music); levels
  start silent unless playmusic() is called; F12 debug dump shows current track
- Credits: OctoLinkYT (music), P7MJ (structure/ideas/textures), Freebuff DeepSeek V4 (code)
- CALinter + CAS docs updated for the new builtins; selftest 94 PASS windowed + F11

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
- Interpreter: replaced the top-level statement runner with an explicit-stack
  machine, so wait() and mchint() can suspend inside loops, if-branches, and
  statement-position function calls, resuming exactly where they left off
  (loop counters + scopes preserved); runaway-loop guards still error cleanly.
- Physics: ResolveAxis now resolves sub-epsilon movement (do-while), fixing
  cubes sitting ungrounded with creeping vy at unlimited FPS - the "unlimited
  fps feels slow" bug and the randomly-refusing jump().
- Warning system (src/warning.h/.c): warning() cinematic, unnecessary-violence
  ladder (6 strikes in 30s -> warning, repeat in 5min -> escalation, third
  offense -> blackout to title, nothing saved), enableviolence() bypass with
  colored-particle KO shatter at 300 extra damage, in-RAM getstat/addstat.
- Debug HUD: "CA A-0-i" version, FPS in place of SIMULATING, compact mode
  text, measured-width flow layout so nothing overlaps.
- Selftest case 25 (violence ladder / shatter / warning) - 99 PASS / 0 FAIL
  windowed and F11. Docs + CALinter updated; todo.txt reorganized with an
  audit index, next-up priorities, and a dedicated obsolete/replaced section.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
- Pause-menu Save Game flips to a locked grey "Saved!" state for 5s after
  saving instead of the yellow "saved to save_XXX" note (UiButtonDisabled).
- EnsureSaveDir(): saves/ is gitignored, so fresh clones had no folder and
  "New Save" silently bounced to the title screen (mkdir ENOENT); create it
  on demand.
- Load Save: right-clicking a row opens an inventory-style Delete context
  menu at the cursor; picking Delete arms the confirmation modal. ESC closes
  menu -> modal -> screen in that order.
- Delete-confirm modal's Delete/Cancel buttons moved from cy+45 (6px past
  the box bottom) to cy+33, and the update pass now matches the draw pass so
  the visible buttons are actually clickable.
- Selftest todo check now greps "title menu" to match the reorganized TODO.
- TODO: cutscene system design notes (camera normal/strict follow, item
  follow, zoom, fade, time multiplier, cutscenemode; impalecube excluded).

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
- console: raw-mode REPL rewrite (left/right arrows, always-present prompt,
  stdout marshaller so logs never split the line); fix the stale-buffer NUL
  invariant that gave the 2nd+ command a phantom byte ("expected ';'"), and
  commit typed lines so commands stay visible after Enter
- shields: held position follows cursor height (sin of shield angle), rest
  pose lowered, left/right swap uses the weapon turn spin
- music: warning() fades audio with the blackout; inventory/write muffle 70%;
  10s silence between loops (musicbrainwash skips it); toggle only mutes, never
  restarts; same-track playmusic continues; level changes fade old track out
  fully before the new one starts; playmusic tolerates .mp3 extensions; raylib
  native looping disabled so we own the restart
- new CAS builtins soundlevel()/sounddb() (audible-mix loudness -> dancing cubes)
- maps load at their real size (rows x chunks from file), no more hardcoded 4x30
- title screen: hop AI moved to levels/title_bg.cas; options/credits from the
  pause menu freeze the world (MenuOpenedFromTitle)
- dialogue(): bubble now binds to a cube permanently (shows within range, no
  skipping); docs + TODO updated
- P7MJ assets: hallway map + level script, title_bg map, chunk textures 05/06/07,
  blocks.txt, whiteboard stat, newsavefile

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
- Pose blending: every held pose (weapon or shield) is now computed in a
  unified space (art centre + centre rotation), and the displayed pose
  GLIDES between states whenever the pose source changes instead of
  snapping - the whiteboard glides from its normal item hold into the
  shield pose when combat toggles (and back), charge aborts/aim
  releases/tired droops ease to idle, and equipping slides the item into
  the grip. Fast attack curves, the shield orbit and the turn sweeps stay
  drawn 1:1 (the blend only fires on transitions) and hitboxes always
  sample the true target pose.
- Shatter: every way an item can break now bursts into shards of its own
  colour (shatterColor = average opaque pixel of the texture) - swing
  break, bayonet charge break, shield block break, thrown/dropped landing,
  and the inventory destroy animation.
- Save data layer: readsavevalue/setsavevalue (true/false keys) and
  readstatistic/setstatistic (numeric) CAS builtins over key = value files
  inside the active save; missing values default to false/0, subpaths like
  region/hallway.txt auto-create, and wrong types error. Docs, CALinter and
  the editor's casref updated.
- usually_held_like_a_shield stat: a shield item with false is held like a
  normal item outside combat and only takes the shield pose while fighting
  (whiteboard updated: hold_x 8, durability 40).
- Return-to-title now saves the game; the in-game Save button shows a 5 s
  grey "Saved!" cooldown instead of toast text; saves/ is auto-created so
  fresh clones can save.
- Selftest: 5 new pose-blend checks (normal/mid/shield/weapon/settle),
  shatter + save-value checks extended - 111 PASS / 0 FAIL windowed and F11.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
- Inventory preview cube now uses the same unified pose-blend layer as the
  world: equipped items glide between poses on open, equip swaps, and combat
  toggles. Weapon hides when combat mode is off (same rule as the world);
  ITEMS always render. Removed the on-screen combat ON/OFF indicator.
- Shield pose in the preview respects combatMode + usually_held_like_a_shield,
  mirroring in-game ShieldTargetPose.
- Removed the weapon->shield fallback that double-drew the shield on unequip.
- Blocking-left no longer spins the shield 360deg: art rotates by the cursor
  angle relative to the facing, and the facing turn sweep is suppressed while
  blocking (instant flip, like aiming a throw).
- Selftest: 118 PASS / 0 FAIL (windowed + F11).

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
- cursorface(index, angle): aim any cube via the 0=right CCW degree convention
  (no-op for the player - their facing is always mouse-driven); stores faceAngle
  and derives the left/right art flip from it
- bayonetcharge(index): start the bayonet charge on any cube (needs combat mode
  + an equipped fix_bayonets weapon); the charge machine is now entity-generic,
  fed by a per-entity chargeHeld flag, full ramp -> window -> tired cycle
- Fix: dialogue bubbles/hints never rendered on the title screen - DrawDialogue/
  DrawHint sat inside the GS_PLAYING gate, so title_bg.cas splashes bound but
  never drew; moved them with the world draws
- TODO: teams/flags/war faction system design (defineteam/addtoteam/defineflag/
  addteamtoflag/declarewar/iswarring, declared_war.txt, script-driven retaliation)
- docs/CAS-Reference.txt + levels/CALinter.py updated for the new builtins
- Selftest: 120 PASS / 0 FAIL windowed + F11 (cursorface, player-noop,
  bayonetcharge, stick-fail, charge-cycle checks)

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
- CAScript file I/O (project-root): readline(n, "file") returns line n
  (1-indexed; errors on missing file / out of range), countline("file")
  counts lines, write("text", "file") destructively creates/overwrites
  (folders auto-created, \n escapes work), append("text", "file") errors if
  the file does not exist. Same path-safety policy as the save helpers.
- Fix: libc rand() was never seeded, so random()/randint() (and swing
  angles, shatter bursts, splash droplets) replayed the same sequence every
  launch - the title splash was always the same. Seed srand(time^pid) in
  main(). title_bg.cas splash picker now uses 1-indexed randint(1, countline).
- Chat bubbles are now a 9-slice (chatter-leftend/center/rightend/lefthook/
  righthook/centerhook) - the center column stretches, so any text width
  fits with zero truncation and pixel-exact centering; the 32 fixed-size
  chatter-*x6 textures and their .pxo sources are removed.
- Title screen: a small "Levels" button (debug mode only) reopens the CAS
  level selector; ESC / Back there return to the title instead of quitting.
- docs/CAS-Reference.txt + CAScript.md + CALinter.py cover the new builtins;
  selftest 121 PASS / 0 FAIL windowed + F11 (fileio, no-truncate, line0=-4)

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
- dialogue.c: draw only the centerhook's tail row instead of the full texture, which double-layered the alpha into a dark stripe through the bubble's middle
- ui.c/h: new UiButtonScreen() for corner-anchored buttons in raw screen coords (UiButton's centre scaling pushed the title Levels button off-screen in F11)
- menu.c: title-screen debug Levels button now uses UiButtonScreen
- main.c: selftest regression checks for the Levels button (follows debugMode instantly, windowed + F11) and the center-hook bubble; renumbered menu-phase steps
- title_bg.cas/splashes.txt: splash text now rotates every 100 loops instead of a 1-in-51 dice roll, plus new splashes

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
- Rarity system (normal/gold): parsed from stat definitions, golden tint on gold items in inventory grid + cursor follow
- unequip(index) CAS builtin: strips both weapon and shield slots
- All items default to 10 damage; items/weapons without explicit damage tags now deal 10 instead of 0/1
- Shields can smack: when no weapon is equipped, pressing attack swings the shield (its texture, collision, durability pool)
- Quest book is no longer special: right-click opens the full context menu (Equip/Drop/Destroy/Open); Open is greyed out for non-interactive items
- ResolveShieldBlock guards against shield swinging (shield can't block while being used as a weapon)
- Docs + CALinter updated for unequip, rarity, and item-as-weapon behavior

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
- New src/stats.c/h: per-save stat engine. time.txt holds the in-game
  clock (30-day months, 12-month years) which only advances while
  simulating; stat_log.txt is an append-only audit trail of every
  engine event (one line per event, in-game timestamps).
- Two tiers: stats.txt (lifetime, accumulates forever) and
  timed_stats.txt (last 20h of in-game time, DERIVED from the log -
  rebuilt destructively on every cleanup so it can never drift).
- Cleanup pass on manual save / save load / every 4h in-game: prunes
  log lines older than 20h, re-sums survivors into timed_stats.txt,
  flushes lifetime counters + the clock.
- Engine auto-counters: times_swung, damage_dealt (post-shield: only
  what actually lands - swings/bumps/stomps/thrown weapons),
  damage_taken, cubes_interacted, unnecessary_violence.
- CAS: readstatistic("timed", name) reads the 20h tier (live RAM
  delta layered on disk); "stats.txt" reads lifetime live;
  setstatistic on the timed tier errors (it is derived, read-only);
  statsstatus(on/off) master switch for bonus levels.
- Selftest phase 12: lifetime merge, 20h prune, log pruning,
  clock persistence, statsstatus off, CAS round-trip + write guard
  (135 PASS / 0 FAIL windowed + F11).
- Docs (CAS-Reference, CAScript.md), CALinter, Makefiles updated.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
- New regionals[] table in interactable.c/h: a coordinate + 2-chunk
  circle, no texture/F-press/follow/collision. Fires the { code }
  block on player ENTRY, re-arms on exit; player-only; cleared with
  the level like interactables.
- Magic var `regional` = the trigger's own index inside the block;
  removeregionalinteractable(index) for one-shot scenes. New
  CasCallRegionalFunction() gives blocks the regional var instead of
  interactable/interactor.
- CAS block-arg parsing extended so regionalinteractable(x,y){code}
  works in any expression position like spawninteractable.
- Selftest phase 13: spawn-armed, walk-in fire + self-remove
  (one-shot), repeatable re-arm (138 PASS / 0 FAIL windowed + F11).
- Docs (CAS-Reference, CAScript.md), CALinter, todo updated.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Weapons and items are now ONE class. The weapon-*-definitions/ folders are
gone - stick, bamboo_pole, pot, whiteboard and quest_book all live in
item-stat-definitions/, item-texture-definitions/ and
item-collision-definitions/. The editor still writes to the old weapon-*
paths, so it is currently BROKEN - editor/README.md explains the new
folder names and stats (your editor's src/files.c needs updating).

Stat changes:
- item: true/false - the ONLY marker left. true renders the def on the
  character even outside combat mode (items); false is a plain weapon.
  Everything else is behaviour driven by its own stat.
- type: hard/brittle - REMOVED. Durability always drains (swings, throws,
  smacks); a def breaks with a shatter burst at 0. Fragility = low number
  (pot: durability 1 = smashable, breaks on first landed hit).
- put_in_inventory - REMOVED. Every def enters the grid; pickup always
  works. No more hold-only class.
- storage_capacity - NEW stat (pot: 1). Parsed + recorded now; the
  storage interaction itself stays FUTURE (inventory rework).
- shield routing / interact types / Open menu no longer check isItem -
  shield: true alone routes to the shield slot, interact_type works on
  any def.

Engine: single ScanDefDir over item-*-definitions; dropped items are
smashed by swings when durability <= SMASH_DURABILITY (1); whiteboard
(durability 100) and quest book (30) are breakable like everything else.
Selftest phase 21 rewritten for the new model. 138 PASS / 0 FAIL
(windowed + F11), CALinter green.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
Every named cube now has a def in cube-stat-definitions/<id>.txt with a
personality section (arbitrary key: int 0..1000 traits, missing = 500) and
optional multipliers (hp/size/mass/speed/jump, default 1 = player baseline).

CAS: spawncube("id",x,y) (warns but allows duplicate spawns), findentity("id")
(lowest live index, warns on multiples), getpersonality("id","trait") (works
even unspawned).

Multipliers are wired into the engine: hp scales max HP, size scales the
cube, mass scales knockback, speed/jump scale movement (physics + player +
CAS jump()). player.txt is the player (loaded at game start).

Per-save personality: on save creation the root cube-stat-definitions/ is
copied into saves/<save>/cube-stat-definitions/ and all reads use ONLY the
save's copy (guarded so an existing copy is never overwritten on load),
enabling the future "master mode" that randomizes traits per save.

New src/cube.c/h; selftest phase 14 (def load, save copy + isolation,
spawn color/hp/size, findentity, personality via CAS, player def). 145 PASS
windowed + F11. CAS-Reference, CAScript.md, CALinter, todo updated. Old test
saves deleted at P7MJ's request.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
Any item can act as a container via storage_capacity (slot count) and
storage_weight (contents' weight cap); containers nest up to 4 deep in a
shared nested-item pool and store to a tree-form inventory.txt with an
escaped-quote parser. Carried encumbrance now sums contents recursively
against a per-cube weight_capacity pool (grid_slots raises the grid up
to 6x5). The inventory UI draws opened containers as draggable,
window-manager-style mini-windows with minimize/restore/close, and
dropping or destroying a container spills its contents. Adds a backpack
item (10 slots / 10 weight) and gives the pot a storage_weight.

Also fixes a save/load hang: the inventory tokenizer looped forever on
the negative equip index (equipped: -1) by emitting an empty token
without advancing; it now emits proper tokens and always advances,
raising the selftest from 70 to 137 PASS.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Cube stat defs can now set `texture: <id>` referencing
cube-texture-definitions/<id>.txt (root-only, never cloned into a save),
whose `texture:` line names the PNG drawn over the cube body with
nearest-neighbour filtering. Precedence is texture > color > err_idiot
(a def with neither renders the idiot square per the game-wide
convention). refresh(["id"]) re-reads live cubes' defs and re-applies
skins so mid-save texture swaps show instantly; new spawns always read
the latest def. Also: renamed the typo'd cube-texture-defintions folder,
wired the user's 8x8 p7mj skin into p7mj.txt, and freed skins on
entity removal and player/def application.

New universal utility builtins (additive; the old save-value/statistic
functions stay working): readboolean/writeboolean, readnumber/writenumber,
readstring/writestring operate on any key:value data file, with "~/x"
resolving inside the active save and plain paths to root. Reads return
typed defaults for missing file/key and error on type mismatches; writes
preserve unrelated lines and separators.

Docs, CALinter (7 new builtins), TODO and selftest phase 16 (skin spawn,
~/ + root universal writes, refresh) updated. Also includes the user's
uncommitted splashes.txt/template.cas touch-ups and removes a stray
committed vim swap file.
hint() now enqueues instead of overwriting, so an interactable handler
can fire several hint() calls in a row and the player pages through
them like RPG dialogue. Each dismissal (Space/Enter/click/ESC) pops the
next page; the 75% black tint appears only when a series starts, so
multi-line conversations never flicker black between pages. mchint()
choice pages queue too and keep their buttons while waiting; queue cap
is 16 with oldest-drop. Selftest gains queue phases plus the phase-8
charge NPC is pinned during the ramp wait so the falling NPC no longer
eats the 0.5x hit before the 4x strike - now 151 PASS / 0 FAIL.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
One light level per tile, seeded from every source then flooded by
directional sweeps, so solid tiles cast real shadows; the buffer is
bilinearly upscaled each frame. New collision pixels 03-12 (dim/bright
light, fire, fuel, lichen, flicker) work for blocks and items, fire
damages on a t^2 contact curve and chain-ignites neighbouring fuel, and
the new torch item holds on the shield orbit to ignite what it touches.
Fog, fullscreen overlays and dynamic lights are exposed to CAScript, and
ambient 1.0 keeps the old look so existing maps are unchanged.

Also labels every selftest phase with a warning-styled banner and fixes
three build warnings (sound.c track buffers, cube.c save path).

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
Map, Collision, Texture and Script now share one undo stack (Ctrl+Z /
Ctrl+Y / Ctrl+Shift+Z, plus on-screen buttons); script typing coalesces
into single steps so undo moves a word at a time. Collision and Texture
edit blocks AND items through a source switcher, and custom palette
colours persist to editor/palette.txt as RRGGBB.

The linter gains world/asset awareness (real map size for coordinate
checks, missing map/music, literal argument kinds), the level template
is trimmed to an immediately usable 29 lines, and headless QA now also
asserts the script editor's undo round-trip.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
The update was judged poorly implemented, so the engine returns to the plain
air/solid/water collision model: lighting.c/h, the 03-12 collision values, the
08-14 blocks, maps/lighting_test.txt, the torch item and the CAS
ambient/fog/overlay/spawnlight builtins all go, and the editor's Collision
palette, README, CALinter and the docs follow. The selftest section banners
that shipped alongside the update are kept.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
The old prompt repainted with cursor-relative moves and a newline-inserted
hint row, so typing on the last terminal row scrolled the whole screen. The
Debug-Mode CAS console now owns a fixed region drawn with absolute cursor
addressing and never writes a newline, keeps its log in a 512-line ring buffer
shown in its own PgUp/PgDn window (so nothing relies on the terminal's
scrollback), reflows straight from TIOCGWINSZ on resize, is pure ASCII, and
shows a [+] ENABLED / [-] DISABLED indicator for whether it may be used. The
editor's CAS status chip becomes ASCII and the docs describe the new UI.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
The collision palette now labels 02 by source (partly solid on an item, water on
a block chunk) so the editor says what the engine really does, an undo that lands
back on the on-disk state counts as saved again, and the window refuses to close
over unsaved work instead of throwing it away. The Textures tab gained a tool per
mouse button (with a marquee that relocates pixels and copy/cut/paste), a fixed
5x5 grid of your own colours that you fill by clicking a square and typing its
hex - no "add colour" button - a pencil-opacity slider, and redrawn bucket /
eraser / eyedropper icons, with no L/R markers on the bar, the two bound tools
drawn as bare icons beside the pointer and the pixel readout in the canvas's
lower-left corner.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The Textures tab's five tools draw the artist's own 16x16 stencils
(editor/misc-texture-definitions) tinted to the theme: loaded through
RootPath so they resolve from either launch directory, filtered by source
size (point for pixel art, bilinear for a slight minify, mipmaps for HD
art) and drawn at their native size, with the drawn icons kept as the
fallback when a PNG is missing. So a finer icon set needs no code change.
The pointer overlay's two icons are smaller and sit lower, clear of the
pixel under the brush, and Ctrl no longer feeds the tool keys - Ctrl+3
(open the Textures tab) used to silently bind the bucket to the left
button.

The custom colour squares are now a 6x4 block that continues the built-ins'
grid - same six columns, same square size and pitch, no frame or caption
between them - so the palette reads as a single element; palette.txt still
loads older files in order (extra lines past the last square are ignored)
and is now written as 24 lines.

selftest.sh asserts the new palette line (fixed=24 cols=6 slots=24) and
that all five tool textures load (EDITOR_TOOLTEX); the README documents the
tool-texture folders, the tint/filter rules, the fallback and the unified
palette.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The Script tab's text area gains a vertical scrollbar: a recessed track
with a proportional thumb (a file that fits the window gets none), the
thumb tracking the first visible line. Dragging the thumb scrolls the
text and a click on the empty track pages one screen towards the click,
while a press inside the strip belongs to the bar rather than the caret -
so grabbing it never moves the caret or drops a pinned lint hint. The
text, caret and lint marks are clipped short of the strip, so nothing is
drawn under the thumb.

Scrolling the view away from the caret now sticks: the view used to follow
the caret on every frame, which snapped any wheel or scrollbar scroll
straight back onto it. It follows only when the caret itself moves, and
the range is clamped to the last full screen so the bar and the view
cannot disagree.

The cube hint box now hangs off the pointer's bottom-right (16px right,
one line down) instead of under the hovered line, where it showed up left
of the pointer at the start of a line and above it at the panel's bottom.

Both are covered by the QA pass: a 15th shot (editor_script_scrollbar.png)
plus the EDITOR_SCRIPTSCROLL probe (thumb inside the track, a drag
reaching the last screen with the thumb flush at the bottom, paging, and
the caret left alone), and the tightened cube-hint assertions on br/dx/dy.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
SelfTestStep was a 4,380-line phase machine - about 88% of src/main.c -
sharing ~30 probe globals with the game's entry-point translation unit,
so every new test grew main.c. It is dev scaffolding, not game logic.

The suite now lives in src/selftest.c behind selftest.h's three calls
(SelfTestInit / SelfTestActive / SelfTestStep): its globals, its section
banner helper, its screenshot probes and the phase machine all moved, and
main.c only asks whether the suite is running and steps it. src/main.c
drops from 4,971 to 485 lines. The banner tick moved into SelfTestStep so
there is no test-only per-frame code left in main; it still advances
first, before the suite's own gate, in every game state.

This is a pure move: main.c is the old file minus the region plus the six
interface edits, and the moved region is byte-identical apart from the
SelfTestStep prologue that now ticks the banner. Behaviour is unchanged -
make stays warning-free, and the full ./selftest.sh run gives the game
PASS=151 FAIL=0 with all 25 editor checks PASS. As a negative test,
making SelfTestActive() return false produced 14 SELFTEST FAIL lines, so
the suite really is driving the moved code through the new interface.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
SelfTestStep was still a single 4,380-line switch: one case per phase,
with the phase's section-banner title living in a second switch of its
own. Two parallel switches could drift apart - a phase could exist with
no banner, or a title with no body - and the control flow was impossible
to hold in your head.

Each phase is now its own function (TestSpawn ... TestCubeSkins) driven by
a table indexed straight off testPhase, which carries both the function
and the banner title so the two can never disagree. Phase 15 is the
terminal one: the banner, then nothing (fn == NULL). SelfTestStep is down
to ~40 lines: the banner tick, the change-of-section banner, the periodic
status line, the frame clock, then one table lookup and call.

This is a pure extraction: all 16 phase bodies are byte-identical to the
old case bodies (compared programmatically after dedenting), the case
comments travelled with their phase, and no phase number changed meaning.
make stays warning-free and the full ./selftest.sh run gives the game
PASS=151 FAIL=0 with all 25 editor checks PASS. As a negative test,
restricting the dispatch to the first two phases collapsed the run to 3
sections and 3 PASS lines and it never reached "Selftest complete" - so
the table really is what drives every phase.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Checkpoints the work in flight. The frame-time clamp is now a 10 fps stall
guard instead of 1/30 s: below 30 fps the old clamp slowed the whole
simulation clock (17.2 u/s of ground covered instead of the 30 u/s walk cap)
and read on screen as high friction while the HUD and self-test, both in sim
time, looked correct. The self-test's "first frame of this phase" gates are
frame-rate independent now, and WRLDBOX_MOVELOG / WRLDBOX_HOLD / WRLDBOX_THROTTLE
make a held-key report reproducible from a terminal - that is what pinned the
current stop to a solid pixel of the block the cube stands in (contact=RIGHT,
vx pinned at 0) rather than to the input path.

loadmap() also resolves a bare file name under maps/ now: naming the map file
on its own (loadmap("testing_3")) loaded nothing at all, which reads as "the
game can't open my map" even though the file was always there.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Both come out of the "invisible force stops my cube" report, which turned out
to be map data, not movement: a block whose collision file is missing or empty
collides with nothing at all, so a floor built from it is a hole the cube
falls through, and the cube then wedges on the solid pixels of whatever art it
lands in. LoadMap now says so out loud ("... collides with NOTHING") and
WRLDBOX_MOVELOG prints the collision grid around a stalled cube ('#' solid,
'~' water, '.' air, 'X' solid inside the cube's box) so the offending tile is
named instead of guessed.

todo.txt also picks up the requested feature: playmusic() with no arguments
plays a random track from music-file-definitions/.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Adding the worktree kept showing up as an untracked folder; it lives in the
project root so the old build finds the assets it expects while it is being
compared against the current one.

Context (NOT changed by this commit - the data is the owner's to restore):
block-collision-definitions/07.txt has been 0 bytes since 127001e2 ("Proto:
Added smart file naming in editor", 2026-10-14) dropped its 16 rows. 07 is the
ENTIRE front-layer floor row of maps/hallway_proto.txt, the map hallway.cas
(save "ss") loads, and in 961c907a (2026-08-17) it was a 768-byte grid with a
solid bottom row - so that floor went missing two days ago, which matches
"this did not happen in older versions". One command restores it:
  git show 961c907a:block-collision-definitions/07.txt > block-collision-definitions/07.txt

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
selftest.sh grepped the menu bar's real labels, so rewording a row or a tab
broke tests about menus: the check is about the menu's SHAPE (how many menus,
where the undo/redo rows sit, their order, which rows are live on which tab),
not about the words on them. Every one of those facts is now printed a second
time under stable role ids - the row index into menus[] plus a lower-case role:
EDITOR_QA_MENUBAR / _MENU_ORDER / _MENU_ENABLED / _MENUROW - and the suite
greps only those (7 assertions, PASS/FAIL lines unchanged). The Edit menu is
found by its ITEM LIST rather than its title, so an id cannot drift from the
real menu, and the ids live in one place (the "QA ids" block in main.c) so
adding an assertion is an entry there instead of a label to grep.

Verified by renaming a row ("Clear to air" -> "Reset grid") and the Map tab:
the prose EDITOR_MENUS / EDITOR_EDITMENU / EDITOR_MENUROWS lines change, every
EDITOR_QA_ line comes back byte-identical, and the assertions still pass. Full
./selftest.sh: all 25 editor checks pass; the 3 failures are the pre-existing
debug_mode=0 ones, byte-for-byte the same as before this change.

First piece of the refactor plan's "stop asserting on printed text"; the
label-bearing lines stay in the log for humans.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Same rule as the menu-bar commit, applied to the two other places the suite
asked a question by quoting a label:

- File > New rows: which dialog a row opened is now reported as a role
  (EDITOR_QA_MENUNEW: row=1 dialog=new_block), read from NewKind - the fact the
  check exists for is that row N opens ITS dialog, never the previous row's.
  Retitling a dialog is not a regression. The recommended value in the field is
  still asserted, with the title and label wildcarded out.
- The Docs tab's right-click: EDITOR_QA_DOCCTX: kind=doc rows=2 (from CtxKind)
  replaces items=[Rename doc...|Delete doc]. Two rows, and row 0 must open the
  rename dialog while row 1 opens the delete one - which the dialogs opened
  through StartContextAction(0)/(1) already prove, so nothing about the row
  wording needs asserting.
- View > Background: the title and label are wildcarded; the preset names, the
  field's current value and the swatch stay, because those are the data.

Kept on purpose, because there the words ARE the requirement: the top bar's
Build + Test label, the create dialogs' short labels, and the docs rename /
delete dialog titles. The README section now says which is which.

Verified by rewording a context-menu row, a dialog title and the map-name label
in a scratch build: every EDITOR_QA_* line comes back byte-identical and the
assertions pass, while the old label assertions fail. Full ./selftest.sh: all 25
editor checks pass, 3 failures unchanged from before (debug_mode=0).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The review is what the recent extractions were working through (self-tests out
of main.c, then the editor assertions off label prose), and steps 3-4 -
sharding editor/src/main.c, then re-checking file sizes - are still open. Keeping
it in the tree means the reasoning behind those commits travels with them instead
of living in one machine's untracked files, the same way suggestion.txt does.
It is advice, not a spec: nothing here changes behaviour, and it is not a request
to do a sweeping restructure - the file says so itself.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Splitting the engine self-test out of main.c moved SelfTestInit, SelfTestActive
and SelfTestStep into src/selftest.c and added it to Makefile, but Makefile.win
keeps its own source list and was not updated - so the Windows link failed on
three undefined references from main.c. Makefile.win's list is now the same 30
sources in the same order as Makefile's, which is the invariant that was missing
rather than a missing flag or shim: the ucrt64 toolchain never got the chance to
compile the file.

Verified without a mingw toolchain, by checking the thing that was wrong: the two
lists are identical (diff of the src/*.c sets), linking exactly Makefile.win's
list with the Linux toolchain succeeds, and dropping src/selftest.c from that
list reproduces the reported errors - SelfTestActive, SelfTestInit, SelfTestStep -
all three and nothing else. selftest.c itself adds no platform surface: it is
math/stdio/stdlib/string/time plus <process.h> on _WIN32, so no new shim is
needed.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
main.c was four subsystems in one file (menus, the modal dialogs, the QA pass,
this viewer) and at 3,436 lines it was the last place the editor was hard to
change - the review called it the grab-bag. The Docs tab goes first because it is
the cleanest of the four: sidebar geometry, the wrapped page and the probes that
check the page never overlaps itself are one subsystem, and nothing else needs to
know how the page wraps. main.c keeps the File > New Doc row and the rename /
delete dialogs, which call back in through editor.h.

The move is verbatim - same functions, same order, no edits inside them. The only
new code is four small reads the QA pass needs now that it cannot see the
viewer's statics (DocsFileCount / DocsFileNameAt / DocsLoadedName /
DocsRescanFiles); it drives the real create / rename / delete dialogs and then
checks the SIDEBAR's own list, so reading the viewer beats a second copy that
could disagree with what is on screen. The five forward declarations main.c used
to carry for docs are gone - editor.h declares them beside the other probes.

main.c 3,436 -> 3,023 lines; docs.c is 448.

Verified as a pure move, not just as "tests pass": the editor's whole QA log is
BYTE-IDENTICAL before and after (226 lines, 105 EDITOR_* lines, diffing only the
temp paths), all 25 editor checks pass, and the full ./selftest.sh still reports
PASS=38 FAIL=3 with the same three debug_mode=0 failures as before. Builds clean
under -Wall.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Second extraction from the editor's grab-bag. The create dialogs (File > New *),
the right-click rename / delete pair, View > Background and the live
recommendation pass that fills the create fields in share one modal, one "what
will OK do" answer (newKind / actKind / bgDialog) and one place that decides what
OK means - so they are one subsystem, and 790 lines of main.c were really this.
The OK half of the create dialogs (HandleNewResult) came along too: it sat below
the quit helpers, which is exactly the kind of spread that made main.c hard to
change.

The tabs now only report events (RequestContextMenu / RequestNewForMode /
RequestBackground); editor.h carries the dialog state the loop still has to read
(modal.open, actKind, bgDialog, newKind) and the two role-id readers the QA pass
uses (CtxQaId / NewKindQaId - the tables moved with the kinds they name, and are
bounds-checked now instead of indexed through a magic QA_ID_AT macro). main.c's
"draw the modal, then decide what its answer means" block is one call to
DialogsUpdate() and its popup block is one to DialogsContextMenu().

Two seams replaced a reach-through rather than widening it: the CAS console's
input field stays in main.c, and RequestNew calls CasBlurInput() instead of
zeroing that field from the outside. The moved code is otherwise verbatim.

main.c 3,023 -> 2,084 lines; dialogs.c is 986.

Verified: the editor's QA log is BYTE-IDENTICAL to the pre-move run again (226
lines, diffing only temp paths), 25/25 editor checks pass, and the full
./selftest.sh reports 25/25 editor with the engine's usual debug_mode=0 sound
failure. Builds clean under -Wall.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Third extraction, and the smallest: "never close the editor over unsaved work"
was a subsystem with its own state (quitPrompt, the button answer, the failed-save
flag) spread over three places in main.c - the helpers above the menu dispatch,
the prompt drawn far below the console, and the close request handled inside the
loop. One file now: RequestQuit (File > Quit), RequestWindowClose (the X /
Alt+F4, which is where the latched GLFW request gets cleared), UpdateQuitPrompt
for the frame, and AnyUnsaved / UnsavedList / SaveAllDocs behind them.

The loop keeps ONE thing - its own flag, g_quit - and every module asks for it
through QuitEditor(), so main.c is still the only place that decides the editor
is done. The prompt's own flag is read through QuitPromptActive() rather than
reached for, and the tab-name array stays private to main.c: quit.c names the
unsaved tabs through ModeName() instead of an extern array (which also keeps the
compiler from having to assume a null could reach a %s).

main.c 2,084 -> 1,963 lines; quit.c is 180.

Verified: the editor's QA log is BYTE-IDENTICAL again (226 lines, 105 EDITOR_
lines, diffing only temp paths), and 25/25 editor checks pass - including the
close-guard check this moved. Builds clean under -Wall. Nothing outside editor/
changed, so the engine half of the suite is untouched by this commit.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Fourth extraction. The five menus, the File / Edit / View row callbacks and
HandleMenu - the one place a picked row turns into an action - were spread over
main.c with the top bar's label and the QA tables in between. The undo / save
glue the Edit rows call (SaveCurrentMode, EditUndoCan / EditUndoStep /
EditSaveCan) goes with them: those rows and the Ctrl+Z / Ctrl+S keys are its only
callers, and "Edit > Undo is grey right now" is that code plus the row callback.

menus[] is now private: the loop draws the strip through MenuBar() / MenuCount(),
and MenuCount() measures the array instead of the hand-written MENU_COUNT that
had to be kept in step with it. The QA pass finds the Edit menu by ITEM LIST
(MenuEditItems()) rather than by title, which is the same rule the earlier commit
established - renaming a menu cannot move a check. The menu-shape probes
(MenuRowEnabled / MenuIndexOfItems) stay in main.c with the QA role tables for
now: they are what the suite asks, so they belong with the rest of the QA pass.

main.c 1,949 -> 1,752 lines; menus.c is 232.

Verified: the editor's QA log is BYTE-IDENTICAL again (226 lines, 105 EDITOR_
lines), and 25/25 editor checks pass. Builds clean under -Wall. Only editor/ files
changed.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The last and biggest chunk of the grab-bag: ~1,000 lines of WRLDBOX_EDITOR_SHOT
scaffolding - the phase state, ShotSave, the menu-bar QA probes with their role
tables, the read-only menu sweep and every screenshot pass - was welded into the
file that runs the editor, so each new probe grew it. This is the same disease
the engine's main.c had before src/selftest.c, in the same place: test code in
the shipped entry point. main.c now asks qa.c two questions, QaInit() at startup
and QaTick() once per frame, and knows nothing else about it.

What the moved passes need from the loop came in through ordinary interfaces
rather than new reach-throughs: the top bar's label is read with
BuildTestLabel() (the wording IS the requirement the probe checks), the tab name
with ModeName(), and "was a quit request refused?" with QuitRequested(). The
passes still drive the real code paths - HandleMenu for a menu row,
RequestContextMenu + StartContextAction for a right-click, the same update pass
for a dialog - so a check cannot pass against a stub of itself.

main.c 1,752 -> 736 lines. Commanded as one extraction per commit, the editor's
main.c went 3,436 -> 736 across five of them (docs.c 448, dialogs.c 999, quit.c
180, menus.c 236, qa.c 830), and the plan's step 4 is answered: no further
splitting is needed, every file is now a named subsystem.

Comment fixes that the move made stale: selftest.sh and editor/README.md both
pointed at the "QA ids" block in main.c - they point at qa.c / dialogs.c now,
per kind.

Verified: the editor's QA log is BYTE-IDENTICAL again (226 lines, 105 EDITOR_
lines), 25/25 editor checks pass, the full ./selftest.sh agrees, bash -n
selftest.sh is clean, and the build has no warnings under -Wall.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The editor had no Windows build at all: its Makefile is the Linux one (X11, dl,
the Linux static raylib) and four of its files were POSIX-only, so `make -f
Makefile.win` in UCRT64 only ever produced the game. editor/Makefile.win now
builds editor.exe the way the game's does - the pacman raylib, -I../win for the
dirent shim, -include ../win_compat.h - with the platform differences behind
#ifdef _WIN32 rather than in a second copy of the source list.

session.c is the real work: there is no fork(), so the live game session (F2
CAS console, Run, Build + Test) spawns wrldbox.exe with CreateProcessA and two
anonymous pipes, drains them through PeekNamedPipe, and stops the child through
its process handle. The console plumbing - the line buffer, the exit notice - is
shared with the fork() path, so both platforms behave the same.

The rest is small: _fullpath() for realpath(), _popen()/_pclose() with no
WIFEXITED (the CRT returns the exit code itself), `python` instead of `python3`,
the lint scratch file in %TEMP% instead of /tmp, and rename() instead of
shelling out to `mv` (system() gets cmd.exe on Windows). The make line that four
entry points spelled out themselves is one BuildMakeCmd(), which asks for
Makefile.win on Windows - the root Makefile is the Linux build, so plain `make`
there fails on the first link flag.

Verified on Linux, the only platform this box has a compiler for: the editor's
QA log is byte-identical to HEAD (226 lines, 105 EDITOR_ lines), 25/25 editor
checks pass, ./selftest.sh agrees (engine 40/1, `sound` - unchanged and partial
as before), and the build has no warnings under -Wall. The Windows branches were
type-checked against a throwaway stub windows.h (all 14 editor TUs clean) and
BuildMakeCmd() was executed for both branches. The Windows build itself has not
been compiled - that is what the first UCRT64 run will say.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Debug Mode's stdin REPL is not a POSIX-only feature: console.c's line-based
path is explicitly the Windows one ("pipe/file path (also Windows)"), and
win/fcntl.h exists only to make that path non-blocking, since Windows has no
O_NONBLOCK on console input. What IS POSIX-only is the raw-mode terminal UI
(arrows, history, Tab completion, the ANSI screen region) - on Windows the
console is the plain line-based one, which is a deliberate split.

That leaves the whole Windows console hanging on one function: the "is a
complete line waiting?" test in win/fcntl.h. It was guessing. It accepted
exactly one spelling of Enter - a KEY_EVENT whose AsciiChar is '\r' - so a
console that reports Enter as '\n' (ENABLE_PROCESSED_INPUT translation) would
never see a single line, which looks exactly like "there is no CAS console on
Windows" rather than like a bug. Two more holes: only the first 256 records of
the queue were scanned, so a paste whose Enter sat beyond that wedged input for
good (nothing is ever consumed, so the queue cannot drain on its own), and the
pipe path had the same shape with a 4096-byte window over its pending bytes.

Now: Enter counts as '\r', '\n' or VK_RETURN (0x0D spelled out - the VK_ names
live in winuser.h, which NOUSER deliberately excludes), the whole queue is
scanned (sized from GetNumberOfConsoleInputEvents, falling back to one chunk if
that malloc fails), the pending pipe run is scanned whole, and a redirected
file is still always "ready". The unclassifiable-handle branch keeps the old
blocking read instead of a "nothing yet", because silently swallowing input is
worse than a hitch. WRLDBOX_STDIN_TRACE=1 now prints which kind of handle was
found and whether a line was ready, so the next report from a Windows machine
names the branch instead of needing another guess.

Verified: console.c type-checks clean under -D_WIN32 against a stub windows.h
with the real win/fcntl.h in the include path, and its preprocessed output
contains the shim's pending function and its call site - the override is
demonstrably the code that runs. Linux is untouched by construction (win/ is
not on the Linux include path; the game's build line has no -Iwin) and the game
still builds warning-free.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The editor's first Windows link failed on exactly one symbol:

    quit.c:(.text+0x5ff): undefined reference to `glfwSetWindowShouldClose'

That call is the close guard's: raylib latches its should-close flag and offers
no API to clear it (raylib 6.0's header has WindowShouldClose() and nothing
else), so quitting with unsaved documents has to clear the flag through GLFW
directly. The Linux build gets away with it because the repo's
lib/libraylib.a has GLFW compiled inside it - `nm` shows a defined
T glfwSetWindowShouldClose in that archive - while the UCRT64 raylib package
resolves GLFW through a separate shared glfw3.dll (raylib's package depends on
mingw-w64-ucrt-x86_64-glfw, which ships libglfw3.dll.a and glfw3.dll). Nothing
in raylib re-exports that symbol, so the editor has to name the library.

editor/Makefile.win now links `-lraylib -lglfw3 ...` (glfw3 must follow
raylib), and the header comment plus WIN_COMPILE.txt say why, plus the trap
that attempt would otherwise fall into: `-Wl,-Bstatic -lraylib -lglfw3` FAILS
with a screenful of `undefined reference to __imp_glfw...`, because the static
libraylib.a is the build that references those import stubs while the static
libglfw3.a defines only the plain names. Keep glfw dynamic, or build raylib
with its bundled GLFW.

The game's Makefile.win is deliberately NOT changed: it never calls GLFW, and
raylib's own dependency is satisfied inside libraylib.dll, so its link line
resolves - confirmed by the failing editor link, which reported the editor's
own object as the only unresolved reference and no __imp_glfw* from raylib.

Verified: `make -f editor/Makefile.win -n` now emits the link line with
-lraylib -lglfw3 in the right order, `make -f Makefile.win` is byte-identical
to HEAD again, and the Linux editor build is unaffected (it links ../lib, which
carries GLFW, and needs no -lglfw3). The Windows link itself can only be
confirmed on the UCRT64 machine.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The Map tab derived *UNSAVED* from "the canvas differs from the last saved
bytes" without ever setting that baseline when no map was open, so a launch
with an empty/unfindable maps/ (or a map directory the editor was started
away from) came up dirty with nothing to save - the header said *UNSAVED*
and the close guard refused to close the window over an edit nobody made.
MapInit now marks the empty canvas saved, says why in the build console, and
names the map it could not read. Which root was found is its own answer now
(RootFound), warned about at startup, and main.c logs one EDITOR_STARTUP line
after the first update pass that ./selftest.sh asserts on.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
A map whose file has rows in only one of Back:/Front: is a map the engine
plays - LoadMap sizes the world from the layer that has rows - but the
editor's parser demanded rows in BOTH sections and called such a file
unreadable. It was then left open, unsaved on purpose so Save could not
overwrite it, which meant the tab reported *UNSAVED* for good: "Not saved
yet" on every close attempt over an edit nobody made, with the one action
that must never touch that file sitting next to it.

MapLoad now matches the engine (one empty layer is legal; only a file with
no rows anywhere is not a map) and parses into a scratch document, so a
failed load no longer zeroes the map that is already open. A file that
really cannot be read is not opened at all: the name is dropped, the canvas
is empty and marked saved, Save does nothing without a target (it used to
write maps/.txt), and the header, the build console and stdout all say why.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
The close warning could trap the editor. A window close request is not a
steady signal here: GLFW raises its own flag, raylib's PollInputEvents()
copies it into raylib's flag and clears GLFW's, so WindowShouldClose() is a
single-frame pulse (and there is no close callback to hook - raylib registers
none, and GLFW's is not called for a window-manager close in this build).
Reading that copy again on later frames - which is what happens wherever it
does not fall back to 0 - re-opened the warning on top of its own dismissal,
and since the warning blocks every tab's input, that is a dialog you cannot
get past: the report was a "Not saved yet" panel that no number of clicks on
"Keep editing" would dismiss.

The request is now read from both flags and answered ONCE: answering clears
the flag this side can clear, so the request cannot come back on its own, a
second X / Alt+F4 is visible as that flag going up again, and a request made
while a dialog owns the screen stays pending until it is out of the way. The
refusal and the launch-time dirty state also go to the build console panel
(F2), which is the only place a Windows run - with no terminal for the
editor's stdout - can see why the window stayed open and which tab thinks it
has unsaved edits.

The QA pass now drives this path through the loop (a request, "Keep editing",
a second request) and ./selftest.sh asserts each step, including that the
answered request does NOT re-open the warning.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
Reverts 4766d5c9..e1321a57. Chasing the Windows port made the editor worse than
the state it started from: a fresh launch reports unsaved work on Linux too, and
the Windows build dies with SIGSEGV while loading the first block texture. The
reverted commits stay in history (and today's in-progress investigation is
parked on rollback-editor-windows-work) so the work can be picked up again
without re-deriving it.
The tree is now byte-for-byte 04661413 - the last commit from before 8am this
morning, the state the editor and the game were last known good in. Nothing is
rewritten: every rolled-back commit stays in history, and revert.txt lists each
one, what it did and how to bring it back.

Rolled back here (04661413..HEAD): the five-way main.c split into docs.c,
dialogs.c, quit.c, menus.c and qa.c, the QA role-id assertions, the
codebase-health review doc, the selftest.c line in Makefile.win and the
temporary-worktree ignore rule. Already undone by 040f6f22: the editor's
Windows port and the three unsaved-warning fixes.

The engine is untouched: the xrdp frame-rate clamp fix (72c04966) and this
baseline's own map-collision warnings (04661413) are still in place.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Docs: record what the two rollbacks took out of cube_game, and how to restore it

revert.txt lists every commit rolled back today - the five-way main.c split into
docs.c / dialogs.c / quit.c / menus.c / qa.c, the QA role-id assertions, the
codebase-health review, the Makefile.win line, the temp-worktree ignore rule,
and the earlier Windows port plus the three unsaved-warning fixes - each with
what it did, plus the problems the baseline brings back, the restore commands
and the branches kept as restore points.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
rollback-485a7242/ moves to archive/rollback-485a7242 (git worktree move - the
branch is untouched and the checkout is still clean) and the pre-8 wrldbox_old
build moves to archive/wrldbox_old. Both were cluttering the project root, and
the checkout made `git add -A` offer to add it as an embedded git repository, so
both new paths are ignored instead.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The old rollback-* / pre-revert-* branches were parked as archive/* tags and the
names dropped, and the old checkout plus the pre-8 build now live under archive/,
so the restore section and the notes had to stop naming branches and a project
root folder that are no longer there.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The rollback to 04661413 dropped 3e8cce07, so Makefile.win listed 29 sources
while Makefile listed 30 and the ucrt64 link failed on exactly three undefined
references from main.c - SelfTestInit, SelfTestActive, SelfTestStep - all of them
defined in src/selftest.c, which the Windows build was no longer compiling.

Re-applied as the same one-line change. Verified without a mingw toolchain, the
same way the original fix was: the two SRC lists are now identical (30 files,
same order), linking the pre-fix list with the Linux toolchain reproduces the
reported three references and nothing else, and linking the fixed list succeeds
with no warnings. selftest.c itself needs no new shim - it takes <process.h> on
_WIN32 and <unistd.h> otherwise, and calls nothing else POSIX-only.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
todo.txt #15, requested today: playmusic() with no argument now switches to a
random track from music-file-definitions/ instead of erroring on the argument
count. Named calls are untouched - the same cue still continues rather than
restarting, a different one still fades the old track out first, and a level
that wants a particular track keeps naming it.

The pick is SoundPickRandomIndex (src/sound.c): a uniform index over the folder
with the track already playing stepped over, so a bare call is always an audible
change. It is pure - no audio device, no file system - which is what lets the
self-test drive it on a machine that runs the game silently; PlayRandomSoundTrack
is the thin audio-side wrapper. Both questions the request left open are decided
in the code comment and in todo.txt: a track that played earlier in the session
MAY come up again (nothing is remembered across calls - only the track playing
right now is skipped), and the title theme is NOT special-cased.

Also documents the no-argument form in docs/CAS-Reference.txt, docs/CAScript.md
and the editor's CAS reference, and adds a selftest check (music-random-pick)
that samples the pick 2000x and asserts it stays in range, never lands on the
playing track, still reaches the last track, and returns "nothing to switch to"
for an empty folder or a folder whose only track is the playing one.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
72c04966 renamed music-file-definitions/test.mp3 to p7mj-test.mp3 and left the
references behind, so playmusic("test") resolved to nothing:

  * levels/hallway.cas played NO music - loadmap fades the track out and the
    level then asked for a file that no longer exists;
  * levels/template.cas and the editor's new-file template handed every new
    script a music line that silently failed;
  * the sound self-test scanned for a track named "test" and failed on the
    name, not on audio (the log always said device=1 playing=1).

All four now name p7mj-test, and the example strings in the CAS reference, the
CAScript doc, the sound header/comments and todo.txt follow the real files.
The splashes.txt line about test.mp3 is left as it is - it is a joke message,
not a track reference. Verified: engine and editor both rebuild with no
warnings, and ./selftest.sh now reports PASS=42 FAIL=0 (sound included).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The engine only ever draws text through DrawText()/MeasureText(), so
src/font.c redirects those two to a font it builds at startup by blitting
one PNG per glyph into a single atlas - raylib's Font holds one texture,
which rules out loading 95 textures and drawing them one at a time, not
storing the art that way. With no art in the folder the shims forward
straight to raylib's own functions, so nothing moves until glyphs exist.

font-definitions/README.txt records the measurements the art has to match
(built-in cell 10 px tall, proportional widths 1-7 px, ink rows 1..7 with
the baseline on row 7, spacing fontSize/10) and the recommended 6x10 cell.

Verified against the real binary: MeasureText agrees with raylib on
225/225 string+size pairs (no layout change), a 95-glyph set draws every
character's own pixels with wrapping atlases, and a partial set renders
missing characters blank instead of borrowing a neighbour's glyph.
A 6x10 glyph was laid out 7 px apart: the cell width (which already
includes the trailing empty column the artist leaves) plus raylib's
1 px spacing. Text came out a quarter wider than the spec claimed.
Default the extra spacing to 0 and correct the spec's width and ink
row numbers, which the artist is drawing against.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The row guide claimed row 0 was always blank and listed the punctuation
as full descenders; rendering every glyph shows ! ( ) [ ] { } | start
at row 0, only g j p q y (and f, unusually) reach row 9, and , ; stop
one row below the baseline. Artists draw from this table.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Saves (src/savefile.c/h, src/stats.c, src/main.c):
- every save write stages to saves/.tmp/ and swaps in with rename, so a full
  volume or a mid-write failure leaves the previous save intact
- gamestate.txt.bak / inventory.txt.bak hold the replaced generation and
  SaveLoad falls back to them, so a failed save costs one session, not the file
- stat_log.txt closes its stream before the rename (it used to rename over an
  open stream, which only worked on POSIX)

CAScript (src/cascript.c, docs):
- a numeric slot takes "12" but errors on "zone" instead of reading 0
- a declaration whose value is a { block } still closes with its own ;

Items (src/combat.c/h, docs, editor/src/casref.h):
- a def resolves by display name ("bamboo pole") or file stem ("bamboo_pole");
  duplication is judged on the display name alone

Editor (editor/src/main.c, mapedit.c, editor.h, README, editor-summary.txt):
- View > Precise cursor: engine debug crosshair + readout on the Map canvas

Tests (src/selftest.c, selftest.sh): blockscope, strictnums, itemname and atomic
probes, plus the Precise cursor menu/readout check

Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
- item-stat-definitions/cardboard_box.txt: a 1-durability swing weapon
  (10 damage, weight 1, 0.5 s cooldown) that cannot fix bayonets
- item-collision-definitions/cardboard_box.txt: empty grid, so the box
  occupies no collision cells
- item-texture-definitions/cardboard_box.png and the key_b / key_~ icons,
  alongside the existing item and key art
- docs/The Programmer's Handbook to Cube A.odt: the handbook source

Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Item physics now resists tiny movement (contact-only wake, rest deadzone,
clear spawn spread, front-of-cube container spills) so piles stack and sleep
instead of jittering; a dropped whiteboard keeps its writing. Shield-weapons
seed and hand back the shared pose blend so the swing no longer snaps, and
CAScript's screen()/screen_dynimage() show a modal three-layer picture that
stops time. Self-tests cover all of it (205 pass).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Pulling a bubble back inside the viewport detached it from its speaker: the
gap grew, a side bubble could land on top of the cube, and the hook pointed at
nothing while still claiming to. Bubbles are now drawn exactly at the speaker's
anchor and the window clips whatever runs off, matching how the rest of the
world is drawn. Also renames a self-test local called `near`, which <windows.h>
defines as an empty macro and broke the ucrt64 build.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Buoyancy used to be velocity-based off the bottom pixel, so bodies sank or hovered and the resting solver kept buzzing on its sleep threshold; measuring from the collision shape's rectangular centre against the water column's top edge makes every float rule exact and adds a rest lock for settled items.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Keep water drag active during the entry delay, resume buoyancy and Spacebar thrust afterward, and re-arm the delay when the cube leaves water. Dropped-item buoyancy remains immediate.

Add entry lockout, resumption, and re-entry regression coverage; adjust dive timing and movement bounds for the delayed buoyancy. Normal suite: 235 PASS, 0 FAIL. Sanitized game: 235 PASS, 0 FAIL, no runtime reports; an editor hover check failed once and passed its isolated retry.
Add a session View toggle for automatic lint diagnostics, preserving manual checks in the console. Highlight and complete callback variables in their lexical scopes; audit all 86 builtins and 27 colors. Warn about possible hint-text truncation and textinput's hidden second line.

Allow one swing per airborne period, reduce horizontal movement to 10% during attack animations, and scale ground jumps to 10% normal height. Cancel cursor-directed throws released inside the throwing cube without spending items or durability.

Normal and UBSan game runs: 239 PASS, 0 FAIL. Editor toggle, contextual highlighting/completion, builtin/color synchronization, and hint-warning regressions pass; final runner exits 0.
Neither wrldbox.exe nor editor.exe imports libgcc_s_seh-1.dll or
libwinpthread-1.dll: the import tables list only libraylib.dll, which needs
glfw3.dll, plus Windows system DLLs. Delay-import directories are empty and no
LoadLibrary use or literal DLL names exist in any binary, so the copies in the
tree, in editor/, and in RUNTIME_DLLS were dead weight. Dropping them removes
the GCC runtime redistribution obligation from the future licence bundle.

Also adds todo-now.txt with the immediate licensing and packaging actions.
Windows Sandbox confirmation is still pending.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The music tracks are only licensed for release builds, so the tips file and a
placeholder README explain their absence, and the todo list now orders war,
then CABMD, then CAVF.
Sprint lived in a global written only by the player's keys, so scripted cubes
that charge were silently capped at walking speed and a sprint leaked across
world loads. The gait now lives in a per-entity intent record and the cap
branches no longer ask whether the cube is the player.
walk() wrote velocity directly and jump() skipped every gate the jump key
applies, so NPCs bypassed acceleration, weight, friction and the swim/charge
rules. walkTimer/walkDir are retired: scripts now fill the per-entity intent
that physics consumes, one EntityJump() gates every jump, and the water stroke
gate no longer asks whether the cube is the player.
player.c both read input and applied forces, so the player kept a movement path
scripts could not share and the KO/charge rules existed in two places. The
writer now only fills the record; ApplyIntent in physics is the single consumer
for every cube and carries the one KO rule and the charge commitment.
This pull request has changes conflicting with the target branch.
  • .gitignore
  • Makefile
  • OLD/ray.c
  • OLD/text_physics.c
  • README.md
  • archive/ray.c
  • archive/text_physics.c
  • ray.c
  • src/config.h
  • src/entity.h
  • src/main.c
  • src/physics.c
  • src/physics.h
  • src/player.c
  • src/player.h
  • src/render.c
  • src/render.h
  • src/world.c
  • src/world.h
  • test.c
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin cube_game:cube_game
git switch cube_game

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff cube_game
git switch cube_game
git rebase main
git switch main
git merge --ff-only cube_game
git switch cube_game
git rebase main
git switch main
git merge --no-ff cube_game
git switch main
git merge --squash cube_game
git switch main
git merge --ff-only cube_game
git switch main
git merge cube_game
git push origin main
Sign in to join this conversation.
No description provided.