]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix a division by 0
authorMario <mario.mario@y7mail.com>
Tue, 24 Dec 2019 13:31:40 +0000 (23:31 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 24 Dec 2019 13:31:40 +0000 (23:31 +1000)
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc

index 256af90affb3650cfc444b0e9d33827af1504ab1..5789b6e4c4ca2e2a06cdf31168d6151db81685d0 100644 (file)
@@ -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