forked from github/server
remove spellbook repair code, we are done
This commit is contained in:
parent
ecd023f7ac
commit
1641e6ef89
|
@ -100,7 +100,6 @@
|
||||||
<param name="magic.power" value="0.5"/>
|
<param name="magic.power" value="0.5"/>
|
||||||
<param name="resource.factor" value="0.25"/>
|
<param name="resource.factor" value="0.25"/>
|
||||||
|
|
||||||
<param name="fix.spells" value="319"/>
|
|
||||||
<param name="skills.cost.tactics" value="500"/>
|
<param name="skills.cost.tactics" value="500"/>
|
||||||
<param name="entertain.base" value="0"/>
|
<param name="entertain.base" value="0"/>
|
||||||
<param name="entertain.perlevel" value="20"/>
|
<param name="entertain.perlevel" value="20"/>
|
||||||
|
|
|
@ -101,7 +101,6 @@
|
||||||
<param name="magic.power" value="0.5"/>
|
<param name="magic.power" value="0.5"/>
|
||||||
<param name="resource.factor" value="0.25"/>
|
<param name="resource.factor" value="0.25"/>
|
||||||
|
|
||||||
<param name="fix.spells" value="67"/>
|
|
||||||
<param name="skills.cost.tactics" value="500"/>
|
<param name="skills.cost.tactics" value="500"/>
|
||||||
<param name="entertain.base" value="0"/>
|
<param name="entertain.base" value="0"/>
|
||||||
<param name="entertain.perlevel" value="20"/>
|
<param name="entertain.perlevel" value="20"/>
|
||||||
|
|
|
@ -64,7 +64,6 @@ ENDIF()
|
||||||
|
|
||||||
set (ERESSEA_SRC
|
set (ERESSEA_SRC
|
||||||
move.c
|
move.c
|
||||||
repair.c
|
|
||||||
spells.c
|
spells.c
|
||||||
battle.c
|
battle.c
|
||||||
alchemy.c
|
alchemy.c
|
||||||
|
|
|
@ -48,7 +48,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "unit.h"
|
#include "unit.h"
|
||||||
#include "lighthouse.h"
|
#include "lighthouse.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "repair.h"
|
|
||||||
|
|
||||||
/* attributes includes */
|
/* attributes includes */
|
||||||
#include <attributes/key.h>
|
#include <attributes/key.h>
|
||||||
|
@ -1697,10 +1696,6 @@ int readgame(const char *filename, int backup)
|
||||||
}
|
}
|
||||||
log_printf(stdout, "Done loading turn %d.\n", turn);
|
log_printf(stdout, "Done loading turn %d.\n", turn);
|
||||||
|
|
||||||
n = get_param_int(global.parameters, "fix.spells", -1);
|
|
||||||
if (n>=turn) {
|
|
||||||
repair_spells("spells.txt");
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
86
src/repair.c
86
src/repair.c
|
@ -1,86 +0,0 @@
|
||||||
#include <platform.h>
|
|
||||||
#include <kernel/config.h>
|
|
||||||
|
|
||||||
#include "repair.h"
|
|
||||||
#include <kernel/faction.h>
|
|
||||||
#include <kernel/spellbook.h>
|
|
||||||
|
|
||||||
#include <util/log.h>
|
|
||||||
#include <util/base36.h>
|
|
||||||
|
|
||||||
#include <quicklist.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
static void write_spellbook_states(FILE *F) {
|
|
||||||
faction *f;
|
|
||||||
for (f = factions; f; f = f->next) {
|
|
||||||
spellbook *sb = f->spellbook;
|
|
||||||
int len = sb ? ql_length(sb->spells) : 0;
|
|
||||||
fprintf(F, "%s %d %d\n", itoa36(f->no), f->subscription, len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void limit_spellbook(faction *f, int num) {
|
|
||||||
spellbook *sb = f->spellbook;
|
|
||||||
int len = sb ? ql_length(sb->spells) : 0;
|
|
||||||
if (len < num) {
|
|
||||||
log_error("limit_spellbook: spellbook is shorter than expected, %d < %d", len, num);
|
|
||||||
}
|
|
||||||
// delete spells backwards from the end:
|
|
||||||
while (len > num) {
|
|
||||||
ql_delete(&sb->spells, len--);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void repair_spells(const char *filename) {
|
|
||||||
FILE *F = fopen(filename, "r");
|
|
||||||
if (F) {
|
|
||||||
char id[32];
|
|
||||||
int numspells, sub;
|
|
||||||
faction *f;
|
|
||||||
while (fscanf(F, "%s %d %d", id, &sub, &numspells) != EOF) {
|
|
||||||
int no = atoi36(id);
|
|
||||||
|
|
||||||
f = findfaction(no);
|
|
||||||
if (!f) {
|
|
||||||
for (f = factions; f; f = f->next) {
|
|
||||||
if (f->subscription == sub) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (f) {
|
|
||||||
log_info("repair_spells: faction %s renamed to %s, located by subscription %d", id, itoa36(f->no), sub);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log_warning("repair_spells: cannot fix faction %s, no such subscription: %d (%d spells)", id, sub, numspells);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (f->subscription != sub) {
|
|
||||||
log_warning("repair_spells: subscription mismatch for faction %s, %d!=%d (%d spells)", id, f->subscription, sub, numspells);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
limit_spellbook(f, numspells);
|
|
||||||
fset(f, FFL_MARK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (f = factions; f; f = f->next) {
|
|
||||||
if (!fval(f, FFL_MARK)) {
|
|
||||||
numspells = ql_length(f->spellbook->spells);
|
|
||||||
log_warning("repair_spells: faction %s did not get a spellbook fix (%d spells at level)", itoa36(f->no), numspells, f->max_spelllevel);
|
|
||||||
}
|
|
||||||
freset(f, FFL_MARK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
F = fopen(filename, "w");
|
|
||||||
if (!F) {
|
|
||||||
perror("repair_spells");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
write_spellbook_states(F);
|
|
||||||
}
|
|
||||||
fclose(F);
|
|
||||||
}
|
|
14
src/repair.h
14
src/repair.h
|
@ -1,14 +0,0 @@
|
||||||
|
|
||||||
#ifndef H_REPAIR
|
|
||||||
#define H_REPAIR
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void repair_spells(const char *filename); // one-time reduction of E3/E4 spellbooks (called at the end of readgame)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue