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.
25 lines
548 B
C++
25 lines
548 B
C++
#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();
|
|
}
|