From eb9eac73183c0c8bdfc6b92e3578a4c058be017c Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 27 Jul 2024 20:44:04 +0200 Subject: [PATCH] fixed a crash when setting custom land difficulty to 0 --- landgen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/landgen.cpp b/landgen.cpp index 78b916c6..f0a38fd1 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -181,7 +181,9 @@ EX int hrand_monster_in(eLand l, int x) { if(t > 500) x = int(((long long)(x)) * t / 500); } if(use_custom_land_list) { - x = x * 100 / custom_land_difficulty[l]; + auto diff = custom_land_difficulty[l]; + if(!diff) return 1000000000; + x = x * 100 / diff; if(x == 0) x = 1; } return hrand(x);