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);
|
self = c->type->cansee(viewer, obj, typ, c, self);
|
||||||
}
|
}
|
||||||
dh = c->type->curseinfo(viewer->locale, 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 (dh==0) {
|
||||||
if (c->type->info_str!=NULL) {
|
if (c->type->info_str!=NULL) {
|
||||||
sprintf(buf, "%s (%s)", c->type->info_str, itoa36(c->no));
|
sprintf(buf, "%s (%s)", c->type->info_str, itoa36(c->no));
|
||||||
} else {
|
} else {
|
||||||
|
log_error(("no curseinfo for %s\n", c->type->cname));
|
||||||
sprintf(buf, "an unknown curse lies on the region. (%s)", itoa36(c->no));
|
sprintf(buf, "an unknown curse lies on the region. (%s)", itoa36(c->no));
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
for(;a;a=a->next) {
|
||||||
int dh = 0;
|
|
||||||
|
|
||||||
if (fval(a->type, ATF_CURSE)) {
|
if (fval(a->type, ATF_CURSE)) {
|
||||||
curse *c = (curse *)a->data.v;
|
curse *c = (curse *)a->data.v;
|
||||||
if (c->type->curseinfo) {
|
if (print_curse(c, viewer, obj, typ, self)) {
|
||||||
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) {
|
|
||||||
rnl(F);
|
rnl(F);
|
||||||
rparagraph(F, buf, indent, 2, 0);
|
rparagraph(F, buf, indent, 2, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -737,7 +737,7 @@ oldcursename(int id)
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
int
|
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;
|
struct message * msg;
|
||||||
|
|
||||||
|
|
|
@ -222,15 +222,14 @@ typedef struct curse_type {
|
||||||
unsigned int mergeflags;
|
unsigned int mergeflags;
|
||||||
const char *info_str; /* Wirkung des curse, wird bei einer gelungenen
|
const char *info_str; /* Wirkung des curse, wird bei einer gelungenen
|
||||||
Zauberanalyse angezeigt */
|
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);
|
void (*change_vigour)(curse*, double);
|
||||||
int (*read)(FILE * F, curse * c);
|
int (*read)(FILE * F, curse * c);
|
||||||
int (*write)(FILE * F, const 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 *);
|
int (*age)(curse *);
|
||||||
} curse_type;
|
} curse_type;
|
||||||
|
|
||||||
|
|
||||||
extern attrib_type at_curse;
|
extern attrib_type at_curse;
|
||||||
extern void curse_write(const attrib * a,FILE * f);
|
extern void curse_write(const attrib * a,FILE * f);
|
||||||
extern int curse_read(struct 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: */
|
/*** COMPATIBILITY MACROS. DO NOT USE FOR NEW CODE, REPLACE IN OLD CODE: */
|
||||||
extern const char * oldcursename(int id);
|
extern const char * oldcursename(int id);
|
||||||
extern void register_curses(void);
|
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) \
|
#define is_cursed(a, id, id2) \
|
||||||
curse_active(get_curse(a, ct_find(oldcursename(id))))
|
curse_active(get_curse(a, ct_find(oldcursename(id))))
|
||||||
|
|
|
@ -68,6 +68,7 @@ struct plane;
|
||||||
struct order;
|
struct order;
|
||||||
struct spell;
|
struct spell;
|
||||||
struct region;
|
struct region;
|
||||||
|
struct curse;
|
||||||
struct fighter;
|
struct fighter;
|
||||||
struct region_list;
|
struct region_list;
|
||||||
struct race;
|
struct race;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "reports.h"
|
#include "reports.h"
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
|
#include <kernel/curse.h>
|
||||||
#include <kernel/building.h>
|
#include <kernel/building.h>
|
||||||
#include <kernel/border.h>
|
#include <kernel/border.h>
|
||||||
#include <kernel/terrain.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 ? '+' : '-')));
|
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 *
|
const struct unit *
|
||||||
ucansee(const struct faction *f, const struct unit *u, const struct unit *x)
|
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 update_nmrs(void);
|
||||||
extern int * nmrs;
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
|
|
||||||
static int
|
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;
|
message * msg;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ cinfo_building(const struct locale * lang, const void * obj, typ_t typ, curse *c
|
||||||
|
|
||||||
/* C_MAGICWALLS*/
|
/* C_MAGICWALLS*/
|
||||||
static int
|
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;
|
message * msg = NULL;
|
||||||
if (typ == TYP_BUILDING){
|
if (typ == TYP_BUILDING){
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
* godcursezone
|
* godcursezone
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
region *r;
|
||||||
message * msg;
|
message * msg;
|
||||||
|
@ -82,7 +82,7 @@ static struct curse_type ct_godcursezone = {
|
||||||
* C_GBDREAM
|
* C_GBDREAM
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
message * msg;
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ static struct curse_type ct_gbdream = {
|
||||||
* erzeugt Straßennetz
|
* erzeugt Straßennetz
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
message * msg;
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ static struct curse_type ct_magicstreet = {
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
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;
|
message * msg;
|
||||||
|
|
||||||
|
@ -169,16 +169,16 @@ cinfo_antimagiczone(const struct locale * lang, const void * obj, typ_t typ, cur
|
||||||
if (msg) {
|
if (msg) {
|
||||||
nr_render(msg, lang, buf, sizeof(buf), NULL);
|
nr_render(msg, lang, buf, sizeof(buf), NULL);
|
||||||
msg_release(msg);
|
msg_release(msg);
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* alle Magier können eine Antimagiezone wahrnehmen */
|
/* alle Magier können eine Antimagiezone wahrnehmen */
|
||||||
static int
|
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;
|
region *r;
|
||||||
unit *u = NULL;
|
unit *u = NULL;
|
||||||
|
@ -212,7 +212,7 @@ static struct curse_type ct_antimagiczone = {
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
static int
|
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;
|
message * msg;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
|
|
||||||
int
|
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;
|
message * msg;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ cinfo_ship(const struct locale * lang, const void * obj, typ_t typ, curse *c, in
|
||||||
|
|
||||||
/* C_SHIP_NODRIFT */
|
/* C_SHIP_NODRIFT */
|
||||||
static int
|
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;
|
ship * sh;
|
||||||
unused(typ);
|
unused(typ);
|
||||||
|
|
|
@ -19,7 +19,7 @@ extern "C" {
|
||||||
|
|
||||||
struct locale;
|
struct locale;
|
||||||
struct curse;
|
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);
|
extern void register_shipcurse(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
*/
|
*/
|
||||||
/* erhöht/senkt regeneration und maxaura um effect% */
|
/* erhöht/senkt regeneration und maxaura um effect% */
|
||||||
static int
|
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;
|
struct unit *u;
|
||||||
unused(typ);
|
unused(typ);
|
||||||
|
@ -82,7 +82,7 @@ static struct curse_type ct_magicboost = {
|
||||||
* C_SLAVE
|
* C_SLAVE
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
unit *u;
|
||||||
unused(typ);
|
unused(typ);
|
||||||
|
@ -110,7 +110,7 @@ static struct curse_type ct_slavery = { "slavery",
|
||||||
* C_CALM
|
* C_CALM
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
unit *u;
|
||||||
const struct race * rc;
|
const struct race * rc;
|
||||||
|
@ -147,7 +147,7 @@ static struct curse_type ct_calmmonster = { "calmmonster",
|
||||||
* C_SPEED
|
* C_SPEED
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
unit *u;
|
||||||
curse_unit * cu;
|
curse_unit * cu;
|
||||||
|
@ -179,7 +179,7 @@ static struct curse_type ct_speed = {
|
||||||
* C_ORC
|
* C_ORC
|
||||||
*/
|
*/
|
||||||
int
|
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;
|
unit *u;
|
||||||
message * msg;
|
message * msg;
|
||||||
|
@ -210,7 +210,7 @@ static struct curse_type ct_orcish = {
|
||||||
* C_KAELTESCHUTZ
|
* C_KAELTESCHUTZ
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
unit *u;
|
||||||
curse_unit * cu;
|
curse_unit * cu;
|
||||||
|
@ -241,7 +241,7 @@ static struct curse_type ct_insectfur = {
|
||||||
* C_SPARKLE
|
* C_SPARKLE
|
||||||
*/
|
*/
|
||||||
static int
|
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[] = {
|
const char * effects[] = {
|
||||||
NULL, /* end grau*/
|
NULL, /* end grau*/
|
||||||
|
@ -383,7 +383,7 @@ write_skill(FILE * F, const curse * c)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
unit *u = (unit *)obj;
|
||||||
int sk = c->data.i;
|
int sk = c->data.i;
|
||||||
|
|
|
@ -19,7 +19,7 @@ extern "C" {
|
||||||
|
|
||||||
struct curse;
|
struct curse;
|
||||||
struct locale;
|
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);
|
extern void register_unitcurse(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue