diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-01-05 19:13:54 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-01-05 19:13:54 +0000 |
commit | 753dda6231bbb2adf585bbc916c0b220e816fcdc (patch) | |
tree | f668854844b1daa45fc24cf40aee5e27cc2be227 /NorthstarDedicatedTest/modmanager.cpp | |
parent | 6fcd21e42f6d6576a9a7aa98d75f03f0ad9b474d (diff) | |
download | NorthstarLauncher-753dda6231bbb2adf585bbc916c0b220e816fcdc.tar.gz NorthstarLauncher-753dda6231bbb2adf585bbc916c0b220e816fcdc.zip |
refactor to allow servers to reregister themselves in heartbeat
Diffstat (limited to 'NorthstarDedicatedTest/modmanager.cpp')
-rw-r--r-- | NorthstarDedicatedTest/modmanager.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/NorthstarDedicatedTest/modmanager.cpp b/NorthstarDedicatedTest/modmanager.cpp index 23dd2d6e..c5f1bf49 100644 --- a/NorthstarDedicatedTest/modmanager.cpp +++ b/NorthstarDedicatedTest/modmanager.cpp @@ -2,7 +2,7 @@ #include "modmanager.h" #include "convar.h" #include "concommand.h" - +#include "masterserver.h" #include "rapidjson/error/en.h" #include "rapidjson/document.h" #include "rapidjson/ostreamwrapper.h" @@ -355,6 +355,32 @@ void ModManager::LoadMods() } } + // build modinfo obj for masterserver + rapidjson_document modinfoDoc; + modinfoDoc.SetObject(); + modinfoDoc.AddMember("Mods", rapidjson_document::GenericValue(rapidjson::kArrayType), modinfoDoc.GetAllocator()); + + int currentModIndex = 0; + for (Mod& mod : m_loadedMods) + { + if (!mod.Enabled || (!mod.RequiredOnClient && !mod.Pdiff.size())) + continue; + + modinfoDoc["Mods"].PushBack(rapidjson_document::GenericValue(rapidjson::kObjectType), modinfoDoc.GetAllocator()); + modinfoDoc["Mods"][currentModIndex].AddMember("Name", rapidjson::StringRef(&mod.Name[0]), modinfoDoc.GetAllocator()); + modinfoDoc["Mods"][currentModIndex].AddMember("Version", rapidjson::StringRef(&mod.Version[0]), modinfoDoc.GetAllocator()); + modinfoDoc["Mods"][currentModIndex].AddMember("RequiredOnClient", mod.RequiredOnClient, modinfoDoc.GetAllocator()); + modinfoDoc["Mods"][currentModIndex].AddMember("Pdiff", rapidjson::StringRef(&mod.Pdiff[0]), modinfoDoc.GetAllocator()); + + currentModIndex++; + } + + rapidjson::StringBuffer buffer; + buffer.Clear(); + rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); + modinfoDoc.Accept(writer); + g_MasterServerManager->m_ownModInfoJson = std::string(buffer.GetString()); + m_hasLoadedMods = true; } |