forked from github/server
kingdoms: crashfix mapper when finding random terrain
This commit is contained in:
parent
b04b3ea168
commit
b086e9f93a
3 changed files with 17 additions and 4 deletions
|
@ -1192,7 +1192,7 @@ Create_Island(region *r, int * n, const terrain_type * terrain, int x, int y) {
|
|||
}
|
||||
|
||||
void
|
||||
create_island(region *r, int n, terrain_t t)
|
||||
create_island(region *r, int n, const struct terrain_type * terrain)
|
||||
{
|
||||
short sx=r->x, sy=r->y, i, x = 0, y = 0;
|
||||
direction_t d;
|
||||
|
@ -1203,7 +1203,7 @@ create_island(region *r, int n, terrain_t t)
|
|||
r2->msgs = (void *)0;
|
||||
}
|
||||
tradegood = NULL;
|
||||
terraform(r,t);
|
||||
terraform_region(r, terrain);
|
||||
if(r->land) settg(r);
|
||||
r->msgs = (void *)(rand()%6);
|
||||
|
||||
|
|
|
@ -1153,7 +1153,20 @@ movearound(short rx, short ry) {
|
|||
case 'I':
|
||||
a=map_input(0,0,0,"Wieviele Regionen?",0,500,0);
|
||||
if (a) {
|
||||
create_island(r, a, (terrain_t)(rand()%(T_GLACIER)+1));
|
||||
const terrain_type * terrain;
|
||||
int nterrains;
|
||||
for (terrain=terrains();terrain;terrain=terrain->next) {
|
||||
if (fval(terrain, NORMAL_TERRAIN)) {
|
||||
++nterrains;
|
||||
}
|
||||
}
|
||||
nterrains = rand() % nterrains;
|
||||
for (terrain=terrains();nterrains;terrain=terrain->next) {
|
||||
if (fval(terrain, NORMAL_TERRAIN)) {
|
||||
--nterrains;
|
||||
}
|
||||
}
|
||||
create_island(r, a, terrain);
|
||||
modified=1;
|
||||
}
|
||||
ch = -9;
|
||||
|
|
|
@ -55,7 +55,7 @@ void showregion(struct region * r, char full);
|
|||
int modify_region(struct region * r);
|
||||
void NeueBurg(struct region * r);
|
||||
void NeuesSchiff(struct region * r);
|
||||
void create_island(struct region *r, int n, terrain_t t);
|
||||
void create_island(struct region *r, int n, const struct terrain_type * t);
|
||||
void make_ocean_block(short x, short y);
|
||||
void make_new_block(int x, int y);
|
||||
void moveln(const int x);
|
||||
|
|
Loading…
Reference in a new issue