From 78e880a608be5f4d39a9e8b967e0e25d31d55811 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 18 Jun 2005 16:52:17 +0000 Subject: [PATCH] (att_move_in_off): When boarding from a sector, mil entering the ship less one were not removed from the sector. The problem is putsect() overwriting data from prior put_combat() with old data. Broken in rev. 1.17. Change lunchbox code to match that of 1.16. Closes #1219918, reported by Doug Wescott. --- src/lib/subs/attsub.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index 040b2423..57c22dc8 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -2461,13 +2461,11 @@ att_move_in_off(int combat_mode, struct combat *off, { struct sctstr sect; struct shpstr ship; - int troops; - int n, lunchbox; + int troops, n; + int lunchbox = 0; move_in_land(combat_mode, off, olist, def); - getsect(def->x, def->y, §); - for (n = 0; n <= off->last; ++n) { if (off[n].type == EF_BAD || !off[n].troops) continue; @@ -2477,25 +2475,29 @@ att_move_in_off(int combat_mode, struct combat *off, def->mil += troops; put_combat(off + n); if (combat_mode == A_ASSAULT) { - if (off[n].type != EF_SHIP || def->type != EF_SECTOR) { - logerror("att_move_in_off: strange assault"); + if (CANT_HAPPEN(off[n].type != EF_SHIP)) continue; - } getship(off[n].shp_uid, &ship); - lunchbox = (int)((troops + 1) * ship.shp_item[I_FOOD] - / (ship.shp_item[I_MILIT] + troops - + ship.shp_item[I_CIVIL] + 0.5)); - if (lunchbox > ITEM_MAX - sect.sct_item[I_FOOD]) - lunchbox = ITEM_MAX - sect.sct_item[I_FOOD]; + lunchbox += (int)((troops + 1) * ship.shp_item[I_FOOD] + / (ship.shp_item[I_MILIT] + troops + + ship.shp_item[I_CIVIL] + 0.5)); ship.shp_item[I_FOOD] -= lunchbox; - sect.sct_item[I_FOOD] += lunchbox; putship(ship.shp_uid, &ship); } } - putsect(§); put_combat(def); + + if (combat_mode == A_ASSAULT) { + if (CANT_HAPPEN(def->type != EF_SECTOR)) + return; + getsect(def->x, def->y, §); + if (lunchbox > ITEM_MAX - sect.sct_item[I_FOOD]) + lunchbox = ITEM_MAX - sect.sct_item[I_FOOD]; + sect.sct_item[I_FOOD] += lunchbox; + putsect(§); + } }