Macro SHP_TYPE_MAX is the largest possible ship type number. It is
only used to size mchr[], and we need + 2 there. Replace by MCHR_SZ
for simplicity.
Same for LND_TYPE_MAX, PLN_TYPE_MAX, P_MAX, and SCT_TYPE_MAX: replace
by LCHR_SZ, PLCHR_SZ, PCHR_SZ, and DCHR_SZ.
Same for N_MAXNUKE, except that one is more than the largest type
number. Replace by NCHR_SZ.
For consistency, define ICHR_SZ and INTRCHR_SZ for sizing ichr[] and
intrchr_sz[].
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 files changed:
* item.h: Definitions for item characteristics stuff
*
* Known contributors to this file:
* item.h: Definitions for item characteristics stuff
*
* Known contributors to this file:
- * Markus Armbruster, 2004-2016
+ * Markus Armbruster, 2004-2020
/* variables using this structure */
/* variables using this structure */
-extern struct ichrstr ichr[I_MAX + 2];
+#define ICHR_SZ (I_MAX + 2)
+extern struct ichrstr ichr[ICHR_SZ];
/* procedures using/returning this struct */
/* procedures using/returning this struct */
* Thomas Ruschak, 1992
* Ken Stevens, 1995
* Steve McClure, 1998
* Thomas Ruschak, 1992
* Ken Stevens, 1995
* Steve McClure, 1998
- * Markus Armbruster, 2004-2016
+ * Markus Armbruster, 2004-2020
#include "retreat.h"
#include "types.h"
#include "retreat.h"
#include "types.h"
#define LAND_MINEFF 10
#define LAND_MINFIREEFF 40 /* arty must be this effic to fire */
#define LAND_MINEFF 10
#define LAND_MINFIREEFF 40 /* arty must be this effic to fire */
#define putland(n, p) ef_write(EF_LAND, (n), (p))
#define getlandp(n) ((struct lndstr *)ef_ptr(EF_LAND, (n)))
#define putland(n, p) ef_write(EF_LAND, (n), (p))
#define getlandp(n) ((struct lndstr *)ef_ptr(EF_LAND, (n)))
-extern struct lchrstr lchr[LND_TYPE_MAX + 2];
+#define LCHR_SZ 32
+extern struct lchrstr lchr[LCHR_SZ];
enum {
LND_AIROPS_EFF = 50 /* min. efficiency for air ops */
enum {
LND_AIROPS_EFF = 50 /* min. efficiency for air ops */
*
* Known contributors to this file:
* Dave Pare, 1986
*
* Known contributors to this file:
* Dave Pare, 1986
- * Markus Armbruster, 2004-2016
+ * Markus Armbruster, 2004-2020
#include "item.h"
#include "types.h"
#include "item.h"
#include "types.h"
#define MIN_DRNUKE_CONST 0.001
struct nukstr {
#define MIN_DRNUKE_CONST 0.001
struct nukstr {
#define putnuke(n, p) ef_write(EF_NUKE, (n), (p))
#define getnukep(n) ((struct nukstr *)ef_ptr(EF_NUKE, (n)))
#define putnuke(n, p) ef_write(EF_NUKE, (n), (p))
#define getnukep(n) ((struct nukstr *)ef_ptr(EF_NUKE, (n)))
-extern struct nchrstr nchr[N_MAXNUKE + 1];
+#define NCHR_SZ 21
+extern struct nchrstr nchr[NCHR_SZ];
/* src/lib/common/cargo.c */
extern void nuk_carrier_change(struct nukstr *, int, int, int);
/* src/lib/common/cargo.c */
extern void nuk_carrier_change(struct nukstr *, int, int, int);
* Dave Pare, 1986
* Ken Stevens, 1995
* Steve McClure, 1998
* Dave Pare, 1986
* Ken Stevens, 1995
* Steve McClure, 1998
- * Markus Armbruster, 2004-2016
+ * Markus Armbruster, 2004-2020
#include "queue.h"
#include "types.h"
#include "queue.h"
#include "types.h"
#define PLANE_MINEFF 10
struct plnstr {
#define PLANE_MINEFF 10
struct plnstr {
#define putplane(n, p) ef_write(EF_PLANE, (n), (p))
#define getplanep(n) ((struct plnstr *)ef_ptr(EF_PLANE, (n)))
#define putplane(n, p) ef_write(EF_PLANE, (n), (p))
#define getplanep(n) ((struct plnstr *)ef_ptr(EF_PLANE, (n)))
-extern struct plchrstr plchr[PLN_TYPE_MAX + 2];
+#define PLCHR_SZ 48
+extern struct plchrstr plchr[PLCHR_SZ];
struct shiplist {
int uid;
struct shiplist {
int uid;
char *p_sname; /* short (7 char or less) name of product */
};
char *p_sname; /* short (7 char or less) name of product */
};
-#define P_MAX 22
-
-extern struct pchrstr pchr[P_MAX + 2];
+#define PCHR_SZ 24
+extern struct pchrstr pchr[PCHR_SZ];
* Dave Pare
* Ken Stevens, 1995
* Steve McClure, 1998
* Dave Pare
* Ken Stevens, 1995
* Steve McClure, 1998
- * Markus Armbruster, 2004-2016
+ * Markus Armbruster, 2004-2020
#define SCT_PLAINS 32 /* plains sector */
#define SCT_BTOWER 33 /* Bridge tower */
#define SCT_PLAINS 32 /* plains sector */
#define SCT_BTOWER 33 /* Bridge tower */
-#define SCT_TYPE_MAX 38
-
#define getsect(x, y, p) ef_read(EF_SECTOR, sctoff((x), (y)), (p))
#define putsect(p) ef_write(EF_SECTOR, (p)->sct_uid, (p))
#define getsectp(x, y) ((struct sctstr *)ef_ptr(EF_SECTOR, sctoff((x), (y))))
#define getsectid(id) ((struct sctstr *)ef_ptr(EF_SECTOR, (id)))
#define getsect(x, y, p) ef_read(EF_SECTOR, sctoff((x), (y)), (p))
#define putsect(p) ef_write(EF_SECTOR, (p)->sct_uid, (p))
#define getsectp(x, y) ((struct sctstr *)ef_ptr(EF_SECTOR, sctoff((x), (y))))
#define getsectid(id) ((struct sctstr *)ef_ptr(EF_SECTOR, (id)))
-extern struct dchrstr dchr[SCT_TYPE_MAX + 2];
+#define DCHR_SZ 40
+extern struct dchrstr dchr[DCHR_SZ];
+
#define IS_BIG_CITY(type) (dchr[(type)].d_pkg == UPKG)
/* Minimal efficiency of sectors that can be knocked down (bridges) */
#define IS_BIG_CITY(type) (dchr[(type)].d_pkg == UPKG)
/* Minimal efficiency of sectors that can be knocked down (bridges) */
unsigned char in_enable; /* enabled iff non-zero */
};
unsigned char in_enable; /* enabled iff non-zero */
};
-extern struct sctintrins intrchr[INT_DEF + 2];
+#define INTRCHR_SZ INT_DEF + 2
+extern struct sctintrins intrchr[INTRCHR_SZ];
extern int fort_fire(struct sctstr *);
extern int sct_rail_track(struct sctstr *);
extern int fort_fire(struct sctstr *);
extern int sct_rail_track(struct sctstr *);
* Thomas Ruschak, 1992
* Ken Stevens, 1995
* Steve McClure, 1998
* Thomas Ruschak, 1992
* Ken Stevens, 1995
* Steve McClure, 1998
- * Markus Armbruster, 2004-2016
+ * Markus Armbruster, 2004-2020
#include "retreat.h"
#include "types.h"
#include "retreat.h"
#include "types.h"
#define SHIP_MINEFF 20
#define MAXSHPNAMLEN 24
#define SHIP_MINEFF 20
#define MAXSHPNAMLEN 24
#define putship(n, p) ef_write(EF_SHIP, (n), (p))
#define getshipp(n) ((struct shpstr *)ef_ptr(EF_SHIP, (n)))
#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];
+#define MCHR_SZ 48
+extern struct mchrstr mchr[MCHR_SZ];
enum {
SHP_AIROPS_EFF = 50, /* min. efficiency for air ops */
enum {
SHP_AIROPS_EFF = 50, /* min. efficiency for air ops */
* Table of item types
* Initialized on startup from item.config and deity custom config (if any).
*/
* Table of item types
* Initialized on startup from item.config and deity custom config (if any).
*/
-struct ichrstr ichr[I_MAX + 2];
+struct ichrstr ichr[ICHR_SZ];
* Initialized on startup from land.config and deity custom config (if any).
* Terminated by a sentinel with null l_name.
*/
* Initialized on startup from land.config and deity custom config (if any).
* Terminated by a sentinel with null l_name.
*/
-struct lchrstr lchr[LND_TYPE_MAX + 2];
+struct lchrstr lchr[LCHR_SZ];
#define logx(a, b) (log((a)) / log((b)))
#define LND_ATTDEF(b, t) (((b) * (1.0 + ((sqrt((t)) / 100.0) * 4.0))) \
#define logx(a, b) (log((a)) / log((b)))
#define LND_ATTDEF(b, t) (((b) * (1.0 + ((sqrt((t)) / 100.0) * 4.0))) \
* Table of nuke types
* Initialized on startup from nuke.config and deity custom config (if any).
*/
* Table of nuke types
* Initialized on startup from nuke.config and deity custom config (if any).
*/
-struct nchrstr nchr[N_MAXNUKE + 1];
+struct nchrstr nchr[NCHR_SZ];
* Initialized on startup from plane.config and deity custom config (if any).
* Terminated by a sentinel with null pl_name.
*/
* Initialized on startup from plane.config and deity custom config (if any).
* Terminated by a sentinel with null pl_name.
*/
-struct plchrstr plchr[PLN_TYPE_MAX + 2];
+struct plchrstr plchr[PLCHR_SZ];
#define logx(a, b) (log((a)) / log((b)))
#define PLN_ATTDEF(b, t) (b + ((b?1:0) * ((t/20)>10?10:(t/20))))
#define logx(a, b) (log((a)) / log((b)))
#define PLN_ATTDEF(b, t) (b + ((b?1:0) * ((t/20)>10?10:(t/20))))
* Table of product types
* Initialized on startup from product.config and deity custom config (if any).
*/
* Table of product types
* Initialized on startup from product.config and deity custom config (if any).
*/
-struct pchrstr pchr[P_MAX + 2];
+struct pchrstr pchr[PCHR_SZ];
* Initialized on startup from sect.config and deity custom config (if any).
* Terminated by a sentinel with null d_name.
*/
* Initialized on startup from sect.config and deity custom config (if any).
* Terminated by a sentinel with null d_name.
*/
-struct dchrstr dchr[SCT_TYPE_MAX + 2];
+struct dchrstr dchr[DCHR_SZ];
/*
* Table of infrastructure types
* Initialized on startup from infra.config and deity custom config (if any).
*/
/*
* Table of infrastructure types
* Initialized on startup from infra.config and deity custom config (if any).
*/
-struct sctintrins intrchr[INT_DEF + 2];
+struct sctintrins intrchr[INTRCHR_SZ];
* Initialized on startup from ship.config and deity custom config (if any).
* Terminated by a sentinel with null m_name.
*/
* Initialized on startup from ship.config and deity custom config (if any).
* Terminated by a sentinel with null m_name.
*/
-struct mchrstr mchr[SHP_TYPE_MAX + 2];
+struct mchrstr mchr[MCHR_SZ];
#define logx(a, b) (log((a)) / log((b)))
#define SHP_DEF(b, t) (t ? (b * (logx(t, 40.0) < 1.0 ? 1.0 : \
#define logx(a, b) (log((a)) / log((b)))
#define SHP_DEF(b, t) (t ? (b * (logx(t, 40.0) < 1.0 ? 1.0 : \