From e129125a90398156780def88a5fdc002bca8776e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 13 Jul 2009 16:19:01 +0000 Subject: [PATCH] Magie-Updates --- src/common/gamecode/laws.c | 41 ++++++++++++++----- src/common/gamecode/study.c | 5 --- src/common/kernel/magic.c | 4 +- src/res/e3a.xml | 2 +- src/res/e3a/spells.xml | 78 ++++++++++++++++++------------------- 5 files changed, 73 insertions(+), 57 deletions(-) diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 1c058f023..3a64dc121 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -3481,20 +3481,41 @@ defaultorders (void) static void update_spells(void) { - region *r; - for(r=regions; r; r=r->next) { - unit *u; - for(u=r->units;u;u=u->next) { - if (u->faction!=NULL && u->number>0) { - sc_mage *m = get_mage(u); - if (!is_monsters(u->faction) && m != NULL) { - if (m->magietyp == M_GRAY) continue; - updatespelllist(u); + faction * f; + + for (f=factions;f;f=f->next) { + if (f->magiegebiet!=M_NONE && !is_monsters(f)) { + unit * mages[MAXMAGICIANS]; + unit *u; + int maxlevel = 0, n = 0, i; + + for (u=f->units;u && nnextF) { + if (u->number>0) { + sc_mage *mage = get_mage(u); + if (mage) { + int level = eff_skill(u, SK_MAGIC, u->region); + if (level>maxlevel) maxlevel = level; + mages[n++] = u; + } } } + + if (FactionSpells() && maxlevel>f->max_spelllevel) { + update_spellbook(f, maxlevel); + for (i=0;i!=n;++i) { + sc_mage *mage = get_mage(mages[i]); + while (mage->spells) { + spell_list * slist = mage->spells; + mage->spells = slist->next; + free(slist); + } + } + } + for (i=0;i!=n;++i) { + updatespelllist(mages[i]); + } } } - } static void diff --git a/src/common/gamecode/study.c b/src/common/gamecode/study.c index 45359ed4d..f7bd35afb 100644 --- a/src/common/gamecode/study.c +++ b/src/common/gamecode/study.c @@ -793,14 +793,9 @@ learn_cmd(unit * u, order * ord) } else if (sk==SK_MAGIC) { sc_mage * mage = get_mage(u); - int level = eff_skill(u, SK_MAGIC, r); - if (FactionSpells() && level>u->faction->max_spelllevel) { - update_spellbook(u->faction, level); - } if (!mage) { mage = create_mage(u, u->faction->magiegebiet); } - updatespelllist(u); } return 0; diff --git a/src/common/kernel/magic.c b/src/common/kernel/magic.c index b329fdb5d..986d3efd8 100644 --- a/src/common/kernel/magic.c +++ b/src/common/kernel/magic.c @@ -415,7 +415,7 @@ update_spellbook(faction * f, int level) for (slist=spells;slist!=NULL;slist=slist->next) { spell * sp = slist->data; - if (sp->magietyp == M_COMMON && levelmax_spelllevel && sp->level<=level) { + if (sp->magietyp == M_COMMON && level>f->max_spelllevel && sp->level<=level) { commonspells[numspells++] = sp; } else { if (know_school(f, sp->magietyp) && sp->level <= level) { @@ -511,7 +511,7 @@ updatespelllist(unit * u) if (sp->level<=sk) { boolean know = u_hasspell(u, sp); - if (know || know_school(u->faction, sp->magietyp)) { + if (know || sp->magietyp==M_COMMON || know_school(u->faction, sp->magietyp)) { faction * f = u->faction; if (!know) add_spell(get_spelllist(mage, u->faction), sp); diff --git a/src/res/e3a.xml b/src/res/e3a.xml index cb058de5c..4ef5d38b8 100644 --- a/src/res/e3a.xml +++ b/src/res/e3a.xml @@ -154,7 +154,7 @@ - + diff --git a/src/res/e3a/spells.xml b/src/res/e3a/spells.xml index 58baf2ead..7160dc3c1 100644 --- a/src/res/e3a/spells.xml +++ b/src/res/e3a/spells.xml @@ -276,7 +276,7 @@ - + @@ -561,15 +561,6 @@ - - - - - - - - - @@ -593,9 +584,6 @@ - - - @@ -646,41 +634,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +