From d2e0c8224b43c6bb3e987e44123ad37984bd4156 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 27 Feb 2004 20:13:28 +0000 Subject: [PATCH] Delete dead code, fix indentation, spelling, obvious warning avoidance, doc fixes. No functional changes. --- include/land.h | 2 +- include/misc.h | 4 ++-- include/nsc.h | 4 +--- include/plane.h | 2 +- include/ship.h | 2 +- src/lib/commands/setsect.c | 2 +- src/lib/commands/tele.c | 2 +- src/lib/commands/upgr.c | 6 +++--- src/lib/common/nstr_subs.c | 7 ++++--- src/lib/subs/bigmap.c | 4 ++-- src/lib/subs/nstr.c | 12 ++++++------ 11 files changed, 23 insertions(+), 24 deletions(-) diff --git a/include/land.h b/include/land.h index 47e6aafa1..f74a8e6c4 100644 --- a/include/land.h +++ b/include/land.h @@ -53,7 +53,7 @@ struct lndstr { short lnd_uid; /* unit id (land unit) */ coord lnd_x; /* x location in abs coords */ coord lnd_y; /* y location in abs coords */ - s_char lnd_type; /* ship type */ + s_char lnd_type; /* index in lchr[] */ s_char lnd_effic; /* 0% to 100% */ s_char lnd_mobil; /* mobility units made int for RS/6000 */ short lnd_sell; /* pointer to trade file */ diff --git a/include/misc.h b/include/misc.h index 0a407d860..ecdc5e13d 100644 --- a/include/misc.h +++ b/include/misc.h @@ -76,7 +76,7 @@ struct mob_acc_globals { #define RESOLVE_IPADDRESS /* resolve ip addresses into hostnames */ #endif -typedef u_char natid; /* also change NSC_NATID in nsc.h */ +typedef u_char natid; /* NSC_NATID must match this */ #if defined(__linux__ ) || defined(__osf__) #define POSIXSIGNALS 1 @@ -98,7 +98,7 @@ typedef char s_char; /* change to signed char for aix */ #else typedef signed char s_char; #endif /* !aix && !sgi */ -typedef short coord; /* also change NSC_COORD in nsc.h */ +typedef short coord; /* * watch it; your compiler might not like this. * If you think this is bogus, look at /usr/include/struct.h diff --git a/include/nsc.h b/include/nsc.h index d9301905a..a5253f391 100644 --- a/include/nsc.h +++ b/include/nsc.h @@ -115,7 +115,7 @@ struct nstr_item { #define NSC_SHORT (3<<18) /* pointer to short */ #define NSC_USHORT (4<<18) /* pointer to unsigned short */ #define NSC_INT (5<<18) /* pointer to int */ -#define NSC_LONG (6<<18) /* pointer to long */ +#define NSC_LONG (6<<18) /* pointer to long */ #define NSC_XCOORD (7<<18) /* pointer to coord that needs x conversion */ #define NSC_YCOORD (8<<18) /* pointer to coord that needs y conversion */ #define NSC_FLOAT (9<<18) /* pointer to float */ @@ -134,7 +134,6 @@ struct castr { long ca_code; /* encoded form */ s_char *ca_name; /* name used for matches */ u_short ca_len; /* Used for arrays */ - long ca_edv; /* which commands is this field visible to? */ }; /* variables using the above */ @@ -152,7 +151,6 @@ extern struct castr trade_ca[]; extern struct castr loan_ca[]; extern struct castr genitem_ca[]; extern struct castr map_ca[]; -extern struct castr bmp_ca[]; extern struct castr lost_ca[]; extern struct castr commodity_ca[]; diff --git a/include/plane.h b/include/plane.h index 7ad79013d..61a2be0dd 100644 --- a/include/plane.h +++ b/include/plane.h @@ -51,7 +51,7 @@ struct plnstr { short pln_uid; /* plane unit id */ coord pln_x; /* plane x-y */ coord pln_y; - s_char pln_type; /* fighter, bomber, etc */ + s_char pln_type; /* index in plchr[] */ s_char pln_effic; /* actually "training" */ s_char pln_mobil; /* plane mobility */ short pln_sell; /* index into trade file */ diff --git a/include/ship.h b/include/ship.h index 210b1538b..7987f6762 100644 --- a/include/ship.h +++ b/include/ship.h @@ -72,7 +72,7 @@ struct shpstr { 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; /* ship type */ + s_char shp_type; /* index in mchr[] */ s_char shp_effic; /* 0% to 100% */ s_char shp_mobil; /* mobility units */ short shp_sell; /* pointer to trade file */ diff --git a/src/lib/commands/setsect.c b/src/lib/commands/setsect.c index d8aa8aaa2..def55b024 100644 --- a/src/lib/commands/setsect.c +++ b/src/lib/commands/setsect.c @@ -360,7 +360,7 @@ resbenefit(natid who, int good) } } -extern void +void resnoise(struct sctstr *sptr, int public_amt, s_char *name, int old, int new) { diff --git a/src/lib/commands/tele.c b/src/lib/commands/tele.c index 2dba05ce1..0812b502b 100644 --- a/src/lib/commands/tele.c +++ b/src/lib/commands/tele.c @@ -62,7 +62,7 @@ tele(void) logerror("tele: typed_wu failed to #%d", to); } else if (*player->argp[0] == 'p') { if (getele("your Gracious Deity", buf) <= 0) { - pr("Prayor aborted\n"); + pr("Prayer aborted\n"); return RET_OK; } pr("\n"); diff --git a/src/lib/commands/upgr.c b/src/lib/commands/upgr.c index c767c5487..c84191392 100644 --- a/src/lib/commands/upgr.c +++ b/src/lib/commands/upgr.c @@ -70,10 +70,10 @@ upgr(void) case 'L': return lupgr(); default: - pr("Ships, land units or planes only!\n"); - return RET_SYN; + break; } - return RET_OK; + pr("Ships, land units or planes only!\n"); + return RET_SYN; } static int diff --git a/src/lib/common/nstr_subs.c b/src/lib/common/nstr_subs.c index 2ca2400d9..d88b61864 100644 --- a/src/lib/common/nstr_subs.c +++ b/src/lib/common/nstr_subs.c @@ -73,9 +73,10 @@ nstr_exec(struct nscstr *conds, register int ncond, void *ptr, int type) lhs = decode(player->cnum, nsc->fld1, ptr, type); op = oper; - if ((op == '<' && lhs >= rhs) || - (op == '=' && lhs != rhs) || - (op == '>' && lhs <= rhs) || (op == '#' && lhs == rhs)) + if ((op == '<' && lhs >= rhs) + || (op == '=' && lhs != rhs) + || (op == '>' && lhs <= rhs) + || (op == '#' && lhs == rhs)) return 0; } return 1; diff --git a/src/lib/subs/bigmap.c b/src/lib/subs/bigmap.c index 1e297e152..20ec874f4 100644 --- a/src/lib/subs/bigmap.c +++ b/src/lib/subs/bigmap.c @@ -43,8 +43,8 @@ * 2 = update only bmap with force */ -static int - do_map_set(natid cnum, s_char *map, coord x, coord y, s_char t, int force, int sync); +static int do_map_set(natid cnum, s_char *map, coord x, coord y, + s_char t, int force, int sync); int map_set(natid cnum, coord x, coord y, s_char t, int only_bmap) diff --git a/src/lib/subs/nstr.c b/src/lib/subs/nstr.c index 75eeb1a07..70a0bf84b 100644 --- a/src/lib/subs/nstr.c +++ b/src/lib/subs/nstr.c @@ -113,14 +113,15 @@ encode(register s_char *str, long int *val, int type) return 0; } if (isdigit(*str) || ((*str == '-') && isdigit(str[1]))) { -#ifdef BIT16ONLY - /* XXX silently truncate to 16 bit int */ - *val = atoi(str) & 0xffff; -#else *val = atoi(str); -#endif /* BIT16ONLY */ return 2; } + /* + * FIXME This accepts the first match found, even if there are + * more matches in other tables, i.e. it quietly accepts ambiguous + * matches (matches in multiple tables), and fails to prefer an + * exact match to partial match in an earlier table. + */ if ((i = typematch(str, type)) >= 0) { *val = i; return 1; @@ -148,7 +149,6 @@ encode(register s_char *str, long int *val, int type) if (i >= 0) { *val = var_ca[i].ca_code & ~NSC_ROUND; return legal_val(str, *val); - return 1; } if (i == M_NOTUNIQUE) { pr("%s -- ambiguous commodity selector\n", str); -- 2.43.0