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); jobs = rpeasants(r);
} }
earnings = jobs * p_wage; earnings = jobs * p_wage;
if (rule_blessed_harvest() == HARVEST_TAXES) { if (r->attribs && rule_blessed_harvest() == HARVEST_TAXES) {
/* E3 rules */ /* E3 rules */
static const curse_type *blessedharvest_ct; const curse_type *blessedharvest_ct = ct_find("blessedharvest");
if (!blessedharvest_ct) { if (blessedharvest_ct) {
blessedharvest_ct = ct_find("blessedharvest");
}
if (blessedharvest_ct && r->attribs) {
int happy = int happy =
(int)curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); (int)curse_geteffect(get_curse(r->attribs, blessedharvest_ct));
happy = _min(happy, jobs); happy = _min(happy, jobs);

View file

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

View file

@ -929,16 +929,16 @@ void spawn_undead(void)
{ {
region *r; region *r;
faction *monsters = get_monsters(); faction *monsters = get_monsters();
const curse_type *ctype = ct_find("holyground");
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
int unburied = deathcount(r); 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 */ /* Chance 0.1% * chaosfactor */
if (r->land && unburied > rpeasants(r) / 20 if (r->land && unburied > rpeasants(r) / 20
&& rng_int() % 10000 < (100 + 100 * chaosfactor(r))) { && 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) { if (sh->type->construction && sh->size != sh->type->construction->maxsize) {
return DBL_MAX; return DBL_MAX;
} else { }
else {
int n = 0, p = 0; int n = 0, p = 0;
int mcabins = sh->type->cabins; int mcabins = sh->type->cabins;
@ -828,7 +829,7 @@ static void drifting_ships(region * r)
/* Kapitän bestimmen */ /* Kapitän bestimmen */
captain = ship_owner(sh); captain = ship_owner(sh);
if (captain && effskill(captain, SK_SAILING, r) < sh->type->cptskill) if (captain && effskill(captain, SK_SAILING, r) < sh->type->cptskill)
captain = NULL; captain = NULL;
/* Kapitän da? Beschädigt? Genügend Matrosen? /* Kapitän da? Beschädigt? Genügend Matrosen?
* Genügend leicht? Dann ist alles OK. */ * Genügend leicht? Dann ist alles OK. */
@ -843,7 +844,8 @@ static void drifting_ships(region * r)
ovl = overload(r, sh); ovl = overload(r, sh);
if (ovl >= overload_start()) { if (ovl >= overload_start()) {
rnext = NULL; rnext = NULL;
} else { }
else {
/* Auswahl einer Richtung: Zuerst auf Land, dann /* Auswahl einer Richtung: Zuerst auf Land, dann
* zufällig. Falls unmögliches Resultat: vergiß es. */ * zufällig. Falls unmögliches Resultat: vergiß es. */
rnext = drift_target(sh); rnext = drift_target(sh);
@ -870,7 +872,8 @@ static void drifting_ships(region * r)
if (ovl >= overload_start()) { if (ovl >= overload_start()) {
damage_ship(sh, damage_overload(ovl)); damage_ship(sh, damage_overload(ovl));
msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("massive_overload", "ship", sh)); msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("massive_overload", "ship", sh));
} else }
else
damage_ship(sh, damage_drift); damage_ship(sh, damage_drift);
if (sh->damage >= sh->size * DAMAGE_SCALE) { if (sh->damage >= sh->size * DAMAGE_SCALE) {
msg_to_ship_inmates(sh, &firstu, &lastu, msg_message("shipsink", "ship", sh)); 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) bool move_blocked(const unit * u, const region * r, const region * r2)
{ {
connection *b; connection *b;
curse *c;
static const curse_type *fogtrap_ct = NULL;
if (r2 == NULL) if (r2 == NULL)
return true; return true;
b = get_borders(r, r2); b = get_borders(r, r2);
while (b) { while (b) {
if (b->type->block && b->type->block(b, u, r)) if (b->type->block && b->type->block(b, u, r)) {
return true; return true;
}
b = b->next; b = b->next;
} }
if (fogtrap_ct == NULL) if (r->attribs) {
fogtrap_ct = ct_find("fogtrap"); const curse_type *fogtrap_ct = ct_find("fogtrap");
c = get_curse(r->attribs, fogtrap_ct); curse *c = get_curse(r->attribs, fogtrap_ct);
if (curse_active(c)) return curse_active(c);
return true; }
return false; 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 /* wenn es hier genug strassen gibt, und verbunden ist, und es dort
* genug strassen gibt, dann existiert eine strasse in diese richtung */ * genug strassen gibt, dann existiert eine strasse in diese richtung */
region *r2; region *r2;
static const curse_type *roads_ct = NULL;
assert(r); assert(r);
assert(dir < MAXDIRECTIONS); assert(dir < MAXDIRECTIONS);
@ -1318,13 +1319,14 @@ static bool roadto(const region * r, direction_t dir)
if (r == NULL || r2 == NULL) if (r == NULL || r2 == NULL)
return false; return false;
if (roads_ct == NULL) if (r->attribs || r2->attribs) {
roads_ct = ct_find("magicstreet"); const curse_type *roads_ct = ct_find("magicstreet");
if (roads_ct != NULL) { if (roads_ct != NULL) {
if (get_curse(r->attribs, roads_ct) != NULL) if (get_curse(r->attribs, roads_ct) != NULL)
return true; return true;
if (get_curse(r2->attribs, roads_ct) != NULL) if (get_curse(r2->attribs, roads_ct) != NULL)
return true; return true;
}
} }
if (r->terrain->max_road <= 0) 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 curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration)
{ {
static const curse_type *ct_flyingship = NULL; curse *c;
if (!ct_flyingship) { const curse_type *ct_flyingship = ct_find("flyingship");
ct_flyingship = ct_find("flyingship"); assert(ct_flyingship);
assert(ct_flyingship); if (sh->attribs) {
} if (curse_active(get_curse(sh->attribs, ct_flyingship))) {
if (curse_active(get_curse(sh->attribs, ct_flyingship))) { return NULL;
return NULL; }
} if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0)) {
else if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0)) { return NULL;
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;
}
} }
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) int levitate_ship(ship * sh, unit * mage, double power, int duration)