Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#13634) use build_cost accessors
Home

[Freeciv-Dev] (PR#13634) use build_cost accessors

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13634) use build_cost accessors
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 8 Aug 2005 15:40:12 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch changes ai and helptext code to use accessors for the 
build_cost values instead of accessing them directly.  With a 
buildbox/shieldbox multiplier this is necessary since the "base" values 
may not be accurate.

-jason

? build_cost
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.235
diff -p -u -r1.235 aicity.c
--- ai/aicity.c 4 Aug 2005 16:26:11 -0000       1.235
+++ ai/aicity.c 8 Aug 2005 22:37:54 -0000
@@ -625,7 +625,8 @@ static void adjust_building_want_by_effe
   }
 
   /* Adjust by building cost */
-  v -= pimpr->build_cost / (pcity->surplus[O_SHIELD] * 10 + 1);
+  v -= (impr_build_shield_cost(pimpr->index)
+       / (pcity->surplus[O_SHIELD] * 10 + 1));
 
   /* Would it mean losing shields? */
   if ((pcity->production.is_unit 
Index: ai/aihunt.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihunt.c,v
retrieving revision 1.20
diff -p -u -r1.20 aihunt.c
--- ai/aihunt.c 22 Jul 2005 16:18:04 -0000      1.20
+++ ai/aihunt.c 8 Aug 2005 22:37:54 -0000
@@ -104,7 +104,8 @@ static struct unit_type *ai_hunter_guess
     }
 
     desire = amortize(desire,
-                     ut->build_cost / MAX(pcity->surplus[O_SHIELD], 1));
+                     (unit_build_shield_cost(ut)
+                      / MAX(pcity->surplus[O_SHIELD], 1)));
 
     if (desire > best) {
         best = desire;
@@ -162,7 +163,8 @@ static void ai_hunter_missile_want(struc
     }
 
     desire = amortize(desire,
-                     ut->build_cost / MAX(pcity->surplus[O_SHIELD], 1));
+                     (unit_build_shield_cost(ut)
+                      / MAX(pcity->surplus[O_SHIELD], 1)));
 
     if (desire > best) {
         best = desire;
@@ -345,7 +347,7 @@ static void ai_hunter_juiciness(struct p
     if (unit_flag(sucker, F_DIPLOMAT)) {
       *stackthreat += 500; /* extra threatening */
     }
-    *stackcost += unit_type(sucker)->build_cost;
+    *stackcost += unit_build_shield_cost(unit_type(sucker));
   } unit_list_iterate_end;
 
   *stackthreat *= 9; /* WAG - reduced by distance later */
@@ -441,9 +443,10 @@ int ai_hunter_manage(struct player *ppla
        * if any. */
       ai_hunter_juiciness(pplayer, punit, target, &stackthreat, &stackcost);
       stackcost *= unit_win_chance(punit, get_defender(punit, target->tile));
-      if (stackcost < unit_type(punit)->build_cost) {
+      if (stackcost < unit_build_shield_cost(unit_type(punit))) {
         UNIT_LOG(LOGLEVEL_HUNT, punit, "%d is too expensive (it %d vs us %d)", 
-                 target->id, stackcost, unit_type(punit)->build_cost);
+                 target->id, stackcost,
+                unit_build_shield_cost(unit_type(punit)));
         continue; /* Too expensive */
       }
       stackthreat /= pos.total_MC + 1;
@@ -454,7 +457,7 @@ int ai_hunter_manage(struct player *ppla
                  target->id, original_target->id);
         continue; /* The threat we found originally was worse than this! */
       }
-      if (stackthreat < unit_type(punit)->build_cost) {
+      if (stackthreat < unit_build_shield_cost(unit_type(punit))) {
         UNIT_LOG(LOGLEVEL_HUNT, punit, "%d is not worth it", target->id);
         continue; /* Not worth it */
       }
Index: ai/aisettler.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aisettler.c,v
retrieving revision 1.27
diff -p -u -r1.27 aisettler.c
--- ai/aisettler.c      23 Jul 2005 18:02:43 -0000      1.27
+++ ai/aisettler.c      8 Aug 2005 22:37:54 -0000
@@ -510,7 +510,7 @@ static bool settler_map_iterate(struct p
      * weeds out very small wants. ie we create a threshold here. */
     /* We also penalise here for using a boat (either virtual or real)
      * it's crude but what isn't? */
-    result.result -= unit_type(punit)->build_cost + boat_cost;
+    result.result -= unit_build_shield_cost(unit_type(punit)) + boat_cost;
 
     /* Find best spot */
     if (result.result > best->result) {
@@ -614,7 +614,7 @@ void find_best_city_placement(struct uni
      * Building a new boat is like a war against a weaker enemy -- 
      * good for the economy. (c) Bush family */
     if (settler_map_iterate(&parameter, punit, best, pplayer, 
-                           unit_type(ferry)->build_cost)) {
+                           unit_build_shield_cost(unit_type(ferry)))) {
       best->overseas = TRUE;
       best->virt_boat = (ferry->id == 0);
     }
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.122
diff -p -u -r1.122 helpdata.c
--- client/helpdata.c   1 Aug 2005 22:38:23 -0000       1.122
+++ client/helpdata.c   8 Aug 2005 22:37:55 -0000
@@ -799,7 +799,7 @@ void helptext_unit(char *buf, struct uni
   if (unit_type_flag(utype, F_HELP_WONDER)) {
     sprintf(buf + strlen(buf),
            _("* Can help build wonders (adds %d production).\n"),
-           utype->build_cost);
+           unit_build_shield_cost(utype));
   }
   if (unit_type_flag(utype, F_UNDISBANDABLE)) {
     sprintf(buf + strlen(buf), _("* May not be disbanded.\n"));

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13634) use build_cost accessors, Jason Short <=