Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] Re: (PR#9798) PATCH assign_continent_number_count size of
Home

[Freeciv-Dev] Re: (PR#9798) PATCH assign_continent_number_count size of

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#9798) PATCH assign_continent_number_count size of continents
From: "Marcelo Burda" <mburda@xxxxxxxxx>
Date: Fri, 27 Aug 2004 15:01:23 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9798 >

Le ven 27/08/2004 à 23:11, Jason Short a écrit :
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=9798 >
> 
> > [mburda - Tue Aug 24 19:55:44 2004]:
> > 
> > depend de 9796
> > This is used by 9627 patch to clean easy small isle or oceans
> 
> The idea seems good.  I'm not quite sure how you plan to use it but it
see my Mega patch of generator (now is less mega)
> seems obvious that the data should be useful.  Only problem is with the
> ugly (but workable) indexing hack you use.
Maybe, i will fix it when number of continent get only positives values
;-)
> 
> 
> Another question I have is if we really want to extend the use of
> MAP_NCONT.  Originally this was just a hack to get gen2 (?) to work. 
> But now it's extended to be a hard limit on the number of continents. 
> While more than 300 continents doesn't seem likely it would be easy to
> make a scenario with it.
> 
i not want it, but i has to see the gen 2-4, if we can unify it, a leave
this hard limit, but seem imposible to get a 500 continents maps!

> Also the name MAP_NCONT is bad.  It should be MAX_NUM_CONTINENTS.
> 
> Two alternatives:
> 
> - Rename MAP_NCONT as MAX_NUM_CONTINENTS.  Possibly make it bigger.
> 
i choice easy way
> - Remove the value entirely and dynamically size any necessary arrays.
> 
> jason
> 

diff -ruN -Xfreeciv/diff_ignore freeciv/server/mapgen.c freeciv_/server/mapgen.c
--- freeciv/server/mapgen.c     2004-08-27 21:52:59.235204272 +0200
+++ freeciv_/server/mapgen.c    2004-08-27 21:49:05.568726976 +0200
@@ -25,7 +25,7 @@
 #include "game.h"
 #include "log.h"
 #include "map.h"
-#include "maphand.h" /* assign_continent_numbers(), MAX_NUM_CONTINENTS */
+#include "maphand.h" /* assign_continent_numbers(), MAP_NCONT */
 #include "mem.h"
 #include "rand.h"
 #include "shared.h"
@@ -2191,7 +2191,7 @@
     islemass = islemass - balance;
 
     /* don't create continents without a number */
-    if (pstate->isleindex >= MAX_NUM_CONTINENTS) {
+    if (pstate->isleindex >= MAP_NCONT) {
       return FALSE;
     }
 
@@ -2276,7 +2276,7 @@
 {
   int i;
   height_map = fc_malloc(sizeof(int) * map.ysize * map.xsize);
-  islands = fc_malloc((MAX_NUM_CONTINENTS+1)*sizeof(struct isledata));
+  islands = fc_malloc((MAP_NCONT+1)*sizeof(struct isledata));
 
   whole_map_iterate(x, y) {
     map_set_terrain(x, y, T_OCEAN);
@@ -2448,7 +2448,7 @@
     islandmass= 2;
 
 
-  while (pstate->isleindex <= MAX_NUM_CONTINENTS - 20 && checkmass > islandmass
+  while (pstate->isleindex <= MAP_NCONT - 20 && checkmass > islandmass
         && ++j < 1500) {
       if(j<1000)
        size = myrand((islandmass+1)/2+1)+islandmass/2;
diff -ruN -Xfreeciv/diff_ignore freeciv/server/maphand.c 
freeciv_/server/maphand.c
--- freeciv/server/maphand.c    2004-08-27 21:53:55.087713400 +0200
+++ freeciv_/server/maphand.c   2004-08-27 21:49:06.574574064 +0200
@@ -41,10 +41,6 @@
 #include "maphand.h"
 
 /**************************************************************************
- * used to store the size of continent
- **************************************************************************/
-int mass_size[2 * MAX_NUM_CONTINENTS];
-/**************************************************************************
   Number this tile and nearby tiles (recursively) with the specified
   continent number, using a flood-fill algorithm.
 
@@ -62,7 +58,6 @@
   }
 
   map_set_continent(x, y, nr);
-  MASS_SIZE(nr)++;
 
   adjc_iterate(x, y, x1, y1) {
     assign_continent_flood(x1, y1, is_land, nr);
@@ -78,12 +73,7 @@
 **************************************************************************/
 void assign_continent_numbers(void)
 {
-  int i;
-
   /* Initialize */
-  for(i = 0; i < 2 * MAX_NUM_CONTINENTS; i++) {
-    MASS_SIZE(i) = 0;
-  }
   map.num_continents = 0;
   map.num_oceans = 0;
 
@@ -99,11 +89,11 @@
     }
     if (!is_ocean(map_get_terrain(x, y))) {
       map.num_continents++;
-      assert(map.num_continents < MAX_NUM_CONTINENTS);
+      assert(map.num_continents < MAP_NCONT);
       assign_continent_flood(x, y, TRUE, map.num_continents);
     } else {
       map.num_oceans++;
-      assert(map.num_oceans < MAX_NUM_CONTINENTS);
+      assert(map.num_oceans < MAP_NCONT);
       assign_continent_flood(x, y, FALSE, -map.num_oceans);
     }
   } whole_map_iterate_end;
diff -ruN -Xfreeciv/diff_ignore freeciv/server/maphand.h 
freeciv_/server/maphand.h
--- freeciv/server/maphand.h    2004-08-27 21:51:18.047587128 +0200
+++ freeciv_/server/maphand.h   2004-08-27 21:49:06.583572696 +0200
@@ -50,11 +50,8 @@
 };
 
 /* The maximum number of continents and oceans. */
-#define MAX_NUM_CONTINENTS 500
+#define MAP_NCONT 300
 
-/* signus safe way for nr continent <0 or >0 */
-extern int mass_size[2 * MAX_NUM_CONTINENTS];
-#define MASS_SIZE(nr) (mass_size[FC_WRAP((nr), 2 * MAX_NUM_CONTINENTS)]) 
 void assign_continent_numbers(void);
 
 void global_warming(int effect);

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