Skip to content
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

Prevent overflow when using gettimetick(0) #2791

Merged
merged 2 commits into from
Jul 26, 2020

Conversation

Kenpachi2k13
Copy link
Member

Pull Request Prelude

Changes Proposed

Prevent overflow of script variables (signed integer) when using gettimetick(0) by doing a bitwise AND operation on timer->gettick()' and INT_MAX.
This decreases the tick loop interval from ~50 to ~25 days, but I think this is the best approach to fix this issue.

Issues addressed: #2779

@Kenpachi2k13 Kenpachi2k13 added type:bug Issue is a bug or describes an incorrect behavior that should be fixed status:code-review Awaiting code review component:core:scriptengine Affecting the script engine or the script commands component:documentation Affecting the documentation in the doc/ folder labels Jul 3, 2020
@Kenpachi2k13 Kenpachi2k13 added this to the Release v2020.07.26 milestone Jul 3, 2020
@Kenpachi2k13 Kenpachi2k13 self-assigned this Jul 3, 2020
@Kenpachi2k13 Kenpachi2k13 linked an issue Jul 3, 2020 that may be closed by this pull request
@Lemongrass3110
Copy link
Contributor

Lemongrass3110 commented Jul 3, 2020

This will still lead to wrong condition checks for many user scripts that do checks based on ticks for time difference.

@Kenpachi2k13
Copy link
Member Author

@Lemongrass3110

This will still lead to wrong condition checks for many user scripts that do checks based on ticks for time difference.

gettimetick(0) is supposed to be used where one needs to precisely validate a short lapse of time.
So the only problem I can imagine is accidentally having the loop interval being reset between setting the start tick and setting the end tick.
If there's something I don't consider, please tell me or provide an example case. 😊

@MishimaHaruna MishimaHaruna merged commit ee767bd into HerculesWS:master Jul 26, 2020
@Kenpachi2k13 Kenpachi2k13 deleted the gettimetick branch July 30, 2020 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:core:scriptengine Affecting the script engine or the script commands component:documentation Affecting the documentation in the doc/ folder status:code-review Awaiting code review type:bug Issue is a bug or describes an incorrect behavior that should be fixed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gettimetick(0) returns negative value
4 participants