forked from github/server
avoiding a_select some more, and removing the unused compare-functions
This commit is contained in:
parent
5c474b9eb7
commit
23247f1831
|
@ -3628,9 +3628,19 @@ init_battle(region * r, battle **bp)
|
||||||
/* Fehler: "Die Einheit ist mit uns alliert" */
|
/* Fehler: "Die Einheit ist mit uns alliert" */
|
||||||
|
|
||||||
if (calm_ct) {
|
if (calm_ct) {
|
||||||
variant var;
|
attrib * a = a_find(u->attribs, &at_curse);
|
||||||
var.i = u2->faction->subscription;
|
boolean calm = false;
|
||||||
if (curse_active(get_cursex(u->attribs, calm_ct, var, cmp_curseeffect_int))) {
|
while (a && a->type==&at_curse) {
|
||||||
|
curse * c = (curse *)a->data.v;
|
||||||
|
if (c->type==calm_ct && c->effect.i==u2->faction->subscription) {
|
||||||
|
if (curse_active(c)) {
|
||||||
|
calm = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a = a->next;
|
||||||
|
}
|
||||||
|
if (calm) {
|
||||||
cmistake(u, ord, 47, MSG_BATTLE);
|
cmistake(u, ord, 47, MSG_BATTLE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,29 +267,6 @@ ct_find(const char *c)
|
||||||
* einen pointer auf die struct zurück.
|
* einen pointer auf die struct zurück.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct cid {
|
|
||||||
int id;
|
|
||||||
int id2;
|
|
||||||
} twoids;
|
|
||||||
|
|
||||||
boolean
|
|
||||||
cmp_curseeffect_vptr(const curse * c, variant var)
|
|
||||||
{
|
|
||||||
return (c->effect.v==var.v);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean
|
|
||||||
cmp_curseeffect_int(const curse * c, variant var)
|
|
||||||
{
|
|
||||||
return (c->effect.i==var.i);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean
|
|
||||||
cmp_cursedata_int(const curse * c, variant data)
|
|
||||||
{
|
|
||||||
return (c->data.i==data.i);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
cmp_curse(const attrib * a, const void * data) {
|
cmp_curse(const attrib * a, const void * data) {
|
||||||
const curse * c = (const curse*)data;
|
const curse * c = (const curse*)data;
|
||||||
|
@ -324,7 +301,7 @@ get_cursex(attrib *ap, const curse_type * ctype, variant data, boolean(*compare)
|
||||||
curse *
|
curse *
|
||||||
get_curse(attrib *ap, const curse_type * ctype)
|
get_curse(attrib *ap, const curse_type * ctype)
|
||||||
{
|
{
|
||||||
attrib * a = ap;
|
attrib * a = ap;
|
||||||
while (a) {
|
while (a) {
|
||||||
if (a->type->flags & ATF_CURSE) {
|
if (a->type->flags & ATF_CURSE) {
|
||||||
const attrib_type * at = a->type;
|
const attrib_type * at = a->type;
|
||||||
|
@ -337,7 +314,6 @@ get_curse(attrib *ap, const curse_type * ctype)
|
||||||
a = a->nexttype;
|
a = a->nexttype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,17 +334,6 @@ remove_curse(attrib **ap, const curse *c)
|
||||||
if (a) a_remove(ap, a);
|
if (a) a_remove(ap, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
remove_allcurse(attrib **ap, const void * data, boolean(*compare)(const attrib *, const void *))
|
|
||||||
{
|
|
||||||
attrib * a = a_select(*ap, data, compare);
|
|
||||||
while (a) {
|
|
||||||
attrib * next = a->next;
|
|
||||||
a_remove(ap, a);
|
|
||||||
a = a_select(next, data, compare);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* gibt die allgemeine Stärke der Verzauberung zurück. id2 wird wie
|
/* gibt die allgemeine Stärke der Verzauberung zurück. id2 wird wie
|
||||||
* oben benutzt. Dies ist nicht die Wirkung, sondern die Kraft und
|
* oben benutzt. Dies ist nicht die Wirkung, sondern die Kraft und
|
||||||
* damit der gegen Antimagie wirkende Widerstand einer Verzauberung */
|
* damit der gegen Antimagie wirkende Widerstand einer Verzauberung */
|
||||||
|
|
|
@ -311,9 +311,6 @@ extern int curse_age(struct attrib * a);
|
||||||
|
|
||||||
extern boolean cmp_curse(const attrib * a, const void * data);
|
extern boolean cmp_curse(const attrib * a, const void * data);
|
||||||
extern boolean cmp_cursetype(const attrib * a, const void * data);
|
extern boolean cmp_cursetype(const attrib * a, const void * data);
|
||||||
extern boolean cmp_curseeffect_vptr(const curse * c, variant data);
|
|
||||||
extern boolean cmp_curseeffect_int(const curse * c, variant data);
|
|
||||||
extern boolean cmp_cursedata_int(const curse * c, variant data);
|
|
||||||
|
|
||||||
extern void * resolve_curse(variant data);
|
extern void * resolve_curse(variant data);
|
||||||
extern boolean is_cursed_with(attrib *ap, curse *c);
|
extern boolean is_cursed_with(attrib *ap, curse *c);
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern "C" {
|
||||||
#define RF_MIGRATION (1<<10)
|
#define RF_MIGRATION (1<<10)
|
||||||
#define RF_UNUSED_1 (1<<11)
|
#define RF_UNUSED_1 (1<<11)
|
||||||
#define RF_ORCIFIED (1<<12)
|
#define RF_ORCIFIED (1<<12)
|
||||||
|
#define RF_CURSED (1<<13)
|
||||||
|
|
||||||
#define RF_COMBATDEBUG (1<<14)
|
#define RF_COMBATDEBUG (1<<14)
|
||||||
|
|
||||||
|
|
|
@ -1067,6 +1067,8 @@ att_modification(const unit *u, skill_t sk)
|
||||||
int result = 0;
|
int result = 0;
|
||||||
static boolean init = false;
|
static boolean init = false;
|
||||||
static const curse_type * skillmod_ct, * gbdream_ct, * worse_ct;
|
static const curse_type * skillmod_ct, * gbdream_ct, * worse_ct;
|
||||||
|
curse * c;
|
||||||
|
|
||||||
if (!init) {
|
if (!init) {
|
||||||
init = true;
|
init = true;
|
||||||
skillmod_ct = ct_find("skillmod");
|
skillmod_ct = ct_find("skillmod");
|
||||||
|
@ -1074,33 +1076,41 @@ att_modification(const unit *u, skill_t sk)
|
||||||
worse_ct = ct_find("worse");
|
worse_ct = ct_find("worse");
|
||||||
}
|
}
|
||||||
|
|
||||||
result += curse_geteffect(get_curse(u->attribs, worse_ct));
|
c = get_curse(u->attribs, worse_ct);
|
||||||
|
if (c!=NULL) result += curse_geteffect(c);
|
||||||
if (skillmod_ct) {
|
if (skillmod_ct) {
|
||||||
curse * c;
|
attrib * a = a_find(u->attribs, &at_curse);
|
||||||
variant var;
|
while (a && a->type==&at_curse) {
|
||||||
var.i = sk;
|
curse * c = (curse *)a->data.v;
|
||||||
c = get_cursex(u->attribs, skillmod_ct, var, cmp_cursedata_int);
|
if (c->type==skillmod_ct && c->data.i==sk) {
|
||||||
result += curse_geteffect(c);
|
result += curse_geteffect(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
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 zurückgegen wird, wir aber alle
|
* jeweils erste vom Typ C_GBDREAM zurückgegen wird, wir aber alle
|
||||||
* durchsuchen und aufaddieren müssen */
|
* durchsuchen und aufaddieren müssen */
|
||||||
a = a_select(u->region->attribs, gbdream_ct, cmp_cursetype);
|
a = a_find(u->region->attribs, &at_curse);
|
||||||
while (a) {
|
while (a && a->type==&at_curse) {
|
||||||
curse * c = (curse*)a->data.v;
|
curse * c = (curse*)a->data.v;
|
||||||
int mod = curse_geteffect(c);
|
if (c->type==gbdream_ct) {
|
||||||
unit * mage = c->magician;
|
int mod = curse_geteffect(c);
|
||||||
/* wir suchen jeweils den größten Bonus und den größten Malus */
|
unit * mage = c->magician;
|
||||||
if (mod>0 && (mage==NULL || alliedunit(mage, u->faction, HELP_GUARD)))
|
/* wir suchen jeweils den größten Bonus und den größten Malus */
|
||||||
{
|
if (mod>bonus) {
|
||||||
if (mod > bonus ) bonus = mod;
|
if (mage==NULL || alliedunit(mage, u->faction, HELP_GUARD)) {
|
||||||
} else if (mod < 0 &&
|
bonus = mod;
|
||||||
(mage == NULL || !alliedunit(mage, u->faction, HELP_GUARD)))
|
}
|
||||||
{
|
} else if (mod < malus) {
|
||||||
if (mod < malus ) malus = mod;
|
if (mage == NULL || !alliedunit(mage, u->faction, HELP_GUARD)) {
|
||||||
}
|
malus = mod;
|
||||||
a = a_select(a->next, gbdream_ct, cmp_cursetype);
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a = a->next;
|
||||||
}
|
}
|
||||||
result = result + bonus + malus;
|
result = result + bonus + malus;
|
||||||
|
|
||||||
|
|
|
@ -4066,10 +4066,6 @@ sp_rallypeasantmob(castorder *co)
|
||||||
unit *mage = co->magician.u;
|
unit *mage = co->magician.u;
|
||||||
int cast_level = co->level;
|
int cast_level = co->level;
|
||||||
|
|
||||||
/* TODO
|
|
||||||
remove_allcurse(&r->attribs, C_RIOT, 0);
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (u = r->units; u; u = un){
|
for (u = r->units; u; u = un){
|
||||||
un = u->next;
|
un = u->next;
|
||||||
if (u->faction->no == MONSTER_FACTION && u->race == new_race[RC_PEASANT]){
|
if (u->faction->no == MONSTER_FACTION && u->race == new_race[RC_PEASANT]){
|
||||||
|
|
Loading…
Reference in New Issue