Add host-authoritative world-state sync
Implement host-authoritative time/weather sync across server and clients. Adds a new worldState packet (and worldStateHost for host assignment) and server-side host tracking/reassignment to the lowest remaining playerId when the host disconnects. Plugin-side changes introduce F4T::WorldStateSync (new header + implementation), polling/apply hooks in the game-thread main loop, and Networking support to send/receive/parse worldState/worldStateHost packets. The server validates host-only sends, relays worldState to peers, broadcasts worldStateHost on host handoff, and augments logging/stats. Protocol and documentation files updated (protocol/world-state.md, docs/*) and server/fake_client.py extended to track/print host world-state snapshots.
This commit is contained in:
@@ -29,4 +29,9 @@ namespace F4T::Networking
|
||||
bool a_weaponDrawn = false,
|
||||
float a_movementSpeed = 0.0F,
|
||||
float a_animationGraphSpeed = -1.0F);
|
||||
bool SendWorldStatePacket(
|
||||
float a_gameHour,
|
||||
float a_gameDaysPassed,
|
||||
bool a_hasWeatherFormId,
|
||||
std::uint32_t a_weatherFormId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace F4T::WorldStateSync
|
||||
{
|
||||
struct PendingWorldState
|
||||
{
|
||||
float gameHour{ 0.0F };
|
||||
float gameDaysPassed{ 0.0F };
|
||||
std::optional<std::uint32_t> weatherFormId;
|
||||
bool hasWeatherFormId{ false };
|
||||
};
|
||||
|
||||
bool IsWorldStateHost();
|
||||
std::optional<std::uint32_t> GetWorldStateHostPlayerId();
|
||||
void SetWorldStateHostPlayerId(std::uint32_t a_hostPlayerId);
|
||||
void Reset();
|
||||
void SetPendingWorldState(PendingWorldState a_state);
|
||||
void PollHostCapture();
|
||||
void ApplyPendingState();
|
||||
}
|
||||
Reference in New Issue
Block a user