cleanup: remove static curse_type variables.

This commit is contained in:
Enno Rehling 2016-08-29 20:02:39 +01:00
parent b43ac6ab27
commit 1a1ec3f363
5 changed files with 51 additions and 57 deletions

View File

@ -2756,13 +2756,10 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
jobs = rpeasants(r);
}
earnings = jobs * p_wage;
if (rule_blessed_harvest() == HARVEST_TAXES) {
if (r->attribs && rule_blessed_harvest() == HARVEST_TAXES) {
/* E3 rules */
static const curse_type *blessedharvest_ct;
if (!blessedharvest_ct) {
blessedharvest_ct = ct_find("blessedharvest");
}
if (blessedharvest_ct && r->attribs) {
const curse_type *blessedharvest_ct = ct_find("blessedharvest");
if (blessedharvest_ct) {
int happy =
(int)curse_geteffect(get_curse(r->attribs, blessedharvest_ct));
happy = _min(happy, jobs);

View File

@ -3487,15 +3487,13 @@ static double heal_factor(const unit * u)
void monthly_healing(void)
{
region *r;
static const curse_type *heal_ct = NULL;
if (heal_ct == NULL)
heal_ct = ct_find("healingzone");
const curse_type *heal_ct = ct_find("healingzone");
for (r = regions; r; r = r->next) {
unit *u;
double healingcurse = 0;
if (heal_ct != NULL) {
if (r->attribs && heal_ct) {
/* bonus zurücksetzen */
curse *c = get_curse(r->attribs, heal_ct);
if (c != NULL) {

View File

@ -929,16 +929,16 @@ void spawn_undead(void)
{
region *r;
faction *monsters = get_monsters();
const curse_type *ctype = ct_find("holyground");
for (r = regions; r; r = r->next) {
int unburied = deathcount(r);
static const curse_type *ctype = NULL;
if (!ctype)
ctype = ct_find("holyground");
if (ctype && curse_active(get_curse(r->attribs, ctype)))
continue;
if (r->attribs && ctype) {
if (curse_active(get_curse(r->attribs, ctype))) {
continue;
}
}
/* Chance 0.1% * chaosfactor */
if (r->land && unburied > rpeasants(r) / 20
&& rng_int() % 10000 < (100 + 100 * chaosfactor(r))) {

View File

@ -496,7 +496,8 @@ static double overload(const region * r, ship * sh)
if (sh->type->construction && sh->size != sh->type->construction->maxsize) {
return DBL_MAX;
} else {
}
else {
int n = 0, p = 0;
int mcabins = sh->type->cabins;
@ -828,7 +829,7 @@ static void drifting_ships(region * r)
/* Kapitän bestimmen */
captain = ship_owner(sh);
if (captain && effskill(captain, SK_SAILING, r) < sh->type->cptskill)
captain = NULL;
captain = NULL;
/* Kapitän da? Beschädigt? Genügend Matrosen?
* Genügend leicht? Dann ist alles OK. */
@ -843,7 +844,8 @@ static void drifting_ships(region * r)
ovl = overload(r, sh);
if (ovl >= overload_start()) {
rnext = NULL;
} else {
}
else {
/* Auswahl einer Richtung: Zuerst auf Land, dann
* zufällig. Falls unmögliches Resultat: vergiß es. */
rnext = drift_target(sh);
@ -870,7 +872,8 @@ static void drifting_ships(region * r)
if (ovl >= overload_start()) {
damage_ship(sh, damage_overload(ovl));
msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("massive_overload", "ship", sh));
} else
}
else
damage_ship(sh, damage_drift);
if (sh->damage >= sh->size * DAMAGE_SCALE) {
msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("shipsink", "ship", sh));
@ -1053,23 +1056,22 @@ unit *is_guarded(region * r, unit * u, unsigned int mask)
bool move_blocked(const unit * u, const region * r, const region * r2)
{
connection *b;
curse *c;
static const curse_type *fogtrap_ct = NULL;
if (r2 == NULL)
return true;
b = get_borders(r, r2);
while (b) {
if (b->type->block && b->type->block(b, u, r))
if (b->type->block && b->type->block(b, u, r)) {
return true;
}
b = b->next;
}
if (fogtrap_ct == NULL)
fogtrap_ct = ct_find("fogtrap");
c = get_curse(r->attribs, fogtrap_ct);
if (curse_active(c))
return true;
if (r->attribs) {
const curse_type *fogtrap_ct = ct_find("fogtrap");
curse *c = get_curse(r->attribs, fogtrap_ct);
return curse_active(c);
}
return false;
}
@ -1308,7 +1310,6 @@ static bool roadto(const region * r, direction_t dir)
/* wenn es hier genug strassen gibt, und verbunden ist, und es dort
* genug strassen gibt, dann existiert eine strasse in diese richtung */
region *r2;
static const curse_type *roads_ct = NULL;
assert(r);
assert(dir < MAXDIRECTIONS);
@ -1318,13 +1319,14 @@ static bool roadto(const region * r, direction_t dir)
if (r == NULL || r2 == NULL)
return false;
if (roads_ct == NULL)
roads_ct = ct_find("magicstreet");
if (roads_ct != NULL) {
if (get_curse(r->attribs, roads_ct) != NULL)
return true;
if (get_curse(r2->attribs, roads_ct) != NULL)
return true;
if (r->attribs || r2->attribs) {
const curse_type *roads_ct = ct_find("magicstreet");
if (roads_ct != NULL) {
if (get_curse(r->attribs, roads_ct) != NULL)
return true;
if (get_curse(r2->attribs, roads_ct) != NULL)
return true;
}
}
if (r->terrain->max_road <= 0)

View File

@ -148,29 +148,26 @@ bool flying_ship(const ship * sh)
static curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration)
{
static const curse_type *ct_flyingship = NULL;
if (!ct_flyingship) {
ct_flyingship = ct_find("flyingship");
assert(ct_flyingship);
}
if (curse_active(get_curse(sh->attribs, ct_flyingship))) {
return NULL;
}
else if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0)) {
return NULL;
}
else {
/* mit C_SHIP_NODRIFT haben wir kein Problem */
curse *c =
create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0);
if (c) {
c->data.v = sh;
if (c->duration > 0) {
sh->flags |= SF_FLYING;
}
curse *c;
const curse_type *ct_flyingship = ct_find("flyingship");
assert(ct_flyingship);
if (sh->attribs) {
if (curse_active(get_curse(sh->attribs, ct_flyingship))) {
return NULL;
}
if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0)) {
return NULL;
}
return c;
}
/* mit C_SHIP_NODRIFT haben wir kein Problem */
c = create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0);
if (c) {
c->data.v = sh;
if (c->duration > 0) {
sh->flags |= SF_FLYING;
}
}
return c;
}
int levitate_ship(ship * sh, unit * mage, double power, int duration)