]> git.pond.sub.org Git - empserver/blobdiff - include/ship.h
retreat: Rewrite automatic retreat code to fix its many bugs
[empserver] / include / ship.h
index 81c2f0868a3d470d53aac328b440798b18eece1d..8557487909eca8ada4a0405df0e3fe3191580cc9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@
  *     Thomas Ruschak, 1992
  *     Ken Stevens, 1995
  *     Steve McClure, 1998
- *     Markus Armbruster, 2004-2014
+ *     Markus Armbruster, 2004-2015
  */
 
 #ifndef SHIP_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 */
-
-/* TMAX is the number of cargo holds a ship use in the autonav code. */
-#define TMAX 6
-
-
 #define MAXSHPPATH     28
 #define MAXSHPNAMLEN   24
 
@@ -79,20 +68,10 @@ struct shpstr {
     short shp_mission;         /* mission code */
     short shp_radius;          /* mission radius */
     /* end of part matching struct empobj */
-    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_access;          /* Last tick mob was updated (MOB_ACCESS) */
-    unsigned char shp_mobquota;        /* mobility quota */
-    char shp_path[MAXSHPPATH];
-    int shp_follow;
     char shp_name[MAXSHPNAMLEN]; /* name set with the "name" command */
     coord shp_orig_x;
     coord shp_orig_y;          /* Where we were built */
@@ -160,6 +139,14 @@ enum {
     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);
@@ -182,15 +169,17 @@ 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(struct emp_qelem *, double *, double *, int *, natid);
-extern void shp_put(struct emp_qelem *, natid);
+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 d_navigation shp_check_nav(struct shpstr *, struct sctstr *);
+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_one_sector(struct emp_qelem *, int, natid, int);
+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 *);