forked from github/server
fix create_roi function in E3
This commit is contained in:
parent
8a27917f27
commit
5547893be7
|
@ -18,6 +18,7 @@ function test_roi()
|
|||
u.magic = "tybied"
|
||||
u.aura = 200
|
||||
u.ship = s1
|
||||
|
||||
-- local err = u:add_spell("create_roi")
|
||||
-- assert_equal(0, err)
|
||||
u:clear_orders()
|
||||
|
|
|
@ -78,6 +78,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/lists.h>
|
||||
#include <util/log.h>
|
||||
#include <util/parser.h>
|
||||
#include <util/quicklist.h>
|
||||
#include <util/rand.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/sql.h>
|
||||
|
@ -3713,6 +3714,20 @@ static int faction_getmages(faction * f, unit ** results, int numresults)
|
|||
return maxlevel;
|
||||
}
|
||||
|
||||
static void copy_spells(const spellbook * src, spellbook * dst, int maxlevel)
|
||||
{
|
||||
assert(dst);
|
||||
if (src && src->spells) {
|
||||
quicklist *ql;
|
||||
int qi;
|
||||
for (qi = 0, ql = src->spells; ql; ql_advance(&ql, &qi, 1)) {
|
||||
spellbook_entry * sbe = (spellbook_entry *)ql_get(ql, qi);
|
||||
if (sbe->level<=maxlevel) {
|
||||
spellbook_add(dst, sbe->sp, sbe->level);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void update_spells(void)
|
||||
{
|
||||
faction *f;
|
||||
|
@ -3723,7 +3738,13 @@ static void update_spells(void)
|
|||
int i;
|
||||
int maxlevel = faction_getmages(f, mages, MAXMAGES);
|
||||
|
||||
if (FactionSpells() && maxlevel > f->max_spelllevel) {
|
||||
if (maxlevel && FactionSpells()) {
|
||||
spellbook * book = get_spellbook(magic_school[f->magiegebiet]);
|
||||
if (!f->spellbook) {
|
||||
f->spellbook = create_spellbook(0);
|
||||
}
|
||||
copy_spells(book, f->spellbook, maxlevel);
|
||||
if (maxlevel > f->max_spelllevel) {
|
||||
static spellbook * common_spells;
|
||||
if (!common_spells) {
|
||||
const char *common_school = get_param(global.parameters, "rules.magic.common");
|
||||
|
@ -3735,6 +3756,7 @@ static void update_spells(void)
|
|||
}
|
||||
pick_random_spells(f, maxlevel, common_spells, COMMONSPELLS);
|
||||
}
|
||||
}
|
||||
show_new_spells(f, maxlevel, faction_get_spellbook(f));
|
||||
for (i=0; i!=MAXMAGES && mages[i]; ++i) {
|
||||
unit * u = mages[i];
|
||||
|
|
|
@ -2477,6 +2477,7 @@ static castorder *cast_cmd(unit * u, order * ord)
|
|||
plane *pl;
|
||||
spellparameter *args = NULL;
|
||||
unit * caster = u;
|
||||
param_t param;
|
||||
|
||||
if (LongHunger(u)) {
|
||||
cmistake(u, ord, 224, MSG_MAGIC);
|
||||
|
@ -2492,8 +2493,9 @@ static castorder *cast_cmd(unit * u, order * ord)
|
|||
init_tokens(ord);
|
||||
skip_token();
|
||||
s = getstrtoken();
|
||||
param = findparam(s, u->faction->locale);
|
||||
/* für Syntax ' STUFE x REGION y z ' */
|
||||
if (findparam(s, u->faction->locale) == P_LEVEL) {
|
||||
if (param == P_LEVEL) {
|
||||
int p = getint();
|
||||
level = MIN(p, level);
|
||||
if (level < 1) {
|
||||
|
@ -2502,8 +2504,9 @@ static castorder *cast_cmd(unit * u, order * ord)
|
|||
return 0;
|
||||
}
|
||||
s = getstrtoken();
|
||||
param = findparam(s, u->faction->locale);
|
||||
}
|
||||
if (findparam(s, u->faction->locale) == P_REGION) {
|
||||
if (param == P_REGION) {
|
||||
int t_x = getint();
|
||||
int t_y = getint();
|
||||
plane *pl = getplane(u->region);
|
||||
|
@ -2518,10 +2521,11 @@ static castorder *cast_cmd(unit * u, order * ord)
|
|||
return 0;
|
||||
}
|
||||
s = getstrtoken();
|
||||
param = findparam(s, u->faction->locale);
|
||||
}
|
||||
/* für Syntax ' REGION x y STUFE z '
|
||||
* hier nach REGION nochmal auf STUFE prüfen */
|
||||
if (findparam(s, u->faction->locale) == P_LEVEL) {
|
||||
if (param == P_LEVEL) {
|
||||
int p = getint();
|
||||
level = MIN(p, level);
|
||||
if (level < 1) {
|
||||
|
|
Loading…
Reference in New Issue