forked from github/server
2577: Fix resource values, again.
This commit is contained in:
parent
46f1d36c17
commit
8c0fc4bd91
2 changed files with 33 additions and 5 deletions
|
@ -42,8 +42,9 @@
|
||||||
#define FAMILIAR_FIXMAGE_VERSION 364 /* familiar links are fixed */
|
#define FAMILIAR_FIXMAGE_VERSION 364 /* familiar links are fixed */
|
||||||
#define FAMILIAR_FIXSPELLBOOK_VERSION 365 /* familiar spells are fixed */
|
#define FAMILIAR_FIXSPELLBOOK_VERSION 365 /* familiar spells are fixed */
|
||||||
#define FIX_STARTLEVEL_VERSION 366 /* fixing resource startlevels */
|
#define FIX_STARTLEVEL_VERSION 366 /* fixing resource startlevels */
|
||||||
|
#define FIX_RES_BASE_VERSION 367 /* fixing resource base */
|
||||||
|
|
||||||
#define RELEASE_VERSION FIX_STARTLEVEL_VERSION /* current datafile */
|
#define RELEASE_VERSION FIX_RES_BASE_VERSION /* current datafile */
|
||||||
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */
|
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */
|
||||||
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */
|
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */
|
||||||
|
|
||||||
|
|
|
@ -613,7 +613,7 @@ static void read_regioninfo(gamedata *data, const region *r, char *info, size_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fix_baselevel(region *r) {
|
static void fix_resource_levels(region *r) {
|
||||||
struct terrain_production *p;
|
struct terrain_production *p;
|
||||||
for (p = r->terrain->production; p->type; ++p) {
|
for (p = r->terrain->production; p->type; ++p) {
|
||||||
char *end;
|
char *end;
|
||||||
|
@ -634,6 +634,27 @@ static void fix_baselevel(region *r) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fix_resource_bases(region *r) {
|
||||||
|
struct terrain_production *p;
|
||||||
|
for (p = r->terrain->production; p->type; ++p) {
|
||||||
|
char *end;
|
||||||
|
long base = (int)strtol(p->base, &end, 10);
|
||||||
|
if (*end == '\0') {
|
||||||
|
rawmaterial *res;
|
||||||
|
for (res = r->resources; res; res = res->next) {
|
||||||
|
if (p->type == res->rtype) {
|
||||||
|
if (base != res->base) {
|
||||||
|
log_debug("setting resource base for %s in %s to %d",
|
||||||
|
res->rtype->_name, regionname(r, NULL), base);
|
||||||
|
res->base = base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static region *readregion(gamedata *data, int x, int y)
|
static region *readregion(gamedata *data, int x, int y)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
|
@ -803,9 +824,15 @@ static region *readregion(gamedata *data, int x, int y)
|
||||||
}
|
}
|
||||||
read_attribs(data, &r->attribs, r);
|
read_attribs(data, &r->attribs, r);
|
||||||
|
|
||||||
if (r->resources && data->version < FIX_STARTLEVEL_VERSION) {
|
if (r->resources) {
|
||||||
/* we had some badly made rawmaterials before this */
|
if (data->version < FIX_STARTLEVEL_VERSION) {
|
||||||
fix_baselevel(r);
|
/* we had some badly made rawmaterials before this */
|
||||||
|
fix_resource_levels(r);
|
||||||
|
}
|
||||||
|
if (data->version < FIX_RES_BASE_VERSION) {
|
||||||
|
/* we had some badly made rawmaterials before this */
|
||||||
|
fix_resource_bases(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue