summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dgn-height.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2014-04-22 22:29:28 -0400
committerNeil Moore <neil@s-z.org>2014-04-23 00:14:08 -0400
commit7a2063a1c841ca47cec7d9f6806a5d3608637e57 (patch)
tree571e81939886bfb4a36aa8b4567d6f7aa9014696 /crawl-ref/source/dgn-height.cc
parent67f9d0461c7b3e5394ef1c653e1bbdae5f8812b0 (diff)
downloadcrawl-ref-7a2063a1c841ca47cec7d9f6806a5d3608637e57.tar.gz
crawl-ref-7a2063a1c841ca47cec7d9f6806a5d3608637e57.zip
Avoid a theoretical divide by zero (floatingatoll, #8415)
Diffstat (limited to 'crawl-ref/source/dgn-height.cc')
-rw-r--r--crawl-ref/source/dgn-height.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/crawl-ref/source/dgn-height.cc b/crawl-ref/source/dgn-height.cc
index 91092552ee..6979acd308 100644
--- a/crawl-ref/source/dgn-height.cc
+++ b/crawl-ref/source/dgn-height.cc
@@ -82,7 +82,10 @@ void dgn_smooth_height_at(coord_def c, int radius, int max_height)
total += nheight * weight;
}
}
- dgn_height_at(c) = total / divisor;
+ // Can't actually be zero currently unless someone passes a negative
+ // or overflowing radius, but this avoids a static analysis warning.
+ if (divisor)
+ dgn_height_at(c) = total / divisor;
}
void dgn_smooth_heights(int radius, int npasses)