More curseinfo everywhere, less code.

This commit is contained in:
Enno Rehling 2007-02-23 23:38:44 +00:00
parent 15d056e423
commit fd06a885f0
10 changed files with 388 additions and 459 deletions

View File

@ -32,11 +32,13 @@
#include "faction.h"
#include "building.h"
#include "ship.h"
#include "message.h"
#include "objtypes.h"
/* util includes */
#include <util/resolve.h>
#include <util/base36.h>
#include <util/nrmessage.h>
#include <util/rand.h>
#include <util/rng.h>
#include <util/goodies.h>
@ -733,3 +735,22 @@ oldcursename(int id)
return oldnames[id];
}
/* ------------------------------------------------------------- */
int
cinfo_simple(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
{
struct message * msg;
unused(typ);
unused(self);
unused(obj);
msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
if (msg) {
nr_render(msg, lang, buf, sizeof(buf), NULL);
msg_release(msg);
return 1;
}
log_warning(("There is no curseinfo for %s.\n", c->type->cname));
return 0;
}

View File

@ -326,6 +326,7 @@ extern boolean curse_active(const curse * c);
/*** COMPATIBILITY MACROS. DO NOT USE FOR NEW CODE, REPLACE IN OLD CODE: */
extern const char * oldcursename(int id);
extern void register_curses(void);
extern int cinfo_simple(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self);
#define is_cursed(a, id, id2) \
curse_active(get_curse(a, ct_find(oldcursename(id))))

View File

@ -121,8 +121,6 @@ static struct curse_type ct_nocostbuilding = { "nocostbuilding",
void
register_buildingcurse(void)
{
register_function((pf_generic)cinfo_magicrunes, "curseinfo::magicrunes");
ct_register(&ct_magicwalls);
ct_register(&ct_strongwall);
ct_register(&ct_magicrunes);

View File

@ -34,30 +34,6 @@
#include <stdlib.h>
#include <assert.h>
/* --------------------------------------------------------------------- */
int
cinfo_region(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
{
message * msg;
unused(typ);
unused(self);
unused(obj);
assert(typ == TYP_REGION);
msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
if (msg) {
nr_render(msg, lang, buf, sizeof(buf), NULL);
msg_release(msg);
return 1;
}
log_warning(("There is no curseinfo for %s.\n", c->type->cname));
return 0;
}
/* --------------------------------------------------------------------- */
/* CurseInfo mit Spezialabfragen
*/
@ -197,18 +173,10 @@ cinfo_antimagiczone(const struct locale * lang, const void * obj, typ_t typ, cur
return 0;
}
static struct curse_type ct_antimagiczone = {
"antimagiczone",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
"Dieser Zauber scheint magische Energien irgendwie abzuleiten und "
"so alle in der Region gezauberten Sprüche in ihrer Wirkung zu "
"schwächen oder ganz zu verhindern.",
cinfo_antimagiczone
};
/* alle Magier können eine Antimagiezone wahrnehmen */
static int
cansee_antimagiczone(const struct faction *viewer, curse *c, const void * obj, typ_t typ, int self)
cansee_antimagiczone(const struct faction *viewer, const void * obj, typ_t typ, curse *c, int self)
{
region *r;
unit *u = NULL;
@ -231,6 +199,14 @@ cansee_antimagiczone(const struct faction *viewer, curse *c, const void * obj, t
}
return self;
}
static struct curse_type ct_antimagiczone = {
"antimagiczone",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
"Dieser Zauber scheint magische Energien irgendwie abzuleiten und "
"so alle in der Region gezauberten Sprüche in ihrer Wirkung zu "
"schwächen oder ganz zu verhindern.",
cinfo_antimagiczone, NULL, NULL, NULL, cansee_antimagiczone
};
/* --------------------------------------------------------------------- */
static int
@ -268,7 +244,7 @@ static struct curse_type ct_fogtrap = {
"fogtrap",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
"",
cinfo_region
cinfo_simple
};
static struct curse_type ct_maelstrom = {
"maelstrom",
@ -282,14 +258,14 @@ static struct curse_type ct_blessedharvest = {
"blessedharvest",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ),
"Dieser Fruchtbarkeitszauber erhöht die Erträge der Felder.",
cinfo_region
cinfo_simple
};
static struct curse_type ct_drought = {
"drought",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ),
"Dieser Zauber strahlt starke negative Energien aus. Warscheinlich "
"ist er die Ursache der Dürre." ,
cinfo_region
cinfo_simple
};
static struct curse_type ct_badlearn = {
"badlearn",
@ -297,7 +273,7 @@ static struct curse_type ct_badlearn = {
"Dieser Zauber scheint die Ursache für die Schlaflosigkeit und "
"Mattigkeit zu sein, unter der die meisten Leute hier leiden und "
"die dazu führt, das Lernen weniger Erfolg bringt. ",
cinfo_region
cinfo_simple
};
/* Trübsal-Zauber */
static struct curse_type ct_depression = {
@ -308,7 +284,7 @@ static struct curse_type ct_depression = {
"hat sich wie ein bleiernes Tuch auf die Gemüter der Bevölkerung "
"gelegt und eh er nicht gebrochen oder verklungen ist, wird keiner "
"sich an Gaukelleien erfreuen können.",
cinfo_region
cinfo_simple
};
/* Astralblock, auf Astralregion */
@ -316,7 +292,7 @@ static struct curse_type ct_astralblock = {
"astralblock",
CURSETYP_NORM, 0, NO_MERGE,
"",
cinfo_region
cinfo_simple
};
/* Unterhaltungsanteil vermehren */
static struct curse_type ct_generous = {
@ -324,7 +300,7 @@ static struct curse_type ct_generous = {
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR | M_MAXEFFECT ),
"Dieser Zauber beeinflusst die allgemeine Stimmung in der Region positiv. "
"Die gute Laune macht die Leute freigiebiger.",
cinfo_region
cinfo_simple
};
/* verhindert Attackiere regional */
static struct curse_type ct_peacezone = {
@ -332,14 +308,14 @@ static struct curse_type ct_peacezone = {
CURSETYP_NORM, 0, NO_MERGE,
"Dieser machtvoller Beeinflussungszauber erstickt jeden Streit schon im "
"Keim.",
cinfo_region
cinfo_simple
};
/* erschwert geordnete Bewegungen */
static struct curse_type ct_disorientationzone = {
"disorientationzone",
CURSETYP_NORM, 0, NO_MERGE,
"",
cinfo_region
cinfo_simple
};
/* erniedigt Magieresistenz von nicht-aliierten Einheiten, wirkt nur 1x
* pro Einheit */
@ -349,7 +325,7 @@ static struct curse_type ct_badmagicresistancezone = {
"Dieses Lied, das irgendwie in die magische Essenz der Region gewoben "
"ist, schwächt die natürliche Widerstandskraft gegen eine "
"Verzauberung. Es scheint jedoch nur auf bestimmte Einheiten zu wirken.",
cinfo_region
cinfo_simple
};
/* erhöht Magieresistenz von aliierten Einheiten, wirkt nur 1x pro
* Einheit */
@ -359,38 +335,32 @@ static struct curse_type ct_goodmagicresistancezone = {
"Dieses Lied, das irgendwie in die magische Essenz der Region gewoben "
"ist, verstärkt die natürliche Widerstandskraft gegen eine "
"Verzauberung. Es scheint jedoch nur auf bestimmte Einheiten zu wirken.",
cinfo_region
cinfo_simple
};
static struct curse_type ct_riotzone = {
"riotzone",
CURSETYP_NORM, 0, (M_DURATION),
NULL,
cinfo_region
cinfo_simple
};
static struct curse_type ct_holyground = {
"holyground",
CURSETYP_NORM, 0, (M_VIGOUR_ADD),
"Verschiedene Naturgeistern sind im Boden der Region gebunden und "
"beschützen diese vor dem der dunklen Magie des lebenden Todes.",
cinfo_region
cinfo_simple
};
static struct curse_type ct_healing = {
"healingzone",
CURSETYP_NORM, 0, (M_VIGOUR | M_DURATION),
"Heilung ist in dieser Region magisch beeinflusst.",
cinfo_region
cinfo_simple
};
void
register_regioncurse(void)
{
register_function((pf_generic)cinfo_cursed_by_the_gods, "curseinfo::cursed_by_the_gods");
register_function((pf_generic)cinfo_dreamcurse, "curseinfo::dreamcurse");
register_function((pf_generic)cinfo_magicstreet, "curseinfo::magicstreet");
register_function((pf_generic)cansee_antimagiczone, "cursecansee::antimagiczone");
ct_register(&ct_fogtrap);
ct_register(&ct_antimagiczone);
ct_register(&ct_farvision);

View File

@ -19,7 +19,6 @@ extern "C" {
struct curse;
struct locale;
extern int cinfo_region(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self);
extern void register_regioncurse(void);

View File

@ -3263,7 +3263,7 @@ dc_age(struct curse * c)
}
static struct curse_type ct_deathcloud = {
"deathcloud", CURSETYP_REGION, 0, NO_MERGE, NULL, cinfo_region, NULL, NULL, NULL, NULL, dc_age
"deathcloud", CURSETYP_REGION, 0, NO_MERGE, NULL, cinfo_simple, NULL, NULL, NULL, NULL, dc_age
};
static curse *

View File

@ -35,29 +35,6 @@
#include <stdlib.h>
#include <assert.h>
/* ------------------------------------------------------------- */
int
cinfo_unit(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
{
struct message * msg;
unused(typ);
unused(self);
unused(obj);
assert(typ == TYP_UNIT);
msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
if (msg) {
nr_render(msg, lang, buf, sizeof(buf), NULL);
msg_release(msg);
return 1;
}
log_warning(("There is no curseinfo for %s.\n", c->type->cname));
return 0;
}
static int
cinfo_unit_onlyowner(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
{
@ -221,8 +198,8 @@ static struct curse_type ct_speed = {
/*
* C_ORC
*/
static int
cinfo_orc(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
int
cinfo_unit(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
{
unit *u;
message * msg;
@ -239,12 +216,13 @@ cinfo_orc(const struct locale * lang, const void * obj, typ_t typ, struct curse
}
return 0;
}
static struct curse_type ct_orcish = {
"orcish",
CURSETYP_UNIT, CURSE_SPREADMODULO, M_MEN,
"Dieser Zauber scheint die Einheit zu 'orkisieren'. Wie bei Orks "
"ist eine deutliche Neigung zur Fortpflanzung zu beobachten.",
cinfo_orc
cinfo_unit
};
/* ------------------------------------------------------------- */
@ -345,53 +323,22 @@ static struct curse_type ct_sparkle = { "sparkle",
/*
* C_STRENGTH
*/
static int
cinfo_strength(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
{
unused(c);
unused(typ);
assert(typ == TYP_UNIT);
unused(obj);
if (self != 0){
sprintf(buf, "Die Leute strotzen nur so vor Kraft. (%s)",
curseid(c));
return 1;
}
return 0;
}
static struct curse_type ct_strength = { "strength",
CURSETYP_UNIT, CURSE_SPREADMODULO, M_MEN,
"Dieser Zauber vermehrt die Stärke der verzauberten Personen um ein "
"vielfaches.",
cinfo_strength
cinfo_simple
};
/* ------------------------------------------------------------- */
/*
* C_ALLSKILLS (Alp)
*/
static int
cinfo_allskills(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
{
unused(obj);
unused(typ);
unused(c);
assert(typ == TYP_UNIT);
if (self != 0){
sprintf(buf, "Wird von einem Alp geritten. (%s)", curseid(c));
return 1;
}
return 0;
}
static struct curse_type ct_worse = {
"worse",
CURSETYP_UNIT, CURSE_SPREADMODULO, M_MEN,
"",
cinfo_allskills
cinfo_unit
};
/* ------------------------------------------------------------- */
@ -399,50 +346,19 @@ static struct curse_type ct_worse = {
/*
* C_ITEMCLOAK
*/
static int
cinfo_itemcloak(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
{
unit *u;
unused(typ);
assert(typ == TYP_UNIT);
u = (unit *)obj;
if (self != 0) {
sprintf(buf, "Die Ausrüstung von %s scheint unsichtbar. (%s)",
u->name, curseid(c));
return 1;
}
return 0;
}
static struct curse_type ct_itemcloak = {
"itemcloak",
CURSETYP_UNIT, CURSE_SPREADNEVER, M_DURATION,
"Dieser Zauber macht die Ausrüstung unsichtbar.",
cinfo_itemcloak
cinfo_unit
};
/* ------------------------------------------------------------- */
static int
cinfo_fumble(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
{
unit * u = (unit*)obj;
unused(typ);
assert(typ == TYP_UNIT);
if (self != 0){
sprintf(buf, "%s kann sich kaum konzentrieren. (%s)",
u->name, curseid(c));
return 1;
}
return 0;
}
static struct curse_type ct_fumble = {
"fumble",
CURSETYP_NORM, CURSE_SPREADNEVER, NO_MERGE,
"Eine Wolke negativer Energie umgibt die Einheit.",
cinfo_fumble
cinfo_unit
};
/* ------------------------------------------------------------- */
@ -452,11 +368,12 @@ static struct curse_type ct_oldrace = { "oldrace",
"",
NULL
};
static struct curse_type ct_magicresistance = { "magicresistance",
CURSETYP_UNIT, CURSE_SPREADMODULO, M_MEN,
"Dieser Zauber verstärkt die natürliche Widerstandskraft gegen eine "
"Verzauberung.",
NULL
cinfo_simple
};
@ -500,6 +417,7 @@ cinfo_skill(const struct locale * lang, const void * obj, typ_t typ, struct curs
}
return 0;
}
static struct curse_type ct_skillmod = {
"skillmod",
CURSETYP_NORM, CURSE_SPREADMODULO, M_MEN,
@ -513,20 +431,6 @@ static struct curse_type ct_skillmod = {
void
register_unitcurse(void)
{
register_function((pf_generic)cinfo_unit_onlyowner, "curseinfo::unit_onlyowner");
register_function((pf_generic)cinfo_auraboost, "curseinfo::auraboost");
register_function((pf_generic)cinfo_slave, "curseinfo::slave");
register_function((pf_generic)cinfo_calm, "curseinfo::calm");
register_function((pf_generic)cinfo_speed, "curseinfo::speed");
register_function((pf_generic)cinfo_orc, "curseinfo::orc");
register_function((pf_generic)cinfo_kaelteschutz, "curseinfo::kaelteschutz");
register_function((pf_generic)cinfo_sparkle, "curseinfo::sparkle");
register_function((pf_generic)cinfo_strength, "curseinfo::strength");
register_function((pf_generic)cinfo_allskills, "curseinfo::allskills");
register_function((pf_generic)cinfo_skill, "curseinfo::skill");
register_function((pf_generic)cinfo_itemcloak, "curseinfo::itemcloak");
register_function((pf_generic)cinfo_fumble, "curseinfo::fumble");
ct_register(&ct_auraboost);
ct_register(&ct_magicboost);
ct_register(&ct_slavery);
@ -544,4 +448,3 @@ register_unitcurse(void)
ct_register(&ct_magicresistance);
}

View File

@ -20,6 +20,7 @@ extern "C" {
struct curse;
struct locale;
extern int cinfo_unit(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self);
extern void register_unitcurse(void);
#ifdef __cplusplus

View File

@ -712,6 +712,7 @@
</string>
<string name="section_newpotions">
<text locale="de">Neue Tränke</text>
<text locale="en">New Potions</text>
</string>
<!--Gebäudetypen -->
@ -2992,19 +2993,19 @@
<string name="alp">
<text locale="de">Alp</text>
<text locale="en">alp</text>
<text locale="en">nightmare</text>
</string>
<string name="alp_p">
<text locale="de">Alps</text>
<text locale="en">alps</text>
<text locale="en">nightmaress</text>
</string>
<string name="alp_d">
<text locale="de">Alps</text>
<text locale="en">alps</text>
<text locale="en">nightmares</text>
</string>
<string name="alp_x">
<text locale="de">Alp</text>
<text locale="en">alp</text>
<text locale="en">nightmare</text>
</string>
<string name="mountainguard">

View File

@ -47,14 +47,49 @@
<text locale="fr">"A fog of negative energy enshrouds the region. ($int36($id))"</text>
<text locale="en">"A fog of negative energy enshrouds the region. ($int36($id))"</text>
</message>
<message name="curseinfo::strength" section="events">
<type>
<arg name="id" type="int"/>
</type>
<text locale="de">"Die Leute strotzen nur so vor Kraft. ($int36($id))"</text>
<text locale="fr">"Testosterone levels are at an all-time high. ($int36($id))"</text>
<text locale="en">"Testosterone levels are at an all-time high. ($int36($id))"</text>
</message>
<message name="curseinfo::worse" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="id" type="int"/>
</type>
<text locale="de">"$unit($unit) wird von einem Alp geritten. ($int36($id))"</text>
<text locale="fr">"$unit($unit) is chased by a nightmare. ($int36($id))"</text>
<text locale="en">"$unit($unit) is chased by a nightmare. ($int36($id))"</text>
</message>
<message name="curseinfo::orcish" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="id" type="int"/>
</type>
<text locale="de">"$unit($unit) stürzt sich von einem amourösen Abenteuer ins nächste. ($int36($id))"</text>
<text locale="fr">"($int36($id))"</text>
<text locale="de">"$unit($unit) goes from one amourous adventure to another. ($int36($id))"</text>
<text locale="fr">"$unit($unit) goes from one amourous adventure to another. ($int36($id))"</text>
<text locale="en">"$unit($unit) goes from one amourous adventure to another. ($int36($id))"</text>
</message>
<message name="curseinfo::fumble" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="id" type="int"/>
</type>
<text locale="de">"$unit($unit) kann sich kaum konzentrieren. ($int36($id))"</text>
<text locale="fr">"$unit($unit) can hardly focus on anything. ($int36($id))"</text>
<text locale="en">"$unit($unit) can hardly focus on anything. ($int36($id))"</text>
</message>
<message name="curseinfo::itemcloak" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="id" type="int"/>
</type>
<text locale="de">"Die Ausrüstung von $unit($unit) scheint unsichtbar. ($int36($id))"</text>
<text locale="fr">"$unit($unit)'s equipment is invisible. ($int36($id))"</text>
<text locale="en">"$unit($unit)'s equipment is invisible. ($int36($id))"</text>
</message>
<message name="curseinfo::magicresistance" section="events">
<type>