- Prüfung passende xml-Resourcendatei

This commit is contained in:
Christian Schlittchen 2004-01-11 10:05:03 +00:00
parent 9ab04459c0
commit 7af84866ed
6 changed files with 44 additions and 7 deletions

View File

@ -79,6 +79,7 @@
#include <errno.h>
/* exported variables */
char *xmlfile;
region *regions;
faction *factions;
settings global;

View File

@ -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;

View File

@ -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);

View File

@ -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]);

View File

@ -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;

View File

@ -76,8 +76,6 @@ extern int maxregions;
extern boolean dirtyload;
char datafile[256];
static char * xmlfile = NULL;
/* -------------------- resizeterm ------------------------------------- */
short Signals = 0;