forked from github/server
save the faction.max_spelllevel in the data file, do not recalculate it each time.
when recalculating it, include spellbook to determine max-level (dead mages may have pushed the level up).
This commit is contained in:
parent
57bb4a49f1
commit
e6eb53c864
|
@ -1,3 +1,3 @@
|
||||||
#define VERSION_MAJOR 3
|
#define VERSION_MAJOR 3
|
||||||
#define VERSION_MINOR 5
|
#define VERSION_MINOR 5
|
||||||
#define VERSION_BUILD 4
|
#define VERSION_BUILD 5
|
||||||
|
|
|
@ -1165,6 +1165,9 @@ faction *readfaction(struct gamedata * data)
|
||||||
}
|
}
|
||||||
READ_INT(data->store, &f->subscription);
|
READ_INT(data->store, &f->subscription);
|
||||||
|
|
||||||
|
if (data->version >= SPELL_LEVEL_VERSION) {
|
||||||
|
READ_INT(data->store, &f->max_spelllevel);
|
||||||
|
}
|
||||||
if (alliances || data->version >= OWNER_2_VERSION) {
|
if (alliances || data->version >= OWNER_2_VERSION) {
|
||||||
int allianceid;
|
int allianceid;
|
||||||
READ_INT(data->store, &allianceid);
|
READ_INT(data->store, &allianceid);
|
||||||
|
@ -1294,6 +1297,9 @@ void writefaction(struct gamedata *data, const faction * f)
|
||||||
|
|
||||||
write_faction_reference(f, data->store);
|
write_faction_reference(f, data->store);
|
||||||
WRITE_INT(data->store, f->subscription);
|
WRITE_INT(data->store, f->subscription);
|
||||||
|
#if RELEASE_VERSION >= SPELL_LEVEL_VERSION
|
||||||
|
WRITE_INT(data->store, f->max_spelllevel);
|
||||||
|
#endif
|
||||||
if (f->alliance) {
|
if (f->alliance) {
|
||||||
WRITE_INT(data->store, f->alliance->id);
|
WRITE_INT(data->store, f->alliance->id);
|
||||||
if (f->alliance->flags & ALF_NON_ALLIED) {
|
if (f->alliance->flags & ALF_NON_ALLIED) {
|
||||||
|
@ -1348,6 +1354,14 @@ void writefaction(struct gamedata *data, const faction * f)
|
||||||
write_spellbook(f->spellbook, data->store);
|
write_spellbook(f->spellbook, data->store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cb_sb_maxlevel(spellbook_entry *sbe, void *cbdata) {
|
||||||
|
faction *f = (faction *)cbdata;
|
||||||
|
if (sbe->level > f->max_spelllevel) {
|
||||||
|
f->max_spelllevel = sbe->level;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int readgame(const char *filename, int backup)
|
int readgame(const char *filename, int backup)
|
||||||
{
|
{
|
||||||
int n, p, nread;
|
int n, p, nread;
|
||||||
|
@ -1648,6 +1662,7 @@ int readgame(const char *filename, int backup)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (u = f->units; u; u = u->nextF) {
|
for (u = f->units; u; u = u->nextF) {
|
||||||
|
if (global.data_version < SPELL_LEVEL_VERSION) {
|
||||||
sc_mage *mage = get_mage(u);
|
sc_mage *mage = get_mage(u);
|
||||||
if (mage) {
|
if (mage) {
|
||||||
faction *f = u->faction;
|
faction *f = u->faction;
|
||||||
|
@ -1663,12 +1678,18 @@ int readgame(const char *filename, int backup)
|
||||||
mage->spellcount = 0;
|
mage->spellcount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (u->number > 0) {
|
if (u->number > 0) {
|
||||||
f->alive = true;
|
f->alive = true;
|
||||||
|
if (global.data_version >= SPELL_LEVEL_VERSION) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (global.data_version < SPELL_LEVEL_VERSION) {
|
||||||
|
spellbook_foreach(f->spellbook, cb_sb_maxlevel, f);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (loadplane || maxregions >= 0) {
|
if (loadplane || maxregions >= 0) {
|
||||||
remove_empty_factions();
|
remove_empty_factions();
|
||||||
|
|
|
@ -30,8 +30,9 @@
|
||||||
#define AUTO_RACENAME_VERSION 345 /* NPC units with name==NULL will automatically get their race for a name */
|
#define AUTO_RACENAME_VERSION 345 /* NPC units with name==NULL will automatically get their race for a name */
|
||||||
#define JSON_REPORT_VERSION 346 /* bit 3 in f->options flags the json report */
|
#define JSON_REPORT_VERSION 346 /* bit 3 in f->options flags the json report */
|
||||||
#define EXPLICIT_CURSE_ISNEW_VERSION 347 /* CURSE_ISNEW is not reset in read/write, but in age() */
|
#define EXPLICIT_CURSE_ISNEW_VERSION 347 /* CURSE_ISNEW is not reset in read/write, but in age() */
|
||||||
|
#define SPELL_LEVEL_VERSION 348 /* f->max_spelllevel gets stored, not calculated */
|
||||||
|
|
||||||
#define RELEASE_VERSION EXPLICIT_CURSE_ISNEW_VERSION /* current datafile */
|
#define RELEASE_VERSION SPELL_LEVEL_VERSION /* current datafile */
|
||||||
#define MIN_VERSION INTPAK_VERSION /* minimal datafile we support */
|
#define MIN_VERSION INTPAK_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 */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue