Fix game crash when burndelay is 0 bug#179
Merged
TheAssassin merged 4 commits intomasterfrom Dec 5, 2020
Merged
Conversation
Member
|
|
Contributor
Author
I just made PR #182 :) |
TheAssassin
requested changes
Aug 1, 2020
src/game/game.cpp
Outdated
| size_t seed = size_t(d) + (millis/50); | ||
| float pc = 1, amt = (millis%50)/50.0f, intensity = 0.75f+(detrnd(seed, 25)*(1-amt) + detrnd(seed + 1, 25)*amt)/100.f; | ||
| if(burntime-millis < burndelay) pc *= float(burntime-millis)/float(burndelay); | ||
| // When playing on servers with an older version, burndelay can be 0, thus add a check to prevent division by 0 |
Member
There was a problem hiding this comment.
The comment is very long, and this is not a check you just enforce a lower boundary.
Suggested change
| // When playing on servers with an older version, burndelay can be 0, thus add a check to prevent division by 0 | |
| // avoid division by zero by enforcing new lower boundary |
src/game/game.cpp
Outdated
| float pc = 1, amt = (millis%50)/50.0f, intensity = 0.75f+(detrnd(seed, 25)*(1-amt) + detrnd(seed + 1, 25)*amt)/100.f; | ||
| if(burntime-millis < burndelay) pc *= float(burntime-millis)/float(burndelay); | ||
| // When playing on servers with an older version, burndelay can be 0, thus add a check to prevent division by 0 | ||
| int _burndelay = std::max(burndelay, 1); |
Member
There was a problem hiding this comment.
The _ prefix is preserved for standard-specified things (as per the ISO C standard) IIRC. Please rename.
Contributor
Author
There was a problem hiding this comment.
ok, changed them to fixed_burndelay
TheAssassin
approved these changes
Aug 2, 2020
Member
TheAssassin
left a comment
There was a problem hiding this comment.
Consider adding more blank lines in the future, especially above inline comments. That really improves the code's readability.
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.
Setting the
burndelayvariable to0crashes the game. To fix this we can't just setburndelaymin to1because servers that don't have the patch, will just override it, therefore I had to use temp vars like_burndelay = std::max(burndelay, 1);Closes: #177