Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
murilo09 committed Oct 30, 2024
1 parent b260617 commit 9a2fc29
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 70 deletions.
103 changes: 34 additions & 69 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10904,44 +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;
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> 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, "");
}
if (!house || house->getOwner() != player->getGUID()|| house->getState() != 2) {
return;
}

house->setBidEndDate(timestamp);
house->setBidder(-1);
house->setState(4);

playerCyclopediaHousesByTown(playerId, "");
Expand All @@ -10958,46 +10925,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;
}
if (!house || house->getOwner() != player->getGUID() || house->getState() != 4) {
return;
}

house->setBidEndDate(0);
house->setBidder(0);
house->setState(2);
house->setBidEndDate(0);
house->setState(2);

playerCyclopediaHousesByTown(playerId, "");
}
playerCyclopediaHousesByTown(playerId, "");
}

bool Game::processBankAuction(std::shared_ptr<Player> player, std::shared_ptr<House> house, uint64_t bid, bool replace /* = false*/) {
if (!replace && player->getBankBalance() < (house->getRent() + bid)) {
return 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;
}

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;
}
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

0 comments on commit 9a2fc29

Please sign in to comment.