-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix game crash when burndelay is 0 bug #179
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -935,10 +935,12 @@ namespace game | |
int millis = lastmillis-d->lastres[WR_BURN]; | ||
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 | ||
int _burndelay = std::max(burndelay, 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to what? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, changed them to |
||
if(burntime-millis < _burndelay) pc *= float(burntime - millis) / float(_burndelay); | ||
else | ||
{ | ||
float fluc = float(millis%burndelay)*(0.25f+0.03f)/burndelay; | ||
float fluc = float(millis % _burndelay) * (0.25f + 0.03f) / _burndelay; | ||
if(fluc >= 0.25f) fluc = (0.25f+0.03f-fluc)*(0.25f/0.03f); | ||
pc *= 0.75f+fluc; | ||
} | ||
|
@@ -3610,8 +3612,10 @@ namespace game | |
{ | ||
int millis = lastmillis-d->lastres[WR_BURN]; | ||
float pc = 1, intensity = 0.5f+(rnd(50)/100.f), fade = (d != focus ? 0.5f : 0.f)+(rnd(50)/100.f); | ||
if(burntime-millis < burndelay) pc *= float(burntime-millis)/float(burndelay); | ||
else pc *= 0.75f+(float(millis%burndelay)/float(burndelay*4)); | ||
// 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); | ||
if(burntime - millis < _burndelay) pc *= float(burntime - millis) / _burndelay; | ||
else pc *= 0.75f + (float(millis % _burndelay) / float(_burndelay * 4)); | ||
vec pos = vec(d->center()).sub(vec(rnd(11)-5, rnd(11)-5, rnd(5)-2).mul(pc)); | ||
regular_part_create(PART_FIREBALL, 50, pos, pulsecols[PULSE_FIRE][rnd(PULSECOLOURS)], d->height*0.75f*intensity*blend*pc, fade*blend*pc, -10, 0); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is very long, and this is not a check you just enforce a lower boundary.