aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Keresztes Schmidt <carbenium@outlook.com>2020-07-13 16:35:31 +0200
committerGitHub <noreply@github.com>2020-07-13 16:35:31 +0200
commit10be49bdfe6bd1f4d8e0eaf3a1b4354c5a57a2a9 (patch)
treef19f3e8e6d8fc903bac6f23db13b3c9e1e40e30c /src
parent5af8ff2b84a0c81ce3aa03f338ce838747b2f25e (diff)
Fix some compiler warnings reported by GCC (#25007)
* 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
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp9
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp9
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp2
-rw-r--r--src/server/game/Entities/Player/Player.cpp2
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp2
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp2
-rw-r--r--src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp31
-rw-r--r--src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp4
-rw-r--r--src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp1
-rw-r--r--src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp4
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp3
11 files changed, 28 insertions, 41 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
index 691ca506ede..bd47759817b 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
@@ -278,13 +278,10 @@ void EscortAI::AddWaypoint(uint32 id, float x, float y, float z, float orientati
void EscortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false */, ObjectGuid playerGUID /* = 0 */, Quest const* quest /* = nullptr */, bool instantRespawn /* = false */, bool canLoopPath /* = false */, bool resetWaypoints /* = true */)
{
// Queue respawn from the point it starts
- if (Map* map = me->GetMap())
+ if (CreatureData const* cdata = me->GetCreatureData())
{
- if (CreatureData const* cdata = me->GetCreatureData())
- {
- if (sWorld->getBoolConfig(CONFIG_RESPAWN_DYNAMIC_ESCORTNPC) && (cdata->spawnGroupData->flags & SPAWNGROUP_FLAG_ESCORTQUESTNPC))
- me->SaveRespawnTime(me->GetRespawnDelay());
- }
+ if (sWorld->getBoolConfig(CONFIG_RESPAWN_DYNAMIC_ESCORTNPC) && (cdata->spawnGroupData->flags & SPAWNGROUP_FLAG_ESCORTQUESTNPC))
+ me->SaveRespawnTime(me->GetRespawnDelay());
}
if (me->IsEngaged())
diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
index 8e9d6827798..d945512a9bf 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
@@ -156,13 +156,10 @@ void FollowerAI::UpdateFollowerAI(uint32 /*uiDiff*/)
void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, uint32 quest)
{
- if (Map* map = me->GetMap())
+ if (CreatureData const* cdata = me->GetCreatureData())
{
- if (CreatureData const* cdata = me->GetCreatureData())
- {
- if (sWorld->getBoolConfig(CONFIG_RESPAWN_DYNAMIC_ESCORTNPC) && (cdata->spawnGroupData->flags & SPAWNGROUP_FLAG_ESCORTQUESTNPC))
- me->SaveRespawnTime(me->GetRespawnDelay());
- }
+ if (sWorld->getBoolConfig(CONFIG_RESPAWN_DYNAMIC_ESCORTNPC) && (cdata->spawnGroupData->flags & SPAWNGROUP_FLAG_ESCORTQUESTNPC))
+ me->SaveRespawnTime(me->GetRespawnDelay());
}
if (me->IsEngaged())
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index ecf12d94db6..39bdfc1e7da 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -649,7 +649,7 @@ void GameObject::Update(uint32 diff)
Unit* target = nullptr;
/// @todo this hack with search required until GO casting not implemented
- if (Unit* owner = GetOwner())
+ if (GetOwner())
{
// Hunter trap: Search units which are unfriendly to the trap's owner
Trinity::NearestAttackableNoTotemUnitInObjectRangeCheck checker(this, radius);
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 6a478c0f868..1ad9c9b9789 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -23575,7 +23575,7 @@ void Player::UpdateVisibleGameobjectsOrSpellClicks()
auto clickBounds = sObjectMgr->GetSpellClickInfoMapBounds(obj->GetEntry());
for (auto const& clickPair : clickBounds)
{
- if (ConditionContainer const* conds = sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), clickPair.second.spellId))
+ if (sConditionMgr->GetConditionsForSpellClickEvent(obj->GetEntry(), clickPair.second.spellId))
{
obj->BuildValuesUpdateBlockForPlayer(&udata, this);
break;
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 5ce9cd94b1a..00d33790d43 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
@@ -109,7 +109,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 1a783bff081..02dd358ed0e 100644
--- a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp
+++ b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp
@@ -360,7 +360,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 03b1e019b39..a166c9632d0 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<Creature*>::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;
}
diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp
index c93568fa253..48ce3c5e1a8 100644
--- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp
+++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp
@@ -157,7 +157,7 @@ class instance_pit_of_saron : public InstanceMapScript
case DATA_GARFROST:
if (state == DONE)
{
- if (Creature* summoner = instance->GetCreature(_garfrostGUID))
+ if (instance->GetCreature(_garfrostGUID))
{
if (_teamInInstance == ALLIANCE)
{
@@ -175,7 +175,7 @@ class instance_pit_of_saron : public InstanceMapScript
case DATA_TYRANNUS:
if (state == DONE)
{
- if (Creature* summoner = instance->GetCreature(_tyrannusGUID))
+ if (instance->GetCreature(_tyrannusGUID))
{
if (_teamInInstance == ALLIANCE)
{
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
index 2001aefd3da..aaad0626077 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp
@@ -402,6 +402,7 @@ struct boss_thaddius : public BossAI
break;
case EVENT_ENABLE_BALL_LIGHTNING:
ballLightningUnlocked = true;
+ break;
case EVENT_ENGAGE:
me->SetReactState(REACT_AGGRESSIVE);
break;
diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
index dd953b8a0e9..3c8e17ad829 100644
--- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
+++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp
@@ -947,7 +947,9 @@ public:
}
else if (GetDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL)
{
- memset(_surgeTargetGUID, 0, sizeof(_surgeTargetGUID));
+ for (ObjectGuid& guid : _surgeTargetGUID)
+ guid.Clear();
+
DoCastAOE(SPELL_SURGE_OF_POWER_WARNING_SELECTOR_25, true);
}
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
index 73ffde4f3f6..54851cb2a56 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
@@ -217,7 +217,8 @@ public:
IsFinalForm = false;
NeedThreatReset = false;
EnrageUsed = false;
- memset(InnderDemon, 0, sizeof(InnderDemon));
+ for (ObjectGuid& guid : InnderDemon)
+ guid.Clear();
InnerDemon_Count = 0;
}