forked from github/server
Bessere Lösung für das auto-seeding: Jeder Terraintyp kriegt eine relative Häufigkeit in die XML-Daten.
This commit is contained in:
parent
c30cebd352
commit
988a0078c4
|
@ -67,6 +67,7 @@ typedef struct terrain_type {
|
||||||
int size; /* how many peasants can work? */
|
int size; /* how many peasants can work? */
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
short max_road; /* this many stones make a full road */
|
short max_road; /* this many stones make a full road */
|
||||||
|
short distribution; /* multiplier used for seeding */
|
||||||
struct terrain_production * production;
|
struct terrain_production * production;
|
||||||
const struct item_type ** herbs; /* zero-terminated array of herbs */
|
const struct item_type ** herbs; /* zero-terminated array of herbs */
|
||||||
const char * (*name)(const struct region * r);
|
const char * (*name)(const struct region * r);
|
||||||
|
|
|
@ -1539,13 +1539,14 @@ parse_terrains(xmlDocPtr doc)
|
||||||
if (xml_bvalue(node, "swim", false)) terrain->flags |= SWIM_INTO;
|
if (xml_bvalue(node, "swim", false)) terrain->flags |= SWIM_INTO;
|
||||||
if (xml_bvalue(node, "shallow", true)) terrain->flags |= LARGE_SHIPS;
|
if (xml_bvalue(node, "shallow", true)) terrain->flags |= LARGE_SHIPS;
|
||||||
if (xml_bvalue(node, "cavalry", false)) terrain->flags |= CAVALRY_REGION;
|
if (xml_bvalue(node, "cavalry", false)) terrain->flags |= CAVALRY_REGION;
|
||||||
if (xml_bvalue(node, "seed", true)) terrain->flags |= AUTO_TERRAIN;
|
|
||||||
}
|
}
|
||||||
if (xml_bvalue(node, "sea", false)) terrain->flags |= SEA_REGION;
|
if (xml_bvalue(node, "sea", false)) terrain->flags |= SEA_REGION;
|
||||||
if (xml_bvalue(node, "arctic", false)) terrain->flags |= ARCTIC_REGION;
|
if (xml_bvalue(node, "arctic", false)) terrain->flags |= ARCTIC_REGION;
|
||||||
if (xml_bvalue(node, "land", true)) terrain->flags |= LAND_REGION;
|
if (xml_bvalue(node, "land", true)) terrain->flags |= LAND_REGION;
|
||||||
if (xml_bvalue(node, "forest", false)) terrain->flags |= FOREST_REGION;
|
if (xml_bvalue(node, "forest", false)) terrain->flags |= FOREST_REGION;
|
||||||
|
|
||||||
|
terrain->distribution = (short)xml_ivalue(node, "seed", 0) terrain->flags |= AUTO_TERRAIN;
|
||||||
|
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
xpathChildren = xmlXPathEvalExpression(BAD_CAST "herb", xpath);
|
xpathChildren = xmlXPathEvalExpression(BAD_CAST "herb", xpath);
|
||||||
children = xpathChildren->nodesetval;
|
children = xpathChildren->nodesetval;
|
||||||
|
|
|
@ -38,23 +38,23 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
const terrain_type *
|
const terrain_type *
|
||||||
random_terrain(unsigned int flags)
|
random_terrain(boolean distribution)
|
||||||
{
|
{
|
||||||
static int nterrains;
|
static int nterrains;
|
||||||
|
static int ndistribution;
|
||||||
const terrain_type * terrain;
|
const terrain_type * terrain;
|
||||||
int n;
|
int n;
|
||||||
if (nterrains==0) {
|
if (nterrains==0) {
|
||||||
for (terrain=terrains();terrain;terrain=terrain->next) {
|
for (terrain=terrains();terrain;terrain=terrain->next) {
|
||||||
if (fval(terrain, flags)==flags) {
|
ndistribution += terrain->distribution;
|
||||||
++nterrains;
|
++nterrains;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
n = rand() % nterrains;
|
n = rand() % distribution?ndistribution:nterrains;
|
||||||
for (terrain=terrains();terrain;terrain=terrain->next) {
|
for (terrain=terrains();terrain;terrain=terrain->next) {
|
||||||
if (fval(terrain, flags)==flags) {
|
n -= distribution?terrain->distribution:1;
|
||||||
if (n--==0) break;
|
if (n<0) break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return terrain;
|
return terrain;
|
||||||
}
|
}
|
||||||
|
@ -645,7 +645,7 @@ autoseed(newfaction ** players, int nsize, boolean new_island)
|
||||||
--isize;
|
--isize;
|
||||||
if (psize>=PLAYERS_PER_ISLAND) break;
|
if (psize>=PLAYERS_PER_ISLAND) break;
|
||||||
} else {
|
} else {
|
||||||
terraform_region(r, random_terrain(AUTO_TERRAIN));
|
terraform_region(r, random_terrain(true));
|
||||||
--isize;
|
--isize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@ autoseed(newfaction ** players, int nsize, boolean new_island)
|
||||||
const struct terrain_type * terrain = newterrain(T_OCEAN);
|
const struct terrain_type * terrain = newterrain(T_OCEAN);
|
||||||
rn = new_region(r->x + delta_x[d], r->y + delta_y[d]);
|
rn = new_region(r->x + delta_x[d], r->y + delta_y[d]);
|
||||||
if (rand() % SPECIALCHANCE < special) {
|
if (rand() % SPECIALCHANCE < special) {
|
||||||
terrain = random_terrain(AUTO_TERRAIN);
|
terrain = random_terrain(true);
|
||||||
special = SPECIALCHANCE / 3; /* 33% chance auf noch eines */
|
special = SPECIALCHANCE / 3; /* 33% chance auf noch eines */
|
||||||
} else {
|
} else {
|
||||||
special = 1;
|
special = 1;
|
||||||
|
|
|
@ -36,7 +36,7 @@ extern int autoseed(newfaction ** players, int nsize, boolean new_island);
|
||||||
extern newfaction * read_newfactions(const char * filename);
|
extern newfaction * read_newfactions(const char * filename);
|
||||||
extern void get_island(struct region * root, struct region_list ** rlist);
|
extern void get_island(struct region * root, struct region_list ** rlist);
|
||||||
extern int fix_demand(struct region *r);
|
extern int fix_demand(struct region *r);
|
||||||
extern const struct terrain_type * random_terrain(unsigned int flags);
|
extern const struct terrain_type * random_terrain(boolean use_distribution);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1154,7 +1154,7 @@ movearound(short rx, short ry) {
|
||||||
if (r!=NULL) {
|
if (r!=NULL) {
|
||||||
a = map_input(0,0,0,"Wieviele Regionen?",0,500,0);
|
a = map_input(0,0,0,"Wieviele Regionen?",0,500,0);
|
||||||
if (a) {
|
if (a) {
|
||||||
const terrain_type * terrain = random_terrain(AUTO_TERRAIN);
|
const terrain_type * terrain = random_terrain(false);
|
||||||
create_island(r, a, terrain);
|
create_island(r, a, terrain);
|
||||||
modified=1;
|
modified=1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
<terrains>
|
<terrains>
|
||||||
<!-- defaults: walk="yes" sail="yes" fly="yes" shallow="yes" swim="no" forest="no" sea="no" land="yes" forbidden="no" arctic="no" cavalry="no" -->
|
<!-- defaults: walk="yes" sail="yes" fly="yes" shallow="yes" swim="no" forest="no" sea="no" land="yes" forbidden="no" arctic="no" cavalry="no" -->
|
||||||
<terrain name="ocean" size="100" shallow="no" walk="no" swim="yes" land="no" sea="yes" seed="no"/>
|
<terrain name="ocean" size="100" shallow="no" walk="no" swim="yes" land="no" sea="yes"/>
|
||||||
|
|
||||||
<terrain name="plain" size="10000" road="50" shallow="no" forest="yes" cavalry="yes">
|
<terrain name="plain" size="10000" road="50" shallow="no" forest="yes" cavalry="yes" seed="3">
|
||||||
<herb name="h0"/>
|
<herb name="h0"/>
|
||||||
<herb name="h1"/>
|
<herb name="h1"/>
|
||||||
<herb name="h2"/>
|
<herb name="h2"/>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<resource name="laen" chance="0.01" level="1d4" base="1d4" div="2d20+50"/>
|
<resource name="laen" chance="0.01" level="1d4" base="1d4" div="2d20+50"/>
|
||||||
</terrain>
|
</terrain>
|
||||||
|
|
||||||
<terrain name="swamp" size="2000" road="75">
|
<terrain name="swamp" size="2000" road="75" seed="2">
|
||||||
<herb name="h6"/>
|
<herb name="h6"/>
|
||||||
<herb name="h7"/>
|
<herb name="h7"/>
|
||||||
<herb name="h8"/>
|
<herb name="h8"/>
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
<resource name="laen" chance="0.02" level="1d4" base="1d4" div="2d20+50"/>
|
<resource name="laen" chance="0.02" level="1d4" base="1d4" div="2d20+50"/>
|
||||||
</terrain>
|
</terrain>
|
||||||
|
|
||||||
<terrain name="desert" size="1000" road="100" cavalry="yes">
|
<terrain name="desert" size="1000" road="100" cavalry="yes" seed="2">
|
||||||
<herb name="h9"/>
|
<herb name="h9"/>
|
||||||
<herb name="h10"/>
|
<herb name="h10"/>
|
||||||
<herb name="h11"/>
|
<herb name="h11"/>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<resource name="laen" chance="0.025" level="1d4" base="1d4" div="2d20+50"/>
|
<resource name="laen" chance="0.025" level="1d4" base="1d4" div="2d20+50"/>
|
||||||
</terrain>
|
</terrain>
|
||||||
|
|
||||||
<terrain name="highland" size="4000" road="100" cavalry="yes">
|
<terrain name="highland" size="4000" road="100" cavalry="yes" seed="2">
|
||||||
<herb name="h12"/>
|
<herb name="h12"/>
|
||||||
<herb name="h13"/>
|
<herb name="h13"/>
|
||||||
<herb name="h14"/>
|
<herb name="h14"/>
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
<resource name="laen" chance="0.025" level="1d4" base="1d4" div="2d20+50"/>
|
<resource name="laen" chance="0.025" level="1d4" base="1d4" div="2d20+50"/>
|
||||||
</terrain>
|
</terrain>
|
||||||
|
|
||||||
<terrain name="mountain" size="1000" road="250">
|
<terrain name="mountain" size="1000" road="250" seed="2">
|
||||||
<herb name="h15"/>
|
<herb name="h15"/>
|
||||||
<herb name="h16"/>
|
<herb name="h16"/>
|
||||||
<herb name="h17"/>
|
<herb name="h17"/>
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
<resource name="laen" chance="0.05" level="1" base="4" div="100"/>
|
<resource name="laen" chance="0.05" level="1" base="4" div="100"/>
|
||||||
</terrain>
|
</terrain>
|
||||||
|
|
||||||
<terrain name="glacier" size="100" road="250" arctic="yes">
|
<terrain name="glacier" size="100" road="250" arctic="yes" seed="2">
|
||||||
<herb name="h15"/>
|
<herb name="h15"/>
|
||||||
<herb name="h16"/>
|
<herb name="h16"/>
|
||||||
<herb name="h17"/>
|
<herb name="h17"/>
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
<resource name="laen" chance="0.05" level="1" base="4" div="100"/>
|
<resource name="laen" chance="0.05" level="1" base="4" div="100"/>
|
||||||
</terrain>
|
</terrain>
|
||||||
|
|
||||||
<terrain name="iceberg_sleep" size="100" road="250" arctic="yes" seed="no">
|
<terrain name="iceberg_sleep" size="100" road="250" arctic="yes">
|
||||||
<herb name="h15"/>
|
<herb name="h15"/>
|
||||||
<herb name="h16"/>
|
<herb name="h16"/>
|
||||||
<herb name="h17"/>
|
<herb name="h17"/>
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
<resource name="laen" chance="0.05" level="1" base="4" div="100"/>
|
<resource name="laen" chance="0.05" level="1" base="4" div="100"/>
|
||||||
</terrain>
|
</terrain>
|
||||||
|
|
||||||
<terrain name="iceberg" size="100" arctic="yes" seed="no">
|
<terrain name="iceberg" size="100" arctic="yes">
|
||||||
<herb name="h15"/>
|
<herb name="h15"/>
|
||||||
<herb name="h16"/>
|
<herb name="h16"/>
|
||||||
<herb name="h17"/>
|
<herb name="h17"/>
|
||||||
|
@ -77,26 +77,26 @@
|
||||||
<resource name="stone" chance="0.9" level="1" base="2" div="100"/>
|
<resource name="stone" chance="0.9" level="1" base="2" div="100"/>
|
||||||
</terrain>
|
</terrain>
|
||||||
|
|
||||||
<terrain name="firewall" size="100" road="250" land="no" walk="no" sail="no" fly="no" forbidden="yes" seed="no"/>
|
<terrain name="firewall" size="100" road="250" land="no" walk="no" sail="no" fly="no" forbidden="yes"/>
|
||||||
|
|
||||||
<terrain name="fog" sail="no" land="no" size="0" seed="no"/>
|
<terrain name="fog" sail="no" land="no" size="0"/>
|
||||||
<terrain name="thickfog" forbidden="yes" sail="no" walk="no" fly="no" land="no" size="0" seed="no"/>
|
<terrain name="thickfog" forbidden="yes" sail="no" walk="no" fly="no" land="no" size="0"/>
|
||||||
|
|
||||||
<terrain name="volcano" size="500" road="250">
|
<terrain name="volcano" size="500" road="250" seed="1">
|
||||||
<resource name="iron" chance="0.5" level="1" base="50" div="50"/>
|
<resource name="iron" chance="0.5" level="1" base="50" div="50"/>
|
||||||
<resource name="stone" chance="0.5" level="1" base="100" div="100"/>
|
<resource name="stone" chance="0.5" level="1" base="100" div="100"/>
|
||||||
<resource name="laen" chance="0.075" level="1" base="4" div="100"/>
|
<resource name="laen" chance="0.075" level="1" base="4" div="100"/>
|
||||||
</terrain>
|
</terrain>
|
||||||
|
|
||||||
<terrain name="activevolcano" size="500" road="250" seed="no">
|
<terrain name="activevolcano" size="500" road="250">
|
||||||
<resource name="iron" chance="0.5" level="1" base="50" div="50"/>
|
<resource name="iron" chance="0.5" level="1" base="50" div="50"/>
|
||||||
<resource name="stone" chance="0.5" level="1" base="100" div="100"/>
|
<resource name="stone" chance="0.5" level="1" base="100" div="100"/>
|
||||||
<resource name="laen" chance="0.075" level="1" base="4" div="100"/>
|
<resource name="laen" chance="0.075" level="1" base="4" div="100"/>
|
||||||
</terrain>
|
</terrain>
|
||||||
|
|
||||||
<!-- used for the museum only -->
|
<!-- used for the museum only -->
|
||||||
<terrain name="hall1" sail="no" fly="no" size="0" seed="no"/>
|
<terrain name="hall1" sail="no" fly="no" size="0"/>
|
||||||
<terrain name="corridor1" sail="no" fly="no" size="0" seed="no"/>
|
<terrain name="corridor1" sail="no" fly="no" size="0"/>
|
||||||
<terrain name="wall1" forbidden="yes" size="0" seed="no"/>
|
<terrain name="wall1" forbidden="yes" size="0"/>
|
||||||
|
|
||||||
</terrains>
|
</terrains>
|
||||||
|
|
Loading…
Reference in New Issue