Core: Some optimizations

- Declare some functions const
- Fix some mem leak
- Fix some resource leak
- Remove unused variables and functions
- Remove duplicate functions
- Reduce the scope of some variables
- Remove unused file

--HG--
branch : trunk
This commit is contained in:
Spp
2010-12-06 02:07:53 +01:00
parent e226c4ac34
commit 408fce1de6
73 changed files with 200 additions and 712 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ class GameObjectAI
virtual bool GossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) {return false;}
virtual bool QuestAccept(Player* /*player*/, Quest const* /*quest*/) {return false;}
virtual bool QuestReward(Player* /*player*/, Quest const* /*quest*/, uint32 /*opt*/) {return false;}
uint32 GetDialogStatus(Player* /*player*/) {return 100;}
virtual uint32 GetDialogStatus(Player* /*player*/) {return 100;}
virtual void Destroyed(Player* /*player*/, uint32 /*eventId*/) {}
virtual void SetData(uint32 /*id*/, uint32 /*value*/) {}
};
-1
View File
@@ -70,7 +70,6 @@ class CreatureAI : public UnitAI
bool UpdateVictim();
bool UpdateVictimWithGaze();
bool UpdateCombatState();
void SetGazeOn(Unit *target);
-20
View File
@@ -524,26 +524,6 @@ inline bool CreatureAI::UpdateVictimWithGaze()
return me->getVictim();
}
inline bool CreatureAI::UpdateCombatState()
{
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::UpdateVictim()
{
if (!me->isInCombat())
@@ -269,7 +269,7 @@ struct BossAI : public ScriptedAI
void Reset() { _Reset(); }
void EnterCombat(Unit * /*who*/) { _EnterCombat(); }
void JustDied(Unit * /*killer*/) { _JustDied(); }
void JustReachedHome() { me->setActive(false); }
void JustReachedHome() { _JustReachedHome(); }
protected:
void _Reset();
@@ -53,7 +53,7 @@ class SmartScript
SmartScriptHolder CreateEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 phaseMask = 0);
void AddEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 phaseMask = 0);
void SetPathId(uint32 id) { mPathId = id; }
uint32 GetPathId() { return mPathId; }
uint32 GetPathId() const { return mPathId; }
WorldObject* GetBaseObject()
{
WorldObject* obj = NULL;
@@ -188,7 +188,7 @@ class SmartScript
DecPhase(abs(p));
}
void DecPhase(int32 p = 1) { mEventPhase -= (mEventPhase < (uint32)p ? (uint32)p - mEventPhase : (uint32)p); }
bool IsInPhase(uint32 p) { return mEventPhase & p; }
bool IsInPhase(uint32 p) const { return mEventPhase & p; }
void SetPhase(uint32 p = 0) { mEventPhase = p; }
SmartAIEventList mEvents;
@@ -1121,10 +1121,10 @@ struct SmartScriptHolder
SmartTarget target;
public:
uint32 GetScriptType() { return (uint32)source_type; }
uint32 GetEventType() { return (uint32)event.type; }
uint32 GetActionType() { return (uint32)action.type; }
uint32 GetTargetType() { return (uint32)target.type; }
uint32 GetScriptType() const { return (uint32)source_type; }
uint32 GetEventType() const { return (uint32)event.type; }
uint32 GetActionType() const { return (uint32)action.type; }
uint32 GetTargetType() const { return (uint32)target.type; }
uint32 timer;
bool active;