Complete.Org: Mailing Lists: Archives: freeciv-dev: August 1999:
Re: [Freeciv-Dev] pollution placement bug (PR#71)
Home

Re: [Freeciv-Dev] pollution placement bug (PR#71)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Freeciv-Dev] pollution placement bug (PR#71)
From: jjm@xxxxxxxxxxxx
Date: Wed, 4 Aug 1999 07:07:25 -0700 (PDT)

--=====================_9736010==_
Content-Type: text/plain; charset="us-ascii"

This patch is a replacement for my earlier effort.  It fixes the bugs that
David pointed out.

Now, pollution should show up in the right layer (above the city graphic,
but below unit or unhappiness graphics).  Also, pollution should be
restricted to the city radius.

jjm

--=====================_9736010==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; 
filename="pr71-pollution-placement-and-draw.diff"

diff -rNu -X /home/jjm/cvs/no.freeciv FreecivCVS/client/gui-gtk/mapview.c 
freeciv/client/gui-gtk/mapview.c
--- FreecivCVS/client/gui-gtk/mapview.c Sun Aug  1 10:57:41 1999
+++ freeciv/client/gui-gtk/mapview.c    Sun Aug  1 18:47:33 1999
@@ -930,6 +930,9 @@
                            pcity->size/10);
   pixmap_put_overlay_tile(pm, xtile, ytile, NUMBER_TILES+pcity->size%10);
 
+  if(map_get_special(pcity->x, pcity->y) & S_POLLUTION)
+    pixmap_put_overlay_tile(pm, xtile, ytile, POLLUTION_TILE);
+
   if(city_unhappy(pcity))
     pixmap_put_overlay_tile(pm, xtile, ytile, CITY_FLASH_TILE);
   
diff -rNu -X /home/jjm/cvs/no.freeciv FreecivCVS/client/gui-xaw/mapview.c 
freeciv/client/gui-xaw/mapview.c
--- FreecivCVS/client/gui-xaw/mapview.c Sun Aug  1 10:57:41 1999
+++ freeciv/client/gui-xaw/mapview.c    Sun Aug  1 18:41:45 1999
@@ -872,6 +872,9 @@
                            pcity->size/10);
   pixmap_put_overlay_tile(pm, xtile, ytile, NUMBER_TILES+pcity->size%10);
 
+  if(map_get_special(pcity->x, pcity->y) & S_POLLUTION)
+    pixmap_put_overlay_tile(pm, xtile, ytile, POLLUTION_TILE);
+
   if(city_unhappy(pcity))
     pixmap_put_overlay_tile(pm, xtile, ytile, CITY_FLASH_TILE);
   
diff -rNu -X /home/jjm/cvs/no.freeciv FreecivCVS/server/cityturn.c 
freeciv/server/cityturn.c
--- FreecivCVS/server/cityturn.c        Sat Jul 31 11:37:33 1999
+++ freeciv/server/cityturn.c   Sun Aug  1 18:31:41 1999
@@ -1179,20 +1179,24 @@
   int k=100;
   if (pcity->pollution && myrand(100)<=pcity->pollution) {
     while (k) {
-      x=pcity->x+myrand(5)-2;
-      y=pcity->y+myrand(5)-2;
-      x=map_adjust_x(x); y=map_adjust_y(y);
-      if ( (x!=pcity->x || y!=pcity->x) && 
-          (map_get_terrain(x,y)!=T_OCEAN && map_get_terrain(x,y)<=T_TUNDRA) &&
-          (!(map_get_special(x,y)&S_POLLUTION)) ) { 
-       map_set_special(x,y, S_POLLUTION);
-       send_tile_info(0, x, y, TILE_KNOWN);
-       notify_player_ex(city_owner(pcity), pcity->x, pcity->y, E_POLLUTION,
-                        "Game: Pollution near %s", pcity->name);
-       return;
+      /* place pollution somewhere in city radius */
+      x=myrand(5)-2;
+      y=myrand(5)-2;
+      if ( !( (x==-2 && y==-2) || (x==-2 && y==2) ||
+             (x==2 && y==-2) || (x==2 && y==2) ) ) {
+       x=map_adjust_x(pcity->x+x); y=map_adjust_y(pcity->y+y);
+       if ( (map_get_terrain(x,y)!=T_OCEAN && map_get_terrain(x,y)<=T_TUNDRA) 
&&
+            (!(map_get_special(x,y)&S_POLLUTION)) ) { 
+         map_set_special(x,y, S_POLLUTION);
+         send_tile_info(0, x, y, TILE_KNOWN);
+         notify_player_ex(city_owner(pcity), pcity->x, pcity->y, E_POLLUTION,
+                          "Game: Pollution near %s", pcity->name);
+         return;
+       }
       }
       k--;
     }
+    freelog(LOG_DEBUG, "pollution not placed: city: %s", pcity->name);
   }
 }
 

--=====================_9736010==_--



[Prev in Thread] Current Thread [Next in Thread]
  • Re: [Freeciv-Dev] pollution placement bug (PR#71), jjm <=