aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorQAston <none@none>2009-06-23 14:05:37 +0200
committerQAston <none@none>2009-06-23 14:05:37 +0200
commitf2ec641e429470bd3adc01bbdf1d62e900b5fa2a (patch)
tree0165de38d0b67f0302fb494df07d02953a028d2b /src/game
parent64786941ddf531bcd3b4bea1738151bfc46a19a7 (diff)
[8056] Move SMSG_CLEAR_COOLDOWN into function and use it. Other cleanups. Author:XTZGZoReX
[8060] Store spell_pet_auras for auraeffects instead of by whole aura Author:hunuza. --HG-- branch : trunk
Diffstat (limited to 'src/game')
-rw-r--r--src/game/PetHandler.cpp6
-rw-r--r--src/game/Player.cpp53
-rw-r--r--src/game/Player.h2
-rw-r--r--src/game/SpellAuras.cpp2
-rw-r--r--src/game/SpellEffects.cpp2
-rw-r--r--src/game/SpellMgr.cpp26
-rw-r--r--src/game/SpellMgr.h6
-rw-r--r--src/game/Unit.cpp33
-rw-r--r--src/game/Unit.h2
9 files changed, 37 insertions, 95 deletions
diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp
index 3960b59d6d4..3dc7c6d4ff1 100644
--- a/src/game/PetHandler.cpp
+++ b/src/game/PetHandler.cpp
@@ -291,7 +291,7 @@ void WorldSession::HandlePetActionHelper(Unit *pet, uint64 guid1, uint16 spellid
pet->SendPetCastFail(spellid, result);
if(!((Creature*)pet)->HasSpellCooldown(spellid))
- pet->SendPetClearCooldown(spellid);
+ GetPlayer()->SendClearCooldown(spellid, pet);
spell->finish(false);
delete spell;
@@ -669,12 +669,12 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
if(caster->GetTypeId() == TYPEID_PLAYER)
{
if(!((Player*)caster)->HasSpellCooldown(spellid))
- caster->SendPetClearCooldown(spellid);
+ GetPlayer()->SendClearCooldown(spellid, caster);
}
else
{
if(!((Creature*)caster)->HasSpellCooldown(spellid))
- caster->SendPetClearCooldown(spellid);
+ GetPlayer()->SendClearCooldown(spellid, caster);
}
spell->finish(false);
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 160737ecfd8..4adac94c946 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -3223,8 +3223,9 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool update_action_bar_
RemoveAurasDueToSpell(spell_id);
// remove pet auras
- if(PetAura const* petSpell = spellmgr.GetPetAura(spell_id))
- RemovePetAura(petSpell);
+ for(int i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ if(PetAura const* petSpell = spellmgr.GetPetAura(spell_id, i))
+ RemovePetAura(petSpell);
// free talent points
uint32 talentCosts = GetTalentSpellCost(spell_id);
@@ -3374,12 +3375,7 @@ void Player::RemoveSpellCooldown( uint32 spell_id, bool update /* = false */ )
m_spellCooldowns.erase(spell_id);
if(update)
- {
- WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8);
- data << uint32(spell_id);
- data << uint64(GetGUID());
- SendDirectMessage(&data);
- }
+ SendClearCooldown(spell_id, this);
}
void Player::RemoveCategoryCooldown( uint32 cat )
@@ -3405,13 +3401,8 @@ void Player::RemoveArenaSpellCooldowns()
entry->RecoveryTime <= 15 * MINUTE * IN_MILISECONDS &&
entry->CategoryRecoveryTime <= 15 * MINUTE * IN_MILISECONDS )
{
- // notify player
- WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8);
- data << uint32(itr->first);
- data << uint64(GetGUID());
- GetSession()->SendPacket(&data);
- // remove cooldown
- m_spellCooldowns.erase(itr);
+ // remove & notify
+ RemoveSpellCooldown(itr->first, true);
}
}
}
@@ -3421,12 +3412,8 @@ void Player::RemoveAllSpellCooldown()
if(!m_spellCooldowns.empty())
{
for(SpellCooldowns::const_iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end(); ++itr)
- {
- WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8);
- data << uint32(itr->first);
- data << uint64(GetGUID());
- GetSession()->SendPacket(&data);
- }
+ SendClearCooldown(itr->first, this);
+
m_spellCooldowns.clear();
}
}
@@ -6453,22 +6440,6 @@ void Player::DuelComplete(DuelCompleteType type)
duel->opponent->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, 1);
}
- // cool-down duel spell
- /*data.Initialize(SMSG_SPELL_COOLDOWN, 17);
-
- data<<GetGUID();
- data<<uint8(0x0);
-
- data<<(uint32)7266;
- data<<uint32(0x0);
- GetSession()->SendPacket(&data);
- data.Initialize(SMSG_SPELL_COOLDOWN, 17);
- data<<duel->opponent->GetGUID();
- data<<uint8(0x0);
- data<<(uint32)7266;
- data<<uint32(0x0);
- duel->opponent->GetSession()->SendPacket(&data);*/
-
//Remove Duel Flag object
GameObject* obj = GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER));
if(obj)
@@ -21132,3 +21103,11 @@ void Player::RemoveAtLoginFlag( AtLoginFlags f, bool in_db_also /*= false*/ )
if(in_db_also)
CharacterDatabase.PExecute("UPDATE characters set at_login = at_login & ~ %u WHERE guid ='%u'", uint32(f), GetGUIDLow());
}
+
+void Player::SendClearCooldown( uint32 spell_id, Unit* target )
+{
+ WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8);
+ data << uint32(spell_id);
+ data << uint64(target->GetGUID());
+ SendDirectMessage(&data);
+}
diff --git a/src/game/Player.h b/src/game/Player.h
index 0fcdef48668..b838449b24f 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1422,6 +1422,8 @@ class TRINITY_DLL_SPEC Player : public Unit
void SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId = 0, Spell* spell = NULL);
void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs );
void RemoveSpellCooldown(uint32 spell_id, bool update = false);
+ void SendClearCooldown( uint32 spell_id, Unit* target );
+
void RemoveCategoryCooldown(uint32 cat);
void RemoveArenaSpellCooldowns();
void RemoveAllSpellCooldown();
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 1d19124a067..1bed0715ce5 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -2895,7 +2895,7 @@ void AuraEffect::HandleAuraDummy(bool apply, bool Real, bool changeAmount)
if (Real)
{
// pet auras
- if(PetAura const* petSpell = spellmgr.GetPetAura(GetId()))
+ if(PetAura const* petSpell = spellmgr.GetPetAura(GetId(), m_effIndex))
{
if(apply)
m_target->AddPetAura(petSpell);
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 08f833d0b6f..29c48cb7251 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -1994,7 +1994,7 @@ void Spell::EffectDummy(uint32 i)
}
// pet auras
- if(PetAura const* petSpell = spellmgr.GetPetAura(m_spellInfo->Id))
+ if(PetAura const* petSpell = spellmgr.GetPetAura(m_spellInfo->Id,i))
{
m_caster->AddPetAura(petSpell);
return;
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 513075ea2b6..8c34e243103 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -1892,8 +1892,8 @@ void SpellMgr::LoadSpellPetAuras()
uint32 count = 0;
- // 0 1 2
- QueryResult *result = WorldDatabase.Query("SELECT spell, pet, aura FROM spell_pet_auras");
+ // 0 1 2 3
+ QueryResult *result = WorldDatabase.Query("SELECT spell, effectId, pet, aura FROM spell_pet_auras");
if( !result )
{
@@ -1915,10 +1915,11 @@ void SpellMgr::LoadSpellPetAuras()
bar.step();
uint16 spell = fields[0].GetUInt16();
- uint16 pet = fields[1].GetUInt16();
- uint16 aura = fields[2].GetUInt16();
+ uint8 eff = fields[1].GetUInt8();
+ uint16 pet = fields[2].GetUInt16();
+ uint16 aura = fields[3].GetUInt16();
- SpellPetAuraMap::iterator itr = mSpellPetAuraMap.find(spell);
+ SpellPetAuraMap::iterator itr = mSpellPetAuraMap.find((spell<<8) + eff);
if(itr != mSpellPetAuraMap.end())
{
itr->second.AddAura(pet, aura);
@@ -1931,14 +1932,9 @@ void SpellMgr::LoadSpellPetAuras()
sLog.outErrorDb("Spell %u listed in `spell_pet_auras` does not exist", spell);
continue;
}
- int i = 0;
- for(; i < 3; ++i)
- if((spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA &&
- spellInfo->EffectApplyAuraName[i] == SPELL_AURA_DUMMY) ||
- spellInfo->Effect[i] == SPELL_EFFECT_DUMMY)
- break;
-
- if(i == 3)
+ if (spellInfo->Effect[eff] != SPELL_EFFECT_DUMMY &&
+ (spellInfo->Effect[eff] != SPELL_EFFECT_APPLY_AURA ||
+ spellInfo->EffectApplyAuraName[eff] != SPELL_AURA_DUMMY))
{
sLog.outError("Spell %u listed in `spell_pet_auras` does not have dummy aura or dummy effect", spell);
continue;
@@ -1951,8 +1947,8 @@ void SpellMgr::LoadSpellPetAuras()
continue;
}
- PetAura pa(pet, aura, spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_PET, spellInfo->CalculateSimpleValue(i));
- mSpellPetAuraMap[spell] = pa;
+ PetAura pa(pet, aura, spellInfo->EffectImplicitTargetA[eff] == TARGET_UNIT_PET, spellInfo->CalculateSimpleValue(eff));
+ mSpellPetAuraMap[(spell<<8) + eff] = pa;
}
++count;
diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h
index 9871930a8fd..b6f2c5d4eca 100644
--- a/src/game/SpellMgr.h
+++ b/src/game/SpellMgr.h
@@ -593,7 +593,7 @@ class PetAura
bool removeOnChangePet;
int32 damage;
};
-typedef std::map<uint16, PetAura> SpellPetAuraMap;
+typedef std::map<uint32, PetAura> SpellPetAuraMap;
struct SpellArea
{
@@ -965,9 +965,9 @@ class SpellMgr
return mSkillLineAbilityMap.upper_bound(spell_id);
}
- PetAura const* GetPetAura(uint16 spell_id)
+ PetAura const* GetPetAura(uint16 spell_id, uint8 eff)
{
- SpellPetAuraMap::const_iterator itr = mSpellPetAuraMap.find(spell_id);
+ SpellPetAuraMap::const_iterator itr = mSpellPetAuraMap.find((spell_id<<8) + eff);
if(itr != mSpellPetAuraMap.end())
return &itr->second;
else
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 7db06f19952..bc9923a5226 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -12845,33 +12845,6 @@ void Unit::SendPetTalk (uint32 pettalk)
((Player*)owner)->GetSession()->SendPacket(&data);
}
-void Unit::SendPetSpellCooldown (uint32 spellid, time_t cooltime)
-{
- Unit* owner = GetOwner();
- if(!owner || owner->GetTypeId() != TYPEID_PLAYER)
- return;
-
- WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4+4);
- data << uint64(GetGUID());
- data << uint8(0x0); // flags (0x1, 0x2)
- data << uint32(spellid);
- data << uint32(cooltime);
-
- ((Player*)owner)->GetSession()->SendPacket(&data);
-}
-
-void Unit::SendPetClearCooldown (uint32 spellid)
-{
- Unit* owner = GetOwner();
- if(!owner || owner->GetTypeId() != TYPEID_PLAYER)
- return;
-
- WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8);
- data << uint32(spellid);
- data << uint64(GetGUID());
- ((Player*)owner)->GetSession()->SendPacket(&data);
-}
-
void Unit::SendPetAIReaction(uint64 guid)
{
Unit* owner = GetOwner();
@@ -13368,12 +13341,6 @@ void Unit::AddPetAura(PetAura const* petSpell)
if(GetTypeId() != TYPEID_PLAYER)
return;
- // Aura already added - not need to add it twice
- // This check is to prevent existing pet having aura applied twice (passive auras can stack)
- // if aura has more than 1 dummy effect
- if (m_petAuras.find(petSpell)!= m_petAuras.end())
- return;
-
m_petAuras.insert(petSpell);
if(Pet* pet = ((Player*)this)->GetPet())
pet->CastPetAura(petSpell);
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 03a02f0c512..f9e076b6085 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1705,8 +1705,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void SendPetCastFail(uint32 spellid, SpellCastResult msg);
void SendPetActionFeedback (uint8 msg);
void SendPetTalk (uint32 pettalk);
- void SendPetSpellCooldown (uint32 spellid, time_t cooltime);
- void SendPetClearCooldown (uint32 spellid);
void SendPetAIReaction(uint64 guid);
///----------End of Pet responses methods----------