Core:
* 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:
@@ -91,10 +91,10 @@ void BattlegroundWS::Update(uint32 diff)
|
||||
else
|
||||
EndBattleground(ALLIANCE);
|
||||
}
|
||||
else if (GetStartTime() > m_minutesElapsed*MINUTE*IN_MILLISECONDS)
|
||||
else if (GetStartTime() > uint32(m_minutesElapsed * MINUTE * IN_MILLISECONDS))
|
||||
{
|
||||
++m_minutesElapsed;
|
||||
UpdateWorldState(BG_WS_STATE_TIMER, 25-m_minutesElapsed);
|
||||
UpdateWorldState(BG_WS_STATE_TIMER, 25 - m_minutesElapsed);
|
||||
}
|
||||
|
||||
if (m_FlagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_WAIT_RESPAWN)
|
||||
|
||||
@@ -3367,7 +3367,7 @@ bool ChatHandler::HandleLookupCreatureCommand(const char *args)
|
||||
int loc_idx = GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(uloc_idx);
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
CreatureLocale const *cl = sObjectMgr.GetCreatureLocale (id);
|
||||
if (cl)
|
||||
{
|
||||
@@ -3438,7 +3438,7 @@ bool ChatHandler::HandleLookupObjectCommand(const char *args)
|
||||
int loc_idx = GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
uint8 uloc_idx = uint8(uloc_idx);
|
||||
uint8 uloc_idx = uint8(loc_idx);
|
||||
GameObjectLocale const *gl = sObjectMgr.GetGameObjectLocale(id);
|
||||
if (gl)
|
||||
{
|
||||
|
||||
@@ -1622,7 +1622,7 @@ bool Pet::resetTalents(bool no_cost)
|
||||
{
|
||||
cost = resetTalentsCost();
|
||||
|
||||
if (player->GetMoney() < cost)
|
||||
if (!player->HasEnoughMoney(cost))
|
||||
{
|
||||
player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
|
||||
return false;
|
||||
|
||||
@@ -4027,7 +4027,7 @@ bool Player::resetTalents(bool no_cost)
|
||||
{
|
||||
cost = resetTalentsCost();
|
||||
|
||||
if (GetMoney() < cost)
|
||||
if (!HasEnoughMoney(cost))
|
||||
{
|
||||
SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
|
||||
return false;
|
||||
@@ -5090,7 +5090,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g
|
||||
|
||||
TotalCost = costs;
|
||||
}
|
||||
else if (GetMoney() < costs)
|
||||
else if (!HasEnoughMoney(costs))
|
||||
{
|
||||
sLog.outStaticDebug("You do not have enough money");
|
||||
return TotalCost;
|
||||
@@ -13699,7 +13699,7 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me
|
||||
case GOSSIP_OPTION_LEARNDUALSPEC:
|
||||
if (GetSpecsCount() == 1 && !(getLevel() < sWorld.getConfig(CONFIG_MIN_DUALSPEC_LEVEL)))
|
||||
{
|
||||
if (GetMoney() < 10000000)
|
||||
if (!HasEnoughMoney(10000000))
|
||||
{
|
||||
SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
|
||||
PlayerTalkClass->CloseGossip();
|
||||
@@ -14127,7 +14127,7 @@ bool Player::CanCompleteQuest(uint32 quest_id)
|
||||
|
||||
if (qInfo->GetRewOrReqMoney() < 0)
|
||||
{
|
||||
if (GetMoney() < uint32(-qInfo->GetRewOrReqMoney()))
|
||||
if (!HasEnoughMoney(-qInfo->GetRewOrReqMoney()))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14194,7 +14194,7 @@ bool Player::CanRewardQuest(Quest const *pQuest, bool msg)
|
||||
}
|
||||
|
||||
// prevent receive reward with low money and GetRewOrReqMoney() < 0
|
||||
if (pQuest->GetRewOrReqMoney() < 0 && GetMoney() < uint32(-pQuest->GetRewOrReqMoney()))
|
||||
if (pQuest->GetRewOrReqMoney() < 0 && !HasEnoughMoney(-pQuest->GetRewOrReqMoney()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -19790,7 +19790,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
|
||||
if (price)
|
||||
price = uint32(floor(price * GetReputationPriceDiscount(pCreature)));
|
||||
|
||||
if (GetMoney() < price)
|
||||
if (!HasEnoughMoney(price))
|
||||
{
|
||||
SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, item, 0);
|
||||
return false;
|
||||
|
||||
@@ -1447,8 +1447,15 @@ class Player : public Unit, public GridObject<Player>
|
||||
void setRegenTimerCount(uint32 time) {m_regenTimerCount = time;}
|
||||
void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
|
||||
|
||||
uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
|
||||
uint32 GetMoney() const { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
|
||||
void ModifyMoney(int32 d);
|
||||
bool HasEnoughMoney(uint32 amount) const { return (GetMoney() >= amount); }
|
||||
bool HasEnoughMoney(int32 amount) const
|
||||
{
|
||||
if (amount > 0)
|
||||
return (GetMoney() >= (uint32) amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetMoney(uint32 value)
|
||||
{
|
||||
|
||||
@@ -122,7 +122,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
|
||||
|
||||
uint32 reqmoney = cost + money;
|
||||
|
||||
if (pl->GetMoney() < reqmoney)
|
||||
if (!pl->HasEnoughMoney(reqmoney))
|
||||
{
|
||||
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
|
||||
return;
|
||||
@@ -425,7 +425,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data)
|
||||
}
|
||||
|
||||
// prevent cheating with skip client money check
|
||||
if (pl->GetMoney() < m->COD)
|
||||
if (!pl->HasEnoughMoney(m->COD))
|
||||
{
|
||||
pl->SendMailResult(mailId, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY);
|
||||
return;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user