]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/ship.c
Eliminate a few pointless relations variables
[empserver] / src / lib / update / ship.c
index 78c6dc36815050f756f64c469c425844cf9e1b0e..e0db619439064c93b332124cffdd9f205b4b1285 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *  ---
  *
  *  ship.c: Do production for ships
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1986
  *     Steve McClure, 1996
  *     Ron Koenderink, 2004
- *     Markus Armbruster, 2006-2007
+ *     Markus Armbruster, 2006-2009
  */
 
 #include <config.h>
@@ -59,9 +59,7 @@ prod_ship(int etus, int natnum, struct bp *bp, int build)
     struct natstr *np;
     int n, k = 0;
     int start_money;
-    int lastx = 9999, lasty = 9999;
 
-    bp_enable_cachepath();
     for (n = 0; NULL != (sp = getshipp(n)); n++) {
        if (sp->shp_own == 0)
            continue;
@@ -75,16 +73,6 @@ prod_ship(int etus, int natnum, struct bp *bp, int build)
        }
 
        np = getnatp(sp->shp_own);
-       if (lastx == 9999 || lasty == 9999) {
-           lastx = sp->shp_x;
-           lasty = sp->shp_y;
-       }
-       if (lastx != sp->shp_x || lasty != sp->shp_y) {
-           /* Reset the cache */
-           bp_disable_cachepath();
-           bp_clear_cachepath();
-           bp_enable_cachepath();
-       }
        start_money = np->nat_money;
        upd_ship(sp, etus, np, bp, build);
        if (build && !player->simulation)       /* make sure to only autonav once */
@@ -95,8 +83,6 @@ prod_ship(int etus, int natnum, struct bp *bp, int build)
        if (player->simulation)
            np->nat_money = start_money;
     }
-    bp_disable_cachepath();
-    bp_clear_cachepath();
 
     if (opt_SAIL) {
        if (build && !player->simulation)       /* make sure to only sail once */
@@ -161,7 +147,7 @@ upd_ship(struct shpstr *sp, int etus,
                product = &pchr[dchr[SCT_OIL].d_prd];
                oil_gained = roundavg(total_work(100, etus,
                                                 sp->shp_item[I_CIVIL],
-                                                sp->shp_item[I_MILIT],
+                                                sp->shp_item[I_MILIT],
                                                 sp->shp_item[I_UW],
                                                 ITEM_MAX)
                                      * sp->shp_effic / 100.0
@@ -277,21 +263,17 @@ shiprepair(struct shpstr *ship, struct natstr *np, struct bp *bp, int etus)
     int w_p_eff;
     int mult;
     int mvec[I_MAX + 1];
-    int rel;
 
     mp = &mchr[(int)ship->shp_type];
     sp = getsectp(ship->shp_x, ship->shp_y);
 
     if ((sp->sct_own != ship->shp_own) && (sp->sct_own != 0)) {
-       rel = getrel(getnatp(sp->sct_own), ship->shp_own);
-
-       if (rel < FRIENDLY)
+       if (getrel(getnatp(sp->sct_own), ship->shp_own) < FRIENDLY)
            return;
     }
 
-    wf = 0;
     /* only military can work on a military boat */
-    if (ship->shp_glim > 0)
+    if (mp->m_glim != 0)
        wf = etus * ship->shp_item[I_MILIT] / 2;
     else
        wf = etus * (ship->shp_item[I_CIVIL] / 2 + ship->shp_item[I_MILIT] / 5);
@@ -382,16 +364,10 @@ feed_ship(struct shpstr *sp, int etus)
     needed = (int)ceil(food_needed(sp->shp_item, etus));
 
     /* scrounge */
-    if (needed > sp->shp_item[I_FOOD])
-       sp->shp_item[I_FOOD] += supply_commod(sp->shp_own,
-                                       sp->shp_x, sp->shp_y, I_FOOD,
-                                       needed - sp->shp_item[I_FOOD]);
     if (needed > sp->shp_item[I_FOOD]) {
        /* take from embarked land units, but don't starve them */
-       snxtitem_all(&ni, EF_LAND);
+       snxtitem_cargo(&ni, EF_LAND, EF_SHIP, sp->shp_uid);
        while ((lp = nxtitemp(&ni)) && needed > sp->shp_item[I_FOOD]) {
-           if (lp->lnd_ship != sp->shp_uid)
-               continue;
            give = lp->lnd_item[I_FOOD] - food_needed(lp->lnd_item, etus);
            if (give < 1.0)
                continue;