]> git.pond.sub.org Git - empserver/commitdiff
config: Drop configuration table size macros
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 26 Dec 2020 05:30:24 +0000 (06:30 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 17 Jan 2021 20:24:28 +0000 (21:24 +0100)
Macros LND_TYPE_MAX, N_MAXNUKE, PLN_TYPE_MAX, P_MAX, SCT_TYPE_MAX,
SHP_TYPE_MAX are only used to size a single array each.  Eliminate.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
12 files changed:
include/land.h
include/nuke.h
include/plane.h
include/product.h
include/sect.h
include/ship.h
src/lib/global/land.c
src/lib/global/nuke.c
src/lib/global/plane.c
src/lib/global/product.c
src/lib/global/sect.c
src/lib/global/ship.c

index 04774240885d52aacc4e495a934f9c188f385c3d..ef0c05840629f01d7415d8c14a7ca5a6bd0d6828 100644 (file)
@@ -30,7 +30,7 @@
  *     Thomas Ruschak, 1992
  *     Ken Stevens, 1995
  *     Steve McClure, 1998
- *     Markus Armbruster, 2004-2016
+ *     Markus Armbruster, 2004-2020
  */
 
 #ifndef LAND_H
@@ -41,7 +41,6 @@
 #include "retreat.h"
 #include "types.h"
 
-#define LND_TYPE_MAX   30
 #define LAND_MINEFF    10
 #define LAND_MINFIREEFF 40     /* arty must be this effic to fire */
 
@@ -125,7 +124,7 @@ struct lchrstr {
 #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];
+extern struct lchrstr lchr[32];
 
 enum {
     LND_AIROPS_EFF = 50                /* min. efficiency for air ops */
index d338d385c8f209a7d1f98f69f30022a9b2a63292..d42a1293e2ba0a7c77e6648c235a8144ae33ec8e 100644 (file)
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Dave Pare, 1986
- *     Markus Armbruster, 2004-2016
+ *     Markus Armbruster, 2004-2020
  */
 
 #ifndef NUKE_H
@@ -38,7 +38,6 @@
 #include "item.h"
 #include "types.h"
 
-#define N_MAXNUKE      20
 #define MIN_DRNUKE_CONST       0.001
 
 struct nukstr {
@@ -83,7 +82,7 @@ struct nchrstr {
 #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];
+extern struct nchrstr nchr[21];
 
 /* src/lib/common/cargo.c */
 extern void nuk_carrier_change(struct nukstr *, int, int, int);
index bef45c2f510b524a550f6184f47cecff5878ca20..66af379f00f409611a7a4bbc4a7c275609c0c8b6 100644 (file)
@@ -30,7 +30,7 @@
  *     Dave Pare, 1986
  *     Ken Stevens, 1995
  *     Steve McClure, 1998
- *     Markus Armbruster, 2004-2016
+ *     Markus Armbruster, 2004-2020
  */
 
 #ifndef PLANE_H
@@ -41,7 +41,6 @@
 #include "queue.h"
 #include "types.h"
 
-#define PLN_TYPE_MAX   46
 #define PLANE_MINEFF   10
 
 struct plnstr {
@@ -135,7 +134,7 @@ struct plist {
 #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];
+extern struct plchrstr plchr[48];
 
 struct shiplist {
     int uid;
index 77e6c13bb1c950af21ff767c01173c322df0a5f4..b6c5a03815b7421403ade6fce5176f436b91d0fd 100644 (file)
@@ -57,8 +57,6 @@ struct pchrstr {
     char *p_sname;             /* short (7 char or less) name of product */
 };
 
-#define P_MAX 22
-
-extern struct pchrstr pchr[P_MAX + 2];
+extern struct pchrstr pchr[24];
 
 #endif
index aa60b58c037540984440ff9479bf60a719f4f6e7..28d30a4e24005e215670f11e234936b37e5289e8 100644 (file)
@@ -30,7 +30,7 @@
  *     Dave Pare
  *     Ken Stevens, 1995
  *     Steve McClure, 1998
- *     Markus Armbruster, 2004-2016
+ *     Markus Armbruster, 2004-2020
  */
 
 
@@ -160,14 +160,12 @@ struct dchrstr {
 #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)))
 
-extern struct dchrstr dchr[SCT_TYPE_MAX + 2];
+extern struct dchrstr dchr[40];
 #define IS_BIG_CITY(type) (dchr[(type)].d_pkg == UPKG)
 
 /* Minimal efficiency of sectors that can be knocked down (bridges) */
index bb0e67f9d6405bc36f23bd36340de5f28079b9f9..84aece94c06ba1e1afecfd8020cebf299346f469 100644 (file)
@@ -31,7 +31,7 @@
  *     Thomas Ruschak, 1992
  *     Ken Stevens, 1995
  *     Steve McClure, 1998
- *     Markus Armbruster, 2004-2016
+ *     Markus Armbruster, 2004-2020
  */
 
 #ifndef SHIP_H
@@ -42,7 +42,6 @@
 #include "retreat.h"
 #include "types.h"
 
-#define SHP_TYPE_MAX   46
 #define SHIP_MINEFF    20
 
 #define MAXSHPNAMLEN   24
@@ -127,7 +126,7 @@ struct mchrstr {
 #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];
+extern struct mchrstr mchr[48];
 
 enum {
     SHP_AIROPS_EFF = 50,       /* min. efficiency for air ops */
index dbefcf9c52bd81a3111134665035aead20ad6ce6..e4081d502ab20a9a8c6d5dcb4e18aa46513e5ad4 100644 (file)
@@ -43,7 +43,7 @@
  * 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[];
 
 #define logx(a, b) (log((a)) / log((b)))
 #define LND_ATTDEF(b, t) (((b) * (1.0 + ((sqrt((t)) / 100.0) * 4.0)))  \
index 4365c5cbc91610b64411a10ad2ab18cb1e5a025c..ff16142a7bfd974e46f137934e0ad1766899b058 100644 (file)
@@ -38,4 +38,4 @@
  * 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[];
index 51575e2840409173bc9ae6fa6050029e349b7daf..43b315800811b436add265ff838004f209f8303e 100644 (file)
@@ -45,7 +45,7 @@
  * 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[];
 
 #define logx(a, b) (log((a)) / log((b)))
 #define PLN_ATTDEF(b, t) (b + ((b?1:0) * ((t/20)>10?10:(t/20))))
index cd6d8b034c183efb04ccb213508019e4fe7165a8..2e28eea1496d5c09bbd7fe2e0490526cb9586156 100644 (file)
@@ -38,4 +38,4 @@
  * 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[];
index e19598431ee8b31f496543c0e2d35e592bde3a1c..0457cbdb60911987c19373d547b9b26b042ece54 100644 (file)
@@ -43,7 +43,7 @@
  * 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[];
 
 /*
  * Table of infrastructure types
index 110ecdb62580755e794b839649febb398cafa8ab..27a88d741bf047a9e6cc50ecc8bd0ab65fdccdd8 100644 (file)
@@ -45,7 +45,7 @@
  * 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[];
 
 #define logx(a, b) (log((a)) / log((b)))
 #define SHP_DEF(b, t) (t ? (b * (logx(t, 40.0) < 1.0 ? 1.0 : \