From 27833fcb8fa3d05222f204da34648c115fbf9742 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Jun 2002 06:23:29 +0000 Subject: [PATCH] Letzte Touches am neuen Autoseed Code (wollte ich schon seit 2 Wochen committen. Ich brauche manchmal doch Internet) --- src/mapper/autoseed.c | 20 ++++++++++++++++++++ src/mapper/mapper.c | 28 +++++++++++++++++----------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/mapper/autoseed.c b/src/mapper/autoseed.c index d781b597f..de41c4cbf 100644 --- a/src/mapper/autoseed.c +++ b/src/mapper/autoseed.c @@ -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; } diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index 29f19f45e..cdb7ee407 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -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 {