Working on the server

This commit is contained in:
Vladislav Khorev committed 2026-11-05 20:12:30 +06:00
1 parent 075750442f
commit 28c6e83eda
30 files changed
+646 -362

No files matched your search

+12 -2
View File
@@ -15,6 +15,7 @@ void RemoteGameServerHost::initializeCampaign(
const std::string& campaignId, const std::string&,
const std::string& zipFile)
{
localState_.clear();
const CampaignConfig* campaign =
CampaignRegistry::instance().find(campaignId);
if (!campaign)
@@ -25,6 +26,7 @@ void RemoteGameServerHost::initializeCampaign(
void RemoteGameServerHost::clearCampaign()
{
runtimeLocations_.clear();
localState_.clear();
client_.replica_.clearCampaign();
}
@@ -48,6 +50,7 @@ void RemoteGameServerHost::setupRuntimeLocation(
throw std::runtime_error("Remote location state was not prepared");
params.definition = stored->second.definition;
params.gameState = &stored->second;
params.localState = localState_.getOrCreate(id);
location->setup(params, audioPlayer);
}
@@ -101,9 +104,16 @@ void RemoteGameServerHost::save(nlohmann::json&)
// Persistence remains server-side.
}
void RemoteGameServerHost::load(const nlohmann::json&)
void RemoteGameServerHost::load(const nlohmann::json& in)
{
// Persistence remains server-side.
// The authoritative half is loaded by the standalone server. Each client
// restores only its local presentation state from the shared start state.
nlohmann::json ignoredNetworkState;
ClientLocationState loadedLocalState;
loadSinglePlayerPersistence(in, ignoredNetworkState, loadedLocalState);
nlohmann::json localStateJson;
loadedLocalState.save(localStateJson);
localState_.load(localStateJson);
}
} // namespace FRG