Event-driven world time sync (timeSync flag)
Introduce an optional timeSync field and event-driven time pushes so host time is only re-applied on connect, resume-from-freeze, or large jumps while weather continues on ~1 Hz heartbeats. Added IsGameTimeFrozen detection and client buffering of latest host time; clients apply host time only when timeSync is true or when gameplay just resumed. Updated networking to read/write timeSync, adjusted F4TWorldStateSync logic (separate time vs weather send/apply paths, changed function signatures and behavior), and updated protocol/docs/changelog and fake_client logging to reflect the new field and behavior.
This commit is contained in:
@@ -30,9 +30,11 @@ both send and receive paths:
|
||||
11. The server tracks a world-state host (`worldStateHostPlayerId`). The first
|
||||
connected client becomes host; when the host disconnects, the server reassigns
|
||||
host to the lowest remaining `playerId` and broadcasts `worldStateHost`. The
|
||||
host sends low-frequency `worldState` packets with `gameHour`, `gameDaysPassed`,
|
||||
and optional `weatherFormId`. Promoted hosts continue with their already-synced
|
||||
local time and weather so remaining clients should not see a jump.
|
||||
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
|
||||
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
|
||||
sorted by `playerId`, and only remote players with valid transform data in
|
||||
|
||||
@@ -9,6 +9,42 @@ failed experiments, successful tests, and next steps.
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-23 - Event-Driven Time Sync
|
||||
|
||||
### Summary
|
||||
Improved host-authoritative time sync so calendar time stays aligned without constant heartbeat updates. The host (client 1) now pushes time with `timeSync: true` after gameplay time resumes from freezes (menus, pip-boy, dialogue, loading screens, save/load, wait/sleep). Non-host clients buffer the latest host time during freezes and snap on resume.
|
||||
|
||||
### Files Changed
|
||||
- `plugin/include/F4TWorldStateSync.h`
|
||||
- `plugin/src/F4TWorldStateSync.cpp`
|
||||
- `plugin/include/F4TNetworking.h`
|
||||
- `plugin/src/F4TNetworking.cpp`
|
||||
- `protocol/world-state.md`
|
||||
- `changelog.md`
|
||||
- `server/fake_client.py`
|
||||
|
||||
### Details
|
||||
- Added `IsGameTimeFrozen()` detection using `Main` flags, open menus, save/load busy state, and sleeping.
|
||||
- Split host send logic: weather continues on ~1 Hz heartbeat; time sends on initial connect, resume-from-freeze, or large time jumps.
|
||||
- Added optional `timeSync` field on `worldState` packets so weather-only heartbeats do not re-apply time on clients.
|
||||
- Clients store latest host time from every packet and force-apply when local gameplay time resumes.
|
||||
|
||||
### Testing
|
||||
- Not run in-game in this session.
|
||||
- Recommended manual checks:
|
||||
- Connect host first, then second client; verify times match after load.
|
||||
- Open pip-boy on client 2 while host keeps playing; close pip-boy and confirm client 2 snaps to host time (`Applied host world time` in log).
|
||||
- Wait/sleep on host; confirm `timeSync=yes` in host log and clients update.
|
||||
- Verify weather still updates on ~1 Hz outdoors without constant time apply logs.
|
||||
|
||||
### Known Issues
|
||||
- None currently known.
|
||||
|
||||
### Next Steps
|
||||
- In-game two-instance verification across load screens and pause menu exits.
|
||||
|
||||
---
|
||||
|
||||
## 2026-06-22 - World-State Host Reassignment
|
||||
|
||||
### Summary
|
||||
|
||||
@@ -105,6 +105,7 @@ Full field definitions live in [`protocol/world-state.md`](../protocol/world-sta
|
||||
"gameHour": 14.25,
|
||||
"gameDaysPassed": 12.5,
|
||||
"weatherFormId": "00123456",
|
||||
"timeSync": true,
|
||||
"clientTime": 1717424000.123,
|
||||
"serverTime": 1717424000.456
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user