]> git.pond.sub.org Git - empserver/blob - include/nsc.h
Remove some unused stuff, mostly Empire 3 leftovers.
[empserver] / include / nsc.h
1 /*
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
5  *
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.
10  *
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.
15  *
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
19  *
20  *  ---
21  *
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.
25  *
26  *  ---
27  *
28  *  nsc.h: Definitions for Empire conditionals
29  * 
30  *  Known contributors to this file:
31  *     Dave Pare, 1989
32  */
33
34 #ifndef _NSC_H_
35 #define _NSC_H_
36
37 #include "xy.h"
38
39 #define NS_LSIZE        128
40 #define NS_NCOND        16
41
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? */
46 };
47
48 struct nscstr {
49     long fld1;                  /* first commodity or number */
50     long fld2;                  /* second commodity or number */
51     int oper;                   /* required relationship operator */
52 };
53
54 struct nstr_sect {
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 */
66 };
67
68 struct nstr_item {
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 */
84 };
85
86 #define NS_UNDEF        0
87 #define NS_LIST         1
88 #define NS_DIST         2
89 #define NS_AREA         3
90 #define NS_ALL          4
91 #define NS_XY           5
92 #define NS_GROUP        6
93
94 /*
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
99  * V: value
100  *
101  * 2 2  1 1    1
102  * 2 0  8 6    2    8    4    0
103  * xxx xxxx xxxx xxxx xxxx xxxx
104  * DTT TTCC VVVV VVVV VVVV VVVV
105  */
106
107 /*
108  * categories
109  */
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)
114
115 /*
116  * how to interpret "offset" fields
117  */
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)
130
131 #define NSC_NATID       NSC_UCHAR /* must match natid */
132
133 #define NSC_MASK        (0xffff0000)
134
135 #define NSC_DEITY       (1<<22)
136
137 struct castr {
138     long ca_code;               /* encoded form */
139     s_char *ca_name;            /* name used for matches */
140     u_short ca_len;             /* Used for arrays */
141 };
142
143 /* variables using the above */
144
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 lost_ca[];
158 extern struct castr commodity_ca[];
159
160 /* src/lib/subs/nstr.c */
161 extern s_char *nstr_comp(struct nscstr *, int *, int, s_char *);
162 extern int encode(register s_char *, long *, int);
163
164
165 extern s_char *decodep(long, void *);
166 extern int decode(natid, long, void *, int);
167 extern int nstr_exec(struct nscstr *, register int, void *, int);
168
169 #endif /* _NSC_H_ */