Merge pull request #510 from ennorehling/develop

Bugfix at_keys
This commit is contained in:
Enno Rehling 2016-05-28 20:29:58 +02:00
commit a313d87c00
3 changed files with 17 additions and 14 deletions

View File

@ -585,12 +585,24 @@ writeorder(struct gamedata *data, const struct order *ord,
} }
int read_attribs(gamedata *data, attrib **alist, void *owner) { int read_attribs(gamedata *data, attrib **alist, void *owner) {
int result;
if (data->version < ATHASH_VERSION) { if (data->version < ATHASH_VERSION) {
return a_read_orig(data, alist, owner); result = a_read_orig(data, alist, owner);
} }
else { else {
return a_read(data, alist, owner); result = a_read(data, alist, owner);
} }
if (result == AT_READ_DEPR) {
/* handle deprecated attributes */
attrib *a = *alist;
while (a) {
if (a->type->upgrade) {
a->type->upgrade(alist, a);
}
a = a->nexttype;
}
}
return result;
} }
void write_attribs(storage *store, attrib *alist, const void *owner) void write_attribs(storage *store, attrib *alist, const void *owner)

View File

@ -29,6 +29,7 @@
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/plane.h> #include <kernel/plane.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/save.h>
#include <kernel/terrain.h> #include <kernel/terrain.h>
#include <kernel/terrainid.h> #include <kernel/terrainid.h>
#include <kernel/unit.h> #include <kernel/unit.h>
@ -48,7 +49,7 @@
static int read_permissions(attrib * a, void *owner, struct gamedata *data) static int read_permissions(attrib * a, void *owner, struct gamedata *data)
{ {
assert(!a); assert(!a);
a_read(data, &a, owner); read_attribs(data, &a, owner);
a_remove(&a, a); a_remove(&a, a);
return AT_READ_OK; return AT_READ_OK;
} }

View File

@ -350,17 +350,7 @@ int a_read(gamedata *data, attrib ** attribs, void *owner) {
} }
READ_INT(store, &key); READ_INT(store, &key);
} }
if (retval == AT_READ_DEPR) { return retval;
/* handle deprecated attributes */
attrib *a = *attribs;
while (a) {
if (a->type->upgrade) {
a->type->upgrade(attribs, a);
}
a = a->nexttype;
}
}
return AT_READ_OK;
} }
int a_read_orig(gamedata *data, attrib ** attribs, void *owner) int a_read_orig(gamedata *data, attrib ** attribs, void *owner)