2010-08-08 10:06:34 +02:00
|
|
|
/*
|
2015-01-30 22:10:29 +01:00
|
|
|
Copyright (c) 1998-2015, Enno Rehling <enno@eressea.de>
|
2015-01-30 20:37:14 +01:00
|
|
|
Katja Zedel <katze@felidae.kn-bremen.de
|
|
|
|
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
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"
|
2014-10-16 07:34:09 +02:00
|
|
|
#include "types.h"
|
2018-10-24 09:27:48 +02:00
|
|
|
#include "db/driver.h"
|
2017-09-21 16:26:53 +02:00
|
|
|
|
|
|
|
#include <util/resolve.h>
|
2015-09-06 19:04:04 +02:00
|
|
|
#include <modules/score.h>
|
2017-09-21 16:26:53 +02:00
|
|
|
|
2017-01-10 16:31:05 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2010-08-08 10:06:34 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
struct alliance;
|
|
|
|
struct item;
|
|
|
|
struct seen_region;
|
2015-11-24 19:32:52 +01:00
|
|
|
struct attrib_type;
|
2016-02-13 20:43:40 +01:00
|
|
|
struct gamedata;
|
2017-01-26 17:41:21 +01:00
|
|
|
struct selist;
|
2018-10-22 21:51:11 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
/* faction flags */
|
2017-07-09 15:37:42 +02:00
|
|
|
#define FFL_NOAID (1<<0) /* Hilfsflag Kampf */
|
2010-08-08 10:06:34 +02:00
|
|
|
#define FFL_ISNEW (1<<1)
|
2017-02-18 21:15:14 +01:00
|
|
|
#define FFL_PWMSG (1<<2) /* received a "new password" message */
|
2010-08-08 10:06:34 +02:00
|
|
|
#define FFL_QUIT (1<<3)
|
2017-02-18 21:15:14 +01:00
|
|
|
#define FFL_CURSED (1<<4) /* you're going to have a bad time */
|
2010-08-08 10:06:34 +02:00
|
|
|
#define FFL_DEFENDER (1<<10)
|
2017-07-09 15:37:42 +02:00
|
|
|
#define FFL_SELECT (1<<22) /* ehemals f->dh, u->dh, r->dh, etc... */
|
|
|
|
#define FFL_MARK (1<<23) /* fuer markierende algorithmen, die das
|
|
|
|
* hinterher auch wieder loeschen muessen!
|
|
|
|
* (FFL_SELECT muss man vorher initialisieren,
|
|
|
|
* FL_MARK hinterher loeschen) */
|
|
|
|
#define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */
|
|
|
|
#define FFL_NPC (1<<25) /* eine Partei mit Monstern */
|
|
|
|
#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NPC|FFL_NOIDLEOUT|FFL_CURSED)
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2018-10-22 21:51:11 +02:00
|
|
|
typedef struct origin {
|
|
|
|
struct origin *next;
|
|
|
|
int id;
|
|
|
|
int x, y;
|
|
|
|
} origin;
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
typedef struct faction {
|
|
|
|
struct faction *next;
|
|
|
|
struct faction *nexthash;
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
struct region *first;
|
|
|
|
struct region *last;
|
|
|
|
int no;
|
2018-09-24 20:18:21 +02:00
|
|
|
int uid;
|
2015-01-30 20:37:14 +01:00
|
|
|
int flags;
|
|
|
|
char *name;
|
2018-10-24 19:54:07 +02:00
|
|
|
dbrow_id banner_id;
|
2015-01-30 20:37:14 +01:00
|
|
|
char *email;
|
2018-10-24 09:27:48 +02:00
|
|
|
dbrow_id password_id;
|
2015-01-30 20:37:14 +01:00
|
|
|
int max_spelllevel;
|
|
|
|
struct spellbook *spellbook;
|
|
|
|
const struct locale *locale;
|
|
|
|
int lastorders;
|
|
|
|
int age;
|
2018-10-22 21:51:11 +02:00
|
|
|
struct origin *origin;
|
2015-01-30 20:37:14 +01:00
|
|
|
const struct race *race;
|
|
|
|
magic_t magiegebiet;
|
|
|
|
int newbies;
|
|
|
|
int num_people; /* Anzahl Personen ohne Monster */
|
2017-03-11 19:36:26 +01:00
|
|
|
int num_units;
|
2015-01-30 20:37:14 +01:00
|
|
|
int options;
|
2018-10-31 17:54:40 +01:00
|
|
|
struct allies *allies; /* alliedgroup and others should check sf.faction.alive before using a faction from f.allies */
|
2016-01-11 14:42:36 +01:00
|
|
|
struct group *groups; /* alliedgroup and others should check sf.faction.alive before using a faction from f.groups */
|
2015-09-06 19:04:04 +02:00
|
|
|
score_t score;
|
2015-01-30 20:37:14 +01:00
|
|
|
struct alliance *alliance;
|
|
|
|
int alliance_joindate; /* the turn on which the faction joined its current alliance (or left the last one) */
|
|
|
|
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 */
|
2017-01-26 17:41:21 +01:00
|
|
|
struct selist *seen_factions;
|
2016-01-11 09:55:47 +01:00
|
|
|
bool _alive; /* enno: sollte ein flag werden */
|
2015-01-30 20:37:14 +01:00
|
|
|
} faction;
|
|
|
|
|
|
|
|
extern struct faction *factions;
|
|
|
|
|
2018-02-03 14:49:35 +01:00
|
|
|
#define WANT_OPTION(option) (1<<option)
|
2016-11-17 10:38:09 +01:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
void fhash(struct faction *f);
|
|
|
|
void funhash(struct faction *f);
|
|
|
|
|
2018-10-26 19:47:50 +02:00
|
|
|
int faction_ally_status(const faction *f, const faction *f2);
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
struct faction *findfaction(int n);
|
|
|
|
int max_magicians(const faction * f);
|
|
|
|
void set_show_item(faction * f, const struct item_type *itype);
|
|
|
|
|
|
|
|
const char *factionname(const struct faction *f);
|
|
|
|
struct unit *addplayer(struct region *r, faction * f);
|
|
|
|
struct faction *addfaction(const char *email, const char *password,
|
2018-09-24 20:18:21 +02:00
|
|
|
const struct race *frace, const struct locale *loc);
|
2015-01-30 20:37:14 +01:00
|
|
|
bool checkpasswd(const faction * f, const char *passwd);
|
2016-01-12 06:46:51 +01:00
|
|
|
int writepasswd(void);
|
2016-01-11 09:55:47 +01:00
|
|
|
void destroyfaction(faction ** f);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
2016-01-11 14:42:36 +01:00
|
|
|
bool faction_alive(const struct faction *f);
|
2018-10-30 06:30:32 +01:00
|
|
|
struct faction *faction_create(int no);
|
2016-01-11 12:25:23 +01:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
struct alliance *f_get_alliance(const struct faction *f);
|
|
|
|
|
|
|
|
void write_faction_reference(const struct faction *f,
|
|
|
|
struct storage *store);
|
2018-11-01 09:53:23 +01:00
|
|
|
int read_faction_reference(struct gamedata *data, struct faction **fp);
|
2015-01-30 20:37:14 +01:00
|
|
|
|
|
|
|
void renumber_faction(faction * f, int no);
|
2016-01-11 18:17:24 +01:00
|
|
|
void free_factions(void);
|
2018-02-23 21:24:15 +01:00
|
|
|
void log_dead_factions(void);
|
2015-01-30 20:37:14 +01:00
|
|
|
void remove_empty_factions(void);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
void update_interval(struct faction *f, struct region *r);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-01-30 20:37:14 +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
|
|
|
|
2015-01-30 20:37:14 +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
|
|
|
|
2015-01-30 20:37:14 +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
|
|
|
|
2019-01-12 21:26:48 +01:00
|
|
|
char *faction_genpassword(struct faction *f, char *buffer);
|
2016-01-12 23:52:30 +01:00
|
|
|
void faction_setpassword(struct faction *self, const char *pwhash);
|
2018-10-24 09:27:48 +02:00
|
|
|
const char *faction_getpassword(const struct faction *f);
|
2015-01-30 20:37:14 +01:00
|
|
|
bool valid_race(const struct faction *f, const struct race *rc);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
2015-05-19 08:02:32 +02:00
|
|
|
void faction_getorigin(const struct faction * f, int id, int *x, int *y);
|
|
|
|
void faction_setorigin(struct faction * f, int id, int x, int y);
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
struct spellbook * faction_get_spellbook(struct faction *f);
|
2014-06-21 08:59:04 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
/* skills */
|
|
|
|
int skill_limit(struct faction *f, skill_t sk);
|
|
|
|
int count_skill(struct faction *f, skill_t sk);
|
2015-11-22 12:47:57 +01:00
|
|
|
bool faction_id_is_unused(int);
|
2014-06-21 08:59:04 +02:00
|
|
|
|
2015-11-22 15:45:31 +01:00
|
|
|
#define COUNT_MONSTERS 0x01
|
|
|
|
#define COUNT_MIGRANTS 0x02
|
|
|
|
#define COUNT_DEFAULT 0x04
|
|
|
|
|
|
|
|
int count_faction(const struct faction * f, int flags);
|
|
|
|
int count_migrants(const struct faction * f);
|
|
|
|
int count_maxmigrants(const struct faction * f);
|
2015-11-24 19:32:52 +01:00
|
|
|
int max_magicians(const struct faction * f);
|
2015-11-22 15:45:31 +01:00
|
|
|
|
2017-12-25 19:11:12 +01:00
|
|
|
#define MONSTER_ID 666
|
2015-11-24 19:53:27 +01:00
|
|
|
struct faction *getfaction(void);
|
2017-12-25 19:11:12 +01:00
|
|
|
struct faction *get_monsters(void);
|
|
|
|
struct faction *get_or_create_monsters(void);
|
|
|
|
void save_special_items(struct unit *u);
|
|
|
|
|
|
|
|
#define is_monsters(f) (f->no==MONSTER_ID)
|
2015-11-24 19:53:27 +01:00
|
|
|
|
2010-08-08 10:06:34 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|