diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 0b32d07d5..b7be7f77b 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -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 * @@ -1252,24 +1252,24 @@ writeunit(FILE * F, const unit * u) fputc(' ', F); } #endif - for (ord = u->orders; ord; ord=ord->next) { + for (ord = u->orders; ord; ord=ord->next) { if (u->old_orders && is_repeated(ord)) continue; /* has new defaults */ - if (is_persistent(ord)) { + if (is_persistent(ord)) { fwriteorder(F, ord, u->faction->locale); fputc(' ', F); - } - } + } + } /* write an empty string to terminate the list */ - fwriteorder(F, NULL, u->faction->locale); - wnl(F); + fputs("\"\"", F); + wnl(F); #if RELEASE_VERSIONlastorder, u->faction->locale); - wnl(F); + fwriteorder(F, u->lastorder, u->faction->locale); + wnl(F); #endif assert(u->number <= UNIT_MAXSIZE); - assert(u->race); + assert(u->race); for (i=0;i!=u->skill_size;++i) { skill * sv = u->skills+i; diff --git a/src/common/modules/autoseed.c b/src/common/modules/autoseed.c index 53371fe07..acdd1e4b9 100644 --- a/src/common/modules/autoseed.c +++ b/src/common/modules/autoseed.c @@ -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,18 +411,18 @@ 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; - region_list * rlist = NULL; - int rsize, tsize = 0; + short x = 0, y = 0; + region * r = NULL; + region_list * rlist = NULL; + int rsize, tsize = 0; int isize = REGIONS_PER_FACTION; /* target size for the island */ int psize = 0; /* players on this island */ if (listlen(*players)& 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); } } diff --git a/src/eressea/main.c b/src/eressea/main.c index 8cf1b7615..51dae3f0d 100644 --- a/src/eressea/main.c +++ b/src/eressea/main.c @@ -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(); diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index 10f2aa189..5af727209 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -144,12 +144,12 @@ newfaction * newfactions = NULL; static void runautoseed(void) { - while (newfactions) { - int n = listlen(newfactions); - int k = (n+ISLANDSIZE-1)/ISLANDSIZE; - k = n / k; - autoseed(&newfactions, k); - } + while (newfactions) { + int n = listlen(newfactions); + int k = (n+ISLANDSIZE-1)/ISLANDSIZE; + k = n / k; + autoseed(&newfactions, k, true); + } } void diff --git a/src/scripts/default.lua b/src/scripts/default.lua index 0fb0f8926..a853435f4 100644 --- a/src/scripts/default.lua +++ b/src/scripts/default.lua @@ -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() diff --git a/src/scripts/eressea.lua b/src/scripts/eressea.lua index 44ec17da4..77e2d2729 100644 --- a/src/scripts/eressea.lua +++ b/src/scripts/eressea.lua @@ -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()