fairland: Eliminate global variable @secs
Move global variable @secs into grow_islands() and grow_continents(). Its other users can use isecs[c] instead. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
fd0ef2c645
commit
cf27d16e47
1 changed files with 8 additions and 8 deletions
|
@ -177,7 +177,6 @@ static const char *outfile = DEFAULT_OUTFILE_NAME;
|
||||||
#define new_x(newx) (((newx) + WORLD_X) % WORLD_X)
|
#define new_x(newx) (((newx) + WORLD_X) % WORLD_X)
|
||||||
#define new_y(newy) (((newy) + WORLD_Y) % WORLD_Y)
|
#define new_y(newy) (((newy) + WORLD_Y) % WORLD_Y)
|
||||||
|
|
||||||
static int secs; /* number of sectors grown */
|
|
||||||
static int ctot; /* total number of continents and islands grown */
|
static int ctot; /* total number of continents and islands grown */
|
||||||
static int *isecs; /* array of how large each island is */
|
static int *isecs; /* array of how large each island is */
|
||||||
|
|
||||||
|
@ -631,7 +630,7 @@ find_coast(int c)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
for (i = 0; i < secs; ++i) {
|
for (i = 0; i < isecs[c]; ++i) {
|
||||||
sectc[c][i] = 0;
|
sectc[c][i] = 0;
|
||||||
for (j = 0; j < 6; ++j)
|
for (j = 0; j < 6; ++j)
|
||||||
if (own[new_x(sectx[c][i] + dirx[j])][new_y(secty[c][i] + diry[j])] == -1)
|
if (own[new_x(sectx[c][i] + dirx[j])][new_y(secty[c][i] + diry[j])] == -1)
|
||||||
|
@ -680,8 +679,8 @@ try_to_grow(int c, int newx, int newy, int d)
|
||||||
return 0;
|
return 0;
|
||||||
} while (next_vector(i));
|
} while (next_vector(i));
|
||||||
}
|
}
|
||||||
sectx[c][secs] = newx;
|
sectx[c][isecs[c]] = newx;
|
||||||
secty[c][secs] = newy;
|
secty[c][isecs[c]] = newy;
|
||||||
isecs[c]++;
|
isecs[c]++;
|
||||||
own[newx][newy] = c;
|
own[newx][newy] = c;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -695,7 +694,7 @@ next_coast(int c, int x, int y, int *xp, int *yp)
|
||||||
{
|
{
|
||||||
int i, nx, ny, wat = 0;
|
int i, nx, ny, wat = 0;
|
||||||
|
|
||||||
if (secs == 1) {
|
if (isecs[c] == 1) {
|
||||||
*xp = x;
|
*xp = x;
|
||||||
*yp = y;
|
*yp = y;
|
||||||
return;
|
return;
|
||||||
|
@ -720,6 +719,7 @@ next_coast(int c, int x, int y, int *xp, int *yp)
|
||||||
static int
|
static int
|
||||||
new_try(int c, int spike)
|
new_try(int c, int spike)
|
||||||
{
|
{
|
||||||
|
int secs = isecs[c];
|
||||||
int i, starti;
|
int i, starti;
|
||||||
|
|
||||||
if (secs == 1) {
|
if (secs == 1) {
|
||||||
|
@ -776,7 +776,7 @@ grow_one_sector(int c)
|
||||||
next_coast(c, x, y, &x, &y);
|
next_coast(c, x, y, &x, &y);
|
||||||
++coast_search;
|
++coast_search;
|
||||||
} while (!done && coast_search < COAST_SEARCH_MAX &&
|
} while (!done && coast_search < COAST_SEARCH_MAX &&
|
||||||
(secs == 1 || x != sx || y != sy));
|
(isecs[c] == 1 || x != sx || y != sy));
|
||||||
if (!done && c < nc)
|
if (!done && c < nc)
|
||||||
fl_status |= STATUS_NO_ROOM;
|
fl_status |= STATUS_NO_ROOM;
|
||||||
return done;
|
return done;
|
||||||
|
@ -787,7 +787,7 @@ grow_one_sector(int c)
|
||||||
static void
|
static void
|
||||||
grow_continents(void)
|
grow_continents(void)
|
||||||
{
|
{
|
||||||
int c;
|
int c, secs;
|
||||||
|
|
||||||
for (c = 0; c < nc; ++c) {
|
for (c = 0; c < nc; ++c) {
|
||||||
sectx[c][0] = capx[c];
|
sectx[c][0] = capx[c];
|
||||||
|
@ -852,7 +852,7 @@ place_island(int c, int *xp, int *yp)
|
||||||
static void
|
static void
|
||||||
grow_islands(void)
|
grow_islands(void)
|
||||||
{
|
{
|
||||||
int c, x, y, isiz;
|
int c, secs, x, y, isiz;
|
||||||
|
|
||||||
for (c = nc; c < nc + ni; ++c) {
|
for (c = nc; c < nc + ni; ++c) {
|
||||||
secs = 0;
|
secs = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue