diff options
| author | maximius <none@none> | 2009-11-22 00:46:38 -0800 |
|---|---|---|
| committer | maximius <none@none> | 2009-11-22 00:46:38 -0800 |
| commit | da5c1bca546028d310bbf12340ca721146dc02f0 (patch) | |
| tree | 141914dc48555e4fce0dac2376e78636a7b44968 /src/game | |
| parent | 461e8d134f9ca432349e65d96fb038269fa4127f (diff) | |
*Cleanup, fix a few warnings, and make the SD2 grid searchers just pass through to the standard Trinity grid searchers, as they have identical functionality. Thanks thmarth. Closes #387, #388
--HG--
branch : trunk
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/GridNotifiers.h | 4 | ||||
| -rw-r--r-- | src/game/Object.cpp | 54 | ||||
| -rw-r--r-- | src/game/Object.h | 6 | ||||
| -rw-r--r-- | src/game/SpellEffects.cpp | 22 | ||||
| -rw-r--r-- | src/game/SpellMgr.h | 26 |
5 files changed, 49 insertions, 63 deletions
diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 424be2121d2..ed6232b101f 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -1072,12 +1072,12 @@ namespace Trinity class NearestCreatureEntryWithLiveStateInObjectRangeCheck { public: - NearestCreatureEntryWithLiveStateInObjectRangeCheck(WorldObject const& obj,uint32 entry, bool alive, float range) + NearestCreatureEntryWithLiveStateInObjectRangeCheck(WorldObject const& obj, uint32 entry, bool alive, float range) : i_obj(obj), i_entry(entry), i_alive(alive), i_range(range) {} bool operator()(Creature* u) { - if(u->GetEntry() == i_entry && u->isAlive()==i_alive && i_obj.IsWithinDistInMap(u, i_range)) + if (u->GetEntry() == i_entry && u->isAlive() == i_alive && i_obj.IsWithinDistInMap(u, i_range)) { i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check return true; diff --git a/src/game/Object.cpp b/src/game/Object.cpp index bfca0c91861..68f7d08be68 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1931,52 +1931,38 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3 return summon; } -Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive) +Creature* WorldObject::FindNearestCreature(uint32 uiEntry, float fMaxSearchRange, bool bAlive) { - Creature *creature = NULL; - Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range); - Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(this, creature, checker); - VisitNearbyObject(range, searcher); - return creature; + Creature *pCreature = NULL; + Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, uiEntry, bAlive, fMaxSearchRange); + Trinity::CreatureLastSearcher<Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(this, pCreature, checker); + VisitNearbyObject(fMaxSearchRange, searcher); + return pCreature; } -GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) +GameObject* WorldObject::FindNearestGameObject(uint32 uiEntry, float fMaxSearchRange) { - GameObject *go = NULL; - Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range); - Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> searcher(this, go, checker); - VisitNearbyGridObject(range, searcher); - return go; -} - -void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) -{ - CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - - Trinity::AllGameObjectsWithEntryInRange check(this, uiEntry, fMaxSearchRange); - Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, lList, check); - TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher); - - CellLock<GridReadGuard> cell_lock(cell, pair); - cell_lock->Visit(cell_lock, visitor, *(this->GetMap())); + GameObject *pGO = NULL; + Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, uiEntry, fMaxSearchRange); + Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> searcher(this, pGO, checker); + VisitNearbyGridObject(fMaxSearchRange, searcher); + return pGO; } void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) { - CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY())); - Cell cell(pair); - cell.data.Part.reserved = ALL_DISTRICT; - cell.SetNoCreate(); - Trinity::AllCreaturesOfEntryInRange check(this, uiEntry, fMaxSearchRange); Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, lList, check); TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher); + VisitNearbyObject(fMaxSearchRange, searcher); +} - CellLock<GridReadGuard> cell_lock(cell, pair); - cell_lock->Visit(cell_lock, visitor, *(this->GetMap())); +void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) +{ + Trinity::AllGameObjectsWithEntryInRange check(this, uiEntry, fMaxSearchRange); + Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, lList, check); + TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher); + VisitNearbyGridObject(fMaxSearchRange, searcher); } /* diff --git a/src/game/Object.h b/src/game/Object.h index 826775500d2..3d07b4625e6 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -610,11 +610,11 @@ class TRINITY_DLL_SPEC WorldObject : public Object, public WorldLocation GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime); Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); - Creature* FindNearestCreature(uint32 entry, float range, bool alive = true); - GameObject* FindNearestGameObject(uint32 entry, float range); + Creature* FindNearestCreature(uint32 uiEntry, float fMaxSearchRange, bool bAlive = true); + GameObject* FindNearestGameObject(uint32 uiEntry, float fMaxSearchRange); - void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange); void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange); + void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange); void DestroyForNearbyPlayers(); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index fb4c36ced1a..538a945ee26 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4637,10 +4637,10 @@ void Spell::SpellDamageWeaponDmg(uint32 i) } bool normalized = false; - float weaponDamagePercentMod = 1.0; - for (int j = 0; j < 3; ++j) + float weaponDamagePercentMod = 1.0f; + for (uint8 j = 0; j < 3; ++j) { - switch(m_spellInfo->Effect[j]) + switch (m_spellInfo->Effect[j]) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: @@ -4659,10 +4659,10 @@ void Spell::SpellDamageWeaponDmg(uint32 i) } // apply to non-weapon bonus weapon total pct effect, weapon total flat effect included in weapon damage - if(fixed_bonus || spell_bonus) + if (fixed_bonus || spell_bonus) { UnitMods unitMod; - switch(m_attackType) + switch (m_attackType) { default: case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break; @@ -4671,23 +4671,23 @@ void Spell::SpellDamageWeaponDmg(uint32 i) } float weapon_total_pct = 1.0f; - if ( m_spellInfo->SchoolMask & SPELL_SCHOOL_MASK_NORMAL ) + if (m_spellInfo->SchoolMask & SPELL_SCHOOL_MASK_NORMAL) weapon_total_pct = m_caster->GetModifierValue(unitMod, TOTAL_PCT); - if(fixed_bonus) + if (fixed_bonus) fixed_bonus = int32(fixed_bonus * weapon_total_pct); - if(spell_bonus) + if (spell_bonus) spell_bonus = int32(spell_bonus * weapon_total_pct); } int32 weaponDamage = m_caster->CalculateDamage(m_attackType, normalized, true); // Sequence is important - for (int j = 0; j < 3; ++j) + for (uint8 j = 0; j < 3; ++j) { // We assume that a spell have at most one fixed_bonus // and at most one weaponDamagePercentMod - switch(m_spellInfo->Effect[j]) + switch (m_spellInfo->Effect[j]) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: @@ -4714,7 +4714,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) // Add melee damage bonuses (also check for negative) m_caster->MeleeDamageBonus(unitTarget, &eff_damage, m_attackType, m_spellInfo); - m_damage+= eff_damage; + m_damage += eff_damage; } void Spell::EffectThreat(uint32 /*i*/) diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index da5a6affde7..b3f98ec7fe3 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -810,7 +810,7 @@ class SpellMgr uint32 GetSpellElixirMask(uint32 spellid) const { SpellElixirMap::const_iterator itr = mSpellElixirs.find(spellid); - if(itr==mSpellElixirs.end()) + if (itr == mSpellElixirs.end()) return 0x0; return itr->second; @@ -819,13 +819,13 @@ class SpellMgr SpellSpecific GetSpellElixirSpecific(uint32 spellid) const { uint32 mask = GetSpellElixirMask(spellid); - if((mask & ELIXIR_FLASK_MASK)==ELIXIR_FLASK_MASK) + if ((mask & ELIXIR_FLASK_MASK) == ELIXIR_FLASK_MASK) return SPELL_FLASK_ELIXIR; - else if(mask & ELIXIR_BATTLE_MASK) + else if (mask & ELIXIR_BATTLE_MASK) return SPELL_BATTLE_ELIXIR; - else if(mask & ELIXIR_GUARDIAN_MASK) + else if (mask & ELIXIR_GUARDIAN_MASK) return SPELL_GUARDIAN_ELIXIR; - else if(mask & ELIXIR_WELL_FED) + else if (mask & ELIXIR_WELL_FED) return SPELL_WELL_FED; else return SPELL_NORMAL; @@ -834,7 +834,7 @@ class SpellMgr uint16 GetSpellThreat(uint32 spellid) const { SpellThreatMap::const_iterator itr = mSpellThreatMap.find(spellid); - if(itr==mSpellThreatMap.end()) + if (itr == mSpellThreatMap.end()) return 0; return itr->second; @@ -844,7 +844,7 @@ class SpellMgr SpellProcEventEntry const* GetSpellProcEvent(uint32 spellId) const { SpellProcEventMap::const_iterator itr = mSpellProcEventMap.find(spellId); - if( itr != mSpellProcEventMap.end( ) ) + if (itr != mSpellProcEventMap.end()) return &itr->second; return NULL; } @@ -854,7 +854,7 @@ class SpellMgr SpellEnchantProcEntry const* GetSpellEnchantProcEvent(uint32 enchId) const { SpellEnchantProcEventMap::const_iterator itr = mSpellEnchantProcEventMap.find(enchId); - if( itr != mSpellEnchantProcEventMap.end( ) ) + if (itr != mSpellEnchantProcEventMap.end()) return &itr->second; return NULL; } @@ -864,13 +864,13 @@ class SpellMgr { // Lookup data SpellBonusMap::const_iterator itr = mSpellBonusMap.find(spellId); - if( itr != mSpellBonusMap.end( ) ) + if (itr != mSpellBonusMap.end()) return &itr->second; // Not found, try lookup for 1 spell rank if exist if (uint32 rank_1 = GetFirstSpellInChain(spellId)) { SpellBonusMap::const_iterator itr2 = mSpellBonusMap.find(rank_1); - if( itr2 != mSpellBonusMap.end( ) ) + if (itr2 != mSpellBonusMap.end()) return &itr2->second; } return NULL; @@ -880,7 +880,7 @@ class SpellMgr SpellTargetPosition const* GetSpellTargetPosition(uint32 spell_id) const { SpellTargetPositionMap::const_iterator itr = mSpellTargetPositions.find( spell_id ); - if( itr != mSpellTargetPositions.end( ) ) + if (itr != mSpellTargetPositions.end()) return &itr->second; return NULL; } @@ -889,7 +889,7 @@ class SpellMgr SpellChainNode const* GetSpellChainNode(uint32 spell_id) const { SpellChainMap::const_iterator itr = mSpellChains.find(spell_id); - if(itr == mSpellChains.end()) + if (itr == mSpellChains.end()) return NULL; return &itr->second; @@ -1009,7 +1009,7 @@ class SpellMgr { SpellLearnSpellMapBounds bounds = GetSpellLearnSpellMapBounds(spell_id1); for (SpellLearnSpellMap::const_iterator i = bounds.first; i != bounds.second; ++i) - if (i->second.spell==spell_id2) + if (i->second.spell == spell_id2) return true; return false; } |
