* add Player::HasEnoughMoney methods to check, whether player has specified amount of money and use new methods where applicable
* fix some signed/unsigned warnings and some typos

--HG--
branch : trunk
This commit is contained in:
azazel
2010-08-23 22:58:32 +06:00
parent ad5c8cadf1
commit caa3a58213
20 changed files with 72 additions and 65 deletions
@@ -198,7 +198,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
//we have to take deposit :
uint32 deposit = sAuctionMgr.GetAuctionDeposit(auctionHouseEntry, etime, it);
if (pl->GetMoney() < deposit)
if (!pl->HasEnoughMoney(deposit))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY);
return;
@@ -305,7 +305,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
return;
}
if (price > pl->GetMoney())
if (pl->HasEnoughMoney(price))
{
//you don't have enought money!, client tests!
//SendAuctionCommandResult(auction->auctionId, AUCTION_PLACE_BID, ???);
@@ -404,7 +404,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid
{
uint32 auctionCut = auction->GetAuctionCut();
if (pl->GetMoney() < auctionCut) //player doesn't have enough money, maybe message needed
if (!pl->HasEnoughMoney(auctionCut)) //player doesn't have enough money, maybe message needed
return;
//some auctionBidderNotification would be needed, but don't know that parts..
sAuctionMgr.SendAuctionCancelledToBidderMail(auction, trans);
@@ -1080,7 +1080,7 @@ void WorldSession::HandleAlterAppearance(WorldPacket & recv_data)
// 0 - ok
// 1,3 - not enough money
// 2 - you have to seat on barber chair
if (_player->GetMoney() < Cost)
if (!_player->HasEnoughMoney(Cost))
{
WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4);
data << uint32(1); // no money
@@ -743,7 +743,7 @@ void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket)
return;
}
if (GetPlayer()->GetMoney() < 10*GOLD)
if (!GetPlayer()->HasEnoughMoney(10 * GOLD))
{
//"You can't afford to do that."
SendSaveGuildEmblem(ERR_GUILDEMBLEM_NOTENOUGHMONEY);
@@ -873,7 +873,7 @@ void WorldSession::HandleGuildBankDepositMoney(WorldPacket & recv_data)
if (!GetPlayer()->GetGameObjectIfCanInteractWith(GoGuid, GAMEOBJECT_TYPE_GUILD_BANK))
return;
if (GetPlayer()->GetMoney() < money)
if (!GetPlayer()->HasEnoughMoney(money))
return;
uint32 GuildId = GetPlayer()->GetGuildId();
@@ -1098,7 +1098,7 @@ void WorldSession::HandleGuildBankBuyTab(WorldPacket & recv_data)
if (!TabCost)
return;
if (GetPlayer()->GetMoney() < TabCost) // Should not happen, this is checked by client
if (!GetPlayer()->HasEnoughMoney(TabCost)) // Should not happen, this is checked by client
return;
// Go on with creating tab
@@ -619,7 +619,7 @@ void WorldSession::HandleBuybackItem(WorldPacket & recv_data)
if (pItem)
{
uint32 price = _player->GetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + slot - BUYBACK_SLOT_START);
if (_player->GetMoney() < price)
if (!_player->HasEnoughMoney(price))
{
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, pItem->GetEntry(), 0);
return;
@@ -886,7 +886,7 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket)
uint32 price = slotEntry->price;
if (_player->GetMoney() < price)
if (!_player->HasEnoughMoney(price))
{
data << uint32(ERR_BANKSLOT_INSUFFICIENT_FUNDS);
SendPacket(&data);
@@ -277,7 +277,7 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket & recv_data)
uint32 nSpellCost = uint32(floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit)));
// check money requirement
if (_player->GetMoney() < nSpellCost)
if (!_player->HasEnoughMoney(nSpellCost))
return;
_player->ModifyMoney(-int32(nSpellCost));
@@ -727,7 +727,7 @@ void WorldSession::HandleBuyStableSlot(WorldPacket & recv_data)
if (GetPlayer()->m_stableSlots < MAX_PET_STABLES)
{
StableSlotPricesEntry const *SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1);
if (_player->GetMoney() >= SlotPrice->Price)
if (_player->HasEnoughMoney(SlotPrice->Price))
{
++GetPlayer()->m_stableSlots;
_player->ModifyMoney(-int32(SlotPrice->Price));
@@ -179,7 +179,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
return;
}
if (_player->GetMoney() < cost)
if (!_player->HasEnoughMoney(cost))
{ //player hasn't got enough money
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, charterid, 0);
return;
@@ -273,7 +273,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
my_trade->SetAccepted(true);
// not accept case incorrect money amount
if (my_trade->GetMoney() > _player->GetMoney())
if (!_player->HasEnoughMoney(my_trade->GetMoney()))
{
SendNotification(LANG_NOT_ENOUGH_GOLD);
my_trade->SetAccepted(false, true);
@@ -281,7 +281,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
}
// not accept case incorrect money amount
if (his_trade->GetMoney() > trader->GetMoney())
if (trader->HasEnoughMoney(his_trade->GetMoney()))
{
trader->GetSession()->SendNotification(LANG_NOT_ENOUGH_GOLD);
his_trade->SetAccepted(false, true);