]> git.pond.sub.org Git - empserver/commitdiff
Fix interdiction not to wipe out target ship updates
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 20 Mar 2010 16:55:56 +0000 (17:55 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 21 Mar 2010 08:34:35 +0000 (09:34 +0100)
Ships can expend shells to defend against missiles, in
shp_missile_defense().  Any shell use by the target ship got wiped out
when shp_missile_interdiction() wrote back the target ship, triggering
a seqno mismatch oops.

Ships get updated when they launch planes to intercept interdicting
planes, in mission_pln_equip().  Any petrol use by the target ship got
wiped out when shp_mission_interdiction() wrote back the target ship,
triggering a seqno mismatch oops.

Fix by re-reading the target ship in shp_damage_one().  This also
affects shp_fort_interdiction(), where it is not necessary.  A bit
inefficient, but let's keep this fix simple.
(cherry picked from commit 1d4fea32b845686163b9be79e21ca7ea279357e1)

src/lib/subs/shpsub.c

index 51fe707949ef9aa53d1b3d4128025bd3f78d1066..11353607f043fe04ae5311bcbe7c4c77136f58b6 100644 (file)
@@ -354,6 +354,8 @@ shp_count(struct emp_qelem *list, int wantflags, int nowantflags,
 static void
 shp_damage_one(struct ulist *mlp, int dam)
 {
 static void
 shp_damage_one(struct ulist *mlp, int dam)
 {
+    /* ship might have changed (launched interceptors, missile defense) */
+    getship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
     shipdamage(&mlp->unit.ship, dam);
     putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
     if (!mlp->unit.ship.shp_own) {
     shipdamage(&mlp->unit.ship, dam);
     putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
     if (!mlp->unit.ship.shp_own) {