]> git.pond.sub.org Git - empserver/commitdiff
Don't produce food without work
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 1 Apr 2008 18:17:52 +0000 (20:17 +0200)
committerMarkus Armbruster <armbru@pike.pond.sub.org>
Wed, 7 May 2008 08:33:41 +0000 (10:33 +0200)
We don't want to starve tiny populations, because that would require
players to move trivial amounts of food after explore and such.
growfood() used to simply grow at least 1f when a sector was about to
starve.  That food is almost never eaten by a tiny population, so we
effectively got some production without work.  Fix by taking away that
free food after people ate, in do_feed().

src/lib/update/human.c

index 9206edf11c390c224978baa1fd54aad60f588cd6..d36b9e158fe17a33a358c26cb594454788fbd758 100644 (file)
@@ -61,6 +61,7 @@ do_feed(struct sctstr *sp, struct natstr *np, short *vec,
     int starved, sctwork;
     int needed;
     int maxpop;
+    int manna;
 
     /* grow people & stuff */
     sctwork = sp->sct_work;
@@ -72,12 +73,16 @@ do_feed(struct sctstr *sp, struct natstr *np, short *vec,
                                     maxpop));
 
     if (sp->sct_type != SCT_SANCT) {
+       manna = 0;
        if (opt_NOFOOD == 0) {
            needed = (int)ceil(food_needed(vec, etu));
            if (vec[I_FOOD] < needed) {
                /* need to grow "emergency rations" */
                work_avail -= 2 * growfood(sp, vec, work_avail / 2, etu);
                /* It's twice as hard to grow those than norm */
+               if (vec[I_FOOD] == 0)
+                   /* Conjure up 1f to make life easier for the player */
+                   manna = vec[I_FOOD] = 1;
            }
            if (vec[I_FOOD] < needed && sp->sct_own == sp->sct_oldown) {
                /* steal food from warehouses, headquarters,
@@ -121,6 +126,9 @@ do_feed(struct sctstr *sp, struct natstr *np, short *vec,
                             sp->sct_x, sp->sct_y, oldche, sp->sct_che);
            }
        }
+       if (manna)
+           /* Take away food we conjured up */
+           vec[I_FOOD] = 0;
     } else
        sctwork = sp->sct_work = 100;
     /* Here is where we truncate extra people, always */
@@ -152,13 +160,7 @@ growfood(struct sctstr *sp, short *vec, int work, int etu)
     food = MIN(food_workers, food_fertil);
     if (food > ITEM_MAX - vec[I_FOOD])
        food = ITEM_MAX - vec[I_FOOD];
-    /*
-     * Be nice; grow minimum one food unit.
-     * This makes life simpler for the player.
-     */
     vec[I_FOOD] += food;
-    if (vec[I_FOOD] == 0)
-       vec[I_FOOD] = 1;
     work_used = food / fcrate;
     return work_used;
 }