diff --git a/src/game/game.cpp b/src/game/game.cpp index 7a054bf71c9..3ae30da8468 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -10905,39 +10905,7 @@ 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; - if (!house || house->getOwner() != player->getGUID() || house->getState() != 2) { - return; - } - - house->setBidEndDate(timestamp); - house->setState(4); - - playerCyclopediaHousesByTown(playerId, ""); - } - - void Game::playerCyclopediaHouseCancelMoveOut(uint32_t playerId, uint32_t houseId) { - if (!g_configManager().getBoolean(CYCLOPEDIA_HOUSE_AUCTION)) { - return; - } - - std::shared_ptr player = getPlayerByID(playerId); - if (!player) { - return; - } - - const auto house = g_game().map.houses.getHouseByClientId(houseId); - if (!house || house->getOwner() != player->getGUID() || house->getState() != 4) { - return; - } - - house->setBidEndDate(0); - house->setBidder(0); - house->setState(2); - - playerCyclopediaHousesByTown(playerId, ""); - } + return; } house->setBidEndDate(timestamp); @@ -10959,45 +10927,44 @@ 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; - } + return; + } - house->setBidEndDate(0); - house->setBidder(0); - house->setState(2); + house->setBidEndDate(0); + house->setBidder(0); + house->setState(2); - playerCyclopediaHousesByTown(playerId, ""); - } + playerCyclopediaHousesByTown(playerId, ""); +} - bool Game::processBankAuction(std::shared_ptr player, std::shared_ptr house, uint64_t bid, bool replace /* = false*/) { - if (!replace && player->getBankBalance() < (house->getRent() + bid)) { - return 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; + } - if (player->getBankBalance() < bid) { - return false; - } + if (player->getBankBalance() < bid) { + return false; + } - uint64_t balance = player->getBankBalance(); - if (replace) { - player->setBankBalance(balance - (bid - house->getInternalBid())); - } else { - player->setBankBalance(balance - (house->getRent() + bid)); - } + uint64_t balance = player->getBankBalance(); + if (replace) { + player->setBankBalance(balance - (bid - house->getInternalBid())); + } else { + player->setBankBalance(balance - (house->getRent() + bid)); + } - player->sendResourceBalance(RESOURCE_BANK, player->getBankBalance()); + player->sendResourceBalance(RESOURCE_BANK, player->getBankBalance()); - if (house->getBidderName() != player->getName()) { - const auto otherPlayer = g_game().getPlayerByName(house->getBidderName()); - if (!otherPlayer) { - uint32_t bidderGuid = IOLoginData::getGuidByName(house->getBidderName()); - IOLoginData::increaseBankBalance(bidderGuid, (house->getBidHolderLimit() + house->getRent())); - } else { - otherPlayer->setBankBalance(otherPlayer->getBankBalance() + (house->getBidHolderLimit() + house->getRent())); - otherPlayer->sendResourceBalance(RESOURCE_BANK, otherPlayer->getBankBalance()); - } + if (house->getBidderName() != player->getName()) { + const auto otherPlayer = g_game().getPlayerByName(house->getBidderName()); + if (!otherPlayer) { + uint32_t bidderGuid = IOLoginData::getGuidByName(house->getBidderName()); + IOLoginData::increaseBankBalance(bidderGuid, (house->getBidHolderLimit() + house->getRent())); + } else { + otherPlayer->setBankBalance(otherPlayer->getBankBalance() + (house->getBidHolderLimit() + house->getRent())); + otherPlayer->sendResourceBalance(RESOURCE_BANK, otherPlayer->getBankBalance()); } - - return true; } + + return true; +} diff --git a/src/io/iomapserialize.cpp b/src/io/iomapserialize.cpp index 562aa02a0d7..ef6fb1beee4 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 && timeNow > bidEndDate && bidder > 0) { // Available - g_logger().debug("[BID] - Setting house id '{}' owner to player GUID '{}'", houseId, bidder); + } else if (state == 0 && bidder > 0 && timeNow > bidEndDate) { 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 == 4 && timeNow > bidEndDate) { // Move Out - g_logger().debug("[MOVE OUT] - Removing house id '{}' owner", houseId); + } else if (state == 2 && bidder == -1 && timeNow > bidEndDate) { + g_logger().debug("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,6 +326,7 @@ bool IOMapSerialize::loadHouseInfo() { house->setInternalBid(internalBid); house->setBidHolderLimit(internalBid); house->setBidEndDate(bidEndDate); + house->setState(state); } } while (result->next());