aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/Guild.cpp23
-rw-r--r--src/game/GuildHandler.cpp2
-rw-r--r--src/game/Item.h6
-rw-r--r--src/game/Player.cpp100
4 files changed, 69 insertions, 62 deletions
diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp
index a39dff1183d..495d64f786f 100644
--- a/src/game/Guild.cpp
+++ b/src/game/Guild.cpp
@@ -1085,7 +1085,7 @@ void Guild::DisplayGuildBankTabsInfo(WorldSession *session)
data << uint64(GetGuildBankMoney());
data << uint8(0); // TabInfo packet must be for TabId 0
- //data << uint32(0xFFFFFFFF); // bit 9 must be set for this packet to work
+ //data << uint32(0xFFFFFFFF); // bit 9 must be set for this packet to work
data << uint32(0);
data << uint8(1); // Tell Client this is a TabInfo packet
data << uint8(m_PurchasedTabs); // here is the number of tabs
@@ -1739,7 +1739,7 @@ Item* Guild::StoreItem(uint8 tabId, GuildItemPosCountVec const& dest, Item* pIte
return lastItem;
}
-// Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case.
+// Return stored item (if stored to stack, it can diff. from pItem). And pItem can be deleted in this case.
Item* Guild::_StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool clone )
{
if (!pItem)
@@ -1765,15 +1765,15 @@ Item* Guild::_StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool
pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0);
AddGBankItemToDB(GetId(), tab, slot, pItem->GetGUIDLow(), pItem->GetEntry());
pItem->FSetState(ITEM_NEW);
- pItem->SaveToDB(); // not in onventory and can be save standalone
+ pItem->SaveToDB(); // not in inventory and can be save standalone
return pItem;
}
else
{
- pItem2->SetCount( pItem2->GetCount() + count );
+ pItem2->SetCount(pItem2->GetCount() + count);
pItem2->FSetState(ITEM_CHANGED);
- pItem2->SaveToDB(); // not in onventory and can be save standalone
+ pItem2->SaveToDB(); // not in inventory and can be save standalone
if (!clone)
{
@@ -1981,7 +1981,7 @@ void Guild::SendGuildBankTabText(WorldSession *session, uint8 TabId)
BroadcastPacket(&data);
}
-void Guild::SwapItems(Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTabDst, uint8 BankTabSlotDst, uint32 SplitedAmount )
+void Guild::SwapItems(Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTabDst, uint8 BankTabSlotDst, uint32 SplitedAmount)
{
// empty operation
if (BankTab == BankTabDst && BankTabSlot == BankTabSlotDst)
@@ -1991,9 +1991,14 @@ void Guild::SwapItems(Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankT
if (!pItemSrc) // may prevent crash
return;
- if (SplitedAmount > pItemSrc->GetCount())
- return; // cheating?
- else if (SplitedAmount == pItemSrc->GetCount())
+ if (pItemSrc->GetCount() == 0)
+ {
+ sLog.outCrash("Guild::SwapItems: Player %s(GUIDLow: %u) tried to move item %u from tab %u slot %u to tab %u slot %u, but item %u has a stack of zero!",
+ pl->GetName(), pl->GetGUIDLow(), pItemSrc->GetEntry(), BankTab, BankTabSlot, BankTabDst, BankTabSlotDst, pItemSrc->GetEntry());
+ //return; // Commented out for now, uncomment when it's verified that this causes a crash!!
+ }
+
+ if (SplitedAmount >= pItemSrc->GetCount())
SplitedAmount = 0; // no split
Item *pItemDst = GetItem(BankTabDst, BankTabSlotDst);
diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp
index f15a75256ee..80f5d124e94 100644
--- a/src/game/GuildHandler.cpp
+++ b/src/game/GuildHandler.cpp
@@ -1133,7 +1133,7 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data )
// Player <-> Bank
// allow work with inventory only
- if(!Player::IsInventoryPos(PlayerBag,PlayerSlot) && !(PlayerBag == NULL_BAG && PlayerSlot == NULL_SLOT) )
+ if(!Player::IsInventoryPos(PlayerBag,PlayerSlot) && !(PlayerBag == NULL_BAG && PlayerSlot == NULL_SLOT))
{
_player->SendEquipError( EQUIP_ERR_NONE, NULL, NULL );
return;
diff --git a/src/game/Item.h b/src/game/Item.h
index b70134fbb63..2988707a464 100644
--- a/src/game/Item.h
+++ b/src/game/Item.h
@@ -255,8 +255,8 @@ class TRINITY_DLL_SPEC Item : public Object
bool IsLimitedToAnotherMapOrZone( uint32 cur_mapId, uint32 cur_zoneId) const;
bool GemsFitSockets() const;
- uint32 GetCount() const { return GetUInt32Value (ITEM_FIELD_STACK_COUNT); }
- void SetCount(uint32 value) { SetUInt32Value (ITEM_FIELD_STACK_COUNT, value); }
+ uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); }
+ void SetCount(uint32 value) { SetUInt32Value(ITEM_FIELD_STACK_COUNT, value); }
uint32 GetMaxStackCount() const { return GetProto()->GetMaxStackSize(); }
uint8 GetGemCountWithID(uint32 GemID) const;
uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const;
@@ -264,7 +264,7 @@ class TRINITY_DLL_SPEC Item : public Object
uint8 GetSlot() const {return m_slot;}
Bag *GetContainer() { return m_container; }
uint8 GetBagSlot() const;
- void SetSlot(uint8 slot) {m_slot = slot;}
+ void SetSlot(uint8 slot) { m_slot = slot; }
uint16 GetPos() const { return uint16(GetBagSlot()) << 8 | GetSlot(); }
void SetContainer(Bag *container) { m_container = container; }
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index c97d6c8d69c..87396daba80 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -2914,7 +2914,7 @@ bool Player::AddTalent(uint32 spell_id, uint8 spec, bool learning)
return false;
}
- if(!SpellMgr::IsSpellValid(spellInfo,this,false))
+ if (!SpellMgr::IsSpellValid(spellInfo,this,false))
{
// do character spell book cleanup (all characters)
if(!IsInWorld() && !learning) // spell load case
@@ -2930,25 +2930,21 @@ bool Player::AddTalent(uint32 spell_id, uint8 spec, bool learning)
PlayerTalentMap::iterator itr = m_talents[spec]->find(spell_id);
if (itr != m_talents[spec]->end())
- {
itr->second->state = PLAYERSPELL_UNCHANGED;
- }
- else if(TalentSpellPos const *talentPos = GetTalentSpellPos(spell_id))
+ else if (TalentSpellPos const *talentPos = GetTalentSpellPos(spell_id))
{
- if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id ))
+ if (TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id ))
{
for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank)
{
// skip learning spell and no rank spell case
uint32 rankSpellId = talentInfo->RankID[rank];
- if(!rankSpellId || rankSpellId == spell_id)
+ if (!rankSpellId || rankSpellId == spell_id)
continue;
PlayerTalentMap::iterator itr = m_talents[spec]->find(rankSpellId);
if (itr != m_talents[spec]->end())
- {
itr->second->state = PLAYERSPELL_REMOVED;
- }
}
}
@@ -3745,8 +3741,8 @@ uint32 Player::resetTalentsCost() const
bool Player::resetTalents(bool no_cost)
{
// not need after this call
- if(HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
- RemoveAtLoginFlag(AT_LOGIN_RESET_TALENTS,true);
+ if (HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
+ RemoveAtLoginFlag(AT_LOGIN_RESET_TALENTS, true);
uint32 talentPointsForLevel = CalculateTalentsPoints();
@@ -3787,7 +3783,14 @@ bool Player::resetTalents(bool no_cost)
if ((getClassMask() & talentTabInfo->ClassMask) == 0)
continue;
+ PlayerTalentMap::const_iterator foundTalent = m_talents[m_activeSpec]->find(i);
+ if (foundTalent == m_talents[spec]->end() || foundTalent->second->state == PLAYERSPELL_REMOVED)
+ continue;
+ else
+ foundTalent->second->state = PLAYERSPELL_REMOVED;
+
removeSpell(i, !IsPassiveSpell(i), false);
+
/*
for (PlayerTalentMap::iterator itr = m_talents[m_activeSpec]->begin(); itr != m_talents[m_activeSpec]->end(); ++itr)
{
@@ -3800,7 +3803,7 @@ bool Player::resetTalents(bool no_cost)
{
for (PlayerSpellMap::iterator itr = GetSpellMap().begin(); itr != GetSpellMap().end();)
{
- if(itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled)
+ if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled)
{
++itr;
continue;
@@ -3856,37 +3859,28 @@ bool Player::resetTalents(bool no_cost)
Mail* Player::GetMail(uint32 id)
{
for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
- {
if ((*itr)->messageID == id)
- {
return (*itr);
- }
- }
+
return NULL;
}
void Player::_SetCreateBits(UpdateMask *updateMask, Player *target) const
{
if(target == this)
- {
Object::_SetCreateBits(updateMask, target);
- }
else
{
for (uint16 index = 0; index < m_valuesCount; index++)
- {
- if(GetUInt32Value(index) != 0 && updateVisualBits.GetBit(index))
+ if (GetUInt32Value(index) != 0 && updateVisualBits.GetBit(index))
updateMask->SetBit(index);
- }
}
}
void Player::_SetUpdateBits(UpdateMask *updateMask, Player *target) const
{
if(target == this)
- {
Object::_SetUpdateBits(updateMask, target);
- }
else
{
Object::_SetUpdateBits(updateMask, target);
@@ -3985,7 +3979,7 @@ void Player::InitVisibleBits()
void Player::BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const
{
- for (uint8 i = 0; i < EQUIPMENT_SLOT_END; i++)
+ for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
{
if(m_items[i] == NULL)
continue;
@@ -3995,7 +3989,7 @@ void Player::BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target )
if(target == this)
{
- for (uint8 i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++)
+ for (uint8 i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
{
if(m_items[i] == NULL)
continue;
@@ -4018,7 +4012,7 @@ void Player::DestroyForPlayer( Player *target, bool anim ) const
{
Unit::DestroyForPlayer( target, anim );
- for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; i++)
+ for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i)
{
if(m_items[i] == NULL)
continue;
@@ -4028,7 +4022,7 @@ void Player::DestroyForPlayer( Player *target, bool anim ) const
if(target == this)
{
- for (uint8 i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; i++)
+ for (uint8 i = INVENTORY_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
{
if(m_items[i] == NULL)
continue;
@@ -15174,7 +15168,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
// sanity check
if (m_specsCount > MAX_TALENT_SPECS || m_activeSpec > MAX_TALENT_SPEC ||
- m_specsCount < MIN_TALENT_SPECS || m_activeSpec < MIN_TALENT_SPEC ) // if (m_specsCount < 2) is not logical
+ m_specsCount < MIN_TALENT_SPECS || m_activeSpec < MIN_TALENT_SPEC)
{
m_activeSpec = 0;
sLog.outError("Player %s(GUID: %u) has SpecCount = %u and ActiveSpec = %u.", GetName(), GetGUIDLow(), m_specsCount, m_activeSpec);
@@ -22012,34 +22006,42 @@ void Player::ActivateSpec(uint8 spec)
// Remove all talents and talent-learned spells under this spec.
for (PlayerTalentMap::iterator itr = m_talents[m_activeSpec]->begin(); itr != m_talents[m_activeSpec]->end(); ++itr)
{
+ TalentEntry const *talentInfo = sTalentStore.LookupEntry(itr->first);
+
+ if (!talentInfo)
+ continue;
+
removeSpell(itr->first, !IsPassiveSpell(itr->first), false);
- uint32 itrFirstId = spellmgr.GetFirstSpellInChain(itr->first);
- for (PlayerSpellMap::iterator itr2 = GetSpellMap().begin(); itr2 != GetSpellMap().end();)
+
+ for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank)
{
- if (itr2->second->state == PLAYERSPELL_REMOVED || itr2->second->disabled)
+ for (PlayerSpellMap::iterator itr2 = GetSpellMap().begin(); itr2 != GetSpellMap().end();)
{
- ++itr2;
- continue;
- }
+ if (itr2->second->state == PLAYERSPELL_REMOVED || itr2->second->disabled)
+ {
+ ++itr2;
+ continue;
+ }
- // remove learned spells (all ranks)
- uint32 itr2FirstId = spellmgr.GetFirstSpellInChain(itr2->first);
+ // remove learned spells (all ranks)
+ uint32 itrFirstId = spellmgr.GetFirstSpellInChain(itr2->first);
- // unlearn if first rank is talent or learned by talent
- if (itrFirstId == itr2FirstId)
- {
- removeSpell(itr2->first, !IsPassiveSpell(itr2->first), false);
- itr2 = GetSpellMap().begin();
- continue;
- }
- else if (spellmgr.IsSpellLearnToSpell(itr->first, itrFirstId))
- {
- removeSpell(itr2->first, !IsPassiveSpell(itr2->first));
- itr2 = GetSpellMap().begin();
- continue;
+ // unlearn if first rank is talent or learned by talent
+ if (itrFirstId == talentInfo->RankID[rank])
+ {
+ removeSpell(itr2->first, !IsPassiveSpell(itr2->first), false);
+ itr2 = GetSpellMap().begin();
+ continue;
+ }
+ else if (spellmgr.IsSpellLearnToSpell(talentInfo->RankID[rank], itrFirstId))
+ {
+ removeSpell(itr2->first, !IsPassiveSpell(itr2->first));
+ itr2 = GetSpellMap().begin();
+ continue;
+ }
+ else
+ ++itr2;
}
- else
- ++itr2;
}
}