2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2020, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 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, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * ship.h: Definitions for things having to do with ships
29 * Known contributors to this file:
31 * Thomas Ruschak, 1992
34 * Markus Armbruster, 2004-2020
45 #define SHIP_MINEFF 20
47 #define MAXSHPNAMLEN 24
50 /* initial part must match struct empobj */
52 unsigned shp_seqno: 12;
53 unsigned shp_generation: 12;
54 int shp_uid; /* unit it (ship #) */
55 time_t shp_timestamp; /* Last time this ship was touched. */
56 natid shp_own; /* owner's country num */
57 coord shp_x; /* x location in abs coords */
58 coord shp_y; /* y location in abs coords */
59 signed char shp_type; /* index in mchr[] */
60 signed char shp_effic; /* 0% to 100% */
61 signed char shp_mobil; /* mobility units */
62 unsigned char shp_off; /* repairs stopped? */
63 short shp_tech; /* tech level ship was built at */
64 char shp_fleet; /* group membership */
65 coord shp_opx, shp_opy; /* Op sector coords */
66 short shp_mission; /* mission code */
67 short shp_radius; /* mission radius */
68 /* end of part matching struct empobj */
69 short shp_item[I_MAX+1]; /* amount of items on board */
70 short shp_pstage; /* plague stage */
71 short shp_ptime; /* how many ETUs remain in this stage */
72 short shp_access; /* Last tick mob was updated (MOB_ACCESS) */
73 char shp_name[MAXSHPNAMLEN]; /* name set with the "name" command */
75 coord shp_orig_y; /* Where we were built */
76 natid shp_orig_own; /* Who built us */
77 int shp_rflags; /* When do I retreat? */
78 char shp_rpath[RET_LEN]; /* retreat path */
82 short m_item[I_MAX+1]; /* load limit */
83 int m_armor; /* how well armored it is */
84 int m_speed; /* how fast it can go */
85 int m_visib; /* how well it can be seen */
86 int m_vrnge; /* how well it can see */
87 int m_frnge; /* how far it can fire */
88 int m_glim; /* how many guns it can fire */
89 unsigned char m_nxlight; /* maximum number of xlight planes */
90 unsigned char m_nchoppers; /* maximum number of choppers */
91 char *m_name; /* full name of type of ship */
92 short m_mat[I_MAX+1]; /* materials to build 100% */
93 /* only I_LCM and I_HCM non-zero */
94 int m_bwork; /* work to build 100% */
95 int m_tech; /* tech required to build */
96 int m_cost; /* how much it costs to build */
97 int m_flags; /* what special things can this ship do */
98 unsigned char m_nplanes; /* maximum number of planes this ship holds */
99 unsigned char m_nland; /* maximum number of units this ship holds */
100 signed char m_type; /* index in mchr[] */
103 #define M_FOOD bit(0) /* catch that fish! */
104 #define M_TORP bit(1) /* fire torpedoes */
105 #define M_DCH bit(2) /* drop depth charges on subs */
106 #define M_FLY bit(3) /* launch and recover planes */
107 #define M_MSL bit(4) /* launch missiles */
108 #define M_OIL bit(5) /* drill for oil */
109 #define M_SONAR bit(6) /* locate submarines */
110 #define M_MINE bit(7) /* drop mines */
111 #define M_SWEEP bit(8) /* clean up the mines */
112 #define M_SUB bit(9) /* a submarine */
114 #define M_LAND bit(11) /* allows full landing ability */
115 #define M_SUBT bit(12) /* allows torping of other subs */
116 #define M_TRADE bit(13) /* is a trade ship */
117 #define M_SEMILAND bit(14) /* can land 1/4 */
121 #define M_SUPPLY bit(18) /* Can supply units/sects/ships */
122 #define M_CANAL bit(19) /* Can navigate a canal (BIG CITY) */
123 #define M_ANTIMISSILE bit(20) /* Shoot down missile */
125 #define getship(n, p) ef_read(EF_SHIP, (n), (p))
126 #define putship(n, p) ef_write(EF_SHIP, (n), (p))
127 #define getshipp(n) ((struct shpstr *)ef_ptr(EF_SHIP, (n)))
130 extern struct mchrstr mchr[MCHR_SZ];
133 SHP_AIROPS_EFF = 50, /* min. efficiency for air ops */
134 SHP_TORP_SHELLS = 3 /* number of shells used by a torpedo */
137 /* Whether and why a ship is stuck in a sector */
139 SHP_STUCK_NOT, /* not stuck */
140 SHP_STUCK_CONSTRUCTION, /* sector not efficient enough */
141 SHP_STUCK_CANAL, /* ship lacks M_CANAL */
142 SHP_STUCK_IMPASSABLE /* sector type not navigable */
145 extern int m_armor(struct mchrstr *, int);
146 extern int m_speed(struct mchrstr *, int);
147 extern int m_visib(struct mchrstr *, int);
148 extern int m_frnge(struct mchrstr *, int);
149 extern int m_glim(struct mchrstr *, int);
150 extern int shp_armor(struct shpstr *);
151 extern int shp_speed(struct shpstr *);
152 extern int shp_visib(struct shpstr *);
153 extern int shp_frnge(struct shpstr *);
154 extern int shp_glim(struct shpstr *);
156 extern int shp_nplane(struct shpstr *, int *, int *, int *);
157 extern int shp_nland(struct shpstr *);
159 extern int shp_dchrg(struct shpstr *);
160 extern int shp_fire(struct shpstr *);
161 extern int shp_torp(struct shpstr *, int);
162 extern double shp_fire_range(struct shpstr *);
163 extern int shp_usable_guns(struct shpstr *);
164 extern double shp_torp_hitchance(struct shpstr *, int);
166 /* src/lib/subs/shpsub.c */
167 extern int shp_may_nav(struct shpstr *, struct shpstr *, char *);
168 extern void shp_sel(struct nstr_item *, struct emp_qelem *);
169 extern struct ulist *shp_insque(struct shpstr *, struct emp_qelem *);
170 extern void shp_nav_stay_behind(struct emp_qelem *, natid);
171 extern void shp_nav_put(struct emp_qelem *, natid);
172 extern int shp_sweep(struct emp_qelem *, int, int, natid);
173 extern enum shp_stuck shp_check_nav(struct shpstr *, struct sctstr *);
174 extern int sect_has_dock(struct sctstr *);
175 extern int shp_hardtarget(struct shpstr *);
176 extern int shp_nav_dir(struct emp_qelem *, int, natid);
177 extern int shp_nav_gauntlet(struct emp_qelem *, int, natid);
178 extern int shp_missile_defense(coord, coord, natid, int);
179 extern void shp_missdef(struct shpstr *, natid);
180 extern double shp_mobcost(struct shpstr *);
181 extern void shp_set_tech(struct shpstr *, int);