]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/attsub.c
Update copyright notice.
[empserver] / src / lib / subs / attsub.c
index b44128bdfe5f7f796069823dd4d039f6198ec8f4..1bcb66907c21a059b72c44ae91c189070b05cb07 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -868,8 +868,7 @@ get_mob_support(int combat_mode, struct combat *off, struct combat *def)
     case A_BOARD:
        if (off->type == EF_SECTOR && off->mob <= 0)
            return 0;
-       mob_support = vl_find(V_MILIT, def->shp_mcp->m_vtype,
-                             def->shp_mcp->m_vamt, def->shp_mcp->m_nv);
+       mob_support = def->shp_mcp->m_item[I_MILIT];
        if (mob_support < off->troops)
            pr("The size of the ship you are trying to board limits your party to %d mil,\n", mob_support);
        else
@@ -880,8 +879,7 @@ get_mob_support(int combat_mode, struct combat *off, struct combat *def)
            return 0;
        if (def->lnd_lcp->l_flags & L_SPY)
            return 1;
-       mob_support = vl_find(V_MILIT, def->lnd_lcp->l_vtype,
-                             def->lnd_lcp->l_vamt, def->lnd_lcp->l_nv);
+       mob_support = def->lnd_lcp->l_item[I_MILIT];
        if (mob_support < off->troops)
            pr("The size of the unit you are trying to board limits your party to %d mil,\n", mob_support);
        else
@@ -2465,10 +2463,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, &sect);
+
     for (n = 0; n <= off->last; ++n) {
        if (off[n].type == EF_BAD || !off[n].troops)
            continue;
@@ -2483,24 +2483,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);
-    sect.sct_item[I_FOOD] += lunchbox;
+
     putsect(&sect);
+    put_combat(def);
 }
 
 
@@ -2558,7 +2554,7 @@ ask_move_in_off(struct combat *off, struct combat *def)
     }
 
     if (dam) {
-       left = commdamage(num_mil, dam, V_MILIT);
+       left = commdamage(num_mil, dam, I_MILIT);
        if (left < num_mil) {
            if (left) {
                pr("%d of the mil you were moving were destroyed!\nOnly %d mil made it to %s\n", num_mil - left, left, xyas(def->x, def->y, player->cnum));