From c8bb4d9b87b5a53075129fc24a89bd35ceeebf81 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 19 Feb 2004 19:14:29 +0000 Subject: [PATCH] (effadv_list, effadv, rejects, rejectname, telnames, rea, numnames, tennames, numstr): Replace by static local variables in their only user. (relates): Move from global/misc.c to common/nat.c. (att_mode): Move from global/misc.c to subs/attsub.c. --- include/nat.h | 2 ++ src/lib/commands/rea.c | 5 ++- src/lib/common/nat.c | 28 +++++++++++++-- src/lib/gen/numstr.c | 18 ++++++++-- src/lib/global/Makefile | 8 ++--- src/lib/global/misc.c | 73 --------------------------------------- src/lib/global/numnames.c | 48 ------------------------- src/lib/subs/attsub.c | 8 +++-- 8 files changed, 56 insertions(+), 134 deletions(-) delete mode 100644 src/lib/global/misc.c delete mode 100644 src/lib/global/numnames.c diff --git a/include/nat.h b/include/nat.h index 6abba322..41fbfeaf 100644 --- a/include/nat.h +++ b/include/nat.h @@ -159,6 +159,8 @@ struct fixnat { int offset; }; +extern s_char *relates[]; + /* procedures relating to nation stuff */ #define putnat(n) \ diff --git a/src/lib/commands/rea.c b/src/lib/commands/rea.c index 9d980b6b..13edb81c 100644 --- a/src/lib/commands/rea.c +++ b/src/lib/commands/rea.c @@ -55,7 +55,10 @@ int rea(void) { - extern s_char *telnames[]; + static s_char *telnames[] = { + /* must follow TEL_ defines in tel.h */ + "Telegram", "Announcement", "BULLETIN", "Production Report" + }; register s_char *p; register s_char *mbox; s_char mbox_buf[256]; /* Maximum path length */ diff --git a/src/lib/common/nat.c b/src/lib/common/nat.c index df040243..48dce535 100644 --- a/src/lib/common/nat.c +++ b/src/lib/common/nat.c @@ -36,6 +36,12 @@ #include "file.h" #include "optlist.h" +s_char *relates[] = { + /* must follow nation relation defines in nat.h */ + "At War", "Sitzkrieg", "Mobilizing", "Hostile", "Neutral", "Friendly", + "Allied" +}; + s_char * cname(natid n) { @@ -49,15 +55,31 @@ cname(natid n) s_char * relatename(struct natstr *np, natid other) { - extern s_char *relates[]; - return relates[getrel(np, other)]; } s_char * rejectname(struct natstr *np, natid other) { - extern s_char *rejects[]; + s_char *rejects[] = { + /* must follow reject flags defined in nat.h */ + " YES YES YES YES", + " NO YES YES YES", + " YES NO YES YES", + " NO NO YES YES", + " YES YES NO YES", + " NO YES NO YES", + " YES NO NO YES", + " NO NO NO YES", + " YES YES YES NO ", + " NO YES YES NO ", + " YES NO YES NO ", + " NO NO YES NO ", + " YES YES NO NO ", + " NO YES NO NO ", + " YES NO NO NO ", + " NO NO NO NO " + }; return rejects[getrejects(other, np)]; } diff --git a/src/lib/gen/numstr.c b/src/lib/gen/numstr.c index eb234dcb..7a5f3053 100644 --- a/src/lib/gen/numstr.c +++ b/src/lib/gen/numstr.c @@ -38,8 +38,18 @@ s_char * numstr(s_char *buf, int n) { - extern s_char *numnames[]; - extern s_char *tennames[]; + static s_char *numnames[] = { + "zero", "one", "two", "three", "four", "five", "six", + "seven", "eight", "nine", "ten", "eleven", "twelve", + "thirteen", "fourteen", "fifteen", "sixteen", + "seventeen", "eighteen", "nineteen", + }; + static s_char *tennames[] = { + "", "", "twenty", "thirty", "forty", "fifty", + "sixty", "seventy", "eighty", "ninety", + "hundred", "hundred ten", "hundred twenty", + "hundred thirty", 0, + }; if (n > 100) { (void)strcpy(buf, "several"); @@ -62,7 +72,9 @@ numstr(s_char *buf, int n) s_char * effadv(int n) { - extern s_char *effadv_list[]; + static s_char *effadv_list[] = { + "minimally", "partially", "moderately", "completely", + }; if (n < 0) n = 0; diff --git a/src/lib/global/Makefile b/src/lib/global/Makefile index a886e838..f87f2292 100644 --- a/src/lib/global/Makefile +++ b/src/lib/global/Makefile @@ -35,12 +35,12 @@ include ../../make.defs LIB = $(SRCDIR)/lib/libglobal.a NTLIB = $(SRCDIR)\lib\libglobal.lib -OBJS = constants.o dir.o file.o init.o item.o land.o misc.o news.o nsc.o \ - nuke.o numnames.o options.o path.o plane.o product.o sect.o ship.o\ +OBJS = constants.o dir.o file.o init.o item.o land.o news.o nsc.o \ + nuke.o options.o path.o plane.o product.o sect.o ship.o\ treaty.o -NTOBJS = constants.obj dir.obj file.obj init.obj item.obj land.obj misc.obj \ - news.obj nsc.obj nuke.obj numnames.obj options.obj path.obj plane.obj \ +NTOBJS = constants.obj dir.obj file.obj init.obj item.obj land.obj \ + news.obj nsc.obj nuke.obj options.obj path.obj plane.obj \ product.obj sect.obj ship.obj treaty.obj all: $(LIB) diff --git a/src/lib/global/misc.c b/src/lib/global/misc.c deleted file mode 100644 index dbfc0a95..00000000 --- a/src/lib/global/misc.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Empire - A multi-player, client/server Internet based war game. - * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak, - * Ken Stevens, Steve McClure - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * --- - * - * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the - * related information and legal notices. It is expected that any future - * projects/authors will amend these files as needed. - * - * --- - * - * misc.c: Misc type description lists - * - * Known contributors to this file: - * - */ - -#include "misc.h" - -s_char *effadv_list[] = { - "minimally", "partially", "moderately", "completely", 0, -}; - -/* must follow nation relation defines in nat.h */ -s_char *relates[] = { - "At War", "Sitzkrieg", "Mobilizing", "Hostile", "Neutral", "Friendly", - "Allied" -}; - -/* must follow reject flags defined in nat.h */ -s_char *rejects[] = { - " YES YES YES YES", - " NO YES YES YES", - " YES NO YES YES", - " NO NO YES YES", - " YES YES NO YES", - " NO YES NO YES", - " YES NO NO YES", - " NO NO NO YES", - " YES YES YES NO ", - " NO YES YES NO ", - " YES NO YES NO ", - " NO NO YES NO ", - " YES YES NO NO ", - " NO YES NO NO ", - " YES NO NO NO ", - " NO NO NO NO " -}; - -/* must follow TEL_ defines in tel.h */ -s_char *telnames[] = { - "Telegram", "Announcement", "BULLETIN", "Production Report" -}; - -s_char *att_mode[] = { - "defend", "attack", "assault", "paradrop", "board", "lboard" -}; diff --git a/src/lib/global/numnames.c b/src/lib/global/numnames.c deleted file mode 100644 index c78d04e5..00000000 --- a/src/lib/global/numnames.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Empire - A multi-player, client/server Internet based war game. - * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak, - * Ken Stevens, Steve McClure - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * --- - * - * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the - * related information and legal notices. It is expected that any future - * projects/authors will amend these files as needed. - * - * --- - * - * numnames.c: Strings used to convert numbers to strings - * - * Known contributors to this file: - * - */ - -#include "misc.h" - -s_char *numnames[] = { - "zero", "one", "two", "three", "four", "five", "six", - "seven", "eight", "nine", "ten", "eleven", "twelve", - "thirteen", "fourteen", "fifteen", "sixteen", - "seventeen", "eighteen", "nineteen", -}; - -s_char *tennames[] = { - "", "", "twenty", "thirty", "forty", "fifty", - "sixty", "seventy", "eighty", "ninety", - "hundred", "hundred ten", "hundred twenty", - "hundred thirty", 0, -}; diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index a3865b66..ce7cd313 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -83,11 +83,15 @@ static void send_reacting_units_home(struct combat *def, static int take_def(int combat_mode, struct emp_qelem *list, struct combat *off, struct combat *def); -void att_move_in_off(int combat_mode, struct combat *off, - struct emp_qelem *olist, struct combat *def); static int get_land(int combat_mode, struct combat *def, int uid, struct llist *llp, int victim_land); +s_char *att_mode[] = { + /* must match combat types in combat.h */ + "defend", "attack", "assault", "paradrop", "board", "lboard" +}; + + /* * The principal object in this code is the "combat" object. A combat object * is either a sector or ship. There are