From 5639c1b4e51ba583494a9d68652c2fa209ecd4d2 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Sat, 24 Feb 2024 19:00:39 -0300 Subject: [PATCH] fix: transfer items house on server startup (#2316) Resolves #2312 --- src/game/scheduling/save_manager.cpp | 8 ++++++-- src/io/iomapserialize.cpp | 5 +++-- src/items/item.cpp | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/game/scheduling/save_manager.cpp b/src/game/scheduling/save_manager.cpp index 6e8b76050ad..2c1eff6657c 100644 --- a/src/game/scheduling/save_manager.cpp +++ b/src/game/scheduling/save_manager.cpp @@ -59,7 +59,9 @@ void SaveManager::schedulePlayer(std::weak_ptr playerPtr) { // Disable save async if the config is set to false if (!g_configManager().getBoolean(TOGGLE_SAVE_ASYNC, __FUNCTION__)) { - logger.debug("Saving player {}.", playerToSave->getName()); + if (g_game().getGameState() == GAME_STATE_NORMAL) { + logger.debug("Saving player {}.", playerToSave->getName()); + } doSavePlayer(playerToSave); return; } @@ -90,7 +92,9 @@ bool SaveManager::doSavePlayer(std::shared_ptr player) { Benchmark bm_savePlayer; Player::PlayerLock lock(player); m_playerMap.erase(player->getGUID()); - logger.debug("Saving player {}...", player->getName()); + if (g_game().getGameState() == GAME_STATE_NORMAL) { + logger.debug("Saving player {}.", player->getName()); + } bool saveSuccess = IOLoginData::savePlayer(player); if (!saveSuccess) { diff --git a/src/io/iomapserialize.cpp b/src/io/iomapserialize.cpp index a0ac392d955..475a210a760 100644 --- a/src/io/iomapserialize.cpp +++ b/src/io/iomapserialize.cpp @@ -47,8 +47,9 @@ void IOMapSerialize::loadHouseItems(Map* map) { while (item_count--) { if (auto houseTile = std::dynamic_pointer_cast(tile)) { - const auto house = houseTile->getHouse(); - if (house->getOwner() == 0) { + const auto &house = houseTile->getHouse(); + auto isTransferOnRestart = g_configManager().getBoolean(TOGGLE_HOUSE_TRANSFER_ON_SERVER_RESTART, __FUNCTION__); + if (!isTransferOnRestart && house->getOwner() == 0) { g_logger().trace("Skipping load item from house id: {}, position: {}, house does not have owner", house->getId(), house->getEntryPosition().toString()); house->clearHouseInfo(false); continue; diff --git a/src/items/item.cpp b/src/items/item.cpp index d937f2c7bd4..b51c076d80b 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -831,7 +831,7 @@ Attr_ReadValue Item::readAttr(AttrTypes_t attr, PropStream &propStream) { return ATTR_READ_ERROR; } - g_logger().debug("Setting flag {} flags, to item id {}", flags, getID()); + g_logger().trace("Setting obtain flag {} flags, to item id {}", flags, getID()); setAttribute(ItemAttribute_t::OBTAINCONTAINER, flags); break; }