implement server drop tables

This commit is contained in:
Martin Michelsen
2023-10-16 23:10:13 -07:00
parent d66c1f5de9
commit 08a1bf3238
13 changed files with 9132 additions and 42 deletions
+35 -9
View File
@@ -861,15 +861,41 @@ void ServerState::load_level_table() {
}
void ServerState::load_item_tables() {
try {
config_log.info("Loading JSON rare item table");
auto json = JSON::parse(load_file("system/blueburst/rare-table.json"));
this->rare_item_set.reset(new JSONRareItemSet(json));
} catch (const exception& e) {
config_log.info("Failed to load JSON rare item table: %s", e.what());
config_log.info("Loading REL rare item table");
this->rare_item_set.reset(new RELRareItemSet(
this->load_bb_file("ItemRT.rel")));
config_log.info("Loading rare item sets");
for (const auto& filename : list_directory_sorted("system/rare-tables")) {
string path = "system/rare-tables/" + filename;
size_t ext_offset = filename.rfind('.');
string basename = (ext_offset == string::npos) ? filename : filename.substr(0, ext_offset);
if (ends_with(filename, ".json")) {
config_log.info("Loading JSON rare item table %s", filename.c_str());
this->rare_item_sets.emplace(basename, new JSONRareItemSet(JSON::parse(load_file(path))));
} else if (ends_with(filename, ".afs")) {
config_log.info("Loading AFS rare item table %s", filename.c_str());
shared_ptr<string> data(new string(load_file(path)));
this->rare_item_sets.emplace(basename, new AFSRareItemSet(data));
} else if (ends_with(filename, ".gsl")) {
config_log.info("Loading GSL rare item table %s", filename.c_str());
shared_ptr<string> data(new string(load_file(path)));
this->rare_item_sets.emplace(basename, new GSLRareItemSet(data, false));
} else if (ends_with(filename, ".gslb")) {
config_log.info("Loading GSL rare item table %s", filename.c_str());
shared_ptr<string> data(new string(load_file(path)));
this->rare_item_sets.emplace(basename, new GSLRareItemSet(data, true));
} else if (ends_with(filename, ".reg")) {
config_log.info("Loading REL rare item table %s", filename.c_str());
shared_ptr<string> data(new string(load_file(path)));
this->rare_item_sets.emplace(basename, new RELRareItemSet(data));
}
}
if (!this->rare_item_sets.count("default-v4")) {
config_log.info("default-v4 rare item set is not available; loading from BB data");
this->rare_item_sets.emplace("default-v4", new RELRareItemSet(this->load_bb_file("ItemRT.rel")));
}
// Note: These files don't exist in BB, so we use the GC versions of them