mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Add enabledpatches config option
The server administrator must now specify which patches they want the server to load (if deviating from the defaults). There are multiple reasons for this: * It's useful to be able to pick and choose which patches you want to boot the server with; without having to move the directories in and out of the patch directory * This way, we can have different default patches for different builds of the game (104 vs 1013) * ...ergo, it's easier to rapidly switch builds without having to rearrange your workspace to properly run them * This also allows us to remove the std::filesystem stuff, which has spotty compatibility with slightly older (but still current) versions of the compilers
This commit is contained in:
parent
32daa68458
commit
5c1bb0acc9
@ -40,6 +40,11 @@ motd=Welcome to OpenFusion!
|
|||||||
# location of the patch folder
|
# location of the patch folder
|
||||||
#patchdir=tdata/patch/
|
#patchdir=tdata/patch/
|
||||||
|
|
||||||
|
# Space-separated list of patch folders in patchdir to load from.
|
||||||
|
# If you uncomment this, note that Academy builds *must* contain 1013,
|
||||||
|
# and pre-Academy builds must *not* contain it.
|
||||||
|
#enabledpatches=1013
|
||||||
|
|
||||||
# xdt json filename
|
# xdt json filename
|
||||||
#xdtdata=xdt.json
|
#xdtdata=xdt.json
|
||||||
# NPC json filename
|
# NPC json filename
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "JSON.hpp"
|
#include "JSON.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
using namespace TableData;
|
using namespace TableData;
|
||||||
@ -1079,19 +1080,26 @@ void TableData::init() {
|
|||||||
}
|
}
|
||||||
fstream.close();
|
fstream.close();
|
||||||
|
|
||||||
// patching: loop through every directory within the patch directory, looking for a matching file
|
// patching: load each patch directory specified in the config file
|
||||||
if (!std::filesystem::exists(settings::PATCHDIR)) continue; // patch dir doesn't exist
|
|
||||||
|
// split config field into individual patch entries
|
||||||
|
std::stringstream ss(settings::ENABLEDPATCHES);
|
||||||
|
std::istream_iterator<std::string> begin(ss);
|
||||||
|
std::istream_iterator<std::string> end;
|
||||||
|
|
||||||
json patch;
|
json patch;
|
||||||
for (const auto& patchModule : std::filesystem::directory_iterator(settings::PATCHDIR)) {
|
for (auto it = begin; it != end; it++) {
|
||||||
// this is the theoretical path of a corresponding patch for this file
|
// this is the theoretical path of a corresponding patch for this file
|
||||||
std::string patchFile = patchModule.path().generic_u8string() + "/" + table.second;
|
std::string patchModuleName = *it;
|
||||||
if (std::filesystem::exists(patchFile)) {
|
std::string patchFile = settings::PATCHDIR + patchModuleName + "/" + table.second;
|
||||||
// file exists
|
try {
|
||||||
std::cout << "[INFO] Patching " << patchFile << std::endl;
|
|
||||||
fstream.open(patchFile);
|
fstream.open(patchFile);
|
||||||
fstream >> patch; // load into temporary json object
|
fstream >> patch; // load into temporary json object
|
||||||
|
std::cout << "[INFO] Patching " << patchFile << std::endl;
|
||||||
patchJSON(table.first, &patch); // patch
|
patchJSON(table.first, &patch); // patch
|
||||||
fstream.close();
|
fstream.close();
|
||||||
|
} catch (const std::exception& err) {
|
||||||
|
// no-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
|
|
||||||
|
@ -45,8 +45,10 @@ std::string settings::DROPSJSON = "drops.json";
|
|||||||
std::string settings::PATHJSON = "paths.json";
|
std::string settings::PATHJSON = "paths.json";
|
||||||
#ifdef ACADEMY
|
#ifdef ACADEMY
|
||||||
std::string settings::XDTJSON = "xdt1013.json";
|
std::string settings::XDTJSON = "xdt1013.json";
|
||||||
|
std::string settings::ENABLEDPATCHES = "1013";
|
||||||
#else
|
#else
|
||||||
std::string settings::XDTJSON = "xdt.json";
|
std::string settings::XDTJSON = "xdt.json";
|
||||||
|
std::string settings::ENABLEDPATCHES = "";
|
||||||
#endif // ACADEMY
|
#endif // ACADEMY
|
||||||
|
|
||||||
int settings::ACCLEVEL = 1;
|
int settings::ACCLEVEL = 1;
|
||||||
@ -96,6 +98,7 @@ void settings::init() {
|
|||||||
DBPATH = reader.Get("shard", "dbpath", DBPATH);
|
DBPATH = reader.Get("shard", "dbpath", DBPATH);
|
||||||
TDATADIR = reader.Get("shard", "tdatadir", TDATADIR);
|
TDATADIR = reader.Get("shard", "tdatadir", TDATADIR);
|
||||||
PATCHDIR = reader.Get("shard", "patchdir", PATCHDIR);
|
PATCHDIR = reader.Get("shard", "patchdir", PATCHDIR);
|
||||||
|
ENABLEDPATCHES = reader.Get("shard", "enabledpatches", ENABLEDPATCHES);
|
||||||
ACCLEVEL = reader.GetInteger("shard", "accountlevel", ACCLEVEL);
|
ACCLEVEL = reader.GetInteger("shard", "accountlevel", ACCLEVEL);
|
||||||
EVENTMODE = reader.GetInteger("shard", "eventmode", EVENTMODE);
|
EVENTMODE = reader.GetInteger("shard", "eventmode", EVENTMODE);
|
||||||
DISABLEFIRSTUSEFLAG = reader.GetBoolean("shard", "disablefirstuseflag", DISABLEFIRSTUSEFLAG);
|
DISABLEFIRSTUSEFLAG = reader.GetBoolean("shard", "disablefirstuseflag", DISABLEFIRSTUSEFLAG);
|
||||||
|
@ -25,6 +25,7 @@ namespace settings {
|
|||||||
extern std::string GRUNTWORKJSON;
|
extern std::string GRUNTWORKJSON;
|
||||||
extern std::string DBPATH;
|
extern std::string DBPATH;
|
||||||
extern std::string PATCHDIR;
|
extern std::string PATCHDIR;
|
||||||
|
extern std::string ENABLEDPATCHES;
|
||||||
extern std::string TDATADIR;
|
extern std::string TDATADIR;
|
||||||
extern int EVENTMODE;
|
extern int EVENTMODE;
|
||||||
extern bool MONITORENABLED;
|
extern bool MONITORENABLED;
|
||||||
|
Loading…
Reference in New Issue
Block a user