From e3956a0a09084ba642dc1071b56d9d79b70fbaa5 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Tue, 14 Nov 2023 12:24:59 -0800 Subject: [PATCH] improve specialized box log messages --- src/ItemCreator.cc | 3 +++ src/ItemCreator.hh | 2 ++ src/Map.cc | 16 ++++++++++++---- src/Map.hh | 3 ++- src/ReceiveCommands.cc | 2 +- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/ItemCreator.cc b/src/ItemCreator.cc index f95a031c..f20aa235 100644 --- a/src/ItemCreator.cc +++ b/src/ItemCreator.cc @@ -1658,7 +1658,10 @@ ItemData ItemCreator::on_specialized_box_item_drop(uint16_t entity_id, uint32_t if (!this->destroyed_boxes.emplace(entity_id).second) { return ItemData(); } + return this->item_for_specialized_box(def0, def1, def2); +} +ItemData ItemCreator::item_for_specialized_box(uint32_t def0, uint32_t def1, uint32_t def2) { ItemData item; item.data1[0] = (def0 >> 0x18) & 0x0F; item.data1[1] = (def0 >> 0x10) + ((item.data1[0] == 0x00) || (item.data1[0] == 0x01)); diff --git a/src/ItemCreator.hh b/src/ItemCreator.hh index 4c8353ca..ab469d72 100644 --- a/src/ItemCreator.hh +++ b/src/ItemCreator.hh @@ -34,6 +34,8 @@ public: ItemData on_box_item_drop(uint16_t entity_id, uint8_t area); ItemData on_specialized_box_item_drop(uint16_t entity_id, uint32_t def0, uint32_t def1, uint32_t def2); + static ItemData item_for_specialized_box(uint32_t def0, uint32_t def1, uint32_t def2); + std::vector generate_armor_shop_contents(size_t player_level); std::vector generate_tool_shop_contents(size_t player_level); std::vector generate_weapon_shop_contents(size_t player_level); diff --git a/src/Map.cc b/src/Map.cc index 3149ada8..16884dba 100644 --- a/src/Map.cc +++ b/src/Map.cc @@ -4,6 +4,7 @@ #include #include +#include "ItemCreator.hh" #include "Loggers.hh" #include "PSOEncryption.hh" #include "Quest.hh" @@ -25,10 +26,17 @@ string Map::Enemy::str() const { name_for_enum(this->type), this->flags, this->last_hit_by_client_id); } -string Map::Object::str() const { - return string_printf("[Map::Object %04hX @%04hX p1=%g (%s) p456=[%08" PRIX32 " %08" PRIX32 " %08" PRIX32 "] floor=%02hhX item_drop_checked=%s]", - this->base_type, this->section, this->param1, (this->param1 <= 0.0f) ? "specialized" : "generic", - this->param4, this->param5, this->param6, this->floor, this->item_drop_checked ? "true" : "false"); +string Map::Object::str(shared_ptr name_index) const { + if (this->param1 <= 0.0f) { + auto item = ItemCreator::item_for_specialized_box(this->param4, this->param5, this->param6); + string item_name = name_index ? name_index->describe_item(GameVersion::BB, item) : item.hex(); + return string_printf("[Map::Object %04hX @%04hX p1=%g (specialized: %s) floor=%02hhX item_drop_checked=%s]", + this->base_type, this->section, this->param1, item_name.c_str(), this->floor, this->item_drop_checked ? "true" : "false"); + } else { + return string_printf("[Map::Object %04hX @%04hX p1=%g (generic) p456=[%08" PRIX32 " %08" PRIX32 " %08" PRIX32 "] floor=%02hhX item_drop_checked=%s]", + this->base_type, this->section, this->param1, this->param4, this->param5, this->param6, + this->floor, this->item_drop_checked ? "true" : "false"); + } } void Map::clear() { diff --git a/src/Map.hh b/src/Map.hh index 141ec9ac..42ce490f 100644 --- a/src/Map.hh +++ b/src/Map.hh @@ -9,6 +9,7 @@ #include #include "BattleParamsIndex.hh" +#include "ItemNameIndex.hh" #include "PSOEncryption.hh" #include "StaticGameData.hh" #include "Text.hh" @@ -204,7 +205,7 @@ struct Map { uint8_t floor; bool item_drop_checked; - std::string str() const; + std::string str(std::shared_ptr name_index) const; }; struct Enemy { diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index b9e6cfb9..b0459c17 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -3777,7 +3777,7 @@ shared_ptr create_game_generic( size_t entries_loaded = game->map->objects.size() - start_offset; c->log.info("[Map/%zu:o] Loaded %s (%zu entries)", floor, filename.c_str(), entries_loaded); for (size_t z = start_offset; z < game->map->objects.size(); z++) { - string e_str = game->map->objects[z].str(); + string e_str = game->map->objects[z].str(s->item_name_index); static_game_data_log.info("(K-%zX) %s", z, e_str.c_str()); } any_map_loaded = true;