]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/ship.c
Update copyright notice
[empserver] / src / lib / update / ship.c
index 85889adcf643154284cfdf0d22f2f10065ad1869..891a8c7edd533f9ce0cfe3a95c107cfa6b819798 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-2009, 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-2008
  */
 
 #include <config.h>
@@ -156,7 +156,7 @@ upd_ship(struct shpstr *sp, int etus,
            sectp = getsectp(sp->shp_x, sp->shp_y);
 
            /* produce oil */
-           if (np->nat_money > 0
+           if (np->nat_money >= 0
                && (mp->m_flags & M_OIL) && sectp->sct_type == SCT_WATER) {
                product = &pchr[dchr[SCT_OIL].d_prd];
                oil_gained = roundavg(total_work(100, etus,
@@ -182,7 +182,7 @@ upd_ship(struct shpstr *sp, int etus,
                sp->shp_item[I_OIL] += oil_gained;
            }
            /* produce fish */
-           if (np->nat_money > 0
+           if (np->nat_money >= 0
                && (mp->m_flags & M_FOOD) && sectp->sct_type == SCT_WATER) {
                sp->shp_item[I_FOOD]
                    += roundavg(total_work(100, etus,
@@ -291,7 +291,7 @@ shiprepair(struct shpstr *ship, struct natstr *np, struct bp *bp, int etus)
 
     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);
@@ -388,10 +388,8 @@ feed_ship(struct shpstr *sp, int etus)
                                        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;