Skip to content

Commit

Permalink
fix load house logic
Browse files Browse the repository at this point in the history
  • Loading branch information
murilo09 committed Oct 30, 2024
1 parent 9f7cc62 commit 6a35471
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
8 changes: 3 additions & 5 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
Expand All @@ -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> player, std::shared_ptr<House> house, uint64_t bid, bool replace /* = false*/) {
bool Game::processBankAuction(std::shared_ptr<Player> player, const std::shared_ptr<House> &house, uint64_t bid, bool replace /* = false*/) {
if (!replace && player->getBankBalance() < (house->getRent() + bid)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> player, std::shared_ptr<House> house, uint64_t bid, bool replace = false);
bool processBankAuction(std::shared_ptr<Player> player, const std::shared_ptr<House> &house, uint64_t bid, bool replace = false);

void updatePlayerSaleItems(uint32_t playerId);

Expand Down
11 changes: 5 additions & 6 deletions src/io/iomapserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,33 +300,32 @@ 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);
house->setHighestBid(highestBid);
house->setInternalBid(internalBid);
house->setBidHolderLimit(internalBid);
house->setBidEndDate(bidEndDate);
house->setState(state);
}
} while (result->next());

Expand Down

0 comments on commit 6a35471

Please sign in to comment.