support decompressed card text archives
This commit is contained in:
@@ -1817,13 +1817,22 @@ uint8_t Rules::max_def_dice() const {
|
||||
return this->def_dice_range & 0x0F;
|
||||
}
|
||||
|
||||
CardIndex::CardIndex(const string& filename, const string& decompressed_filename, const string& text_filename) {
|
||||
CardIndex::CardIndex(
|
||||
const string& filename,
|
||||
const string& decompressed_filename,
|
||||
const string& text_filename,
|
||||
const string& decompressed_text_filename) {
|
||||
unordered_map<uint32_t, vector<string>> card_tags;
|
||||
unordered_map<uint32_t, string> card_text;
|
||||
if (!text_filename.empty()) {
|
||||
try {
|
||||
string data = prs_decompress(load_file(text_filename));
|
||||
StringReader r(data);
|
||||
try {
|
||||
string text_bin_data;
|
||||
if (!decompressed_text_filename.empty() && isfile(decompressed_text_filename)) {
|
||||
text_bin_data = load_file(decompressed_text_filename);
|
||||
} else if (!text_filename.empty() && isfile(text_filename)) {
|
||||
text_bin_data = prs_decompress(load_file(text_filename));
|
||||
}
|
||||
if (!text_bin_data.empty()) {
|
||||
StringReader r(text_bin_data);
|
||||
|
||||
while (!r.eof()) {
|
||||
string card_id_str = r.get_cstr();
|
||||
@@ -1905,10 +1914,9 @@ CardIndex::CardIndex(const string& filename, const string& decompressed_filename
|
||||
|
||||
r.go((r.where() + 0x3FF) & (~0x3FF));
|
||||
}
|
||||
|
||||
} catch (const exception& e) {
|
||||
static_game_data_log.warning("Failed to load card text: %s", e.what());
|
||||
}
|
||||
} catch (const exception& e) {
|
||||
static_game_data_log.warning("Failed to load card text: %s", e.what());
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -1304,7 +1304,11 @@ struct COMDeckDefinition {
|
||||
|
||||
class CardIndex {
|
||||
public:
|
||||
CardIndex(const std::string& filename, const std::string& decompressed_filename, const std::string& text_filename = "");
|
||||
CardIndex(
|
||||
const std::string& filename,
|
||||
const std::string& decompressed_filename,
|
||||
const std::string& text_filename = "",
|
||||
const std::string& deecompressed_text_filename = "");
|
||||
|
||||
struct CardEntry {
|
||||
CardDefinition def;
|
||||
|
||||
+2
-2
@@ -1642,7 +1642,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
case Behavior::SHOW_EP3_CARDS: {
|
||||
Episode3::CardIndex card_index("system/ep3/card-definitions.mnr", "system/ep3/card-definitions.mnrd", "system/ep3/card-text.mnr");
|
||||
Episode3::CardIndex card_index("system/ep3/card-definitions.mnr", "system/ep3/card-definitions.mnrd", "system/ep3/card-text.mnr", "system/ep3/card-text.mnrd");
|
||||
|
||||
auto card_ids = card_index.all_ids();
|
||||
log_info("%zu card definitions", card_ids.size());
|
||||
@@ -1664,7 +1664,7 @@ int main(int argc, char** argv) {
|
||||
case Behavior::SHOW_EP3_MAPS: {
|
||||
config_log.info("Collecting Episode 3 data");
|
||||
Episode3::MapIndex map_index("system/ep3");
|
||||
Episode3::CardIndex card_index("system/ep3/card-definitions.mnr", "system/ep3/card-definitions.mnrd", "system/ep3/card-text.mnr");
|
||||
Episode3::CardIndex card_index("system/ep3/card-definitions.mnr", "system/ep3/card-definitions.mnrd", "system/ep3/card-text.mnr", "system/ep3/card-text.mnrd");
|
||||
|
||||
auto map_ids = map_index.all_numbers();
|
||||
log_info("%zu maps", map_ids.size());
|
||||
|
||||
+2
-2
@@ -888,9 +888,9 @@ void ServerState::load_ep3_data() {
|
||||
config_log.info("Collecting Episode 3 maps");
|
||||
this->ep3_map_index.reset(new Episode3::MapIndex("system/ep3"));
|
||||
config_log.info("Loading Episode 3 card definitions");
|
||||
this->ep3_card_index.reset(new Episode3::CardIndex("system/ep3/card-definitions.mnr", "system/ep3/card-definitions.mnrd", "system/ep3/card-text.mnr"));
|
||||
this->ep3_card_index.reset(new Episode3::CardIndex("system/ep3/card-definitions.mnr", "system/ep3/card-definitions.mnrd", "system/ep3/card-text.mnr", "system/ep3/card-text.mnrd"));
|
||||
config_log.info("Loading Episode 3 trial card definitions");
|
||||
this->ep3_card_index_trial.reset(new Episode3::CardIndex("system/ep3/card-definitions-trial.mnr", "system/ep3/card-definitions-trial.mnrd", "system/ep3/card-text-trial.mnr"));
|
||||
this->ep3_card_index_trial.reset(new Episode3::CardIndex("system/ep3/card-definitions-trial.mnr", "system/ep3/card-definitions-trial.mnrd", "system/ep3/card-text-trial.mnr", "system/ep3/card-text-trial.mnrd"));
|
||||
config_log.info("Loading Episode 3 COM decks");
|
||||
this->ep3_com_deck_index.reset(new Episode3::COMDeckIndex("system/ep3/com-decks.json"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user