forked from github/server
Merge branch 'master' into develop
Conflicts: src/buildno.h src/kernel/save.c src/laws.c
This commit is contained in:
commit
dfb0bcaccf
|
@ -1170,6 +1170,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);
|
||||||
|
@ -1299,6 +1302,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) {
|
||||||
|
@ -1353,6 +1359,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, bool backup)
|
int readgame(const char *filename, bool backup)
|
||||||
{
|
{
|
||||||
int n, p, nread;
|
int n, p, nread;
|
||||||
|
@ -1653,32 +1667,40 @@ int readgame(const char *filename, bool backup)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (u = f->units; u; u = u->nextF) {
|
for (u = f->units; u; u = u->nextF) {
|
||||||
sc_mage *mage = get_mage(u);
|
if (global.data_version < SPELL_LEVEL_VERSION) {
|
||||||
if (mage) {
|
sc_mage *mage = get_mage(u);
|
||||||
faction *f = u->faction;
|
if (mage) {
|
||||||
int skl = effskill(u, SK_MAGIC);
|
faction *f = u->faction;
|
||||||
if (f->magiegebiet == M_GRAY) {
|
int skl = effskill(u, SK_MAGIC);
|
||||||
log_error("faction %s had magic=gray, fixing (%s)\n", factionname(f), magic_school[mage->magietyp]);
|
if (f->magiegebiet == M_GRAY) {
|
||||||
f->magiegebiet = mage->magietyp;
|
log_error("faction %s had magic=gray, fixing (%s)\n", factionname(f), magic_school[mage->magietyp]);
|
||||||
}
|
f->magiegebiet = mage->magietyp;
|
||||||
if (f->max_spelllevel < skl) {
|
}
|
||||||
f->max_spelllevel = skl;
|
if (f->max_spelllevel < skl) {
|
||||||
}
|
f->max_spelllevel = skl;
|
||||||
if (mage->spellcount < 0) {
|
}
|
||||||
mage->spellcount = 0;
|
if (mage->spellcount < 0) {
|
||||||
|
mage->spellcount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (u->number > 0) {
|
if (u->number > 0) {
|
||||||
f->alive = true;
|
f->alive = true;
|
||||||
break;
|
if (global.data_version >= SPELL_LEVEL_VERSION) {
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
log_printf(stdout, "Done loading turn %d.\n", turn);
|
log_printf(stdout, "Done loading turn %d.\n", turn);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 */
|
||||||
|
|
||||||
|
|
|
@ -4520,8 +4520,6 @@ void init_processor(void)
|
||||||
void processorders(void)
|
void processorders(void)
|
||||||
{
|
{
|
||||||
init_processor();
|
init_processor();
|
||||||
|
|
||||||
update_spells();
|
|
||||||
process();
|
process();
|
||||||
/*************************************************/
|
/*************************************************/
|
||||||
|
|
||||||
|
|
|
@ -465,11 +465,13 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells
|
||||||
spellno = rng_int() % maxspell;
|
spellno = rng_int() % maxspell;
|
||||||
sbe = commonspells[spellno];
|
sbe = commonspells[spellno];
|
||||||
if (sbe->level > f->max_spelllevel) {
|
if (sbe->level > f->max_spelllevel) {
|
||||||
|
// not going to pick it in this round, move it to the end for later
|
||||||
commonspells[spellno] = commonspells[--maxspell];
|
commonspells[spellno] = commonspells[--maxspell];
|
||||||
commonspells[maxspell] = sbe;
|
commonspells[maxspell] = sbe;
|
||||||
sbe = 0;
|
sbe = 0;
|
||||||
}
|
}
|
||||||
else if (f->spellbook && spellbook_get(f->spellbook, sbe->sp)) {
|
else if (f->spellbook && spellbook_get(f->spellbook, sbe->sp)) {
|
||||||
|
// already have this spell, remove it from the list of candidates
|
||||||
commonspells[spellno] = commonspells[--numspells];
|
commonspells[spellno] = commonspells[--numspells];
|
||||||
if (maxspell > numspells) {
|
if (maxspell > numspells) {
|
||||||
maxspell = numspells;
|
maxspell = numspells;
|
||||||
|
|
Loading…
Reference in New Issue