remove static initialization code

This commit is contained in:
Enno Rehling 2016-08-29 19:46:19 +01:00
parent aa998166e4
commit b43ac6ab27
2 changed files with 26 additions and 29 deletions

View File

@ -1923,28 +1923,29 @@ int skilldiff(troop at, troop dt, int dist)
}
if (df->building) {
static const curse_type *strongwall_ct;
strongwall_ct = ct_find("strongwall");
if (strongwall_ct) {
curse *c = get_curse(df->building->attribs, strongwall_ct);
if (curse_active(c)) {
/* wirkt auf alle Gebäude */
skdiff -= curse_geteffect_int(c);
is_protected = 2;
if (df->building->attribs) {
const curse_type *strongwall_ct = ct_find("strongwall");
if (strongwall_ct) {
curse *c = get_curse(df->building->attribs, strongwall_ct);
if (curse_active(c)) {
/* wirkt auf alle Gebäude */
skdiff -= curse_geteffect_int(c);
is_protected = 2;
}
}
}
if (df->building->type->protection) {
int beff = df->building->type->protection(df->building, du, DEFENSE_BONUS);
if (beff) {
static const curse_type *magicwalls_ct;
skdiff -= beff;
is_protected = 2;
magicwalls_ct = ct_find("magicwalls");
if (magicwalls_ct
&& curse_active(get_curse(df->building->attribs, magicwalls_ct))) {
/* Verdoppelt Burgenbonus */
skdiff -= beff;
if (df->building->attribs) {
const curse_type *magicwalls_ct = ct_find("magicwalls");
if (magicwalls_ct
&& curse_active(get_curse(df->building->attribs, magicwalls_ct))) {
/* Verdoppelt Burgenbonus */
skdiff -= beff;
}
}
}
}

View File

@ -298,8 +298,6 @@ int crew_skill(const ship *sh) {
int shipspeed(const ship * sh, const unit * u)
{
int k = sh->type->range;
static const struct curse_type *stormwind_ct, *nodrift_ct;
static bool init;
attrib *a;
struct curse *c;
int bonus;
@ -312,19 +310,17 @@ int shipspeed(const ship * sh, const unit * u)
assert(sh->type->construction);
assert(sh->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */
if (!init) {
init = true;
stormwind_ct = ct_find("stormwind");
nodrift_ct = ct_find("nodrift");
}
if (sh->size != sh->type->construction->maxsize)
return 0;
if (curse_active(get_curse(sh->attribs, stormwind_ct)))
k *= 2;
if (curse_active(get_curse(sh->attribs, nodrift_ct)))
k += 1;
if (sh->attribs) {
if (curse_active(get_curse(sh->attribs, ct_find("stormwind")))) {
k *= 2;
}
if (curse_active(get_curse(sh->attribs, ct_find("nodrift")))) {
k += 1;
}
}
if (u->faction->race == u_race(u)) {
/* race bonus for this faction? */
if (fval(u_race(u), RCF_SHIPSPEED)) {
@ -333,7 +329,7 @@ int shipspeed(const ship * sh, const unit * u)
}
bonus = ShipSpeedBonus(u);
if (bonus > 0 && sh->type->range_max>sh->type->range) {
if (bonus > 0 && sh->type->range_max > sh->type->range) {
int crew = crew_skill(sh);
int crew_bonus = (crew / sh->type->sumskill / 2) - 1;
if (crew_bonus > 0) {
@ -358,7 +354,7 @@ int shipspeed(const ship * sh, const unit * u)
c = c->nexthash;
}
if (sh->damage>0) {
if (sh->damage > 0) {
int size = sh->size * DAMAGE_SCALE;
k *= (size - sh->damage);
k = (k + size - 1) / size;