From 7d34832100cd6dd8a12ce4c5e3760d2dc30637fd Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 10 Sep 2004 18:41:58 +0000 Subject: [PATCH] (fldoff): Use offsetof() instead. Rest of struct.h is unused, remove. --- include/struct.h | 41 ----------------------------------------- src/lib/common/file.c | 1 - src/lib/global/nsc.c | 6 ++++-- 3 files changed, 4 insertions(+), 44 deletions(-) delete mode 100644 include/struct.h diff --git a/include/struct.h b/include/struct.h deleted file mode 100644 index f431564b..00000000 --- a/include/struct.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Empire - A multi-player, client/server Internet based war game. - * Copyright (C) 1986-2004, 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. - * - * --- - * - * struct.h: Used to access information relating to the fields of a structure. - * - * Known contributors to this file: - * - */ - -#ifndef _STRUCT_H_ -#define _STRUCT_H_ - -#define fldoff(str, fld) ((int)&(((struct str *)0)->fld)) -#define fldsiz(str, fld) (sizeof(((struct str *)0)->fld)) -#define strbase(str, ptr, fld) ((struct str *)((s_char *)(ptr)-fldoff(str, fld))) - -#endif /* _STRUCT_H_ */ diff --git a/src/lib/common/file.c b/src/lib/common/file.c index cd04db58..cbffe669 100644 --- a/src/lib/common/file.c +++ b/src/lib/common/file.c @@ -44,7 +44,6 @@ #include "nsc.h" #include "file.h" #include "match.h" -#include "struct.h" #include "common.h" #include "gen.h" diff --git a/src/lib/global/nsc.c b/src/lib/global/nsc.c index 251feb5e..ea23f1a6 100644 --- a/src/lib/global/nsc.c +++ b/src/lib/global/nsc.c @@ -32,7 +32,7 @@ * */ -#include +#include #include "misc.h" #include "var.h" #include "xy.h" @@ -52,6 +52,8 @@ #include "commodity.h" #include "lost.h" +#define fldoff(str, fld) offsetof(struct str, fld) + #define NSC_IELT(name, pfx, sfx, base, itype) \ {NSC_SHORT, 0, 0, ((base) + (itype)*sizeof(u_short)), \ sizeof(sfx) == 1 ? name : pfx sfx} @@ -84,9 +86,9 @@ struct castr sect_ca[] = { {NSC_UCHAR, NSC_EXTRA, 0, fldoff(sctstr, sct_terr), "terr0"}, {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_terr1), "terr1"}, {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_terr2), "terr2"}, + {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_terr3), "terr3"}, {NSC_XCOORD, 0, 0, fldoff(sctstr, sct_dist_x), "xdist"}, {NSC_YCOORD, 0, 0, fldoff(sctstr, sct_dist_y), "ydist"}, - {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_terr3), "terr3"}, {NSC_SHORT, 0, 0, fldoff(sctstr, sct_avail), "avail"}, {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_work), "work"}, {NSC_UCHAR, 0, 0, fldoff(sctstr, sct_coastal), "coastal"},