From 712cfc9ac4e02e94fa00b33a1f5396f7857a3d32 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Mon, 10 Nov 2025 22:56:23 -0800 Subject: [PATCH] fix JSON common table parser --- src/CommonItemSet.cc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/CommonItemSet.cc b/src/CommonItemSet.cc index 00551f67..aa1661b6 100644 --- a/src/CommonItemSet.cc +++ b/src/CommonItemSet.cc @@ -122,20 +122,19 @@ CommonItemSet::Table::Table(const phosg::JSON& json, Episode episode) const auto& enemy_type_drop_probs_json = json.at("EnemyTypeDropProbs").as_dict(); const auto& enemy_item_classes_json = json.at("EnemyItemClasses").as_dict(); for (size_t z = 0; z < 0x64; z++) { - for (Episode episode : ALL_EPISODES_V4) { - auto types = enemy_types_for_rare_table_index(episode, z); - vector names; - if (types.empty()) { - names.emplace_back(std::format("{}:!{:02X}", abbreviation_for_episode(episode), z)); - } - for (auto type : enemy_types_for_rare_table_index(episode, z)) { + auto types = enemy_types_for_rare_table_index(episode, z); + vector names; + if (types.empty()) { + names.emplace_back(std::format("{}:!{:02X}", abbreviation_for_episode(episode), z)); + } else { + for (auto type : types) { names.emplace_back(std::format("{}:{}", abbreviation_for_episode(episode), phosg::name_for_enum(type))); } - for (const auto& name : names) { - from_json_into(*enemy_meseta_ranges_json.at(name), this->enemy_meseta_ranges[z]); - this->enemy_type_drop_probs[z] = enemy_type_drop_probs_json.at(name)->as_int(); - this->enemy_item_classes[z] = enemy_item_classes_json.at(name)->as_int(); - } + } + for (const auto& name : names) { + from_json_into(*enemy_meseta_ranges_json.at(name), this->enemy_meseta_ranges[z]); + this->enemy_type_drop_probs[z] = enemy_type_drop_probs_json.at(name)->as_int(); + this->enemy_item_classes[z] = enemy_item_classes_json.at(name)->as_int(); } } }