aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiztazz <felianther15@gmail.com>2022-04-22 12:59:08 +0200
committerShauren <shauren.trinity@gmail.com>2022-06-10 19:08:05 +0200
commit5417285a11dfeebd4ba83e6f28f085f9f1b05a67 (patch)
treef8422d4addcdc6b2998d45457837fd6d7ad5c5a6 /src
parent312569970ee14855d7e9153fd36cdea413676df4 (diff)
Core/Scripts: Fix heap buffer overflow in BRD Tomb of seven event (#27920)
* Core/Scripts: Fix heap buffer overflow in BRD Tomb of seven event * Core/Scripts: Remove magic numbers in brd script, adjust codestyle to tc preference * missing ) Closes #27919 (cherry picked from commit 0d8672732552b0474e22b077a2318fa87446f25f)
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp
index 69e84081c8f..8c06fa25d62 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp
@@ -26,6 +26,7 @@
#define TIMER_TOMBOFTHESEVEN 15000
#define MAX_ENCOUNTER 6
+constexpr uint8 TOMB_OF_SEVEN_BOSS_NUM = 7;
enum Creatures
{
@@ -124,7 +125,7 @@ public:
uint32 BarAleCount;
uint32 GhostKillCount;
- ObjectGuid TombBossGUIDs[7];
+ ObjectGuid TombBossGUIDs[TOMB_OF_SEVEN_BOSS_NUM];
ObjectGuid TombEventStarterGUID;
uint32 TombTimer;
uint32 TombEventCounter;
@@ -170,7 +171,7 @@ public:
case GO_TOMB_ENTER: GoTombEnterGUID = go->GetGUID(); break;
case GO_TOMB_EXIT:
GoTombExitGUID = go->GetGUID();
- if (GhostKillCount >= 7)
+ if (GhostKillCount >= TOMB_OF_SEVEN_BOSS_NUM)
HandleGameObject(ObjectGuid::Empty, true, go);
else
HandleGameObject(ObjectGuid::Empty, false, go);
@@ -234,7 +235,7 @@ public:
break;
}
- if (data == DONE || GhostKillCount >= 7)
+ if (data == DONE || GhostKillCount >= TOMB_OF_SEVEN_BOSS_NUM)
{
OUT_SAVE_INST_DATA;
@@ -340,17 +341,17 @@ public:
for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
if (encounter[i] == IN_PROGRESS)
encounter[i] = NOT_STARTED;
- if (GhostKillCount > 0 && GhostKillCount < 7)
+ if (GhostKillCount > 0 && GhostKillCount < TOMB_OF_SEVEN_BOSS_NUM)
GhostKillCount = 0;//reset tomb of seven event
- if (GhostKillCount >= 7)
- GhostKillCount = 7;
+ if (GhostKillCount >= TOMB_OF_SEVEN_BOSS_NUM)
+ GhostKillCount = TOMB_OF_SEVEN_BOSS_NUM;
OUT_LOAD_INST_DATA_COMPLETE;
}
void TombOfSevenEvent()
{
- if (GhostKillCount < 7 && !TombBossGUIDs[TombEventCounter].IsEmpty())
+ if (GhostKillCount < TOMB_OF_SEVEN_BOSS_NUM && !TombBossGUIDs[TombEventCounter].IsEmpty())
{
if (Creature* boss = instance->GetCreature(TombBossGUIDs[TombEventCounter]))
{
@@ -366,7 +367,7 @@ public:
{
HandleGameObject(GoTombExitGUID, false);//event reseted, close exit door
HandleGameObject(GoTombEnterGUID, true);//event reseted, open entrance door
- for (uint8 i = 0; i < 7; ++i)
+ for (uint8 i = 0; i < TOMB_OF_SEVEN_BOSS_NUM; ++i)
{
if (Creature* boss = instance->GetCreature(TombBossGUIDs[i]))
{
@@ -400,15 +401,19 @@ public:
}
void Update(uint32 diff) override
{
- if (!TombEventStarterGUID.IsEmpty() && GhostKillCount < 7)
+ if (!TombEventStarterGUID.IsEmpty() && GhostKillCount < TOMB_OF_SEVEN_BOSS_NUM)
{
if (TombTimer <= diff)
{
TombTimer = TIMER_TOMBOFTHESEVEN;
- ++TombEventCounter;
- TombOfSevenEvent();
+ if (TombEventCounter < TOMB_OF_SEVEN_BOSS_NUM)
+ {
+ TombOfSevenEvent();
+ ++TombEventCounter;
+ }
+
// Check Killed bosses
- for (uint8 i = 0; i < 7; ++i)
+ for (uint8 i = 0; i < TOMB_OF_SEVEN_BOSS_NUM; ++i)
{
if (Creature* boss = instance->GetCreature(TombBossGUIDs[i]))
{
@@ -420,7 +425,7 @@ public:
}
} else TombTimer -= diff;
}
- if (GhostKillCount >= 7 && !TombEventStarterGUID.IsEmpty())
+ if (GhostKillCount >= TOMB_OF_SEVEN_BOSS_NUM && !TombEventStarterGUID.IsEmpty())
TombOfSevenEnd();
}
};