forked from github/server
support code for reading data files with old curses
This commit is contained in:
parent
43b0ff2ce3
commit
577601f912
2 changed files with 47 additions and 12 deletions
|
@ -155,6 +155,32 @@ curse_done(attrib * a) {
|
||||||
destroy_curse((curse *)a->data.v);
|
destroy_curse((curse *)a->data.v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** reads curses that have been removed from the code */
|
||||||
|
static int
|
||||||
|
read_ccompat(const char * cursename, struct storage * store)
|
||||||
|
{
|
||||||
|
struct compat {
|
||||||
|
const char * name;
|
||||||
|
const char * tokens;
|
||||||
|
} * seek, old_curses[] = { {"disorientationzone", ""}, {"shipdisorientation", ""}, { NULL, NULL } } ;
|
||||||
|
for (seek=old_curses;seek->name;++seek) {
|
||||||
|
if (strcmp(seek->name, cursename)==0) {
|
||||||
|
const char * p;
|
||||||
|
for (p=seek->name;p;++p) {
|
||||||
|
switch (*p) {
|
||||||
|
case 'd': store->r_int(store); break;
|
||||||
|
case 's': store->r_str(store); break;
|
||||||
|
case 't': store->r_tok(store); break;
|
||||||
|
case 'i': store->r_id(store); break;
|
||||||
|
case 'f': store->r_flt(store); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
curse_read(attrib * a, struct storage * store)
|
curse_read(attrib * a, struct storage * store)
|
||||||
{
|
{
|
||||||
|
@ -182,7 +208,13 @@ curse_read(attrib * a, struct storage * store)
|
||||||
}
|
}
|
||||||
c->effect.i = store->r_int(store);
|
c->effect.i = store->r_int(store);
|
||||||
ct = ct_find(cursename);
|
ct = ct_find(cursename);
|
||||||
assert(ct!=NULL);
|
if (ct==NULL) {
|
||||||
|
int result = read_ccompat(cursename, store);
|
||||||
|
if (result!=0) {
|
||||||
|
log_error(("missing curse %s, no compatibility code either.\n", cursename));
|
||||||
|
}
|
||||||
|
assert(result!=0);
|
||||||
|
}
|
||||||
c->type = ct;
|
c->type = ct;
|
||||||
|
|
||||||
if (store->version < CURSEFLAGS_VERSION) {
|
if (store->version < CURSEFLAGS_VERSION) {
|
||||||
|
@ -192,17 +224,19 @@ curse_read(attrib * a, struct storage * store)
|
||||||
}
|
}
|
||||||
c_clearflag(c, CURSE_ISNEW);
|
c_clearflag(c, CURSE_ISNEW);
|
||||||
|
|
||||||
if (c->type->read) c->type->read(store, c);
|
if (c->type) {
|
||||||
else if (c->type->typ==CURSETYP_UNIT) {
|
if (c->type->read) c->type->read(store, c);
|
||||||
curse_unit * cc = calloc(1, sizeof(curse_unit));
|
else if (c->type->typ==CURSETYP_UNIT) {
|
||||||
|
curse_unit * cc = calloc(1, sizeof(curse_unit));
|
||||||
|
|
||||||
c->data.v = cc;
|
c->data.v = cc;
|
||||||
cc->cursedmen = store->r_int(store);
|
cc->cursedmen = store->r_int(store);
|
||||||
}
|
}
|
||||||
if (c->type->typ == CURSETYP_REGION) {
|
if (c->type->typ == CURSETYP_REGION) {
|
||||||
int rr = read_reference(&c->data.v, store, read_region_reference, RESOLVE_REGION(store->version));
|
int rr = read_reference(&c->data.v, store, read_region_reference, RESOLVE_REGION(store->version));
|
||||||
if (ur==0 && rr==0 && !c->data.v) {
|
if (ur==0 && rr==0 && !c->data.v) {
|
||||||
return AT_READ_FAIL;
|
return AT_READ_FAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,6 +728,7 @@ resolve_curse(variant id, void * address)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * oldnames[MAXCURSE] = {
|
static const char * oldnames[MAXCURSE] = {
|
||||||
|
/* OBS: when removing curses, remember to update read_ccompat() */
|
||||||
"fogtrap",
|
"fogtrap",
|
||||||
"antimagiczone",
|
"antimagiczone",
|
||||||
"farvision",
|
"farvision",
|
||||||
|
|
|
@ -134,7 +134,7 @@ enum {
|
||||||
C_SPARKLE,
|
C_SPARKLE,
|
||||||
/* struct's vom untertyp curse_skill: */
|
/* struct's vom untertyp curse_skill: */
|
||||||
C_SKILL,
|
C_SKILL,
|
||||||
MAXCURSE
|
MAXCURSE /* OBS: when removing curses, remember to update read_ccompat() */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
Loading…
Reference in a new issue