diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 6bd5ae6df..709f999b4 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -79,6 +79,7 @@ #include /* exported variables */ +char *xmlfile; region *regions; faction *factions; settings global; diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 03015fa66..eb57f7a36 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -164,7 +164,9 @@ struct xml_stack; #define ALLIANCES_VERSION 313 #define DBLINK_VERSION 314 #define CURSEVIGOURISFLOAT_VERSION 315 -#define REGIONOWNERS_VERSION 316 +#define SAVEXMLNAME_VERSION 316 + +#define REGIONOWNERS_VERSION 317 #define MIN_VERSION ALLIANCES_VERSION #define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */ @@ -172,7 +174,7 @@ struct xml_stack; #ifdef REGIONOWNERS # define RELEASE_VERSION REGIONOWNERS_VERSION #else -# define RELEASE_VERSION CURSEVIGOURISFLOAT_VERSION +# define RELEASE_VERSION SAVEXMLNAME_VERSION #endif #if RESOURCE_CONVERSION @@ -888,6 +890,7 @@ typedef struct request { } request; extern int turn; +extern char *xmlfile; /* parteinummern */ extern int *used_faction_ids; diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 9ffd3ce8b..2416c39eb 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -887,7 +887,32 @@ readgame(const char * filename, int backup) #else assert(global.data_version >= NEWSOURCE_VERSION); #endif - if (global.data_version >= GLOBAL_ATTRIB_VERSION) a_read(F, &global.attribs); + if(global.data_version >= SAVEXMLNAME_VERSION) { + char basefile[1024]; + char *basearg; + + rs(F, basefile); + if(xmlfile != NULL) { + basearg = strrchr(xmlfile, '/'); + if(!basearg) { + basearg = xmlfile; + } else { + basearg++; + } + } else { + basearg = "(null)"; + } + if(strcmp(basearg, basefile)) { + printf("WARNING: xmlfile mismatch:\n"); + printf("WARNING: datafile contains %s\n", basefile); + printf("WARNING: argument/default is %s\n", basearg); + printf("WARNING: any key to continue, Ctrl-C to stop\n"); + getchar(); + } + } + if (global.data_version >= GLOBAL_ATTRIB_VERSION) { + a_read(F, &global.attribs); + } #ifndef COMPATIBILITY if (global.data_version < ITEMTYPE_VERSION) { fprintf(stderr, "kann keine alten datenfiles einlesen"); @@ -1308,6 +1333,7 @@ export_players(const char * path) int writegame(const char *filename, char quiet) { + char *base; int i,n; faction *f; region *r; @@ -1340,6 +1366,14 @@ writegame(const char *filename, char quiet) wi(F, RELEASE_VERSION); wnl(F); + base = strrchr(xmlfile, '/'); + if(base) { + ws(F, base+1); + } else { + ws(F, xmlfile); + } + wnl(F); + a_write(F, global.attribs); wnl(F); diff --git a/src/eressea/main.c b/src/eressea/main.c index e2abe0cae..57c4a616b 100644 --- a/src/eressea/main.c +++ b/src/eressea/main.c @@ -121,7 +121,6 @@ extern int fuzzy_hits; ** global variables that we are exporting **/ static char * orders = NULL; -static char * xmlfile = NULL; static int nowrite = 0; static boolean g_writemap = false; static boolean g_killeiswald = false; @@ -522,6 +521,9 @@ static int read_args(int argc, char **argv) { int i; + + xmlfile = NULL; + for (i=1;i!=argc;++i) { if (argv[i][0]!='-') { return usage(argv[0], argv[i]); diff --git a/src/eressea/server.cpp b/src/eressea/server.cpp index c35a453da..7cef76273 100644 --- a/src/eressea/server.cpp +++ b/src/eressea/server.cpp @@ -132,7 +132,6 @@ extern int fuzzy_hits; ** global variables that we are exporting **/ static char * orders = NULL; -static char * xmlfile = NULL; static int nowrite = 0; static boolean g_writemap = false; static boolean opt_reportonly = false; diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index 43412e350..265820e2b 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -76,8 +76,6 @@ extern int maxregions; extern boolean dirtyload; char datafile[256]; -static char * xmlfile = NULL; - /* -------------------- resizeterm ------------------------------------- */ short Signals = 0;