2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2007, 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 files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future 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 Ruschak, 1992
45 #define SHP_TYPE_MAX 46
46 #define SHIP_MINEFF 20
48 /* bit masks for the autonav mode flags */
50 #define AN_AUTONAV bit(2)
51 #define AN_STANDBY bit(3)
52 #define AN_LOADING bit(4)
53 #define AN_SCUTTLE bit(5) /* Auto-scuttle of trade ships */
55 /* TMAX is the number of cargo holds a ship use in the autonav code. */
60 #define MAXSHPNAMLEN 24
63 /* initial part must match struct empobj */
65 natid shp_own; /* owner's country num */
66 short shp_uid; /* unit id (ship #) */
67 coord shp_x; /* x location in abs coords */
68 coord shp_y; /* y location in abs coords */
69 signed char shp_type; /* index in mchr[] */
70 signed char shp_effic; /* 0% to 100% */
71 signed char shp_mobil; /* mobility units */
72 unsigned char shp_off; /* repairs stopped? */
73 short shp_tech; /* tech level ship was built at */
74 char shp_fleet; /* group membership */
75 coord shp_opx, shp_opy; /* Op sector coords */
76 short shp_mission; /* mission code */
77 short shp_radius; /* mission radius */
78 /* end of part matching struct empobj */
79 unsigned char shp_nplane; /* number of planes on board */
80 unsigned char shp_nland; /* number of land units on board */
86 coord shp_destx[2]; /* location for ship destination */
88 i_type shp_tstart[TMAX]; /* what goods to pick up at start point */
89 i_type shp_tend[TMAX]; /* what goods to pick up at end point */
90 short shp_lstart[TMAX]; /* How much do we pick up at the start */
91 short shp_lend[TMAX]; /* How much do we pick up at the end */
92 unsigned char shp_autonav; /* autonavigation flags */
93 short shp_item[I_MAX+1]; /* amount of items on board */
94 short shp_pstage; /* plague stage */
95 short shp_ptime; /* how many etus remain in this stage */
96 short shp_access; /* Last tick mob was updated (MOB_ACCESS) */
97 time_t shp_timestamp; /* Last time this ship was touched. */
98 unsigned char shp_mobquota; /* mobility quota */
99 char shp_path[MAXSHPPATH];
101 char shp_name[MAXSHPNAMLEN]; /* name set with the "name" command */
102 unsigned char shp_fuel; /* How much fuel do we have */
103 unsigned char shp_nchoppers; /* How many choppers on board? */
104 unsigned char shp_nxlight; /* How many xlight planes on board? */
106 coord shp_orig_y; /* Where we were built */
107 natid shp_orig_own; /* Who built us */
108 int shp_rflags; /* When do I retreat? */
109 char shp_rpath[RET_LEN]; /* retreat path */
115 double mobil, mobcost;
116 struct fltelemstr *next;
122 /* defines for the real_q member */
123 #define LEADER_VIRTUAL 0
124 #define LEADER_REAL 1
125 #define LEADER_WRONGSECT 2
129 struct fltelemstr *head;
130 struct fltheadstr *next;
134 short m_item[I_MAX+1]; /* load limit */
135 int m_lcm; /* units of lcm to build */
136 int m_hcm; /* units of hcm to build */
137 int m_armor; /* how well armored it is */
138 int m_speed; /* how fast it can go */
139 int m_visib; /* how well it can be seen */
140 int m_vrnge; /* how well it can see */
141 int m_frnge; /* how far it can fire */
142 int m_glim; /* how many guns it can fire */
143 unsigned char m_nxlight; /* maximum number of xlight planes */
144 unsigned char m_nchoppers; /* maximum number of choppers */
145 unsigned char m_fuelc; /* fuel capacity */
146 unsigned char m_fuelu; /* fuel used per 10 mob */
147 char *m_name; /* full name of type of ship */
148 int m_tech; /* tech required to build */
149 int m_cost; /* how much it costs to build */
150 long m_flags; /* what special things can this ship do */
151 unsigned char m_nplanes; /* maximum number of planes this ship holds */
152 unsigned char m_nland; /* maximum number of units this ship holds */
153 signed char m_type; /* index in mchr[] */
156 #define M_FOOD bit(0) /* catch that fish! */
157 #define M_TORP bit(1) /* fire torpedoes */
158 #define M_DCH bit(2) /* drop depth charges on subs */
159 #define M_FLY bit(3) /* launch and recover planes */
160 /* M_MSL will be automatically set in init_global() if m_nplanes > 0
161 and M_FLY is not set */
162 #define M_MSL bit(4) /* launch missiles */
163 #define M_OIL bit(5) /* drill for oil */
164 #define M_SONAR bit(6) /* locate submarines */
165 #define M_MINE bit(7) /* drop mines */
166 #define M_SWEEP bit(8) /* clean up the mines */
167 #define M_SUB bit(9) /* a submarine */
169 #define M_LAND bit(11) /* allows full landing ability */
170 #define M_SUBT bit(12) /* allows torping of other subs */
171 #define M_TRADE bit(13) /* is a trade ship */
172 #define M_SEMILAND bit(14) /* can land 1/4 */
173 /* M_XLIGHT will be automatically set in init_mchr() if m_nxlight > 0 */
174 #define M_XLIGHT bit(15) /* can hold xlight planes */
175 /* M_CHOPPER will be automatically set in init_mchr() if m_nchoppers > 0 */
176 #define M_CHOPPER bit(16) /* can hold choppers */
177 #define M_OILER bit(17) /* can re-fuel ships */
178 #define M_SUPPLY bit(18) /* Can supply units/sects/ships */
179 #define M_CANAL bit(19) /* Can navigate a canal (BIG CITY) */
180 #define M_ANTIMISSILE bit(20) /* Shoot down missile */
182 #define getship(n, p) ef_read(EF_SHIP, (n), (p))
183 #define putship(n, p) ef_write(EF_SHIP, (n), (p))
184 #define getshipp(n) ((struct shpstr *)ef_ptr(EF_SHIP, (n)))
186 extern struct mchrstr mchr[SHP_TYPE_MAX + 2];
188 #define SHP_DEF(b, t) (t ? (b * (logx(t, 40.0) < 1.0 ? 1.0 : \
190 #define SHP_SPD(b, t) (t ? (b * (logx(t, 35.0) < 1.0 ? 1.0 : \
192 #define SHP_VIS(b, t) (b * (1 - (sqrt(t) / 50)))
193 #define SHP_RNG(b, t) (t ? (b * (logx(t, 35.0) < 1.0 ? 1.0 : \
195 #define SHP_FIR(b, t) (t ? (b * (logx(t, 60.0) < 1.0 ? 1.0 : \
198 /* Work required for building 100% */
199 #define SHP_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
201 /* return codes from shp_check_nav */
202 #define CN_NAVIGABLE 0
203 #define CN_LANDLOCKED 1
204 #define CN_CONSTRUCTION 2
208 SHP_AIROPS_EFF = 50, /* min. efficiency for air ops */
209 SHP_TORP_SHELLS = 3 /* number of shells used by a torpedo */