diff options
| author | jackpoz <giacomopoz@gmail.com> | 2014-09-04 23:05:03 +0200 |
|---|---|---|
| committer | jackpoz <giacomopoz@gmail.com> | 2014-09-05 22:44:24 +0200 |
| commit | 6df2ff5efa0a84c5423804d713acd0e8952db86e (patch) | |
| tree | 75e8fa91a6ea2ceb502356e7ee804fc6993a2ef0 /src/server/scripts/EasternKingdoms | |
| parent | d3a50ffb59f315d43c9ba93d5909887c6abe3685 (diff) | |
Core/Misc: Refactor scripts to fix static analysis warnings
Third batch of fixes targeting 100 issues reported by Coverity
Diffstat (limited to 'src/server/scripts/EasternKingdoms')
| -rw-r--r-- | src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp | 28 | ||||
| -rw-r--r-- | src/server/scripts/EasternKingdoms/zone_wetlands.cpp | 12 |
2 files changed, 26 insertions, 14 deletions
diff --git a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp index dbcf5998bdb..d242d17806c 100644 --- a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp @@ -319,19 +319,24 @@ public: struct npc_anchorite_truuenAI : public npc_escortAI { - npc_anchorite_truuenAI(Creature* creature) : npc_escortAI(creature) { } + npc_anchorite_truuenAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + UghostGUID = 0; + } + + void Initialize() + { + m_uiChatTimer = 7000; + } uint32 m_uiChatTimer; uint64 UghostGUID; - uint64 TheldanisGUID; - - Creature* Ughost; - Creature* Theldanis; void Reset() override { - m_uiChatTimer = 7000; + Initialize(); } void JustSummoned(Creature* summoned) override @@ -364,26 +369,25 @@ public: Talk(SAY_WP_2); break; case 21: - Theldanis = GetClosestCreatureWithEntry(me, NPC_THEL_DANIS, 150); - if (Theldanis) + if (Creature* Theldanis = GetClosestCreatureWithEntry(me, NPC_THEL_DANIS, 150)) Theldanis->AI()->Talk(SAY_WP_3); break; case 23: - Ughost = me->SummonCreature(NPC_GHOST_UTHER, 971.86f, -1825.42f, 81.99f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); - if (Ughost) + if (Creature* Ughost = me->SummonCreature(NPC_GHOST_UTHER, 971.86f, -1825.42f, 81.99f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000)) { + UghostGUID = Ughost->GetGUID(); Ughost->SetDisableGravity(true); Ughost->AI()->Talk(SAY_WP_4, me); } m_uiChatTimer = 4000; break; case 24: - if (Ughost) + if (Creature* Ughost = ObjectAccessor::GetCreature(*me, UghostGUID)) Ughost->AI()->Talk(SAY_WP_5, me); m_uiChatTimer = 4000; break; case 25: - if (Ughost) + if (Creature* Ughost = ObjectAccessor::GetCreature(*me, UghostGUID)) Ughost->AI()->Talk(SAY_WP_6, me); m_uiChatTimer = 4000; break; diff --git a/src/server/scripts/EasternKingdoms/zone_wetlands.cpp b/src/server/scripts/EasternKingdoms/zone_wetlands.cpp index e6c844b1b1e..94cea417b04 100644 --- a/src/server/scripts/EasternKingdoms/zone_wetlands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_wetlands.cpp @@ -59,14 +59,22 @@ public: struct npc_tapoke_slim_jahnAI : public npc_escortAI { - npc_tapoke_slim_jahnAI(Creature* creature) : npc_escortAI(creature) { } + npc_tapoke_slim_jahnAI(Creature* creature) : npc_escortAI(creature) + { + Initialize(); + } + + void Initialize() + { + IsFriendSummoned = false; + } bool IsFriendSummoned; void Reset() override { if (!HasEscortState(STATE_ESCORT_ESCORTING)) - IsFriendSummoned = false; + Initialize(); } void WaypointReached(uint32 waypointId) override |
