]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/land.c
Update copyright notice
[empserver] / src / lib / update / land.c
index 6be2c14264ab364bc90694e1ab91bbca4dc42338..96b309770fe1491d689ad9b57cc8f9684b7d9f32 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2017, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -35,9 +35,7 @@
 
 #include <config.h>
 
-#include <math.h>
 #include "chance.h"
-#include "file.h"
 #include "land.h"
 #include "lost.h"
 #include "nat.h"
@@ -52,19 +50,16 @@ static void upd_land(struct lndstr *, int, struct bp *, int);
 static void plague_land(struct lndstr *, int);
 static void landrepair(struct lndstr *, struct natstr *, struct bp *,
                       int, struct budget *);
-static int feed_land(struct lndstr *, int);
 
-void prep_lands(int etus, natid natnum)
+void prep_lands(int etus, struct bp *bp)
 {
-    int mil, i;
+    int mil, i, n;
     double mil_pay;
     struct lndstr *lp;
 
     for (i = 0; (lp = getlandp(i)); i++) {
        if (lp->lnd_own == 0)
            continue;
-       if (lp->lnd_own != natnum)
-           continue;
        if (CANT_HAPPEN(lp->lnd_effic < LAND_MINEFF)) {
            makelost(EF_LAND, lp->lnd_own, lp->lnd_uid,
                     lp->lnd_x, lp->lnd_y);
@@ -72,29 +67,35 @@ void prep_lands(int etus, natid natnum)
            continue;
        }
 
+       bp_consider_unit(bp, (struct empobj *)lp);
        mil = lp->lnd_item[I_MILIT];
        mil_pay = mil * etus * money_mil;
-       nat_budget[natnum].mil.count += mil;
-       nat_budget[natnum].mil.money += mil_pay;
-       nat_budget[natnum].money += mil_pay;
+       nat_budget[lp->lnd_own].mil.count += mil;
+       nat_budget[lp->lnd_own].mil.money += mil_pay;
+       nat_budget[lp->lnd_own].money += mil_pay;
+
+       if (!player->simulation) {
+           if ((n = feed_people(lp->lnd_item, etus)) > 0) {
+               wu(0, lp->lnd_own, "%d starved in %s\n", n, prland(lp));
+               if (n > 10)
+                   nreport(lp->lnd_own, N_DIE_FAMINE, 0, 1);
+           }
+           plague_land(lp, etus);
+       }
     }
 }
 
 void
-prod_land(int etus, int natnum, struct bp *bp, int build)
+prod_land(int etus, struct bp *bp, int build)
                /* build = 1, maintain = 0 */
 {
     struct lndstr *lp;
-    struct sctstr *sp;
     int i;
 
     for (i = 0; (lp = getlandp(i)); i++) {
        if (lp->lnd_own == 0)
            continue;
-       if (lp->lnd_own != natnum)
-           continue;
-       sp = getsectp(lp->lnd_x, lp->lnd_y);
-       if (sp->sct_type == SCT_SANCT)
+       if (bp_skip_unit(bp, (struct empobj *)lp))
            continue;
        upd_land(lp, etus, bp, build);
     }
@@ -108,7 +109,7 @@ upd_land(struct lndstr *lp, int etus, struct bp *bp, int build)
     struct lchrstr *lcp = &lchr[lp->lnd_type];
     struct natstr *np = getnatp(lp->lnd_own);
     int min = morale_base - (int)np->nat_level[NAT_HLEV];
-    int n, mult, eff_lost;
+    int mult, eff_lost;
     double cost;
 
     if (!player->simulation)
@@ -142,16 +143,6 @@ upd_land(struct lndstr *lp, int etus, struct bp *bp, int build)
            budget->bm[BUDG_LND_MAINT].money -= cost;
            budget->money -= cost;
        }
-
-       if (!player->simulation) {
-           /* feed */
-           if ((n = feed_land(lp, etus)) > 0) {
-               wu(0, lp->lnd_own, "%d starved in %s\n", n, prland(lp));
-               if (n > 10)
-                   nreport(lp->lnd_own, N_DIE_FAMINE, 0, 1);
-           }
-           plague_land(lp, etus);
-       }                       /* end !player->simulation */
     }
 }
 
@@ -235,12 +226,3 @@ landrepair(struct lndstr *land, struct natstr *np, struct bp *bp, int etus,
     if (!player->simulation)
        land->lnd_effic += (signed char)build;
 }
-
-/*
- * returns the number who starved, if any.
- */
-static int
-feed_land(struct lndstr *lp, int etus)
-{
-    return feed_people(lp->lnd_item, etus);
-}