From: Mario Date: Tue, 24 Dec 2019 13:31:40 +0000 (+1000) Subject: Fix a division by 0 X-Git-Tag: xonotic-v0.8.5~1197 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c8e8ae6baec383d1199c22c3a34dfcbce1db006d;p=xonotic%2Fxonotic-data.pk3dir.git Fix a division by 0 --- diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 256af90af..5789b6e4c 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -227,7 +227,8 @@ void buff_NewType(entity ent) FOREACH(Buffs, buff_Available(it), { // if it's already been chosen, give it a lower priority - RandomSelection_AddEnt(it, max(0.2, 1 / it.buff_seencount), 1); + float myseencount = (it.buff_seencount > 0) ? it.buff_seencount : 1; // no division by zero please! + RandomSelection_AddEnt(it, max(0.2, 1 / myseencount), 1); }); entity newbuff = RandomSelection_chosen_ent; newbuff.buff_seencount += 1; // lower chances of seeing this buff again soon