Add serverWorldState packet and GUI controls

Introduce a server-authoritative world-state packet to control weather and time from the dev server GUI. Adds protocol docs and message type (serverWorldState), a new Weather/Time tab in dev_server_app.py, server-side broadcasting in server_core.py, and preset utilities in server/world_state_presets.py. Plugin changes (F4TNetworking.cpp, F4TWorldStateSync.*) queue and apply incoming serverWorldState on the game thread, run `set gamehour` for all clients, and run `fw <8-digit-id>` on the assigned player 1 then force the host to relay a worldState snapshot. Also includes parsing/validation of hex form IDs, logging improvements, and minimal fake client handling. This ensures consistent server-driven time/weather and documents usage and presets.
This commit is contained in:
2026-06-23 23:03:34 +12:00
parent 70933db6e5
commit 4c17e70620
14 changed files with 757 additions and 3 deletions
+3 -1
View File
@@ -33,7 +33,9 @@ both send and receive paths:
host sends `worldState` packets with `gameHour`, `gameDaysPassed`, optional
`weatherFormId`, and optional `timeSync`. Weather heartbeats run at ~1 Hz;
time is pushed with `timeSync: true` on connect, after time freezes (menus,
loads, saves), and on large time jumps. Promoted hosts continue with their
loads, saves), and on large time jumps. The dev server GUI can also broadcast
`serverWorldState` to all clients for admin weather (`fw`) and time
(`set gamehour to HHmm`) commands. Promoted hosts continue with their
already-synced local time and weather so remaining clients should not see a jump.
12. On the game-thread update path, the proxy controller reads a copied
remote-player snapshot before attempting any actor work. The snapshot is
+131
View File
@@ -9,6 +9,137 @@ failed experiments, successful tests, and next steps.
---
## 2026-06-23 - GUI Weather Uses Numeric `fw` ID
### Summary
Fixed dev server GUI weather by matching manual console behaviour: player 1 runs `fw <8-digit-hex-form-id>` on the game thread instead of `fw <editorName>`. Weather packets are broadcast to all clients; only player 1 executes.
### Files Changed
- `plugin/src/F4TWorldStateSync.cpp`
- `plugin/src/F4TNetworking.cpp`
- `plugin/include/F4TWorldStateSync.h`
- `server/world_state_presets.py`
- `server/server_core.py`
- `server/dev_server_app.py`
- `protocol/server-world-state.md`
- `changelog.md`
### Details
- `weatherConsoleArg` is the exact `fw` argument (8-digit hex, e.g. `00148c45`).
- `weatherFormId` is used for host `worldState` relay after `fw` runs.
- Preset IDs in `world_state_presets.py` may differ from what works in a given load order; edit them to match console-tested IDs.
### Testing
- User confirmed `fw` works with a numeric form ID (e.g. `fw 0000015E`) but not with editor names like `fw CommonwealthRain`.
- Plugin rebuild and GUI retest pending.
### Known Issues
- None currently known.
### Next Steps
- Rebuild plugin, connect game client as player 1 (first to connect), click a weather preset outdoors.
- Check `CommonwealthOnline.log` for `Player 1 executed server weather command: fw ...`.
- Update `WEATHER_PRESETS` if needed to use IDs verified in your console.
---
## 2026-06-23 - Host-Console Weather Relay
### Summary
Server GUI weather now runs only on client 1: the host executes `fw <editorId>` as if typed in the console, then immediately relays `worldState` so other clients sync through the existing host weather path.
### Files Changed
- `plugin/src/F4TWorldStateSync.cpp`
- `server/server_core.py`
- `server/dev_server_app.py`
- `protocol/server-world-state.md`
- `changelog.md`
### Details
- Non-host clients ignore weather fields in `serverWorldState`.
- Server sends weather packets only to the connected world-state host.
- Host force-broadcasts `worldState` with the requested `weatherFormId` after running `fw`.
### Testing
- Not re-tested in-game in this session.
- Recommended: two clients outdoors, client 1 connected first; set Rain from GUI; confirm host log shows `fw CommonwealthRain` and client 2 receives host `worldState`.
### Known Issues
- None currently known.
### Next Steps
- In-game verification that host console `fw` works from plugin `ExecuteCommand`.
---
## 2026-06-23 - Server Weather Apply Fix
### Summary
Fixed dev server GUI weather not applying and clients drifting to different weather after a server time change.
### Files Changed
- `plugin/src/F4TWorldStateSync.cpp`
- `plugin/include/F4TWorldStateSync.h`
- `plugin/src/F4TNetworking.cpp`
- `server/server_core.py`
- `server/world_state_presets.py`
- `server/dev_server_app.py`
- `protocol/server-world-state.md`
- `changelog.md`
### Details
- Weather now uses `Sky::ForceWeather` with hex `weatherFormId` instead of `fw` via `ExecuteCommand`.
- Server broadcasts the full snapshot on every GUI change so time buttons also re-send weather.
- Host weather capture state updates after server weather apply to avoid stale host heartbeats.
### Testing
- Not re-tested in-game in this session.
- Recommended: two clients outdoors, set weather from GUI, then change time and confirm both stay on the same weather.
### Known Issues
- None currently known.
### Next Steps
- Verify Glowing Sea form ID (`001B9779`) in-game; adjust preset if needed.
---
## 2026-06-23 - Server Weather and Time GUI
### Summary
Added server-authoritative weather and time control from the dev server GUI. A new **Weather / Time** tab broadcasts `serverWorldState` packets to all connected clients, which apply `fw <editorId>` for weather and `set gamehour to HHmm` for time.
### Files Changed
- `server/server_core.py`
- `server/dev_server_app.py`
- `server/world_state_presets.py`
- `server/fake_client.py`
- `plugin/include/F4TWorldStateSync.h`
- `plugin/src/F4TWorldStateSync.cpp`
- `plugin/src/F4TNetworking.cpp`
- `protocol/server-world-state.md`
- `protocol/message-types.md`
- `docs/protocol.md`
- `changelog.md`
### Details
- Dev server stores the latest requested time/weather and broadcasts to every connected client.
- Plugin queues `serverWorldState` on the network thread and runs console commands on the game thread.
- Weather presets use Commonwealth editor IDs (`CommonwealthClear`, `CommonwealthRain`, etc.) because `setweather` does not work on Fallout 4.
- Time presets use HHmm values such as `1900` for 7:00 PM.
### Testing
- Not run in-game in this session.
- Recommended: start dev server GUI, connect one or two game clients outdoors, use Weather / Time tab buttons, verify `CommonwealthOnline.log` shows applied server commands and in-game weather/time changes.
### Known Issues
- None currently known.
### Next Steps
- In-game verification with two clients and mixed interior/exterior weather apply behaviour.
---
## 2026-06-23 - Event-Driven Time Sync
### Summary
+1
View File
@@ -16,6 +16,7 @@ Long-term versions may move to a binary protocol if performance becomes a proble
- `transform`
- `worldState`
- `worldStateHost`
- `serverWorldState`
- `disconnect`
- `ping`
- `pong`