1 /* $Id: map.h,v 5.7 2002/01/27 22:58:55 kimiko Exp $
2  *
3  * XPilot, a multiplayer gravity war game.  Copyright (C) 1991-2001 by
4  *
5  *      Bj�rn Stabell        <bjoern@xpilot.org>
6  *      Ken Ronny Schouten   <ken@xpilot.org>
7  *      Bert Gijsbers        <bert@xpilot.org>
8  *      Dick Balaska         <dick@xpilot.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24 
25 #ifndef	MAP_H
26 #define	MAP_H
27 
28 #ifndef TYPES_H
29 /* need position */
30 #include "types.h"
31 #endif
32 #ifndef RULES_H
33 /* need rules_t */
34 #include "rules.h"
35 #endif
36 #ifndef ITEM_H
37 /* need NUM_ITEMS */
38 #include "item.h"
39 #endif
40 
41 #define SPACE			0
42 #define BASE			1
43 #define FILLED			2
44 #define REC_LU			3
45 #define REC_LD			4
46 #define REC_RU			5
47 #define REC_RD			6
48 #define FUEL			7
49 #define CANNON			8
50 #define CHECK			9
51 #define POS_GRAV		10
52 #define NEG_GRAV		11
53 #define CWISE_GRAV		12
54 #define ACWISE_GRAV		13
55 #define WORMHOLE		14
56 #define TREASURE		15
57 #define TARGET			16
58 #define ITEM_CONCENTRATOR	17
59 #define DECOR_FILLED		18
60 #define DECOR_LU		19
61 #define DECOR_LD		20
62 #define DECOR_RU		21
63 #define DECOR_RD		22
64 #define UP_GRAV			23
65 #define DOWN_GRAV		24
66 #define RIGHT_GRAV		25
67 #define LEFT_GRAV		26
68 #define FRICTION		27
69 #define ASTEROID_CONCENTRATOR		28
70 #define BASE_ATTRACTOR		127
71 
72 #define SPACE_BIT		(1 << SPACE)
73 #define BASE_BIT		(1 << BASE)
74 #define FILLED_BIT		(1 << FILLED)
75 #define REC_LU_BIT		(1 << REC_LU)
76 #define REC_LD_BIT		(1 << REC_LD)
77 #define REC_RU_BIT		(1 << REC_RU)
78 #define REC_RD_BIT		(1 << REC_RD)
79 #define FUEL_BIT		(1 << FUEL)
80 #define CANNON_BIT		(1 << CANNON)
81 #define CHECK_BIT		(1 << CHECK)
82 #define POS_GRAV_BIT		(1 << POS_GRAV)
83 #define NEG_GRAV_BIT		(1 << NEG_GRAV)
84 #define CWISE_GRAV_BIT		(1 << CWISE_GRAV)
85 #define ACWISE_GRAV_BIT		(1 << ACWISE_GRAV)
86 #define WORMHOLE_BIT		(1 << WORMHOLE)
87 #define TREASURE_BIT		(1 << TREASURE)
88 #define TARGET_BIT		(1 << TARGET)
89 #define ITEM_CONCENTRATOR_BIT	(1 << ITEM_CONCENTRATOR)
90 #define DECOR_FILLED_BIT	(1 << DECOR_FILLED)
91 #define DECOR_LU_BIT		(1 << DECOR_LU)
92 #define DECOR_LD_BIT		(1 << DECOR_LD)
93 #define DECOR_RU_BIT		(1 << DECOR_RU)
94 #define DECOR_RD_BIT		(1 << DECOR_RD)
95 #define UP_GRAV_BIT             (1 << UP_GRAV)
96 #define DOWN_GRAV_BIT           (1 << DOWN_GRAV)
97 #define RIGHT_GRAV_BIT          (1 << RIGHT_GRAV)
98 #define LEFT_GRAV_BIT           (1 << LEFT_GRAV)
99 #define FRICTION_BIT		(1 << FRICTION)
100 #define ASTEROID_CONCENTRATOR_BIT	(1 << ASTEROID_CONCENTRATOR)
101 
102 #define DIR_RIGHT		0
103 #define DIR_UP			(RES/4)
104 #define DIR_LEFT		(RES/2)
105 #define DIR_DOWN		(3*RES/4)
106 
107 typedef struct {
108     ipos	blk_pos;
109     position	pix_pos;
110     long	fuel;
111     unsigned	conn_mask;
112     long	last_change;
113     int		team;
114 } fuel_t;
115 
116 typedef struct {
117     ipos	pos;
118     DFLOAT	force;
119 } grav_t;
120 
121 typedef struct {
122     ipos		pos;
123     int			dir;
124     unsigned short	team;
125 } base_t;
126 
127 typedef struct {
128     int		base_idx;	/* Index in World.base[] */
129     DFLOAT	dist;		/* Distance to first checkpoint */
130 } baseorder_t;
131 
132 typedef struct {
133     ipos		blk_pos;
134     position		pix_pos;
135     int			dir;
136     int			dead_time;
137     unsigned		conn_mask;
138     long		last_change;
139     int			item[NUM_ITEMS];
140     int			damaged;
141     int			tractor_target;
142     int			tractor_count;
143     bool		tractor_is_pressor;
144     unsigned short	team;
145     long		used;
146     int			emergency_shield_left;
147     int			phasing_left;
148 } cannon_t;
149 
150 typedef struct {
151     DFLOAT	prob;		/* Probability [0..1] for item to appear */
152     int		max;		/* Max on world at a given time */
153     int		num;		/* Number active right now */
154     int		chance;		/* Chance [0..127] for this item to appear */
155     DFLOAT	cannonprob;	/* Relative probability for item to appear */
156     int		min_per_pack;	/* minimum number of elements per item. */
157     int		max_per_pack;	/* maximum number of elements per item. */
158     int		initial;	/* initial number of elements per player. */
159     int		limit;		/* max number of elements per player/cannon. */
160 } item_t;
161 
162 typedef struct {
163     DFLOAT	prob;		/* Probability [0..1] for asteroid to appear */
164     int		max;		/* Max on world at a given time */
165     int		num;		/* Number active right now */
166     int		chance;		/* Chance [0..127] for asteroid to appear */
167 } asteroid_t;
168 
169 typedef enum { WORM_NORMAL, WORM_IN, WORM_OUT } wormType;
170 
171 typedef struct {
172     ipos		pos;
173     int			lastdest,	/* last destination wormhole */
174 			countdown;	/* if >0 warp to lastdest else random */
175     bool		temporary;	/* wormhole was left by hyperjump */
176     wormType		type;
177     u_byte		lastblock;	/* block it occluded */
178     unsigned short	lastID;
179 } wormhole_t;
180 
181 typedef struct {
182     ipos		pos;
183     bool		have;	/* true if this treasure has ball in it */
184     unsigned short	team;	/* team of this treasure */
185     int 		destroyed;	/* how often this treasure destroyed */
186     bool		empty;	/* true if this treasure never had a ball in it */
187 } treasure_t;
188 
189 typedef struct {
190     ipos		pos;
191     unsigned short	team;
192     int			dead_time;
193     int			damage;
194     unsigned		conn_mask;
195     unsigned 		update_mask;
196     long		last_change;
197 } target_t;
198 
199 typedef struct {
200     int		NumMembers;		/* Number of current members */
201     int		NumRobots;		/* Number of robot players */
202     int		NumBases;		/* Number of bases owned */
203     int		NumTreasures;		/* Number of treasures owned */
204     int		NumEmptyTreasures;	/* Number of empty treasures owned */
205     int		TreasuresDestroyed;	/* Number of destroyed treasures */
206     int		TreasuresLeft;		/* Number of treasures left */
207     DFLOAT	score;
208     DFLOAT	prev_score;
209 } team_t;
210 
211 typedef struct {
212     ipos	pos;
213 } item_concentrator_t, asteroid_concentrator_t;
214 
215 typedef struct {
216     int			x, y;		/* Size of world in blocks */
217     int			diagonal;	/* Diagonal length in blocks */
218     int			width, height;	/* Size of world in pixels (optimization) */
219     int			hypotenuse;	/* Diagonal length in pixels (optimization) */
220     rules_t		*rules;
221     char		name[MAX_CHARS];
222     char		author[MAX_CHARS];
223 
224     u_byte		**block;        /* type of item in each block */
225 
226 			/* index into mapobject depending on value of corresponding block,
227 			** -1 for space, walls, etc */
228     unsigned short	**itemID;
229 
230     vector		**gravity;
231 
232     item_t		items[NUM_ITEMS];
233 
234     asteroid_t		asteroids;
235 
236     team_t		teams[MAX_TEAMS];
237 
238     int			NumTeamBases;      /* How many 'different' teams are allowed */
239     int			NumBases;
240     base_t		*base;
241     baseorder_t		*baseorder;
242     int			NumFuels;
243     fuel_t		*fuel;
244     int			NumGravs;
245     grav_t		*grav;
246     int			NumCannons;
247     cannon_t		*cannon;
248     int			NumChecks;
249     ipos		check[MAX_CHECKS];
250     int			NumWormholes;
251     wormhole_t		*wormHoles;
252     int			NumTreasures;
253     treasure_t		*treasures;
254     int			NumTargets;
255     target_t		*targets;
256     int			NumItemConcentrators;
257     item_concentrator_t	*itemConcentrators;
258     int			NumAsteroidConcs;
259     asteroid_concentrator_t	*asteroidConcs;
260 } World_map;
261 
262 #endif
263