Skip to content

Commit b1f463e

Browse files
Add load_order and incompatibilities to modinfo.json, fix NKH bug causing only one mods textures to load
1 parent 46e0d24 commit b1f463e

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

Diff for: Common/Mod/ModInfo.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,27 @@ nlohmann::json ModInfo::Serialize() {
149149
if (this->website.length() > 0) {
150150
result["website"] = this->website;
151151
}
152+
if (this->loadOrder.has_value()) {
153+
if (this->loadOrder == LoadOrder::BASE)
154+
{
155+
result["load_order"] = "BASE";
156+
}
157+
if (this->loadOrder == LoadOrder::FIRST)
158+
{
159+
result["load_order"] = "FIRST";
160+
}
161+
if (this->loadOrder == LoadOrder::ANY)
162+
{
163+
result["load_order"] = "ANY";
164+
}
165+
if (this->loadOrder == LoadOrder::LAST)
166+
{
167+
result["load_order"] = "LAST";
168+
}
169+
}
170+
if (!this->incompatibilites.empty()) {
171+
result["incompatibilities"] = this->incompatibilites;
172+
}
152173
return result;
153174
}
154175

Diff for: NKHook5/Assets/AssetServer.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ std::shared_ptr<Asset> AssetServer::Serve(fs::path assetPath, std::vector<uint8_
6666
AssetBin theBin = FromPath(assetPath);
6767

6868
//JSON files are only found in the json bin
69-
if (theBin == AssetBin::JSON) {
69+
if (theBin == AssetBin::JSON || assetPath.filename().string().ends_with(".json")) {
7070
auto toCache = this->ServeJSON(assetPath, vanilla);
7171
this->cache.push_back(toCache);
7272
return toCache;
@@ -126,12 +126,15 @@ std::shared_ptr<Asset> AssetServer::ServeJSON(fs::path assetPath, std::vector<ui
126126
nlohmann::ordered_json vanillaJson = nlohmann::ordered_json::parse(vanillaStr, nullptr, true, true);
127127
merged.Add(vanillaJson);
128128
}
129-
129+
130130
for (std::shared_ptr<Asset> find : finds) {
131131
const std::vector<uint8_t>& findData = find->GetData();
132132
std::string findStr(findData.begin(), findData.end());
133133
nlohmann::ordered_json findJson = nlohmann::ordered_json::parse(findStr, nullptr, true, true);
134-
merged.Add(findJson);
134+
if (ExtensionManager::GetByTarget(assetPath.string()).empty())
135+
merged.Add(findJson);
136+
else
137+
merged.Add(findJson, MergeMode::INSERTIVE);
135138
}
136139

137140
nlohmann::ordered_json mergedJson = merged.GetMerged();

Diff for: NKHook5/Patches/CBloonsTD5Game/Constructor.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ namespace NKHook5
5656
Print("An error occured while preparing mod initialization: %s", ex.what());
5757
}
5858
}
59+
//Compatibility check
60+
if (sources[LoadOrder::BASE].size() > 1)
61+
{
62+
Print(LogLevel::ERR, "Multiple mods tried to have a BASE load order! Below are the incompatible mods:");
63+
for (ModAssetSource* source : sources[LoadOrder::BASE])
64+
{
65+
Print(LogLevel::ERR, "%s", source->GetModArch()->GetInfo().GetName().c_str());
66+
}
67+
Print(LogLevel::ERR, "You may only have ONE of these mods at a time.");
68+
69+
MessageBoxA(nullptr, "You have incompatible mods! Read the console for more information.", "Compatibility check", MB_OK);
70+
Print("Press enter to quit...");
71+
std::cin.get();
72+
exit(-1);
73+
}
5974
LoadOrder priorityList[] = {
6075
LoadOrder::BASE,
6176
LoadOrder::FIRST,
@@ -75,6 +90,11 @@ namespace NKHook5
7590
{
7691
Print(LogLevel::ERR, "'%s' uses MergeIgnore, but without 'BASE' load_order!", modArch->GetInfo().GetName().c_str());
7792
Print(LogLevel::SUCCESS, "Add a 'load_order' entry to the mod's modinfo.json file with the value 'BASE'");
93+
94+
MessageBoxA(nullptr, "A compatibility check failed, read the console for more info.", "Compatibility check", MB_OK);
95+
Print("Press enter to quit...");
96+
std::cin.get();
97+
exit(-1);
7898
}
7999
}
80100
const ModInfo& modInfo = modArch->GetInfo();

0 commit comments

Comments
 (0)