From 6ac9ad66e104b1b5d2c20c3ab52e22efc1dfe168 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 15 Feb 2009 14:38:09 +0100 Subject: [PATCH] Don't let automatic supply starve the sector containing the sink Automatic supply always leaves enough food to avoid starvation in supply sources, except for one case: when drawing supplies from the sector containing the sink. This behavior contradicted info supply. However, do_feed() used to rely on it (it would have wiped out food without it). Supply use there was removed in commit 7da69c92, so we can now fix this. Affected by this is the automatic food supply of land units in combat, and the food supply in commands supply, load and lload. Except supply is disabled due to bugs in the last two. --- src/lib/subs/supply.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/subs/supply.c b/src/lib/subs/supply.c index d6203a32c..dbe725720 100644 --- a/src/lib/subs/supply.c +++ b/src/lib/subs/supply.c @@ -133,7 +133,7 @@ s_commod(int own, int x, int y, i_type type, int total_wanted, struct shpstr ship; struct lndstr land; /* leave at least 1 military in sectors/ships */ - int minimum = (type == I_MILIT ? 1 : 0); + int minimum = 0; int can_move; double move_cost, weight, mobcost; int packing; @@ -145,6 +145,9 @@ s_commod(int own, int x, int y, i_type type, int total_wanted, getsect(x, y, &dest); getsect(x, y, §); if (sect.sct_own == own) { + if (!opt_NOFOOD && type == I_FOOD) + minimum = 1 + (int)ceil(food_needed(sect.sct_item, + etu_per_update)); if (sect.sct_item[type] - wanted >= minimum) { sect.sct_item[type] -= wanted; if (actually_doit) -- 2.43.0