]> git.pond.sub.org Git - empserver/commitdiff
Don't run supply machinery to get zero units
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 28 May 2008 05:35:22 +0000 (07:35 +0200)
committerMarkus Armbruster <armbru@pike.pond.sub.org>
Wed, 28 May 2008 20:33:27 +0000 (22:33 +0200)
Change supply_commod() and try_supply_commod() not to call s_commod()
when zero units are wanted.

This isn't just for efficiency, it's also for limiting exposure to
supply bugs a bit.
(cherry picked from commit 7f17369491f9d6a01f35d1017d9da49b308f80b4)

src/lib/subs/supply.c

index 96b2d2cc314dcb7f8e64725932d37c4b4b23cbc9..1aa46b474b2520ba6707885809d11b1a66aa077d 100644 (file)
@@ -124,7 +124,7 @@ resupply_commod(struct lndstr *lp, i_type type)
 int
 supply_commod(int own, int x, int y, i_type type, int total_wanted)
 {
-    if (total_wanted < 0)
+    if (total_wanted <= 0)
        return 0;
     return s_commod(own, x, y, type, total_wanted, !player->simulation);
 }
@@ -135,7 +135,7 @@ supply_commod(int own, int x, int y, i_type type, int total_wanted)
 static int
 try_supply_commod(int own, int x, int y, i_type type, int total_wanted)
 {
-    if (total_wanted < 0)
+    if (total_wanted <= 0)
        return 0;
 
     return s_commod(own, x, y, type, total_wanted, 0);