From: Markus Armbruster Date: Fri, 5 Mar 2004 13:14:28 +0000 (+0000) Subject: (att_move_in_off): Don't put more than ITEM_MAX food into the X-Git-Tag: v4.2.14~73 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=733aff63ed9b989198e52bf5c09868bbc319fec5 (att_move_in_off): Don't put more than ITEM_MAX food into the assaulted sector. Simplify some more. --- diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index b44128bdf..eb9d3b3de 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -2465,10 +2465,12 @@ att_move_in_off(int combat_mode, struct combat *off, struct sctstr sect; struct shpstr ship; int troops; - int n, lunchbox = 0; + int n, lunchbox; 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; @@ -2483,24 +2485,20 @@ att_move_in_off(int combat_mode, struct combat *off, 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; + sect.sct_item[I_FOOD] += lunchbox; 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; + putsect(§); + put_combat(def); }