]> git.pond.sub.org Git - empserver/commit
Take care not to supply from self
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 15 Feb 2009 07:47:43 +0000 (08:47 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 17 Feb 2009 18:32:14 +0000 (19:32 +0100)
commit59c3913b2fbb01392a8dd2771fa25db4df943da3
tree78eb7860706637d88886a5e785feb490750234c4
parent98f24d5cf98ba5f5f4b64f9128edae1bd22beb4b
Take care not to supply from self

Change s_commod() not to use the supply sink as source.  As explained
in the message of the commit before the previous one, using the sink
as source makes it impossible for callers to safely keep a copy of the
sink across a supply call.  All current users do that.  Some were safe
anyway, some were not:

* fort_fire() was safe, because a fort draws shells only when it has
  none.

* shp_fire() was unsafe for ships with capability supply and ammo use
  greater than 1.  No such ship exists in the stock game.

* shp_dchrg() was unsafe for ships with both capabilities dchrg and
  supply.  Same for shp_torp() and capability torp, and
  shp_missile_defense() and capability anti-missile.  No such ship
  exists in the stock game.

* lnd_fire(), supp() and get_dlist() were safe, because they draw
  shells only when they have less than their ammo need, and then they
  don't supply any.

* mission_pln_equip() was unsafe when equipping planes with shells in
  supply sources.

* landmine() was unsafe for land units with both capability engineer
  and supply.  No such land units exist in the stock game.

* load() and lload() were unsafe for loadable supply units, but the
  supply use there was disabled in commit 65410d16 because of another
  bug.

* ask_olist() and att_reacting_units() were safe, because
  lnd_can_attack() excludes supply units.

In the stock game, planes flying interception or support missions,
abms intercepting ballistic missiles, launch of missiles or anti-sats
could conjure up shells, triggering a seqno mismatch oops.

In games with unusual customizations, this could also happen with
supply ships firing guns or torpedoes, dropping depth charges, or
shooting down marine missiles, and in the lmine command.
src/lib/subs/supply.c