fix deprecated attributes (at_key) yet again.
This commit is contained in:
Enno Rehling 2016-05-28 20:26:59 +02:00
parent c1b0395a6c
commit 6148273d97
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 result;
if (data->version < ATHASH_VERSION) {
return a_read_orig(data, alist, owner);
result = a_read_orig(data, alist, owner);
}
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)

View File

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

View File

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