diff --git a/src/kernel/save.c b/src/kernel/save.c index 2dd3f54ea..2c9bf77e0 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -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) diff --git a/src/modules/gmcmd.c b/src/modules/gmcmd.c index f450cd67f..b9e1bc342 100644 --- a/src/modules/gmcmd.c +++ b/src/modules/gmcmd.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -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; } diff --git a/src/util/attrib.c b/src/util/attrib.c index 841bf9559..c22570356 100644 --- a/src/util/attrib.c +++ b/src/util/attrib.c @@ -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)