2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * ship.h: Definitions for things having to do with ships
30 * Known contributors to this file:
32 * Thomas Rushack, 1992
45 #define SHIP_MINEFF 20
47 /* bit masks for the autonav mode flags */
55 #define AN_SAILDIR bit(1)
56 #define AN_AUTONAV bit(2)
57 #define AN_STANDBY bit(3)
58 #define AN_LOADING bit(4)
59 #define AN_SCUTTLE bit(5) /* Auto-scuttle of trade ships */
61 /* TMAX is the number of cargo holds a ship use in the autonav code. */
66 #define MAXSHPNAMLEN 24
70 natid shp_own; /* owner's country num */
71 short shp_uid; /* unit id (ship #) */
72 coord shp_x; /* x location in abs coords */
73 coord shp_y; /* y location in abs coords */
74 s_char shp_type; /* index in mchr[] */
75 s_char shp_effic; /* 0% to 100% */
76 s_char shp_mobil; /* mobility units */
77 short shp_tech; /* tech level ship was built at */
78 s_char shp_fleet; /* group membership */
79 coord shp_opx, shp_opy; /* Op sector coords */
80 short shp_mission; /* mission code */
81 short shp_radius; /* mission radius */
82 u_char shp_nplane; /* number of planes on board */
83 u_char shp_nland; /* number of land units on board */
89 coord shp_destx[2]; /* location for ship destination */
91 s_char shp_tstart[TMAX]; /* what goods to pick up at start point */
92 s_char shp_tend[TMAX]; /* what goods to pick up at end point */
93 short shp_lstart[TMAX]; /* How much do we pick up at the start */
94 short shp_lend[TMAX]; /* How much do we pick up at the end */
95 u_char shp_autonav; /* autonavigation flags */
96 short shp_item[I_MAX+1]; /* amount of items on board */
97 u_short shp_pstage; /* plague stage */
98 u_short shp_ptime; /* how many etus remain in this stage */
99 time_t shp_access; /* Last time mob was updated (MOB_ACCESS) */
100 time_t shp_timestamp; /* Last time this ship was touched. */
101 u_char shp_mobquota; /* mobility quota */
102 s_char shp_path[MAXSHPPATH];
104 s_char shp_name[MAXSHPNAMLEN]; /* name set with the "name" command */
105 u_char shp_fuel; /* How much fuel do we have */
106 u_char shp_nchoppers; /* How many choppers on board? */
107 u_char shp_nxlight; /* How many xlight planes on board? */
109 coord shp_orig_y; /* Where we were built */
110 natid shp_orig_own; /* Who built us */
111 int shp_rflags; /* When do I retreat? */
112 s_char shp_rpath[RET_LEN]; /* retreat path */
118 double mobil, mobcost;
119 struct fltelemstr *next;
125 /* defines for the real_q member */
126 #define LEADER_VIRTUAL 0
127 #define LEADER_REAL 1
128 #define LEADER_WRONGSECT 2
132 struct fltelemstr *head;
133 struct fltheadstr *next;
137 u_char m_nv; /* number of variables it can hold */
138 u_char m_vtype[MAXCHRNV];
139 u_short m_vamt[MAXCHRNV];
140 int m_lcm; /* units of lcm to build */
141 int m_hcm; /* units of hcm to build */
142 int m_armor; /* how well armored it is */
143 int m_speed; /* how fast it can go */
144 int m_visib; /* how well it can be seen */
145 int m_vrnge; /* how well it can see */
146 int m_frnge; /* how far it can fire */
147 int m_glim; /* how many guns it can fire */
148 u_char m_nxlight; /* maximum number of xlight planes */
149 u_char m_nchoppers; /* maximum number of choppers */
150 u_char m_fuelc; /* fuel capacity */
151 u_char m_fuelu; /* fuel used per 10 mob */
152 s_char *m_name; /* full name of type of ship */
153 int m_tech; /* tech required to build */
154 int m_cost; /* how much it costs to build */
155 long m_flags; /* what special things can this ship do */
156 u_char m_nplanes; /* maximum number of planes this ship holds */
157 u_char m_nland; /* maximum number of units this ship holds */
160 #define M_FOOD bit(0) /* catch that fish! */
161 #define M_TORP bit(1) /* fire torpedoes */
162 #define M_DCH bit(2) /* drop depth charges on subs */
163 #define M_FLY bit(3) /* launch and recover planes */
164 /* M_MSL will be automatically set in init_global() if m_nplanes > 0
165 and M_FLY is not set */
166 #define M_MSL bit(4) /* launch missiles */
167 #define M_OIL bit(5) /* drill for oil */
168 #define M_SONAR bit(6) /* locate submarines */
169 #define M_MINE bit(7) /* drop mines */
170 #define M_SWEEP bit(8) /* clean up the mines */
171 #define M_SUB bit(9) /* a submarine */
172 #define M_SPY bit(10) /* gather intelligence info */
173 #define M_LAND bit(11) /* allows full landing ability */
174 #define M_SUBT bit(12) /* allows torping of other subs */
175 #define M_TRADE bit(13) /* is a trade ship */
176 #define M_SEMILAND bit(14) /* can land 1/4 */
177 /* M_XLIGHT will be automatically set in init_global() if m_nxlight > 0 */
178 #define M_XLIGHT bit(15) /* can hold xlight planes */
179 /* M_CHOPPER will be automatically set in init_global() if m_nchoppers > 0 */
180 #define M_CHOPPER bit(16) /* can hold choppers */
181 #define M_OILER bit(17) /* can re-fuel ships */
182 #define M_SUPPLY bit(18) /* Can supply units/sects/ships */
183 /* M_XUNIT will be automatically set in init_global() if m_nland > 0 */
184 #define M_UNIT bit(19) /* Can carry units */
185 #define M_ANTIMISSILE bit(20) /* Shoot down missile */
187 #define getship(n, p) \
188 ef_read(EF_SHIP, n, (caddr_t)p)
189 #define putship(n, p) \
190 ef_write(EF_SHIP, n, (caddr_t)p)
191 #define getshipp(n) \
192 (struct shpstr *) ef_ptr(EF_SHIP, n)
194 extern struct mchrstr mchr[];
195 extern int shp_maxno;
198 struct emp_qelem queue; /* list of ships */
199 struct mchrstr *mcp; /* pointer to desc of ship */
200 struct shpstr ship; /* struct ship */
201 double mobil; /* how much mobility the ship has left */
202 int done; /* has this ship been interdicted yet? */
205 #define SHP_DEF(b, t) (t ? (b * (logx((double)t, (double)40.0) < 1.0 ? 1.0 : \
206 logx((double)t, (double)40.0))) : b)
207 #define SHP_SPD(b, t) (t ? (b * (logx((double)t, (double)35.0) < 1.0 ? 1.0 : \
208 logx((double)t, (double)35.0))) : b)
209 #define SHP_VIS(b, t) (b * (1 - (sqrt((double)t) / 50)))
210 #define SHP_RNG(b, t) (t ? (b * (logx((double)t, (double)35.0) < 1.0 ? 1.0 : \
211 logx((double)t, (double)35.0))) : b)
212 #define SHP_FIR(b, t) (t ? (b * (logx((double)t, (double)60.0) < 1.0 ? 1.0 : \
213 logx((double)t, (double)60.0))) : b)
215 /* return codes from shp_check_nav */
216 #define CN_NAVIGABLE (0)
217 #define CN_LANDLOCKED (1)
218 #define CN_CONSTRUCTION (2)
219 #define CN_ERROR (-1)
221 #endif /* _SHIP_H_ */