diff --git a/scripts/tests/e2/spells.lua b/scripts/tests/e2/spells.lua index de2386113..9cdc28b96 100644 --- a/scripts/tests/e2/spells.lua +++ b/scripts/tests/e2/spells.lua @@ -14,6 +14,29 @@ function setup() eressea.settings.set("magic.regeneration.enable", "0") end +function test_undead_cannot_enter_holyground() + local r1 = region.create(0, 0, 'plain') + local r2 = region.create(1, 0, 'plain') + local f = faction.create('human') + local u1 = unit.create(f, r1, 1) + local u2 = unit.create(f, r2, 1) + + u2.name = "Xolgrim's Magier" + u1.name = "Xolgrim's Opfer" + + u2.magic = 'gwyrrd' + u2:set_skill('magic', 100) + u2.aura = 200 + u2:add_spell('holyground') + u2:add_order('ZAUBERE STUFE 10 "Heiliger Boden"') + + u1.race = "skeleton" + u1:add_order("NACH Osten") + process_orders() + assert_not_nil(r2:get_curse('holyground')) + assert_equal(r1, u1.region) +end + function test_shapeshift() local r = region.create(42, 0, "plain") local f = faction.create("demon", "noreply@eressea.de", "de") diff --git a/src/bind_monsters.c b/src/bind_monsters.c index f9aef4a2a..2acacfaa3 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -28,9 +28,6 @@ static int tolua_levitate_ship(lua_State * L) return 1; } -extern void spawn_undead(void); -extern void plan_monsters(struct faction *f); - static int tolua_planmonsters(lua_State * L) { faction *f = (faction *)tolua_tousertype(L, 1, get_monsters()); diff --git a/src/laws.c b/src/laws.c index 10975c6a7..4170975b5 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3712,8 +3712,9 @@ void process(void) log_debug("- Step %u", prio); while (proc && proc->priority == prio) { - if (proc->name) + if (proc->name) { log_debug(" - %s", proc->name); + } proc = proc->next; } @@ -3721,8 +3722,9 @@ void process(void) pglobal->data.global.process(); pglobal = pglobal->next; } - if (pglobal == NULL || pglobal->priority != prio) + if (pglobal == NULL || pglobal->priority != prio) { continue; + } for (r = regions; r; r = r->next) { unit *u; @@ -3733,8 +3735,9 @@ void process(void) pregion->data.per_region.process(r); pregion = pregion->next; } - if (pregion == NULL || pregion->priority != prio) + if (pregion == NULL || pregion->priority != prio) { continue; + } if (r->units) { for (u = r->units; u; u = u->next) { @@ -3744,14 +3747,16 @@ void process(void) punit->data.per_unit.process(u); punit = punit->next; } - if (punit == NULL || punit->priority != prio) + if (punit == NULL || punit->priority != prio) { continue; + } porder = punit; while (porder && porder->priority == prio && porder->type == PR_ORDER) { order **ordp = &u->orders; - if (porder->flags & PROC_THISORDER) + if (porder->flags & PROC_THISORDER) { ordp = &u->thisorder; + } while (*ordp) { order *ord = *ordp; if (getkeyword(ord) == porder->data.per_order.kword) { @@ -3780,8 +3785,9 @@ void process(void) } } } - if (!ord || *ordp == ord) + if (!ord || *ordp == ord) { ordp = &(*ordp)->next; + } } porder = porder->next; } @@ -3798,9 +3804,9 @@ void process(void) pregion->data.per_region.process(r); pregion = pregion->next; } - if (pregion == NULL || pregion->priority != prio) + if (pregion == NULL || pregion->priority != prio) { continue; - + } } } diff --git a/src/monsters.h b/src/monsters.h index 81f7e39a3..99d60a3fb 100644 --- a/src/monsters.h +++ b/src/monsters.h @@ -21,6 +21,10 @@ extern "C" { bool monster_is_waiting(const struct unit *u); void make_zombie(struct unit * u); + void spawn_undead(void); + void plan_monsters(struct faction *f); + + #ifdef __cplusplus } #endif diff --git a/src/move.c b/src/move.c index d33987d54..5d5513cd3 100644 --- a/src/move.c +++ b/src/move.c @@ -974,10 +974,17 @@ bool move_blocked(const unit * u, const region * r, const region * r2) } if (r->attribs) { - const curse_type *fogtrap_ct = &ct_fogtrap; - curse *c = get_curse(r->attribs, fogtrap_ct); + curse *c = get_curse(r->attribs, &ct_fogtrap); + if (curse_active(c)) { + return true; + } + } + + if (r2->attribs && fval(u_race(u), RCF_UNDEAD)) { + curse *c = get_curse(r2->attribs, &ct_holyground); return curse_active(c); } + return false; }