mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-24 20:02:27 +00:00
Switch AI timers to smart pointers
This commit is contained in:
parent
2211a63fe7
commit
99164fe3f9
17
zone/mob.h
17
zone/mob.h
@ -25,6 +25,7 @@
|
|||||||
#include "position.h"
|
#include "position.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
char* strn0cpy(char* dest, const char* source, uint32 size);
|
char* strn0cpy(char* dest, const char* source, uint32 size);
|
||||||
|
|
||||||
@ -879,8 +880,8 @@ public:
|
|||||||
virtual FACTION_VALUE GetReverseFactionCon(Mob* iOther) { return FACTION_INDIFFERENT; }
|
virtual FACTION_VALUE GetReverseFactionCon(Mob* iOther) { return FACTION_INDIFFERENT; }
|
||||||
|
|
||||||
inline bool IsTrackable() const { return(trackable); }
|
inline bool IsTrackable() const { return(trackable); }
|
||||||
Timer* GetAIThinkTimer() { return AIthink_timer; }
|
const Timer* GetAIThinkTimer() { return AIthink_timer.get(); }
|
||||||
Timer* GetAIMovementTimer() { return AImovement_timer; }
|
const Timer* GetAIMovementTimer() { return AImovement_timer.get(); }
|
||||||
Timer GetAttackTimer() { return attack_timer; }
|
Timer GetAttackTimer() { return attack_timer; }
|
||||||
Timer GetAttackDWTimer() { return attack_dw_timer; }
|
Timer GetAttackDWTimer() { return attack_dw_timer; }
|
||||||
inline bool IsFindable() { return findable; }
|
inline bool IsFindable() { return findable; }
|
||||||
@ -1170,14 +1171,14 @@ protected:
|
|||||||
uint32 maxLastFightingDelayMoving;
|
uint32 maxLastFightingDelayMoving;
|
||||||
float pAggroRange;
|
float pAggroRange;
|
||||||
float pAssistRange;
|
float pAssistRange;
|
||||||
Timer* AIthink_timer;
|
std::unique_ptr<Timer> AIthink_timer;
|
||||||
Timer* AImovement_timer;
|
std::unique_ptr<Timer> AImovement_timer;
|
||||||
Timer* AItarget_check_timer;
|
std::unique_ptr<Timer> AItarget_check_timer;
|
||||||
bool movetimercompleted;
|
bool movetimercompleted;
|
||||||
bool permarooted;
|
bool permarooted;
|
||||||
Timer* AIscanarea_timer;
|
std::unique_ptr<Timer> AIscanarea_timer;
|
||||||
Timer* AIwalking_timer;
|
std::unique_ptr<Timer> AIwalking_timer;
|
||||||
Timer* AIfeignremember_timer;
|
std::unique_ptr<Timer> AIfeignremember_timer;
|
||||||
uint32 pLastFightingDelayMoving;
|
uint32 pLastFightingDelayMoving;
|
||||||
HateList hate_list;
|
HateList hate_list;
|
||||||
std::set<uint32> feign_memory_list;
|
std::set<uint32> feign_memory_list;
|
||||||
|
|||||||
@ -425,12 +425,12 @@ bool EntityList::AICheckCloseBeneficialSpells(NPC* caster, uint8 iChance, float
|
|||||||
void Mob::AI_Init()
|
void Mob::AI_Init()
|
||||||
{
|
{
|
||||||
pAIControlled = false;
|
pAIControlled = false;
|
||||||
AIthink_timer = nullptr;
|
AIthink_timer.reset(nullptr);
|
||||||
AIwalking_timer = nullptr;
|
AIwalking_timer.reset(nullptr);
|
||||||
AImovement_timer = nullptr;
|
AImovement_timer.reset(nullptr);
|
||||||
AItarget_check_timer = nullptr;
|
AItarget_check_timer.reset(nullptr);
|
||||||
AIfeignremember_timer = nullptr;
|
AIfeignremember_timer.reset(nullptr);
|
||||||
AIscanarea_timer = nullptr;
|
AIscanarea_timer.reset(nullptr);
|
||||||
minLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMin);
|
minLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMin);
|
||||||
maxLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMax);
|
maxLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMax);
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ void Mob::AI_Init()
|
|||||||
|
|
||||||
void NPC::AI_Init()
|
void NPC::AI_Init()
|
||||||
{
|
{
|
||||||
AIautocastspell_timer = nullptr;
|
AIautocastspell_timer.reset(nullptr);
|
||||||
casting_spell_AIindex = static_cast<uint8>(AIspells.size());
|
casting_spell_AIindex = static_cast<uint8>(AIspells.size());
|
||||||
|
|
||||||
roambox_max_x = 0;
|
roambox_max_x = 0;
|
||||||
@ -474,13 +474,13 @@ void Mob::AI_Start(uint32 iMoveDelay) {
|
|||||||
pLastFightingDelayMoving = 0;
|
pLastFightingDelayMoving = 0;
|
||||||
|
|
||||||
pAIControlled = true;
|
pAIControlled = true;
|
||||||
AIthink_timer = new Timer(AIthink_duration);
|
AIthink_timer = std::unique_ptr<Timer>(new Timer(AIthink_duration));
|
||||||
AIthink_timer->Trigger();
|
AIthink_timer->Trigger();
|
||||||
AIwalking_timer = new Timer(0);
|
AIwalking_timer = std::unique_ptr<Timer>(new Timer(0));
|
||||||
AImovement_timer = new Timer(AImovement_duration);
|
AImovement_timer = std::unique_ptr<Timer>(new Timer(AImovement_duration));
|
||||||
AItarget_check_timer = new Timer(AItarget_check_duration);
|
AItarget_check_timer = std::unique_ptr<Timer>(new Timer(AItarget_check_duration));
|
||||||
AIfeignremember_timer = new Timer(AIfeignremember_delay);
|
AIfeignremember_timer = std::unique_ptr<Timer>(new Timer(AIfeignremember_delay));
|
||||||
AIscanarea_timer = new Timer(AIscanarea_delay);
|
AIscanarea_timer = std::unique_ptr<Timer>(new Timer(AIscanarea_delay));
|
||||||
#ifdef REVERSE_AGGRO
|
#ifdef REVERSE_AGGRO
|
||||||
if(IsNPC() && !CastToNPC()->WillAggroNPCs())
|
if(IsNPC() && !CastToNPC()->WillAggroNPCs())
|
||||||
AIscanarea_timer->Disable();
|
AIscanarea_timer->Disable();
|
||||||
@ -516,10 +516,10 @@ void NPC::AI_Start(uint32 iMoveDelay) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (AIspells.size() == 0) {
|
if (AIspells.size() == 0) {
|
||||||
AIautocastspell_timer = new Timer(1000);
|
AIautocastspell_timer = std::unique_ptr<Timer>(new Timer(1000));
|
||||||
AIautocastspell_timer->Disable();
|
AIautocastspell_timer->Disable();
|
||||||
} else {
|
} else {
|
||||||
AIautocastspell_timer = new Timer(750);
|
AIautocastspell_timer = std::unique_ptr<Timer>(new Timer(750));
|
||||||
AIautocastspell_timer->Start(RandomTimer(0, 15000), false);
|
AIautocastspell_timer->Start(RandomTimer(0, 15000), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,19 +540,19 @@ void Mob::AI_Stop() {
|
|||||||
|
|
||||||
pAIControlled = false;
|
pAIControlled = false;
|
||||||
|
|
||||||
safe_delete(AIthink_timer);
|
AIthink_timer.reset(nullptr);
|
||||||
safe_delete(AIwalking_timer);
|
AIwalking_timer.reset(nullptr);
|
||||||
safe_delete(AImovement_timer);
|
AImovement_timer.reset(nullptr);
|
||||||
safe_delete(AItarget_check_timer);
|
AItarget_check_timer.reset(nullptr);
|
||||||
safe_delete(AIscanarea_timer);
|
AIscanarea_timer.reset(nullptr);
|
||||||
safe_delete(AIfeignremember_timer);
|
AIfeignremember_timer.reset(nullptr);
|
||||||
|
|
||||||
hate_list.WipeHateList();
|
hate_list.WipeHateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPC::AI_Stop() {
|
void NPC::AI_Stop() {
|
||||||
Waypoints.clear();
|
Waypoints.clear();
|
||||||
safe_delete(AIautocastspell_timer);
|
AIautocastspell_timer.reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::AI_Stop() {
|
void Client::AI_Stop() {
|
||||||
|
|||||||
@ -436,7 +436,7 @@ protected:
|
|||||||
|
|
||||||
uint32 npc_spells_id;
|
uint32 npc_spells_id;
|
||||||
uint8 casting_spell_AIindex;
|
uint8 casting_spell_AIindex;
|
||||||
Timer* AIautocastspell_timer;
|
std::unique_ptr<Timer> AIautocastspell_timer;
|
||||||
uint32* pDontCastBefore_casting_spell;
|
uint32* pDontCastBefore_casting_spell;
|
||||||
std::vector<AISpells_Struct> AIspells;
|
std::vector<AISpells_Struct> AIspells;
|
||||||
bool HasAISpell;
|
bool HasAISpell;
|
||||||
@ -444,7 +444,7 @@ protected:
|
|||||||
virtual bool AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgainBefore = 0);
|
virtual bool AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgainBefore = 0);
|
||||||
AISpellsVar_Struct AISpellVar;
|
AISpellsVar_Struct AISpellVar;
|
||||||
int16 GetFocusEffect(focusType type, uint16 spell_id);
|
int16 GetFocusEffect(focusType type, uint16 spell_id);
|
||||||
|
|
||||||
uint32 npc_spells_effects_id;
|
uint32 npc_spells_effects_id;
|
||||||
std::vector<AISpellsEffects_Struct> AIspellsEffects;
|
std::vector<AISpellsEffects_Struct> AIspellsEffects;
|
||||||
bool HasAISpellEffects;
|
bool HasAISpellEffects;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user