2001-01-25 10:37:55 +01:00
|
|
|
|
/* vi: set ts=2:
|
|
|
|
|
*
|
2001-04-14 13:39:14 +02:00
|
|
|
|
*
|
2001-01-25 10:37:55 +01:00
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2000
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _REGION_H
|
|
|
|
|
#define _REGION_H
|
|
|
|
|
|
|
|
|
|
#include "language.h"
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define RF_CHAOTIC (1<<0)
|
|
|
|
|
#define RF_MALLORN (1<<1)
|
|
|
|
|
#define RF_BLOCKED (1<<2)
|
|
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
|
|
|
|
|
#define RF_ENCOUNTER (1<<9)
|
|
|
|
|
#define RF_MIGRATION (1<<10)
|
|
|
|
|
#define RF_UNUSED_1 (1<<11)
|
|
|
|
|
#define RF_ORCIFIED (1<<12)
|
|
|
|
|
#define RF_DH (1<<18)
|
|
|
|
|
|
|
|
|
|
#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;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
typedef struct land_region {
|
|
|
|
|
char *name;
|
|
|
|
|
/* TODO: demand kann nach Konvertierung entfernt werden. */
|
|
|
|
|
struct demand {
|
|
|
|
|
struct demand * next;
|
|
|
|
|
const struct luxury_type * type;
|
|
|
|
|
int value;
|
|
|
|
|
} * demands;
|
|
|
|
|
const struct herb_type * herbtype;
|
|
|
|
|
short herbs;
|
2001-12-15 13:26:04 +01:00
|
|
|
|
#if GROWING_TREES
|
2001-09-05 21:40:40 +02:00
|
|
|
|
int trees[3]; /* 0 -> Samen, 1 -> Spr<70><72>linge, 2 -> B<>ume */
|
|
|
|
|
#else
|
2001-01-25 10:37:55 +01:00
|
|
|
|
int trees;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
int horses;
|
|
|
|
|
int peasants;
|
|
|
|
|
int newpeasants;
|
|
|
|
|
int money;
|
2001-12-15 13:26:04 +01:00
|
|
|
|
#if NEW_RESOURCEGROWTH == 0
|
2001-01-25 10:37:55 +01:00
|
|
|
|
int iron;
|
2001-12-10 01:13:39 +01:00
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} land_region;
|
|
|
|
|
|
|
|
|
|
typedef struct region {
|
|
|
|
|
struct region *next;
|
|
|
|
|
struct land_region *land;
|
|
|
|
|
struct unit *units;
|
|
|
|
|
struct ship *ships;
|
|
|
|
|
struct building *buildings;
|
|
|
|
|
int x, y;
|
|
|
|
|
struct plane *planep;
|
|
|
|
|
char *display;
|
|
|
|
|
unsigned int flags;
|
2001-02-24 13:50:51 +01:00
|
|
|
|
struct message_list *msgs;
|
2001-05-20 09:46:13 +02:00
|
|
|
|
struct individual_message {
|
|
|
|
|
struct individual_message * next;
|
|
|
|
|
const struct faction * viewer;
|
|
|
|
|
struct message_list *msgs;
|
|
|
|
|
} * individual_messages;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
struct attrib *attribs;
|
|
|
|
|
struct region *nexthash;
|
|
|
|
|
terrain_t terrain;
|
|
|
|
|
unsigned short age;
|
|
|
|
|
#ifdef WEATHER
|
|
|
|
|
weather_t weathertype;
|
|
|
|
|
#endif
|
2001-12-15 13:26:04 +01:00
|
|
|
|
#if NEW_RESOURCEGROWTH
|
2001-12-10 01:13:39 +01:00
|
|
|
|
struct rawmaterial * resources;
|
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} region;
|
|
|
|
|
|
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
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
typedef struct {
|
|
|
|
|
int x;
|
|
|
|
|
int y;
|
|
|
|
|
int duration;
|
|
|
|
|
char *desc;
|
|
|
|
|
char *keyword;
|
|
|
|
|
} spec_direction;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
direction_t dir;
|
|
|
|
|
} moveblock;
|
|
|
|
|
|
|
|
|
|
#define region_hashkey(r) (abs((r)->x + 0x100 * (r)->y))
|
|
|
|
|
int distance(const struct region*, const struct region*);
|
|
|
|
|
int koor_distance(int ax, int ay, int bx, int by) ;
|
|
|
|
|
direction_t reldirection(struct region * from, struct region * to);
|
|
|
|
|
direction_t koor_reldirection(int ax, int ay, int bx, int by) ;
|
|
|
|
|
extern struct region * findregion(int x, int y);
|
|
|
|
|
|
|
|
|
|
extern attrib_type at_direction;
|
|
|
|
|
extern attrib_type at_moveblock;
|
|
|
|
|
/* new: */
|
|
|
|
|
#if AT_SALARY
|
|
|
|
|
extern attrib_type at_salary;
|
|
|
|
|
#endif
|
|
|
|
|
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;
|
|
|
|
|
extern attrib_type at_road;
|
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);
|
|
|
|
|
|
|
|
|
|
typedef struct regionlist {
|
|
|
|
|
struct regionlist *next;
|
2001-02-10 20:24:05 +01:00
|
|
|
|
struct region *region;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} regionlist;
|
|
|
|
|
|
|
|
|
|
void free_regionlist(regionlist *rl);
|
2002-01-09 09:20:33 +01:00
|
|
|
|
void add_regionlist(regionlist **rl, struct region *r);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
int woodcount(const struct region * r);
|
|
|
|
|
int deathcount(const struct region * r);
|
|
|
|
|
int chaoscount(const struct region * r);
|
|
|
|
|
|
|
|
|
|
void woodcounts(struct region * r, int delta);
|
|
|
|
|
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);
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
int rroad(const struct region * r, direction_t d);
|
|
|
|
|
void rsetroad(struct region * r, direction_t d, int value);
|
|
|
|
|
|
|
|
|
|
int is_coastregion(struct region *r);
|
|
|
|
|
|
2001-12-15 13:26:04 +01:00
|
|
|
|
#if GROWING_TREES
|
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-09-05 21:40:40 +02:00
|
|
|
|
#else
|
2001-01-25 10:37:55 +01:00
|
|
|
|
int rtrees(const struct region * r);
|
2001-12-10 01:13:39 +01:00
|
|
|
|
int rsettrees(const struct region * r, int value);
|
2001-09-05 21:40:40 +02:00
|
|
|
|
#endif
|
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);
|
|
|
|
|
|
|
|
|
|
#define rhorses(r) ((r)->land?(r)->land->horses:0)
|
|
|
|
|
#define rsethorses(r, value) ((r)->land?((r)->land->horses=(value)):(assert((value)>=0), (value)),0)
|
|
|
|
|
|
|
|
|
|
#define rbuildings(r) ((r)->buildings)
|
|
|
|
|
|
2001-12-15 13:26:04 +01:00
|
|
|
|
#if NEW_RESOURCEGROWTH == 0
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#define riron(r) ((r)->land?(r)->land->iron:0)
|
|
|
|
|
#define rsetiron(r, value) ((r)->land?((r)->land->iron=(value)):(value),0)
|
|
|
|
|
|
2001-12-10 01:13:39 +01:00
|
|
|
|
int rlaen(const struct region * r);
|
|
|
|
|
void rsetlaen(struct region * r, int value);
|
|
|
|
|
#endif /* NEW_RESOURCEGROWTH */
|
|
|
|
|
|
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-12-15 12:54:33 +01:00
|
|
|
|
extern boolean r_issea(const struct region * r);
|
2001-09-05 21:40:40 +02:00
|
|
|
|
extern boolean r_isglacier(const struct region * r);
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#define rterrain(r) (terrain_t)((r)?(r)->terrain:T_FIREWALL)
|
|
|
|
|
#define rsetterrain(r, value) (r->terrain=value)
|
|
|
|
|
|
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);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern void * resolve_region(void * data);
|
|
|
|
|
extern struct region * new_region(int x, int y);
|
|
|
|
|
extern void terraform(struct region * r, terrain_t terrain);
|
|
|
|
|
|
|
|
|
|
extern const int delta_x[MAXDIRECTIONS];
|
|
|
|
|
extern const int delta_y[MAXDIRECTIONS];
|
|
|
|
|
extern const direction_t back[MAXDIRECTIONS];
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#endif /* _REGION_H */
|