]> git.pond.sub.org Git - empserver/blobdiff - include/land.h
Update copyright notice
[empserver] / include / land.h
index 65520a9fcf0648cd82bf47eb7a734dd22bf9d176..6f5232ffc12cef5fdbaf17a1412809ef14b725a4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *  ---
  *
  *  land.h: Definitions for land units
- * 
+ *
  *  Known contributors to this file:
  *     Thomas Ruschak, 1992
  *     Ken Stevens, 1995
  *     Steve McClure, 1998
+ *     Markus Armbruster, 2004-2008
  */
 
 #ifndef LAND_H
 #define LAND_H
 
-#include "sect.h"
-#include "ship.h"
+#include <time.h>
+#include "item.h"
 #include "queue.h"
-#include "nsc.h"
 #include "retreat.h"
+#include "types.h"
 
-#define N_MAXLAND      30
+#define LND_TYPE_MAX   30
 #define LAND_MINEFF    10
 #define LAND_MINFIREEFF 40     /* arty must be this effic to fire */
 
 struct lndstr {
-    /* initial part must match struct genitem */
+    /* initial part must match struct empobj */
     short ef_type;
-    natid lnd_own;             /* owner's country num */
     short lnd_uid;             /* unit id (land unit) */
+    unsigned lnd_seqno;
+    time_t lnd_timestamp;      /* Last time this unit was touched */
+    natid lnd_own;             /* owner's country num */
     coord lnd_x;               /* x location in abs coords */
     coord lnd_y;               /* y location in abs coords */
     signed char lnd_type;      /* index in lchr[] */
@@ -62,40 +65,19 @@ struct lndstr {
     coord lnd_opx, lnd_opy;    /* Op sector coords */
     short lnd_mission;         /* mission code */
     short lnd_radius;          /* mission radius */
-    /* end of part matching struct genitem */
+    /* end of part matching struct empobj */
     signed char lnd_flags;     /* unit flags (unused) */
     short lnd_ship;            /* pointer to transporting ship */
     signed char lnd_harden;    /* fortification */
     short lnd_retreat;         /* retreat percentage */
-    unsigned char lnd_fuel;    /* How much fuel do we have */
-    unsigned char lnd_nxlight; /* How many xlight planes on board? */
     int lnd_rflags;            /* When do I retreat? */
     char lnd_rpath[RET_LEN];   /* retreat path */
-    unsigned char lnd_rad_max; /* max radius for this unit */
     unsigned char lnd_scar;    /* how experienced the unit is (not used) */
     short lnd_item[I_MAX+1];   /* amount of items on board */
     short lnd_pstage;          /* plague stage */
     short lnd_ptime;           /* how many etus remain in this stage */
     short lnd_land;            /* pointer to transporting unit */
-    unsigned char lnd_nland;
-    time_t lnd_access;         /* Last time mob was updated (MOB_ACCESS) */
-    float lnd_att;             /* attack multiplier */
-    float lnd_def;             /* defense multiplier */
-    int lnd_vul;               /* vulnerability (0-100) */
-    int lnd_spd;               /* speed */
-    int lnd_vis;               /* visibility */
-    int lnd_spy;               /* Seeing distance */
-    int lnd_rad;               /* reaction radius */
-    int lnd_frg;               /* firing range */
-    int lnd_acc;               /* firing accuracy */
-    int lnd_dam;               /* # of guns firing */
-    int lnd_ammo;              /* firing ammu used per shot */
-    int lnd_aaf;               /* aa fire */
-    unsigned char lnd_fuelc;   /* fuel capacity */
-    unsigned char lnd_fuelu;   /* fuel used per 10 mob */
-    unsigned char lnd_maxlight;        /* maximum number of xlight planes */
-    unsigned char lnd_maxland; /* maximum number of units */
-    time_t lnd_timestamp;      /* Last time this unit was touched */
+    short lnd_access;          /* Last tick mob was updated (MOB_ACCESS) */
 };
 
 struct lchrstr {
@@ -103,7 +85,7 @@ struct lchrstr {
     char *l_name;              /* full name of type of land unit */
     int l_lcm;                 /* units of lcm to build */
     int l_hcm;                 /* units of hcm to build */
-    int l_mil;                 /* how many mil it takes to build */
+    int l_mil;                 /* how many mil it takes to build (unused) */
     int l_gun;                 /* how many guns it takes to build (unused) */
     int l_shell;               /* #shells it takes to build (unused) */
     int l_tech;                        /* tech required to build */
@@ -120,8 +102,6 @@ struct lchrstr {
     int l_dam;                 /* # of guns firing */
     int l_ammo;                        /* firing ammu used per shot */
     int l_aaf;                 /* aa fire */
-    unsigned char l_fuelc;     /* fuel capacity */
-    unsigned char l_fuelu;     /* fuel used per 10 mob */
     unsigned char l_nxlight;   /* maximum number of xlight planes */
     unsigned char l_nland;     /* maximum number of units */
     signed char l_type;                /* index in lchr[] */
@@ -142,32 +122,6 @@ struct lchrstr {
 #define L_TRAIN         bit(11)        /* train unit - neato */
 #define L_HEAVY         bit(12)        /* heavy unit - can't go on trains */
 
-#define LND_ATTDEF(b, t) (((b) * (1.0 + ((sqrt((t)) / 100.0) * 4.0)))  \
-                         > 127 ? 127 :                                 \
-                         ((b) * (1.0 + ((sqrt((t)) / 100.0) * 4.0))))
-#define LND_SPD(b, t) ((b * (1.0 + ((sqrt(t) / 100.0) * 2.1))) > 127   \
-                      ? 127 : (b * (1.0 + ((sqrt(t) / 100.0) * 2.1))))
-#define LND_VUL(b, t) ((b * (1.0 - ((sqrt(t) / 100.0) * 1.1))) < 0     \
-                      ? 0 : (b * (1.0 - ((sqrt(t) / 100.0) * 1.1))))
-#define LND_VIS(b, t) (b)
-#define LND_SPY(b, t) (b)
-#define LND_RAD(b, t) (b)
-#define LND_FRG(b, t) ((t) ?                                \
-                      ((b) * (logx((t), 35.0) < 1.0 ? 1.0 : \
-                              logx((t), 35.0))) : (b))
-#define LND_DAM(b, t) ((t) ?                                \
-                      ((b) * (logx((t), 60.0) < 1.0 ? 1.0 : \
-                              logx((t), 60.0))) : (b))
-#define LND_ACC(b, t) ((b * (1.0 - ((sqrt(t) / 100.0) * 1.1))) < 0     \
-                      ? 0 : (b * (1.0 - ((sqrt(t) / 100.0) * 1.1))))
-#define LND_AMM(b, d, t) ((b) ? ((LND_DAM((d), (t)) / 2) + 1) : 0)
-#define LND_AAF(b, t) ((b * (1.0 + ((sqrt(t) / 100.0) * 3.0))) > 127   \
-                      ? 127 : (b * (1.0 + ((sqrt(t) / 100.0) * 3.0))))
-#define LND_FC(b, t)  (b)
-#define LND_FU(b, t)  (b)
-#define LND_XPL(b, t) (b)
-#define LND_MXL(b, t) (b)
-
 /* Work required for building 100% */
 #define LND_BLD_WORK(lcm, hcm) (20 + (lcm) + 2 * (hcm))
 
@@ -176,24 +130,43 @@ struct lchrstr {
 
 #define getland(n, p) ef_read(EF_LAND, (n), (p))
 #define putland(n, p) ef_write(EF_LAND, (n), (p))
-#define getlandp(n) (struct lndstr *)ef_ptr(EF_LAND, (n))
-
-extern struct lchrstr lchr[N_MAXLAND + 1];
-
-struct llist {
-    struct emp_qelem queue;    /* list of units */
-    coord x, y;                        /* x,y it came from */
-    struct lchrstr *lcp;       /* pointer to desc of land unit */
-    struct lndstr land;                /* struct land unit */
-    int eff;
-    double mobil;
-    int supplied;
-};
+#define getlandp(n) ((struct lndstr *)ef_ptr(EF_LAND, (n)))
+
+extern struct lchrstr lchr[LND_TYPE_MAX + 2];
 
 enum {
     LND_AIROPS_EFF = 50                /* min. efficiency for air ops */
 };
 
+extern float l_att(struct lchrstr *, int);
+extern float l_def(struct lchrstr *, int);
+extern int l_vul(struct lchrstr *, int);
+extern int l_spd(struct lchrstr *, int);
+extern int l_frg(struct lchrstr *, int);
+extern int l_acc(struct lchrstr *, int);
+extern int l_dam(struct lchrstr *, int);
+extern int l_aaf(struct lchrstr *, int);
+extern float lnd_att(struct lndstr *);
+extern float lnd_def(struct lndstr *);
+extern int lnd_vul(struct lndstr *);
+extern int lnd_spd(struct lndstr *);
+extern int lnd_vis(struct lndstr *);
+extern int lnd_frg(struct lndstr *);
+extern int lnd_acc(struct lndstr *);
+extern int lnd_dam(struct lndstr *);
+extern int lnd_aaf(struct lndstr *);
+
+/* src/lib/common/cargo.c */
+extern void lnd_carrier_change(struct lndstr *, int, int, int);
+extern int lnd_first_on_ship(struct shpstr *);
+extern int lnd_first_on_land(struct lndstr *);
+extern int lnd_next_on_unit(int);
+extern int lnd_nxlight(struct lndstr *);
+extern int lnd_nland(struct lndstr *);
+
+extern int lnd_fire(struct lndstr *);
+extern double lnd_fire_range(struct lndstr *);
+
 /* src/lib/subs/lndsub.c */
 extern void lnd_sweep(struct emp_qelem *, int, int, natid);
 extern int lnd_interdict(struct emp_qelem *, coord, coord, natid);
@@ -202,23 +175,18 @@ extern int lnd_check_mines(struct emp_qelem *);
 extern double lnd_pathcost(struct lndstr *, double);
 extern int lnd_mobtype(struct lndstr *);
 extern double lnd_mobcost(struct lndstr *, struct sctstr *);
-extern char *lnd_path(int, struct lndstr *, char *);
 
 extern double attack_val(int, struct lndstr *);
 extern double defense_val(struct lndstr *);
-extern void lnd_print(struct llist *, char *);
-extern void lnd_delete(struct llist *, char *);
-extern int lnd_take_casualty(int, struct llist *, int);
+extern int lnd_reaction_range(struct lndstr *);
+extern void lnd_print(struct ulist *, char *);
+extern void lnd_delete(struct ulist *, char *);
+extern int lnd_take_casualty(int, struct ulist *, int);
 extern void lnd_submil(struct lndstr *, int);
 extern void lnd_takemob(struct emp_qelem *, double);
 extern int lnd_spyval(struct lndstr *);
-extern double intelligence_report(int, struct lndstr *, int, char *);
-extern int count_sect_units(struct sctstr *);
-extern void count_units(struct shpstr *);
-extern void lnd_count_units(struct lndstr *);
+extern void intelligence_report(int, struct lndstr *, int, char *);
 extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
-extern void lnd_put(struct emp_qelem *, natid);
-extern void lnd_list(struct emp_qelem *);
 extern int lnd_hardtarget(struct lndstr *);
 extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
 extern int lnd_support(natid, natid, coord, coord, int);