]> git.pond.sub.org Git - empserver/blob - include/nsc.h
Delete dead code, fix indentation, spelling, obvious warning
[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 struct nscstr {
43     long fld1;                  /* first commodity or number */
44     long fld2;                  /* second commodity or number */
45     int oper;                   /* required relationship operator */
46 };
47
48 struct nstr_sect {
49     coord x, y;                 /* current x-y */
50     coord dx, dy;               /* accumlated x,y travel */
51     int id;                     /* return value of sctoff */
52     int type;                   /* type of query */
53     int curdist;                /* dist query: current range */
54     struct range range;         /* area of coverage */
55     int dist;                   /* dist query: range */
56     coord cx, cy;               /* dist query: center x-y */
57     int (*read)(int type, int id, caddr_t ptr); /* read function */
58     int ncond;                  /* # of selection conditions */
59     struct nscstr cond[NS_NCOND];       /* selection conditions */
60 };
61
62 struct nstr_item {
63     int cur;                    /* current item */
64     int sel;                    /* selection type */
65     int type;                   /* item type being selected */
66     int curdist;                /* if NS_DIST, current item's dist */
67     struct range range;         /* NS_AREA/NS_DIST: range selector */
68     int dist;                   /* NS_DIST: distance selector */
69     coord cx, cy;               /* NS_DIST: center x-y, NS_XY: xy */
70     int group;                  /* NS_GROUP: fleet/wing match */
71     int size;                   /* NS_LIST: size of list */
72     int index;                  /* NS_LIST: index */
73     int list[NS_LSIZE];         /* NS_LIST: item list */
74     int (*read)(int type, int id, caddr_t ptr); /* read function */
75     int flags;                  /* EFF_ flags */
76     int ncond;                  /* # of selection conditions */
77     struct nscstr cond[NS_NCOND];       /* selection conditions */
78 };
79
80 #define NS_UNDEF        0
81 #define NS_LIST         1
82 #define NS_DIST         2
83 #define NS_AREA         3
84 #define NS_ALL          4
85 #define NS_XY           5
86 #define NS_GROUP        6
87
88 /*
89  * looks something like this:
90  * D: only deity can query on this field
91  * R: round this value to the nearest 10 if not owner
92  * T: type of pointer.
93  * C: catagory of value.
94  * V: value.
95  *
96  * 22 2  1 1    1
97  * 32 0  8 6    2    8    4    0
98  * xxxx xxxx xxxx xxxx xxxx xxxx
99  * DRTT TTCC VVVV VVVV VVVV VVVV
100  */
101
102 /*
103  * catagories
104  */
105 #define NSC_VAL         (0)     /* normal number */
106 #define NSC_VAR         (1<<16) /* is a vtype */
107 #define NSC_OFF         (2<<16) /* is an offset */
108 #define NSC_CMASK       (3<<16)
109
110 /*
111  * how to interpret "offset" fields
112  */
113 #define NSC_CHAR        (1<<18) /* pointer to s_char */
114 #define NSC_UCHAR       (2<<18) /* pointer to uchar */
115 #define NSC_SHORT       (3<<18) /* pointer to short */
116 #define NSC_USHORT      (4<<18) /* pointer to unsigned short */
117 #define NSC_INT         (5<<18) /* pointer to int */
118 #define NSC_LONG        (6<<18) /* pointer to long */
119 #define NSC_XCOORD      (7<<18) /* pointer to coord that needs x conversion */
120 #define NSC_YCOORD      (8<<18) /* pointer to coord that needs y conversion */
121 #define NSC_FLOAT       (9<<18) /* pointer to float */
122 #define NSC_CHARP       (10<<18)        /* pointer to string pointer */
123 #define NSC_TIME        (11<<18)        /* pointer to time_t */
124 #define NSC_TMASK       (15<<18)
125
126 #define NSC_NATID       NSC_UCHAR       /* change if natid typedef changes */
127
128 #define NSC_MASK        (0xffff0000)
129
130 #define NSC_ROUND       (1<<22)
131 #define NSC_DEITY       (1<<23)
132
133 struct castr {
134     long ca_code;               /* encoded form */
135     s_char *ca_name;            /* name used for matches */
136     u_short ca_len;             /* Used for arrays */
137 };
138
139 /* variables using the above */
140
141 extern struct castr var_ca[];
142 extern struct castr sect_ca[];
143 extern struct castr ship_ca[];
144 extern struct castr plane_ca[];
145 extern struct castr land_ca[];
146 extern struct castr nuke_ca[];
147 extern struct castr news_ca[];
148 extern struct castr nat_ca[];
149 extern struct castr treaty_ca[];
150 extern struct castr trade_ca[];
151 extern struct castr loan_ca[];
152 extern struct castr genitem_ca[];
153 extern struct castr map_ca[];
154 extern struct castr lost_ca[];
155 extern struct castr commodity_ca[];
156
157 /* src/lib/subs/nstr.c */
158 extern s_char *nstr_comp(struct nscstr *, int *, int, s_char *);
159 extern int encode(register s_char *, long *, int);
160
161
162 extern s_char *decodep(long, void *);
163 extern int decode(natid, long, void *, int);
164 extern int nstr_exec(struct nscstr *, register int, void *, int);
165
166 #endif /* _NSC_H_ */