Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#13043) trade calculation wrong?
Home

[Freeciv-Dev] (PR#13043) trade calculation wrong?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: brett.albertson@xxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#13043) trade calculation wrong?
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 17 May 2005 18:03:42 -0700
Reply-to: bugs@xxxxxxxxxxx

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

> [bretta - Fri May 13 12:34:48 2005]:
> 
> > [bretta - Thu May 12 20:51:27 2005]:
> > Once I typed start and the game/GUI initialized, it turned to 
> > 100% TRUE.  For thousands of lines, there isn't a single FALSE.  So,
> > something is being passed in or initiallized such that is_req_active
> > always returns TRUE.  Any ideas?
> 
> The thing always returning TRUE is when it checks REQ_BUILDING in
> is_req_active.  

I don't get that error.  But I do get a different error.

When loading the savegame (./ser -f ...) the players government is
believed to be republic.  Thus there is no penalty, and the trade is
evaluated much higher than it would normally be.  After the game starts,
the government is (correctly?) evaluated as despotism and the correct
penalty and corruption apply.

I suspect this is another pregame-rulesets issue.  It might be unrelated
to the bug you're seeing.

-jason

Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.347
diff -u -r1.347 city.c
--- common/city.c       14 May 2005 14:45:23 -0000      1.347
+++ common/city.c       18 May 2005 00:27:47 -0000
@@ -655,6 +655,9 @@
     prod += (prod * get_city_tile_output_bonus(pcity, ptile, output,
                                               EFT_OUTPUT_PER_TILE)) / 100;
 
+    if (dologme)
+      freelog(LOG_NORMAL, "before penalty is %d (gov %s)", before_penalty,
+             g->name);
     if (before_penalty > 0 && prod > before_penalty) {
       prod--;
     }
@@ -1591,8 +1594,19 @@
    * to 0 when the city was created. */
   city_map_checked_iterate(pcity->tile, x, y, ptile) {
     output_type_iterate(o) {
+
+
+      if (dologme) {
+       freelog(LOG_NORMAL, "Calculating %s on %d,%d:",
+               get_output_name(o), x, y);
+      }
       pcity->tile_output[x][y][o]
        = base_city_get_output_tile(x, y, pcity, is_celebrating, o);
+
+      if (dologme) {
+       freelog(LOG_NORMAL, "%d,%d : %s : %d", x, y,
+               get_output_name(o), pcity->tile_output[x][y][o]);
+      }
     } output_type_iterate_end;
   } city_map_checked_iterate_end;
 }
@@ -2082,6 +2096,8 @@
   } unit_list_iterate_end;
 }
 
+bool dologme = FALSE;
+
 /**************************************************************************
   Refreshes the internal cached data in the city structure.
 
@@ -2108,6 +2124,11 @@
   struct player *pplayer = city_owner(pcity);
   int prev_tile_trade = pcity->citizen_base[O_TRADE];
 
+  if (strcasecmp(pcity->name, "Davao") == 0) {
+    dologme = TRUE;
+    freelog(LOG_NORMAL, "Davao refresh %s", full_refresh ? "full" : "small");
+  }
+
   if (full_refresh) {
     set_city_bonuses(pcity);   /* Calculate the bonus[] array values. */
     set_city_tile_output(pcity); /* Calculate the tile_output[] values. */
@@ -2152,6 +2173,13 @@
       }
     }
   }
+
+  if (dologme) {
+    freelog(LOG_NORMAL, "  Trade: %d (-%d)",
+           pcity->surplus[O_TRADE], pcity->waste[O_TRADE]);
+  }
+
+  dologme = FALSE;
 }
 
 /**************************************************************************
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.214
diff -u -r1.214 city.h
--- common/city.h       11 May 2005 14:11:20 -0000      1.214
+++ common/city.h       18 May 2005 00:27:48 -0000
@@ -575,4 +575,6 @@
   return CITY_MAP_RADIUS == city_x && CITY_MAP_RADIUS == city_y;
 }
 
+extern bool dologme;
+
 #endif  /* FC__CITY_H */
Index: common/requirements.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/requirements.c,v
retrieving revision 1.26
diff -u -r1.26 requirements.c
--- common/requirements.c       14 May 2005 15:34:41 -0000      1.26
+++ common/requirements.c       18 May 2005 00:27:48 -0000
@@ -756,6 +756,7 @@
                   const struct requirement *req)
 {
   bool eval = FALSE;
+  char buf[1024];
 
   /* Note the target may actually not exist.  In particular, effects that
    * have a REQ_SPECIAL or REQ_TERRAIN may often be passed to this function
@@ -824,6 +825,12 @@
     return FALSE;
   }
 
+  if (dologme && FALSE) {
+    freelog(LOG_NORMAL, "Req on %s evaluates to %s",
+           get_req_source_text(&req->source, buf, sizeof(buf)),
+           eval ? "true" : "false");
+  }
+
   if (req->negated) {
     return !eval;
   } else {

[Prev in Thread] Current Thread [Next in Thread]