forked from github/server
eliminate static curse variables (gbdream & more)
This commit is contained in:
parent
1a1ec3f363
commit
f47113e9bd
|
@ -304,7 +304,7 @@ extern "C" {
|
|||
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);
|
||||
#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) \
|
||||
curse_geteffect(get_curse(a, ct_find(oldcursename(id))))
|
||||
|
||||
|
|
|
@ -146,24 +146,25 @@ int deathcount(const region * r)
|
|||
|
||||
void deathcounts(region * r, int fallen)
|
||||
{
|
||||
attrib *a;
|
||||
static const curse_type *ctype = NULL;
|
||||
attrib *a = NULL;
|
||||
|
||||
if (fallen == 0)
|
||||
return;
|
||||
if (!ctype)
|
||||
ctype = ct_find("holyground");
|
||||
if (r->attribs) {
|
||||
const curse_type *ctype = ct_find("holyground");
|
||||
if (ctype && curse_active(get_curse(r->attribs, ctype)))
|
||||
return;
|
||||
|
||||
a = a_find(r->attribs, &at_deathcount);
|
||||
if (!a)
|
||||
}
|
||||
if (!a) {
|
||||
a = a_add(&r->attribs, a_new(&at_deathcount));
|
||||
}
|
||||
a->data.i += fallen;
|
||||
|
||||
if (a->data.i <= 0)
|
||||
if (a->data.i <= 0) {
|
||||
a_remove(&r->attribs, a);
|
||||
}
|
||||
}
|
||||
|
||||
/* Moveblock wird zur Zeit nicht über Attribute, sondern ein Bitfeld
|
||||
r->moveblock gemacht. Sollte umgestellt werden, wenn kompliziertere
|
||||
|
|
|
@ -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))
|
||||
|| (fval(r->terrain, SWIM_INTO) && (u_race(u)->flags & RCF_SWIM))
|
||||
|| (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))
|
||||
return false;
|
||||
|
||||
if (!ctype)
|
||||
ctype = ct_find("holyground");
|
||||
if (r->attribs) {
|
||||
const curse_type *ctype = ct_find("holyground");
|
||||
if (fval(u_race(u), RCF_UNDEAD) && curse_active(get_curse(r->attribs, ctype)))
|
||||
return false;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
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)
|
||||
{
|
||||
double result = 0;
|
||||
static const curse_type *skillmod_ct, *gbdream_ct, *worse_ct;
|
||||
|
||||
if (u->attribs) {
|
||||
curse *c;
|
||||
|
||||
skillmod_ct = ct_find("skillmod");
|
||||
gbdream_ct = ct_find("gbdream");
|
||||
worse_ct = ct_find("worse");
|
||||
|
||||
const curse_type *skillmod_ct = ct_find("skillmod");
|
||||
const curse_type *worse_ct = ct_find("worse");
|
||||
c = get_curse(u->attribs, worse_ct);
|
||||
if (c != NULL)
|
||||
result += curse_geteffect(c);
|
||||
|
@ -1238,11 +1235,13 @@ static int att_modification(const unit * u, skill_t sk)
|
|||
a = a->next;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* TODO hier kann nicht mit get/iscursed gearbeitet werden, da nur der
|
||||
* jeweils erste vom Typ C_GBDREAM zurueckgegen wird, wir aber alle
|
||||
* 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;
|
||||
attrib *a = a_find(u->region->attribs, &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;
|
||||
}
|
||||
}
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
|
11
src/spells.c
11
src/spells.c
|
@ -2012,7 +2012,7 @@ static int sp_treewalkexit(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);
|
||||
unit *mage = co->magician.u;
|
||||
int cast_level = co->level;
|
||||
|
@ -2021,9 +2021,7 @@ static int sp_holyground(castorder * co)
|
|||
report_spell(mage, r, msg);
|
||||
msg_release(msg);
|
||||
|
||||
if (!ctype) {
|
||||
ctype = ct_find("holyground");
|
||||
}
|
||||
create_curse(mage, &r->attribs, ctype, power * power, 1, zero_effect, 0);
|
||||
|
||||
a_removeall(&r->attribs, &at_deathcount);
|
||||
|
@ -3206,15 +3204,14 @@ static int sp_magicboost(castorder * co)
|
|||
double power = co->force;
|
||||
double effect;
|
||||
trigger *tsummon;
|
||||
static const curse_type *ct_auraboost;
|
||||
static const curse_type *ct_magicboost;
|
||||
const curse_type *ct_auraboost;
|
||||
const curse_type *ct_magicboost;
|
||||
|
||||
if (!ct_auraboost) {
|
||||
ct_auraboost = ct_find("auraboost");
|
||||
ct_magicboost = ct_find("magicboost");
|
||||
assert(ct_auraboost != NULL);
|
||||
assert(ct_magicboost != NULL);
|
||||
}
|
||||
|
||||
/* fehler, wenn schon ein boost */
|
||||
if (is_cursed(mage->attribs, C_MBOOST, 0)) {
|
||||
report_failure(mage, co->order);
|
||||
|
|
|
@ -277,21 +277,20 @@ teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
|
|||
|
||||
int teach_cmd(unit * u, struct order *ord)
|
||||
{
|
||||
static const curse_type *gbdream_ct = NULL;
|
||||
plane *pl;
|
||||
region *r = u->region;
|
||||
skill_t sk_academy = NOSKILL;
|
||||
int teaching, i, j, count, academy = 0;
|
||||
|
||||
if (gbdream_ct == 0)
|
||||
gbdream_ct = ct_find("gbdream");
|
||||
if (u->region->attribs) {
|
||||
const curse_type *gbdream_ct = ct_find("gbdream");
|
||||
if (gbdream_ct) {
|
||||
if (get_curse(u->region->attribs, gbdream_ct)) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "gbdream_noteach", ""));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if ((u_race(u)->flags & RCF_NOTEACH) || fval(u, UFL_WERE)) {
|
||||
cmistake(u, ord, 274, MSG_EVENT);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue