aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/modmanager.cpp
diff options
context:
space:
mode:
authorHappyDOGE <28511119+HappyDOGE@users.noreply.github.com>2022-01-16 13:12:50 +0300
committerHappyDOGE <28511119+HappyDOGE@users.noreply.github.com>2022-01-16 13:12:50 +0300
commit8e9338805062f53be1135d49b6021bd3ab8a220f (patch)
tree6c56076795299c601ed6afae5bac973b61585774 /NorthstarDedicatedTest/modmanager.cpp
parent4f0e396e9774dad1eb03aa54f65c64da4b0e3a60 (diff)
parentd4d4e489e4a1435e1df3cd1a1e3666e7ae713829 (diff)
downloadNorthstarLauncher-8e9338805062f53be1135d49b6021bd3ab8a220f.tar.gz
NorthstarLauncher-8e9338805062f53be1135d49b6021bd3ab8a220f.zip
merge with upstream
Diffstat (limited to 'NorthstarDedicatedTest/modmanager.cpp')
-rw-r--r--NorthstarDedicatedTest/modmanager.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/NorthstarDedicatedTest/modmanager.cpp b/NorthstarDedicatedTest/modmanager.cpp
index 34bba6af..2e287dcd 100644
--- a/NorthstarDedicatedTest/modmanager.cpp
+++ b/NorthstarDedicatedTest/modmanager.cpp
@@ -3,7 +3,7 @@
#include "convar.h"
#include "concommand.h"
#include "audio.h"
-
+#include "masterserver.h"
#include "rapidjson/error/en.h"
#include "rapidjson/document.h"
#include "rapidjson/ostreamwrapper.h"
@@ -372,6 +372,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;
}