Core/Misc: Fix static analysis issues (#25178)

This commit is contained in:
Giacomo Pozzoni
2020-07-31 20:53:13 +00:00
committed by GitHub
parent 5b863acf92
commit 7cf122fc2a
20 changed files with 137 additions and 97 deletions

View File

@@ -422,19 +422,12 @@ public:
}
// Set the level of logging
static bool HandleServerSetLogLevelCommand(ChatHandler* /*handler*/, char const* args)
static bool HandleServerSetLogLevelCommand(ChatHandler* /*handler*/, std::string const& type, std::string const& name, int32 level)
{
if (!*args)
if (name.empty() || level < 0 || (type != "a" && type != "l"))
return false;
char* type = strtok((char*)args, " ");
char* name = strtok(nullptr, " ");
char* level = strtok(nullptr, " ");
if (!type || !name || !level || *name == '\0' || *level == '\0' || (*type != 'a' && *type != 'l'))
return false;
sLog->SetLogLevel(name, level, *type == 'l');
sLog->SetLogLevel(name, level, type == "l");
return true;
}

View File

@@ -100,7 +100,13 @@ public:
{
instance = creature->GetInstanceScript();
creature->RestoreFaction();
Reset();
Initialize();
}
void Initialize()
{
uiTimer = 0;
uiPhase = 0;
}
InstanceScript* instance;
@@ -115,8 +121,7 @@ public:
{
if (!HasEscortState(STATE_ESCORT_ESCORTING))
{
uiTimer = 0;
uiPhase = 0;
Initialize();
RestoreAll();

View File

@@ -70,18 +70,12 @@ class instance_magisters_terrace : public InstanceMapScript
struct instance_magisters_terrace_InstanceMapScript : public InstanceScript
{
instance_magisters_terrace_InstanceMapScript(InstanceMap* map) : InstanceScript(map)
instance_magisters_terrace_InstanceMapScript(InstanceMap* map) : InstanceScript(map), _delrissaDeathCount(0)
{
SetHeaders(DataHeader);
SetBossNumber(EncounterCount);
LoadObjectData(creatureData, gameObjectData);
LoadDoorData(doorData);
Initialize();
}
void Initialize() override
{
_delrissaDeathCount = 0;
}
uint32 GetData(uint32 type) const override

View File

@@ -280,7 +280,28 @@ public:
{
npc_highlord_darion_mograineAI(Creature* creature) : EscortAI(creature)
{
Reset();
Initialize();
}
void Initialize()
{
bIsBattle = false;
uiStep = 0;
uiPhase_timer = 3000;
uiFight_duration = 300000; // 5 minutes
uiTotal_dawn = ENCOUNTER_TOTAL_DAWN;
uiTotal_scourge = ENCOUNTER_TOTAL_SCOURGE;
uiSummon_counter = 0;
uiAnti_magic_zone = urand(1000, 6000);
uiDeath_strike = urand(5000, 10000);
uiDeath_embrace = urand(5000, 10000);
uiIcy_touch = urand(5000, 10000);
uiUnholy_blight = urand(5000, 10000);
uiFight_speech = 15000;
uiSpawncheck = 1000;
uiTargetcheck = 10000;
}
bool bIsBattle;
@@ -326,23 +347,7 @@ public:
{
if (!HasEscortState(STATE_ESCORT_ESCORTING))
{
bIsBattle = false;
uiStep = 0;
uiPhase_timer = 3000;
uiFight_duration = 300000; // 5 minutes
uiTotal_dawn = ENCOUNTER_TOTAL_DAWN;
uiTotal_scourge = ENCOUNTER_TOTAL_SCOURGE;
uiSummon_counter = 0;
uiAnti_magic_zone = urand(1000, 6000);
uiDeath_strike = urand(5000, 10000);
uiDeath_embrace = urand(5000, 10000);
uiIcy_touch = urand(5000, 10000);
uiUnholy_blight = urand(5000, 10000);
uiFight_speech = 15000;
uiSpawncheck = 1000;
uiTargetcheck = 10000;
Initialize();
me->SetStandState(UNIT_STAND_STATE_STAND);
me->Mount(25279);
@@ -1657,9 +1662,9 @@ public:
struct npc_the_lich_king_tirion_dawnAI : public ScriptedAI
{
npc_the_lich_king_tirion_dawnAI(Creature* creature) : ScriptedAI(creature) { Reset(); }
npc_the_lich_king_tirion_dawnAI(Creature* creature) : ScriptedAI(creature) { }
void Reset() override { }
void AttackStart(Unit* /*who*/) override { } // very sample, just don't make them aggreesive
void AttackStart(Unit* /*who*/) override { } // very simple, just don't make them aggreesive
void UpdateAI(uint32 /*diff*/) override { }
void JustDied(Unit* /*killer*/) override { }
};

View File

@@ -57,8 +57,6 @@ class npc_jaina_proudmoore : public CreatureScript
{
npc_jaina_proudmooreAI(Creature* creature) : hyjalAI(creature)
{
Reset();
Spells[0].SpellId = SPELL_BLIZZARD;
Spells[0].Cooldown = urand(15000, 35000);
Spells[0].TargetType = TARGETTYPE_RANDOM;
@@ -134,8 +132,6 @@ class npc_thrall : public CreatureScript
{
npc_thrallAI(Creature* creature) : hyjalAI(creature)
{
Reset();
Spells[0].SpellId = SPELL_CHAIN_LIGHTNING;
Spells[0].Cooldown = urand(3000, 8000);
Spells[0].TargetType = TARGETTYPE_VICTIM;
@@ -213,7 +209,6 @@ class npc_tyrande_whisperwind : public CreatureScript
{
npc_tyrande_whisperwindAI(Creature* creature) : hyjalAI(creature)
{
Reset();
}
bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override

View File

@@ -424,7 +424,14 @@ public:
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->SetDisplayId(MODEL_INVIS);
go = false;
Reset();
Initialize();
}
void Initialize()
{
spawnTimer = 2000;
FlameBuffetTimer = 2000;
imol = false;
}
bool meteor;
@@ -436,9 +443,7 @@ public:
void Reset() override
{
spawnTimer = 2000;
FlameBuffetTimer= 2000;
imol = false;
Initialize();
}
void JustEngagedWith(Unit* /*who*/) override { }
@@ -548,14 +553,19 @@ public:
{
instance = creature->GetInstanceScript();
go = false;
Reset();
Initialize();
}
void Initialize()
{
KnockDownTimer = 10000;
}
bool go;
uint32 KnockDownTimer;
void Reset() override
{
KnockDownTimer = 10000;
Initialize();
}
void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
@@ -642,7 +652,14 @@ public:
{
instance = creature->GetInstanceScript();
go = false;
Reset();
Initialize();
}
void Initialize()
{
FrenzyTimer = 5000 + rand32() % 5000;
MoveTimer = 2000;
RandomMove = false;
}
bool go;
@@ -651,9 +668,7 @@ public:
bool RandomMove;
void Reset() override
{
FrenzyTimer = 5000 + rand32() % 5000;
MoveTimer = 2000;
RandomMove = false;
Initialize();
}
void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
@@ -740,7 +755,12 @@ public:
{
instance = creature->GetInstanceScript();
go = false;
Reset();
Initialize();
}
void Initialize()
{
ShadowBoltTimer = 1000 + rand32() % 5000;
}
SummonList summons;
@@ -749,7 +769,7 @@ public:
void Reset() override
{
ShadowBoltTimer = 1000 + rand32() % 5000;
Initialize();
summons.DespawnAll();
}
@@ -864,7 +884,14 @@ public:
{
instance = creature->GetInstanceScript();
go = false;
Reset();
Initialize();
}
void Initialize()
{
CourseTimer = 20000 + rand32() % 5000;
WailTimer = 15000 + rand32() % 5000;
ShellTimer = 50000 + rand32() % 10000;
}
bool go;
@@ -874,9 +901,7 @@ public:
void Reset() override
{
CourseTimer = 20000 + rand32() % 5000;
WailTimer = 15000 + rand32() % 5000;
ShellTimer = 50000 + rand32() % 10000;
Initialize();
}
void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
@@ -964,7 +989,12 @@ public:
{
instance = creature->GetInstanceScript();
go = false;
Reset();
Initialize();
}
void Initialize()
{
WebTimer = 20000 + rand32() % 5000;
}
bool go;
@@ -972,7 +1002,7 @@ public:
void Reset() override
{
WebTimer = 20000 + rand32() % 5000;
Initialize();
}
void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
@@ -1050,7 +1080,12 @@ public:
{
instance = creature->GetInstanceScript();
go = false;
Reset();
Initialize();
}
void Initialize()
{
ManaBurnTimer = 9000 + rand32() % 5000;
}
bool go;
@@ -1058,7 +1093,7 @@ public:
void Reset() override
{
ManaBurnTimer = 9000 + rand32() % 5000;
Initialize();
}
void WaypointReached(uint32 waypointId, uint32 /*pathId*/) override
@@ -1262,7 +1297,15 @@ public:
go = false;
for (uint8 i = 0; i < 3; ++i)
DummyTarget[i] = 0;
Reset();
Initialize();
}
void Initialize()
{
forcemove = true;
Zpos = 10.0f;
StrikeTimer = 2000 + rand32() % 5000;
MoveTimer = 0;
}
bool go;
@@ -1273,10 +1316,7 @@ public:
void Reset() override
{
forcemove = true;
Zpos = 10.0f;
StrikeTimer = 2000 + rand32() % 5000;
MoveTimer = 0;
Initialize();
me->SetDisableGravity(true);
}

View File

@@ -112,7 +112,6 @@ class boss_kologarn : public CreatureScript
DoCast(SPELL_KOLOGARN_REDUCE_PARRY);
SetCombatMovement(false);
Reset();
}
bool left, right;

View File

@@ -25,6 +25,8 @@
#include "SpellScript.h"
#include "TemporarySummon.h"
Position const Executioner = { 152.8524f, -83.63912f, 2.021005f, 0.06981317f };
class at_nethekurse_exit : public AreaTriggerScript
{
public:

View File

@@ -90,7 +90,7 @@ enum SHActions
ACTION_EXECUTIONER_TAUNT = 1
};
Position const Executioner = { 152.8524f, -83.63912f, 2.021005f, 0.06981317f };
extern Position const Executioner;
struct FactionSpawnerHelper
{

View File

@@ -73,7 +73,17 @@ public:
struct npc_maghar_captiveAI : public EscortAI
{
npc_maghar_captiveAI(Creature* creature) : EscortAI(creature) { Reset(); }
npc_maghar_captiveAI(Creature* creature) : EscortAI(creature)
{
Initialize();
}
void Initialize()
{
ChainLightningTimer = 1000;
HealTimer = 0;
FrostShockTimer = 6000;
}
uint32 ChainLightningTimer;
uint32 HealTimer;
@@ -81,9 +91,7 @@ public:
void Reset() override
{
ChainLightningTimer = 1000;
HealTimer = 0;
FrostShockTimer = 6000;
Initialize();
}
void JustEngagedWith(Unit* /*who*/) override

View File

@@ -365,7 +365,7 @@ public:
npc_enslaved_netherwing_drakeAI(Creature* creature) : ScriptedAI(creature)
{
Tapped = false;
Reset();
FlyTimer = 10 * IN_MILLISECONDS;
}
void Reset() override

View File

@@ -996,7 +996,15 @@ public:
break;
}
Reset();
Initialize();
}
void Initialize()
{
IsHealed = false;
CanRun = false;
RunAwayTimer = 5000;
}
ObjectGuid CasterGUID;
@@ -1011,10 +1019,7 @@ public:
{
CasterGUID.Clear();
IsHealed = false;
CanRun = false;
RunAwayTimer = 5000;
Initialize();
me->SetStandState(UNIT_STAND_STATE_KNEEL);
// expect database to have RegenHealth=0