Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2000:
[Freeciv-Dev] Very small patch to start the coordinate generalization
Home

[Freeciv-Dev] Very small patch to start the coordinate generalization

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Very small patch to start the coordinate generalization
From: Erik Sigra <freeciv@xxxxxxx>
Date: Fri, 22 Sep 2000 10:45:35 +0200

Hi,
This 955 byte patch starts the proces of coordinate generalization. It
should be completely harmless, not changing anything visible. Since it
is so small, it should be easy to audit. It is an important step to
build further on.
diff -U2 -rNXd a/common/coordinates.h 1/common/coordinates.h
--- a/common/coordinates.h      Thu Jan  1 01:00:00 1970
+++ 1/common/coordinates.h      Fri Sep 22 09:33:20 2000
@@ -0,0 +1 @@
+struct locus {int x, y;};
diff -U2 -rNXd a/server/mapgen.c 1/server/mapgen.c
--- a/server/mapgen.c   Fri Sep 22 10:05:12 2000
+++ 1/server/mapgen.c   Fri Sep 22 10:20:19 2000
@@ -21,4 +21,5 @@
 #include <time.h>
 
+#include "coordinates.h"
 #include "fcintl.h"
 #include "game.h"
@@ -56,4 +57,12 @@
 #define MAP_NCONT 255
 
+/*********************************************************************
+ Just a wrapper function off the height_map, returns the height at
+ position. Should eventually replace full_map.
+*********************************************************************/
+static int get_height(struct locus position) {
+  return height_map[position.y * map.xsize + position.x];
+}
+
 /**************************************************************************
  Just a wrapper function off the height_map, returns the height at x,y
@@ -106,24 +115,27 @@
 static void make_polar(void)
 {
-  int y,x;
+  struct locus position;
 
-  for (y=0;y<map.ysize/10;y++) {
-    for (x=0;x<map.xsize;x++) {
-      if ((full_map(x, y)+(map.ysize/10-y*25)>myrand(maxval) && 
map_get_terrain(x,y)==T_GRASSLAND) || y==0) { 
-       if (y<2)
-         map_set_terrain(x, y, T_ARCTIC);
-       else
-         map_set_terrain(x, y, T_TUNDRA);
-         
+  for (position.y = 0; position.y < map.ysize / 10; position.y++) {
+    for (position.x = 0; position.x < map.xsize; position.x++) {
+      if ((get_height(position) + (map.ysize / 10 - position.y * 25) >
+          myrand(maxval) && map_get_terrain(position.x, position.y)
+          == T_GRASSLAND) || position.y == 0) { 
+       if (position.y < 2)
+         map_set_terrain(position.x, position.y, T_ARCTIC);
+       else map_set_terrain(position.x, position.y, T_TUNDRA);
       } 
     }
   }
-  for (y=map.ysize*9/10;y<map.ysize;y++) {
-    for (x=0;x<map.xsize;x++) {
-      if ((full_map(x, y)+(map.ysize/10-(map.ysize-y)*25)>myrand(maxval) && 
map_get_terrain(x, y)==T_GRASSLAND) || y==map.ysize-1) {
-       if (y>map.ysize-3)
-         map_set_terrain(x, y, T_ARCTIC);
-       else
-         map_set_terrain(x, y, T_TUNDRA);
+  for (position.y = map.ysize * 9 / 10; position.y < map.ysize;
+       position.y++) {
+    for (position.x = 0; position.x < map.xsize; position.x++) {
+      if ((get_height(position) +
+          (map.ysize / 10 - (map.ysize - position.y) * 25) >
+          myrand(maxval) && map_get_terrain(position.x, position.y)
+          == T_GRASSLAND) || position.y == map.ysize - 1) {
+       if (position.y > map.ysize - 3)
+         map_set_terrain(position.x, position.y, T_ARCTIC);
+       else map_set_terrain(position.x, position.y, T_TUNDRA);
       }
     }

Attachment: get_height-1.diff.bz2
Description: Binary data


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