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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user