Compare commits

..

No commits in common. "8eb1af20c889bb838941e4f1cd85a7eca588b124" and "a9af8713bc1f5bd1b50e1b6b0a2dd32889e57be4" have entirely different histories.

View File

@ -662,8 +662,6 @@ static void loadEggs(json& eggData, int32_t* nextId) {
* Load gruntwork output, if it exists
*/
static void loadGruntworkPre(json& gruntwork, int32_t* nextId) {
if (gruntwork.is_null())
return;
try {
auto paths = gruntwork["paths"];
@ -713,8 +711,8 @@ static void loadGruntworkPre(json& gruntwork, int32_t* nextId) {
}
static void loadGruntworkPost(json& gruntwork, int32_t* nextId) {
if (gruntwork.is_null())
return;
if (gruntwork.is_null()) return;
try {
// skyway paths
@ -1072,39 +1070,19 @@ void TableData::init() {
};
// load JSON data into tables
std::ifstream fstream;
for (int i = 0; i < 7; i++) {
std::pair<json*, std::string>& table = tables[i];
// scope for fstream
{
std::ifstream fstream;
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;
if (!fstream.fail()) {
fstream >> *table.first; // load file contents into table
} else {
if (table.first != &gruntwork) { // gruntwork isn't critical
std::cerr << "[FATAL] Critical tdata file missing: " << table.second << std::endl;
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
@ -1119,11 +1097,11 @@ void TableData::init() {
std::string patchModuleName = *it;
std::string patchFile = settings::PATCHDIR + patchModuleName + "/" + table.second;
try {
std::ifstream fstream;
fstream.open(patchFile);
fstream >> patch; // load into temporary json object
std::cout << "[INFO] Patching " << patchFile << std::endl;
patchJSON(table.first, &patch); // patch
fstream.close();
} catch (const std::exception& err) {
// no-op
}