From 365ae6ff25a288ea83e192066b9cc162a020a844 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Mon, 13 Jul 2020 16:35:31 +0200 Subject: Fix some compiler warnings reported by GCC (#25007) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Core/AI: Remove unneeded null checks GetMap() can never return NULL. Fixes additionally -Wunused-variable warnings reported by GCC. * Core/GameObject: Fix a -Wunused-variable warning reported by GCC * Core/Player: Fix a -Wunused-variable warning reported by GCC * Scritps/CavernsOfTime: Fix -Wimplicit-fallthrough warnings reported by GCC * Scritps/CavernsOfTime: Fix a -Wmaybe-uninitialized warning reported by GCC Warning: /home/peterke/DEV/TrinityCore/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp: In member function ‘virtual void npc_arthas_stratholme::npc_arthas_stratholmeAI::UpdateAI(uint32)’: /home/peterke/DEV/TrinityCore/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp:1119:58: warning: ‘emote’ may be used uninitialized in this function [-Wmaybe-uninitialized] 1119 | (*it)->HandleEmoteCommand(emote); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ * Scritps/PitOfSaron: Fix -Wunused-variable warnings reported by GCC * Scritps/EyeOfEternity: Fix a -Wclass-memaccess warning reported by GCC Warning: /home/peterke/DEV/TrinityCore/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp: In member function ‘virtual void boss_malygos::boss_malygosAI::UpdateAI(uint32)’: /home/peterke/DEV/TrinityCore/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp:950:81: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class ObjectGuid’; use assignment or value-initialization instead [-Wclass-memaccess] 950 | memset(_surgeTargetGUID, 0, sizeof(_surgeTargetGUID)); | * Scritps/CoilfangReservoir: Fix a -Wclass-memaccess warning reported by GCC Warning: /home/peterke/DEV/TrinityCore/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp: In member function ‘void boss_leotheras_the_blind::boss_leotheras_the_blindAI::Initialize()’: /home/peterke/DEV/TrinityCore/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp:220:55: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class ObjectGuid’; use assignment or value-initialization instead [-Wclass-memaccess] 220 | memset(InnderDemon, 0, sizeof(InnderDemon)); | ^ * Scritps/Naxx: Fix a -Wimplicit-fallthrough warning reported by GCC For discussion see https://github.com/TrinityCore/TrinityCore/pull/25007 (cherry picked from commit 10be49bdfe6bd1f4d8e0eaf3a1b4354c5a57a2a9) --- .../boss_salramm_the_fleshcrafter.cpp | 2 +- .../CullingOfStratholme/culling_of_stratholme.cpp | 2 +- .../CullingOfStratholme/npc_arthas.cpp | 31 +++++++--------------- 3 files changed, 12 insertions(+), 23 deletions(-) (limited to 'src/server/scripts/Kalimdor') diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp index bf17d74e7ad..075e7315285 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp @@ -110,7 +110,7 @@ class boss_salramm : public CreatureScript break; case EVENT_EXPLODE_GHOUL2: events.ScheduleEvent(EVENT_SUMMON_GHOULS, Seconds(4)); - // intentional missing break + /* fallthrough */ case EVENT_EXPLODE_GHOUL1: Talk(SAY_EXPLODE_GHOUL); DoCastAOE(SPELL_EXPLODE_GHOUL, true); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp index ecae7ab189d..eac319c4191 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp @@ -361,7 +361,7 @@ class npc_chromie_start : public CreatureScript break; case GOSSIP_OFFSET_SKIP_1: AdvanceDungeonFar(); - // intentional missing break + /* fallthrough */ case GOSSIP_OFFSET_TELEPORT: CloseGossipMenuFor(player); me->CastSpell(player, SPELL_TELEPORT_PLAYER); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp index 9a74bcb0fc7..ffefb1457a9 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp @@ -1095,28 +1095,17 @@ public: me->GetCreatureListWithEntryInGrid(nearbyVictims, urand(0, 1) ? NPC_CITIZEN : NPC_RESIDENT, 60.0f); if (!nearbyVictims.empty()) { - std::list::iterator it = nearbyVictims.begin(); - std::advance(it, urand(0, nearbyVictims.size()-1)); - Emote emote; - switch (urand(0, 3)) + Emote emotes[] = { - case 0: - emote = EMOTE_ONESHOT_TALK; - break; - case 1: - emote = EMOTE_ONESHOT_EXCLAMATION; - break; - case 2: - emote = EMOTE_ONESHOT_RUDE; - break; - case 3: - emote = EMOTE_ONESHOT_ROAR; - break; - default: - break; - } - if ((*it)->IsAlive()) - (*it)->HandleEmoteCommand(emote); + EMOTE_ONESHOT_TALK, + EMOTE_ONESHOT_EXCLAMATION, + EMOTE_ONESHOT_RUDE, + EMOTE_ONESHOT_ROAR + }; + + Creature* victim = Trinity::Containers::SelectRandomContainerElement(nearbyVictims); + if (victim->IsAlive()) + victim->HandleEmoteCommand(Trinity::Containers::SelectRandomContainerElement(emotes)); } break; } -- cgit v1.2.3