]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/land.c
License upgrade to GPL version 3 or later
[empserver] / src / lib / update / land.c
index ee1c170fe0c9caaa767eb13834b9264c65166bfb..f457d62327321548e67348ae6a8fef838c480ca6 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
  *  ---
  *
  *  land.c: Do production for land units
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1986
  *     Thomas Ruschak, 1992
  *     Steve McClure, 1996
- *     Markus Armbruster, 2006-2008
+ *     Markus Armbruster, 2006-2009
  */
 
 #include <config.h>
@@ -59,9 +58,7 @@ prod_land(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 != (lp = getlandp(n)); n++) {
        if (lp->lnd_own == 0)
            continue;
@@ -77,16 +74,6 @@ prod_land(int etus, int natnum, struct bp *bp, int build)
        sp = getsectp(lp->lnd_x, lp->lnd_y);
        if (sp->sct_type == SCT_SANCT)
            continue;
-       if (lastx == 9999 || lasty == 9999) {
-           lastx = lp->lnd_x;
-           lasty = lp->lnd_y;
-       }
-       if (lastx != lp->lnd_x || lasty != lp->lnd_y) {
-           /* Reset the cache */
-           bp_disable_cachepath();
-           bp_clear_cachepath();
-           bp_enable_cachepath();
-       }
        np = getnatp(lp->lnd_own);
        start_money = np->nat_money;
        upd_land(lp, etus, np, bp, build);
@@ -96,8 +83,6 @@ prod_land(int etus, int natnum, struct bp *bp, int build)
        if (player->simulation)
            np->nat_money = start_money;
     }
-    bp_disable_cachepath();
-    bp_clear_cachepath();
 
     return k;
 }
@@ -139,6 +124,7 @@ upd_land(struct lndstr *lp, int etus,
                makelost(EF_LAND, lp->lnd_own, lp->lnd_uid,
                         lp->lnd_x, lp->lnd_y);
                lp->lnd_own = 0;
+               lp->lnd_ship = lp->lnd_land = -1;
                return;
            }
            wu(0, lp->lnd_own,
@@ -237,8 +223,7 @@ landrepair(struct lndstr *land, struct natstr *np, struct bp *bp, int etus)
        /* land is ok; no repairs needed */
        return;
     }
-    if ((sp->sct_own != land->lnd_own) &&
-       (getrel(getnatp(sp->sct_own), land->lnd_own) != ALLIED))
+    if (relations_with(sp->sct_own, land->lnd_own) != ALLIED)
        return;
 
     if (!player->simulation)
@@ -285,16 +270,5 @@ landrepair(struct lndstr *land, struct natstr *np, struct bp *bp, int etus)
 static int
 feed_land(struct lndstr *lp, int etus)
 {
-    int needed;
-
-    if (opt_NOFOOD)
-       return 0;
-
-    needed = (int)ceil(food_needed(lp->lnd_item, etus));
-
-    /* scrounge */
-    if (needed > lp->lnd_item[I_FOOD])
-       resupply_commod(lp, I_FOOD);
-
     return feed_people(lp->lnd_item, etus);
 }