diff --git a/config.ini b/config.ini index fb7977d..b5e24f4 100644 --- a/config.ini +++ b/config.ini @@ -1,3 +1,8 @@ +# name of the client build the server is targetting. +# used for determining which patches to apply. +# default is beta-20111013 for Academy, beta-20100104 otherwise. +#buildname=beta-20100104 + # verbosity level # 0 = mostly silence # 1 = debug prints and unknown packets @@ -46,11 +51,6 @@ motd=Welcome to OpenFusion! # location of the patch folder #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 #xdtdata=xdt.json # NPC json filename @@ -61,6 +61,8 @@ motd=Welcome to OpenFusion! #pathdata=paths.json # drop json filename #dropdata=drops.json +# patchmap json filename +#patchmapdata=patchmap.json # gruntwork output filename (this is what you submit) #gruntwork=gruntwork.json # location of the database diff --git a/src/TableData.cpp b/src/TableData.cpp index a685cee..56ff404 100644 --- a/src/TableData.cpp +++ b/src/TableData.cpp @@ -1086,6 +1086,26 @@ static void patchJSON(json* base, json* patch) { void TableData::init() { int32_t nextId = INT32_MAX; // next dynamic ID to hand out + json patchmap; + + // load patch map + { + std::fstream fstream; + fstream.open(settings::TDATADIR + "/" + settings::PATCHMAPJSON); + + if (fstream.fail()) { + std::cerr << "[FATAL] Critical tdata file missing: " << settings::PATCHMAPJSON << std::endl; + exit(1); + } + + if (fstream.peek() == std::ifstream::traits_type::eof()) { + std::cerr << "[FATAL] Critical tdata file is empty: " << settings::PATCHMAPJSON << std::endl; + exit(1); + } + + fstream >> patchmap; + fstream.close(); + } // base JSON tables json xdt, paths, drops, eggs, npcs, mobs, gruntwork; @@ -1134,15 +1154,13 @@ void TableData::init() { fstream >> *table.first; } - // patching: load each patch directory specified in the config file - - // split config field into individual patch entries - std::stringstream ss(settings::ENABLEDPATCHES); - std::istream_iterator begin(ss); - std::istream_iterator end; + // patching: load each patch directory specified in patchmap.json + // fetch list of patches that need to be applied for the current build json patch; - for (auto it = begin; it != end; it++) { + json patchlist = patchmap["patchmap"][settings::BUILDNAME]; + + for (auto it = patchlist.begin(); it != patchlist.end(); it++) { // this is the theoretical path of a corresponding patch for this file std::string patchModuleName = *it; std::string patchFile = settings::PATCHDIR + patchModuleName + "/" + table.second; diff --git a/src/settings.cpp b/src/settings.cpp index 14d8de4..fb4c722 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -47,12 +47,13 @@ std::string settings::GRUNTWORKJSON = "gruntwork.json"; std::string settings::MOTDSTRING = "Welcome to OpenFusion!"; std::string settings::DROPSJSON = "drops.json"; std::string settings::PATHJSON = "paths.json"; +std::string settings::PATCHMAPJSON = "patchmap.json"; #ifdef ACADEMY std::string settings::XDTJSON = "xdt1013.json"; -std::string settings::ENABLEDPATCHES = "1013"; +std::string settings::BUILDNAME = "beta-20111013"; #else std::string settings::XDTJSON = "xdt.json"; -std::string settings::ENABLEDPATCHES = ""; +std::string settings::BUILDNAME = "beta-20100104"; #endif // ACADEMY int settings::ACCLEVEL = 1; @@ -78,6 +79,7 @@ void settings::init() { return; } + BUILDNAME = reader.Get("", "buildname", BUILDNAME); VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY); SANDBOX = reader.GetBoolean("", "sandbox", SANDBOX); LOGINPORT = reader.GetInteger("login", "port", LOGINPORT); @@ -105,7 +107,7 @@ void settings::init() { DBPATH = reader.Get("shard", "dbpath", DBPATH); TDATADIR = reader.Get("shard", "tdatadir", TDATADIR); PATCHDIR = reader.Get("shard", "patchdir", PATCHDIR); - ENABLEDPATCHES = reader.Get("shard", "enabledpatches", ENABLEDPATCHES); + PATCHMAPJSON = reader.Get("shard", "patchmapdata", PATCHMAPJSON); ACCLEVEL = reader.GetInteger("shard", "accountlevel", ACCLEVEL); EVENTMODE = reader.GetInteger("shard", "eventmode", EVENTMODE); DISABLEFIRSTUSEFLAG = reader.GetBoolean("shard", "disablefirstuseflag", DISABLEFIRSTUSEFLAG); diff --git a/src/settings.hpp b/src/settings.hpp index 1ea3a43..c226aba 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -29,7 +29,8 @@ namespace settings { extern std::string GRUNTWORKJSON; extern std::string DBPATH; extern std::string PATCHDIR; - extern std::string ENABLEDPATCHES; + extern std::string PATCHMAPJSON; + extern std::string BUILDNAME; extern std::string TDATADIR; extern int EVENTMODE; extern bool MONITORENABLED;