]> git.pond.sub.org Git - empserver/blob - include/nat.h
Import of Empire 4.2.12
[empserver] / include / nat.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  *  nat.h: Definitions for things having to do with nations
29  * 
30  *  Known contributors to this file:
31  *     Thomas Rushack
32  *     Ken Stevens, 1995
33  *     Steve McClure, 1998-2000
34  */
35
36 #ifndef _NAT_H_
37 #define _NAT_H_
38
39 #include "mission.h"
40 #include "sect.h"
41
42 #define MAXNOR          50              /* max # realms */
43
44 struct  boundstr {
45         short   b_xl, b_xh;             /* horizontal bounds */
46         short   b_yl, b_yh;             /* vertical bounds */
47 };
48
49 struct  natstr {
50         short   ef_type;        
51         s_char  nat_cnam[20];           /* country name */
52         s_char  nat_pnam[20];           /* representative */
53         s_char  nat_hostaddr[32];       /* host addr of last user */
54         s_char  nat_hostname[512];      /* hostname of last user */
55         s_char  nat_userid[32];         /* userid of last user */
56         coord   nat_xstart, nat_ystart; /* cap location at start */
57         coord   nat_xcap, nat_ycap;     /* cap location in abs coords */
58         coord   nat_xorg, nat_yorg;     /* origin location in abs coords */
59         natid   nat_cnum;               /* our country number */
60         s_char  nat_stat;               /* inuse, norm, god, abs */
61         s_char  nat_dayno;              /* day of the year mod 128 */
62         s_char  nat_connected;          /* connected or not? */
63         s_char  nat_update;             /* Want an update or not. */
64         u_char  nat_missed;             /* How many updates missed */
65         u_short nat_tgms;               /* # of telegrams to be announced */
66         u_short nat_ann;                /* # of annos pending */
67         u_short nat_minused;            /* number of minutes used today */
68         short   nat_btu;                /* bureaucratic time units */
69         long    nat_reserve;            /* military reserves */
70         long    nat_money;              /* moola */
71         time_t  nat_last_login;         /* time of last login */
72         time_t  nat_last_logout;        /* time of last logout */
73         time_t  nat_newstim;            /* date news last read */
74         time_t  nat_annotim;            /* date annos last read */
75         float   nat_level[4];           /* technology, etc */
76         struct  boundstr nat_b[MAXNOR]; /* realm bounds */
77         short   nat_relate[MAXNOC];
78         short   nat_contact[MAXNOC];    /* short for everyone */
79         short   nat_rejects[(MAXNOC+3)/4];      /* four bits for each country */
80         s_char  nat_priorities[SCT_MAXDEF+8];   /* priority for each SCT_MAXDEF+8*/
81         long    nat_flags;              /* nation flags */
82         s_char  nat_mission_trigger[MI_MAX]; /* not used -- relation to trig */
83 };
84
85         /* Priorities */
86 #define PRI_SMAINT      SCT_MAXDEF+2
87 #define PRI_PMAINT      SCT_MAXDEF+3
88 #define PRI_LMAINT      SCT_MAXDEF+4
89 #define PRI_SBUILD      SCT_MAXDEF+5
90 #define PRI_PBUILD      SCT_MAXDEF+6
91 #define PRI_LBUILD      SCT_MAXDEF+7
92
93         /* nation status types */
94 #define STAT_INUSE      bit(0)          /* cnum in use */
95 #define STAT_SANCT      bit(1)          /* country in sanctuary */
96 #define STAT_NORM       bit(2)          /* normal country */
97 #define STAT_GOD        bit(3)          /* deity powers */
98 #define STAT_ABS        bit(4)          /* abs coords */
99 #define STAT_NEW        bit(5)          /* just initialized */
100
101         /* Update fields. */
102 #define WUPD_WANT       bit(0)
103
104         /* nstat values */
105 #define VIS             STAT_INUSE
106 #define NORM            (STAT_INUSE|STAT_NORM)
107 #define GOD             (STAT_INUSE|STAT_GOD)
108 #define SANCT           (STAT_INUSE|STAT_SANCT)
109 #define CAP             bit(6)
110 #define MONEY           bit(7)
111
112         /* nation relation codes */
113 #define AT_WAR          0
114 #define SITZKRIEG       1
115 #define MOBILIZATION    2
116 #define HOSTILE         3
117 #define NEUTRAL         4
118 #define FRIENDLY        5
119 #define ALLIED          6
120
121         /* nation reject codes */
122 #define REJ_TELE        bit(0)          /* dont allow telegrams to be sent */
123 #define REJ_TREA        bit(1)          /* dont allow treaties to be offered */
124 #define REJ_ANNO        bit(2)          /* don't receive announcements */
125 #define REJ_LOAN        bit(3)          /* don't allow loans to be offered */
126
127 #define NAT_TLEV        0
128 #define NAT_RLEV        1
129 #define NAT_ELEV        2
130 #define NAT_HLEV        3
131
132 #define NF_CHAR         1
133 #define NF_UCHAR        2
134 #define NF_SHORT        3
135 #define NF_LONG         4
136 #define NF_STRING       5
137 #define NF_FLOAT        6
138 #define NF_DOUBLE       7
139 #define NF_BOUND        8
140
141 #define NF_NOTIFY       1
142 #define NF_PRIVATE      2
143
144 #define NF_NATID        NF_UCHAR
145 #define NF_COORD        NF_SHORT
146
147 #define FOUND_FLY       3               /* Number of updates contact lasts */
148 #define FOUND_LOOK      5               /* These are only useful with the */
149 #define FOUND_SPY       6               /* LOSE_CONTACT option (and HIDDEN) */
150 #define FOUND_MAP       6
151 #define FOUND_TELE      3
152 #define FOUND_COAST     3
153
154 struct fixnat {
155         s_char *name;
156         int type;
157         int index;
158         int notify;
159         int offset;
160 };
161
162 /* procedures relating to nation stuff */
163
164 #define putnat(n) \
165         ef_write(EF_NATION, n->nat_cnum, (caddr_t)n)
166 #define getnatp(n) \
167         (struct natstr *) ef_ptr(EF_NATION, (int)n)
168
169 extern double tfact(natid cn, double mult);
170 extern double tfactfire(natid cn, double mult);
171 extern double techfact(int level, double mult);
172 extern double techfactfire(int level, double mult);
173 extern double reltech(int level1, int level2, double mult);
174 /* src/lib/subs/comsub.c */
175 extern double multread(natid  , natid );
176 extern int commread(void );
177 extern int commwrite(void );
178 extern int commlock(void );
179 extern int communlock(void );
180 extern int commamt(natid  , int  , float * );
181 extern void commset(natid  , int  , int );
182 extern void multset(natid  , float );
183 extern void commprice(int  , float * );
184
185 extern s_char *cname(natid n);
186 extern s_char *relatename(struct natstr *np, natid other);
187 extern s_char *rejectname(struct natstr *np, natid other);
188 extern s_char *natstate(struct natstr *np);
189 extern int     getrel(struct natstr *np, natid them);
190 extern int     getrejects(natid them, struct natstr *np);
191 extern int     getcontact(struct natstr *np, natid them);
192 extern void    putrel(struct natstr *np, natid them, int relate);
193 extern void    putreject(struct natstr *np, natid them, int how, int what);
194 extern void    putcontact(struct natstr *np, natid them, int contact);
195 extern void    agecontact(struct natstr *np);
196 extern  struct fixnat *natfield();
197
198 #define NF_INFORM       bit(0) /* Inform me of telegrams right away */
199 #define NF_FLASH        bit(1) /* Allow other players to flash me (sicko :) */
200 #define NF_BEEP         bit(2) /* Make beeping sounds when appropriate */
201 #define NF_COASTWATCH   bit(3) /* Turn auto-coastwatch on */
202 #define NF_SONAR        bit(4) /* Turn auto-sonar on */
203 #define NF_TECHLISTS    bit(5) /* Sort lists by tech not type */
204 #define NF_SACKED       bit(6) /* Capital was sacked, and hasn't been reset yet */
205
206 #endif /* _NAT_H_ */