diff --git a/sql/updates/world/custom/custom_2020_01_11_04_world.sql b/sql/updates/world/custom/custom_2020_01_11_04_world.sql
new file mode 100644
index 00000000000..895b6cfcd8e
--- /dev/null
+++ b/sql/updates/world/custom/custom_2020_01_11_04_world.sql
@@ -0,0 +1,14 @@
+ALTER TABLE `game_event_battleground_holiday`
+ CHANGE `eventEntry` `EventEntry` TINYINT(3) UNSIGNED NOT NULL COMMENT 'game_event EventEntry identifier',
+ CHANGE `bgflag` `BattlegroundID` INT(3) UNSIGNED DEFAULT 0 NOT NULL;
+
+TRUNCATE TABLE `game_event_battleground_holiday`;
+INSERT INTO `game_event_battleground_holiday` (`EventEntry`, `BattlegroundID`) VALUES
+(18, 1),
+(19, 2),
+(20, 3),
+(21, 7),
+(53, 9),
+(54, 30),
+(82, 120),
+(83, 108);
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index aea888f17b4..a1774fe5418 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -1079,12 +1079,17 @@ void BattlegroundMgr::ToggleArenaTesting()
sWorld->SendWorldText(m_ArenaTesting ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF);
}
-void BattlegroundMgr::SetHolidayWeekends(uint32 mask)
+void BattlegroundMgr::ResetHolidays()
{
- // The current code supports battlegrounds up to BattlegroundTypeId(31)
- for (uint32 bgtype = 1; bgtype < MAX_BATTLEGROUND_TYPE_ID && bgtype < 32; ++bgtype)
- if (Battleground* bg = GetBattlegroundTemplate(BattlegroundTypeId(bgtype)))
- bg->SetHoliday((mask & (1 << bgtype)) != 0);
+ for (uint32 i = BATTLEGROUND_AV; i < MAX_BATTLEGROUND_TYPE_ID; i++)
+ if (Battleground* bg = GetBattlegroundTemplate(BattlegroundTypeId(i)))
+ bg->SetHoliday(false);
+}
+
+void BattlegroundMgr::SetHolidayActive(uint32 battlegroundId)
+{
+ if (Battleground* bg = GetBattlegroundTemplate(BattlegroundTypeId(battlegroundId)))
+ bg->SetHoliday(true);
}
void BattlegroundMgr::ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 arenaType, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h
index 81d9f7ed377..459ef7ee896 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.h
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.h
@@ -100,7 +100,8 @@ class TC_GAME_API BattlegroundMgr
void ToggleArenaTesting();
void ToggleTesting();
- void SetHolidayWeekends(uint32 mask);
+ void ResetHolidays();
+ void SetHolidayActive(uint32 battlegroundId);
bool isArenaTesting() const { return m_ArenaTesting; }
bool isTesting() const { return m_Testing; }
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index 634103620d4..0bd5d6479d9 100644
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -861,12 +861,12 @@ void GameEventMgr::LoadFromDB()
}
}
- TC_LOG_INFO("server.loading", "Loading Game Event Battleground Data...");
+ TC_LOG_INFO("server.loading", "Loading Game Event Battleground Holiday Data...");
{
uint32 oldMSTime = getMSTime();
- // 0 1
- QueryResult result = WorldDatabase.Query("SELECT eventEntry, bgflag FROM game_event_battleground_holiday");
+ // 0 1
+ QueryResult result = WorldDatabase.Query("SELECT EventEntry, BattlegroundID FROM game_event_battleground_holiday");
if (!result)
TC_LOG_INFO("server.loading", ">> Loaded 0 battleground holidays in game events. DB table `game_event_battleground_holiday` is empty.");
@@ -877,7 +877,7 @@ void GameEventMgr::LoadFromDB()
{
Field* fields = result->Fetch();
- uint16 event_id = fields[0].GetUInt8();
+ uint32 event_id = fields[0].GetUInt8();
if (event_id >= mGameEvent.size())
{
@@ -1220,10 +1220,10 @@ void GameEventMgr::UpdateEventNPCFlags(uint16 event_id)
void GameEventMgr::UpdateBattlegroundSettings()
{
- uint32 mask = 0;
- for (ActiveEvents::const_iterator itr = m_ActiveEvents.begin(); itr != m_ActiveEvents.end(); ++itr)
- mask |= mGameEventBattlegroundHolidays[*itr];
- sBattlegroundMgr->SetHolidayWeekends(mask);
+ sBattlegroundMgr->ResetHolidays();
+
+ for (uint32 activeEventId : m_ActiveEvents)
+ sBattlegroundMgr->SetHolidayActive(mGameEventBattlegroundHolidays[activeEventId]);
}
void GameEventMgr::UpdateEventNPCVendor(uint16 event_id, bool activate)
@@ -1835,8 +1835,8 @@ bool IsHolidayActive(HolidayIds id)
return false;
}
-bool IsEventActive(uint16 event_id)
+bool IsEventActive(uint32 eventId)
{
GameEventMgr::ActiveEvents const& ae = sGameEventMgr->GetActiveEventList();
- return ae.find(event_id) != ae.end();
+ return ae.find(eventId) != ae.end();
}
diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h
index 21843976f98..81f3f15eba1 100644
--- a/src/server/game/Events/GameEventMgr.h
+++ b/src/server/game/Events/GameEventMgr.h
@@ -166,7 +166,7 @@ class TC_GAME_API GameEventMgr
typedef std::pair GuidNPCFlagPair;
typedef std::list NPCFlagList;
typedef std::vector GameEventNPCFlagMap;
- typedef std::vector GameEventBitmask;
+ typedef std::vector GameEventBattlegroundMap;
GameEventQuestMap mGameEventCreatureQuests;
GameEventQuestMap mGameEventGameObjectQuests;
GameEventNPCVendorMap mGameEventVendors;
@@ -175,7 +175,7 @@ class TC_GAME_API GameEventMgr
//GameEventGuidMap mGameEventGameobjectGuids;
GameEventIdMap mGameEventPoolIds;
GameEventDataMap mGameEvent;
- GameEventBitmask mGameEventBattlegroundHolidays;
+ GameEventBattlegroundMap mGameEventBattlegroundHolidays;
QuestIdToEventConditionMap mQuestToEventConditions;
GameEventNPCFlagMap mGameEventNPCFlags;
ActiveEvents m_ActiveEvents;
@@ -190,6 +190,6 @@ class TC_GAME_API GameEventMgr
#define sGameEventMgr GameEventMgr::instance()
TC_GAME_API bool IsHolidayActive(HolidayIds id);
-TC_GAME_API bool IsEventActive(uint16 event_id);
+TC_GAME_API bool IsEventActive(uint32 eventId);
#endif