mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-25 06:20:14 +00:00
Compare commits
3 Commits
a9af8713bc
...
8eb1af20c8
Author | SHA1 | Date | |
---|---|---|---|
8eb1af20c8 | |||
e73daa0865 | |||
743a39c125 |
@ -662,6 +662,8 @@ static void loadEggs(json& eggData, int32_t* nextId) {
|
|||||||
* Load gruntwork output, if it exists
|
* Load gruntwork output, if it exists
|
||||||
*/
|
*/
|
||||||
static void loadGruntworkPre(json& gruntwork, int32_t* nextId) {
|
static void loadGruntworkPre(json& gruntwork, int32_t* nextId) {
|
||||||
|
if (gruntwork.is_null())
|
||||||
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto paths = gruntwork["paths"];
|
auto paths = gruntwork["paths"];
|
||||||
@ -711,8 +713,8 @@ static void loadGruntworkPre(json& gruntwork, int32_t* nextId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void loadGruntworkPost(json& gruntwork, int32_t* nextId) {
|
static void loadGruntworkPost(json& gruntwork, int32_t* nextId) {
|
||||||
|
if (gruntwork.is_null())
|
||||||
if (gruntwork.is_null()) return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// skyway paths
|
// skyway paths
|
||||||
@ -1070,19 +1072,39 @@ void TableData::init() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// load JSON data into tables
|
// load JSON data into tables
|
||||||
std::ifstream fstream;
|
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
std::pair<json*, std::string>& table = tables[i];
|
std::pair<json*, std::string>& table = tables[i];
|
||||||
fstream.open(settings::TDATADIR + "/" + table.second); // open file
|
|
||||||
if (!fstream.fail()) {
|
// scope for fstream
|
||||||
fstream >> *table.first; // load file contents into table
|
{
|
||||||
} else {
|
std::ifstream fstream;
|
||||||
if (table.first != &gruntwork) { // gruntwork isn't critical
|
fstream.open(settings::TDATADIR + "/" + table.second); // open file
|
||||||
|
|
||||||
|
// did we fail to open the file?
|
||||||
|
if (fstream.fail()) {
|
||||||
|
// gruntwork isn't critical
|
||||||
|
if (table.first == &gruntwork)
|
||||||
|
continue;
|
||||||
|
|
||||||
std::cerr << "[FATAL] Critical tdata file missing: " << table.second << std::endl;
|
std::cerr << "[FATAL] Critical tdata file missing: " << table.second << std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// is the file empty?
|
||||||
|
if (fstream.peek() == std::ifstream::traits_type::eof()) {
|
||||||
|
// tolerate empty gruntwork file
|
||||||
|
if (table.first == &gruntwork) {
|
||||||
|
std::cout << "[WARN] The gruntwork file is empty" << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "[FATAL] Critical tdata file is empty: " << table.second << std::endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load file contents into table
|
||||||
|
fstream >> *table.first;
|
||||||
}
|
}
|
||||||
fstream.close();
|
|
||||||
|
|
||||||
// patching: load each patch directory specified in the config file
|
// patching: load each patch directory specified in the config file
|
||||||
|
|
||||||
@ -1097,11 +1119,11 @@ void TableData::init() {
|
|||||||
std::string patchModuleName = *it;
|
std::string patchModuleName = *it;
|
||||||
std::string patchFile = settings::PATCHDIR + patchModuleName + "/" + table.second;
|
std::string patchFile = settings::PATCHDIR + patchModuleName + "/" + table.second;
|
||||||
try {
|
try {
|
||||||
|
std::ifstream fstream;
|
||||||
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;
|
std::cout << "[INFO] Patching " << patchFile << std::endl;
|
||||||
patchJSON(table.first, &patch); // patch
|
patchJSON(table.first, &patch); // patch
|
||||||
fstream.close();
|
|
||||||
} catch (const std::exception& err) {
|
} catch (const std::exception& err) {
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user