]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/sect.c
Update copyright notice
[empserver] / src / lib / update / sect.c
index 91996a8013924dfa9dae864e6fab6a82aeffeabf..acaf5fac71452f6619c103962f69315eae8559d2 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-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -79,6 +79,7 @@ upd_buildeff(struct natstr *np, struct sctstr *sp, int *workp,
        *cost += work_cost;
        if (!n && IS_BIG_CITY(old_type) &&
            !IS_BIG_CITY(*desig)) {
+           // FIXME use trunc_people() and total_work()
            int maxpop = max_population(np->nat_level[NAT_RLEV], *desig, n);
            if (vec[I_CIVIL] > maxpop)
                vec[I_CIVIL] = maxpop;
@@ -137,9 +138,9 @@ enlist(short *vec, int etu, int *cost)
 
     /* Need to check treaties here */
     enlisted = 0;
-    maxmil = (vec[I_CIVIL] / 2) - vec[I_MILIT];
+    maxmil = vec[I_CIVIL] / 2 - vec[I_MILIT];
     if (maxmil > 0) {
-       enlisted = (etu * (10 + vec[I_MILIT]) * 0.05);
+       enlisted = etu * (10 + vec[I_MILIT]) * 0.05;
        if (enlisted > maxmil)
            enlisted = maxmil;
        vec[I_CIVIL] -= enlisted;
@@ -264,7 +265,7 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2])
     short buf[I_MAX + 1];
     short *vec;
     int work, cost, ecost, pcost, sctwork;
-    int n, desig, maxpop, neweff, amount;
+    int n, desig, neweff, amount;
 
     for (n = 0; NULL != (sp = getsectid(n)); n++) {
        if (sp->sct_type == SCT_WATER)
@@ -311,7 +312,8 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2])
           here */
        bp_enable_cachepath();
 
-       sctwork = do_feed(sp, np, vec, &work, bp, etu);
+       sctwork = do_feed(sp, np, vec, &work, etu);
+       bp_put_items(bp, sp, vec);
 
        bp_disable_cachepath();
        bp_clear_cachepath();
@@ -326,11 +328,10 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2])
        desig = sp->sct_type;
 
        if ((sp->sct_effic < 100 || sp->sct_type != sp->sct_newtype) &&
-           np->nat_money > 0) {
+           np->nat_money >= 0) {
            neweff = upd_buildeff(np, sp, &work, vec, etu, &desig, sctwork,
                                  &cost);
-           bp_put_item(bp, sp, I_LCM, vec[I_LCM]);
-           bp_put_item(bp, sp, I_HCM, vec[I_HCM]);
+           bp_put_items(bp, sp, vec);
            p_sect[SCT_EFFIC][0]++;
            p_sect[SCT_EFFIC][1] += cost;
            if (!player->simulation) {
@@ -346,6 +347,7 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2])
            p_sect[desig][1] += ecost;
            if (!player->simulation)
                np->nat_money -= ecost;
+           bp_put_items(bp, sp, vec);
        }
 
        /*
@@ -353,20 +355,16 @@ produce_sect(int natnum, int etu, struct bp *bp, long p_sect[][2])
         */
 
        if (neweff >= 60) {
-           if (np->nat_money > 0 && dchr[desig].d_prd >= 0)
+           if (np->nat_money >= 0 && dchr[desig].d_prd >= 0)
                work -= produce(np, sp, vec, work, desig, neweff,
                                &pcost, &amount);
+           bp_put_items(bp, sp, vec);
        }
 
        bp_put_avail(bp, sp, work);
        p_sect[desig][0] += amount;
        p_sect[desig][1] += pcost;
        if (!player->simulation) {
-           maxpop = max_pop(np->nat_level[NAT_RLEV], sp);
-           if (vec[I_CIVIL] > maxpop)
-               vec[I_CIVIL] = maxpop;
-           if (vec[I_UW] > maxpop)
-               vec[I_UW] = maxpop;
            sp->sct_avail = work;
            np->nat_money -= pcost;
        }