diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index 2f8764119..5b2caf61c 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -404,3 +404,22 @@ function test_birthdaycake() u:add_order("ZEIGE Geburtstagstorte") process_orders() end + +function test_demonstealth() + local desc, r, f, u + r = region.create(0, 0, "plain") + f = faction.create("demon@eressea.de", "demon", "de") + u = unit.create(f, r, 1) + + u:clear_orders() + u:add_order("TARNE Zwerg") + process_orders() + desc = u:show() + assert_not_nil(string.find(desc, "Zwerg")) + + u:clear_orders() + u:add_order("TARNE Drache") + process_orders() + desc = u:show() + assert_equal(nil, string.find(desc, "Drache")) +end diff --git a/src/kernel/race.c b/src/kernel/race.c index d159fd6d8..077e03b28 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -166,7 +166,7 @@ const struct race *findrace(const char *s, const struct locale *lang) const struct race *get_race(race_t rt) { const char * name; - assert(rt < MAXRACES); + assert(rt>=0 && rt < MAXRACES); name = racenames[rt]; if (!name) { return NULL; diff --git a/src/spy.c b/src/spy.c index c9667f7ee..12a30848d 100644 --- a/src/spy.c +++ b/src/spy.c @@ -254,19 +254,18 @@ int setstealth_cmd(unit * u, struct order *ord) NORACE }; int i; - for (i = 0; allowed[i] != NORACE; ++i) - if (get_race(allowed[i]) == trace) + for (i = 0; allowed[i] != NORACE; ++i) { + if (get_race(allowed[i]) == trace) { + u->irace = trace; + if (u_race(u)->flags & RCF_SHAPESHIFTANY && get_racename(u->attribs)) + set_racename(&u->attribs, NULL); break; - if (get_race(allowed[i]) == trace) { - u->irace = trace; - if (u_race(u)->flags & RCF_SHAPESHIFTANY && get_racename(u->attribs)) - set_racename(&u->attribs, NULL); + } } return 0; } - /* Singdrachen koennen sich nur als Drachen tarnen */ - if (u_race(u) == get_race(RC_SONGDRAGON) + else if (u_race(u) == get_race(RC_SONGDRAGON) || u_race(u) == get_race(RC_BIRTHDAYDRAGON)) { if (trace == get_race(RC_SONGDRAGON) || trace == get_race(RC_FIREDRAGON) || trace == get_race(RC_DRAGON) || trace == get_race(RC_WYRM)) {