From ae3195149da65775b471e2e962e5d330b4b33539 Mon Sep 17 00:00:00 2001
From: Andreas Gattringer <gattringera@a772-cvl-ws23.biodiv.univie.ac.at>
Date: Wed, 28 Jun 2023 15:05:40 +0200
Subject: [PATCH] butterflies: return early from maturation if no eggs are
 present

---
 src/modules/butterflies/butterflies_populations.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/modules/butterflies/butterflies_populations.c b/src/modules/butterflies/butterflies_populations.c
index f1a4b8e..a06db76 100644
--- a/src/modules/butterflies/butterflies_populations.c
+++ b/src/modules/butterflies/butterflies_populations.c
@@ -81,8 +81,9 @@ void bf_cell_maturation(struct cats_grid *grid, struct cats_thread_info *ts, cat
 
         data->eggs[row][col] -= eggs;
 
-        assert(data->eggs[row][col] >= 0);
 
+        assert(data->eggs[row][col] >= 0);
+        if (eggs == 0) return;
 
         // not capped, we can have more adults than CC
         struct conf_data_butterflies *module_conf = CATS_MODULE_DATA;
-- 
GitLab