2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * nsc.h: Definitions for Empire conditionals
30 * Known contributors to this file:
42 enum { /* masks for struct nscstr member oper */
43 NSC_OPMASK = 0x0ff, /* operator */
44 NSC_ISNUM1 = 0x100, /* is left operand a number? */
45 NSC_ISNUM2 = 0x200 /* is right operand a number? */
49 long fld1; /* first commodity or number */
50 long fld2; /* second commodity or number */
51 int oper; /* required relationship operator */
55 coord x, y; /* current x-y */
56 coord dx, dy; /* accumlated x,y travel */
57 int id; /* return value of sctoff */
58 int type; /* type of query */
59 int curdist; /* dist query: current range */
60 struct range range; /* area of coverage */
61 int dist; /* dist query: range */
62 coord cx, cy; /* dist query: center x-y */
63 int (*read)(int type, int id, caddr_t ptr); /* read function */
64 int ncond; /* # of selection conditions */
65 struct nscstr cond[NS_NCOND]; /* selection conditions */
69 int cur; /* current item */
70 int sel; /* selection type */
71 int type; /* item type being selected */
72 int curdist; /* if NS_DIST, current item's dist */
73 struct range range; /* NS_AREA/NS_DIST: range selector */
74 int dist; /* NS_DIST: distance selector */
75 coord cx, cy; /* NS_DIST: center x-y, NS_XY: xy */
76 int group; /* NS_GROUP: fleet/wing match */
77 int size; /* NS_LIST: size of list */
78 int index; /* NS_LIST: index */
79 int list[NS_LSIZE]; /* NS_LIST: item list */
80 int (*read)(int type, int id, caddr_t ptr); /* read function */
81 int flags; /* EFF_ flags */
82 int ncond; /* # of selection conditions */
83 struct nscstr cond[NS_NCOND]; /* selection conditions */
95 * codes looks like this:
96 * D: is access restricted to deity?
97 * T: type of member addressed by offset, if category NSC_OFF
98 * C: category of value
103 * xxx xxxx xxxx xxxx xxxx xxxx
104 * DTT TTCC VVVV VVVV VVVV VVVV
110 #define NSC_VAL (0) /* value is plain number */
111 #define NSC_VAR (1<<16) /* value is a vtype */
112 #define NSC_OFF (2<<16) /* value is an offset */
113 #define NSC_CMASK (3<<16)
116 * how to interpret "offset" fields
118 #define NSC_CHAR (1<<18) /* offset of s_char member */
119 #define NSC_UCHAR (2<<18) /* offset of unsigned char member */
120 #define NSC_SHORT (3<<18) /* offset of short */
121 #define NSC_USHORT (4<<18) /* offset of unsigned short member */
122 #define NSC_INT (5<<18) /* offset of int member */
123 #define NSC_LONG (6<<18) /* offset of long member */
124 #define NSC_XCOORD (7<<18) /* offset of coord that needs x conversion */
125 #define NSC_YCOORD (8<<18) /* offset of coord that needs y conversion */
126 #define NSC_FLOAT (9<<18) /* offset of float member */
127 #define NSC_CHARP (10<<18) /* offset of char *member */
128 #define NSC_TIME (11<<18) /* offset of time_t member */
129 #define NSC_TMASK (15<<18)
131 #define NSC_NATID NSC_UCHAR /* must match natid */
133 #define NSC_MASK (0xffff0000)
135 #define NSC_DEITY (1<<22)
138 long ca_code; /* encoded form */
139 s_char *ca_name; /* name used for matches */
140 u_short ca_len; /* Used for arrays */
143 /* variables using the above */
145 extern struct castr var_ca[];
146 extern struct castr sect_ca[];
147 extern struct castr ship_ca[];
148 extern struct castr plane_ca[];
149 extern struct castr land_ca[];
150 extern struct castr nuke_ca[];
151 extern struct castr news_ca[];
152 extern struct castr nat_ca[];
153 extern struct castr treaty_ca[];
154 extern struct castr trade_ca[];
155 extern struct castr loan_ca[];
156 extern struct castr genitem_ca[];
157 extern struct castr map_ca[];
158 extern struct castr lost_ca[];
159 extern struct castr commodity_ca[];
161 /* src/lib/subs/nstr.c */
162 extern s_char *nstr_comp(struct nscstr *, int *, int, s_char *);
163 extern int encode(register s_char *, long *, int);
166 extern s_char *decodep(long, void *);
167 extern int decode(natid, long, void *, int);
168 extern int nstr_exec(struct nscstr *, register int, void *, int);