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>
|
2014-07-23 11:54:51 +02: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 ERESSEA_H
|
|
|
|
|
#define ERESSEA_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* this should always be the first thing included after platform.h */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#include "types.h"
|
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* experimental gameplay features (that don't affect the savefile) */
|
|
|
|
|
/* TODO: move these settings to settings.h or into configuration files */
|
2011-03-07 08:02:35 +01:00
|
|
|
|
#define GOBLINKILL /* Goblin-Spezialklau kann t<>dlich enden */
|
|
|
|
|
#define HERBS_ROT /* herbs owned by units have a chance to rot. */
|
|
|
|
|
#define INSECT_POTION /* Spezialtrank f<>r Insekten */
|
|
|
|
|
#define ORCIFICATION /* giving snotlings to the peasants gets counted */
|
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* for some good prime numbers, check http://www.math.niu.edu/~rusin/known-math/98/pi_x */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#ifndef MAXREGIONS
|
2011-03-07 08:02:35 +01:00
|
|
|
|
# define MAXREGIONS 524287 /* must be prime for hashing. 262139 was a little small */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#endif
|
|
|
|
|
#ifndef MAXUNITS
|
2011-03-07 08:02:35 +01:00
|
|
|
|
# define MAXUNITS 1048573 /* must be prime for hashing. 524287 was >90% full */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#endif
|
2014-12-25 22:38:01 +01:00
|
|
|
|
#define MAXLUXURIES 16 /* there must be no more than MAXLUXURIES kinds of luxury goods in any game */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2014-09-18 12:10:42 +02:00
|
|
|
|
#define TREESIZE (8) /* space used by trees (in #peasants) */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
|
#define PEASANTFORCE 0.75 /* Chance einer Vermehrung trotz 90% Auslastung */
|
|
|
|
|
#define HERBROTCHANCE 5 /* Verrottchance f<>r Kr<4B>uter (ifdef HERBS_ROT) */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Geb<65>udegr<67><72>e = Minimalbelagerer */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define SIEGEFACTOR 2
|
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/** Magic */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define MAXMAGICIANS 3
|
|
|
|
|
#define MAXALCHEMISTS 3
|
|
|
|
|
|
2014-12-12 20:53:39 +01:00
|
|
|
|
/* getunit results: */
|
|
|
|
|
#define GET_UNIT 0
|
|
|
|
|
#define GET_NOTFOUND 1
|
|
|
|
|
#define GET_PEASANTS 2
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Bewegungsweiten: */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define BP_WALKING 4
|
|
|
|
|
#define BP_RIDING 6
|
|
|
|
|
#define BP_UNICORN 9
|
|
|
|
|
#define BP_DRAGON 4
|
|
|
|
|
|
|
|
|
|
#define BP_NORMAL 3
|
|
|
|
|
#define BP_ROAD 2
|
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
|
#define PERSON_WEIGHT 1000 /* weight of a "normal" human unit */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define STAMINA_AFFECTS_HP 1<<0
|
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/**
|
|
|
|
|
* Hier endet der Teil von config.h, der die defines f<EFBFBD>r die
|
|
|
|
|
* Spielwelt Eressea enth<EFBFBD>lt, und beginnen die allgemeinen Routinen
|
|
|
|
|
*/
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2011-03-07 08:02:35 +01:00
|
|
|
|
#define ENCCHANCE 10 /* %-Chance f<>r einmalige Zufallsbegegnung */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2013-12-31 10:06:28 +01:00
|
|
|
|
#define DISPLAYSIZE 8192 /* max. L<>nge einer Beschreibung, incl trailing 0 */
|
2014-08-14 09:57:05 +02:00
|
|
|
|
#define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */
|
2013-12-31 10:06:28 +01:00
|
|
|
|
#define NAMESIZE 128 /* max. L<>nge eines Namens, incl trailing 0 */
|
|
|
|
|
#define IDSIZE 16 /* max. L<>nge einer no (als String), incl trailing 0 */
|
2011-03-07 08:02:35 +01:00
|
|
|
|
#define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. L<>nge der Strings, die
|
2014-07-23 11:54:51 +02:00
|
|
|
|
* von struct unitname, etc. zur<EFBFBD>ckgegeben werden. ohne die 0 */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2014-11-01 12:09:56 +01:00
|
|
|
|
#define BAGCAPACITY 20000 /* soviel pa<70>t in einen Bag of Holding */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* ----------------- Befehle ----------------------------------- */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
|
|
#define want(option) (1<<option)
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* ------------------------------------------------------------- */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2012-06-24 07:41:07 +02:00
|
|
|
|
#define i2b(i) ((bool)((i)?(true):(false)))
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
|
|
#define fval(u, i) ((u)->flags & (i))
|
|
|
|
|
#define fset(u, i) ((u)->flags |= (i))
|
|
|
|
|
#define freset(u, i) ((u)->flags &= ~(i))
|
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* parteinummern */
|
|
|
|
|
bool faction_id_is_unused(int);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
int max_magicians(const struct faction * f);
|
|
|
|
|
int findoption(const char *s, const struct locale *lang);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
param_t findparam(const char *s, const struct locale *lang);
|
|
|
|
|
param_t findparam_ex(const char *s, const struct locale * lang);
|
|
|
|
|
bool isparam(const char *s, const struct locale * lang, param_t param);
|
|
|
|
|
param_t getparam(const struct locale *lang);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
|
|
#define unitid(x) itoa36((x)->no)
|
|
|
|
|
|
|
|
|
|
#define buildingid(x) itoa36((x)->no)
|
|
|
|
|
#define shipid(x) itoa36((x)->no)
|
|
|
|
|
#define factionid(x) itoa36((x)->no)
|
|
|
|
|
#define curseid(x) itoa36((x)->no)
|
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
const char * game_name(void);
|
|
|
|
|
int game_id(void);
|
|
|
|
|
int lovar(double xpct_x2);
|
|
|
|
|
/* returns a value between [0..xpct_2], generated with two dice */
|
|
|
|
|
|
|
|
|
|
int distribute(int old, int new_value, int n);
|
2014-09-29 21:19:07 +02:00
|
|
|
|
void init_locale(struct locale *lang);
|
2014-07-23 11:54:51 +02:00
|
|
|
|
|
|
|
|
|
int newunitid(void);
|
|
|
|
|
int forbiddenid(int id);
|
|
|
|
|
int newcontainerid(void);
|
|
|
|
|
|
2014-12-12 20:53:39 +01:00
|
|
|
|
int getunit(const struct region * r, const struct faction * f, struct unit **uresult);
|
2014-07-23 11:54:51 +02:00
|
|
|
|
|
|
|
|
|
int read_unitid(const struct faction *f, const struct region *r);
|
|
|
|
|
|
|
|
|
|
int alliedunit(const struct unit *u, const struct faction *f2,
|
|
|
|
|
int mode);
|
|
|
|
|
int alliedfaction(const struct plane *pl, const struct faction *f,
|
|
|
|
|
const struct faction *f2, int mode);
|
|
|
|
|
int alliedgroup(const struct plane *pl, const struct faction *f,
|
|
|
|
|
const struct faction *f2, const struct ally *sf, int mode);
|
|
|
|
|
|
|
|
|
|
struct faction *getfaction(void);
|
|
|
|
|
|
2014-12-09 05:55:16 +01:00
|
|
|
|
char *untilde(char *s);
|
2014-07-23 11:54:51 +02:00
|
|
|
|
|
|
|
|
|
typedef int(*cmp_building_cb) (const struct building * b,
|
|
|
|
|
const struct building * a);
|
|
|
|
|
struct building *largestbuilding(const struct region *r, cmp_building_cb,
|
|
|
|
|
bool imaginary);
|
|
|
|
|
int cmp_wage(const struct building *b, const struct building *bother);
|
|
|
|
|
int cmp_taxes(const struct building *b, const struct building *bother);
|
|
|
|
|
int cmp_current_owner(const struct building *b,
|
|
|
|
|
const struct building *bother);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2015-09-11 10:04:08 +02:00
|
|
|
|
bool rule_region_owners(void);
|
2015-11-09 13:36:52 +01:00
|
|
|
|
bool rule_stealth_other(void); // units can pretend to be another faction, TARNE PARTEI <no>
|
|
|
|
|
bool rule_stealth_anon(void); // units can anonymize their faction, TARNE PARTEI [NICHT]
|
2015-09-11 10:04:08 +02:00
|
|
|
|
int rule_alliance_limit(void);
|
|
|
|
|
int rule_faction_limit(void);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define HARVEST_WORK 0x00
|
|
|
|
|
#define HARVEST_TAXES 0x01
|
2014-07-23 11:54:51 +02:00
|
|
|
|
int rule_blessed_harvest(void);
|
2015-09-11 10:04:08 +02:00
|
|
|
|
#define GIVE_SELF 1
|
|
|
|
|
#define GIVE_PEASANTS 2
|
|
|
|
|
#define GIVE_LUXURIES 4
|
|
|
|
|
#define GIVE_HERBS 8
|
|
|
|
|
#define GIVE_GOODS 16
|
|
|
|
|
#define GIVE_ONDEATH 32
|
|
|
|
|
#define GIVE_ALLITEMS (GIVE_GOODS|GIVE_HERBS|GIVE_LUXURIES)
|
|
|
|
|
#define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS)
|
2014-07-23 11:54:51 +02:00
|
|
|
|
int rule_give(void);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2014-05-25 05:25:06 +02:00
|
|
|
|
#define COUNT_MONSTERS 0x01
|
|
|
|
|
#define COUNT_MIGRANTS 0x02
|
|
|
|
|
#define COUNT_DEFAULT 0x04
|
|
|
|
|
#define COUNT_ALL 0x07
|
|
|
|
|
#define COUNT_UNITS 0x10
|
2014-07-23 11:54:51 +02:00
|
|
|
|
|
2014-05-25 05:25:06 +02:00
|
|
|
|
int count_faction(const struct faction * f, int flags);
|
|
|
|
|
int count_migrants(const struct faction * f);
|
|
|
|
|
int count_maxmigrants(const struct faction * f);
|
|
|
|
|
int count_all(const struct faction * f);
|
|
|
|
|
int count_units(const struct faction * f);
|
|
|
|
|
|
|
|
|
|
bool has_limited_skills(const struct unit *u);
|
|
|
|
|
const struct race *findrace(const char *, const struct locale *);
|
|
|
|
|
|
2014-12-10 23:04:54 +01:00
|
|
|
|
bool unit_has_cursed_item(const struct unit *u);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* grammatik-flags: */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GF_NONE 0
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* singular, ohne was dran */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GF_PLURAL 1
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Angaben in Mehrzahl */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GF_ARTICLE 8
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* der, die, eine */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GF_SPECIFIC 16
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* der, die, das vs. ein, eine */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GF_DETAILED 32
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* mehr Informationen. z.b. stra<72>e zu 50% */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GF_PURE 64
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* untranslated */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
|
|
#define GUARD_NONE 0
|
|
|
|
|
#define GUARD_TAX 1
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Verhindert Steuereintreiben */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GUARD_MINING 2
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Verhindert Bergbau */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GUARD_TREES 4
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Verhindert Waldarbeiten */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GUARD_TRAVELTHRU 8
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Blockiert Durchreisende */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GUARD_LANDING 16
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Verhindert Ausstieg + Weiterreise */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GUARD_CREWS 32
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Verhindert Unterhaltung auf Schiffen */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GUARD_RECRUIT 64
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Verhindert Rekrutieren */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GUARD_PRODUCE 128
|
2014-07-23 11:54:51 +02:00
|
|
|
|
/* Verhindert Abbau von Resourcen mit RTF_LIMITED */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
#define GUARD_ALL 0xFFFF
|
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
void setstatus(struct unit *u, int status);
|
|
|
|
|
/* !< sets combatstatus of a unit */
|
|
|
|
|
int besieged(const struct unit *u);
|
|
|
|
|
int maxworkingpeasants(const struct region *r);
|
|
|
|
|
bool has_horses(const struct unit *u);
|
2015-11-09 13:36:52 +01:00
|
|
|
|
bool markets_module(void);
|
2014-07-23 11:54:51 +02:00
|
|
|
|
int wage(const struct region *r, const struct faction *f,
|
|
|
|
|
const struct race *rc, int in_turn);
|
|
|
|
|
int maintenance_cost(const struct unit *u);
|
|
|
|
|
|
|
|
|
|
const char *datapath(void);
|
|
|
|
|
void set_datapath(const char *path);
|
|
|
|
|
|
|
|
|
|
const char *basepath(void);
|
|
|
|
|
void set_basepath(const char *);
|
|
|
|
|
|
|
|
|
|
const char *reportpath(void);
|
|
|
|
|
void set_reportpath(const char *);
|
|
|
|
|
|
|
|
|
|
void kernel_init(void);
|
|
|
|
|
void kernel_done(void);
|
|
|
|
|
|
|
|
|
|
/* globale settings des Spieles */
|
|
|
|
|
typedef struct settings {
|
|
|
|
|
const char *gamename;
|
|
|
|
|
struct attrib *attribs;
|
|
|
|
|
unsigned int data_turn;
|
|
|
|
|
struct param *parameters;
|
|
|
|
|
void *vm_state;
|
|
|
|
|
int data_version; /* TODO: eliminate in favor of gamedata.version */
|
|
|
|
|
struct _dictionary_ *inifile;
|
|
|
|
|
|
|
|
|
|
struct global_functions {
|
|
|
|
|
int(*wage) (const struct region * r, const struct faction * f,
|
|
|
|
|
const struct race * rc, int in_turn);
|
|
|
|
|
int(*maintenance) (const struct unit * u);
|
|
|
|
|
} functions;
|
2015-09-12 16:49:18 +02:00
|
|
|
|
/* the following are some cached values, because get_param can be slow.
|
|
|
|
|
* you should almost never need to touch them */
|
|
|
|
|
int cookie;
|
2014-07-23 11:54:51 +02:00
|
|
|
|
} settings;
|
|
|
|
|
|
|
|
|
|
typedef struct helpmode {
|
|
|
|
|
const char *name;
|
|
|
|
|
int status;
|
|
|
|
|
} helpmode;
|
|
|
|
|
|
|
|
|
|
const char *dbrace(const struct race *rc);
|
|
|
|
|
|
2015-11-22 10:33:31 +01:00
|
|
|
|
void set_param(struct param **p, const char *key, const char *value);
|
2014-08-08 13:29:26 +02:00
|
|
|
|
const char *get_param(const struct param *p, const char *key);
|
|
|
|
|
int get_param_int(const struct param *p, const char *key, int def);
|
|
|
|
|
int check_param(const struct param *p, const char *key, const char *searchvalue);
|
2015-09-12 16:38:39 +02:00
|
|
|
|
double get_param_flt(const struct param *p, const char *key, double def);
|
2015-09-05 18:14:28 +02:00
|
|
|
|
void free_params(struct param **pp);
|
2014-07-23 11:54:51 +02:00
|
|
|
|
|
2015-11-22 10:33:31 +01:00
|
|
|
|
void config_set(const char *key, const char *value);
|
|
|
|
|
const char *config_get(const char *key);
|
|
|
|
|
int config_get_int(const char *key, int def);
|
|
|
|
|
double config_get_flt(const char *key, double def);
|
2015-11-22 12:20:33 +01:00
|
|
|
|
bool config_token(const char *key, const char *tok);
|
2015-11-22 10:33:31 +01:00
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
bool ExpensiveMigrants(void);
|
|
|
|
|
int NMRTimeout(void);
|
|
|
|
|
int LongHunger(const struct unit *u);
|
|
|
|
|
int NewbieImmunity(void);
|
|
|
|
|
bool IsImmune(const struct faction *f);
|
|
|
|
|
int AllianceAuto(void); /* flags that allied factions get automatically */
|
|
|
|
|
int AllianceRestricted(void); /* flags restricted to allied factions */
|
|
|
|
|
int HelpMask(void); /* flags restricted to allied factions */
|
2015-08-05 00:03:30 +02:00
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
struct order *default_order(const struct locale *lang);
|
2015-08-05 00:03:30 +02:00
|
|
|
|
void set_default_order(int kwd);
|
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
int entertainmoney(const struct region *r);
|
2015-08-05 12:19:17 +02:00
|
|
|
|
void init_parameters(struct locale *lang);
|
2014-07-23 11:54:51 +02:00
|
|
|
|
|
|
|
|
|
void free_gamedata(void);
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
2014-07-23 11:54:51 +02:00
|
|
|
|
extern struct helpmode helpmodes[];
|
|
|
|
|
extern const char *parameters[];
|
|
|
|
|
extern const char *localenames[];
|
|
|
|
|
extern settings global;
|
|
|
|
|
|
|
|
|
|
extern bool battledebug;
|
|
|
|
|
extern bool sqlpatch;
|
|
|
|
|
extern bool lomem; /* save memory */
|
|
|
|
|
extern int turn;
|
|
|
|
|
extern bool getunitpeasants;
|
|
|
|
|
|
2015-09-12 20:58:09 +02:00
|
|
|
|
extern const char *options[MAXOPTIONS]; /* report options */
|
2010-08-08 10:06:34 +02:00
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|