forked from github/server
move read/write_attribs to attrib.h, too
This commit is contained in:
parent
11b122048b
commit
0eaa750ef4
5 changed files with 33 additions and 34 deletions
|
@ -24,7 +24,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "monster.h"
|
||||
|
||||
#include <kernel/ally.h>
|
||||
#include <kernel/save.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/race.h>
|
||||
|
|
|
@ -670,36 +670,6 @@ writeorder(struct gamedata *data, const struct order *ord,
|
|||
WRITE_STR(data->store, obuf);
|
||||
}
|
||||
|
||||
int read_attribs(gamedata *data, attrib **alist, void *owner) {
|
||||
int result;
|
||||
if (data->version < ATHASH_VERSION) {
|
||||
result = a_read_orig(data, alist, owner);
|
||||
}
|
||||
else {
|
||||
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)
|
||||
{
|
||||
#if RELEASE_VERSION < ATHASH_VERSION
|
||||
a_write_orig(store, alist, owner);
|
||||
#else
|
||||
a_write(store, alist, owner);
|
||||
#endif
|
||||
}
|
||||
|
||||
unit *read_unit(struct gamedata *data)
|
||||
{
|
||||
unit *u;
|
||||
|
|
|
@ -56,9 +56,6 @@ extern "C" {
|
|||
void read_spellbook(struct spellbook **bookp, struct gamedata *data, int(*get_level)(const struct spell * sp, void *), void * cbdata);
|
||||
void write_spellbook(const struct spellbook *book, struct storage *store);
|
||||
|
||||
void write_attribs(struct storage *store, struct attrib *alist, const void *owner);
|
||||
int read_attribs(struct gamedata *store, struct attrib **alist, void *owner);
|
||||
|
||||
void write_unit(struct gamedata *data, const struct unit *u);
|
||||
struct unit *read_unit(struct gamedata *data);
|
||||
|
||||
|
|
|
@ -29,6 +29,36 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int read_attribs(gamedata *data, attrib **alist, void *owner) {
|
||||
int result;
|
||||
if (data->version < ATHASH_VERSION) {
|
||||
result = a_read_orig(data, alist, owner);
|
||||
}
|
||||
else {
|
||||
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)
|
||||
{
|
||||
#if RELEASE_VERSION < ATHASH_VERSION
|
||||
a_write_orig(store, alist, owner);
|
||||
#else
|
||||
a_write(store, alist, owner);
|
||||
#endif
|
||||
}
|
||||
|
||||
int a_readint(attrib * a, void *owner, struct gamedata *data)
|
||||
{
|
||||
int n;
|
||||
|
|
|
@ -66,6 +66,9 @@ extern "C" {
|
|||
extern void at_register(attrib_type * at);
|
||||
extern void at_deprecate(const char * name, int(*reader)(attrib *, void *, struct gamedata *));
|
||||
|
||||
void write_attribs(struct storage *store, struct attrib *alist, const void *owner);
|
||||
int read_attribs(struct gamedata *store, struct attrib **alist, void *owner);
|
||||
|
||||
extern attrib *a_select(attrib * a, const void *data,
|
||||
bool(*compare) (const attrib *, const void *));
|
||||
extern attrib *a_find(attrib * a, const attrib_type * at);
|
||||
|
|
Loading…
Reference in a new issue