Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] (PR#13319) Patch: Less idle workers
Home

[Freeciv-Dev] (PR#13319) Patch: Less idle workers

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13319) Patch: Less idle workers
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Thu, 23 Jun 2005 11:31:45 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13319 >


  Sometimes existing workers do nothing because their food consumption 
is subtracted from improvement want. This is wrong, of course, since 
they consume food even when they stand idle.
  With attached patch food consumption affects only want for new 
workers, no improvement want for existing workers.


  - ML


diff -Nurd -X.diff_ignore freeciv/server/settlers.c freeciv/server/settlers.c
--- freeciv/server/settlers.c   2005-06-23 19:09:39.078125000 +0300
+++ freeciv/server/settlers.c   2005-06-23 21:19:44.437500000 +0300
@@ -836,8 +836,6 @@
   int best_oldv = 9999;                /* oldv of best target so far; compared 
if
                                   newv==best_newv; not initialized to zero,
                                   so that newv=0 activities are not chosen */
-  int food_upkeep        = unit_food_upkeep(punit);
-  int food_cost          = unit_foodbox_cost(punit);
   bool can_rr = player_knows_techs_with_flag(pplayer, TF_RAILROAD);
 
   int best_newv = 0;
@@ -958,8 +956,6 @@
 
   best_newv /= WORKER_FACTOR;
 
-  best_newv = (best_newv
-              - food_upkeep * FOOD_WEIGHTING) * 100 / (40 + food_cost);
   best_newv = MAX(best_newv, 0); /* sanity */
 
   if (best_newv > 0) {
@@ -1368,6 +1364,8 @@
   want = evaluate_improvements(virtualunit, &best_act,
                               &best_tile, &completion_time,
                               NULL);
+  want = (want - unit_food_upkeep(virtualunit) * FOOD_WEIGHTING) * 100
+         / (40 + unit_foodbox_cost(virtualunit));
   free(virtualunit);
 
   /* Massage our desire based on available statistics to prevent
@@ -1375,7 +1373,8 @@
    * the ruleset */
   want /= MAX(1, ai->stats.workers[ptile->continent]
                  / (ai->stats.cities[ptile->continent] + 1));
-  want -= MIN(ai->stats.workers[ptile->continent], want);
+  want -= ai->stats.workers[ptile->continent];
+  want = MAX(want, 0);
 
   CITY_LOG(LOG_DEBUG, pcity, "wants %s with want %d to do %s at (%d,%d), "
            "we have %d workers and %d cities on the continent",

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13319) Patch: Less idle workers, Marko Lindqvist <=