mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Misc: Fix static analysis issues (#25178)
(cherry picked from commit 7cf122fc2a)
This commit is contained in:
@@ -287,12 +287,13 @@ std::string Log::GetTimestampStr()
|
||||
}
|
||||
}
|
||||
|
||||
bool Log::SetLogLevel(std::string const& name, char const* newLevelc, bool isLogger /* = true */)
|
||||
bool Log::SetLogLevel(std::string const& name, int32 newLeveli, bool isLogger /* = true */)
|
||||
{
|
||||
LogLevel newLevel = LogLevel(atoi(newLevelc));
|
||||
if (newLevel < 0)
|
||||
if (newLeveli < 0)
|
||||
return false;
|
||||
|
||||
LogLevel newLevel = LogLevel(newLeveli);
|
||||
|
||||
if (isLogger)
|
||||
{
|
||||
auto it = loggers.begin();
|
||||
|
||||
@@ -66,7 +66,7 @@ class TC_COMMON_API Log
|
||||
void LoadFromConfig();
|
||||
void Close();
|
||||
bool ShouldLog(std::string const& type, LogLevel level) const;
|
||||
bool SetLogLevel(std::string const& name, char const* level, bool isLogger = true);
|
||||
bool SetLogLevel(std::string const& name, int32 level, bool isLogger = true);
|
||||
|
||||
template<typename Format, typename... Args>
|
||||
inline void outMessage(std::string const& filter, LogLevel const level, Format&& fmt, Args&&... args)
|
||||
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
/// Tries to terminate the process
|
||||
void Terminate() override
|
||||
{
|
||||
if (!my_child)
|
||||
if (my_child)
|
||||
{
|
||||
was_terminated = true;
|
||||
try
|
||||
|
||||
@@ -215,8 +215,8 @@ void CalendarMgr::RemoveEvent(CalendarEvent* calendarEvent, ObjectGuid remover)
|
||||
trans->Append(stmt);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
delete calendarEvent;
|
||||
_events.erase(calendarEvent);
|
||||
delete calendarEvent;
|
||||
}
|
||||
|
||||
void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid /*remover*/)
|
||||
|
||||
@@ -162,11 +162,6 @@ class TC_GAME_API InstanceScript : public ZoneScript
|
||||
|
||||
InstanceMap* instance;
|
||||
|
||||
// On creation, NOT load.
|
||||
// PLEASE INITIALIZE FIELDS IN THE CONSTRUCTOR INSTEAD !!!
|
||||
// KEEPING THIS METHOD ONLY FOR BACKWARD COMPATIBILITY !!!
|
||||
virtual void Initialize() { }
|
||||
|
||||
// On instance load, exactly ONE of these methods will ALWAYS be called:
|
||||
// if we're starting without any saved instance data
|
||||
virtual void Create();
|
||||
|
||||
@@ -4135,8 +4135,6 @@ void InstanceMap::CreateInstanceData(bool load)
|
||||
if (!i_data)
|
||||
return;
|
||||
|
||||
i_data->Initialize();
|
||||
|
||||
if (load)
|
||||
{
|
||||
/// @todo make a global storage for this
|
||||
|
||||
@@ -211,7 +211,7 @@ void FlightPathMovementGenerator::LoadPath(Player* owner, uint32 startNode /*= 0
|
||||
{
|
||||
uint32 path, cost;
|
||||
sObjectMgr->GetTaxiPath(taxi[src], taxi[dst], path, cost);
|
||||
if (path > sTaxiPathNodesByPath.size())
|
||||
if (path >= sTaxiPathNodesByPath.size())
|
||||
return;
|
||||
|
||||
TaxiPathNodeList const& nodes = sTaxiPathNodesByPath[path];
|
||||
|
||||
@@ -160,7 +160,7 @@ void WardenCheckMgr::LoadWardenOverrides()
|
||||
if (action > WARDEN_ACTION_BAN)
|
||||
TC_LOG_ERROR("warden", "Warden check override action out of range (ID: %u, action: %u)", checkId, action);
|
||||
// Check if check actually exists before accessing the CheckStore vector
|
||||
else if (checkId > CheckStore.size())
|
||||
else if (checkId >= CheckStore.size())
|
||||
TC_LOG_ERROR("warden", "Warden check action override for non-existing check (ID: %u, action: %u), skipped", checkId, action);
|
||||
else
|
||||
{
|
||||
|
||||
@@ -426,19 +426,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,13 @@ public:
|
||||
{
|
||||
instance = creature->GetInstanceScript();
|
||||
creature->RestoreFaction();
|
||||
Reset();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
uiTimer = 0;
|
||||
uiPhase = 0;
|
||||
}
|
||||
|
||||
InstanceScript* instance;
|
||||
@@ -114,8 +120,7 @@ public:
|
||||
{
|
||||
if (!HasEscortState(STATE_ESCORT_ESCORTING))
|
||||
{
|
||||
uiTimer = 0;
|
||||
uiPhase = 0;
|
||||
Initialize();
|
||||
|
||||
RestoreAll();
|
||||
|
||||
|
||||
@@ -71,18 +71,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
|
||||
|
||||
@@ -281,7 +281,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;
|
||||
@@ -327,23 +348,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);
|
||||
@@ -1658,9 +1663,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 { }
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -424,7 +424,14 @@ public:
|
||||
me->AddUnitFlag(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);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ class boss_kologarn : public CreatureScript
|
||||
|
||||
DoCast(SPELL_KOLOGARN_REDUCE_PARRY);
|
||||
SetCombatMovement(false);
|
||||
Reset();
|
||||
}
|
||||
|
||||
bool left, right;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -91,7 +91,7 @@ enum SHActions
|
||||
ACTION_EXECUTIONER_TAUNT = 1
|
||||
};
|
||||
|
||||
Position const Executioner = { 152.8524f, -83.63912f, 2.021005f, 0.06981317f };
|
||||
extern Position const Executioner;
|
||||
|
||||
struct FactionSpawnerHelper
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -365,7 +365,7 @@ public:
|
||||
npc_enslaved_netherwing_drakeAI(Creature* creature) : ScriptedAI(creature)
|
||||
{
|
||||
Tapped = false;
|
||||
Reset();
|
||||
FlyTimer = 10 * IN_MILLISECONDS;
|
||||
}
|
||||
|
||||
void Reset() override
|
||||
|
||||
@@ -993,7 +993,15 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
Reset();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
IsHealed = false;
|
||||
CanRun = false;
|
||||
|
||||
RunAwayTimer = 5000;
|
||||
}
|
||||
|
||||
ObjectGuid CasterGUID;
|
||||
@@ -1008,10 +1016,7 @@ public:
|
||||
{
|
||||
CasterGUID.Clear();
|
||||
|
||||
IsHealed = false;
|
||||
CanRun = false;
|
||||
|
||||
RunAwayTimer = 5000;
|
||||
Initialize();
|
||||
|
||||
me->SetStandState(UNIT_STAND_STATE_KNEEL);
|
||||
// expect database to have RegenHealth=0
|
||||
|
||||
Reference in New Issue
Block a user