From 6a35471b46602000480d78e87b337b922ea91ed0 Mon Sep 17 00:00:00 2001 From: murilo09 <78226931+murilo09@users.noreply.github.com> Date: Wed, 30 Oct 2024 02:36:36 -0300 Subject: [PATCH] fix load house logic --- src/game/game.cpp | 8 +++----- src/game/game.hpp | 2 +- src/io/iomapserialize.cpp | 11 +++++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index eaaffb05059..915128d6388 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -10904,12 +10904,11 @@ void Game::playerCyclopediaHouseMoveOut(uint32_t playerId, uint32_t houseId, uin } const auto house = g_game().map.houses.getHouseByClientId(houseId); - if (!house || house->getOwner() != player->getGUID()) { + if (!house || house->getOwner() != player->getGUID() || house->getState() != 2) { return; } house->setBidEndDate(timestamp); - house->setBidder(-1); house->setState(4); playerCyclopediaHousesByTown(playerId, ""); @@ -10926,18 +10925,17 @@ void Game::playerCyclopediaHouseCancelMoveOut(uint32_t playerId, uint32_t houseI } const auto house = g_game().map.houses.getHouseByClientId(houseId); - if (!house || house->getOwner() != player->getGUID()) { + if (!house || house->getOwner() != player->getGUID() || house->getState() != 4) { return; } house->setBidEndDate(0); - house->setBidder(0); house->setState(2); playerCyclopediaHousesByTown(playerId, ""); } -bool Game::processBankAuction(std::shared_ptr player, std::shared_ptr house, uint64_t bid, bool replace /* = false*/) { +bool Game::processBankAuction(std::shared_ptr player, const std::shared_ptr &house, uint64_t bid, bool replace /* = false*/) { if (!replace && player->getBankBalance() < (house->getRent() + bid)) { return false; } diff --git a/src/game/game.hpp b/src/game/game.hpp index 99790ce2f67..a631619f7ae 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -320,7 +320,7 @@ class Game { void playerCyclopediaHouseBid(uint32_t playerId, uint32_t houseId, uint64_t bidValue); void playerCyclopediaHouseMoveOut(uint32_t playerId, uint32_t houseId, uint32_t timestamp); void playerCyclopediaHouseCancelMoveOut(uint32_t playerId, uint32_t houseId); - bool processBankAuction(std::shared_ptr player, std::shared_ptr house, uint64_t bid, bool replace = false); + bool processBankAuction(std::shared_ptr player, const std::shared_ptr &house, uint64_t bid, bool replace = false); void updatePlayerSaleItems(uint32_t playerId); diff --git a/src/io/iomapserialize.cpp b/src/io/iomapserialize.cpp index ef6fb1beee4..562aa02a0d7 100644 --- a/src/io/iomapserialize.cpp +++ b/src/io/iomapserialize.cpp @@ -300,25 +300,25 @@ bool IOMapSerialize::loadHouseInfo() { g_logger().debug("Setting house id '{}' owner to player GUID '{}'", houseId, newOwner); house->setOwner(newOwner); } - } else if (state == 0 && bidder > 0 && timeNow > bidEndDate) { + } else if (state == 0 && timeNow > bidEndDate && bidder > 0) { // Available + g_logger().debug("[BID] - Setting house id '{}' owner to player GUID '{}'", houseId, bidder); if (highestBid < internalBid) { uint32_t diff = internalBid - highestBid; IOLoginData::increaseBankBalance(bidder, diff); } - g_logger().debug("Setting house id '{}' owner to player GUID '{}'", houseId, bidder); house->setOwner(bidder); bidder = 0; bidderName = ""; highestBid = 0; internalBid = 0; bidEndDate = 0; - } else if (state == 2 && bidder == -1 && timeNow > bidEndDate) { - g_logger().debug("Removing house id '{}' owner", houseId); + } else if (state == 4 && timeNow > bidEndDate) { // Move Out + g_logger().debug("[MOVE OUT] - Removing house id '{}' owner", houseId); house->setOwner(0); bidEndDate = 0; - bidder = 0; } else { house->setOwner(owner, false); + house->setState(state); } house->setBidder(bidder); house->setBidderName(bidderName); @@ -326,7 +326,6 @@ bool IOMapSerialize::loadHouseInfo() { house->setInternalBid(internalBid); house->setBidHolderLimit(internalBid); house->setBidEndDate(bidEndDate); - house->setState(state); } } while (result->next());