2001-01-25 10:37:55 +01:00
|
|
|
|
/* vi: set ts=2:
|
|
|
|
|
*
|
2004-05-30 14:09:45 +02:00
|
|
|
|
*
|
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
2001-01-25 10:37:55 +01:00
|
|
|
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
|
|
|
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
|
|
|
|
* Henning Peters (faroul@beyond.kn-bremen.de)
|
|
|
|
|
* Enno Rehling (enno@eressea-pbem.de)
|
|
|
|
|
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
|
|
|
|
*
|
|
|
|
|
* This program may not be used, modified or distributed without
|
|
|
|
|
* prior permission by the authors of Eressea.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-07-29 11:48:03 +02:00
|
|
|
|
#ifndef H_KRNL_REGION
|
|
|
|
|
#define H_KRNL_REGION
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
#include "language.h"
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
2005-04-27 23:03:08 +02:00
|
|
|
|
/* FAST_CONNECT: regions are directly connected to neighbours, saves doing
|
|
|
|
|
a hash-access each time a neighbour is needed */
|
2004-01-12 16:49:34 +01:00
|
|
|
|
#define FAST_CONNECT
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2004-05-30 14:09:45 +02:00
|
|
|
|
#define RF_CHAOTIC (1<<0)
|
|
|
|
|
#define RF_MALLORN (1<<1)
|
|
|
|
|
#define RF_BLOCKED (1<<2)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2004-05-30 14:09:45 +02:00
|
|
|
|
#define RF_BLOCK_NORTHWEST (1<<3)
|
|
|
|
|
#define RF_BLOCK_NORTHEAST (1<<4)
|
|
|
|
|
#define RF_BLOCK_EAST (1<<5)
|
|
|
|
|
#define RF_BLOCK_SOUTHEAST (1<<6)
|
|
|
|
|
#define RF_BLOCK_SOUTHWEST (1<<7)
|
|
|
|
|
#define RF_BLOCK_WEST (1<<8)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2004-05-30 14:09:45 +02:00
|
|
|
|
#define RF_ENCOUNTER (1<<9)
|
|
|
|
|
#define RF_MIGRATION (1<<10)
|
|
|
|
|
#define RF_UNUSED_1 (1<<11)
|
|
|
|
|
#define RF_ORCIFIED (1<<12)
|
2006-02-26 12:12:25 +01:00
|
|
|
|
#define RF_CURSED (1<<13)
|
2004-05-30 14:09:45 +02:00
|
|
|
|
|
|
|
|
|
#define RF_COMBATDEBUG (1<<14)
|
|
|
|
|
|
|
|
|
|
#define RF_DH (1<<18)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2005-06-12 01:02:52 +02:00
|
|
|
|
/* flags that speed up attribute access: */
|
|
|
|
|
#define RF_TRAVELUNIT (1<<19)
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#define RF_ALL 0xFFFFFF
|
|
|
|
|
|
|
|
|
|
#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_BLOCK_NORTHWEST|RF_BLOCK_NORTHEAST|RF_BLOCK_EAST|RF_BLOCK_SOUTHEAST|RF_BLOCK_SOUTHWEST|RF_BLOCK_WEST|RF_ENCOUNTER|RF_ORCIFIED)
|
2001-05-20 09:46:13 +02:00
|
|
|
|
struct message;
|
|
|
|
|
struct message_list;
|
2001-12-10 01:13:39 +01:00
|
|
|
|
struct rawmaterial;
|
2005-06-04 16:47:02 +02:00
|
|
|
|
struct donation;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
typedef struct land_region {
|
2004-05-30 14:09:45 +02:00
|
|
|
|
char *name;
|
|
|
|
|
/* TODO: demand kann nach Konvertierung entfernt werden. */
|
|
|
|
|
struct demand {
|
|
|
|
|
struct demand * next;
|
|
|
|
|
const struct luxury_type * type;
|
|
|
|
|
int value;
|
|
|
|
|
} * demands;
|
2005-10-25 14:38:01 +02:00
|
|
|
|
const struct item_type * herbtype;
|
2004-05-30 14:09:45 +02:00
|
|
|
|
short herbs;
|
|
|
|
|
int trees[3]; /* 0 -> Samen, 1 -> Spr<70><72>linge, 2 -> B<>ume */
|
|
|
|
|
int horses;
|
|
|
|
|
int peasants;
|
|
|
|
|
int newpeasants;
|
|
|
|
|
int money;
|
2005-12-11 10:58:17 +01:00
|
|
|
|
struct item * items; /* items that can be claimed */
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} land_region;
|
|
|
|
|
|
2005-06-11 10:09:55 +02:00
|
|
|
|
typedef struct donation {
|
|
|
|
|
struct donation *next;
|
|
|
|
|
struct faction *f1, *f2;
|
|
|
|
|
int amount;
|
|
|
|
|
} donation;
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
typedef struct region {
|
2004-05-30 14:09:45 +02:00
|
|
|
|
struct region *next;
|
|
|
|
|
struct land_region *land;
|
|
|
|
|
struct unit *units;
|
|
|
|
|
struct ship *ships;
|
|
|
|
|
struct building *buildings;
|
2006-01-21 09:34:01 +01:00
|
|
|
|
unsigned int index;
|
|
|
|
|
/* an ascending number, to improve the speed of determining the interval in
|
|
|
|
|
which a faction has its units. See the implementations of firstregion
|
|
|
|
|
and lastregion */
|
2005-06-10 00:10:35 +02:00
|
|
|
|
short x, y;
|
2004-05-30 14:09:45 +02:00
|
|
|
|
struct plane *planep;
|
|
|
|
|
char *display;
|
|
|
|
|
unsigned int flags;
|
|
|
|
|
unsigned short age;
|
|
|
|
|
struct message_list *msgs;
|
|
|
|
|
struct individual_message {
|
|
|
|
|
struct individual_message * next;
|
|
|
|
|
const struct faction * viewer;
|
|
|
|
|
struct message_list *msgs;
|
|
|
|
|
} * individual_messages;
|
|
|
|
|
struct attrib *attribs;
|
|
|
|
|
struct region *nexthash;
|
2005-06-04 16:47:02 +02:00
|
|
|
|
struct donation * donations;
|
2005-10-25 14:38:01 +02:00
|
|
|
|
const struct terrain_type * terrain;
|
2004-05-30 14:09:45 +02:00
|
|
|
|
struct rawmaterial * resources;
|
2005-11-20 13:58:59 +01:00
|
|
|
|
#ifdef REGIONOWNERS
|
|
|
|
|
struct faction * owner;
|
|
|
|
|
#endif
|
2004-01-12 16:49:34 +01:00
|
|
|
|
#ifdef FAST_CONNECT
|
|
|
|
|
struct region * connect[MAXDIRECTIONS];
|
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} region;
|
|
|
|
|
|
2003-12-17 10:46:17 +01:00
|
|
|
|
typedef struct region_list {
|
|
|
|
|
struct region_list * next;
|
|
|
|
|
struct region * data;
|
|
|
|
|
} region_list;
|
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
extern struct message_list * r_getmessages(const struct region * r, const struct faction * viewer);
|
2001-05-20 23:47:56 +02:00
|
|
|
|
extern struct message * r_addmessage(struct region * r, const struct faction * viewer, struct message * msg);
|
2001-05-20 09:46:13 +02:00
|
|
|
|
|
2004-04-12 18:21:23 +02:00
|
|
|
|
typedef struct spec_direction {
|
2005-06-10 00:10:35 +02:00
|
|
|
|
short x, y;
|
2004-04-09 03:33:19 +02:00
|
|
|
|
int duration;
|
|
|
|
|
boolean active;
|
|
|
|
|
char *desc;
|
|
|
|
|
char *keyword;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} spec_direction;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2004-05-30 14:09:45 +02:00
|
|
|
|
direction_t dir;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} moveblock;
|
|
|
|
|
|
2006-01-21 09:34:01 +01:00
|
|
|
|
#define reg_hashkey(r) (r->index)
|
|
|
|
|
#define coor_hashkey(x, y) (abs(x + 0x100 * y))
|
2005-06-10 00:10:35 +02:00
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
int distance(const struct region*, const struct region*);
|
|
|
|
|
int koor_distance(int ax, int ay, int bx, int by) ;
|
2004-04-12 18:21:23 +02:00
|
|
|
|
extern direction_t reldirection(const struct region * from, const struct region * to);
|
2005-06-10 00:10:35 +02:00
|
|
|
|
extern struct region * findregion(short x, short y);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
extern attrib_type at_direction;
|
|
|
|
|
extern attrib_type at_moveblock;
|
|
|
|
|
/* new: */
|
|
|
|
|
extern attrib_type at_peasantluck;
|
|
|
|
|
extern attrib_type at_horseluck;
|
|
|
|
|
extern attrib_type at_chaoscount;
|
|
|
|
|
extern attrib_type at_woodcount;
|
|
|
|
|
extern attrib_type at_deathcount;
|
|
|
|
|
extern attrib_type at_travelunit;
|
2001-12-10 01:13:39 +01:00
|
|
|
|
extern attrib_type at_laen;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
void initrhash(void);
|
|
|
|
|
void rhash(struct region * r);
|
|
|
|
|
void runhash(struct region * r);
|
|
|
|
|
|
2004-02-21 13:18:29 +01:00
|
|
|
|
void free_regionlist(region_list *rl);
|
|
|
|
|
void add_regionlist(region_list **rl, struct region *r);
|
2004-04-12 18:21:23 +02:00
|
|
|
|
extern struct spec_direction * special_direction(const region * from, const region * to);
|
2005-01-01 12:48:36 +01:00
|
|
|
|
extern struct attrib *create_special_direction(struct region *r, struct region *rt,
|
|
|
|
|
int duration, const char *desc,
|
|
|
|
|
const char *keyword);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
int deathcount(const struct region * r);
|
|
|
|
|
int chaoscount(const struct region * r);
|
|
|
|
|
|
|
|
|
|
void deathcounts(struct region * r, int delta);
|
|
|
|
|
void chaoscounts(struct region * r, int delta);
|
|
|
|
|
|
2001-02-03 14:45:35 +01:00
|
|
|
|
void setluxuries(struct region * r, const struct luxury_type * sale);
|
2005-11-26 01:09:29 +01:00
|
|
|
|
extern int get_maxluxuries(void);
|
2001-02-03 14:45:35 +01:00
|
|
|
|
|
2005-06-12 11:48:19 +02:00
|
|
|
|
short rroad(const struct region * r, direction_t d);
|
|
|
|
|
void rsetroad(struct region * r, direction_t d, short value);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
int is_coastregion(struct region *r);
|
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
int rtrees(const struct region * r, int ageclass);
|
2001-12-10 01:13:39 +01:00
|
|
|
|
int rsettrees(const struct region *r, int ageclass, int value);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
int rpeasants(const struct region * r);
|
|
|
|
|
void rsetpeasants(struct region * r, int value);
|
|
|
|
|
int rmoney(const struct region * r);
|
|
|
|
|
void rsetmoney(struct region * r, int value);
|
2002-04-28 15:06:27 +02:00
|
|
|
|
int rhorses(const struct region * r);
|
|
|
|
|
void rsethorses(const struct region * r, int value);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
#define rbuildings(r) ((r)->buildings)
|
|
|
|
|
|
2004-10-16 02:46:38 +02:00
|
|
|
|
extern int rlaen(const struct region * r);
|
|
|
|
|
extern void rsetlaen(struct region * r, int value);
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#define rherbtype(r) ((r)->land?(r)->land->herbtype:0)
|
|
|
|
|
#define rsetherbtype(r, value) ((r)->land?((r)->land->herbtype=(value)):(value),0)
|
|
|
|
|
|
|
|
|
|
#define rherbs(r) ((r)->land?(r)->land->herbs:0)
|
|
|
|
|
#define rsetherbs(r, value) ((r)->land?((r)->land->herbs=(short)(value)):(value),0)
|
|
|
|
|
|
|
|
|
|
extern boolean r_isforest(const struct region * r);
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
2005-10-25 14:38:01 +02:00
|
|
|
|
#define rterrain(r) (oldterrain((r)->terrain))
|
|
|
|
|
#define rsetterrain(r, t) ((r)->terrain = newterrain(t))
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
extern const char * rname(const struct region * r, const struct locale * lang);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#define rsetname(r, str) (set_string(&(r)->land->name, str))
|
|
|
|
|
|
|
|
|
|
#define rplane(r) getplane(r)
|
|
|
|
|
|
|
|
|
|
extern void r_setdemand(struct region * r, const struct luxury_type * ltype, int value);
|
|
|
|
|
extern int r_demand(const struct region * r, const struct luxury_type * ltype);
|
|
|
|
|
|
- Neue Messages fertig
Messages werden jetzt in einem anderen Meta-Format (message* of
message_type*) gespeichert, das man in beliebige Formate (CR oder NR)
rendern kann. crmessage.c und nrmessage.c sind die render-engines dafür.
Die Messagetypen werden in res/{de,en}/messages.xml gesammelt, ultimativ
kann das aber durchaus eine einzelne Datei sein. Die ist derzeit nicht
wirklich xml (Umlaute drin, keine Definitionsdatei), aber gut lesbar.
- make_message
Diese Funktion ersetzt new_message, und ist etwas einfacher in der Syntax:
make_message("dumb_mistake", "unit region command", u, r, cmd) erzeugt
eine neue Nachricht, die dann einfach mit add_message wie bisher an die
Nachrichtenliste gehängt werden kann.
TODO: Messages könnte man durchaus reference-counten, und in mehrere Listen
einfügen, solang sie a) mehrfachverwendet (Kampf!) und b) vom Betrachter
unabhängig sind. Das spart einigen Speicher.
- CR Version erhöht.
Weil die MESSAGETYPES Blocks anders sind als früher
- OFFENSIVE_DELAY
Verbietet Einheiten, deren Partei eine Reigon niht bewachen, den
Angriff in der Region, wenn sie sich in der Runde zuvor bewegt haben.
Status der letzten Runde wird in neuem Attribut at_moved gespeichert.
- SHORT_ATTACKS
ein define, das angibt ob Kämpfen grundsätzlich keine lange Aktion ist.
- XML Parser
xml.[hc] enthält einen XML-Parser, dem man ein plugin mit callbacks
übergibt, die nach dem Parsen eines tokens aufgerufen werden.
2001-04-12 19:21:57 +02:00
|
|
|
|
extern const char * regionname(const struct region * r, const struct faction * f);
|
2005-06-10 00:10:35 +02:00
|
|
|
|
extern void * resolve_region(variant data);
|
|
|
|
|
extern struct region * new_region(short x, short y);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern void terraform(struct region * r, terrain_t terrain);
|
2005-10-25 14:38:01 +02:00
|
|
|
|
extern void terraform_region(struct region * r, const struct terrain_type * terrain);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2005-06-10 00:10:35 +02:00
|
|
|
|
extern const short delta_x[MAXDIRECTIONS];
|
|
|
|
|
extern const short delta_y[MAXDIRECTIONS];
|
2004-04-12 18:21:23 +02:00
|
|
|
|
extern direction_t dir_invert(direction_t dir);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern int production(const struct region *r);
|
2002-04-07 02:44:01 +02:00
|
|
|
|
extern int read_region_reference(struct region ** r, FILE * F);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern void write_region_reference(const struct region * r, FILE * F);
|
2001-12-10 01:13:39 +01:00
|
|
|
|
|
2005-11-20 13:58:59 +01:00
|
|
|
|
void region_setowner(struct region * r, struct faction * owner);
|
|
|
|
|
extern struct faction * region_owner(const struct region * r);
|
|
|
|
|
|
2004-01-12 16:49:34 +01:00
|
|
|
|
extern struct region * r_connect(const struct region *, direction_t dir);
|
|
|
|
|
#ifdef FAST_CONNECT
|
|
|
|
|
# define rconnect(r, dir) ((r)->connect[dir]?(r)->connect[dir]:r_connect(r, dir))
|
|
|
|
|
#else
|
|
|
|
|
# define rconnect(r, dir) r_connect(r, dir)
|
|
|
|
|
#endif
|
2002-12-18 01:34:19 +01:00
|
|
|
|
|
2003-07-29 11:48:03 +02:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#endif /* _REGION_H */
|