]> git.pond.sub.org Git - empserver/commit - src/lib/subs/attsub.c
board: Don't retreat ship#0 after failed board sinks ship
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 12 Jan 2015 19:07:17 +0000 (20:07 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 2 Mar 2015 07:20:51 +0000 (08:20 +0100)
commitebe4f05d8730852c47abd05200b6a2203842faa9
tree04d24d529e69817c8800e4c1f410a982b770d708
parent0447bf3f585ed6deac6f08234126a1daa15d510e
board: Don't retreat ship#0 after failed board sinks ship

The root cause is in put_combat(): after it sinks the ship, it calls
att_get_combat(), which treats a combat object with a dead ship as an
error, tells the attacker "not in the same sector!", and "recovers" by
putting the combat object into an error state.  Too hard for me to fix
right now, so put in a FIXME comment.

The error state trips up retreat.  boar() uses the victim's ship
number in the combat object to find the ship it may have to retreat.
Putting the combat object into an error state sets this number to
zero.  If that ship exists, and isn't owned by the attacker, and has
RET_BOARDED set, it retreats.  Oops.  Broken when Empire 2 factored
out common combat code.

Fix by saving the ship number while it's still valid.

This uncovers the next bug: we now pass a dead ship to retreat_ship().
Oopses since commit f743f37.  Its commit message says "Harmless, but
avoid it anyway."  Going to revert.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
src/lib/commands/boar.c
src/lib/subs/attsub.c
tests/retreat/01-retreat-1
tests/retreat/server.log