Grasscutters / Grasscutter

A server software reimplementation for a certain anime game.
https://grasscutter.io/
GNU Affero General Public License v3.0
16.04k stars 4.47k forks source link

[Bug] Welkin claim time is midnight instead of 4am. #1107

Open AZthemute opened 2 years ago

AZthemute commented 2 years ago

Did you look for other closed issues that have the same problem?

Yes.

Describe the bug

Currently, the Welkin rewards are given out at midnight. In the oficial game, the rewards are given out at 4am - this is the time of the daily reset. The highlighted 4 is usually a 0 - and this is how I tried to fix the code. image I tried changing this one character in the hopes that SOMETHING would happen (before you ask, yes the time is formatted as seconds minutes hours for some reason), but the only change is that now I have to relog at midnight to claim the rewards instead of just being given the rewards. It also seems to make it impossible to save progress - now when I log out and try to save my progress, I am at where I was the time BEFORE the last time I logged out. Yes, this is the ONLY change I made to the code and it happens consistently after rebuilding and testing the fix from zero about 10 times.

I have no clue what's happening and it's driving me insane, so I decided to open this as an issue.

Which branch did you use?

Latest development

Screenshots

Additional context

Yazawazi commented 2 years ago

Uh, seems to be my mistake, Asia server seem to send rewards at 4am UTC+8, not sure about other servers, so I just set 0. There seems to be a problem with the Bless of moon logic, I'll test it again and try to fix it.

Birdulon commented 2 years ago

but the only change is that now I have to relog at midnight to claim the rewards instead of just being given the rewards.

The function getTodayMoonCard is also called on login, and that function only checks against calendar day. We should probably have a DateHelper function that gives out server day instead of calendar day for stuff like this.

Birdulon commented 2 years ago

ofc a hacky fix would be to set this to currenttime minus four hours in addition to changing the cron expression. image

Yazawazi commented 2 years ago

I might try to refactor the implementation of Bless of Moon, the code I wrote before was pretty ugly.

AZthemute commented 2 years ago

but the only change is that now I have to relog at midnight to claim the rewards instead of just being given the rewards.

The function getTodayMoonCard is also called on login, and that function only checks against calendar day. We should probably have a DateHelper function that gives out server day instead of calendar day for stuff like this.

Why would the DateHelper function matter and how would this even be implemented? Would it just take the time from your computer?

Birdulon commented 2 years ago

Yes, it would just take system time with a configurable offset (default -4hr to make 0400 system time the change of day). There's enough game systems that rely on it (https://genshin-impact.fandom.com/wiki/Reset#Daily_Reset) that it may as well be a common helper function.

AZthemute commented 2 years ago

Oh yeah, I forgot about enemy respawn timers. That seems like a good solution, but I'm too scared to touch the coffee programming language any more. It's probably best if I let someone who knows what they're doing to deal with this issue since it'll be very important.