Skip to content

Use mask to match any weekday and some optimizations - #26

Open
kissingers wants to merge 2 commits into
azerothcore:masterfrom
kissingers:master
Open

Use mask to match any weekday and some optimizations#26
kissingers wants to merge 2 commits into
azerothcore:masterfrom
kissingers:master

Conversation

@kissingers

@kissingers kissingers commented Aug 25, 2025

Copy link
Copy Markdown
Contributor
  1. Use mask to match any weekday, and cover the method ServerAutoShutdown.weekday, so remove the weekday config and code. now can set any weekday you want to shutdown the server.

  2. Move most load config and check config to top side of init

  3. Merged the function for obtaining the next shudown time.

  4. Remove redundant includes and code, rename some para

Description: If set, the server will restart on the specified weekdays at the configured time. Overrides ServerAutoShutdown.EveryDays if set to a valid value.

Weekday bitmask where each day corresponds to a bit position:

Sunday = 1 = 0b0000001 (2^0)

Monday = 2 = 0b0000010 (2^1)

Tuesday = 4 = 0b0000100 (2^2)

Wednesday = 8 = 0b0001000 (2^3)

Thursday = 16 = 0b0010000 (2^4)

Friday = 32 = 0b0100000 (2^5)

Saturday = 64 = 0b1000000 (2^6)

To select multiple days, add the corresponding decimal values.

Examples:

Monday: 2^1 = 2 (binary: 0b0000010), just one day a week

Tuesday and Wednesday: 4 + 8 = 12 (binary: 0b0000100 + 0b0001000 = 0b0001100), both the 2 days a week

Sunday, Friday, Saturday: 1 + 32 + 64 = 97 (binary: 0b0000001 + 0b0100000 + 0b1000000 = 0b1100001), the selected 3 days a week

All days: 1+2+4+8+16+32+64 = 127 (binary: 0b0000001 + 0b0000010 + 0b0000100 + 0b0001000 + 0b0010000 + 0b0100000 + 0b1000000 = 0b1111111)

Default: 0 - disabled, use ServerAutoShutdown.EveryDays

1-127 - Enable masked weekdays

ServerAutoShutdown.WeekdayMask = 0

@kissingers

Copy link
Copy Markdown
Contributor Author

Tested all logic, if weekday mask today, now time big than shutdown time, will right shutdown at the next masked weekday

@Helias
Helias requested a review from Nyeriah August 26, 2025 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant