X-Git-Url: http://git.pond.sub.org/?p=empserver;a=blobdiff_plain;f=include%2Fship.h;h=83db8c034caa6f68eb4487527559d7ad1166f517;hp=0b9ed35ba277307605af85a3b36ebd3224833166;hb=HEAD;hpb=a680c81110d562afd759ff5e91e4a2fba624544c diff --git a/include/ship.h b/include/ship.h index 0b9ed35ba..83db8c034 100644 --- a/include/ship.h +++ b/include/ship.h @@ -1,11 +1,11 @@ /* * Empire - A multi-player, client/server Internet based war game. - * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak, - * Ken Stevens, Steve McClure + * Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak, + * Ken Stevens, Steve McClure, Markus Armbruster * - * This program is free software; you can redistribute it and/or modify + * Empire is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program. If not, see . * * --- * @@ -26,44 +25,33 @@ * --- * * ship.h: Definitions for things having to do with ships - * + * * Known contributors to this file: * Dave Pare * Thomas Ruschak, 1992 * Ken Stevens, 1995 * Steve McClure, 1998 + * Markus Armbruster, 2004-2020 */ #ifndef SHIP_H #define SHIP_H -#include +#include "file.h" #include "item.h" -#include "queue.h" #include "retreat.h" #include "types.h" -#define SHP_TYPE_MAX 46 -#define SHIP_MINEFF 20 - -/* bit masks for the autonav mode flags */ - -#define AN_AUTONAV bit(2) -#define AN_STANDBY bit(3) -#define AN_LOADING bit(4) -#define AN_SCUTTLE bit(5) /* Auto-scuttle of trade ships */ +#define SHIP_MINEFF 20 -/* TMAX is the number of cargo holds a ship use in the autonav code. */ -#define TMAX 6 - - -#define MAXSHPPATH 28 -#define MAXSHPNAMLEN 24 +#define MAXSHPNAMLEN 24 struct shpstr { /* initial part must match struct empobj */ - short ef_type; - short shp_uid; /* unit id (ship #) */ + signed ef_type: 8; + unsigned shp_seqno: 12; + unsigned shp_generation: 12; + int shp_uid; /* unit it (ship #) */ time_t shp_timestamp; /* Last time this ship was touched. */ natid shp_own; /* owner's country num */ coord shp_x; /* x location in abs coords */ @@ -78,26 +66,11 @@ struct shpstr { short shp_mission; /* mission code */ short shp_radius; /* mission radius */ /* end of part matching struct empobj */ - unsigned char shp_nplane; /* number of planes on board */ - unsigned char shp_nland; /* number of land units on board */ - coord shp_destx[2]; /* location for ship destination */ - coord shp_desty[2]; - i_type shp_tstart[TMAX]; /* what goods to pick up at start point */ - i_type shp_tend[TMAX]; /* what goods to pick up at end point */ - short shp_lstart[TMAX]; /* How much do we pick up at the start */ - short shp_lend[TMAX]; /* How much do we pick up at the end */ - unsigned char shp_autonav; /* autonavigation flags */ short shp_item[I_MAX+1]; /* amount of items on board */ short shp_pstage; /* plague stage */ - short shp_ptime; /* how many etus remain in this stage */ + short shp_ptime; /* how many ETUs remain in this stage */ short shp_access; /* Last tick mob was updated (MOB_ACCESS) */ - unsigned char shp_mobquota; /* mobility quota */ - char shp_path[MAXSHPPATH]; - short shp_follow; char shp_name[MAXSHPNAMLEN]; /* name set with the "name" command */ - unsigned char shp_fuel; /* How much fuel do we have */ - unsigned char shp_nchoppers; /* How many choppers on board? */ - unsigned char shp_nxlight; /* How many xlight planes on board? */ coord shp_orig_x; coord shp_orig_y; /* Where we were built */ natid shp_orig_own; /* Who built us */ @@ -107,8 +80,6 @@ struct shpstr { struct mchrstr { short m_item[I_MAX+1]; /* load limit */ - int m_lcm; /* units of lcm to build */ - int m_hcm; /* units of hcm to build */ int m_armor; /* how well armored it is */ int m_speed; /* how fast it can go */ int m_visib; /* how well it can be seen */ @@ -117,12 +88,13 @@ struct mchrstr { int m_glim; /* how many guns it can fire */ unsigned char m_nxlight; /* maximum number of xlight planes */ unsigned char m_nchoppers; /* maximum number of choppers */ - unsigned char m_fuelc; /* fuel capacity */ - unsigned char m_fuelu; /* fuel used per 10 mob */ char *m_name; /* full name of type of ship */ + short m_mat[I_MAX+1]; /* materials to build 100% */ + /* only I_LCM and I_HCM non-zero */ + int m_bwork; /* work to build 100% */ int m_tech; /* tech required to build */ int m_cost; /* how much it costs to build */ - long m_flags; /* what special things can this ship do */ + int m_flags; /* what special things can this ship do */ unsigned char m_nplanes; /* maximum number of planes this ship holds */ unsigned char m_nland; /* maximum number of units this ship holds */ signed char m_type; /* index in mchr[] */ @@ -132,46 +104,44 @@ struct mchrstr { #define M_TORP bit(1) /* fire torpedoes */ #define M_DCH bit(2) /* drop depth charges on subs */ #define M_FLY bit(3) /* launch and recover planes */ -/* M_MSL will be automatically set in init_global() if m_nplanes > 0 - and M_FLY is not set */ #define M_MSL bit(4) /* launch missiles */ #define M_OIL bit(5) /* drill for oil */ #define M_SONAR bit(6) /* locate submarines */ #define M_MINE bit(7) /* drop mines */ #define M_SWEEP bit(8) /* clean up the mines */ #define M_SUB bit(9) /* a submarine */ -/* unused bit(10) */ +/* unused bit(10) */ #define M_LAND bit(11) /* allows full landing ability */ #define M_SUBT bit(12) /* allows torping of other subs */ #define M_TRADE bit(13) /* is a trade ship */ #define M_SEMILAND bit(14) /* can land 1/4 */ -/* unused bit(15) */ -/* unused bit(16) */ -#define M_OILER bit(17) /* can re-fuel ships */ +/* unused bit(15) */ +/* unused bit(16) */ +/* unused bit(17) */ #define M_SUPPLY bit(18) /* Can supply units/sects/ships */ -#define M_CANAL bit(19) /* Can navigate a canal (BIG CITY) */ -#define M_ANTIMISSILE bit(20) /* Shoot down missile */ +#define M_CANAL bit(19) /* Can navigate a canal (BIG CITY) */ +#define M_ANTIMISSILE bit(20) /* Shoot down missile */ #define getship(n, p) ef_read(EF_SHIP, (n), (p)) #define putship(n, p) ef_write(EF_SHIP, (n), (p)) #define getshipp(n) ((struct shpstr *)ef_ptr(EF_SHIP, (n))) -extern struct mchrstr mchr[SHP_TYPE_MAX + 2]; - -/* Work required for building 100% */ -#define SHP_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm)) - - /* return codes from shp_check_nav */ -#define CN_NAVIGABLE 0 -#define CN_LANDLOCKED 1 -#define CN_CONSTRUCTION 2 -#define CN_ERROR -1 +#define MCHR_SZ 128 +extern struct mchrstr mchr[MCHR_SZ]; enum { SHP_AIROPS_EFF = 50, /* min. efficiency for air ops */ SHP_TORP_SHELLS = 3 /* number of shells used by a torpedo */ }; +/* Whether and why a ship is stuck in a sector */ +enum shp_stuck { + SHP_STUCK_NOT, /* not stuck */ + SHP_STUCK_CONSTRUCTION, /* sector not efficient enough */ + SHP_STUCK_CANAL, /* ship lacks M_CANAL */ + SHP_STUCK_IMPASSABLE /* sector type not navigable */ +}; + extern int m_armor(struct mchrstr *, int); extern int m_speed(struct mchrstr *, int); extern int m_visib(struct mchrstr *, int); @@ -183,6 +153,9 @@ extern int shp_visib(struct shpstr *); extern int shp_frnge(struct shpstr *); extern int shp_glim(struct shpstr *); +extern int shp_nplane(struct shpstr *, int *, int *, int *); +extern int shp_nland(struct shpstr *); + extern int shp_dchrg(struct shpstr *); extern int shp_fire(struct shpstr *); extern int shp_torp(struct shpstr *, int); @@ -190,4 +163,21 @@ extern double shp_fire_range(struct shpstr *); extern int shp_usable_guns(struct shpstr *); extern double shp_torp_hitchance(struct shpstr *, int); +/* src/lib/subs/shpsub.c */ +extern int shp_may_nav(struct shpstr *, struct shpstr *, char *); +extern void shp_sel(struct nstr_item *, struct emp_qelem *); +extern struct ulist *shp_insque(struct shpstr *, struct emp_qelem *); +extern void shp_nav_stay_behind(struct emp_qelem *, natid); +extern void shp_nav_put(struct emp_qelem *, natid); +extern int shp_sweep(struct emp_qelem *, int, int, natid); +extern enum shp_stuck shp_check_nav(struct shpstr *, struct sctstr *); +extern int sect_has_dock(struct sctstr *); +extern int shp_hardtarget(struct shpstr *); +extern int shp_nav_dir(struct emp_qelem *, int, natid); +extern int shp_nav_gauntlet(struct emp_qelem *, int, natid); +extern int shp_missile_defense(coord, coord, natid, int); +extern void shp_missdef(struct shpstr *, natid); +extern double shp_mobcost(struct shpstr *); +extern void shp_set_tech(struct shpstr *, int); + #endif