Letzte Touches am neuen Autoseed Code (wollte ich schon seit 2 Wochen committen. Ich brauche manchmal doch Internet)

This commit is contained in:
Enno Rehling 2002-06-02 06:23:29 +00:00
parent cb9f17a0c8
commit 27833fcb8f
2 changed files with 37 additions and 11 deletions

View File

@ -372,6 +372,7 @@ mkisland(int nsize)
regionlist ** rbegin = &rlist;
int i;
#define MINOCEANDIST 3
#define MAXFILLDIST 10
for (i=0;i!=MINOCEANDIST;++i) {
regionlist ** rend = rbegin;
while (*rend) rend=&(*rend)->next;
@ -390,6 +391,25 @@ mkisland(int nsize)
}
}
while (*rbegin) {
region * r = (*rbegin)->region;
direction_t d;
rbegin=&(*rbegin)->next;
for (d=0;d!=MAXDIRECTIONS;++d) if (rconnect(r, d)==NULL) {
int i;
for (i=1;i!=MAXFILLDIST;++i) {
if (findregion(r->x + i*delta_x[d], r->y + i*delta_y[d]))
break;
}
if (i!=MAXFILLDIST) {
while (--i) {
region * rn = new_region(r->x + i*delta_x[d], r->y + i*delta_y[d]);
terraform(rn, T_OCEAN);
}
}
}
}
}
return isize;
}

View File

@ -130,6 +130,17 @@ boolean minimapx=false,minimapy=false; /* Karte nicht vert./hor. scrollen */
/* top, left => ? */
/* hx, hy => ? */
static void
runautoseed(void)
{
while (newfactions) {
int n = listlen(newfactions);
int k = (n+ISLANDSIZE-1)/ISLANDSIZE;
k = n / k;
mkisland(k);
}
}
void
init_win(int x, int y) {
if (initscr() == NULL) {
@ -1040,6 +1051,7 @@ movearound(int rx, int ry) {
ch = -9;
break;
case 'a':
#if 0
if (r && r->land) {
regionlist * rlist = NULL;
add_regionlist(&rlist, r);
@ -1047,15 +1059,14 @@ movearound(int rx, int ry) {
autoseed(rlist);
modified = 1;
}
break;
#else
runautoseed();
modified = 1;
#endif
case 's':
seed_dropouts();
modified = 1;
break;
case 'm':
mkisland(ISLANDSIZE);
modified = 1;
break;
case 'S':
if (modified)
if (yes_no(0, "Daten abspeichern?", 'j')) {
@ -1592,12 +1603,7 @@ main(int argc, char *argv[])
srand(time((time_t *) NULL));
if (autoseeding) {
while (newfactions) {
int n = listlen(newfactions);
int k = (n+ISLANDSIZE-1)/ISLANDSIZE;
k = n / k;
mkisland(k);
}
runautoseed();
remove_empty_units();
writegame(datafile, 1);
} else {