forked from github/server
Cleanup in cinfo_ code, although I would prefer that it doesn't write into buf but returns a message *. sometime later.
This commit is contained in:
parent
041a258ab2
commit
da224f6670
|
@ -250,13 +250,12 @@ print_curses(FILE * F, const faction * viewer, const void * obj, typ_t typ)
|
|||
self = c->type->cansee(viewer, obj, typ, c, self);
|
||||
}
|
||||
dh = c->type->curseinfo(viewer->locale, obj, typ, c, self);
|
||||
} else {
|
||||
log_error(("no curseinfo for %s\n", c->type->cname));
|
||||
}
|
||||
if (dh==0) {
|
||||
if (c->type->info_str!=NULL) {
|
||||
sprintf(buf, "%s (%s)", c->type->info_str, itoa36(c->no));
|
||||
} else {
|
||||
log_error(("no curseinfo for %s\n", c->type->cname));
|
||||
sprintf(buf, "an unknown curse lies on the region. (%s)", itoa36(c->no));
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -495,17 +495,10 @@ print_curses(FILE *F, const faction *viewer, const void * obj, typ_t typ, int in
|
|||
}
|
||||
|
||||
for(;a;a=a->next) {
|
||||
int dh = 0;
|
||||
|
||||
if (fval(a->type, ATF_CURSE)) {
|
||||
curse *c = (curse *)a->data.v;
|
||||
if (c->type->curseinfo) {
|
||||
if (c->type->cansee) {
|
||||
self = c->type->cansee(viewer, obj, typ, c, self);
|
||||
}
|
||||
dh = c->type->curseinfo(viewer->locale, obj, typ, c, self);
|
||||
}
|
||||
if (dh == 1) {
|
||||
if (print_curse(c, viewer, obj, typ, self)) {
|
||||
rnl(F);
|
||||
rparagraph(F, buf, indent, 2, 0);
|
||||
}
|
||||
|
|
|
@ -737,7 +737,7 @@ oldcursename(int id)
|
|||
|
||||
/* ------------------------------------------------------------- */
|
||||
int
|
||||
cinfo_simple(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
|
||||
cinfo_simple(const struct locale * lang, const void * obj, typ_t typ, const struct curse *c, int self)
|
||||
{
|
||||
struct message * msg;
|
||||
|
||||
|
|
|
@ -222,15 +222,14 @@ typedef struct curse_type {
|
|||
unsigned int mergeflags;
|
||||
const char *info_str; /* Wirkung des curse, wird bei einer gelungenen
|
||||
Zauberanalyse angezeigt */
|
||||
int (*curseinfo)(const struct locale*, const void*, typ_t, curse*, int);
|
||||
int (*curseinfo)(const struct locale*, const void*, typ_t, const curse*, int);
|
||||
void (*change_vigour)(curse*, double);
|
||||
int (*read)(FILE * F, curse * c);
|
||||
int (*write)(FILE * F, const curse * c);
|
||||
int (*cansee)(const struct faction*, const void*, typ_t, curse *, int);
|
||||
int (*cansee)(const struct faction*, const void*, typ_t, const curse *, int);
|
||||
int (*age)(curse *);
|
||||
} curse_type;
|
||||
|
||||
|
||||
extern attrib_type at_curse;
|
||||
extern void curse_write(const attrib * a,FILE * f);
|
||||
extern int curse_read(struct attrib * a,FILE * f);
|
||||
|
@ -326,7 +325,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);
|
||||
extern int cinfo_simple(const struct locale * lang, const void * obj, typ_t typ, const struct curse *c, int self);
|
||||
|
||||
#define is_cursed(a, id, id2) \
|
||||
curse_active(get_curse(a, ct_find(oldcursename(id))))
|
||||
|
|
|
@ -68,6 +68,7 @@ struct plane;
|
|||
struct order;
|
||||
struct spell;
|
||||
struct region;
|
||||
struct curse;
|
||||
struct fighter;
|
||||
struct region_list;
|
||||
struct race;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "reports.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/curse.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/border.h>
|
||||
#include <kernel/terrain.h>
|
||||
|
@ -808,6 +809,24 @@ spunit(struct strlist ** SP, const struct faction * f, const unit * u, int inden
|
|||
lparagraph(SP, buf, indent, (char) ((u->faction == f) ? '*' : (dh ? '+' : '-')));
|
||||
}
|
||||
|
||||
int
|
||||
print_curse(const struct curse * c, const struct faction * viewer, const void * obj, typ_t typ, int self)
|
||||
{
|
||||
if (c->type->curseinfo) {
|
||||
if (c->type->cansee) {
|
||||
self = c->type->cansee(viewer, obj, typ, c, self);
|
||||
}
|
||||
return c->type->curseinfo(viewer->locale, obj, typ, c, self);
|
||||
} else {
|
||||
if (c->type->info_str!=NULL) {
|
||||
sprintf(buf, "%s (%s)", c->type->info_str, itoa36(c->no));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
log_error(("no curseinfo for %s\n", c->type->cname));
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct unit *
|
||||
ucansee(const struct faction *f, const struct unit *u, const struct unit *x)
|
||||
{
|
||||
|
|
|
@ -110,6 +110,8 @@ extern const char * report_kampfstatus(const struct unit * u, const struct local
|
|||
extern int update_nmrs(void);
|
||||
extern int * nmrs;
|
||||
|
||||
extern int print_curse(const struct curse * c, const struct faction * viewer, const void * obj, typ_t typ, int self);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
|
||||
static int
|
||||
cinfo_building(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self)
|
||||
cinfo_building(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
message * msg;
|
||||
|
||||
|
@ -59,7 +59,7 @@ cinfo_building(const struct locale * lang, const void * obj, typ_t typ, curse *c
|
|||
|
||||
/* C_MAGICWALLS*/
|
||||
static int
|
||||
cinfo_magicrunes(const struct locale* lang, const void * obj, typ_t typ, curse *c, int self)
|
||||
cinfo_magicrunes(const struct locale* lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
message * msg = NULL;
|
||||
if (typ == TYP_BUILDING){
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* godcursezone
|
||||
*/
|
||||
static int
|
||||
cinfo_cursed_by_the_gods(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self)
|
||||
cinfo_cursed_by_the_gods(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
region *r;
|
||||
message * msg;
|
||||
|
@ -82,7 +82,7 @@ static struct curse_type ct_godcursezone = {
|
|||
* C_GBDREAM
|
||||
*/
|
||||
static int
|
||||
cinfo_dreamcurse(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self)
|
||||
cinfo_dreamcurse(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
message * msg;
|
||||
|
||||
|
@ -117,7 +117,7 @@ static struct curse_type ct_gbdream = {
|
|||
* erzeugt Straßennetz
|
||||
*/
|
||||
static int
|
||||
cinfo_magicstreet(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self)
|
||||
cinfo_magicstreet(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
message * msg;
|
||||
|
||||
|
@ -153,7 +153,7 @@ static struct curse_type ct_magicstreet = {
|
|||
/* --------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
cinfo_antimagiczone(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self)
|
||||
cinfo_antimagiczone(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
message * msg;
|
||||
|
||||
|
@ -169,16 +169,16 @@ cinfo_antimagiczone(const struct locale * lang, const void * obj, typ_t typ, cur
|
|||
if (msg) {
|
||||
nr_render(msg, lang, buf, sizeof(buf), NULL);
|
||||
msg_release(msg);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* alle Magier können eine Antimagiezone wahrnehmen */
|
||||
static int
|
||||
cansee_antimagiczone(const struct faction *viewer, const void * obj, typ_t typ, curse *c, int self)
|
||||
cansee_antimagiczone(const struct faction *viewer, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
region *r;
|
||||
unit *u = NULL;
|
||||
|
@ -212,7 +212,7 @@ static struct curse_type ct_antimagiczone = {
|
|||
|
||||
/* --------------------------------------------------------------------- */
|
||||
static int
|
||||
cinfo_farvision(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self)
|
||||
cinfo_farvision(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
message * msg;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
|
||||
int
|
||||
cinfo_ship(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self)
|
||||
cinfo_ship(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
message * msg;
|
||||
|
||||
|
@ -59,7 +59,7 @@ cinfo_ship(const struct locale * lang, const void * obj, typ_t typ, curse *c, in
|
|||
|
||||
/* C_SHIP_NODRIFT */
|
||||
static int
|
||||
cinfo_shipnodrift(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self)
|
||||
cinfo_shipnodrift(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
ship * sh;
|
||||
unused(typ);
|
||||
|
|
|
@ -19,7 +19,7 @@ extern "C" {
|
|||
|
||||
struct locale;
|
||||
struct curse;
|
||||
extern int cinfo_ship(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self);
|
||||
extern int cinfo_ship(const struct locale * lang, const void * obj, typ_t typ, const struct curse *c, int self);
|
||||
extern void register_shipcurse(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
/* erhöht/senkt regeneration und maxaura um effect% */
|
||||
static int
|
||||
cinfo_auraboost(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
|
||||
cinfo_auraboost(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
struct unit *u;
|
||||
unused(typ);
|
||||
|
@ -82,7 +82,7 @@ static struct curse_type ct_magicboost = {
|
|||
* C_SLAVE
|
||||
*/
|
||||
static int
|
||||
cinfo_slave(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
|
||||
cinfo_slave(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
unit *u;
|
||||
unused(typ);
|
||||
|
@ -110,7 +110,7 @@ static struct curse_type ct_slavery = { "slavery",
|
|||
* C_CALM
|
||||
*/
|
||||
static int
|
||||
cinfo_calm(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
|
||||
cinfo_calm(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
unit *u;
|
||||
const struct race * rc;
|
||||
|
@ -147,7 +147,7 @@ static struct curse_type ct_calmmonster = { "calmmonster",
|
|||
* C_SPEED
|
||||
*/
|
||||
static int
|
||||
cinfo_speed(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
|
||||
cinfo_speed(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
unit *u;
|
||||
curse_unit * cu;
|
||||
|
@ -179,7 +179,7 @@ static struct curse_type ct_speed = {
|
|||
* C_ORC
|
||||
*/
|
||||
int
|
||||
cinfo_unit(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
|
||||
cinfo_unit(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
unit *u;
|
||||
message * msg;
|
||||
|
@ -210,7 +210,7 @@ static struct curse_type ct_orcish = {
|
|||
* C_KAELTESCHUTZ
|
||||
*/
|
||||
static int
|
||||
cinfo_kaelteschutz(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
|
||||
cinfo_kaelteschutz(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
unit *u;
|
||||
curse_unit * cu;
|
||||
|
@ -241,7 +241,7 @@ static struct curse_type ct_insectfur = {
|
|||
* C_SPARKLE
|
||||
*/
|
||||
static int
|
||||
cinfo_sparkle(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
|
||||
cinfo_sparkle(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
const char * effects[] = {
|
||||
NULL, /* end grau*/
|
||||
|
@ -383,7 +383,7 @@ write_skill(FILE * F, const curse * c)
|
|||
}
|
||||
|
||||
static int
|
||||
cinfo_skill(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self)
|
||||
cinfo_skill(const struct locale * lang, const void * obj, typ_t typ, const curse *c, int self)
|
||||
{
|
||||
unit *u = (unit *)obj;
|
||||
int sk = c->data.i;
|
||||
|
|
|
@ -19,7 +19,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 int cinfo_unit(const struct locale * lang, const void * obj, typ_t typ, const struct curse *c, int self);
|
||||
|
||||
extern void register_unitcurse(void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue