]> git.pond.sub.org Git - empserver/commitdiff
Fix return value of s_commod() when it can't draw enough
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 16 Apr 2009 11:06:32 +0000 (13:06 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 16 Apr 2009 11:06:32 +0000 (13:06 +0200)
s_commod() could incorrectly claim success when the sink ended up with
at least as many supplies than were missing initially.  This caused a
number of problems:

* shp_torp() let a ship with two shells fire a torpedo, resulting in
  -1 shells, which then made item_prewrite() oops.  Affected missions
  and return fire, but not the torpedo command.

* shp_missile_defense() let a ship with one shell use missile defense,
  resulting in -1 shells, and the same item_prewrite() oops.

* Land units were considered in supply even when they had not quite
  enough supplies.  Such land units could defend without penalty,
  attack and react.  Commands load and lload weren't affected, because
  they use lnd_in_supply(), which doesn't use s_commod().

Broken in 98f24d5c, v4.3.20.

src/lib/subs/supply.c

index 2650d33f8313696add027ff33bf7ff77729c5c51..853e77fb178a7886c9dc7e9a3905e49dc081da32 100644 (file)
@@ -402,7 +402,7 @@ s_commod(struct empobj *sink, short *vec,
 
     if (actually_doit)
        put_empobj(sink->ef_type, sink->uid, sink);
-    return wanted <= vec[type];
+    return 0;
 }
 
 /*