2010-08-08 10:06:34 +02:00
|
|
|
|
/*
|
|
|
|
|
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
|
|
|
|
Katja Zedel <katze@felidae.kn-bremen.de
|
|
|
|
|
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
#ifndef H_KRNL_FACTION
|
|
|
|
|
#define H_KRNL_FACTION
|
2014-06-21 08:59:04 +02:00
|
|
|
|
|
|
|
|
|
#include "skill.h"
|
|
|
|
|
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
|
struct alliance;
|
|
|
|
|
struct item;
|
|
|
|
|
struct seen_region;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
|
|
/* SMART_INTERVALS: define to speed up finding the interval of regions that a
|
|
|
|
|
faction is in. defining this speeds up the turn by 30-40% */
|
|
|
|
|
#define SMART_INTERVALS
|
|
|
|
|
|
|
|
|
|
/* faction flags */
|
2011-03-07 08:02:35 +01:00
|
|
|
|
#define FFL_NEWID (1<<0) /* Die Partei hat bereits einmal ihre no gewechselt */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define FFL_ISNEW (1<<1)
|
|
|
|
|
#define FFL_RESTART (1<<2)
|
|
|
|
|
#define FFL_QUIT (1<<3)
|
|
|
|
|
#define FFL_DEFENDER (1<<10)
|
2011-03-07 08:02:35 +01:00
|
|
|
|
#define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */
|
|
|
|
|
#define FFL_NOAID (1<<21) /* Hilfsflag Kampf */
|
|
|
|
|
#define FFL_MARK (1<<23) /* f<>r markierende algorithmen, die das
|
|
|
|
|
* hinterher auch wieder l<EFBFBD>schen m<EFBFBD>ssen!
|
|
|
|
|
* (FFL_SELECT muss man vorher initialisieren,
|
|
|
|
|
* FL_MARK hinterher l<EFBFBD>schen) */
|
|
|
|
|
#define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */
|
2014-05-06 04:11:40 +02:00
|
|
|
|
#define FFL_NPC (1<<25) /* eine Partei mit Monstern */
|
2011-03-07 08:02:35 +01:00
|
|
|
|
#define FFL_DBENTRY (1<<28) /* Partei ist in Datenbank eingetragen */
|
|
|
|
|
#define FFL_NOTIMEOUT (1<<29) /* ignore MaxAge() */
|
|
|
|
|
#define FFL_GM (1<<30) /* eine Partei mit Sonderrechten */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2014-05-06 04:11:40 +02:00
|
|
|
|
#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_GM|FFL_NPC|FFL_NOTIMEOUT|FFL_DBENTRY|FFL_NOIDLEOUT)
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
|
|
#define is_monsters(f) ((f)->flags&FFL_NPC)
|
|
|
|
|
|
2014-06-23 16:28:10 +02:00
|
|
|
|
typedef struct faction {
|
2011-03-07 08:02:35 +01:00
|
|
|
|
struct faction *next;
|
|
|
|
|
struct faction *nexthash;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
|
|
#ifdef SMART_INTERVALS
|
2011-03-07 08:02:35 +01:00
|
|
|
|
struct region *first;
|
|
|
|
|
struct region *last;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#endif
|
2011-03-07 08:02:35 +01:00
|
|
|
|
int no;
|
|
|
|
|
int subscription;
|
2014-05-06 04:11:40 +02:00
|
|
|
|
int flags;
|
2011-03-07 08:02:35 +01:00
|
|
|
|
char *name;
|
|
|
|
|
char *banner;
|
|
|
|
|
char *email;
|
|
|
|
|
char *passw;
|
|
|
|
|
int max_spelllevel;
|
2012-05-24 09:56:54 +02:00
|
|
|
|
struct spellbook *spellbook;
|
2011-03-07 08:02:35 +01:00
|
|
|
|
const struct locale *locale;
|
|
|
|
|
int lastorders;
|
|
|
|
|
int age;
|
|
|
|
|
struct ursprung *ursprung;
|
|
|
|
|
const struct race *race;
|
|
|
|
|
magic_t magiegebiet;
|
|
|
|
|
int newbies;
|
|
|
|
|
int num_people; /* Anzahl Personen ohne Monster */
|
|
|
|
|
int num_total; /* Anzahl Personen mit Monstern */
|
|
|
|
|
int options;
|
|
|
|
|
int no_units;
|
|
|
|
|
struct ally *allies;
|
|
|
|
|
struct group *groups;
|
2012-06-24 07:41:07 +02:00
|
|
|
|
bool alive; /* enno: sollte ein flag werden */
|
2011-03-07 08:02:35 +01:00
|
|
|
|
int nregions;
|
|
|
|
|
int money;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#if SCORE_MODULE
|
2011-03-07 08:02:35 +01:00
|
|
|
|
int score;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#endif
|
2011-03-07 08:02:35 +01:00
|
|
|
|
struct alliance *alliance;
|
|
|
|
|
int alliance_joindate; /* the turn on which the faction joined its current alliance (or left the last one) */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#ifdef VICTORY_DELAY
|
2011-03-07 08:02:35 +01:00
|
|
|
|
unsigned char victory_delay;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#endif
|
2011-03-07 08:02:35 +01:00
|
|
|
|
struct unit *units;
|
|
|
|
|
struct attrib *attribs;
|
|
|
|
|
struct message_list *msgs;
|
|
|
|
|
struct bmsg {
|
|
|
|
|
struct bmsg *next;
|
|
|
|
|
struct region *r;
|
|
|
|
|
struct message_list *msgs;
|
|
|
|
|
} *battles;
|
|
|
|
|
struct item *items; /* items this faction can claim */
|
|
|
|
|
struct seen_region **seen;
|
|
|
|
|
struct quicklist *seen_factions;
|
2014-06-23 16:28:10 +02:00
|
|
|
|
} faction;
|
2011-03-07 08:02:35 +01:00
|
|
|
|
|
2014-06-23 16:28:10 +02:00
|
|
|
|
extern struct faction *factions;
|
2011-03-07 08:02:35 +01:00
|
|
|
|
|
2014-06-23 16:28:10 +02:00
|
|
|
|
struct faction *get_monsters(void);
|
2014-08-16 13:46:34 +02:00
|
|
|
|
struct faction *get_or_create_monsters(void);
|
2014-06-23 16:28:10 +02:00
|
|
|
|
int max_magicians(const faction * f);
|
|
|
|
|
void set_show_item(faction * f, const struct item_type *itype);
|
2014-06-21 08:59:04 +02:00
|
|
|
|
|
2014-06-23 16:28:10 +02:00
|
|
|
|
const struct unit *random_unit_in_faction(const struct faction *f);
|
|
|
|
|
const char *factionname(const struct faction *f);
|
|
|
|
|
struct unit *addplayer(struct region *r, faction * f);
|
|
|
|
|
struct faction *addfaction(const char *email, const char *password,
|
2011-03-07 08:02:35 +01:00
|
|
|
|
const struct race *frace, const struct locale *loc, int subscription);
|
2014-06-23 16:28:10 +02:00
|
|
|
|
bool checkpasswd(const faction * f, const char *passwd, bool shortp);
|
|
|
|
|
void destroyfaction(faction * f);
|
2011-03-07 08:02:35 +01:00
|
|
|
|
|
|
|
|
|
extern void set_alliance(struct faction *a, struct faction *b, int status);
|
|
|
|
|
extern int get_alliance(const struct faction *a, const struct faction *b);
|
|
|
|
|
|
2012-06-27 05:29:32 +02:00
|
|
|
|
extern struct alliance *f_get_alliance(const struct faction *f);
|
2011-03-07 08:02:35 +01:00
|
|
|
|
|
|
|
|
|
extern void write_faction_reference(const struct faction *f,
|
|
|
|
|
struct storage *store);
|
|
|
|
|
extern variant read_faction_reference(struct storage *store);
|
|
|
|
|
extern int resolve_faction(variant data, void *addr);
|
|
|
|
|
|
|
|
|
|
extern void renumber_faction(faction * f, int no);
|
|
|
|
|
void free_faction(struct faction *f);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
|
|
#ifdef SMART_INTERVALS
|
2011-03-07 08:02:35 +01:00
|
|
|
|
extern void update_interval(struct faction *f, struct region *r);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
|
const char *faction_getbanner(const struct faction *self);
|
|
|
|
|
void faction_setbanner(struct faction *self, const char *name);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
|
const char *faction_getname(const struct faction *self);
|
|
|
|
|
void faction_setname(struct faction *self, const char *name);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
|
const char *faction_getemail(const struct faction *self);
|
|
|
|
|
void faction_setemail(struct faction *self, const char *email);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
|
const char *faction_getpassword(const struct faction *self);
|
|
|
|
|
void faction_setpassword(struct faction *self, const char *password);
|
2012-06-24 07:41:07 +02:00
|
|
|
|
bool valid_race(const struct faction *f, const struct race *rc);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2012-05-26 09:33:55 +02:00
|
|
|
|
struct spellbook * faction_get_spellbook(struct faction *f);
|
2014-06-21 08:59:04 +02:00
|
|
|
|
|
|
|
|
|
/* skills */
|
|
|
|
|
int skill_limit(struct faction *f, skill_t sk);
|
|
|
|
|
int count_skill(struct faction *f, skill_t sk);
|
|
|
|
|
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|