Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] (PR#6183) barbarians on the poles
Home

[Freeciv-Dev] (PR#6183) barbarians on the poles

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#6183) barbarians on the poles
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 17 Sep 2003 13:33:46 -0700
Reply-to: rt@xxxxxxxxxxxxxx

In barbarians.c there is code to prevent barbarian uprisings on the 
poles.  But this code is buggy: you won't get barbarians on the y==0 or 
y==map.ysize-1 line but you can still get them on the y==1 and 
y==map.ysize-2 line.

Moreover, this code makes assumptions about the terrain - namely, that 
the poles exist and that they are at these locations.  Under 
gen-topologies this isn't necessarily true, and should be up to the 
mapgen code in any case.

Two alternatives:

- Remove this restriction, and let barbarians be summoned anywhere.

- Let mapgen determine what's polar and what's not.

This patch implements the second.

jason

Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.142
diff -u -r1.142 map.c
--- common/map.c        2003/09/11 11:30:42     1.142
+++ common/map.c        2003/09/17 20:32:49
@@ -193,6 +193,8 @@
   map.separatepoles         = MAP_DEFAULT_SEPARATE_POLES;
   map.tiles                 = NULL;
   map.num_continents        = 0;
+  map.continents.north_pole = -1;
+  map.continents.south_pole = -1;
   map.num_start_positions   = 0;
   map.fixed_start_positions = FALSE;
   map.have_specials         = FALSE;
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.152
diff -u -r1.152 map.h
--- common/map.h        2003/09/11 11:30:42     1.152
+++ common/map.h        2003/09/17 20:32:49
@@ -174,6 +174,10 @@
   bool have_huts;
   bool have_rivers_overlay;    /* only applies if !have_specials */
   int num_continents;
+  struct {
+    /* Continent numbers for this map. */
+    int north_pole, south_pole;
+  } continents;
   struct tile *tiles;
 
   /* Only used by server. */
Index: server/barbarian.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/barbarian.c,v
retrieving revision 1.67
diff -u -r1.67 barbarian.c
--- server/barbarian.c  2003/08/04 15:42:47     1.67
+++ server/barbarian.c  2003/09/17 20:32:49
@@ -331,7 +331,8 @@
   /* No uprising on North or South Pole */
   do {
     rand_map_pos(&x, &y);
-  } while (y == 0 || y == map.ysize - 1);
+  } while (map_get_continent(x, y) != map.continents.north_pole
+          && map_get_continent(x, y) != map.continents.south_pole);
 
   if (!(pc = dist_nearest_city(NULL, x, y, TRUE, FALSE))) {
     /* any city */
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.116
diff -u -r1.116 mapgen.c
--- server/mapgen.c     2003/09/11 12:09:46     1.116
+++ server/mapgen.c     2003/09/17 20:32:50
@@ -942,8 +942,10 @@
   } whole_map_iterate_end;
 
   if (map.generator != 0) {
-    assign_continent_flood(0, 0, 1);
-    assign_continent_flood(0, map.ysize-1, 2);
+    map.continents.north_pole = 1;
+    map.continents.south_pole = 2;
+    assign_continent_flood(0, 0, map.continents.north_pole);
+    assign_continent_flood(0, map.ysize-1, map.continents.south_pole);
     isle = 3;
   }
       
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.135
diff -u -r1.135 savegame.c
--- server/savegame.c   2003/09/09 15:49:07     1.135
+++ server/savegame.c   2003/09/17 20:32:50
@@ -2060,6 +2060,11 @@
       map.forestsize = secfile_lookup_int(file, "map.forestsize");
       map.have_huts = secfile_lookup_bool_default(file, TRUE, "map.have_huts");
 
+      map.continents.north_pole =
+       secfile_lookup_int_default(file, -1, "map.continents.north_pole");
+      map.continents.south_pole =
+       secfile_lookup_int_default(file, -1, "map.continents.south_pole");
+
       if (has_capability("startoptions", savefile_options)) {
        map.xsize = secfile_lookup_int(file, "map.width");
        map.ysize = secfile_lookup_int(file, "map.height");
@@ -2337,6 +2342,11 @@
     secfile_insert_int(file, map.huts, "map.huts");
     secfile_insert_int(file, map.generator, "map.generator");
     secfile_insert_bool(file, map.have_huts, "map.have_huts");
+
+    secfile_insert_int(file, map.continents.north_pole,
+                      "map.continents.north_pole");
+    secfile_insert_int(file, map.continents.south_pole,
+                      "map.continents.south_pole");
   } 
 
   secfile_insert_int(file, game.randseed, "game.randseed");

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