diff --git a/src/BattleParamsIndex.cc b/src/BattleParamsIndex.cc index b05f8f9c..385a8b53 100644 --- a/src/BattleParamsIndex.cc +++ b/src/BattleParamsIndex.cc @@ -9,10 +9,17 @@ using namespace std; -void BattleParamsIndex::Table::print(FILE* stream) const { - auto print_entry = +[](FILE* stream, const PlayerStats& e) { +void BattleParamsIndex::Table::print(FILE* stream, Episode episode) const { + auto print_entry = [stream, episode](const PlayerStats& e, size_t z) { + string names_str; + for (auto type : enemy_types_for_battle_param_index(episode, z)) { + if (!names_str.empty()) { + names_str += ", "; + } + names_str += phosg::name_for_enum(type); + } phosg::fwrite_fmt(stream, - "{:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5}", + "{:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {:5} {}", e.char_stats.atp, e.char_stats.mst, e.char_stats.evp, @@ -22,15 +29,16 @@ void BattleParamsIndex::Table::print(FILE* stream) const { e.char_stats.lck, e.esp, e.experience, - e.meseta); + e.meseta, + names_str); }; for (size_t diff = 0; diff < 4; diff++) { - phosg::fwrite_fmt(stream, "{} ZZ ATP PSV EVP HP DFP ATA LCK ESP EXP DIFF\n", + phosg::fwrite_fmt(stream, "{} ZZ ATP PSV EVP HP DFP ATA LCK ESP EXP DIFF NAMES\n", abbreviation_for_difficulty(diff)); for (size_t z = 0; z < 0x60; z++) { phosg::fwrite_fmt(stream, " {:02X} ", z); - print_entry(stream, this->stats[diff][z]); + print_entry(this->stats[diff][z], z); fputc('\n', stream); } } diff --git a/src/BattleParamsIndex.hh b/src/BattleParamsIndex.hh index fb4e0390..5db027f6 100644 --- a/src/BattleParamsIndex.hh +++ b/src/BattleParamsIndex.hh @@ -76,7 +76,7 @@ public: /* AE00 */ parray, 4> movement_data; /* F600 */ - void print(FILE* stream) const; + void print(FILE* stream, Episode episode) const; } __packed_ws__(Table, 0xF600); BattleParamsIndex( diff --git a/src/EnemyType.cc b/src/EnemyType.cc index 2037c34f..d2ef8cb2 100644 --- a/src/EnemyType.cc +++ b/src/EnemyType.cc @@ -198,6 +198,33 @@ const vector& enemy_types_for_rare_table_index(Episode episode, uint8 } } +const vector& enemy_types_for_battle_param_index(Episode episode, uint8_t bp_index) { + const auto& generate_table = +[](Episode episode) -> vector> { + vector> ret; + for (const auto& def : type_defs) { + if (def.valid_in_episode(episode) && (def.bp_index != 0xFF)) { + if (def.bp_index >= ret.size()) { + ret.resize(def.bp_index + 1); + } + ret[def.bp_index].emplace_back(def.type); + } + } + return ret; + }; + + static array>, 5> data; + auto& ret = data.at(static_cast(episode)); + if (ret.empty()) { + ret = generate_table(episode); + } + try { + return ret.at(bp_index); + } catch (const out_of_range&) { + static const vector empty_vec; + return empty_vec; + } +} + EnemyType EnemyTypeDefinition::rare_type(Episode episode, uint8_t event, uint8_t floor) const { switch (this->type) { case EnemyType::HILDEBEAR: diff --git a/src/EnemyType.hh b/src/EnemyType.hh index 43ddd142..bf824d52 100644 --- a/src/EnemyType.hh +++ b/src/EnemyType.hh @@ -181,3 +181,4 @@ template <> EnemyType phosg::enum_for_name(const char* name); const std::vector& enemy_types_for_rare_table_index(Episode episode, uint8_t rt_index); +const std::vector& enemy_types_for_battle_param_index(Episode episode, uint8_t bp_index); diff --git a/src/Main.cc b/src/Main.cc index 23249ed4..6a02f5f4 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -2809,17 +2809,17 @@ Action a_show_battle_params( s->load_battle_params(); phosg::fwrite_fmt(stdout, "Episode 1 multi\n"); - s->battle_params->get_table(false, Episode::EP1).print(stdout); + s->battle_params->get_table(false, Episode::EP1).print(stdout, Episode::EP1); phosg::fwrite_fmt(stdout, "Episode 1 solo\n"); - s->battle_params->get_table(true, Episode::EP1).print(stdout); + s->battle_params->get_table(true, Episode::EP1).print(stdout, Episode::EP1); phosg::fwrite_fmt(stdout, "Episode 2 multi\n"); - s->battle_params->get_table(false, Episode::EP2).print(stdout); + s->battle_params->get_table(false, Episode::EP2).print(stdout, Episode::EP2); phosg::fwrite_fmt(stdout, "Episode 2 solo\n"); - s->battle_params->get_table(true, Episode::EP2).print(stdout); + s->battle_params->get_table(true, Episode::EP2).print(stdout, Episode::EP2); phosg::fwrite_fmt(stdout, "Episode 4 multi\n"); - s->battle_params->get_table(false, Episode::EP4).print(stdout); + s->battle_params->get_table(false, Episode::EP4).print(stdout, Episode::EP4); phosg::fwrite_fmt(stdout, "Episode 4 solo\n"); - s->battle_params->get_table(true, Episode::EP4).print(stdout); + s->battle_params->get_table(true, Episode::EP4).print(stdout, Episode::EP4); }); Action a_check_supermaps( diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index 9de683ee..9f1f12dd 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -2252,8 +2252,7 @@ static asio::awaitable on_pick_up_item_generic( // This can happen if the network is slow, and the client tries to pick up // the same item multiple times. Or multiple clients could try to pick up // the same item at approximately the same time; only one should get it. - l->log.warning_f("Player {} requests to pick up {:08X}, but the item does not exist; dropping command", - client_id, item_id); + l->log.warning_f("Player {} requests to pick up {:08X}, but the item does not exist; dropping command", client_id, item_id); } else { // This is handled by the server on BB, and by the leader on other versions. @@ -2300,8 +2299,7 @@ static asio::awaitable on_pick_up_item_generic( } } - if (!c->login->account->check_user_flag(Account::UserFlag::DISABLE_DROP_NOTIFICATION_BROADCAST) && - (fi->flags & 0x1000)) { + if (!c->login->account->check_user_flag(Account::UserFlag::DISABLE_DROP_NOTIFICATION_BROADCAST) && (fi->flags & 0x1000)) { uint32_t pi = fi->data.primary_identifier(); bool should_send_game_notif, should_send_global_notif; if (is_v1_or_v2(c->version()) && (c->version() != Version::GC_NTE)) {