From 1abb44724393abd55c7f87c7426247295cbaa2b6 Mon Sep 17 00:00:00 2001 From: "dr.skull" Date: Thu, 12 Jan 2012 13:10:43 +0100 Subject: Fix Feral Spirit passive spell Spirit Hunt Now will heal wolfs too. Signed-off-by: dr.skull --- src/server/game/Entities/Unit/Unit.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/server/game/Entities') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 753d1fb752c..a6b2d57da9b 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -7182,6 +7182,8 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere return false; basepoints0 = CalculatePctN(int32(damage), triggerAmount); triggered_spell_id = 58879; + // Cast on spirit wolf + CastCustomSpell(this, triggered_spell_id, &basepoints0, NULL, NULL, true, NULL, triggeredByAura); break; } // Shaman T8 Elemental 4P Bonus -- cgit v1.2.3 From 6a44399852f746883d39a17e34670e1f5c8c10a6 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Tue, 17 Jan 2012 18:51:04 +0100 Subject: Core/Items: Fix a trading spoof exploit. Closes #4713 --- src/server/game/Entities/Player/Player.cpp | 20 ++++++++++++++++++-- src/server/game/Entities/Player/Player.h | 6 ++++-- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/server/game/Entities') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index bed3c0cb1a7..5ba80caaaf1 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -296,15 +296,24 @@ Item* TradeData::GetItem(TradeSlots slot) const return m_items[slot] ? m_player->GetItemByGuid(m_items[slot]) : NULL; } -bool TradeData::HasItem(uint64 item_guid) const +bool TradeData::HasItem(uint64 itemGuid) const { for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i) - if (m_items[i] == item_guid) + if (m_items[i] == itemGuid) return true; return false; } +TradeSlots const TradeData::GetTradeSlotForItem(uint64 itemGuid) +{ + for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i) + if (m_items[i] == itemGuid) + return TradeSlots(i); + + return TRADE_SLOT_INVALID; +} + Item* TradeData::GetSpellCastItem() const { return m_spellCastItem ? m_player->GetItemByGuid(m_spellCastItem) : NULL; @@ -12874,6 +12883,13 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) EquipItem(dest, pNewItem, true); AutoUnequipOffhandIfNeed(); } + + //! Update item count in trade window, prevent spoofing + //! Since pSrcItem has its count updated (see above), Item::GetCount() will return the new count + //! in the underlying packet builder function + TradeSlots const slot = GetTradeData()->GetTradeSlotForItem(pSrcItem->GetGUID()); + if (slot != TRADE_SLOT_INVALID) + GetTradeData()->SetItem(slot, pSrcItem); } void Player::SwapItem(uint16 src, uint16 dst) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 7a455590506..fccd380bd29 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -686,7 +686,8 @@ enum TradeSlots { TRADE_SLOT_COUNT = 7, TRADE_SLOT_TRADED_COUNT = 6, - TRADE_SLOT_NONTRADED = 6 + TRADE_SLOT_NONTRADED = 6, + TRADE_SLOT_INVALID = -1, }; enum TransferAbortReason @@ -1001,7 +1002,8 @@ class TradeData TradeData* GetTraderData() const; Item* GetItem(TradeSlots slot) const; - bool HasItem(uint64 item_guid) const; + bool HasItem(uint64 itemGuid) const; + TradeSlots const GetTradeSlotForItem(uint64 itemGuid); void SetItem(TradeSlots slot, Item* item); uint32 GetSpell() const { return m_spell; } -- cgit v1.2.3 From 819da8af4df187f39061d1abbfe80414e5e1607c Mon Sep 17 00:00:00 2001 From: kaelima Date: Wed, 18 Jan 2012 06:06:52 +0100 Subject: Core/Items: Attempt to fix crash in Player::SplitItem caused by 6a44399852f746883d39a17e34670e1f5c8c10a6. And some random cleanup --- src/server/game/DungeonFinding/LFGMgr.cpp | 2 +- src/server/game/Entities/Player/Player.cpp | 8 ++++++-- src/server/game/Entities/Unit/Unit.cpp | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/server/game/Entities') diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 0f146598a6e..ac7343e8f23 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -483,7 +483,7 @@ void LFGMgr::InitializeLockedDungeons(Player* player) void LFGMgr::Join(Player* player, uint8 roles, const LfgDungeonSet& selectedDungeons, const std::string& comment) { if (!player || !player->GetSession() || selectedDungeons.empty()) - return; + return; Group* grp = player->GetGroup(); uint64 guid = player->GetGUID(); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 5ba80caaaf1..ed65e1ce527 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -12842,7 +12842,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) pSrcItem->SetState(ITEM_CHANGED, this); StoreItem(dest, pNewItem, true); } - else if (IsBankPos (dst)) + else if (IsBankPos(dst)) { // change item amount before check (for unique max count check) pSrcItem->SetCount(pSrcItem->GetCount() - count); @@ -12862,7 +12862,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) pSrcItem->SetState(ITEM_CHANGED, this); BankItem(dest, pNewItem, true); } - else if (IsEquipmentPos (dst)) + else if (IsEquipmentPos(dst)) { // change item amount before check (for unique max count check), provide space for splitted items pSrcItem->SetCount(pSrcItem->GetCount() - count); @@ -12884,6 +12884,10 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) AutoUnequipOffhandIfNeed(); } + //! Make sure that code below only is executed when trading + if (!GetTradeData()) + return; + //! Update item count in trade window, prevent spoofing //! Since pSrcItem has its count updated (see above), Item::GetCount() will return the new count //! in the underlying packet builder function diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 63aa7771063..d7353d72ee0 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2114,12 +2114,12 @@ void Unit::SendMeleeAttackStart(Unit* victim) void Unit::SendMeleeAttackStop(Unit* victim) { - WorldPacket data(SMSG_ATTACKSTOP, (8+8+4)); // we guess size + WorldPacket data(SMSG_ATTACKSTOP, (8+8+4)); data.append(GetPackGUID()); data.append(victim ? victim->GetPackGUID() : 0); // can be 0x00... data << uint32(0); // can be 0x1 SendMessageToSet(&data, true); - sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTART"); + sLog->outStaticDebug("WORLD: Sent SMSG_ATTACKSTOP"); if (victim) sLog->outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow()); -- cgit v1.2.3 From cc88681dc5da60218e36ca00873cdf3033bcc5b5 Mon Sep 17 00:00:00 2001 From: SignFinder Date: Wed, 18 Jan 2012 11:56:34 +0400 Subject: Core/Items: Really fix a trading spoof exploit. Thanks Alexsot for fix. --- src/server/game/Entities/Player/Player.cpp | 6 +++--- src/server/game/Entities/Player/Player.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/server/game/Entities') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index ed65e1ce527..855fb9332b2 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -319,11 +319,11 @@ Item* TradeData::GetSpellCastItem() const return m_spellCastItem ? m_player->GetItemByGuid(m_spellCastItem) : NULL; } -void TradeData::SetItem(TradeSlots slot, Item* item) +void TradeData::SetItem(TradeSlots slot, Item* item, bool update) { uint64 itemGuid = item ? item->GetGUID() : 0; - if (m_items[slot] == itemGuid) + if (m_items[slot] == itemGuid && !update) return; m_items[slot] = itemGuid; @@ -12893,7 +12893,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) //! in the underlying packet builder function TradeSlots const slot = GetTradeData()->GetTradeSlotForItem(pSrcItem->GetGUID()); if (slot != TRADE_SLOT_INVALID) - GetTradeData()->SetItem(slot, pSrcItem); + GetTradeData()->SetItem(slot, pSrcItem, true); } void Player::SwapItem(uint16 src, uint16 dst) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index fccd380bd29..ae889e342c3 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1004,7 +1004,7 @@ class TradeData Item* GetItem(TradeSlots slot) const; bool HasItem(uint64 itemGuid) const; TradeSlots const GetTradeSlotForItem(uint64 itemGuid); - void SetItem(TradeSlots slot, Item* item); + void SetItem(TradeSlots slot, Item* item, bool update = false); uint32 GetSpell() const { return m_spell; } void SetSpell(uint32 spell_id, Item* castItem = NULL); -- cgit v1.2.3 From abd94e324b1ba872da331e19a3e80a6667edb363 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Wed, 18 Jan 2012 13:10:36 +0100 Subject: Core/Items: Fix crash and updated documentation in SplitItem --- src/server/game/Entities/Player/Player.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/server/game/Entities') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 855fb9332b2..eb270521500 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -12891,7 +12891,9 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) //! Update item count in trade window, prevent spoofing //! Since pSrcItem has its count updated (see above), Item::GetCount() will return the new count //! in the underlying packet builder function - TradeSlots const slot = GetTradeData()->GetTradeSlotForItem(pSrcItem->GetGUID()); + //! Note that this is not blizzlike, the item should be greyed out when in trade. + //! TODO: Figure out which packet(s) are responsible for that. + TradeSlots const slot = GetTradeData() ? GetTradeData()->GetTradeSlotForItem(pSrcItem->GetGUID()) : TRADE_SLOT_INVALID; if (slot != TRADE_SLOT_INVALID) GetTradeData()->SetItem(slot, pSrcItem, true); } -- cgit v1.2.3 From 46dda033c8b5abe45286ac94c4c727e57710ded3 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Wed, 18 Jan 2012 18:57:21 +0100 Subject: Core/Items: Blizzlike fix for the recent trade exploit fix --- src/server/game/Entities/Player/Player.cpp | 21 ++++++++------------- src/server/game/Entities/Player/Player.h | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) (limited to 'src/server/game/Entities') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index eb270521500..ddd1cdc8849 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -12814,6 +12814,14 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) return; } + //! If trading + if (TradeData* tradeData = GetTradeData()) + { + //! If current item is in trade window (only possible with packet spoofing - silent return) + if (GetTradeData()->GetTradeSlotForItem(pSrcItem->GetGUID()) != TRADE_SLOT_INVALID) + return; + } + sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "STORAGE: SplitItem bag = %u, slot = %u, item = %u, count = %u", dstbag, dstslot, pSrcItem->GetEntry(), count); Item* pNewItem = pSrcItem->CloneItem(count, this); if (!pNewItem) @@ -12883,19 +12891,6 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) EquipItem(dest, pNewItem, true); AutoUnequipOffhandIfNeed(); } - - //! Make sure that code below only is executed when trading - if (!GetTradeData()) - return; - - //! Update item count in trade window, prevent spoofing - //! Since pSrcItem has its count updated (see above), Item::GetCount() will return the new count - //! in the underlying packet builder function - //! Note that this is not blizzlike, the item should be greyed out when in trade. - //! TODO: Figure out which packet(s) are responsible for that. - TradeSlots const slot = GetTradeData() ? GetTradeData()->GetTradeSlotForItem(pSrcItem->GetGUID()) : TRADE_SLOT_INVALID; - if (slot != TRADE_SLOT_INVALID) - GetTradeData()->SetItem(slot, pSrcItem, true); } void Player::SwapItem(uint16 src, uint16 dst) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index ae889e342c3..fccd380bd29 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1004,7 +1004,7 @@ class TradeData Item* GetItem(TradeSlots slot) const; bool HasItem(uint64 itemGuid) const; TradeSlots const GetTradeSlotForItem(uint64 itemGuid); - void SetItem(TradeSlots slot, Item* item, bool update = false); + void SetItem(TradeSlots slot, Item* item); uint32 GetSpell() const { return m_spell; } void SetSpell(uint32 spell_id, Item* castItem = NULL); -- cgit v1.2.3 From e652d9043ba7c4c2b1b159eccc1e09c0c0c9bf55 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Wed, 18 Jan 2012 19:00:52 +0100 Subject: Missing unsaved changes for previous commit... --- src/server/game/Entities/Player/Player.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/server/game/Entities') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index ddd1cdc8849..ce80d7a7af3 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -319,11 +319,11 @@ Item* TradeData::GetSpellCastItem() const return m_spellCastItem ? m_player->GetItemByGuid(m_spellCastItem) : NULL; } -void TradeData::SetItem(TradeSlots slot, Item* item, bool update) +void TradeData::SetItem(TradeSlots slot, Item* item) { uint64 itemGuid = item ? item->GetGUID() : 0; - if (m_items[slot] == itemGuid && !update) + if (m_items[slot] == itemGuid) return; m_items[slot] = itemGuid; @@ -12818,7 +12818,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) if (TradeData* tradeData = GetTradeData()) { //! If current item is in trade window (only possible with packet spoofing - silent return) - if (GetTradeData()->GetTradeSlotForItem(pSrcItem->GetGUID()) != TRADE_SLOT_INVALID) + if (tradeData->GetTradeSlotForItem(pSrcItem->GetGUID()) != TRADE_SLOT_INVALID) return; } -- cgit v1.2.3 From 0f383e9cdd12531260f722671f6bd51bef85930e Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 20 Jan 2012 05:11:52 +0300 Subject: Core/Movement: properly set mover for possess/vehicles --- src/server/game/Entities/Unit/Unit.cpp | 2 ++ src/server/game/Entities/Vehicle/Vehicle.cpp | 4 ---- src/server/game/Spells/Auras/SpellAuraEffects.cpp | 14 ++------------ 3 files changed, 4 insertions(+), 16 deletions(-) (limited to 'src/server/game/Entities') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 7b51840b49f..6bab63acf1b 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -15849,6 +15849,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au case CHARM_TYPE_VEHICLE: SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); charmer->ToPlayer()->SetClientControl(this, 1); + charmer->ToPlayer()->SetMover(this); charmer->ToPlayer()->SetViewpoint(this, true); charmer->ToPlayer()->VehicleSpellInitialize(); break; @@ -15857,6 +15858,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); charmer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); charmer->ToPlayer()->SetClientControl(this, 1); + charmer->ToPlayer()->SetMover(this); charmer->ToPlayer()->SetViewpoint(this, true); charmer->ToPlayer()->PossessSpellInitialize(); break; diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index b3531d585c3..7e4bebaab95 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -359,7 +359,6 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId) { if (!_me->SetCharmedBy(unit, CHARM_TYPE_VEHICLE)) ASSERT(false); - unit->ToPlayer()->SetMover(this->GetBase()); } if (_me->IsInWorld()) @@ -411,10 +410,7 @@ void Vehicle::RemovePassenger(Unit* unit) unit->ClearUnitState(UNIT_STAT_ONVEHICLE); if (_me->GetTypeId() == TYPEID_UNIT && unit->GetTypeId() == TYPEID_PLAYER && seat->first == 0 && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL) - { _me->RemoveCharmedBy(unit); - unit->ToPlayer()->SetMover(unit->ToPlayer()); - } if (_me->IsInWorld()) { diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 535253f4e13..7c09a2f32c6 100755 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -3096,17 +3096,9 @@ void AuraEffect::HandleModPossess(AuraApplication const* aurApp, uint8 mode, boo } if (apply) - { - if (target->SetCharmedBy(caster, CHARM_TYPE_POSSESS, aurApp)) - caster->ToPlayer()->SetMover(target); - } + target->SetCharmedBy(caster, CHARM_TYPE_POSSESS, aurApp); else - { target->RemoveCharmedBy(caster); - caster->ToPlayer()->SetMover(caster); - if (target->GetTypeId() == TYPEID_PLAYER) - target->ToPlayer()->SetMover(target); - } } // only one spell has this aura @@ -3134,13 +3126,11 @@ void AuraEffect::HandleModPossessPet(AuraApplication const* aurApp, uint8 mode, if (caster->ToPlayer()->GetPet() != pet) return; - if (pet->SetCharmedBy(caster, CHARM_TYPE_POSSESS, aurApp)) - caster->ToPlayer()->SetMover(pet); + pet->SetCharmedBy(caster, CHARM_TYPE_POSSESS, aurApp); } else { pet->RemoveCharmedBy(caster); - caster->ToPlayer()->SetMover(caster); if (!pet->IsWithinDistInMap(caster, pet->GetMap()->GetVisibilityRange())) pet->Remove(PET_SAVE_NOT_IN_SLOT, true); -- cgit v1.2.3