]> git.pond.sub.org Git - empserver/blobdiff - include/ship.h
Update copyright notice.
[empserver] / include / ship.h
index e3e1112d55dade458b649c67c1179dadef4f4fa1..3042e0d602901d56786565bdf6aa89abd7048c84 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -19,9 +19,9 @@
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
  *
  *  ---
  *
  * 
  *  Known contributors to this file:
  *     Dave Pare
- *     Thomas Rushack, 1992
+ *     Thomas Ruschak, 1992
  *     Ken Stevens, 1995
  *     Steve McClure, 1998
  */
 
-#ifndef _SHIP_H_
-#define _SHIP_H_
+#ifndef SHIP_H
+#define SHIP_H
 
 #include "item.h"
 #include "queue.h"
-#include "misc.h"
 #include "retreat.h"
+#include "types.h"
 
-#define N_MAXSHIPS     40
+#define SHP_TYPE_MAX   46
 #define        SHIP_MINEFF     20
 
 /* bit masks for the autonav mode flags */
 #define        MAXSHPNAMLEN    24
 
 struct shpstr {
-    /* initial part must match struct genitem */
+    /* initial part must match struct empobj */
     short ef_type;
     natid shp_own;             /* owner's country num */
     short shp_uid;             /* unit id (ship #) */
     coord shp_x;               /* x location in abs coords */
     coord shp_y;               /* y location in abs coords */
-    s_char shp_type;           /* index in mchr[] */
-    s_char shp_effic;          /* 0% to 100% */
-    s_char shp_mobil;          /* mobility units */
+    signed char shp_type;      /* index in mchr[] */
+    signed char shp_effic;     /* 0% to 100% */
+    signed char shp_mobil;     /* mobility units */
+    unsigned char shp_off;     /* repairs stopped? */
     short shp_tech;            /* tech level ship was built at */
-    s_char shp_fleet;          /* group membership */
+    char shp_fleet;            /* group membership */
     coord shp_opx, shp_opy;    /* Op sector coords */
     short shp_mission;         /* mission code */
     short shp_radius;          /* mission radius */
-    /* end of part matching struct genitem */
-    u_char shp_nplane;         /* number of planes on board */
-    u_char shp_nland;          /* number of land units on board */
+    /* 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 */
     short shp_armor;
     short shp_speed;
     short shp_visib;
@@ -88,19 +89,19 @@ struct shpstr {
     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    */
-    u_char shp_autonav;                /* autonavigation flags */
+    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 */
     time_t shp_access;         /* Last time mob was updated (MOB_ACCESS) */
     time_t shp_timestamp;      /* Last time this ship was touched. */
-    u_char shp_mobquota;       /* mobility quota */
+    unsigned char shp_mobquota;        /* mobility quota */
     char shp_path[MAXSHPPATH];
     short shp_follow;
     char shp_name[MAXSHPNAMLEN]; /* name set with the "name" command */
-    u_char shp_fuel;           /* How much fuel do we have */
-    u_char shp_nchoppers;      /* How many choppers on board? */
-    u_char shp_nxlight;                /* How many xlight planes on board? */
+    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 */
@@ -117,7 +118,7 @@ struct fltelemstr {
 
 struct fltheadstr {
     int leader;
-    s_char real_q;
+    signed char real_q;
 /* defines for the real_q member */
 #define        LEADER_VIRTUAL  0
 #define        LEADER_REAL     1
@@ -130,7 +131,7 @@ struct fltheadstr {
 };
 
 struct mchrstr {
-    u_short m_item[I_MAX+1];   /* load limit */
+    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 */
@@ -139,16 +140,17 @@ struct mchrstr {
     int m_vrnge;               /* how well it can see */
     int m_frnge;               /* how far it can fire */
     int m_glim;                        /* how many guns it can fire */
-    u_char m_nxlight;          /* maximum number of xlight planes */
-    u_char m_nchoppers;                /* maximum number of choppers */
-    u_char m_fuelc;            /* fuel capacity */
-    u_char m_fuelu;            /* fuel used per 10 mob */
+    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 */
     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 */
-    u_char m_nplanes;          /* maximum number of planes this ship holds */
-    u_char m_nland;            /* maximum number of units this ship holds */
+    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[] */
 };
 
 #define M_FOOD         bit(0)  /* catch that fish! */
@@ -163,46 +165,35 @@ struct mchrstr {
 #define M_MINE         bit(7)  /* drop mines */
 #define M_SWEEP                bit(8)  /* clean up the mines */
 #define M_SUB          bit(9)  /* a submarine */
-#define M_SPY          bit(10) /* gather intelligence info */
+/* 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 */
-/* M_XLIGHT will be automatically set in init_global() if m_nxlight > 0 */
+/* M_XLIGHT will be automatically set in init_mchr() if m_nxlight > 0 */
 #define        M_XLIGHT        bit(15) /* can hold xlight planes */
-/* M_CHOPPER will be automatically set in init_global() if m_nchoppers > 0 */
+/* M_CHOPPER will be automatically set in init_mchr() if m_nchoppers > 0 */
 #define M_CHOPPER      bit(16) /* can hold choppers */
 #define M_OILER                bit(17) /* can re-fuel ships */
 #define M_SUPPLY       bit(18) /* Can supply units/sects/ships */
-/* M_UNIT will be automatically set in init_global() if m_nland > 0 */
-#define M_UNIT         bit(19) /* Can carry units */
+#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)
+#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[N_MAXSHIPS + 1];
+extern struct mchrstr mchr[SHP_TYPE_MAX + 2];
 
-struct mlist {
-    struct emp_qelem queue;    /* list of ships */
-    struct mchrstr *mcp;       /* pointer to desc of ship */
-    struct shpstr ship;                /* struct ship */
-    double mobil;              /* how much mobility the ship has left */
-};
-
-#define SHP_DEF(b, t) (t ? (b * (logx((double)t, (double)40.0) < 1.0 ? 1.0 : \
-                            logx((double)t, (double)40.0))) : b)
-#define SHP_SPD(b, t) (t ? (b * (logx((double)t, (double)35.0) < 1.0 ? 1.0 : \
-                            logx((double)t, (double)35.0))) : b)
-#define SHP_VIS(b, t) (b * (1 - (sqrt((double)t) / 50)))
-#define SHP_RNG(b, t) (t ? (b * (logx((double)t, (double)35.0) < 1.0 ? 1.0 : \
-                            logx((double)t, (double)35.0))) : b)
-#define SHP_FIR(b, t) (t ? (b * (logx((double)t, (double)60.0) < 1.0 ? 1.0 : \
-                            logx((double)t, (double)60.0))) : b)
+#define SHP_DEF(b, t) (t ? (b * (logx(t, 40.0) < 1.0 ? 1.0 : \
+                                logx(t, 40.0))) : b)
+#define SHP_SPD(b, t) (t ? (b * (logx(t, 35.0) < 1.0 ? 1.0 : \
+                                logx(t, 35.0))) : b)
+#define SHP_VIS(b, t) (b * (1 - (sqrt(t) / 50)))
+#define SHP_RNG(b, t) (t ? (b * (logx(t, 35.0) < 1.0 ? 1.0 : \
+                                logx(t, 35.0))) : b)
+#define SHP_FIR(b, t) (t ? (b * (logx(t, 60.0) < 1.0 ? 1.0 : \
+                                logx(t, 60.0))) : b)
 
 /* Work required for building 100% */
 #define SHP_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
@@ -218,4 +209,4 @@ enum {
     SHP_TORP_SHELLS = 3                /* number of shells used by a torpedo */
 };
 
-#endif /* _SHIP_H_ */
+#endif