autoseed, creating island controlled from script.

bugfix empty orders in savefile
This commit is contained in:
Enno Rehling 2005-08-07 13:48:18 +00:00
parent 3b671396c1
commit e639a1258b
8 changed files with 29 additions and 29 deletions

View File

@ -1015,7 +1015,7 @@ void
fwriteorder(FILE * F, const order * ord, const struct locale * lang)
{
write_order(ord, lang, buf, sizeof(buf));
fwritestr(F, buf);
if (buf[0]) fwritestr(F, buf);
}
unit *
@ -1260,7 +1260,7 @@ writeunit(FILE * F, const unit * u)
}
}
/* write an empty string to terminate the list */
fwriteorder(F, NULL, u->faction->locale);
fputs("\"\"", F);
wnl(F);
#if RELEASE_VERSION<NOLASTORDER_VERSION
/* the current default order */

View File

@ -355,7 +355,6 @@ preferred_terrain(const struct race * rc)
#define REGIONS_PER_FACTION 2
#define PLAYERS_PER_ISLAND 20
#define TURNS_PER_ISLAND 3
#define MINFACTIONS 1
#define MAXAGEDIFF 5
#define VOLCANO_CHANCE 100
@ -412,7 +411,7 @@ get_island(region * root, region_list ** rlist)
* returns the number of players placed on the new island.
*/
int
autoseed(newfaction ** players, int nsize)
autoseed(newfaction ** players, int nsize, boolean new_island)
{
short x = 0, y = 0;
region * r = NULL;
@ -423,7 +422,7 @@ autoseed(newfaction ** players, int nsize)
if (listlen(*players)<MINFACTIONS) return 0;
if (turn % TURNS_PER_ISLAND) {
if (!new_island) {
region * rmin = NULL;
/* find a spot that's adjacent to the previous island, but virgin.
* like the last land virgin ocean region adjacent to land.

View File

@ -32,7 +32,7 @@ typedef struct newfaction {
struct alliance * allies;
} newfaction;
extern int autoseed(newfaction ** players, int nsize);
extern int autoseed(newfaction ** players, int nsize, boolean new_island);
extern newfaction * read_newfactions(const char * filename);
extern void get_island(struct region * root, struct region_list ** rlist);
extern int fix_demand(struct region *r);

View File

@ -166,15 +166,16 @@ race_setscript(const char * rcname, const functor<void>& f)
}
#define ISLANDSIZE 20
#define TURNS_PER_ISLAND 3
static void
lua_autoseed(const char * filename)
lua_autoseed(const char * filename, bool new_island)
{
newfaction * players = read_newfactions(filename);
while (players) {
int n = listlen(players);
int k = (n+ISLANDSIZE-1)/ISLANDSIZE;
k = n / k;
autoseed(&players, k);
autoseed(&players, k, new_island || (turn % TURNS_PER_ISLAND)==0);
}
}

View File

@ -265,7 +265,7 @@ processturn(char *filename)
int n = listlen(players);
int k = (n+ISLANDSIZE-1)/ISLANDSIZE;
k = n / k;
autoseed(&players, k);
autoseed(&players, k, true);
}
score();
remove_unequipped_guarded();

View File

@ -148,7 +148,7 @@ runautoseed(void)
int n = listlen(newfactions);
int k = (n+ISLANDSIZE-1)/ISLANDSIZE;
k = n / k;
autoseed(&newfactions, k);
autoseed(&newfactions, k, true);
}
}

View File

@ -40,7 +40,7 @@ function process(orders)
add_equipment("money", 4200);
-- use newfactions file to place out new players
autoseed(basepath .. "/newfactions")
autoseed(basepath .. "/newfactions", true)
write_passwords()
write_reports()

View File

@ -82,7 +82,7 @@ function process(orders)
change_locales()
-- use newfactions file to place out new players
autoseed(basepath .. "/newfactions")
autoseed(basepath .. "/newfactions", false)
write_passwords()
write_reports()