forked from github/server
bug 2292: allow packice to be guarded again.
https://bugs.eressea.de/view.php?id=2292
This commit is contained in:
parent
326f543ece
commit
45854851ae
3 changed files with 13 additions and 18 deletions
|
@ -24,17 +24,18 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "monsters.h"
|
#include "monsters.h"
|
||||||
|
|
||||||
#include <kernel/ally.h>
|
#include <kernel/ally.h>
|
||||||
#include <kernel/unit.h>
|
#include <kernel/building.h>
|
||||||
#include <kernel/faction.h>
|
#include <kernel/faction.h>
|
||||||
#include <kernel/race.h>
|
#include <kernel/race.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
#include <kernel/building.h>
|
#include <kernel/terrain.h>
|
||||||
|
#include <kernel/unit.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
guard_t can_start_guarding(const unit * u)
|
guard_t can_start_guarding(const unit * u)
|
||||||
{
|
{
|
||||||
if (!u->region->land) {
|
if (u->region->terrain->flags & SEA_REGION) {
|
||||||
return E_GUARD_TERRAIN;
|
return E_GUARD_TERRAIN;
|
||||||
}
|
}
|
||||||
if (u->status >= ST_FLEE || fval(u, UFL_FLEEING))
|
if (u->status >= ST_FLEE || fval(u, UFL_FLEEING))
|
||||||
|
@ -72,7 +73,6 @@ void setguard(unit * u, bool enabled)
|
||||||
} else {
|
} else {
|
||||||
assert(!fval(u, UFL_MOVED));
|
assert(!fval(u, UFL_MOVED));
|
||||||
assert(u->status < ST_FLEE);
|
assert(u->status < ST_FLEE);
|
||||||
assert(u->region->land);
|
|
||||||
fset(u, UFL_GUARD);
|
fset(u, UFL_GUARD);
|
||||||
fset(u->region, RF_GUARDED);
|
fset(u->region, RF_GUARDED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ static void test_update_guard(CuTest * tc)
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
||||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
t_plain = test_create_terrain("packice", ARCTIC_REGION);
|
||||||
itype = it_get_or_create(rt_get_or_create("sword"));
|
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2);
|
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2);
|
||||||
r = test_create_region(0, 0, t_plain);
|
r = test_create_region(0, 0, t_plain);
|
||||||
|
@ -181,6 +181,13 @@ static void test_guard_on(CuTest * tc)
|
||||||
guard_on_cmd(ug, ug->thisorder);
|
guard_on_cmd(ug, ug->thisorder);
|
||||||
CuAssertTrue(tc, is_guard(ug));
|
CuAssertTrue(tc, is_guard(ug));
|
||||||
|
|
||||||
|
terraform_region(r, test_create_terrain("packice", ARCTIC_REGION));
|
||||||
|
|
||||||
|
setguard(ug, false);
|
||||||
|
CuAssertIntEquals(tc, E_GUARD_OK, can_start_guarding(ug));
|
||||||
|
guard_on_cmd(ug, ug->thisorder);
|
||||||
|
CuAssertTrue(tc, is_guard(ug));
|
||||||
|
|
||||||
terraform_region(r, t_ocean);
|
terraform_region(r, t_ocean);
|
||||||
|
|
||||||
setguard(ug, false);
|
setguard(ug, false);
|
||||||
|
@ -189,13 +196,6 @@ static void test_guard_on(CuTest * tc)
|
||||||
CuAssertTrue(tc, !is_guard(ug));
|
CuAssertTrue(tc, !is_guard(ug));
|
||||||
CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "error2"));
|
CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "error2"));
|
||||||
|
|
||||||
setguard(ug, false);
|
|
||||||
t_ocean->flags &= ~ SEA_REGION;
|
|
||||||
CuAssertIntEquals(tc, E_GUARD_TERRAIN, can_start_guarding(ug));
|
|
||||||
guard_on_cmd(ug, ug->thisorder);
|
|
||||||
CuAssertTrue(tc, !is_guard(ug));
|
|
||||||
CuAssertPtrNotNull(tc, test_find_messagetype(ug->faction->msgs, "error_onlandonly"));
|
|
||||||
|
|
||||||
terraform_region(r, t_plain);
|
terraform_region(r, t_plain);
|
||||||
|
|
||||||
i_change(&ug->items, itype, -1);
|
i_change(&ug->items, itype, -1);
|
||||||
|
|
|
@ -2699,12 +2699,7 @@ int guard_on_cmd(unit * u, struct order *ord)
|
||||||
setguard(u, true);
|
setguard(u, true);
|
||||||
}
|
}
|
||||||
else if (err == E_GUARD_TERRAIN) {
|
else if (err == E_GUARD_TERRAIN) {
|
||||||
if (fval(u->region->terrain, SEA_REGION)) {
|
cmistake(u, ord, 2, MSG_EVENT);
|
||||||
cmistake(u, ord, 2, MSG_EVENT);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (err == E_GUARD_UNARMED) {
|
else if (err == E_GUARD_UNARMED) {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unit_unarmed", ""));
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unit_unarmed", ""));
|
||||||
|
|
Loading…
Reference in a new issue