Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Server/Source/core_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ class Config final : public IEarlyConfig
IUnicodeComponent* unicode = nullptr;
ICore& core;

std::map<String, ConfigStorage> defaults;

void processNode(const nlohmann::json::object_t& node, String ns = "")
{
for (const auto& kv : node)
Expand Down Expand Up @@ -348,6 +350,24 @@ class Config final : public IEarlyConfig
{
processed = Defaults;
}
defaults = processed;
}

void reset()
{
// Don't use the copy constructor because we need to keep pointers valid.
for (auto const& i : defaults)
{
auto it = processed.find(i.first);
if (it == processed.end())
{
continue;
}
if (it->second.index() == i.second.index())
{
it->second = i.second;
}
}
}

void init(IComponentList& components)
Expand Down Expand Up @@ -1347,6 +1367,7 @@ class Core final : public ICore, public PlayerConnectEventHandler, public Consol
reloading_ = true;
NetCode::RPC::PlayerClose RPC;
PacketHelper::broadcast(RPC, players);
config.reset();
components.reset();
players.removeSyncPacketsHandlers();

Expand Down