forked from github/server
demon stealth: cloak as other race.
added a Lua test. get_race oob fix (potential crash).
This commit is contained in:
parent
e938350acd
commit
e530543022
|
@ -404,3 +404,22 @@ function test_birthdaycake()
|
||||||
u:add_order("ZEIGE Geburtstagstorte")
|
u:add_order("ZEIGE Geburtstagstorte")
|
||||||
process_orders()
|
process_orders()
|
||||||
end
|
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
|
||||||
|
|
|
@ -166,7 +166,7 @@ const struct race *findrace(const char *s, const struct locale *lang)
|
||||||
const struct race *get_race(race_t rt) {
|
const struct race *get_race(race_t rt) {
|
||||||
const char * name;
|
const char * name;
|
||||||
|
|
||||||
assert(rt < MAXRACES);
|
assert(rt>=0 && rt < MAXRACES);
|
||||||
name = racenames[rt];
|
name = racenames[rt];
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -254,19 +254,18 @@ int setstealth_cmd(unit * u, struct order *ord)
|
||||||
NORACE
|
NORACE
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; allowed[i] != NORACE; ++i)
|
for (i = 0; allowed[i] != NORACE; ++i) {
|
||||||
if (get_race(allowed[i]) == trace)
|
|
||||||
break;
|
|
||||||
if (get_race(allowed[i]) == trace) {
|
if (get_race(allowed[i]) == trace) {
|
||||||
u->irace = trace;
|
u->irace = trace;
|
||||||
if (u_race(u)->flags & RCF_SHAPESHIFTANY && get_racename(u->attribs))
|
if (u_race(u)->flags & RCF_SHAPESHIFTANY && get_racename(u->attribs))
|
||||||
set_racename(&u->attribs, NULL);
|
set_racename(&u->attribs, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Singdrachen koennen sich nur als Drachen tarnen */
|
/* 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)) {
|
|| u_race(u) == get_race(RC_BIRTHDAYDRAGON)) {
|
||||||
if (trace == get_race(RC_SONGDRAGON) || trace == get_race(RC_FIREDRAGON)
|
if (trace == get_race(RC_SONGDRAGON) || trace == get_race(RC_FIREDRAGON)
|
||||||
|| trace == get_race(RC_DRAGON) || trace == get_race(RC_WYRM)) {
|
|| trace == get_race(RC_DRAGON) || trace == get_race(RC_WYRM)) {
|
||||||
|
|
Loading…
Reference in New Issue