-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(Core/Events): Add dynamic holiday date calculator #24038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(Core/Events): Add dynamic holiday date calculator #24038
Conversation
Replaces static SQL-based holiday dates with dynamic C++ calculation. Holidays are now computed at runtime using: - Computus algorithm for Easter-based holidays (Noblegarden) - Nth weekday calculation for floating holidays (Pilgrim's Bounty) - Fixed dates for standard holidays Includes unit tests covering years 1900-2200. DB overrides still supported for custom servers.
5d19425 to
61eee6f
Compare
|
does this align with the entries in or even better could those entries be taken into account maybe |
|
it would be great if the calendar could actually reflect what |
|
also is this one of your AI generated fixes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces dynamic holiday date calculation to replace static SQL-based holiday dates. It adds a new HolidayDateCalculator utility class that computes holiday dates at runtime using mathematical algorithms (Computus for Easter, nth-weekday calculation for Thanksgiving-like holidays, and fixed dates for regular holidays). The system generates dates for the current year plus 10 future years at server startup, while preserving database override capabilities for custom servers.
Key Changes:
- New holiday date calculation system supporting three types: fixed dates, nth weekday of month, and Easter-relative dates
- Comprehensive unit test coverage spanning 301 years (1900-2200) with edge case validation
- Integration with existing
GameEventMgrthat generates dynamic dates while maintaining DB override compatibility
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
HolidayDateCalculator.h |
Declares calculator class with Easter (Computus), nth-weekday, and fixed-date calculation methods; defines holiday rule structures and enums |
HolidayDateCalculator.cpp |
Implements Gregorian Computus algorithm for Easter, nth-weekday finder, date packing/unpacking for WoW's 2000-2031 format, and holiday rule configuration |
HolidayDateCalculatorTest.cpp |
Comprehensive test suite with 485 lines covering known Easter dates, weekday calculations, pack/unpack roundtrips, leap years, and century boundaries across 1900-2200 |
GameEventMgr.cpp |
Modified LoadHolidayDates() to generate 11 years of dynamic dates per holiday, then load DB overrides; preserves backward compatibility |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use std::chrono with thread-safe localtime_r/localtime_s - Add const to applicable variables - Change Weekday to enum class - Add source reference for Computus algorithm - Add unit test for packed date year limitations
No currently it doesn't... I'll see what I can do today
I use AI to help me quite a bit yeah, but its more like don't trust and verify/read through exactly what I'm doing. It's why also I wanted the unit tests. |
|
darkmoon faires dates are already beeing calculated in the core via the dbc configuration, the dbc entry is linked in
|
|
After digging deeper into this, I want to clarify how the integration actually works: The dynamic dates DO feed into game_event timing - they're not independent systems. The loading order in World.cpp is:
SetHolidayEventTime() (line 1880) reads from holiday->Date[] to set gameEvent.Start. So when we populate Date[] dynamically, both the calendar AND the game event timing use the same calculated dates. HolidayDateCalculator The only thing "hardcoded" in C++ is the calculation rules (Easter algorithm, "4th Thursday of November" logic), not the dates themselves. The holiday_dates table still works as an override layer for custom servers or cultural differences. |
this PR doesn't change that. Darkmoon uses Looping=1 with a fixed occurence interval, which works because it recurs at regular intervals |
Implement Jean Meeus algorithm to calculate Chinese New Year dates dynamically using astronomical new moon calculation instead of a static lookup table. CNY falls on the new moon between Jan 21-Feb 20. - Add CalculateLunarNewYear() with full Meeus algorithm - Add DateToJulianDay/JulianDayToDate conversion functions - Add CalculateNewMoon() with 15 correction terms from Table 49.A - Update Lunar Festival rule to use LUNAR_NEW_YEAR calculation type - Add 5 unit tests covering years 1900-2200 with 100% accuracy
Add 7 additional fixed-date holidays to the dynamic system: - Midsummer Fire Festival (Jun 21) - Fireworks Spectacular (Jul 4) - Pirates' Day (Sep 19) - Brewfest (Sep 20) - Hallow's End (Oct 18) - Day of the Dead (Nov 1) - Winter Veil (Dec 15) Total holidays now managed by dynamic system: 13
- Alphabetize HolidayDateCalculator.h include - Use explicit time_point type instead of auto
Changes Proposed:
Replaces static SQL-based holiday dates with dynamic C++ calculation, eliminating the need for recurring SQL maintenance as years progress.
This PR proposes changes to:
New Files
HolidayDateCalculator.h/.cpp- Utility class that calculates holiday dates at runtime:HolidayDateCalculatorTest.cpp- Unit tests covering years 1900-2200Modified Files
GameEventMgr.cpp- Generates dynamic dates on load, DB overrides preserved for custom serversHolidays Covered
Issues Addressed:
SOURCE:
The changes have been validated through:
Easter dates validated against known astronomical Easter tables. Thanksgiving dates validated against US calendar.
Tests Performed:
This PR has been:
Unit tests pass:
How to Test the Changes:
HolidayDateCalculatorTestto verify calculationsKnown Issues and TODO List: