]> git.lizzy.rs Git - dungeon_game.git/blobdiff - plugins/game/game.c
Add loot boxes
[dungeon_game.git] / plugins / game / game.c
index cc6d21dffff5a163fba85636a2286f68db771152..ef2651fda5033e4e32b40dcb6d8e22555e93c727 100644 (file)
@@ -334,7 +334,9 @@ static void mapgen_set_air(int x, int y, enum mg_context ctx)
        for (struct list *ptr = air_functions; ptr != NULL; ptr = ptr->next) {
                struct generator_function *func = ptr->element;
 
-               if (rand() % (ctx == MG_CTX_CORRIDOR ? func->corridor_chance : func->room_chance) == 0)
+               int chance = ctx == MG_CTX_CORRIDOR ? func->corridor_chance : func->room_chance;
+
+               if (chance && rand() % chance == 0)
                        func->callback(x, y, ctx);
        }
 }