From 408fce1de69249b82cc042cb31f3fd16983c7e81 Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 6 Dec 2010 02:07:53 +0100 Subject: 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 --- src/server/scripts/World/npcs_special.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/server/scripts/World') diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 412626d29c8..66b8e400a71 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -820,9 +820,6 @@ void npc_doctor::npc_doctorAI::UpdateAI(const uint32 diff) { if (SummonPatient_Timer <= diff) { - Creature* Patient = NULL; - Location* Point = NULL; - if (Coordinates.empty()) return; @@ -838,22 +835,21 @@ void npc_doctor::npc_doctorAI::UpdateAI(const uint32 diff) return; } - Point = *itr; - - Patient = me->SummonCreature(patientEntry, Point->x, Point->y, Point->z, Point->o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000); - - if (Patient) + if (Location* Point = *itr) { - //303, this flag appear to be required for client side item->spell to work (TARGET_SINGLE_FRIEND) - Patient->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); + if (Creature* Patient = me->SummonCreature(patientEntry, Point->x, Point->y, Point->z, Point->o, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000)) + { + //303, this flag appear to be required for client side item->spell to work (TARGET_SINGLE_FRIEND) + Patient->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); - Patients.push_back(Patient->GetGUID()); - CAST_AI(npc_injured_patient::npc_injured_patientAI, Patient->AI())->Doctorguid = me->GetGUID(); + Patients.push_back(Patient->GetGUID()); + CAST_AI(npc_injured_patient::npc_injured_patientAI, Patient->AI())->Doctorguid = me->GetGUID(); - if (Point) - CAST_AI(npc_injured_patient::npc_injured_patientAI, Patient->AI())->Coord = Point; + if (Point) + CAST_AI(npc_injured_patient::npc_injured_patientAI, Patient->AI())->Coord = Point; - Coordinates.erase(itr); + Coordinates.erase(itr); + } } SummonPatient_Timer = 10000; ++SummonPatientCount; -- cgit v1.2.3