removing code for old versions that we no longer have datafiles for (pre-287)

This commit is contained in:
Enno Rehling 2008-05-27 07:30:04 +00:00
parent ad240fecc0
commit 43b0ff2ce3
5 changed files with 92 additions and 137 deletions

View File

@ -315,15 +315,6 @@ read_race_reference(struct storage * store)
{ {
variant result; variant result;
char zName[20]; char zName[20];
if (store->version<NEWRACE_VERSION) {
int i;
i = store->r_int(store);
if (i>=0) {
result.v = (void*)new_race[i];
} else {
result.v = NULL;
}
} else {
store->r_tok_buf(store, zName, sizeof(zName)); store->r_tok_buf(store, zName, sizeof(zName));
if (strcmp(zName, "none")==0) { if (strcmp(zName, "none")==0) {
result.v = NULL; result.v = NULL;
@ -331,6 +322,5 @@ read_race_reference(struct storage * store)
result.v = rc_find(zName); result.v = rc_find(zName);
assert(result.v!=NULL); assert(result.v!=NULL);
} }
}
return result; return result;
} }

View File

@ -649,6 +649,7 @@ readunit(struct storage * store)
order ** orderp; order ** orderp;
char obuf[1024]; char obuf[1024];
faction * f; faction * f;
char rname[32];
n = store->r_id(store); n = store->r_id(store);
u = findunit(n); u = findunit(n);
@ -677,11 +678,6 @@ readunit(struct storage * store)
} }
number = store->r_int(store); number = store->r_int(store);
u->age = (short)store->r_int(store); u->age = (short)store->r_int(store);
if (store->version<NEWRACE_VERSION) {
u->race = new_race[(race_t)store->r_int(store)];
u->irace = new_race[(race_t)store->r_int(store)];
} else {
char rname[32];
if (store->version<STORAGE_VERSION) { if (store->version<STORAGE_VERSION) {
char * space; char * space;
@ -711,7 +707,7 @@ readunit(struct storage * store)
} }
if (rname[0]) u->irace = rc_find(rname); if (rname[0]) u->irace = rc_find(rname);
else u->irace = u->race; else u->irace = u->race;
}
if (u->race->describe) { if (u->race->describe) {
const char * rcdisp = u->race->describe(u, u->faction->locale); const char * rcdisp = u->race->describe(u, u->faction->locale);
if (u->display && rcdisp) { if (u->display && rcdisp) {
@ -792,22 +788,6 @@ readunit(struct storage * store)
set_order(&u->thisorder, NULL); set_order(&u->thisorder, NULL);
assert(u->race); assert(u->race);
if (store->version<NEWSKILL_VERSION) {
/* convert old data */
if (u->number) {
while ((sk = (skill_t) store->r_int(store)) != NOSKILL) {
int days = store->r_int(store) / u->number;
int lvl = level(days);
int weeks = lvl + 1 - (days - level_days(lvl))/30;
assert(weeks>0 && weeks<=lvl+1);
if (lvl) {
skill * sv = add_skill(u, sk);
sv->level = sv->old = (unsigned char)lvl;
sv->weeks = (unsigned char)weeks;
}
}
}
} else {
while ((sk = (skill_t) store->r_int(store)) != NOSKILL) { while ((sk = (skill_t) store->r_int(store)) != NOSKILL) {
int level = store->r_int(store); int level = store->r_int(store);
int weeks = store->r_int(store); int weeks = store->r_int(store);
@ -817,7 +797,6 @@ readunit(struct storage * store)
sv->weeks = (unsigned char)weeks; sv->weeks = (unsigned char)weeks;
} }
} }
}
read_items(store, &u->items); read_items(store, &u->items);
u->hp = store->r_int(store); u->hp = store->r_int(store);
if (u->hp < u->number) { if (u->hp < u->number) {
@ -955,10 +934,7 @@ readregion(struct storage * store, short x, short y)
if (r->land) { if (r->land) {
int i; int i;
rawmaterial ** pres = &r->resources; rawmaterial ** pres = &r->resources;
if (store->version < GROWTREE_VERSION) {
i = store->r_int(store);
rsettrees(r, 2, i);
} else {
i = store->r_int(store); i = store->r_int(store);
if (i<0) { if (i<0) {
log_error(("number of trees in %s is %d.\n", log_error(("number of trees in %s is %d.\n",
@ -980,7 +956,7 @@ readregion(struct storage * store, short x, short y)
i=0; i=0;
} }
rsettrees(r, 2, i); rsettrees(r, 2, i);
}
i = store->r_int(store); rsethorses(r, i); i = store->r_int(store); rsethorses(r, i);
assert(*pres==NULL); assert(*pres==NULL);
for (;;) { for (;;) {
@ -997,20 +973,9 @@ readregion(struct storage * store, short x, short y)
res->amount = store->r_int(store); res->amount = store->r_int(store);
res->flags = 0; res->flags = 0;
if(store->version >= RANDOMIZED_RESOURCES_VERSION) {
res->startlevel = store->r_int(store); res->startlevel = store->r_int(store);
res->base = store->r_int(store); res->base = store->r_int(store);
res->divisor = store->r_int(store); res->divisor = store->r_int(store);
} else {
int i;
for (i=0;r->terrain->production[i].type;++i) {
if (res->type->rtype == r->terrain->production[i].type) break;
}
res->base = dice_rand(r->terrain->production[i].base);
res->divisor = dice_rand(r->terrain->production[i].divisor);
res->startlevel = 1;
}
*pres = res; *pres = res;
pres=&res->next; pres=&res->next;
@ -1192,14 +1157,9 @@ readfaction(struct storage * store)
f->locale = find_locale(token); f->locale = find_locale(token);
f->lastorders = store->r_int(store); f->lastorders = store->r_int(store);
f->age = store->r_int(store); f->age = store->r_int(store);
if (store->version < NEWRACE_VERSION) {
race_t rc = (char) store->r_int(store);
f->race = new_race[rc];
} else {
store->r_str_buf(store, token, sizeof(token)); store->r_str_buf(store, token, sizeof(token));
f->race = rc_find(token); f->race = rc_find(token);
assert(f->race); assert(f->race);
}
f->magiegebiet = (magic_t)store->r_int(store); f->magiegebiet = (magic_t)store->r_int(store);
#if KARMA_MODULE #if KARMA_MODULE
@ -1367,7 +1327,7 @@ readgame(const char * filename, int mode, int backup)
assert(store->version>=MIN_VERSION || !"unsupported data format"); assert(store->version>=MIN_VERSION || !"unsupported data format");
assert(store->version<=RELEASE_VERSION || !"unsupported data format"); assert(store->version<=RELEASE_VERSION || !"unsupported data format");
assert(store->version >= GROWTREE_VERSION);
if (store->version >= SAVEXMLNAME_VERSION) { if (store->version >= SAVEXMLNAME_VERSION) {
char basefile[1024]; char basefile[1024];
const char *basearg = "(null)"; const char *basearg = "(null)";
@ -1411,7 +1371,8 @@ readgame(const char * filename, int mode, int backup)
pl->miny = (short)store->r_int(store); pl->miny = (short)store->r_int(store);
pl->maxy = (short)store->r_int(store); pl->maxy = (short)store->r_int(store);
pl->flags = store->r_int(store); pl->flags = store->r_int(store);
if (store->version>WATCHERS_VERSION) {
/* read watchers */
store->r_str_buf(store, token, sizeof(token)); store->r_str_buf(store, token, sizeof(token));
while (strcmp(token, "end")!=0) { while (strcmp(token, "end")!=0) {
watcher * w = calloc(sizeof(watcher),1); watcher * w = calloc(sizeof(watcher),1);
@ -1423,7 +1384,7 @@ readgame(const char * filename, int mode, int backup)
ur_add(fno, &w->faction, resolve_faction); ur_add(fno, &w->faction, resolve_faction);
store->r_str_buf(store, token, sizeof(token)); store->r_str_buf(store, token, sizeof(token));
} }
}
a_read(store, &pl->attribs); a_read(store, &pl->attribs);
addlist(&planes, pl); addlist(&planes, pl);
} }

View File

@ -133,8 +133,8 @@ enum {
K_DEFAULT, K_DEFAULT,
K_URSPRUNG, K_URSPRUNG,
K_EMAIL, K_EMAIL,
K_VOTE, K_VOTE, /* not in use */
K_MAGIEGEBIET, K_MAGIEGEBIET, /* not in use */
K_PIRACY, K_PIRACY,
K_RESTART, K_RESTART,
K_GROUP, K_GROUP,

View File

@ -28,15 +28,17 @@
* 193: curse bekommen id aus struct unit-nummernraum * 193: curse bekommen id aus struct unit-nummernraum
*/ */
/*
#define HEX_VERSION 81 #define HEX_VERSION 81
#define GROWTREE_VERSION 305 #define GROWTREE_VERSION 305
#define RANDOMIZED_RESOURCES_VERSION 306 /* should be the same, but doesn't work */ #define RANDOMIZED_RESOURCES_VERSION 306
#define NEWRACE_VERSION 307 #define NEWRACE_VERSION 307
#define INTERIM_VERSION 309 #define INTERIM_VERSION 309
#define NEWSKILL_VERSION 309 #define NEWSKILL_VERSION 309
#define WATCHERS_VERSION 310 #define WATCHERS_VERSION 310
*/
#define OVERRIDE_VERSION 311 #define OVERRIDE_VERSION 311
#define CURSETYPE_VERSION 312 #define CURSETYPE_VERSION 312 /* turn 287 */
#define ALLIANCES_VERSION 313 #define ALLIANCES_VERSION 313
#define DBLINK_VERSION 314 #define DBLINK_VERSION 314
#define CURSEVIGOURISFLOAT_VERSION 315 #define CURSEVIGOURISFLOAT_VERSION 315

View File

@ -32,7 +32,9 @@
#define M_PIl 3.1415926535897932384626433832795029L /* pi */ #define M_PIl 3.1415926535897932384626433832795029L /* pi */
/* NormalRand aus python, random.py geklaut, dort ist Referenz auf /* NormalRand aus python, random.py geklaut, dort ist Referenz auf
* den Algorithmus. mu = Mittelwert, sigma = Standardabweichung. */ * den Algorithmus. mu = Mittelwert, sigma = Standardabweichung.
* http://de.wikipedia.org/wiki/Standardabweichung#Diskrete_Gleichverteilung.2C_W.C3.BCrfel
*/
double double
normalvariate(double mu, double sigma) normalvariate(double mu, double sigma)
{ {