From d492487a5b968674aad2f518baa13dfbc590f476 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 12 Dec 2014 22:52:23 +0100 Subject: [PATCH] remove support for versions prior to turn 572 (INTPAK_VERSION). reading anything prior stopped working some time ago, let's not kid ourselves. nobody needs to read those datafiles, they are more than 7 years old. less code is better. if access to these files is needed, check out an old version from source control. --- src/building_action.c | 22 ++----- src/kernel/curse.c | 7 +-- src/kernel/group.c | 2 - src/kernel/save.c | 139 +++++++++--------------------------------- src/kernel/version.h | 36 ----------- src/magic.c | 43 ++++--------- src/spells/borders.c | 11 +--- src/vortex.c | 33 ++-------- 8 files changed, 54 insertions(+), 239 deletions(-) diff --git a/src/building_action.c b/src/building_action.c index a0656773e..bcddbec8c 100644 --- a/src/building_action.c +++ b/src/building_action.c @@ -104,12 +104,7 @@ static int lc_read(struct attrib *a, void *owner, struct storage *store) building_action *data = (building_action *)a->data.v; int result = read_reference(&data->b, store, read_building_reference, resolve_building); - if (global.data_version < UNICODE_VERSION) { - READ_STR(store, name, sizeof(name)); - } - else { - READ_TOK(store, name, sizeof(name)); - } + READ_TOK(store, name, sizeof(name)); if (strcmp(name, "tunnel_action") == 0) { /* E2: Weltentor has a new module, doesn't need this any longer */ result = 0; @@ -119,16 +114,11 @@ static int lc_read(struct attrib *a, void *owner, struct storage *store) data->fname = _strdup(name); } if (global.data_version >= BACTION_VERSION) { - if (global.data_version < UNICODE_VERSION) { - READ_STR(store, name, sizeof(name)); - } - else { - READ_TOK(store, name, sizeof(name)); - if (strcmp(name, "tnnL") == 0) { - /* tunnel_action was the old Weltentore, their code has changed. ignore this object */ - result = 0; - data->b = 0; - } + READ_TOK(store, name, sizeof(name)); + if (strcmp(name, "tnnL") == 0) { + /* tunnel_action was the old Weltentore, their code has changed. ignore this object */ + result = 0; + data->b = 0; } if (strcmp(name, NULLSTRING) == 0) data->param = 0; diff --git a/src/kernel/curse.c b/src/kernel/curse.c index fb807b125..d80e93da5 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -226,12 +226,7 @@ int curse_read(attrib * a, void *owner, struct storage *store) assert(result == 0); return AT_READ_FAIL; } - if (global.data_version < CURSEFLAGS_VERSION) { - c_setflag(c, flags); - } - else { - c->flags = flags; - } + c->flags = flags; c_clearflag(c, CURSE_ISNEW); if (c->type->read) diff --git a/src/kernel/group.c b/src/kernel/group.c index 402ebe9a3..36464454d 100755 --- a/src/kernel/group.c +++ b/src/kernel/group.c @@ -236,8 +236,6 @@ void read_groups(struct storage *store, faction * f) READ_INT(store, &fid.i); if (fid.i <= 0) break; - if (global.data_version < STORAGE_VERSION && fid.i == 0) - break; a = ally_add(pa, findfaction(fid.i)); READ_INT(store, &a->status); if (!a->faction) diff --git a/src/kernel/save.c b/src/kernel/save.c index 9b6f23e12..c9ae37e98 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -645,36 +645,10 @@ unit *read_unit(struct gamedata *data) READ_INT(data->store, &n); u->age = (short)n; - if (data->version < STORAGE_VERSION) { - char *space; - READ_STR(data->store, rname, sizeof(rname)); - space = strchr(rname, ' '); - if (space != NULL) { - char *inc = space + 1; - char *outc = space; - do { - while (*inc == ' ') - ++inc; - while (*inc) { - *outc++ = *inc++; - if (*inc == ' ') - break; - } - } while (*inc); - *outc = 0; - } - } - else { - READ_TOK(data->store, rname, sizeof(rname)); - } + READ_TOK(data->store, rname, sizeof(rname)); u_setrace(u, rc_find(rname)); - if (data->version < STORAGE_VERSION) { - READ_STR(data->store, rname, sizeof(rname)); - } - else { - READ_TOK(data->store, rname, sizeof(rname)); - } + READ_TOK(data->store, rname, sizeof(rname)); if (rname[0] && skill_enabled(SK_STEALTH)) u->irace = rc_find(rname); else @@ -869,13 +843,11 @@ static region *readregion(struct gamedata *data, int x, int y) { region *r = findregion(x, y); const terrain_type *terrain; - char token[32]; + char name[NAMESIZE]; int uid = 0; int n; - if (data->version >= UID_VERSION) { - READ_INT(data->store, &uid); - } + READ_INT(data->store, &uid); if (r == NULL) { plane *pl = findplane(x, y); @@ -906,23 +878,11 @@ static region *readregion(struct gamedata *data, int x, int y) region_setinfo(r, info); } - if (data->version < TERRAIN_VERSION) { - int ter; - READ_INT(data->store, &ter); - terrain = newterrain((terrain_t)ter); - if (terrain == NULL) { - log_error("while reading datafile from pre-TERRAIN_VERSION, could not find terrain #%d.\n", ter); - terrain = newterrain(T_PLAIN); - } - } - else { - char name[64]; - READ_STR(data->store, name, sizeof(name)); - terrain = get_terrain(name); - if (terrain == NULL) { - log_error("Unknown terrain '%s'\n", name); - assert(!"unknown terrain"); - } + READ_STR(data->store, name, sizeof(name)); + terrain = get_terrain(name); + if (terrain == NULL) { + log_error("Unknown terrain '%s'\n", name); + assert(!"unknown terrain"); } r->terrain = terrain; READ_INT(data->store, &r->flags); @@ -930,7 +890,6 @@ static region *readregion(struct gamedata *data, int x, int y) r->age = (unsigned short)n; if (fval(r->terrain, LAND_REGION)) { - char name[NAMESIZE]; r->land = calloc(1, sizeof(land_region)); READ_STR(data->store, name, sizeof(name)); r->land->name = _strdup(name); @@ -963,13 +922,13 @@ static region *readregion(struct gamedata *data, int x, int y) assert(*pres == NULL); for (;;) { rawmaterial *res; - READ_STR(data->store, token, sizeof(token)); - if (strcmp(token, "end") == 0) + READ_STR(data->store, name, sizeof(name)); + if (strcmp(name, "end") == 0) break; res = malloc(sizeof(rawmaterial)); - res->type = rmt_find(token); + res->type = rmt_find(name); if (res->type == NULL) { - log_error("invalid resourcetype %s in data.\n", token); + log_error("invalid resourcetype %s in data.\n", name); } assert(res->type != NULL); READ_INT(data->store, &n); @@ -990,9 +949,9 @@ static region *readregion(struct gamedata *data, int x, int y) } *pres = NULL; - READ_STR(data->store, token, sizeof(token)); - if (strcmp(token, "noherb") != 0) { - const resource_type *rtype = rt_find(token); + READ_STR(data->store, name, sizeof(name)); + if (strcmp(name, "noherb") != 0) { + const resource_type *rtype = rt_find(name); assert(rtype && rtype->itype && fval(rtype->itype, ITF_HERB)); rsetherbtype(r, rtype->itype); } @@ -1016,17 +975,15 @@ static region *readregion(struct gamedata *data, int x, int y) int n; for (;;) { const struct resource_type *rtype; - READ_STR(data->store, token, sizeof(token)); - if (!strcmp(token, "end")) + READ_STR(data->store, name, sizeof(name)); + if (!strcmp(name, "end")) break; - rtype = rt_find(token); + rtype = rt_find(name); assert(rtype && rtype->ltype); READ_INT(data->store, &n); r_setdemand(r, rtype->ltype, n); } - if (data->version >= REGIONITEMS_VERSION) { - read_items(data->store, &r->land->items); - } + read_items(data->store, &r->land->items); if (data->version >= REGIONOWNER_VERSION) { READ_INT(data->store, &n); r->land->morale = (short)n; @@ -1088,10 +1045,8 @@ void writeregion(struct gamedata *data, const region * r) WRITE_INT(data->store, demand->value); } WRITE_TOK(data->store, "end"); -#if RELEASE_VERSION>=REGIONITEMS_VERSION write_items(data->store, r->land->items); WRITE_SECTION(data->store); -#endif #if RELEASE_VERSION>=REGIONOWNER_VERSION WRITE_INT(data->store, r->land->morale); write_owner(data, r->land->ownership); @@ -1163,24 +1118,13 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co char spname[64]; int level = 0; - if (global.data_version < SPELLNAME_VERSION) { - int i; - READ_INT(store, &i); - if (i < 0) - break; - if (bookp) { - sp = find_spellbyid((unsigned int)i); - } - } - else { - READ_TOK(store, spname, sizeof(spname)); - if (strcmp(spname, "end") == 0) - break; - if (bookp) { - sp = find_spell(spname); - if (!sp) { - log_error("read_spells: could not find spell '%s'\n", spname); - } + READ_TOK(store, spname, sizeof(spname)); + if (strcmp(spname, "end") == 0) + break; + if (bookp) { + sp = find_spell(spname); + if (!sp) { + log_error("read_spells: could not find spell '%s'\n", spname); } } if (global.data_version >= SPELLBOOK_VERSION) { @@ -1355,15 +1299,7 @@ faction *readfaction(struct gamedata * data) else { for (;;) { int aid = 0; - if (data->version < STORAGE_VERSION) { - READ_TOK(data->store, name, sizeof(name)); - if (strcmp(name, "end") != 0) { - aid = atoi36(name); - } - } - else { - READ_INT(data->store, &aid); - } + READ_INT(data->store, &aid); if (aid > 0) { int state; READ_INT(data->store, &state); @@ -1445,7 +1381,7 @@ void writefaction(struct gamedata *data, const faction * f) int readgame(const char *filename, int backup) { - int i, n, p, nread; + int n, p, nread; faction *f, **fp; region *r; building *b, **bp; @@ -1594,14 +1530,6 @@ int readgame(const char *filename, int backup) } *fp = 0; - /* ignore the obsolete list of "used" faction ids */ - if (gdata.version < STORAGE_VERSION) { - READ_INT(&store, &i); - while (i--) { - READ_INT(&store, &n); - } - } - /* Regionen */ READ_INT(&store, &nread); @@ -1975,9 +1903,6 @@ void a_writeint(const attrib * a, const void *owner, struct storage *store) int a_readshorts(attrib * a, void *owner, struct storage *store) { int n; - if (global.data_version < ATTRIBREAD_VERSION) { - return a_readint(a, store, owner); - } READ_INT(store, &n); a->data.sa[0] = (short)n; READ_INT(store, &n); @@ -1994,9 +1919,6 @@ void a_writeshorts(const attrib * a, const void *owner, struct storage *store) int a_readchars(attrib * a, void *owner, struct storage *store) { int i; - if (global.data_version < ATTRIBREAD_VERSION) { - return a_readint(a, store, owner); - } for (i = 0; i != 4; ++i) { int n; READ_INT(store, &n); @@ -2016,9 +1938,6 @@ void a_writechars(const attrib * a, const void *owner, struct storage *store) int a_readvoid(attrib * a, void *owner, struct storage *store) { - if (global.data_version < ATTRIBREAD_VERSION) { - return a_readint(a, store, owner); - } return AT_READ_OK; } diff --git a/src/kernel/version.h b/src/kernel/version.h index e92d23aa6..5287e527c 100644 --- a/src/kernel/version.h +++ b/src/kernel/version.h @@ -10,34 +10,6 @@ without prior permission by the authors of Eressea. */ - -/* changes from->to: 72->73: struct unit::lock entfernt. - * 73->74: struct unit::flags eingeführt. - * 74->75: parteitarnung als flag. - * 75->76: #ifdef NEW_HP: hp - * 76->77: ship->damage - * 77->78: neue Message-Option "Orkvermehrung" (MAX_MSG +1) - * 78->79: showdata nicht mehr speichern - * 79->HEX_VERSION: hex - * 80->82: ATTRIB_VERSION - * 90: Ebenen - * 92: Magiegebiet-Auswahl f->magiegebiet - * 94: f->attribs wird gespeichert - * 100: NEWMAGIC, neue Message-Option "Zauber" (MAX_MSG +1) - * 108: Speichern von Timeouts - * 193: curse bekommen id aus struct unit-nummernraum - */ - -/* -#define HEX_VERSION 81 -#define GROWTREE_VERSION 305 -#define RANDOMIZED_RESOURCES_VERSION 306 -#define NEWRACE_VERSION 307 -#define INTERIM_VERSION 309 -#define NEWSKILL_VERSION 309 -#define WATCHERS_VERSION 310 -#define OVERRIDE_VERSION 311 -*/ #define CURSETYPE_VERSION 312 /* turn 287 */ #define ALLIANCES_VERSION 313 #define DBLINK_VERSION 314 @@ -48,14 +20,6 @@ /* 319 is the HSE4 data version */ #define BACTION_VERSION 319 /* building action gets a param string */ #define NOLASTORDER_VERSION 320 /* do not use lastorder */ -#define SPELLNAME_VERSION 321 /* reference spells by name */ -#define TERRAIN_VERSION 322 /* terrains are a full type and saved by name */ -#define REGIONITEMS_VERSION 323 /* regions have items */ -#define ATTRIBREAD_VERSION 324 /* remove a_readint */ -#define CURSEFLAGS_VERSION 325 /* remove a_readint */ -#define UNICODE_VERSION 326 /* 2007-06-27 everything is stored as UTF8 */ -#define UID_VERSION 327 /* regions have a unique id */ -#define STORAGE_VERSION 328 /* with storage.h, some things are stored smarter (ids as base36, fractions as float) */ #define INTPAK_VERSION 329 /* in binary, ints can get packed */ #define NOZEROIDS_VERSION 330 /* 2008-05-16 zero is not a valid ID for anything (including factions) */ #define NOBORDERATTRIBS_VERSION 331 /* 2008-05-17 connection::attribs has been moved to userdata */ diff --git a/src/magic.c b/src/magic.c index f31d6afb5..d59503def 100644 --- a/src/magic.c +++ b/src/magic.c @@ -229,21 +229,12 @@ struct storage *store) spell *sp; char spname[64]; - if (global.data_version < SPELLNAME_VERSION) { - int i; - READ_INT(store, &i); - if (i < 0) - break; - sp = find_spellbyid((unsigned int)i); - } - else { - READ_TOK(store, spname, sizeof(spname)); - if (strcmp(spname, "end") == 0) - break; - sp = find_spell(spname); - if (!sp) { - log_error("read_spells: could not find spell '%s' in school '%s'\n", spname, magic_school[mtype]); - } + READ_TOK(store, spname, sizeof(spname)); + if (strcmp(spname, "end") == 0) + break; + sp = find_spell(spname); + if (!sp) { + log_error("read_spells: could not find spell '%s' in school '%s'\n", spname, magic_school[mtype]); } if (sp) { add_spell(slistp, sp); @@ -272,23 +263,13 @@ static int read_mage(attrib * a, void *owner, struct storage *store) for (i = 0; i != MAXCOMBATSPELLS; ++i) { spell *sp = NULL; int level = 0; - if (global.data_version < SPELLNAME_VERSION) { - int spid; - READ_INT(store, &spid); - READ_INT(store, &level); - if (spid >= 0) { - sp = find_spellbyid((unsigned int)spid); - } - } - else { - READ_TOK(store, spname, sizeof(spname)); - READ_INT(store, &level); + READ_TOK(store, spname, sizeof(spname)); + READ_INT(store, &level); - if (strcmp("none", spname) != 0) { - sp = find_spell(spname); - if (!sp) { - log_error("read_mage: could not find combat spell '%s' in school '%s'\n", spname, magic_school[mage->magietyp]); - } + if (strcmp("none", spname) != 0) { + sp = find_spell(spname); + if (!sp) { + log_error("read_mage: could not find combat spell '%s' in school '%s'\n", spname, magic_school[mage->magietyp]); } } if (sp && level >= 0) { diff --git a/src/spells/borders.c b/src/spells/borders.c index ec64d8692..41eca0bd1 100644 --- a/src/spells/borders.c +++ b/src/spells/borders.c @@ -174,17 +174,8 @@ static void wall_read(connection * b, storage * store) { static wall_data dummy; wall_data *fd = b->data.v ? (wall_data *) b->data.v : &dummy; - variant mno; - if (global.data_version < STORAGE_VERSION) { - READ_INT(store, &mno.i); - fd->mage = findunit(mno.i); - if (!fd->mage && b->data.v) { - ur_add(mno, &fd->mage, resolve_unit); - } - } else { - read_reference(&fd->mage, store, read_unit_reference, resolve_unit); - } + read_reference(&fd->mage, store, read_unit_reference, resolve_unit); READ_INT(store, &fd->force); if (global.data_version >= NOBORDERATTRIBS_VERSION) { READ_INT(store, &fd->countdown); diff --git a/src/vortex.c b/src/vortex.c index f9993a561..a44b90172 100644 --- a/src/vortex.c +++ b/src/vortex.c @@ -74,39 +74,16 @@ static int a_agedirection(attrib * a) static int a_readdirection(attrib * a, void *owner, struct storage *store) { spec_direction *d = (spec_direction *)(a->data.v); + char lbuf[32]; (void) owner; READ_INT(store, &d->x); READ_INT(store, &d->y); READ_INT(store, &d->duration); - if (global.data_version < UNICODE_VERSION) { - char lbuf[16]; - dir_lookup *dl = dir_name_lookup; - - READ_TOK(store, NULL, 0); - READ_TOK(store, lbuf, sizeof(lbuf)); - - untilde(lbuf); - for (; dl; dl = dl->next) { - if (strcmp(lbuf, dl->oldname) == 0) { - d->keyword = _strdup(dl->name); - _snprintf(lbuf, sizeof(lbuf), "%s_desc", d->keyword); - d->desc = _strdup(dl->name); - break; - } - } - if (dl == NULL) { - log_error("unknown spec_direction '%s'\n", lbuf); - assert(!"not implemented"); - } - } - else { - char lbuf[32]; - READ_TOK(store, lbuf, sizeof(lbuf)); - d->desc = _strdup(lbuf); - READ_TOK(store, lbuf, sizeof(lbuf)); - d->keyword = _strdup(lbuf); - } + READ_TOK(store, lbuf, sizeof(lbuf)); + d->desc = _strdup(lbuf); + READ_TOK(store, lbuf, sizeof(lbuf)); + d->keyword = _strdup(lbuf); d->active = true; return AT_READ_OK; }