Use world-state host for server weather actions

Stop hardcoding player 1 for server-initiated weather/time and instead use the current world-state host. Plugin code now defers weather commands until GetWorldStateHostPlayerId() is available, uses IsWorldStateHost() to gate execution, logs local/host IDs, and requeues when host assignment is missing. Relay logic now attempts ForceHostWorldStateBroadcast and logs if relay fails. Updated protocol docs, dev server UI tooltips, presets comment, changelog, and dev log to reflect world-state host terminology and behavior. This ensures weather/time control survives host reassignment and avoids dropped commands on reconnect/restart.
This commit is contained in:
2026-06-25 10:48:18 +12:00
parent c4466718a3
commit 77751c69f7
7 changed files with 70 additions and 21 deletions
+21 -8
View File
@@ -486,9 +486,21 @@ namespace
return;
}
if (*assignedPlayerId != 1U) {
const auto hostPlayerId = F4T::WorldStateSync::GetWorldStateHostPlayerId();
if (!hostPlayerId) {
RequeueServerWorldState(a_state);
if (ShouldLog("server_world_state_weather_defer_host")) {
LogInfo("Deferred server weather command until world-state host assignment is available.");
}
return;
}
if (!F4T::WorldStateSync::IsWorldStateHost()) {
if (ShouldLog("server_world_state_weather_skip")) {
LogInfo("Ignored server weather command on non-player-1 client.");
LogInfo(std::format(
"Ignored server weather command on non-host client (local={}, host={}).",
*assignedPlayerId,
*hostPlayerId));
}
return;
}
@@ -505,7 +517,10 @@ namespace
RE::Console::ExecuteCommand(command.c_str());
if (ShouldLog("server_world_state_weather_apply")) {
LogInfo(std::format("Player 1 executed server weather command: {}", command));
LogInfo(std::format(
"World-state host (player {}) executed server weather command: {}",
*assignedPlayerId,
command));
}
std::optional<std::uint32_t> forcedWeatherFormId;
@@ -515,11 +530,9 @@ namespace
forcedWeatherFormId = parsed;
}
if (F4T::WorldStateSync::IsWorldStateHost()) {
ForceHostWorldStateBroadcast(forcedWeatherFormId, false);
} else if (ShouldLog("server_world_state_weather_no_relay")) {
LogWarning(
"Player 1 applied server weather but is not world-state host; other clients may not sync.");
if (!ForceHostWorldStateBroadcast(forcedWeatherFormId, false) &&
ShouldLog("server_world_state_weather_no_relay")) {
LogWarning("Could not relay host world-state after server weather command.");
}
}
}