mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 05:20:05 +00:00
[refac] Clean up new tdata init routine
This commit is contained in:
parent
e546d3948c
commit
183586afe4
@ -928,12 +928,10 @@ static void loadMobs(json& npcData, int32_t* nextId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadingError(const char* which) {
|
/*
|
||||||
std::cerr << "[FATAL] Critical tdata file missing: " << which << std::endl;
|
* Iterate through the fields of every TLO in `patch` and modify `base` accordingly.
|
||||||
exit(1);
|
*/
|
||||||
}
|
static void patch(json& base, json &patch) {
|
||||||
|
|
||||||
static void patch(json& base, json patch) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -942,40 +940,31 @@ void TableData::init() {
|
|||||||
|
|
||||||
// base JSON tables
|
// base JSON tables
|
||||||
json xdt, paths, drops, eggs, npcs, mobs, gruntwork;
|
json xdt, paths, drops, eggs, npcs, mobs, gruntwork;
|
||||||
|
std::pair<json*, std::string> tables[7] = {
|
||||||
|
std::make_pair(&xdt, settings::XDTJSON), // 0
|
||||||
|
std::make_pair(&paths, settings::PATHJSON), // 1
|
||||||
|
std::make_pair(&drops, settings::DROPSJSON), // 2
|
||||||
|
std::make_pair(&eggs, settings::EGGSJSON), // 3
|
||||||
|
std::make_pair(&npcs, settings::NPCJSON), // 4
|
||||||
|
std::make_pair(&mobs, settings::MOBJSON), // 5
|
||||||
|
std::make_pair(&gruntwork, settings::GRUNTWORKJSON) // 6
|
||||||
|
};
|
||||||
|
|
||||||
// open file streams
|
// load JSON data into tables
|
||||||
std::ifstream fXDT(settings::XDTJSON);
|
std::ifstream fstream;
|
||||||
std::ifstream fPaths(settings::PATHJSON);
|
for (int i = 0; i < 7; i++) {
|
||||||
std::ifstream fDrops(settings::DROPSJSON);
|
std::pair<json*, std::string>& table = tables[i];
|
||||||
std::ifstream fEggs(settings::EGGSJSON);
|
fstream.open(table.second); // open file
|
||||||
std::ifstream fNPCs(settings::NPCJSON);
|
if (!fstream.fail()) {
|
||||||
std::ifstream fMobs(settings::MOBJSON);
|
fstream >> *table.first; // load file contents into table
|
||||||
std::ifstream fGruntwork(settings::GRUNTWORKJSON);
|
} else {
|
||||||
|
if (i != 6) { // gruntwork isn't critical
|
||||||
if (fXDT.fail()) loadingError("XDT.json");
|
std::cerr << "[FATAL] Critical tdata file missing: " << table.second << std::endl;
|
||||||
if (fPaths.fail()) loadingError("paths.json");
|
exit(1);
|
||||||
if (fDrops.fail()) loadingError("drops.json");
|
}
|
||||||
if (fEggs.fail()) loadingError("eggs.json");
|
}
|
||||||
if (fNPCs.fail()) loadingError("NPCs.json");
|
fstream.close();
|
||||||
if (fMobs.fail()) loadingError("mobs.json");
|
}
|
||||||
|
|
||||||
// read contents into json tables
|
|
||||||
fXDT >> xdt;
|
|
||||||
fPaths >> paths;
|
|
||||||
fDrops >> drops;
|
|
||||||
fEggs >> eggs;
|
|
||||||
fNPCs >> npcs;
|
|
||||||
fMobs >> mobs;
|
|
||||||
if (!fGruntwork.fail()) fGruntwork >> gruntwork;
|
|
||||||
|
|
||||||
// close file streams
|
|
||||||
fXDT.close();
|
|
||||||
fPaths.close();
|
|
||||||
fDrops.close();
|
|
||||||
fEggs.close();
|
|
||||||
fNPCs.close();
|
|
||||||
fMobs.close();
|
|
||||||
fGruntwork.close();
|
|
||||||
|
|
||||||
// patching
|
// patching
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user