When exiting a race, LegoRace::Create stashes the UserActor and sets
it to NULL. The destructor restores it, but runs later than
OnWorldEnabled, so NotifyPlayerCountChanged sees a NULL UserActor and
doesn't count the local player. Fall back to GameState::GetActorId()
which is restored earlier (in LegoRace::Enable(FALSE)).
* Add free camera orbit controls to multiplayer third-person camera
Replace the fixed camera offset with dynamic orbit parameters (yaw,
pitch, distance) computed from spherical coordinates. Mouse wheel
controls zoom, right-click drag controls orbit, and two-finger
touch gestures support pinch-zoom and orbit on touchscreens.
The controls are always active when third-person mode is enabled.
A single SDL event forwarding hook is added to the main event loop;
all other changes are contained within the multiplayer extension.
https://claude.ai/code/session_013FyPCrJSaHxiJwdfGBVnYP
* Fix linker error and refactor orbit camera controls
Move HandleSDLEvent extension call from ISLE (no EXTENSIONS define) into
LegoInputManager::UpdateLastInputMethod in LEGO1 to fix unresolved
symbol errors. DRY up orbit camera code with ClampPitch/ClampDistance/
ResetOrbitState/ApplyOrbitCamera helpers. Simplify direction vector
computation. Fix mouse orbit yaw direction.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fixes
---------
Co-authored-by: Claude <noreply@anthropic.com>
* Sync sky color and light position in multiplayer
Add ENTITY_SKY and ENTITY_LIGHT to the WorldEvent system so the host
controls sky color (hue/saturation via observatory sun/moon/palette
buttons) and light position (globe arrows) with the same
host-authoritative pattern used for plants and buildings. Non-host
players send requests to the host who applies and broadcasts. Sky/light
state is appended to the world snapshot so joining players get the
current values.
https://claude.ai/code/session_01X2cPVQEo7c92wpWA7QPPMG
* Clean up sky/light sync: remove debug logging, DRY apply logic, fix host routing
- Extract ApplySkyLightState helper to deduplicate sky/light apply code
between RestoreSkyLightState and HandleWorldSnapshot
- Remove all SDL_Log debug calls and SDL_log.h includes
- Remove dead OnWorldEnabled method from WorldStateSync (replaced by
OnHostChanged in OnSaveLoaded)
- Fix HandleSkyLightMutation host path: return FALSE to let local
switch case proceed, instead of duplicating via ApplyWorldEvent
- Simplify isle.cpp HandleControl: split observatory cases into
individual switch arms with single early-return multiplayer hook
- Add save load hooks to sync world state with multiplayer peers
- Fix player count to exclude local player without valid actor
- Support broadcast snapshots (targetPeerId=0) in relay server
---------
* WIP: Add character customization to multiplayer
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Refine character customization: fix message buffering, DRY up code, request-based model
- Register NetworkManager with TickleManager via HandleCreate hook in
LegoOmni::Create(), so packets are processed continuously instead of
buffering between Connect() and OnWorldEnabled()
- Spawn unspawned remote players in OnWorldEnabled() (created before
world was ready)
- Switch to request-based customization: HandleROIClick sends
MSG_CUSTOMIZE to server, server echoes to all peers, HandleCustomize
applies state and plays effects
- DRY up SwitchVariant to delegate LOD cloning to ApplyHatVariant
- Add ApplyChange helper consolidating the switch-on-changeType pattern
- Fix InitFromActorInfo to derive dependent color parts from independent
parts (matching Unpack rules)
- Remove dead code: m_hasBeenTicked, ApplyCustomizeChange on
RemotePlayer, m_localCustomizeState on NetworkManager
- Add null ROI checks in HandleCustomize for unspawned players
- Move MSG_CUSTOMIZE constant to shared protocol.ts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix
* Fix character customization bugs from code review
- BUG-1: Add bounds check in SwitchColor to prevent OOB access from
unvalidated network input (p_partIndex could exceed array bounds)
- BUG-2: Enforce allowRemoteCustomize on receiver side in HandleCustomize
(was only checked on sender side, byppassable by malicious client)
- BUG-3: Document stale-state sound asymmetry for remote targets
- OBS-1: Remove unused bodyVariantIndex from CustomizeState (never
modified, wasted 3 bits per state message)
- NAME-1: Fix p_ prefix convention on ApplyCustomizeChange parameters
Renders a billboard text bubble showing each remote player's display
name. Includes a WASM export to toggle visibility from the frontend.
- Bitmap font renderer generates paletted textures for name labels
- Billboard quad faces the camera each frame via orientation matrix
- Bubble visibility managed globally by NetworkManager toggle
- Fix miniwin D3DRMIMAGE constructor code style (static_cast, const)
* Implement display actor override for multiplayer extension
Add displayActorIndex to the multiplayer protocol, allowing players to
choose any of the 66 character models from g_actorInfoInit via the
multiplayer:actor INI setting. The visual display is decoupled from the
gameplay actor ID while maintaining backward compatibility.
- Protocol: Add displayActorIndex field to PlayerStateMsg and validation helpers
- RemotePlayer: Use display actor name for cloning instead of actorId
- NetworkManager: Broadcast/handle displayActorIndex, respawn on display change
- ThirdPersonCamera: Create/manage display clone ROI for local player override
- INI: Read multiplayer:actor setting and resolve to g_actorInfoInit index
* Use array syntax for INI option access in display actor setup
Consistent with how relayUrl and room are read from options.
* Fix display actor ROI handling in 3rd person camera
- Fix direction flip targeting display clone instead of native ROI in
Disable(), ReinitForCharacter(), and OnCamAnimEnd(). The native ROI is
the source of truth for TransformPointOfView and Tick() sync.
- Fix use-after-free: DestroyDisplayClone() now nulls m_playerROI when
it points to the destroyed clone, preventing dangling pointer access
in BuildRideAnimation after a 3rd→1st→3rd person toggle on a vehicle.
- Recreate display clone in ReinitForCharacter() vehicle branch.
- Extract EnsureDisplayROI() helper to deduplicate clone setup pattern.
- Move IsValidDisplayActorIndex() to charactercloner.h, replacing magic
number 66 with sizeOfArray(g_actorInfoInit).
* Remove display actors plan document
* Fix 3rd person camera 180-degree flip after cam anim ends
When a cam anim (NPC interaction cutscene) ends, FUN_1004b6d0 places the
player actor at the camera's final position using the camera's direction,
which uses standard convention (z = visual forward). The 3rd person camera
relies on backward-z convention (z = visual backward, from TurnAround).
This mismatch caused the camera to face 180 degrees wrong permanently
after any cam anim.
Add a HandleCamAnimEnd extension hook in FUN_1004b6d0 that, when the 3rd
person camera is active, flips the ROI direction back to backward-z and
re-establishes the correct camera position.
- Fix broadcast direction: use IsActive() instead of IsROITurnedAround()
so the negate in BroadcastLocalState only fires when movement inversion
is active, not based on a default-true flag
- Fix vehicle ROI direction for 3rd-person camera: undo Enter()'s
TurnAround on small vehicles so the backward-z convention is preserved.
Vehicles are placed with ROI z opposite to visual forward, and Enter()'s
TurnAround breaks this for 3rd-person rendering. Applied in both
OnActorEnter (entering while 3rd-person enabled) and ReinitForCharacter
(enabling 3rd-person while already on a vehicle)
- Fix vehicle direction on exit: apply extra TurnAround in OnActorExit
when 3rd-person is active, since Exit()'s TurnAround assumes Enter()'s
TurnAround is still in effect
- Add WrappedUpdateWorldData() after manual direction flips in Disable()
and ReinitForCharacter() to keep bounding volumes consistent and prevent
stale world data from causing momentary camera/direction glitches
- Remove unused IsROITurnedAround() method
- Fix data race between WASM exports and game thread
* Add feasibility plan for reusing multiplayer animation system for third-person camera
Evaluates reusing the multiplayer extension's RemotePlayer animation system
(BuildROIMap, AssignROIIndices, ApplyAnimationTransformation) for the local
player to enable a third-person camera mode. Conclusion: feasible with only
3 single-line extension hooks added to core game code.
https://claude.ai/code/session_01NC3zdQZ4nqEcYjyvStqcdD
* WIP: Third-person camera with animation reuse and movement fix
* Fix third-person camera bugs: vehicles, remote facing, emote distortion (#2)
- Fix spawn pose and building re-entry by applying idle frame 0 and
reinitializing on world enable
- Handle vehicle transitions: ride animations for small vehicles,
first-person fallback for large vehicles and helicopter
- Keep vehicle dashboards visible for exit controls
- Disable third-person camera for large vehicles, fix ROI cleanup
- Move HandleActorExit hook to end of Exit() for immediate reinit
- Fix remote player facing 180 degrees wrong by negating direction
in BroadcastLocalState when third-person camera is active
- Fix Hat Tip emote distortion from compounding transform scale by
saving clean parent transform at emote start and restoring after
each frame's animation application
* DRY cleanup for third-person camera branch
- Extract shared DetectVehicleType() to protocol.h/cpp (was duplicated
in ThirdPersonCamera and NetworkManager)
- Remove no-op HandlePostApplyTransform hook chain (called every frame
for every LegoPathActor but did nothing)
- Add ThirdPersonCamera::ClearAnimCaches() helper (pattern repeated 5x)
- Add AnimUtils::EnsureROIMapVisibility() inline helper (loop repeated
5x across ThirdPersonCamera and RemotePlayer)
- Remove redundant static_cast in multiplayer.cpp (UserActor() already
returns LegoPathActor*)
- Delete THIRD_PERSON_CAMERA_ANIMATION_REUSE_PLAN.md development artifact
Move all Emscripten-specific multiplayer code under platforms/emscripten/
and introduce an abstract PlatformCallbacks interface for outbound
notifications, mirroring the existing NetworkTransport pattern. This
removes all #ifdef __EMSCRIPTEN__ blocks from networkmanager.cpp.
Move WASM exports (mp_set_walk_animation, mp_set_idle_animation,
mp_trigger_emote) from multiplayer.cpp into a dedicated
wasm_exports.cpp, added to the isle target (guarded by both
EMSCRIPTEN and ISLE_EXTENSIONS) so the linker keeps the symbols.
Replace the polling mp_get_player_count export with push-based
playerCountChanged CustomEvents dispatched from NetworkManager.
The count only reflects players visible in the Isle world: null
when the local player is outside Isle, filtered by remote player
worldId when inside. Remove the now-unused GetPlayerCount() method.
Implement the animation system from the Phase 1 plan:
Protocol: Add walkAnimId/idleAnimId fields to PlayerStateMsg (2 extra bytes
per 15Hz tick), add MSG_EMOTE (type 9) with EmoteMsg struct, and define
shared animation lookup tables (walk: 6 anims, idle: 3, emote: 2).
NetworkManager: Store local walk/idle animation indices, include them in
every state broadcast, handle incoming MSG_EMOTE by dispatching to the
target remote player's TriggerEmote(). Add SetWalkAnimation(),
SetIdleAnimation(), SendEmote(), GetPlayerCount() public API.
RemotePlayer: Replace per-animation raw pointers with AnimCache struct
and lazy m_animCacheMap (name -> ROI map, built on first use, cleared on
Despawn). UpdateFromNetwork() detects walk/idle ID changes and swaps the
active animation cache. UpdateAnimation() now has three states: moving
(configurable walk anim), emote (one-shot with duration tracking,
interrupted by movement), and idle (configurable idle anim after 2.5s
timeout). Add TriggerEmote() for one-shot emote playback.
WASM exports: mp_set_walk_animation(), mp_set_idle_animation(),
mp_trigger_emote(), mp_get_player_count() with EMSCRIPTEN_KEEPALIVE.
CMakeLists.txt adds EXPORTED_FUNCTIONS and EXPORTED_RUNTIME_METHODS
for Svelte ccall/cwrap access.
https://claude.ai/code/session_01BEYdu8gXr1QmYwzRRgaEA6
- Remove hardcoded multiplayer config from emscripten config.cpp
- Add relay HTTP endpoints for room preview (GET) and creation (POST)
with capacity check, CORS headers, and configurable max players
- Add WebSocket rejection detection (room full/503) via onclose flag
- Add CheckRejected extension call in IsleApp::Tick for clean shutdown
through SDL_APP_SUCCESS path instead of calling exit()
- Set Module._exitCode in JS for sessionStorage-based toast after reload
Split relay.ts into protocol.ts (constants, binary helpers), gameroom.ts
(Durable Object), and a thin relay.ts entry point. Replace magic numbers
with named constants matching protocol.h. Run wrangler directly as PID 1
in Docker so Ctrl+C shuts down gracefully instead of being swallowed by npx.
Move world state synchronization logic (snapshots, events, entity
mutation routing) into a dedicated WorldStateSync class, reducing
NetworkManager from ~790 to ~420 lines.
Revert plant/building manager globals back to private class statics
(matching master) and use friend declarations for extension access.
Move CreateCharacterClone out of LegoCharacterManager into a new
CharacterCloner class in the multiplayer extension.
Add serialization framework using C++ templates and table-driven lookup
to sync plant and building state between players. Includes world snapshot
routing to requesting peer, relay server Docker support, and fixes for
building color sync, ride vehicle visibility, and ARM compilation.
- Replace manual vector math in UpdateTransform with CalcLocalTransform and vec.h macros (LERP3, SET3, MV3, DISTSQRD3, ZEROVEC3)
- Remove all SDL_Log debug logging from multiplayer code
- Strip extraneous comments that restate the code
- Extract CreateAndSpawnPlayer helper to consolidate repeated spawn pattern
- Simplify UpdateVehicleState control flow
- Remove unused includes (SDL_log.h, mxgeometry/mxmatrix.h)
- WebSocket relay server (Cloudflare Worker + Durable Object)
- Remote player character cloning with walk/idle/ride animations
- Vehicle support for remote players
- INI config for relay URL
- Extension hook for world transition ROI management