assaulted sector. Simplify some more.
struct sctstr sect;
struct shpstr ship;
int troops;
struct sctstr sect;
struct shpstr ship;
int troops;
move_in_land(combat_mode, off, olist, def);
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;
for (n = 0; n <= off->last; ++n) {
if (off[n].type == EF_BAD || !off[n].troops)
continue;
continue;
}
getship(off[n].shp_uid, &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));
+ 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];
+
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);
}
}
- put_combat(def);
- if (!lunchbox)
- return;
- if (def->type != EF_SECTOR) {
- pr("Please tell the deity that you got the 'hungry mole' error\n");
- logerror("att_move_in_off: hungry mole");
- return;
- }
- getsect(def->x, def->y, §);
- sect.sct_item[I_FOOD] += lunchbox;