diff options
20 files changed, 137 insertions, 97 deletions
diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp index 59baea2c143..6c364105a7b 100644 --- a/src/common/Logging/Log.cpp +++ b/src/common/Logging/Log.cpp @@ -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(); diff --git a/src/common/Logging/Log.h b/src/common/Logging/Log.h index c5ca989ef5d..a496687ab57 100644 --- a/src/common/Logging/Log.h +++ b/src/common/Logging/Log.h @@ -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) diff --git a/src/common/Utilities/StartProcess.cpp b/src/common/Utilities/StartProcess.cpp index 3794b6c293b..8d713540e11 100644 --- a/src/common/Utilities/StartProcess.cpp +++ b/src/common/Utilities/StartProcess.cpp @@ -225,7 +225,7 @@ public: /// Tries to terminate the process void Terminate() override { - if (!my_child) + if (my_child) { was_terminated = true; try diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index dd36321da74..f035ac9b7e9 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -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*/) diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h index b4a4de064cf..985101779be 100644 --- a/src/server/game/Instances/InstanceScript.h +++ b/src/server/game/Instances/InstanceScript.h @@ -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(); diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 36d610f941c..e070d165539 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -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 diff --git a/src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.cpp index 76d6f86854b..26d10e25faf 100644 --- a/src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.cpp @@ -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]; diff --git a/src/server/game/Warden/WardenCheckMgr.cpp b/src/server/game/Warden/WardenCheckMgr.cpp index 2c170dbdc91..b23f53f927a 100644 --- a/src/server/game/Warden/WardenCheckMgr.cpp +++ b/src/server/game/Warden/WardenCheckMgr.cpp @@ -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 { diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index 67c31cd4e2a..d9cc9e3aa1f 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -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) - 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')) + if (name.empty() || level < 0 || (type != "a" && type != "l")) return false; - sLog->SetLogLevel(name, level, *type == 'l'); + sLog->SetLogLevel(name, level, type == "l"); return true; } diff --git a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp index 229e0133e7d..1bd12a1837b 100644 --- a/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp +++ b/src/server/scripts/EasternKingdoms/Gnomeregan/gnomeregan.cpp @@ -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(); diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp index ded5c46ce0c..41adbc63c04 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/instance_magisters_terrace.cpp @@ -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 diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index 09ba0713453..7f5b17d183b 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -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 { } }; diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp index 7791e9c0ae7..ebc77e71430 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.cpp @@ -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 diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp index ac1cd4c6665..a6c5aee0368 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal_trash.cpp @@ -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); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index 6ce48f1e3e4..2bf4a42e065 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp @@ -112,7 +112,6 @@ class boss_kologarn : public CreatureScript DoCast(SPELL_KOLOGARN_REDUCE_PARRY); SetCombatMovement(false); - Reset(); } bool left, right; diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp index b4d721396bf..31a6d8dbc51 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.cpp @@ -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: diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.h b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.h index b1ec4de98c4..1bf9b822b31 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.h +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/shattered_halls.h @@ -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 { diff --git a/src/server/scripts/Outland/zone_nagrand.cpp b/src/server/scripts/Outland/zone_nagrand.cpp index 53f792336f5..0686e27c8a2 100644 --- a/src/server/scripts/Outland/zone_nagrand.cpp +++ b/src/server/scripts/Outland/zone_nagrand.cpp @@ -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 diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp index de8146baf60..e0339e8d9c3 100644 --- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp @@ -365,7 +365,7 @@ public: npc_enslaved_netherwing_drakeAI(Creature* creature) : ScriptedAI(creature) { Tapped = false; - Reset(); + FlyTimer = 10 * IN_MILLISECONDS; } void Reset() override diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 9930ed37b0d..3b5a88889bf 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -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 |