Implement automatic tdata patching

This commit is contained in:
gsemaj 2021-05-01 21:19:36 -04:00 committed by Gent Semaj
parent bf12ed4c47
commit 26894c8a69
2 changed files with 15 additions and 1 deletions

View File

@ -1013,7 +1013,20 @@ void TableData::init() {
} }
fstream.close(); fstream.close();
// patching // patching: loop through every directory within the patch directory, looking for a matching file
json patch;
for (const auto& patchModule : std::filesystem::directory_iterator(settings::PATCHDIR)) {
// this is the theoretical path of a corresponding patch for this file
std::string patchFile = patchModule.path().generic_u8string() + "/" + table.second;
if (std::filesystem::exists(patchFile)) {
// file exists
std::cout << "[INFO] Patching " << patchFile << std::endl;
fstream.open(patchFile);
fstream >> patch; // load into temporary json object
patchJSON(table.first, &patch); // patch
fstream.close();
}
}
} }
// fetch data from patched tables and load them appropriately // fetch data from patched tables and load them appropriately

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <map> #include <map>
#include <filesystem>
#include "NPCManager.hpp" #include "NPCManager.hpp"