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
This commit is contained in:
Ovahlord
2020-01-11 23:42:08 +01:00
parent 02c12f7e77
commit 0e60ed1682
2 changed files with 7 additions and 2 deletions

View File

@@ -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;

View File

@@ -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);