Use mask to match any weekday and some optimizations - #26
Open
kissingers wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
Tested all logic, if weekday mask today, now time big than shutdown time, will right shutdown at the next masked weekday |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Move most load config and check config to top side of init
Merged the function for obtaining the next shudown time.
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