diff options
author | megamage <none@none> | 2009-03-20 14:23:25 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-03-20 14:23:25 -0600 |
commit | d7e05e8003a095db6e10c470d96a80f431046099 (patch) | |
tree | c4df7751b99bdc58350cda37b08579dbf2b23b32 /src | |
parent | 7f130ba9717902a56439d660d17f31b00dded470 (diff) |
*Fix some out-of-range array indices of totem slot and charm spell slot.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Player.cpp | 10 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 2 | ||||
-rw-r--r-- | src/game/Unit.cpp | 6 | ||||
-rw-r--r-- | src/game/Unit.h | 6 |
4 files changed, 14 insertions, 10 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index c047e3f8794..4373ae2098a 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -17207,7 +17207,7 @@ void Player::PetSpellInitialize() data << uint8(pet->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0); // action bar loop - for(uint32 i = 0; i < 10; i++) + for(uint32 i = 0; i < MAX_SPELL_CONTROL_BAR; ++i) { data << uint32(charmInfo->GetActionBarEntry(i)->Raw); } @@ -17336,7 +17336,7 @@ void Player::VehicleSpellInitialize() data << uint16(spellId) << uint8(0) << uint8(i+8); } - for(uint32 i = CREATURE_MAX_SPELLS; i < 10; ++i) + for(uint32 i = CREATURE_MAX_SPELLS; i < MAX_SPELL_CONTROL_BAR; ++i) data << uint16(0) << uint8(0) << uint8(i+8); data << uint8(0); @@ -17365,7 +17365,7 @@ void Player::CharmSpellInitialize() CreatureInfo const *cinfo = ((Creature*)charm)->GetCreatureInfo(); //if(cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK) { - for(uint32 i = 0; i < 4; ++i) + for(uint32 i = 0; i < MAX_SPELL_CHARM; ++i) { if(charmInfo->GetCharmSpell(i)->spellId) ++addlist; @@ -17386,7 +17386,7 @@ void Player::CharmSpellInitialize() data << uint16(0); //action bar 40 - for(uint32 i = 0; i < 10; ++i) //40 + for(uint32 i = 0; i < MAX_SPELL_CONTROL_BAR; ++i) //40 { data << uint16(charmInfo->GetActionBarEntry(i)->SpellOrAction) << uint16(charmInfo->GetActionBarEntry(i)->Type); } @@ -17395,7 +17395,7 @@ void Player::CharmSpellInitialize() data << uint8(addlist); //1 if(addlist) { - for(uint32 i = 0; i < 4; ++i) + for(uint32 i = 0; i < MAX_SPELL_CHARM; ++i) { CharmSpellEntry *cspell = charmInfo->GetCharmSpell(i); if(cspell->spellId) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 583087a5106..775ac762cd2 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -6539,7 +6539,7 @@ void Spell::SummonTotem(uint32 entry, SummonPropertiesEntry const *properties) pTotem->Relocate(x, y, z, m_caster->GetOrientation()); - if(slot < MAX_TOTEM) + if(slot >= 0 && slot < MAX_TOTEM) m_caster->m_TotemSlot[slot] = pTotem->GetGUID(); pTotem->SetOwner(m_caster->GetGUID()); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index c57528e87a9..77f0a0eb4c3 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8157,7 +8157,7 @@ bool Unit::isAttackingPlayer() const if(charmed && charmed->isAttackingPlayer()) return true; - for (int8 i = 0; i < MAX_TOTEM; i++) + for (int8 i = 0; i < MAX_SUMMON_SLOT; ++i) { if(m_TotemSlot[i]) { @@ -11561,7 +11561,7 @@ void CharmInfo::InitCharmCreateSpells() InitPetActionBar(); - for(uint32 x = 0; x < 4; ++x) + for(uint32 x = 0; x < MAX_SPELL_CHARM; ++x) { uint32 spellId = ((Creature*)m_unit)->m_spells[x]; m_charmspells[x].spellId = spellId; @@ -11623,7 +11623,7 @@ void CharmInfo::ToggleCreatureAutocast(uint32 spellid, bool apply) if(IsPassiveSpell(spellid)) return; - for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) + for(uint32 x = 0; x < MAX_SPELL_CHARM; ++x) { if(spellid == m_charmspells[x].spellId) { diff --git a/src/game/Unit.h b/src/game/Unit.h index b06f2582f2e..ff2826c3b44 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -219,6 +219,10 @@ enum UnitRename }; #define CREATURE_MAX_SPELLS 8 +#define MAX_SPELL_CHARM 4 +#define MAX_SPELL_VEHICLE 6 +#define MAX_SPELL_POSSESS 8 +#define MAX_SPELL_CONTROL_BAR 10 enum Swing { @@ -1301,7 +1305,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject Spell* m_currentSpells[CURRENT_MAX_SPELL]; uint32 m_addDmgOnce; - uint64 m_TotemSlot[MAX_TOTEM]; + uint64 m_TotemSlot[MAX_SUMMON_SLOT]; uint64 m_ObjectSlot[4]; uint32 m_detectInvisibilityMask; uint32 m_invisibilityMask; |