[Freeciv-Dev] Re: (PR#14269) Better Control of World Size
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14269 >
Benedict Adamson wrote:
...
> I suggest we deal with both of these problems by changing the size
> parameter to be tiles per nation, rather than thousands of tiles.
...
And here is a patch to do it.
diff -ruN -Xvendor.freeciv.current/diff_ignore
vendor.freeciv.current/common/map.c freeciv.PR14269/common/map.c
--- vendor.freeciv.current/common/map.c 2005-10-12 00:47:36.000000000 +0100
+++ freeciv.PR14269/common/map.c 2005-10-12 00:41:32.000000000 +0100
@@ -95,6 +95,7 @@
{
map.topology_id = MAP_DEFAULT_TOPO;
map.size = MAP_DEFAULT_SIZE;
+ map.nationsize = MAP_DEFAULT_NATIONSIZE;
/* The [xy]size values are set in map_init_topology. It is initialized
* to a non-zero value because some places erronously use these values
diff -ruN -Xvendor.freeciv.current/diff_ignore
vendor.freeciv.current/common/map.h freeciv.PR14269/common/map.h
--- vendor.freeciv.current/common/map.h 2005-10-12 00:47:36.000000000 +0100
+++ freeciv.PR14269/common/map.h 2005-10-12 00:41:32.000000000 +0100
@@ -42,7 +42,8 @@
int num_valid_dirs, num_cardinal_dirs;
struct iter_index *iterate_outwards_indices;
int num_iterate_outwards_indices;
- int size; /* used to calculate [xy]size */
+ int size; /* number of tiles / 1000 */
+ int nationsize; /* used to calculate [xy]size: tiles per inital nation */
int xsize, ysize; /* native dimensions */
int seed;
int riches;
@@ -436,6 +437,11 @@
#define MAP_MIN_SIZE 1
#define MAP_MAX_SIZE 29
+/* Size of the map in tiles per starting nation */
+#define MAP_DEFAULT_NATIONSIZE 800
+#define MAP_MIN_NATIONSIZE 100
+#define MAP_MAX_NATIONSIZE 3200
+
/* This defines the maximum linear size in _map_ coordinates.
* This must be smaller than 255 because of the way coordinates are sent
* across the network. */
diff -ruN -Xvendor.freeciv.current/diff_ignore
vendor.freeciv.current/server/generator/mapgen_topology.c
freeciv.PR14269/server/generator/mapgen_topology.c
--- vendor.freeciv.current/server/generator/mapgen_topology.c 2005-10-12
00:47:19.000000000 +0100
+++ freeciv.PR14269/server/generator/mapgen_topology.c 2005-10-12
00:41:14.000000000 +0100
@@ -14,6 +14,7 @@
#include <config.h>
#endif
+#include "game.h"
#include "map.h"
#include "log.h"
@@ -182,7 +183,7 @@
/* We have:
*
- * 1000 * size = xsize * ysize
+ * size = xsize * ysize
*
* And to satisfy the ratios and other constraints we set
*
@@ -191,31 +192,31 @@
*
* For any value of "i_size". So with some substitution
*
- * 1000 * size = i_size * i_size * xratio * yratio * even * even * iso
- * i_size = sqrt(1000 * size / (xratio * yratio * even * even * iso))
+ * size = i_size * i_size * xratio * yratio * even * even * iso
+ * i_size = sqrt(size / (xratio * yratio * even * even * iso))
*
* Make sure to round off i_size to preserve exact wanted ratios,
* that may be importante for some topologies.
*/
const int i_size
- = sqrt((float)(1000 * size)
- / (float)(Xratio * Yratio * iso * even * even)) + 0.49;
+ = sqrt(size / (float)(Xratio * Yratio * iso * even * even)) + 0.49;
/* Now build xsize and ysize value as described above. */
map.xsize = Xratio * i_size * even;
map.ysize = Yratio * i_size * even * iso;
+ map.size = map.xsize * map.ysize / 1000;
/* Now make sure the size isn't too large for this ratio. If it is
* then decrease the size and try again. */
if (MAX(MAP_WIDTH, MAP_HEIGHT) > MAP_MAX_LINEAR_SIZE ) {
- assert(size > 0.1);
- set_sizes(size - 0.1, Xratio, Yratio);
+ assert(size > 100);
+ set_sizes(size - 100, Xratio, Yratio);
return;
}
/* If the ratio is too big for some topology the simplest way to avoid
* this error is to set the maximum size smaller for all topologies! */
- if (map.size > size + 0.9) {
+ if (1000 * map.size > size + 900) {
/* Warning when size is set uselessly big */
freelog(LOG_ERROR,
"Requested size of %d is too big for this topology.",
@@ -251,11 +252,14 @@
{AUTO_RATIO_FLAT, AUTO_RATIO_CLASSIC,
AUTO_RATIO_URANUS, AUTO_RATIO_TORUS};
const int id = 0x3 & map.topology_id;
+ const double size = MIN(map.nationsize * get_num_human_and_ai_players(),
+ 1000 * MAP_MAX_SIZE);
assert(TF_WRAPX == 0x1 && TF_WRAPY == 0x2);
- /* Set map.xsize and map.ysize based on map.size. */
- set_sizes(map.size, default_ratios[id][0], default_ratios[id][1]);
+ /* Set map.xsize and map.ysize based on
+ * map.nationsize and number of nations. */
+ set_sizes(size, default_ratios[id][0], default_ratios[id][1]);
}
/* initialize the ICE_BASE_LEVEL */
diff -ruN -Xvendor.freeciv.current/diff_ignore
vendor.freeciv.current/server/generator/startpos.c
freeciv.PR14269/server/generator/startpos.c
--- vendor.freeciv.current/server/generator/startpos.c 2005-10-12
00:47:19.000000000 +0100
+++ freeciv.PR14269/server/generator/startpos.c 2005-10-12 00:41:14.000000000
+0100
@@ -193,7 +193,7 @@
int min_goodies_per_player = 2000;
int total_goodies = 0;
/* this is factor is used to maximize land used in extreme little maps */
- float efactor = game.info.nplayers / map.size / 4;
+ float efactor = 250.0 / (float)map.nationsize;
bool failure = FALSE;
/* Unsafe terrains separate continents, otherwise small areas of green
diff -ruN -Xvendor.freeciv.current/diff_ignore
vendor.freeciv.current/server/settings.c freeciv.PR14269/server/settings.c
--- vendor.freeciv.current/server/settings.c 2005-10-12 00:47:20.000000000
+0100
+++ freeciv.PR14269/server/settings.c 2005-10-12 00:41:15.000000000 +0100
@@ -207,13 +207,15 @@
/* These should be grouped by sclass */
/* Map size parameters: adjustable if we don't yet have a map */
- GEN_INT("size", map.size, SSET_MAP_SIZE,
+ GEN_INT("nationsize", map.nationsize, SSET_MAP_SIZE,
SSET_GEOLOGY, SSET_VITAL, SSET_TO_CLIENT,
- N_("Map size (in thousands of tiles)"),
+ N_("Size of a typical nation (in tiles)"),
N_("This value is used to determine the map dimensions.\n"
- " size = 4 is a normal map of 4,000 tiles (default)\n"
- " size = 20 is a huge map of 20,000 tiles"), NULL,
- MAP_MIN_SIZE, MAP_MAX_SIZE, MAP_DEFAULT_SIZE)
+ "It is the number of map tiles per starting nation\n"
+ "(with a maximum of 29000 tiles total).\n"
+ " nationsize = 800 is a normal map (default)\n"
+ " nationsize = 300 is a small map"), NULL,
+ MAP_MIN_NATIONSIZE, MAP_MAX_NATIONSIZE, MAP_DEFAULT_NATIONSIZE)
GEN_INT("topology", map.topology_id, SSET_MAP_SIZE,
SSET_GEOLOGY, SSET_VITAL, SSET_TO_CLIENT,
N_("Map topology index"),
|
|