aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSpp <spp@jorge.gr>2013-01-02 14:20:20 +0100
committerSpp <spp@jorge.gr>2013-01-02 14:20:20 +0100
commit601fcc5612a3788b3f22f98c89809235d0b725a7 (patch)
treebcd069b5c670e209c1372595acd14c7e376cee7a /src
parentebd14b4f01cc64a2a488bdbb1046897cc4da8e9a (diff)
Core/Misc: Removed odd code from CreatureAIImpl.h, it does not belong here
- Also some minor corrections from previous commit
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp1
-rw-r--r--src/server/game/AI/CoreAI/UnitAI.cpp22
-rw-r--r--src/server/game/AI/CreatureAI.cpp88
-rw-r--r--src/server/game/AI/CreatureAIImpl.h110
-rw-r--r--src/server/game/Spells/Spell.cpp8
-rw-r--r--src/server/shared/Database/PreparedStatement.cpp8
-rw-r--r--src/server/shared/Database/PreparedStatement.h2
7 files changed, 119 insertions, 120 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index 14839196da8..31e49e4b8d3 100644
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -130,7 +130,6 @@ void PetAI::UpdateAI(const uint32 diff)
}
else
HandleReturnMovement();
-
}
// Autocast (casted only in combat or persistent spells in any state)
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp
index 81e32a2f8b6..a3cb57b3332 100644
--- a/src/server/game/AI/CoreAI/UnitAI.cpp
+++ b/src/server/game/AI/CoreAI/UnitAI.cpp
@@ -162,6 +162,28 @@ void UnitAI::DoCast(uint32 spellId)
me->CastSpell(target, spellId, false);
}
+void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
+{
+ if (!victim || (me->HasUnitState(UNIT_STATE_CASTING) && !triggered))
+ return;
+
+ me->CastSpell(victim, spellId, triggered);
+}
+
+void UnitAI::DoCastVictim(uint32 spellId, bool triggered)
+{
+ // Why don't we check for casting unit_state and existing target as we do in DoCast(.. ?
+ me->CastSpell(me->getVictim(), spellId, triggered);
+}
+
+void UnitAI::DoCastAOE(uint32 spellId, bool triggered)
+{
+ if (!triggered && me->HasUnitState(UNIT_STATE_CASTING))
+ return;
+
+ me->CastSpell((Unit*)NULL, spellId, triggered);
+}
+
#define UPDATE_TARGET(a) {if (AIInfo->target<a) AIInfo->target=a;}
void UnitAI::FillAISpellInfo()
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index 8491a055516..427818fe571 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -174,3 +174,91 @@ void CreatureAI::EnterEvadeMode()
if (!me->getVictim())
AttackStart(attacker);
}*/
+
+void CreatureAI::SetGazeOn(Unit* target)
+{
+ if (me->IsValidAttackTarget(target))
+ {
+ AttackStart(target);
+ me->SetReactState(REACT_PASSIVE);
+ }
+}
+
+bool CreatureAI::UpdateVictimWithGaze()
+{
+ if (!me->isInCombat())
+ return false;
+
+ if (me->HasReactState(REACT_PASSIVE))
+ {
+ if (me->getVictim())
+ return true;
+ else
+ me->SetReactState(REACT_AGGRESSIVE);
+ }
+
+ if (Unit* victim = me->SelectVictim())
+ AttackStart(victim);
+ return me->getVictim();
+}
+
+bool CreatureAI::UpdateVictim()
+{
+ if (!me->isInCombat())
+ return false;
+
+ if (!me->HasReactState(REACT_PASSIVE))
+ {
+ if (Unit* victim = me->SelectVictim())
+ AttackStart(victim);
+ return me->getVictim();
+ }
+ else if (me->getThreatManager().isThreatListEmpty())
+ {
+ EnterEvadeMode();
+ return false;
+ }
+
+ return true;
+}
+
+bool CreatureAI::_EnterEvadeMode()
+{
+ if (!me->isAlive())
+ return false;
+
+ // dont remove vehicle auras, passengers arent supposed to drop off the vehicle
+ me->RemoveAllAurasExceptType(SPELL_AURA_CONTROL_VEHICLE);
+
+ // sometimes bosses stuck in combat?
+ me->DeleteThreatList();
+ me->CombatStop(true);
+ me->LoadCreaturesAddon();
+ me->SetLootRecipient(NULL);
+ me->ResetPlayerDamageReq();
+
+ if (me->IsInEvadeMode())
+ return false;
+
+ return true;
+}
+
+Creature* CreatureAI::DoSummon(uint32 entry, const Position& pos, uint32 despawnTime, TempSummonType summonType)
+{
+ return me->SummonCreature(entry, pos, summonType, despawnTime);
+}
+
+Creature* CreatureAI::DoSummon(uint32 entry, WorldObject* obj, float radius, uint32 despawnTime, TempSummonType summonType)
+{
+ Position pos;
+ obj->GetRandomNearPosition(pos, radius);
+ return me->SummonCreature(entry, pos, summonType, despawnTime);
+}
+
+Creature* CreatureAI::DoSummonFlyer(uint32 entry, WorldObject* obj, float flightZ, float radius, uint32 despawnTime, TempSummonType summonType)
+{
+ Position pos;
+ obj->GetRandomNearPosition(pos, radius);
+ pos.m_positionZ += flightZ;
+ return me->SummonCreature(entry, pos, summonType, despawnTime);
+}
diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h
index f3e32b6033d..559240c4a3f 100644
--- a/src/server/game/AI/CreatureAIImpl.h
+++ b/src/server/game/AI/CreatureAIImpl.h
@@ -540,115 +540,5 @@ struct AISpellInfoType
AISpellInfoType* GetAISpellInfo(uint32 i);
-inline void CreatureAI::SetGazeOn(Unit* target)
-{
- if (me->IsValidAttackTarget(target))
- {
- AttackStart(target);
- me->SetReactState(REACT_PASSIVE);
- }
-}
-
-inline bool CreatureAI::UpdateVictimWithGaze()
-{
- if (!me->isInCombat())
- return false;
-
- if (me->HasReactState(REACT_PASSIVE))
- {
- if (me->getVictim())
- return true;
- else
- me->SetReactState(REACT_AGGRESSIVE);
- }
-
- if (Unit* victim = me->SelectVictim())
- AttackStart(victim);
- return me->getVictim();
-}
-
-inline bool CreatureAI::UpdateVictim()
-{
- if (!me->isInCombat())
- return false;
-
- if (!me->HasReactState(REACT_PASSIVE))
- {
- if (Unit* victim = me->SelectVictim())
- AttackStart(victim);
- return me->getVictim();
- }
- else if (me->getThreatManager().isThreatListEmpty())
- {
- EnterEvadeMode();
- return false;
- }
-
- return true;
-}
-
-inline bool CreatureAI::_EnterEvadeMode()
-{
- if (!me->isAlive())
- return false;
-
- // dont remove vehicle auras, passengers arent supposed to drop off the vehicle
- me->RemoveAllAurasExceptType(SPELL_AURA_CONTROL_VEHICLE);
-
- // sometimes bosses stuck in combat?
- me->DeleteThreatList();
- me->CombatStop(true);
- me->LoadCreaturesAddon();
- me->SetLootRecipient(NULL);
- me->ResetPlayerDamageReq();
-
- if (me->IsInEvadeMode())
- return false;
-
- return true;
-}
-
-inline void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
-{
- if (!victim || (me->HasUnitState(UNIT_STATE_CASTING) && !triggered))
- return;
-
- me->CastSpell(victim, spellId, triggered);
-}
-
-inline void UnitAI::DoCastVictim(uint32 spellId, bool triggered)
-{
- // Why don't we check for casting unit_state and existing target as we do in DoCast(.. ?
- me->CastSpell(me->getVictim(), spellId, triggered);
-}
-
-inline void UnitAI::DoCastAOE(uint32 spellId, bool triggered)
-{
- if (!triggered && me->HasUnitState(UNIT_STATE_CASTING))
- return;
-
- me->CastSpell((Unit*)NULL, spellId, triggered);
-}
-
-inline Creature* CreatureAI::DoSummon(uint32 entry, const Position& pos, uint32 despawnTime, TempSummonType summonType)
-{
- return me->SummonCreature(entry, pos, summonType, despawnTime);
-}
-
-inline Creature* CreatureAI::DoSummon(uint32 entry, WorldObject* obj, float radius, uint32 despawnTime, TempSummonType summonType)
-{
- Position pos;
- obj->GetRandomNearPosition(pos, radius);
- return me->SummonCreature(entry, pos, summonType, despawnTime);
-}
-
-inline Creature* CreatureAI::DoSummonFlyer(uint32 entry, WorldObject* obj, float flightZ, float radius, uint32 despawnTime, TempSummonType summonType)
-{
- Position pos;
- obj->GetRandomNearPosition(pos, radius);
- pos.m_positionZ += flightZ;
- return me->SummonCreature(entry, pos, summonType, despawnTime);
-}
-
#endif
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 9cbdab91032..68a2cbf4a8c 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -819,10 +819,10 @@ void Spell::SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTar
for (uint32 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j)
{
SpellEffectInfo const* effects = GetSpellInfo()->Effects;
- if (effects[effIndex].TargetA.GetTarget() == effects[j].TargetA.GetTarget()
- && effects[effIndex].TargetB.GetTarget() == effects[j].TargetB.GetTarget()
- && effects[effIndex].ImplicitTargetConditions == effects[j].ImplicitTargetConditions
- && effects[effIndex].CalcRadius(m_caster) == effects[j].CalcRadius(m_caster))
+ if (effects[effIndex].TargetA.GetTarget() == effects[j].TargetA.GetTarget() &&
+ effects[effIndex].TargetB.GetTarget() == effects[j].TargetB.GetTarget() &&
+ effects[effIndex].ImplicitTargetConditions == effects[j].ImplicitTargetConditions &&
+ effects[effIndex].CalcRadius(m_caster) == effects[j].CalcRadius(m_caster))
{
effectMask |= 1 << j;
}
diff --git a/src/server/shared/Database/PreparedStatement.cpp b/src/server/shared/Database/PreparedStatement.cpp
index 3256c3c9db3..86010e61686 100644
--- a/src/server/shared/Database/PreparedStatement.cpp
+++ b/src/server/shared/Database/PreparedStatement.cpp
@@ -33,7 +33,7 @@ void PreparedStatement::BindParameters()
{
ASSERT (m_stmt);
- uint32 i = 0;
+ uint8 i = 0;
for (; i < statement_data.size(); i++)
{
switch (statement_data[i].type)
@@ -241,7 +241,7 @@ void MySQLPreparedStatement::ClearParameters()
}
}
-static bool ParementerIndexAssertFail(uint32 stmtIndex, uint8 index, uint32 paramCount)
+static bool ParamenterIndexAssertFail(uint32 stmtIndex, uint8 index, uint32 paramCount)
{
sLog->outError(LOG_FILTER_SQL_DRIVER, "Attempted to bind parameter %u%s on a PreparedStatement %u (statement has only %u parameters)", uint32(index) + 1, (index == 1 ? "st" : (index == 2 ? "nd" : (index == 3 ? "rd" : "nd"))), stmtIndex, paramCount);
return false;
@@ -250,7 +250,7 @@ static bool ParementerIndexAssertFail(uint32 stmtIndex, uint8 index, uint32 para
//- Bind on mysql level
bool MySQLPreparedStatement::CheckValidIndex(uint8 index)
{
- ASSERT(index < m_paramCount || ParementerIndexAssertFail(m_stmt->m_index, index, m_paramCount));
+ ASSERT(index < m_paramCount || ParamenterIndexAssertFail(m_stmt->m_index, index, m_paramCount));
if (m_paramsSet[index])
sLog->outWarn(LOG_FILTER_SQL, "[WARNING] Prepared Statement (id: %u) trying to bind value on already bound index (%u).", m_stmt->m_index, index);
@@ -386,7 +386,7 @@ void MySQLPreparedStatement::setValue(MYSQL_BIND* param, enum_field_types type,
memcpy(param->buffer, value, len);
}
-std::string MySQLPreparedStatement::getQueryString(std::string const &sqlPattern) const
+std::string MySQLPreparedStatement::getQueryString(std::string const& sqlPattern) const
{
std::string queryString = sqlPattern;
diff --git a/src/server/shared/Database/PreparedStatement.h b/src/server/shared/Database/PreparedStatement.h
index 9334bc6dc66..2cab6e40de0 100644
--- a/src/server/shared/Database/PreparedStatement.h
+++ b/src/server/shared/Database/PreparedStatement.h
@@ -135,7 +135,7 @@ class MySQLPreparedStatement
PreparedStatement* m_stmt;
void ClearParameters();
bool CheckValidIndex(uint8 index);
- std::string getQueryString(std::string const &sqlPattern) const;
+ std::string getQueryString(std::string const& sqlPattern) const;
private:
void setValue(MYSQL_BIND* param, enum_field_types type, const void* value, uint32 len, bool isUnsigned);