]> git.pond.sub.org Git - empserver/commit
Fix navigate not to wipe out concurrent updates
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 17 May 2012 18:33:34 +0000 (20:33 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 22 May 2012 18:38:19 +0000 (20:38 +0200)
commita694e4934359deca1662dabd3441c4bb63e08789
tree14afe61853d9e7efa533cad5f82d7a8bb7592d58
parent0700d97fe3f0d15f2239f09383bd4f110aafa47b
Fix navigate not to wipe out concurrent updates

Navigation code reads the ships into a ship list, and writes them back
when it changes them, e.g. when a ship stops.  If a ship changes in
the ship file while it is in such a ship list, the copy in the ship
list becomes stale, and must not be used.

To that end, do_unit_move() calls shp_nav() after prompting for path
or destination.  shp_nav() re-reads all the ships.  Unfortunately, it
still writes back stale copies in certain circumstances.  Known ways
to trigger such writes:

* Deity sets a sail path

* Ship's crew gone, e.g. killed by shell fire

* Sector no longer navigable, e.g. harbor shelled down, or bridge
  built

Writing a stale copy wipes out the updates that made the copy stale,
and triggers a seqno mismatch oops.  For instance, ship damage that
kills all crew while the ship is being navigated gets wiped out.
src/lib/subs/shpsub.c