[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
This commit is contained in:
QAston
2009-06-23 14:05:37 +02:00
parent 64786941dd
commit f2ec641e42
12 changed files with 100 additions and 143 deletions
-5
View File
@@ -74,11 +74,6 @@ INSERT INTO `spell_linked_spell` (`spell_trigger`, `spell_effect`, `type`, `comm
( -52610, -62071, 0, 'Savage Roar'),
(51209, 55095, 1, 'Hungering cold - frost fever'),
(50334, 58923, 2, 'Berserk - modify target number aura'),
(57447,57485,2,'Kindred Spirits'),
(57482,57484,2,'Kindred Spirits'),
(57453,57483,2,'Kindred Spirits'),
(57457,57482,2,'Kindred Spirits'),
(57458,57475,2,'Kindred Spirits'),
-- Creature
( 36574, 36650, 0, 'Apply Phase Slip Vulnerability'),
+17
View File
@@ -0,0 +1,17 @@
ALTER TABLE spell_pet_auras ADD effectId TINYINT( 3 ) UNSIGNED NOT NULL AFTER spell;
ALTER TABLE spell_pet_auras DROP PRIMARY KEY, ADD PRIMARY KEY(spell,effectId,pet);
INSERT INTO spell_pet_auras VALUES
(56314, 0, 0, 57447),
(56314, 1, 0, 57485),
(56315, 0, 0, 57452),
(56315, 1, 0, 57484),
(56316, 0, 0, 57453),
(56316, 1, 0, 57483),
(56317, 0, 0, 57457),
(56317, 1, 0, 57482),
(56318, 0, 0, 57458),
(56318, 1, 0, 57475);
DELETE FROM spell_linked_spell where `spell_trigger` in (57447,57482,57453, 57457, 57458);
+46 -43
View File
@@ -14270,9 +14270,10 @@ SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `spell_pet_auras` (
`spell` mediumint(8) unsigned NOT NULL COMMENT 'dummy spell id',
`effectId` tinyint(3) unsigned NOT NULL default '0',
`pet` mediumint(8) unsigned NOT NULL default '0' COMMENT 'pet id; 0 = all',
`aura` mediumint(8) unsigned NOT NULL COMMENT 'pet aura id',
PRIMARY KEY (`spell`,`pet`)
PRIMARY KEY (`spell`,`effectId`,`pet`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;
@@ -14283,48 +14284,50 @@ SET character_set_client = @saved_cs_client;
LOCK TABLES `spell_pet_auras` WRITE;
/*!40000 ALTER TABLE `spell_pet_auras` DISABLE KEYS */;
INSERT INTO `spell_pet_auras` VALUES
(18754,65536,18754),
(18755,65536,18755),
(18756,65536,18756),
(19028,0,25228),
(19578,0,19579),
(20895,0,24529),
(28757,0,28758),
(35029,0,35060),
(35030,0,35061),
(35691,0,35696),
(35692,0,35696),
(35693,0,35696),
(23785,416,23759),
(23822,416,23826),
(23823,416,23827),
(23824,416,23828),
(23825,416,23829),
(23785,417,23762),
(23822,417,23837),
(23823,417,23838),
(23824,417,23839),
(23825,417,23840),
(23785,1860,23760),
(23822,1860,23841),
(23823,1860,23842),
(23824,1860,23843),
(23825,1860,23844),
(23785,1863,23761),
(23822,1863,23833),
(23823,1863,23834),
(23824,1863,23835),
(23825,1863,23836),
(23785,17252,35702),
(23822,17252,35703),
(23823,17252,35704),
(23824,17252,35705),
(23825,17252,35706),
(56314,0,57447),
(56315,0,57482),
(56316,0,57453),
(56317,0,57457),
(56318,0,57458);
(19028, 0, 0, 25228),
(19578, 0, 0, 19579),
(20895, 0, 0, 24529),
(28757, 0, 0, 28758),
(35029, 0, 0, 35060),
(35030, 0, 0, 35061),
(35691, 0, 0, 35696),
(35692, 0, 0, 35696),
(35693, 0, 0, 35696),
(56314, 0, 0, 57447),
(56314, 1, 0, 57485),
(56315, 0, 0, 57452),
(56315, 1, 0, 57484),
(56316, 0, 0, 57453),
(56316, 1, 0, 57483),
(56317, 0, 0, 57457),
(56317, 1, 0, 57482),
(56318, 0, 0, 57458),
(56318, 1, 0, 57475),
(23785, 0, 416, 23759),
(23822, 0, 416, 23826),
(23823, 0, 416, 23827),
(23824, 0, 416, 23828),
(23825, 0, 416, 23829),
(23785, 0, 417, 23762),
(23822, 0, 417, 23837),
(23823, 0, 417, 23838),
(23824, 0, 417, 23839),
(23825, 0, 417, 23840),
(23785, 0, 1860, 23760),
(23822, 0, 1860, 23841),
(23823, 0, 1860, 23842),
(23824, 0, 1860, 23843),
(23825, 0, 1860, 23844),
(23785, 0, 1863, 23761),
(23822, 0, 1863, 23833),
(23823, 0, 1863, 23834),
(23824, 0, 1863, 23835),
(23825, 0, 1863, 23836),
(23785, 0, 17252, 35702),
(23822, 0, 17252, 35703),
(23823, 0, 17252, 35704),
(23824, 0, 17252, 35705),
(23825, 0, 17252, 35706);
/*!40000 ALTER TABLE `spell_pet_auras` ENABLE KEYS */;
UNLOCK TABLES;
+3 -3
View File
@@ -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);
+16 -37
View File
@@ -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);
}
+2
View File
@@ -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();
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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;
+11 -15
View File
@@ -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;
+3 -3
View File
@@ -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
-33
View File
@@ -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);
-2
View File
@@ -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----------