(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.
This commit is contained in:
Markus Armbruster 2005-06-18 16:52:17 +00:00
parent e6a7d4a694
commit 78e880a608

View file

@ -2461,13 +2461,11 @@ att_move_in_off(int combat_mode, struct combat *off,
{ {
struct sctstr sect; struct sctstr sect;
struct shpstr ship; struct shpstr ship;
int troops; int troops, n;
int n, lunchbox; int lunchbox = 0;
move_in_land(combat_mode, off, olist, def); move_in_land(combat_mode, off, olist, def);
getsect(def->x, def->y, &sect);
for (n = 0; n <= off->last; ++n) { for (n = 0; n <= off->last; ++n) {
if (off[n].type == EF_BAD || !off[n].troops) if (off[n].type == EF_BAD || !off[n].troops)
continue; continue;
@ -2477,25 +2475,29 @@ att_move_in_off(int combat_mode, struct combat *off,
def->mil += troops; def->mil += troops;
put_combat(off + n); put_combat(off + n);
if (combat_mode == A_ASSAULT) { if (combat_mode == A_ASSAULT) {
if (off[n].type != EF_SHIP || def->type != EF_SECTOR) { if (CANT_HAPPEN(off[n].type != EF_SHIP))
logerror("att_move_in_off: strange assault");
continue; continue;
}
getship(off[n].shp_uid, &ship); getship(off[n].shp_uid, &ship);
lunchbox = (int)((troops + 1) * ship.shp_item[I_FOOD] lunchbox += (int)((troops + 1) * ship.shp_item[I_FOOD]
/ (ship.shp_item[I_MILIT] + troops / (ship.shp_item[I_MILIT] + troops
+ ship.shp_item[I_CIVIL] + 0.5)); + ship.shp_item[I_CIVIL] + 0.5));
if (lunchbox > ITEM_MAX - sect.sct_item[I_FOOD])
lunchbox = ITEM_MAX - sect.sct_item[I_FOOD];
ship.shp_item[I_FOOD] -= lunchbox; ship.shp_item[I_FOOD] -= lunchbox;
sect.sct_item[I_FOOD] += lunchbox;
putship(ship.shp_uid, &ship); putship(ship.shp_uid, &ship);
} }
} }
putsect(&sect);
put_combat(def); put_combat(def);
if (combat_mode == A_ASSAULT) {
if (CANT_HAPPEN(def->type != EF_SECTOR))
return;
getsect(def->x, def->y, &sect);
if (lunchbox > ITEM_MAX - sect.sct_item[I_FOOD])
lunchbox = ITEM_MAX - sect.sct_item[I_FOOD];
sect.sct_item[I_FOOD] += lunchbox;
putsect(&sect);
}
} }