Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2005:
[Freeciv-Dev] (PR#13481) T_UNKNOWN dereference in generic_city_refresh
Home

[Freeciv-Dev] (PR#13481) T_UNKNOWN dereference in generic_city_refresh

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13481) T_UNKNOWN dereference in generic_city_refresh
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 15 Jul 2005 20:51:00 -0700
Reply-to: bugs@xxxxxxxxxxx

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

In client CM we end up dereferencing T_UNKNOWN.  This _might_ be a bug
in 2.0 also; I'll take a look at that later.

-jason

Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.354
diff -p -u -r1.354 city.c
--- common/city.c       14 Jul 2005 19:25:45 -0000      1.354
+++ common/city.c       16 Jul 2005 03:48:56 -0000
@@ -576,13 +576,16 @@ static int base_get_output_tile(const st
   const struct terrain *pterrain = ptile->terrain;
   struct tile tile;
   int prod;
-  const bool auto_water = (pcity && is_city_center(city_x, city_y)
-                          && ptile->terrain == pterrain->irrigation_result
-                          && terrain_control.may_irrigate);
   const struct output_type *output = &output_types[otype];
 
   assert(otype >= 0 && otype < O_LAST);
 
+  if (ptile->terrain == T_UNKNOWN) {
+    /* Special case for the client.  The server doesn't allow unknown tiles
+     * to be worked but we don't necessarily know what player is involved. */
+    return 0;
+  }
+
   if (tile_has_special(ptile, S_SPECIAL_1)) {
     prod = pterrain->special[0].output[otype];
   } else if (tile_has_special(ptile, S_SPECIAL_2)) {
@@ -595,7 +598,9 @@ static int base_get_output_tile(const st
   tile.terrain = tile_get_terrain(ptile);
   tile.special = tile_get_special(ptile);
 
-  if (auto_water) {
+  if (pcity && is_city_center(city_x, city_y)
+      && ptile->terrain == pterrain->irrigation_result
+      && terrain_control.may_irrigate) {
     /* The center tile is auto-irrigated. */
     tile_set_special(&tile, S_IRRIGATION);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13481) T_UNKNOWN dereference in generic_city_refresh, Jason Short <=