Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2003:
[Freeciv-Dev] (PR#3386) suggestion: prebuilt cities, w/ patch
Home

[Freeciv-Dev] (PR#3386) suggestion: prebuilt cities, w/ patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3386) suggestion: prebuilt cities, w/ patch
From: "andrearo@xxxxxxxxxxxx via RT" <rt@xxxxxxxxxxxxxx>
Date: Tue, 11 Feb 2003 08:43:19 -0800
Reply-to: rt.freeciv.org@xxxxxxxxxxxxxx

Hi all,
This is a suggestion I came up with while playing Metalknights (another 
civ-like strategygame).
When the game starts, the land is already filled with cities. This means 
that it's possible to
start a game and begin a war in very few turns. (Actually, it's filled 
with huts that all contain cities.)
Set the serveroption; freecities 1 (for one square between each hut) or 
freecities 2 (for two squares).
This serveroption is disabled by default.

I've playtested it several times, and I've found that generator 2 gives 
approx. the same populations
for each player. This option overrides the regular huts option. Any 
feedback/ideas about this modification?

Andreas Røsdal



Favorite comment:  server/mapgen.c
/* Vi vil have store promiller; man kan aldrig faa
                for meget oel! */


diff -u -r -Xfreeciv/diff_ignore freeciv/common/map.c freeciv.work/common/map.c
--- freeciv/common/map.c        2003-01-09 06:55:57.000000000 +0100
+++ freeciv.work/common/map.c   2003-02-11 16:43:09.000000000 +0100
@@ -181,6 +181,7 @@
   map.riches                = MAP_DEFAULT_RICHES;
   map.is_earth              = FALSE;
   map.huts                  = MAP_DEFAULT_HUTS;
+  map.freecities            = MAP_DEFAULT_FREECITIES;
   map.landpercent           = MAP_DEFAULT_LANDMASS;
   map.grasssize             = MAP_DEFAULT_GRASS;
   map.swampsize             = MAP_DEFAULT_SWAMPS;
@@ -539,9 +540,9 @@
 /***************************************************************
 ...
 ***************************************************************/
-bool is_hut_close(int x, int y)
+bool is_hut_close(int x, int y, int radius)
 {
-  square_iterate(x, y, 3, x1, y1) {
+  square_iterate(x, y, radius, x1, y1) {
     if (map_has_special(x1, y1, S_HUT))
       return TRUE;
   } square_iterate_end;
diff -u -r -Xfreeciv/diff_ignore freeciv/common/map.h freeciv.work/common/map.h
--- freeciv/common/map.h        2003-01-06 06:55:30.000000000 +0100
+++ freeciv.work/common/map.h   2003-02-11 16:55:41.000000000 +0100
@@ -159,6 +159,7 @@
   int riches;
   bool is_earth;
   int huts;
+  int freecities;
   int landpercent;
   int grasssize;
   int swampsize;
@@ -302,7 +303,7 @@
 bool is_coastline(int x,int y);
 bool terrain_is_clean(int x, int y);
 bool is_at_coast(int x, int y);
-bool is_hut_close(int x, int y);
+bool is_hut_close(int x, int y, int radius);
 bool is_starter_close(int x, int y, int nr, int dist); 
 int is_good_tile(int x, int y);
 bool is_special_close(int x, int y);
@@ -578,6 +579,10 @@
 #define MAP_MIN_HUTS             0
 #define MAP_MAX_HUTS             500
 
+#define MAP_DEFAULT_FREECITIES   0
+#define MAP_MIN_FREECITIES       0
+#define MAP_MAX_FREECITIES       2
+
 #define MAP_DEFAULT_WIDTH        80
 #define MAP_MIN_WIDTH            40
 #define MAP_MAX_WIDTH            200
diff -u -r -Xfreeciv/diff_ignore freeciv/server/mapgen.c 
freeciv.work/server/mapgen.c
--- freeciv/server/mapgen.c     2003-01-09 06:56:03.000000000 +0100
+++ freeciv.work/server/mapgen.c        2003-02-11 16:59:17.000000000 +0100
@@ -36,6 +36,7 @@
 #define rmap(x, y) (river_map[map_inx(x, y)])
 
 static void make_huts(int number);
+static void make_freecities(int radius);
 static void add_specials(int prob);
 static void mapgenerator1(void);
 static void mapgenerator2(void);
@@ -1164,6 +1165,9 @@
   if(!map.have_specials) /* some scenarios already provide specials */
     add_specials(map.riches); /* hvor mange promiller specials oensker vi*/
 
+  if(map.freecities!=0)      
+    make_freecities(map.freecities);   /* make huts containing cities*/
+  
   if (!map.have_huts)
     make_huts(map.huts); /* Vi vil have store promiller; man kan aldrig faa
                            for meget oel! */
@@ -1330,6 +1334,30 @@
 }
 
 /**************************************************************************
+  Fills the land with prebuilt cities, found in huts.
+**************************************************************************/
+static void make_freecities(int radius)
+{
+  int x,y,l,number=500;
+  int count=0;
+  while (number * map_num_tiles() >= 2000 && count++ < map_num_tiles() * 2) {
+    rand_map_pos(&x, &y);
+    l=myrand(6); 
+    if (!is_ocean(map_get_terrain(x, y)) && 
+       ( map_get_terrain(x, y)!=T_ARCTIC || l<3 )
+       ) {
+      if (!is_hut_close(x,y,radius)) {
+       number--;
+       map_set_special(x, y, S_HUT);
+       /* Don't add to islands[].goodies because islands[] not
+          setup at this point, except for generator>1, but they
+          have pre-set starters anyway. */
+      }
+    }
+  }
+}
+
+/**************************************************************************
   this function spreads out huts on the map, a position can be used for a
   hut if there isn't another hut close and if it's not on the ocean.
 **************************************************************************/
@@ -1343,7 +1371,7 @@
     if (!is_ocean(map_get_terrain(x, y)) && 
        ( map_get_terrain(x, y)!=T_ARCTIC || l<3 )
        ) {
-      if (!is_hut_close(x,y)) {
+      if (!is_hut_close(x,y,3)) {
        number--;
        map_set_special(x, y, S_HUT);
        /* Don't add to islands[].goodies because islands[] not
diff -u -r -Xfreeciv/diff_ignore freeciv/server/stdinhand.c 
freeciv.work/server/stdinhand.c
--- freeciv/server/stdinhand.c  2003-01-21 06:57:00.000000000 +0100
+++ freeciv.work/server/stdinhand.c     2003-02-11 17:05:43.000000000 +0100
@@ -315,6 +315,14 @@
          N_("Amount of huts (minor tribe villages)"), "", NULL, 
          MAP_MIN_HUTS, MAP_MAX_HUTS, MAP_DEFAULT_HUTS)
 
+  GEN_INT("freecities", map.freecities, SSET_MAP_ADD, SSET_TO_CLIENT,
+         N_("Fills the land with prebuilt cities, found in huts."),
+          N_("0 = No prebuilt cities (default)\n"
+          "1 = One square between each prebuilt city\n"
+          "2 = Two squares between each prebuilt city\n"
+          "(This setting overrides the hut option.)") , NULL, 
+         MAP_MIN_FREECITIES, MAP_MAX_FREECITIES, MAP_DEFAULT_FREECITIES)
+
 /* Options affecting numbers of players and AI players.  These only
  * affect the start of the game and can not be adjusted after that.
  * (Actually, minplayers does also affect reloads: you can't start a
diff -u -r -Xfreeciv/diff_ignore freeciv/server/unittools.c 
freeciv.work/server/unittools.c
--- freeciv/server/unittools.c  2003-02-05 06:58:53.000000000 +0100
+++ freeciv.work/server/unittools.c     2003-02-11 16:56:46.000000000 +0100
@@ -2398,6 +2398,12 @@
     hut_chance = 0;
   }
 
+  /* If the freecities option is set, player always gets city in hut */
+  if(map.freecities!=0){
+    hut_get_city(punit);
+    return ok;
+  }
+
   switch (hut_chance) {
   case 0:
     hut_get_gold(punit, 25);

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