1 /*
2  * XPilot NG, a multiplayer space war game.
3  *
4  * Copyright (C) 1991-2001 by
5  *
6  *      Bj�rn Stabell        <bjoern@xpilot.org>
7  *      Ken Ronny Schouten   <ken@xpilot.org>
8  *      Bert Gijsbers        <bert@xpilot.org>
9  *      Dick Balaska         <dick@xpilot.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25 
26 #ifndef SERVERCONST_H
27 #define SERVERCONST_H
28 
29 #ifndef CONST_H
30 #include "const.h"
31 #endif
32 
33 /*
34  * Two macros for edge wrap of x and y coordinates measured in map blocks.
35  * Note that the correction needed shouldn't ever be bigger than one mapsize.
36  */
37 #define WRAP_XBLOCK(x_)	\
38 	(BIT(World.rules->mode, WRAP_PLAY) \
39 	    ? ((x_) < 0 \
40 		? (x_) + World.x \
41 		: ((x_) >= World.x \
42 		    ? (x_) - World.x \
43 		    : (x_))) \
44 	    : (x_))
45 
46 #define WRAP_YBLOCK(y_)	\
47 	(BIT(World.rules->mode, WRAP_PLAY) \
48 	    ? ((y_) < 0 \
49 		? (y_) + World.y \
50 		: ((y_) >= World.y \
51 		    ? (y_) - World.y \
52 		    : (y_))) \
53 	    : (y_))
54 
55 /*
56  * Two macros for edge wrap of differences in position.
57  * If the absolute value of a difference is bigger than
58  * half the map size then it is wrapped.
59  */
60 #define WRAP_DX(dx)	\
61 	(BIT(World.rules->mode, WRAP_PLAY) \
62 	    ? ((dx) < - (World.width >> 1) \
63 		? (dx) + World.width \
64 		: ((dx) > (World.width >> 1) \
65 		    ? (dx) - World.width \
66 		    : (dx))) \
67 	    : (dx))
68 
69 #define WRAP_DY(dy)	\
70 	(BIT(World.rules->mode, WRAP_PLAY) \
71 	    ? ((dy) < - (World.height >> 1) \
72 		? (dy) + World.height \
73 		: ((dy) > (World.height >> 1) \
74 		    ? (dy) - World.height \
75 		    : (dy))) \
76 	    : (dy))
77 
78 
79 #define PSEUDO_TEAM(pl1,pl2)\
80 	((pl1)->pseudo_team == (pl2)->pseudo_team)
81 
82 /*
83  * Used when we want to pass an index which is not in use.
84  */
85 #define NO_IND			(-1)
86 
87 #define RECOVERY_DELAY		(12 * 3)
88 #define ROBOT_CREATE_DELAY	(12 * 2)
89 
90 /*
91  * ID values: In the network protocol these are 16 bit signed values.
92  */
93 #define NO_ID			(-1)
94 
95 /* Currently there is 256 possible player IDs. */
96 #define NUM_IDS			256
97 #define MAX_PSEUDO_PLAYERS	16
98 
99 /* Expired mines have id EXPIRED_MINE_ID, defined in common/const.h */
100 
101 /* Cannon IDs. */
102 #define NUM_CANNON_IDS		10000
103 #define MIN_CANNON_ID		(EXPIRED_MINE_ID + 1)
104 #define MAX_CANNON_ID		(EXPIRED_MINE_ID + NUM_CANNON_IDS)
105 
106 #define MAX_TOTAL_SHOTS		16384	/* must be <= 65536 */
107 
108 /*
109  * Energy drainage
110  */
111 #define ED_SHOT			(-0.2)
112 #define ED_SMART_SHOT		(-30.0)
113 #define ED_MINE			(-60.0)
114 #define ED_ECM			(-60.0)
115 #define ED_TRANSPORTER		(-60.0)
116 #define ED_HYPERJUMP		(-60.0)
117 #define ED_SHIELD		(-0.20)
118 #define ED_PHASING_DEVICE	(-0.40)
119 #define ED_CLOAKING_DEVICE	(-0.07)
120 #define ED_DEFLECTOR		(-0.15)
121 #define ED_SHOT_HIT		(-25.0)
122 #define ED_SMART_SHOT_HIT	(-120.0)
123 #define ED_PL_CRASH		(-options.playerCollisionFuelDrain)
124 #define ED_BALL_HIT		(-options.ballCollisionFuelDrain)
125 #define ED_LASER		(-10.0)
126 #define ED_LASER_HIT		(-100.0)
127 
128 #define MAX_PLAYER_FUEL		2600.0
129 #define ENERGY_PACK_FUEL	(500.0 + rfrac() * 511.0)
130 
131 #define LG2_MAX_AFTERBURNER     4
132 #define ALT_SPARK_MASS_FACT     4.2
133 #define ALT_FUEL_FACT	   3
134 #define MAX_AFTERBURNER	((1<<LG2_MAX_AFTERBURNER)-1)
135 /*#define AFTER_BURN_SPARKS(s,n)  (((s)*(n))>>LG2_MAX_AFTERBURNER)*/
136 #define AFTER_BURN_POWER_FACTOR(n) \
137  (options.afterburnerPowerMult \
138   * (1.0+(n)*((ALT_SPARK_MASS_FACT-1.0)/(MAX_AFTERBURNER+1.0))))
139 #define AFTER_BURN_POWER(p,n)   \
140  ((p)*AFTER_BURN_POWER_FACTOR(n))
141 #define AFTER_BURN_FUEL(f,n)    \
142  (((f)*((MAX_AFTERBURNER+1)+(n)*(ALT_FUEL_FACT-1)))/(MAX_AFTERBURNER+1.0))
143 
144 #define THRUST_MASS	     0.7
145 #define ARMOR_MASS		(options.shipMass / 14)
146 
147 #define MAX_TANKS	       8
148 #define TANK_MASS	       (options.shipMass / 10)
149 #define TANK_CAP(n)	     (!(n)?MAX_PLAYER_FUEL:(MAX_PLAYER_FUEL/3))
150 #define TANK_FUEL(n)	    ((TANK_CAP(n)*(5+(randomMT()&3)))/32)
151 #define TANK_REFILL_LIMIT       (350.0/8.0)
152 #define TANK_THRUST_FACT	0.7
153 #define TANK_NOTHRUST_TIME      (HEAT_CLOSE_TIMEOUT/2+2)
154 #define TANK_THRUST_TIME	(TANK_NOTHRUST_TIME/2+1)
155 
156 #define GRAVS_POWER		2.7
157 
158 #define ECM_DISTANCE		(VISIBILITY_DISTANCE*0.4)
159 #define TRANSPORTER_DISTANCE	(VISIBILITY_DISTANCE*0.2)
160 
161 #define MINE_RADIUS		8
162 #define MINE_RANGE	 	(VISIBILITY_DISTANCE*0.1)
163 #define MINE_SENSE_BASE_RANGE   (MINE_RANGE*1.3)
164 #define MINE_SENSE_RANGE_FACTOR (MINE_RANGE*0.3)
165 #define MINE_MASS		30.0
166 #define MINE_SPEED_FACT		1.3
167 
168 #define MISSILE_MASS		5.0
169 #define MISSILE_RANGE		4
170 #define SMART_SHOT_ACC		0.6
171 #define SMART_SHOT_DECFACT	3
172 #define SMART_SHOT_MIN_SPEED	(SMART_SHOT_ACC*8)
173 #define SMART_TURNSPEED		2.6
174 #define SMART_SHOT_MAX_SPEED	22.0
175 #define SMART_SHOT_LOOK_AH      4
176 #define CONFUSED_TIME		3
177 #define TORPEDO_SPEED_TIME      (2 * 12)
178 #define TORPEDO_ACC		((18.0*SMART_SHOT_MAX_SPEED)/\
179 				(12*TORPEDO_SPEED_TIME))
180 #define TORPEDO_RANGE		(MINE_RANGE*0.45)
181 
182 #define NUKE_SPEED_TIME		(2 * 12)
183 #define NUKE_ACC 		(5*TORPEDO_ACC)
184 #define NUKE_RANGE		(MINE_RANGE*1.5)
185 #define NUKE_MASS_MULT		1
186 #define NUKE_MINE_EXPL_MULT	3
187 #define NUKE_SMART_EXPL_MULT	4
188 
189 #define HEAT_RANGE		(VISIBILITY_DISTANCE/2)
190 #define HEAT_SPEED_FACT		1.7
191 #define HEAT_CLOSE_TIMEOUT      (2 * 12)
192 #define HEAT_CLOSE_RANGE	HEAT_RANGE
193 #define HEAT_CLOSE_ERROR	0
194 #define HEAT_MID_TIMEOUT	(4 * 12)
195 #define HEAT_MID_RANGE		(2 * HEAT_RANGE)
196 #define HEAT_MID_ERROR		8
197 #define HEAT_WIDE_TIMEOUT       (8 * 12)
198 #define HEAT_WIDE_ERROR		16
199 
200 #define CLUSTER_MASS_SHOTS(mass) ((mass) * 0.9 / options.shotMass)
201 #define CLUSTER_MASS_DRAIN(mass) (CLUSTER_MASS_SHOTS(mass)*ED_SHOT)
202 
203 #define SMART_SHOT_LEN		12
204 #define HEAT_SHOT_LEN		15
205 #define TORPEDO_LEN		18
206 
207 #define CANNON_PULSE_LIFE	(4.75)
208 
209 #define TRACTOR_MAX_RANGE(items)  (200 + (items) * 50)
210 #define TRACTOR_MAX_FORCE(items)  (-40 + (items) * -20)
211 #define TRACTOR_PERCENT(dist, maxdist) \
212 	(1.0 - (0.5 * (dist) / (maxdist)))
213 #define TRACTOR_COST(percent) (-1.5 * (percent))
214 #define TRACTOR_FORCE(tr_pr, percent, maxforce) \
215 	((percent) * (maxforce) * ((tr_pr) ? -1 : 1))
216 
217 #define WARN_TIME		(2 * 12)
218 #define EMERGENCY_SHIELD_TIME	(4 * 12)
219 #define SHIELD_TIME		(2 * 12)
220 #define PHASING_TIME		(4 * 12)
221 #define EMERGENCY_THRUST_TIME	(4 * 12)
222 
223 #define FUEL_MASS(f)		((f) * 0.005)
224 #define START_STATION_FUEL	MAX_STATION_FUEL
225 #define STATION_REGENERATION	0.06
226 #define REFUEL_RATE		5.0
227 #define TARGET_FUEL_REPAIR_PER_FRAME (TARGET_DAMAGE / (12 * 10))
228 #define TARGET_REPAIR_PER_FRAME	(TARGET_DAMAGE / (12 * 600))
229 #define TARGET_UPDATE_DELAY	(TARGET_DAMAGE / (TARGET_REPAIR_PER_FRAME \
230 				    * BLOCK_SZ))
231 
232 #define ALLIANCE_NOT_SET	(-1)
233 
234 #define DEBRIS_MASS		4.5
235 
236 #define ENERGY_RANGE_FACTOR	2.5
237 
238 /* Wall code only considers one way of wrapping around the map, and
239  * assumes that after moving the length of one line or one unit of object
240  * movement (max 32000 clicks) the shortest distance from the start to
241  * the end position is the path that was moved (there are some fudge
242  * factors in the length). For this to hold, the map must be somewhat
243  * larger than 2 * 32000 clicks = 1000 pixels. */
244 #define MIN_MAP_SIZE		1100
245 /* map dimension limitation: (0x7FFF - 1280) */
246 /* Where does 1280 come from? uau */
247 #define MAX_MAP_SIZE		31500
248 
249 #define POLYGON_MAX_OFFSET	30000
250 #define NO_GROUP		(-1)
251 
252 /* Maximum frames per second the server code supports. */
253 #define MAX_SERVER_FPS		255
254 
255 #endif
256