forked from github/server
on a hunch, checking that number of mages is correct. Also, removing invalid familiars.
This commit is contained in:
parent
64ca5c666e
commit
2f8e9e2053
3 changed files with 1104 additions and 1074 deletions
|
@ -504,6 +504,19 @@ static attrib_type at_npcfaction = {
|
||||||
ATF_UNIQUE
|
ATF_UNIQUE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
max_magicians(const faction * f)
|
||||||
|
{
|
||||||
|
int m = MAXMAGICIANS;
|
||||||
|
if ((a = a_find(f->attribs, &at_maxmagicians)) != NULL) {
|
||||||
|
m = a->data.i;
|
||||||
|
}
|
||||||
|
if (f->race == new_race[RC_ELF]) ++m;
|
||||||
|
#ifdef KARMA_MODULE
|
||||||
|
m += fspecial(f, FS_MAGOCRACY) * 2;
|
||||||
|
#endif /* KARMA_MODULE */
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
max_skill(faction * f, skill_t sk)
|
max_skill(faction * f, skill_t sk)
|
||||||
{
|
{
|
||||||
|
@ -523,15 +536,7 @@ max_skill(faction * f, skill_t sk)
|
||||||
}
|
}
|
||||||
switch (sk) {
|
switch (sk) {
|
||||||
case SK_MAGIC:
|
case SK_MAGIC:
|
||||||
if((a = a_find(f->attribs, &at_maxmagicians)) != NULL) {
|
m = max_magicians(f);
|
||||||
m = a->data.i;
|
|
||||||
} else {
|
|
||||||
m = MAXMAGICIANS;
|
|
||||||
}
|
|
||||||
if (f->race == new_race[RC_ELF]) m += 1;
|
|
||||||
#ifdef KARMA_MODULE
|
|
||||||
m += fspecial(f, FS_MAGOCRACY) * 2;
|
|
||||||
#endif /* KARMA_MODULE */
|
|
||||||
break;
|
break;
|
||||||
case SK_ALCHEMY:
|
case SK_ALCHEMY:
|
||||||
m = MAXALCHEMISTS;
|
m = MAXALCHEMISTS;
|
||||||
|
|
|
@ -2150,7 +2150,9 @@ remove_familiar(unit *mage)
|
||||||
attrib *an;
|
attrib *an;
|
||||||
skillmod_data *smd;
|
skillmod_data *smd;
|
||||||
|
|
||||||
|
if (a!=NULL) {
|
||||||
a_remove(&mage->attribs, a);
|
a_remove(&mage->attribs, a);
|
||||||
|
}
|
||||||
a = a_find(mage->attribs, &at_skillmod);
|
a = a_find(mage->attribs, &at_skillmod);
|
||||||
while (a && a->type==&at_skillmod) {
|
while (a && a->type==&at_skillmod) {
|
||||||
an = a->next;
|
an = a->next;
|
||||||
|
|
|
@ -826,6 +826,27 @@ check_dissolve(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
check_mages(void)
|
||||||
|
{
|
||||||
|
faction * f;
|
||||||
|
for (f=factions;f!=NULL;f=f->next) {
|
||||||
|
if (f->no!=MONSTER_FACTION) {
|
||||||
|
unit * u;
|
||||||
|
int mages = 0;
|
||||||
|
int maxmages = max_skill(f, SK_MAGIC);
|
||||||
|
|
||||||
|
for (u = f->units;u!=NULL;u=u->nextF) {
|
||||||
|
if (is_mage(u) && !is_familiar(u)) ++mages;
|
||||||
|
}
|
||||||
|
if (mages>maxmages) {
|
||||||
|
log_error(("faction %s has %d of max %d magicians.\n",
|
||||||
|
factionid(u->faction), mages, maxmages));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fix_familiars(void)
|
fix_familiars(void)
|
||||||
{
|
{
|
||||||
|
@ -843,15 +864,16 @@ fix_familiars(void)
|
||||||
char fname[64];
|
char fname[64];
|
||||||
|
|
||||||
if (mage==0) {
|
if (mage==0) {
|
||||||
log_error(("%s is a %s familiar with no mage for faction %s\n",
|
log_error(("%s was a %s familiar with no mage for faction %s\n",
|
||||||
unitid(u), racename(lang, u, u->race),
|
unitid(u), racename(lang, u, u->race),
|
||||||
factionid(u->faction)));
|
factionid(u->faction)));
|
||||||
|
a_remove(&u->attribs, a);
|
||||||
} else if (!is_mage(mage)) {
|
} else if (!is_mage(mage)) {
|
||||||
log_error(("%s is a %s familiar, but %s is not a mage for faction %s\n",
|
log_error(("%s was a %s familiar, but %s is not a mage for faction %s\n",
|
||||||
unitid(u), racename(lang, u, u->race), unitid(mage),
|
unitid(u), racename(lang, u, u->race), unitid(mage),
|
||||||
factionid(u->faction)));
|
factionid(u->faction)));
|
||||||
}
|
a_remove(&u->attribs, a);
|
||||||
if (has_skill(u, SK_MAGIC) && !is_mage(u)) {
|
} else if (has_skill(u, SK_MAGIC) && !is_mage(u)) {
|
||||||
log_error(("%s is a familiar with magic skill, but did not have a mage-attribute\n",
|
log_error(("%s is a familiar with magic skill, but did not have a mage-attribute\n",
|
||||||
unitid(u)));
|
unitid(u)));
|
||||||
create_mage(u, M_GRAU);
|
create_mage(u, M_GRAU);
|
||||||
|
@ -1022,6 +1044,7 @@ korrektur(void)
|
||||||
fix_demands();
|
fix_demands();
|
||||||
fix_otherfaction();
|
fix_otherfaction();
|
||||||
fix_familiars();
|
fix_familiars();
|
||||||
|
check_mages();
|
||||||
do_once("tfrs", &fix_resources);
|
do_once("tfrs", &fix_resources);
|
||||||
/* trade_orders(); */
|
/* trade_orders(); */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue