forked from github/server
There's a pretty bad problem with watchers in older datafiles.
This commit is contained in:
parent
f5b4b1ff99
commit
42c5331f1b
|
@ -1413,7 +1413,9 @@ readgame(const char * filename, int mode, int backup)
|
|||
n = store->r_int(store);
|
||||
while(--n >= 0) {
|
||||
int id = store->r_int(store);
|
||||
variant fno;
|
||||
plane *pl = getplanebyid(id);
|
||||
|
||||
if (pl==NULL) {
|
||||
pl = calloc(1, sizeof(plane));
|
||||
} else {
|
||||
|
@ -1428,18 +1430,28 @@ readgame(const char * filename, int mode, int backup)
|
|||
pl->flags = store->r_int(store);
|
||||
|
||||
/* read watchers */
|
||||
store->r_str_buf(store, token, sizeof(token));
|
||||
while (strcmp(token, "end")!=0) {
|
||||
watcher * w = calloc(sizeof(watcher),1);
|
||||
variant fno;
|
||||
fno.i = atoi36(token);
|
||||
w->mode = (unsigned char)store->r_int(store);
|
||||
w->next = pl->watchers;
|
||||
pl->watchers = w;
|
||||
ur_add(fno, &w->faction, resolve_faction);
|
||||
store->r_str_buf(store, token, sizeof(token));
|
||||
if (store->version<FIX_WATCHERS_VERSION) {
|
||||
char rname[64];
|
||||
/* before this version, watcher storage was pretty broken. we are incompatible and don't read them */
|
||||
for (;;) {
|
||||
store->r_tok_buf(store, rname, sizeof(rname));
|
||||
if (strcmp(rname, "end")==0) {
|
||||
break; /* this is most likely the end of the list */
|
||||
} else {
|
||||
log_error(("This datafile contains watchers, but we are unable to read them\n"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fno = read_faction_reference(store);
|
||||
while (fno.i) {
|
||||
watcher * w = (watcher *)malloc(sizeof(watcher));
|
||||
ur_add(fno, &w->faction, resolve_faction);
|
||||
w->mode = (unsigned char)store->r_int(store);
|
||||
w->next = pl->watchers;
|
||||
pl->watchers = w;
|
||||
fno = read_faction_reference(store);
|
||||
}
|
||||
}
|
||||
|
||||
a_read(store, &pl->attribs, pl);
|
||||
addlist(&planes, pl);
|
||||
}
|
||||
|
@ -1715,7 +1727,7 @@ writegame(const char *filename, int mode)
|
|||
}
|
||||
w = w->next;
|
||||
}
|
||||
store->w_tok(store, "end");
|
||||
write_faction_reference(NULL, store); /* mark the end of the list */
|
||||
a_write(store, pl->attribs, pl);
|
||||
store->w_brk(store);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
#define MOURNING_VERSION 335 /* mourning peasants */
|
||||
#define FOSS_VERSION 336 /* the open source release */
|
||||
#define OWNER_2_VERSION 337 /* region owners contain an alliance */
|
||||
#define FIX_WATCHERS_VERSION 338 /* fixed storage of watchers */
|
||||
|
||||
#define MIN_VERSION CURSETYPE_VERSION /* minimal datafile we support */
|
||||
#define RELEASE_VERSION OWNER_2_VERSION /* current datafile */
|
||||
#define RELEASE_VERSION FIX_WATCHERS_VERSION /* current datafile */
|
||||
|
|
Loading…
Reference in New Issue