forked from github/server
optimization: no need to look for a curse if unit has no attribs.
This commit is contained in:
parent
40d9ebfa94
commit
8ff26eb0e4
|
@ -1463,8 +1463,6 @@ static void make_route(unit * u, order * ord, region_list ** routep)
|
||||||
static int movement_speed(unit * u)
|
static int movement_speed(unit * u)
|
||||||
{
|
{
|
||||||
int mp = BP_WALKING;
|
int mp = BP_WALKING;
|
||||||
static const curse_type *speed_ct;
|
|
||||||
static bool init = false;
|
|
||||||
double dk = u_race(u)->speed;
|
double dk = u_race(u)->speed;
|
||||||
|
|
||||||
assert(u->number);
|
assert(u->number);
|
||||||
|
@ -1482,10 +1480,8 @@ static int movement_speed(unit * u)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!init) {
|
if (u->attribs) {
|
||||||
init = true;
|
const curse_type *speed_ct = ct_find("speed");
|
||||||
speed_ct = ct_find("speed");
|
|
||||||
}
|
|
||||||
if (speed_ct) {
|
if (speed_ct) {
|
||||||
curse *c = get_curse(u->attribs, speed_ct);
|
curse *c = get_curse(u->attribs, speed_ct);
|
||||||
if (c != NULL) {
|
if (c != NULL) {
|
||||||
|
@ -1493,6 +1489,7 @@ static int movement_speed(unit * u)
|
||||||
dk *= 1.0 + (double)men / (double)u->number;
|
dk *= 1.0 + (double)men / (double)u->number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (canride(u)) {
|
switch (canride(u)) {
|
||||||
case 1: /* Pferd */
|
case 1: /* Pferd */
|
||||||
|
|
|
@ -270,19 +270,19 @@ report_items(const unit *u, item * result, int size, const unit * owner,
|
||||||
{
|
{
|
||||||
const item *itm, *items = u->items;
|
const item *itm, *items = u->items;
|
||||||
int n = 0; /* number of results */
|
int n = 0; /* number of results */
|
||||||
bool itemcloak = false;
|
|
||||||
const curse_type *itemcloak_ct = ct_find("itemcloak");
|
|
||||||
|
|
||||||
assert(owner == NULL || viewer != owner->faction);
|
assert(owner == NULL || viewer != owner->faction);
|
||||||
assert(size);
|
assert(size);
|
||||||
|
|
||||||
|
if (u->attribs) {
|
||||||
|
const curse_type *itemcloak_ct = ct_find("itemcloak");
|
||||||
if (itemcloak_ct) {
|
if (itemcloak_ct) {
|
||||||
curse * cu = get_curse(u->attribs, itemcloak_ct);
|
curse * cu = get_curse(u->attribs, itemcloak_ct);
|
||||||
itemcloak = cu && curse_active(cu);
|
if (cu && curse_active(cu)) {
|
||||||
}
|
|
||||||
if (itemcloak) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for (itm = items; itm; itm = itm->next) {
|
for (itm = items; itm; itm = itm->next) {
|
||||||
item *ishow;
|
item *ishow;
|
||||||
const char *ic;
|
const char *ic;
|
||||||
|
|
Loading…
Reference in New Issue