eliminate static curse variables (gbdream & more)

This commit is contained in:
Enno Rehling 2016-08-29 20:31:18 +01:00
parent 1a1ec3f363
commit f47113e9bd
5 changed files with 67 additions and 70 deletions

View File

@ -304,7 +304,7 @@ extern "C" {
const struct curse *c, int self); const struct curse *c, int self);
int curse_cansee(const struct curse *c, const struct faction *viewer, objtype_t typ, const void *obj, int self); int curse_cansee(const struct curse *c, const struct faction *viewer, objtype_t typ, const void *obj, int self);
#define is_cursed(a, id, id2) \ #define is_cursed(a, id, id2) \
curse_active(get_curse(a, ct_find(oldcursename(id)))) (a && curse_active(get_curse(a, ct_find(oldcursename(id)))))
#define get_curseeffect(a, id, id2) \ #define get_curseeffect(a, id, id2) \
curse_geteffect(get_curse(a, ct_find(oldcursename(id)))) curse_geteffect(get_curse(a, ct_find(oldcursename(id))))

View File

@ -146,24 +146,25 @@ int deathcount(const region * r)
void deathcounts(region * r, int fallen) void deathcounts(region * r, int fallen)
{ {
attrib *a; attrib *a = NULL;
static const curse_type *ctype = NULL;
if (fallen == 0) if (fallen == 0)
return; return;
if (!ctype) if (r->attribs) {
ctype = ct_find("holyground"); const curse_type *ctype = ct_find("holyground");
if (ctype && curse_active(get_curse(r->attribs, ctype))) if (ctype && curse_active(get_curse(r->attribs, ctype)))
return; return;
a = a_find(r->attribs, &at_deathcount); a = a_find(r->attribs, &at_deathcount);
if (!a) }
if (!a) {
a = a_add(&r->attribs, a_new(&at_deathcount)); a = a_add(&r->attribs, a_new(&at_deathcount));
}
a->data.i += fallen; a->data.i += fallen;
if (a->data.i <= 0) if (a->data.i <= 0) {
a_remove(&r->attribs, a); a_remove(&r->attribs, a);
} }
}
/* Moveblock wird zur Zeit nicht über Attribute, sondern ein Bitfeld /* Moveblock wird zur Zeit nicht über Attribute, sondern ein Bitfeld
r->moveblock gemacht. Sollte umgestellt werden, wenn kompliziertere r->moveblock gemacht. Sollte umgestellt werden, wenn kompliziertere

View File

@ -863,16 +863,15 @@ bool can_survive(const unit * u, const region * r)
if ((fval(r->terrain, WALK_INTO) && (u_race(u)->flags & RCF_WALK)) if ((fval(r->terrain, WALK_INTO) && (u_race(u)->flags & RCF_WALK))
|| (fval(r->terrain, SWIM_INTO) && (u_race(u)->flags & RCF_SWIM)) || (fval(r->terrain, SWIM_INTO) && (u_race(u)->flags & RCF_SWIM))
|| (fval(r->terrain, FLY_INTO) && (u_race(u)->flags & RCF_FLY))) { || (fval(r->terrain, FLY_INTO) && (u_race(u)->flags & RCF_FLY))) {
static const curse_type *ctype = NULL;
if (has_horses(u) && !fval(r->terrain, WALK_INTO)) if (has_horses(u) && !fval(r->terrain, WALK_INTO))
return false; return false;
if (!ctype) if (r->attribs) {
ctype = ct_find("holyground"); const curse_type *ctype = ct_find("holyground");
if (fval(u_race(u), RCF_UNDEAD) && curse_active(get_curse(r->attribs, ctype))) if (fval(u_race(u), RCF_UNDEAD) && curse_active(get_curse(r->attribs, ctype)))
return false; return false;
}
return true; return true;
} }
return false; return false;
@ -1217,13 +1216,11 @@ static int item_modification(const unit * u, skill_t sk, int val)
static int att_modification(const unit * u, skill_t sk) static int att_modification(const unit * u, skill_t sk)
{ {
double result = 0; double result = 0;
static const curse_type *skillmod_ct, *gbdream_ct, *worse_ct;
if (u->attribs) {
curse *c; curse *c;
const curse_type *skillmod_ct = ct_find("skillmod");
skillmod_ct = ct_find("skillmod"); const curse_type *worse_ct = ct_find("worse");
gbdream_ct = ct_find("gbdream");
worse_ct = ct_find("worse");
c = get_curse(u->attribs, worse_ct); c = get_curse(u->attribs, worse_ct);
if (c != NULL) if (c != NULL)
result += curse_geteffect(c); result += curse_geteffect(c);
@ -1238,11 +1235,13 @@ static int att_modification(const unit * u, skill_t sk)
a = a->next; a = a->next;
} }
} }
}
/* TODO hier kann nicht mit get/iscursed gearbeitet werden, da nur der /* TODO hier kann nicht mit get/iscursed gearbeitet werden, da nur der
* jeweils erste vom Typ C_GBDREAM zurueckgegen wird, wir aber alle * jeweils erste vom Typ C_GBDREAM zurueckgegen wird, wir aber alle
* durchsuchen und aufaddieren muessen */ * durchsuchen und aufaddieren muessen */
if (gbdream_ct && u->region) { if (u->region && u->region->attribs) {
const curse_type *gbdream_ct = ct_find("gbdream");
if (gbdream_ct) {
int bonus = 0, malus = 0; int bonus = 0, malus = 0;
attrib *a = a_find(u->region->attribs, &at_curse); attrib *a = a_find(u->region->attribs, &at_curse);
while (a && a->type == &at_curse) { while (a && a->type == &at_curse) {
@ -1262,6 +1261,7 @@ static int att_modification(const unit * u, skill_t sk)
} }
result = result + bonus + malus; result = result + bonus + malus;
} }
}
return (int)result; return (int)result;
} }

View File

@ -2012,7 +2012,7 @@ static int sp_treewalkexit(castorder * co)
*/ */
static int sp_holyground(castorder * co) static int sp_holyground(castorder * co)
{ {
static const curse_type *ctype = NULL; const curse_type *ctype = NULL;
region *r = co_get_region(co); region *r = co_get_region(co);
unit *mage = co->magician.u; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
@ -2021,9 +2021,7 @@ static int sp_holyground(castorder * co)
report_spell(mage, r, msg); report_spell(mage, r, msg);
msg_release(msg); msg_release(msg);
if (!ctype) {
ctype = ct_find("holyground"); ctype = ct_find("holyground");
}
create_curse(mage, &r->attribs, ctype, power * power, 1, zero_effect, 0); create_curse(mage, &r->attribs, ctype, power * power, 1, zero_effect, 0);
a_removeall(&r->attribs, &at_deathcount); a_removeall(&r->attribs, &at_deathcount);
@ -3206,15 +3204,14 @@ static int sp_magicboost(castorder * co)
double power = co->force; double power = co->force;
double effect; double effect;
trigger *tsummon; trigger *tsummon;
static const curse_type *ct_auraboost; const curse_type *ct_auraboost;
static const curse_type *ct_magicboost; const curse_type *ct_magicboost;
if (!ct_auraboost) {
ct_auraboost = ct_find("auraboost"); ct_auraboost = ct_find("auraboost");
ct_magicboost = ct_find("magicboost"); ct_magicboost = ct_find("magicboost");
assert(ct_auraboost != NULL); assert(ct_auraboost != NULL);
assert(ct_magicboost != NULL); assert(ct_magicboost != NULL);
}
/* fehler, wenn schon ein boost */ /* fehler, wenn schon ein boost */
if (is_cursed(mage->attribs, C_MBOOST, 0)) { if (is_cursed(mage->attribs, C_MBOOST, 0)) {
report_failure(mage, co->order); report_failure(mage, co->order);

View File

@ -277,21 +277,20 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
int teach_cmd(unit * u, struct order *ord) int teach_cmd(unit * u, struct order *ord)
{ {
static const curse_type *gbdream_ct = NULL;
plane *pl; plane *pl;
region *r = u->region; region *r = u->region;
skill_t sk_academy = NOSKILL; skill_t sk_academy = NOSKILL;
int teaching, i, j, count, academy = 0; int teaching, i, j, count, academy = 0;
if (gbdream_ct == 0) if (u->region->attribs) {
gbdream_ct = ct_find("gbdream"); const curse_type *gbdream_ct = ct_find("gbdream");
if (gbdream_ct) { if (gbdream_ct) {
if (get_curse(u->region->attribs, gbdream_ct)) { if (get_curse(u->region->attribs, gbdream_ct)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "gbdream_noteach", "")); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "gbdream_noteach", ""));
return 0; return 0;
} }
} }
}
if ((u_race(u)->flags & RCF_NOTEACH) || fval(u, UFL_WERE)) { if ((u_race(u)->flags & RCF_NOTEACH) || fval(u, UFL_WERE)) {
cmistake(u, ord, 274, MSG_EVENT); cmistake(u, ord, 274, MSG_EVENT);
return 0; return 0;