Game-state feed #2
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#3 Discord Rich Presence
mintopia/blur
#4 Race state websocket
mintopia/blur
#5 Live race telemetry in the game-state feed
mintopia/blur
Reference
mintopia/blur#2
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
Prefactor for Discord Rich Presence and the race state websocket. The host keeps a single store of the current game state, fed from Lua patches through a new
Host.state(key, value)function (ADR 0008), with native reads only where the scripts can't reach the data. Initial keys: current screen, game mode, event/track name, and online lobby status (none/hosting/joined, player count). Consumers subscribe to changes.BLUR_STATE_LOG=1logs every change so the feed can be checked by itself.Acceptance criteria
BLUR_STATE_LOG=1, moving between menus logs the screen changesBLUR_ENGINE=recompBlocked by
None (can start immediately)
Implemented game-state feed (ADR 0008): src/host/game_state.{h,cpp} store + subscribe(), Host.state(key,value) Lua import, BLUR_STATE_LOG=1 logging, patches/Screens/Commands.post.lua wrapping screen/mode/event/track/lobby/players setters. Unit test game_state passes. Verified on recomp (career_race + mp_menus plans): screen changes, mode, event+track logged. NOT verified: live lobby host/join player counts (no plan drives a server session; wrappers on NetRace Create*/Join*/EnterLobby/Multiplayer.GetLobbySlots are untested). No consumers/log active = one hash-map compare per Lua call, no timing measured. mdrive.py gained DEVPATCH/NETON env overrides.
Follow-up. Fixed lobby hooks after testing on recomp against a local blur-online server (NETON=1, BLUR_ONLINE_URL=ws://127.0.0.1:18080/socket): hosting a LAN game logs lobby=hosting, track, players=1. Found Multiplayer.RefreshLobby never fires in the lobby and GetLobbySlots only returns data when the lobby screen rebuilds its roster, so players now comes from wrapping GetLobbySlots (updates when the game refreshes the roster). Removed the ticket ref from the Lua header comment. All 17 ctest tests pass. Frame cost: no per-frame hooks remain; wrappers run only on screen/mode/lobby/race calls; no-op set() = one mutex+map compare. Not timed with fps measurement. NOT verified: a second client joining/leaving (two-instance LAN test could not discover the host on loopback), so joined role and player-count updates on join/leave are untested.
Attempt 6 update (commits
d1f36eb,5dc9d4d,a48582fon harmonic/task-9).Fixed
wraprenamedhook_after, header comments trimmed). That re-run returned FAIL (3) and was not repeated after the fixes.TSTRINGconstant added.NetRace.JoinLanServerreturns 3 values (start, customrace, event_id), so a joining client lost its race setup. DTLS was established, the client then sent nothing, and the host logged "DTLS receive timeout" and the game showed "Unable to connect to session".hook_afternow passes every return value through and runs the hook underpcall, so a feed error can't break a game call. Checked with a Lua harness (3 returns including a nil, hook that throws). In-game runs with the fix still log screen changes.BLUR_NETTRACEbind lines now include the errno reason.Verified on recomp
lobby=hosting, track,players=1(several runs, two instances on one Mac with BLUR_PORTMAP/BLUR_ADAPTER_IP).career_racewith vsync off, presents/s median over the 35 s throttle segment, 2 runs each): on 130 / 97, off 85 / 87. The spread is run-to-run noise and the feed-on runs were not slower, so there is no measurable cost.Not verified: a client joining or leaving (
lobby=joined, players 1→2→1). Every join attempt before the fix failed for the reason above. Runs with the fix couldn't finish because the Mac's screen locked during the session (CGSSessionScreenIsLocked=true): the game hangs at boot or drops key presses. Needs one two-instance run on an unlocked machine. Driver plans: /tmp/t9/host.py, /tmp/t9/client.py, /tmp/t9/lan1.sh.Attempt 7: last acceptance criterion verified (commit on harmonic/task-9: header comment fix).
Join/leave verified on recomp: two-instance LAN run (screen unlocked this time, /tmp/t9/lan1.sh) with the
hook_afterfix.lobby=hosting,track=UK_London_Hackney_4,players=1→2(client joins) →1(client leaves) →2(rejoin), then race start logsevent=Multiplayer_Racingand the Ingame screens.lobby=joined,players=2; on leavelobby=none,players=0,track=; rejoinlobby=joined,players=2; race loads and runs; when the session ends,lobby=none/players=0/event=/track=.Other
host_netfailed twice when run right after the game instances exited (looks like port reuse). It passed on rerun.All acceptance criteria are now met.
Attempt 8: fixed the comment violation the verifier flagged (commit on harmonic/task-9).
patches/Screens/Commands.post.lua:GameStateFeedtoGameStateHooksInstalled, so the name says what the guard is for.src/host/lua_patch.cpp: theHost.statedoc said only nil clears a value. Any type that isn't a string, number or bool clears it, and the doc now says that.Checks:
luac -ppasses on the patch.BLUR_STATE_LOG=1: hooks still install and log screen, mode, lobby and players.72217f3..HEAD: PASS.Completed and merged by Harmonic (task 9).