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; regionlist ** rbegin = &rlist;
int i; int i;
#define MINOCEANDIST 3 #define MINOCEANDIST 3
#define MAXFILLDIST 10
for (i=0;i!=MINOCEANDIST;++i) { for (i=0;i!=MINOCEANDIST;++i) {
regionlist ** rend = rbegin; regionlist ** rend = rbegin;
while (*rend) rend=&(*rend)->next; 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; return isize;
} }

View File

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