aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2013-05-13 05:55:43 -0700
committerShauren <shauren.trinity@gmail.com>2013-05-13 05:55:43 -0700
commite5928e13d705e6bb50571742f6c967c559f983ee (patch)
treea4e97fb899b17a9a24ddb2b4b6f619a3b8f10e84 /src
parent16074667c074131476adb6166918d4a9ee450d4d (diff)
parent78195b3c54a32866f96efb02457fe8161460b692 (diff)
Merge pull request #9790 from vlad852/master
spell_target_position - allow use effectIndex
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Spells/Spell.cpp2
-rw-r--r--src/server/game/Spells/SpellMgr.cpp44
-rw-r--r--src/server/game/Spells/SpellMgr.h6
3 files changed, 23 insertions, 29 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 0c6d70add0b..63ec9d032ff 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -1391,7 +1391,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
m_targets.SetDst(playerCaster->m_homebindX, playerCaster->m_homebindY, playerCaster->m_homebindZ, playerCaster->GetOrientation(), playerCaster->m_homebindMapId);
return;
case TARGET_DEST_DB:
- if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id))
+ if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id, effIndex))
{
/// @todo fix this check
if (m_spellInfo->HasEffect(SPELL_EFFECT_TELEPORT_UNITS) || m_spellInfo->HasEffect(SPELL_EFFECT_BIND))
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index ee34e26808c..8f2e05bde53 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -620,9 +620,9 @@ bool SpellMgr::IsSpellLearnToSpell(uint32 spell_id1, uint32 spell_id2) const
return false;
}
-SpellTargetPosition const* SpellMgr::GetSpellTargetPosition(uint32 spell_id) const
+SpellTargetPosition const* SpellMgr::GetSpellTargetPosition(uint32 spell_id, SpellEffIndex effIndex) const
{
- SpellTargetPositionMap::const_iterator itr = mSpellTargetPositions.find(spell_id);
+ SpellTargetPositionMap::const_iterator itr = mSpellTargetPositions.find(std::make_pair(spell_id, effIndex));
if (itr != mSpellTargetPositions.end())
return &itr->second;
return NULL;
@@ -1501,8 +1501,8 @@ void SpellMgr::LoadSpellTargetPositions()
mSpellTargetPositions.clear(); // need for reload case
- // 0 1 2 3 4 5
- QueryResult result = WorldDatabase.Query("SELECT id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM spell_target_position");
+ // 0 1 2 3 4 5 6
+ QueryResult result = WorldDatabase.Query("SELECT id, effIndex, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM spell_target_position");
if (!result)
{
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 spell target coordinates. DB table `spell_target_position` is empty.");
@@ -1515,54 +1515,48 @@ void SpellMgr::LoadSpellTargetPositions()
Field* fields = result->Fetch();
uint32 Spell_ID = fields[0].GetUInt32();
+ SpellEffIndex effIndex = SpellEffIndex(fields[1].GetUInt8());
SpellTargetPosition st;
- st.target_mapId = fields[1].GetUInt16();
- st.target_X = fields[2].GetFloat();
- st.target_Y = fields[3].GetFloat();
- st.target_Z = fields[4].GetFloat();
- st.target_Orientation = fields[5].GetFloat();
+ st.target_mapId = fields[2].GetUInt16();
+ st.target_X = fields[3].GetFloat();
+ st.target_Y = fields[4].GetFloat();
+ st.target_Z = fields[5].GetFloat();
+ st.target_Orientation = fields[6].GetFloat();
MapEntry const* mapEntry = sMapStore.LookupEntry(st.target_mapId);
if (!mapEntry)
{
- sLog->outError(LOG_FILTER_SQL, "Spell (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.", Spell_ID, st.target_mapId);
+ sLog->outError(LOG_FILTER_SQL, "Spell (Id: %u, effIndex: %u) target map (ID: %u) does not exist in `Map.dbc`.", Spell_ID, effIndex, st.target_mapId);
continue;
}
if (st.target_X==0 && st.target_Y==0 && st.target_Z==0)
{
- sLog->outError(LOG_FILTER_SQL, "Spell (ID:%u) target coordinates not provided.", Spell_ID);
+ sLog->outError(LOG_FILTER_SQL, "Spell (Id: %u, effIndex: %u) target coordinates not provided.", Spell_ID, effIndex);
continue;
}
SpellInfo const* spellInfo = GetSpellInfo(Spell_ID);
if (!spellInfo)
{
- sLog->outError(LOG_FILTER_SQL, "Spell (Id: %u) listed in `spell_target_position` does not exist.", Spell_ID);
+ sLog->outError(LOG_FILTER_SQL, "Spell (ID:%u) listed in `spell_target_position` does not exist.", Spell_ID);
continue;
}
- bool found = false;
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ if (spellInfo->Effects[effIndex].TargetA.GetTarget() == TARGET_DEST_DB || spellInfo->Effects[effIndex].TargetB.GetTarget() == TARGET_DEST_DB)
{
- if (spellInfo->Effects[i].TargetA.GetTarget() == TARGET_DEST_DB || spellInfo->Effects[i].TargetB.GetTarget() == TARGET_DEST_DB)
- {
- found = true;
- break;
- }
+ std::pair<uint32, SpellEffIndex> key = std::make_pair(Spell_ID, effIndex);
+ mSpellTargetPositions[key] = st;
+ ++count;
}
-
- if (!found)
+ else
{
- sLog->outError(LOG_FILTER_SQL, "Spell (Id: %u) listed in `spell_target_position` does not have target TARGET_DEST_DB (17).", Spell_ID);
+ sLog->outError(LOG_FILTER_SQL, "Spell (Id: %u, effIndex: %u) listed in `spell_target_position` does not have target TARGET_DEST_DB (17).", Spell_ID, effIndex);
continue;
}
- mSpellTargetPositions[Spell_ID] = st;
- ++count;
-
} while (result->NextRow());
/*
diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h
index c1b64e76a41..b7a3294efe3 100644
--- a/src/server/game/Spells/SpellMgr.h
+++ b/src/server/game/Spells/SpellMgr.h
@@ -377,6 +377,8 @@ struct SpellTargetPosition
float target_Orientation;
};
+typedef std::map<std::pair<uint32 /*spell_id*/, SpellEffIndex /*effIndex*/>, SpellTargetPosition> SpellTargetPositionMap;
+
// Enum with EffectRadiusIndex and their actual radius
enum EffectRadiusIndex
{
@@ -439,8 +441,6 @@ enum EffectRadiusIndex
EFFECT_RADIUS_80_YARDS_2 = 65
};
-typedef UNORDERED_MAP<uint32, SpellTargetPosition> SpellTargetPositionMap;
-
// Spell pet auras
class PetAura
{
@@ -641,7 +641,7 @@ class SpellMgr
bool IsSpellLearnToSpell(uint32 spell_id1, uint32 spell_id2) const;
// Spell target coordinates
- SpellTargetPosition const* GetSpellTargetPosition(uint32 spell_id) const;
+ SpellTargetPosition const* GetSpellTargetPosition(uint32 spell_id, SpellEffIndex effIndex) const;
// Spell Groups table
SpellSpellGroupMapBounds GetSpellSpellGroupMapBounds(uint32 spell_id) const;