Merge pull request #848 from ennorehling/master

2577: Fix resource values, again.
This commit is contained in:
Enno Rehling 2019-04-30 19:00:34 +02:00 committed by GitHub
commit 6b93acec08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 6 deletions

View File

@ -6,7 +6,7 @@ cd Debug
make clean
../../coverity/bin/cov-build --dir cov-int make eressea
tar czf eressea.tgz cov-int
curl --form token=IISXKH3A1ngZGfFmBz_aSA \
curl -k --form token=IISXKH3A1ngZGfFmBz_aSA \
--form email=enno.rehling@gmail.com \
--form file=@eressea.tgz \
--form version="$VERSION" \

View File

@ -42,8 +42,9 @@
#define FAMILIAR_FIXMAGE_VERSION 364 /* familiar links are fixed */
#define FAMILIAR_FIXSPELLBOOK_VERSION 365 /* familiar spells are fixed */
#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 MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */

View File

@ -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;
for (p = r->terrain->production; p->type; ++p) {
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)
{
region *r;
@ -803,9 +824,15 @@ static region *readregion(gamedata *data, int x, int y)
}
read_attribs(data, &r->attribs, r);
if (r->resources && data->version < FIX_STARTLEVEL_VERSION) {
if (r->resources) {
if (data->version < FIX_STARTLEVEL_VERSION) {
/* we had some badly made rawmaterials before this */
fix_baselevel(r);
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;
}