From 0e60ed168285e5c9a0bc97693da100faa54375ab Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sat, 11 Jan 2020 23:42:08 +0100 Subject: [PATCH] Core/Events: allow to override holiday durations and correct Lunar Festival duration down to 2 weeks * the new field must be set for every new holiday date entry to take effect if you want to override the duration of the given --- sql/updates/world/custom/custom_2020_01_11_05_world.sql | 2 ++ src/server/game/Events/GameEventMgr.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 sql/updates/world/custom/custom_2020_01_11_05_world.sql diff --git a/sql/updates/world/custom/custom_2020_01_11_05_world.sql b/sql/updates/world/custom/custom_2020_01_11_05_world.sql new file mode 100644 index 00000000000..62c271ad054 --- /dev/null +++ b/sql/updates/world/custom/custom_2020_01_11_05_world.sql @@ -0,0 +1,2 @@ +ALTER TABLE `holiday_dates` ADD COLUMN `holiday_duration` INT(10) UNSIGNED NOT NULL AFTER `date_value`; +UPDATE `holiday_dates` SET `holiday_duration`= 360 WHERE `id`= 327; diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 2df63196437..7add6c2f422 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -945,8 +945,8 @@ void GameEventMgr::LoadHolidayDates() { uint32 oldMSTime = getMSTime(); - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT id, date_id, date_value FROM holiday_dates"); + // 0 1 2 3 + QueryResult result = WorldDatabase.Query("SELECT id, date_id, date_value, holiday_duration FROM holiday_dates"); if (!result) { TC_LOG_INFO("server.loading", ">> Loaded 0 holiday dates. DB table `holiday_dates` is empty."); @@ -972,6 +972,9 @@ void GameEventMgr::LoadHolidayDates() } entry->Date[dateId] = fields[2].GetUInt32(); + if (uint32 duration = fields[3].GetUInt32()) + entry->Duration[0] = duration; + auto itr = std::lower_bound(modifiedHolidays.begin(), modifiedHolidays.end(), entry->Id); if (itr == modifiedHolidays.end() || *itr != entry->Id) modifiedHolidays.insert(itr, entry->Id);