forked from github/server
kill curse cache logic, it was a bad idea.
ct_find is almost never what we want to do.
This commit is contained in:
parent
134ff982ba
commit
c99e92db20
56
src/battle.c
56
src/battle.c
|
@ -55,6 +55,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <attributes/otherfaction.h>
|
||||
#include <attributes/moved.h>
|
||||
#include <spells/buildingcurse.h>
|
||||
#include <spells/regioncurse.h>
|
||||
#include <spells/unitcurse.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/assert.h>
|
||||
|
@ -138,15 +140,10 @@ static int rule_nat_armor;
|
|||
static int rule_cavalry_mode;
|
||||
static int rule_vampire;
|
||||
|
||||
static const curse_type *peace_ct, *slave_ct, *calm_ct;
|
||||
|
||||
/** initialize rules from configuration.
|
||||
*/
|
||||
static void init_rules(void)
|
||||
{
|
||||
peace_ct = ct_find("peacezone");
|
||||
slave_ct = ct_find("slavery");
|
||||
calm_ct = ct_find("calmmonster");
|
||||
rule_nat_armor = config_get_int("rules.combat.nat_armor", 0);
|
||||
rule_tactics_formula = config_get_int("rules.tactics.formula", 0);
|
||||
rule_goblin_bonus = config_get_int("rules.combat.goblinbonus", 10);
|
||||
|
@ -1889,16 +1886,13 @@ int skilldiff(troop at, troop dt, int dist)
|
|||
if (df->building) {
|
||||
building *b = df->building;
|
||||
if (b->attribs) {
|
||||
const curse_type *strongwall_ct = ct_find("strongwall");
|
||||
if (strongwall_ct) {
|
||||
curse *c = get_curse(b->attribs, strongwall_ct);
|
||||
curse *c = get_curse(b->attribs, &ct_strongwall);
|
||||
if (curse_active(c)) {
|
||||
/* wirkt auf alle Geb<65>ude */
|
||||
skdiff -= curse_geteffect_int(c);
|
||||
is_protected = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (b->type->flags & BTF_FORTIFICATION) {
|
||||
int stage = buildingeffsize(b, false);
|
||||
int beff = building_protection(b->type, stage);
|
||||
|
@ -3173,16 +3167,12 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
|
|||
/* Effekte von Spr<70>chen */
|
||||
|
||||
if (u->attribs) {
|
||||
const curse_type *speed_ct;
|
||||
speed_ct = ct_find("speed");
|
||||
if (speed_ct) {
|
||||
curse *c = get_curse(u->attribs, speed_ct);
|
||||
curse *c = get_curse(u->attribs, &ct_speed);
|
||||
if (c) {
|
||||
speeded = get_cursedmen(u, c);
|
||||
speed = curse_geteffect_int(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Effekte von Alchemie */
|
||||
berserk = get_effect(u, oldpotiontype[P_BERSERK]);
|
||||
|
@ -3748,6 +3738,21 @@ static void flee(const troop dt)
|
|||
kill_troop(dt);
|
||||
}
|
||||
|
||||
static bool is_calmed(const unit *u, const faction *f) {
|
||||
attrib *a = a_find(u->attribs, &at_curse);
|
||||
|
||||
while (a && a->type == &at_curse) {
|
||||
curse *c = (curse *)a->data.v;
|
||||
if (c->type == &ct_calmmonster && curse_geteffect_int(c) == f->subscription) {
|
||||
if (curse_active(c)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
a = a->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool start_battle(region * r, battle ** bp)
|
||||
{
|
||||
battle *b = NULL;
|
||||
|
@ -3794,12 +3799,12 @@ static bool start_battle(region * r, battle ** bp)
|
|||
if (fval(u, UFL_LONGACTION))
|
||||
continue;
|
||||
|
||||
if (peace_ct && curse_active(get_curse(r->attribs, peace_ct))) {
|
||||
if (curse_active(get_curse(r->attribs, &ct_peacezone))) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "peace_active", ""));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (slave_ct && curse_active(get_curse(u->attribs, slave_ct))) {
|
||||
if (curse_active(get_curse(u->attribs, &ct_slavery))) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "slave_active", ""));
|
||||
continue;
|
||||
}
|
||||
|
@ -3847,27 +3852,12 @@ static bool start_battle(region * r, battle ** bp)
|
|||
NewbieImmunity()));
|
||||
continue;
|
||||
}
|
||||
/* Fehler: "Die Einheit ist mit uns alliert" */
|
||||
|
||||
if (calm_ct) {
|
||||
attrib *a = a_find(u->attribs, &at_curse);
|
||||
bool calm = false;
|
||||
while (a && a->type == &at_curse) {
|
||||
curse *c = (curse *)a->data.v;
|
||||
if (c->type == calm_ct
|
||||
&& curse_geteffect_int(c) == u2->faction->subscription) {
|
||||
if (curse_active(c)) {
|
||||
calm = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
a = a->next;
|
||||
}
|
||||
if (calm) {
|
||||
/* Fehler: "Die Einheit ist mit uns alliert" */
|
||||
if (is_calmed(u, u2->faction)) {
|
||||
cmistake(u, ord, 47, MSG_BATTLE);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* Ende Fehlerbehandlung */
|
||||
if (b == NULL) {
|
||||
unit *utmp;
|
||||
|
|
|
@ -466,11 +466,9 @@ static void test_battle_skilldiff_building(CuTest *tc)
|
|||
unit *ua, *ud;
|
||||
battle *b = NULL;
|
||||
building_type *btype;
|
||||
const curse_type *strongwall_ct;
|
||||
|
||||
test_setup();
|
||||
btype = setup_castle();
|
||||
strongwall_ct = ct_find("strongwall");
|
||||
|
||||
r = test_create_region(0, 0, 0);
|
||||
ud = test_create_unit(test_create_faction(0), r);
|
||||
|
@ -489,7 +487,7 @@ static void test_battle_skilldiff_building(CuTest *tc)
|
|||
create_curse(NULL, &ud->building->attribs, &ct_magicwalls, 1, 1, 1, 1);
|
||||
CuAssertIntEquals(tc, -2, skilldiff(ta, td, 0));
|
||||
|
||||
create_curse(NULL, &ud->building->attribs, strongwall_ct, 1, 1, 2, 1);
|
||||
create_curse(NULL, &ud->building->attribs, &ct_strongwall, 1, 1, 2, 1);
|
||||
CuAssertIntEquals(tc, -4, skilldiff(ta, td, 0));
|
||||
|
||||
free_battle(b);
|
||||
|
|
|
@ -69,6 +69,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
#include <attributes/reduceproduction.h>
|
||||
#include <attributes/racename.h>
|
||||
#include <spells/buildingcurse.h>
|
||||
|
||||
/* libs includes */
|
||||
#include <math.h>
|
||||
|
@ -728,13 +729,12 @@ static int maintain(building * b)
|
|||
|
||||
void maintain_buildings(region * r)
|
||||
{
|
||||
const curse_type *nocost_ct = ct_find("nocostbuilding");
|
||||
building **bp = &r->buildings;
|
||||
while (*bp) {
|
||||
building *b = *bp;
|
||||
int flags = BLD_MAINTAINED;
|
||||
|
||||
if (!curse_active(get_curse(b->attribs, nocost_ct))) {
|
||||
if (!curse_active(get_curse(b->attribs, &ct_nocostbuilding))) {
|
||||
flags = maintain(b);
|
||||
}
|
||||
fset(b, flags);
|
||||
|
|
|
@ -56,6 +56,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
/* attributes includes */
|
||||
#include <attributes/reduceproduction.h>
|
||||
#include <spells/regioncurse.h>
|
||||
|
||||
typedef struct building_typelist {
|
||||
struct building_typelist *next;
|
||||
|
@ -679,12 +680,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
building *b = largestbuilding(r, cmp_wage, false);
|
||||
int esize = 0;
|
||||
double wage;
|
||||
static int ct_cache;
|
||||
static const struct curse_type *drought_ct;
|
||||
|
||||
if (ct_changed(&ct_cache)) {
|
||||
drought_ct = ct_find("drought");
|
||||
}
|
||||
if (b != NULL) {
|
||||
/* TODO: this reveals imaginary castles */
|
||||
esize = buildingeffsize(b, false);
|
||||
|
@ -709,23 +705,23 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
}
|
||||
if (r->attribs && rule_blessed_harvest() == HARVEST_WORK) {
|
||||
/* E1 rules */
|
||||
wage += curse_geteffect(get_curse(r->attribs, ct_find("blessedharvest")));
|
||||
wage += curse_geteffect(get_curse(r->attribs, &ct_blessedharvest));
|
||||
}
|
||||
}
|
||||
|
||||
if (r->attribs) {
|
||||
attrib *a;
|
||||
const struct curse_type *ctype;
|
||||
curse *c;
|
||||
|
||||
/* Godcurse: Income -10 */
|
||||
ctype = ct_find("godcursezone");
|
||||
if (ctype && curse_active(get_curse(r->attribs, ctype))) {
|
||||
c = get_curse(r->attribs, &ct_godcursezone);
|
||||
if (c && curse_active(c)) {
|
||||
wage = MAX(0, wage - 10);
|
||||
}
|
||||
|
||||
/* Bei einer D<>rre verdient man nur noch ein Viertel */
|
||||
if (drought_ct) {
|
||||
curse *c = get_curse(r->attribs, drought_ct);
|
||||
if (curse_active(c))
|
||||
c = get_curse(r->attribs, &ct_drought);
|
||||
if (c && curse_active(c)) {
|
||||
wage /= curse_geteffect(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -284,17 +284,6 @@ attrib_type at_curse = {
|
|||
|
||||
#define MAXCTHASH 128
|
||||
static selist *cursetypes[MAXCTHASH];
|
||||
static int ct_changes = 1;
|
||||
|
||||
bool ct_changed(int *cache)
|
||||
{
|
||||
assert(cache);
|
||||
if (*cache != ct_changes) {
|
||||
*cache = ct_changes;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ct_register(const curse_type * ct)
|
||||
{
|
||||
|
@ -304,7 +293,6 @@ void ct_register(const curse_type * ct)
|
|||
assert(ct->age==NULL || (ct->flags&CURSE_NOAGE) == 0);
|
||||
assert((ct->flags&CURSE_ISNEW) == 0);
|
||||
selist_set_insert(ctlp, (void *)ct, NULL);
|
||||
++ct_changes;
|
||||
}
|
||||
|
||||
void ct_remove(const char *c)
|
||||
|
@ -320,7 +308,6 @@ void ct_remove(const char *c)
|
|||
|
||||
if (strcmp(c, type->cname) == 0) {
|
||||
selist_delete(&ctl, qi);
|
||||
++ct_changes;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -845,5 +832,4 @@ void curses_done(void) {
|
|||
selist_free(cursetypes[i]);
|
||||
cursetypes[i] = 0;
|
||||
}
|
||||
++ct_changes;
|
||||
}
|
||||
|
|
|
@ -285,7 +285,6 @@ extern "C" {
|
|||
struct curse *get_curse(struct attrib *ap, const curse_type * ctype);
|
||||
|
||||
const curse_type *ct_find(const char *c);
|
||||
bool ct_changed(int *cache);
|
||||
void ct_register(const curse_type *);
|
||||
void ct_remove(const char *c);
|
||||
void ct_checknames(void);
|
||||
|
|
|
@ -159,24 +159,6 @@ static void test_write_flag(CuTest *tc) {
|
|||
cleanup_curse(&fix);
|
||||
}
|
||||
|
||||
static void test_curse_cache(CuTest *tc)
|
||||
{
|
||||
int cache = 0;
|
||||
const curse_type ct_dummy = { "dummy", CURSETYP_NORM, 0, M_SUMEFFECT, NULL };
|
||||
test_setup();
|
||||
CuAssertIntEquals(tc, true, ct_changed(&cache));
|
||||
CuAssertIntEquals(tc, false, ct_changed(&cache));
|
||||
CuAssertPtrEquals(tc, NULL, (void *)ct_find(ct_dummy.cname));
|
||||
ct_register(&ct_dummy);
|
||||
CuAssertIntEquals(tc, true, ct_changed(&cache));
|
||||
CuAssertPtrEquals(tc, (void *)&ct_dummy, (void *)ct_find(ct_dummy.cname));
|
||||
ct_remove(ct_dummy.cname);
|
||||
CuAssertIntEquals(tc, true, ct_changed(&cache));
|
||||
CuAssertIntEquals(tc, false, ct_changed(&cache));
|
||||
CuAssertPtrEquals(tc, NULL, (void *)ct_find(ct_dummy.cname));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_curse_ids(CuTest *tc) {
|
||||
const curse_type ct_dummy = { "dummy", CURSETYP_NORM, 0, M_SUMEFFECT, NULL };
|
||||
curse *c1, *c2;
|
||||
|
@ -218,7 +200,6 @@ CuSuite *get_curse_suite(void)
|
|||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_curse);
|
||||
SUITE_ADD_TEST(suite, test_curse_cache);
|
||||
SUITE_ADD_TEST(suite, test_magicstreet);
|
||||
SUITE_ADD_TEST(suite, test_magicstreet_warning);
|
||||
SUITE_ADD_TEST(suite, test_good_dreams);
|
||||
|
|
|
@ -37,6 +37,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "terrainid.h"
|
||||
#include "unit.h"
|
||||
|
||||
#include <spells/regioncurse.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/assert.h>
|
||||
#include <util/attrib.h>
|
||||
|
@ -1241,8 +1243,9 @@ int production(const region * r)
|
|||
{
|
||||
/* muß rterrain(r) sein, nicht rterrain() wegen rekursion */
|
||||
int p = r->terrain->size;
|
||||
if (curse_active(get_curse(r->attribs, ct_find("drought"))))
|
||||
if (curse_active(get_curse(r->attribs, &ct_drought))) {
|
||||
p /= 2;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <attributes/racename.h>
|
||||
#include <attributes/stealth.h>
|
||||
|
||||
#include <spells/unitcurse.h>
|
||||
#include <spells/regioncurse.h>
|
||||
|
||||
#include "guard.h"
|
||||
|
||||
/* util includes */
|
||||
|
@ -1268,39 +1271,33 @@ static int att_modification(const unit * u, skill_t sk)
|
|||
|
||||
if (u->attribs) {
|
||||
curse *c;
|
||||
static int cache;
|
||||
static const curse_type *skillmod_ct, *worse_ct;
|
||||
if (ct_changed(&cache)) {
|
||||
skillmod_ct = ct_find("skillmod");
|
||||
worse_ct = ct_find("worse");
|
||||
}
|
||||
c = get_curse(u->attribs, worse_ct);
|
||||
if (c != NULL)
|
||||
attrib *a;
|
||||
|
||||
c = get_curse(u->attribs, &ct_worse);
|
||||
if (c != NULL) {
|
||||
result += curse_geteffect(c);
|
||||
if (skillmod_ct) {
|
||||
attrib *a = a_find(u->attribs, &at_curse);
|
||||
}
|
||||
|
||||
a = a_find(u->attribs, &at_curse);
|
||||
while (a && a->type == &at_curse) {
|
||||
curse *c = (curse *)a->data.v;
|
||||
if (c->type == skillmod_ct && c->data.i == sk) {
|
||||
c = (curse *)a->data.v;
|
||||
if (c->type == &ct_skillmod && c->data.i == sk) {
|
||||
result += curse_geteffect(c);
|
||||
break;
|
||||
}
|
||||
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 (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) {
|
||||
curse *c = (curse *)a->data.v;
|
||||
|
||||
if (c->magician && curse_active(c) && c->type == gbdream_ct) {
|
||||
if (c->magician && curse_active(c) && c->type == &ct_gbdream) {
|
||||
int effect = curse_geteffect_int(c);
|
||||
bool allied = alliedunit(c->magician, u->faction, HELP_GUARD);
|
||||
if (allied) {
|
||||
|
@ -1314,7 +1311,6 @@ static int att_modification(const unit * u, skill_t sk)
|
|||
}
|
||||
result = result + bonus + malus;
|
||||
}
|
||||
}
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
|
@ -1738,18 +1734,11 @@ int unit_max_hp(const unit * u)
|
|||
|
||||
/* der healing curse veraendert die maximalen hp */
|
||||
if (u->region && u->region->attribs) {
|
||||
static int cache;
|
||||
static const curse_type *heal_ct;
|
||||
if (ct_changed(&cache)) {
|
||||
heal_ct = ct_find("healingzone");
|
||||
}
|
||||
if (heal_ct) {
|
||||
curse *c = get_curse(u->region->attribs, heal_ct);
|
||||
curse *c = get_curse(u->region->attribs, &ct_healing);
|
||||
if (c) {
|
||||
h = (int)(h * (1.0 + (curse_geteffect(c) / 100)));
|
||||
}
|
||||
}
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <kernel/unit.h>
|
||||
|
||||
#include <spells/flyingship.h>
|
||||
#include <spells/unitcurse.h>
|
||||
|
||||
#include "teleport.h"
|
||||
#include "direction.h"
|
||||
|
@ -1415,15 +1416,12 @@ static int movement_speed(unit * u)
|
|||
}
|
||||
|
||||
if (u->attribs) {
|
||||
const curse_type *speed_ct = ct_find("speed");
|
||||
if (speed_ct) {
|
||||
curse *c = get_curse(u->attribs, speed_ct);
|
||||
curse *c = get_curse(u->attribs, &ct_speed);
|
||||
if (c != NULL) {
|
||||
int men = get_cursedmen(u, c);
|
||||
dk *= 1.0 + (double)men / (double)u->number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (canride(u)) {
|
||||
case 1: /* Pferd */
|
||||
|
|
|
@ -72,6 +72,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <kernel/unit.h>
|
||||
#include <kernel/alliance.h>
|
||||
|
||||
#include <spells/buildingcurse.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
|
@ -1390,7 +1392,6 @@ report_template(const char *filename, report_context * ctx, const char *bom)
|
|||
char buf[8192], *bufp;
|
||||
size_t size;
|
||||
int bytes;
|
||||
const curse_type *nocost_ct = ct_find("nocostbuilding");
|
||||
|
||||
if (F == NULL) {
|
||||
perror(filename);
|
||||
|
@ -1459,7 +1460,7 @@ report_template(const char *filename, report_context * ctx, const char *bom)
|
|||
WARN_STATIC_BUFFER();
|
||||
if (u->building && building_owner(u->building) == u) {
|
||||
building *b = u->building;
|
||||
if (!curse_active(get_curse(b->attribs, nocost_ct))) {
|
||||
if (!curse_active(get_curse(b->attribs, &ct_nocostbuilding))) {
|
||||
int cost = buildingmaintenance(b, rsilver);
|
||||
if (cost > 0) {
|
||||
bytes = (int)strlcpy(bufp, ",U", size);
|
||||
|
|
20
src/spells.c
20
src/spells.c
|
@ -1659,7 +1659,7 @@ static int sp_great_drought(castorder * co)
|
|||
|
||||
/* Arbeitslohn = 1/4 */
|
||||
effect = 4.0; /* curses: higher is stronger */
|
||||
create_curse(mage, &r->attribs, ct_find("drought"), force, duration, effect,
|
||||
create_curse(mage, &r->attribs, &ct_drought, force, duration, effect,
|
||||
0);
|
||||
|
||||
/* terraforming */
|
||||
|
@ -2141,7 +2141,7 @@ static int sp_drought(castorder * co)
|
|||
* hoch (evtl dauert dann die Duerre laenger). Ansonsten volle
|
||||
* Auswirkungen.
|
||||
*/
|
||||
c = get_curse(r->attribs, ct_find("drought"));
|
||||
c = get_curse(r->attribs, &ct_drought);
|
||||
if (c) {
|
||||
c->vigour = MAX(c->vigour, power);
|
||||
c->duration = MAX(c->duration, (int)power);
|
||||
|
@ -2154,7 +2154,7 @@ static int sp_drought(castorder * co)
|
|||
rsettrees(r, 0, rtrees(r, 0) / 2);
|
||||
rsethorses(r, rhorses(r) / 2);
|
||||
|
||||
create_curse(mage, &r->attribs, ct_find("drought"), power, duration, effect,
|
||||
create_curse(mage, &r->attribs, &ct_drought, power, duration, effect,
|
||||
0);
|
||||
}
|
||||
return cast_level;
|
||||
|
@ -3647,7 +3647,7 @@ static int sp_charmingsong(castorder * co)
|
|||
add_trigger(&mage->faction->attribs, "destroy", trigger_killunit(target));
|
||||
}
|
||||
/* sperre ATTACKIERE, GIB PERSON und ueberspringe Migranten */
|
||||
create_curse(mage, &target->attribs, ct_find("slavery"), force, duration, zero_effect, 0);
|
||||
create_curse(mage, &target->attribs, &ct_slavery, force, duration, zero_effect, 0);
|
||||
|
||||
/* setze Partei um und loesche langen Befehl aus Sicherheitsgruenden */
|
||||
u_setfaction(target, mage->faction);
|
||||
|
@ -3921,7 +3921,7 @@ static int sp_song_of_peace(castorder * co)
|
|||
int duration = 2 + lovar(force / 2);
|
||||
message *msg[2] = { NULL, NULL };
|
||||
|
||||
create_curse(mage, &r->attribs, ct_find("peacezone"), force, duration,
|
||||
create_curse(mage, &r->attribs, &ct_peacezone, force, duration,
|
||||
zero_effect, 0);
|
||||
|
||||
for (u = r->units; u; u = u->next)
|
||||
|
@ -4295,7 +4295,7 @@ static int sp_calm_monster(castorder * co)
|
|||
}
|
||||
|
||||
effect = mage->faction->subscription;
|
||||
c = create_curse(mage, &target->attribs, ct_find("calmmonster"), force,
|
||||
c = create_curse(mage, &target->attribs, &ct_calmmonster, force,
|
||||
(int)force, effect, 0);
|
||||
if (c == NULL) {
|
||||
report_failure(mage, co->order);
|
||||
|
@ -5829,7 +5829,7 @@ static int sp_eternizewall(castorder * co)
|
|||
return 0;
|
||||
|
||||
b = pa->param[0]->data.b;
|
||||
c = create_curse(mage, &b->attribs, ct_find("nocostbuilding"),
|
||||
c = create_curse(mage, &b->attribs, &ct_nocostbuilding,
|
||||
power * power, 1, zero_effect, 0);
|
||||
|
||||
if (c == NULL) { /* ist bereits verzaubert */
|
||||
|
@ -6167,7 +6167,7 @@ static int sp_magicrunes(castorder * co)
|
|||
b = pa->param[0]->data.b;
|
||||
|
||||
/* Magieresistenz der Burg erhoeht sich um 20% */
|
||||
create_curse(mage, &b->attribs, ct_find("magicrunes"), force,
|
||||
create_curse(mage, &b->attribs, &ct_magicrunes, force,
|
||||
duration, effect, 0);
|
||||
|
||||
/* Erfolg melden */
|
||||
|
@ -6181,7 +6181,7 @@ static int sp_magicrunes(castorder * co)
|
|||
ship *sh;
|
||||
sh = pa->param[0]->data.sh;
|
||||
/* Magieresistenz des Schiffs erhoeht sich um 20% */
|
||||
create_curse(mage, &sh->attribs, ct_find("magicrunes"), force,
|
||||
create_curse(mage, &sh->attribs, &ct_magicrunes, force,
|
||||
duration, effect, 0);
|
||||
|
||||
/* Erfolg melden */
|
||||
|
@ -6233,7 +6233,7 @@ int sp_speed2(castorder * co)
|
|||
|
||||
men = MIN(maxmen, u->number);
|
||||
effect = 2;
|
||||
create_curse(mage, &u->attribs, ct_find("speed"), force, dur, effect, men);
|
||||
create_curse(mage, &u->attribs, &ct_speed, force, dur, effect, men);
|
||||
maxmen -= men;
|
||||
used += men;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ static message *cinfo_magicrunes(const void *obj, objtype_t typ, const curse * c
|
|||
return msg;
|
||||
}
|
||||
|
||||
static struct curse_type ct_magicrunes = { "magicrunes",
|
||||
const struct curse_type ct_magicrunes = { "magicrunes",
|
||||
CURSETYP_NORM, 0, M_SUMEFFECT, cinfo_magicrunes
|
||||
};
|
||||
|
||||
|
@ -80,12 +80,12 @@ CURSETYP_NORM, CURSE_ONLYONE|CURSE_NOAGE, NO_MERGE, cinfo_building
|
|||
};
|
||||
|
||||
/* Feste Mauer - Präkampfzauber, wirkt nur 1 Runde */
|
||||
static struct curse_type ct_strongwall = { "strongwall",
|
||||
const struct curse_type ct_strongwall = { "strongwall",
|
||||
CURSETYP_NORM, 0, NO_MERGE, NULL
|
||||
};
|
||||
|
||||
/* Ewige Mauern-Zauber */
|
||||
static struct curse_type ct_nocostbuilding = { "nocostbuilding",
|
||||
const struct curse_type ct_nocostbuilding = { "nocostbuilding",
|
||||
CURSETYP_NORM, CURSE_NOAGE | CURSE_ONLYONE, NO_MERGE, cinfo_building
|
||||
};
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ extern "C" {
|
|||
struct curse_type;
|
||||
|
||||
extern const struct curse_type ct_magicwalls;
|
||||
extern const struct curse_type ct_strongwall;
|
||||
extern const struct curse_type ct_magicrunes;
|
||||
extern const struct curse_type ct_nocostbuilding;
|
||||
|
||||
extern void register_buildingcurse(void);
|
||||
struct message *cinfo_building(const void *obj, objtype_t typ, const struct curse * c, int self);
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include <kernel/race.h>
|
||||
#include <kernel/terrain.h>
|
||||
|
||||
#include <spells/buildingcurse.h>
|
||||
|
||||
#include <guard.h>
|
||||
#include <battle.h>
|
||||
#include <move.h>
|
||||
|
@ -879,7 +881,7 @@ int sp_strong_wall(struct castorder * co)
|
|||
burg = mage->building;
|
||||
|
||||
effect = power / 4;
|
||||
create_curse(mage, &burg->attribs, ct_find("strongwall"), power, 1, effect, 0);
|
||||
create_curse(mage, &burg->attribs, &ct_strongwall, power, 1, effect, 0);
|
||||
|
||||
msg =
|
||||
msg_message("sp_strongwalls_effect", "mage building", mage, mage->building);
|
||||
|
|
|
@ -55,7 +55,7 @@ static message *cinfo_cursed_by_the_gods(const void *obj, objtype_t typ,
|
|||
return msg_message("curseinfo::godcurse", "id", c->no);
|
||||
}
|
||||
|
||||
static struct curse_type ct_godcursezone = {
|
||||
const struct curse_type ct_godcursezone = {
|
||||
"godcursezone",
|
||||
CURSETYP_NORM, CURSE_IMMUNE, (NO_MERGE),
|
||||
cinfo_cursed_by_the_gods,
|
||||
|
@ -81,7 +81,7 @@ static message *cinfo_dreamcurse(const void *obj, objtype_t typ, const curse * c
|
|||
}
|
||||
}
|
||||
|
||||
static struct curse_type ct_gbdream = {
|
||||
const struct curse_type ct_gbdream = {
|
||||
"gbdream",
|
||||
CURSETYP_NORM, 0, (NO_MERGE), cinfo_dreamcurse
|
||||
};
|
||||
|
@ -200,13 +200,13 @@ static struct curse_type ct_maelstrom = {
|
|||
cinfo_simple
|
||||
};
|
||||
|
||||
static struct curse_type ct_blessedharvest = {
|
||||
const struct curse_type ct_blessedharvest = {
|
||||
"blessedharvest",
|
||||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
||||
cinfo_simple
|
||||
};
|
||||
|
||||
static struct curse_type ct_drought = {
|
||||
const struct curse_type ct_drought = {
|
||||
"drought",
|
||||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
|
||||
cinfo_simple
|
||||
|
@ -240,7 +240,7 @@ static struct curse_type ct_generous = {
|
|||
};
|
||||
|
||||
/* verhindert Attackiere regional */
|
||||
static struct curse_type ct_peacezone = {
|
||||
const struct curse_type ct_peacezone = {
|
||||
"peacezone",
|
||||
CURSETYP_NORM, 0, NO_MERGE,
|
||||
cinfo_simple
|
||||
|
@ -274,7 +274,7 @@ static struct curse_type ct_holyground = {
|
|||
cinfo_simple
|
||||
};
|
||||
|
||||
static struct curse_type ct_healing = {
|
||||
const struct curse_type ct_healing = {
|
||||
"healingzone",
|
||||
CURSETYP_NORM, 0, (M_VIGOUR | M_DURATION),
|
||||
cinfo_simple
|
||||
|
|
|
@ -17,10 +17,16 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct curse;
|
||||
struct locale;
|
||||
struct curse_type;
|
||||
|
||||
extern void register_regioncurse(void);
|
||||
extern const struct curse_type ct_peacezone;
|
||||
extern const struct curse_type ct_drought;
|
||||
extern const struct curse_type ct_blessedharvest;
|
||||
extern const struct curse_type ct_godcursezone;
|
||||
extern const struct curse_type ct_gbdream;
|
||||
extern const struct curse_type ct_healing;
|
||||
|
||||
void register_regioncurse(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ static message *cinfo_slave(const void *obj, objtype_t typ, const curse * c,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct curse_type ct_slavery = { "slavery",
|
||||
const struct curse_type ct_slavery = { "slavery",
|
||||
CURSETYP_NORM, 0, NO_MERGE,
|
||||
cinfo_slave
|
||||
};
|
||||
|
@ -120,7 +120,7 @@ static message *cinfo_calm(const void *obj, objtype_t typ, const curse * c,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct curse_type ct_calmmonster = {
|
||||
const struct curse_type ct_calmmonster = {
|
||||
"calmmonster",
|
||||
CURSETYP_NORM, CURSE_SPREADNEVER | CURSE_ONLYONE, NO_MERGE,
|
||||
cinfo_calm
|
||||
|
@ -144,7 +144,7 @@ static message *cinfo_speed(const void *obj, objtype_t typ, const curse * c,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct curse_type ct_speed = {
|
||||
const struct curse_type ct_speed = {
|
||||
"speed",
|
||||
CURSETYP_UNIT, CURSE_SPREADNEVER, M_MEN,
|
||||
cinfo_speed
|
||||
|
@ -275,7 +275,7 @@ CURSETYP_UNIT, CURSE_SPREADMODULO, M_MEN, cinfo_simple
|
|||
/*
|
||||
* C_ALLSKILLS (Alp)
|
||||
*/
|
||||
static struct curse_type ct_worse = {
|
||||
const struct curse_type ct_worse = {
|
||||
"worse", CURSETYP_UNIT, CURSE_SPREADMODULO | CURSE_NOAGE, M_MEN, cinfo_unit
|
||||
};
|
||||
|
||||
|
@ -339,7 +339,7 @@ static message *cinfo_skillmod(const void *obj, objtype_t typ, const curse * c,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct curse_type ct_skillmod = {
|
||||
const struct curse_type ct_skillmod = {
|
||||
"skillmod", CURSETYP_NORM, CURSE_SPREADMODULO, M_MEN, cinfo_skillmod,
|
||||
NULL, read_skill, write_skill
|
||||
};
|
||||
|
|
|
@ -20,8 +20,16 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
struct curse;
|
||||
struct curse_type;
|
||||
struct message;
|
||||
extern struct message *cinfo_unit(const void *obj, objtype_t typ,
|
||||
|
||||
extern const struct curse_type ct_slavery;
|
||||
extern const struct curse_type ct_calmmonster;
|
||||
extern const struct curse_type ct_speed;
|
||||
extern const struct curse_type ct_worse;
|
||||
extern const struct curse_type ct_skillmod;
|
||||
|
||||
struct message *cinfo_unit(const void *obj, objtype_t typ,
|
||||
const struct curse *c, int self);
|
||||
|
||||
extern void register_unitcurse(void);
|
||||
|
|
Loading…
Reference in New Issue