]> git.pond.sub.org Git - empserver/blob - include/nat.h
d1bae7eb65db7e919fe2e2ca1d47aebc5113baa4
[empserver] / include / nat.h
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2005, 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 "sect.h"
40
41 #define MAXNOR          50      /* max # realms */
42
43 enum {                          /* Priorities */
44     /* sector types are also priorities */
45     PRI_SMAINT = SCT_MAXDEF+1,  /* ship maintenance */
46     PRI_PMAINT,                 /* plane maintenance */
47     PRI_LMAINT,                 /* land unit maintenance */
48     PRI_SBUILD,                 /* ship building */
49     PRI_PBUILD,                 /* plane building */
50     PRI_LBUILD,                 /* land building */
51     PRI_MAX = PRI_LBUILD
52 };
53
54 struct boundstr {
55     short b_xl, b_xh;           /* horizontal bounds */
56     short b_yl, b_yh;           /* vertical bounds */
57 };
58
59 struct natstr {
60     /* initial part must match struct genitem */
61     short ef_type;
62     natid nat_cnum;             /* our country number */
63     /* end of part matching struct genitem */
64     s_char nat_stat;            /* inuse, norm, god, abs */
65     s_char nat_cnam[20];        /* country name */
66     s_char nat_pnam[20];        /* representative */
67     s_char nat_hostaddr[32];    /* host addr of last user */
68     s_char nat_hostname[512];   /* hostname of last user */
69     s_char nat_userid[32];      /* userid of last user */
70     coord nat_xstart, nat_ystart;       /* cap location at start */
71     coord nat_xcap, nat_ycap;   /* cap location in abs coords */
72     coord nat_xorg, nat_yorg;   /* origin location in abs coords */
73     s_char nat_dayno;           /* day of the year mod 128 */
74     s_char nat_connected;       /* connected or not? */
75     s_char nat_update;          /* Want an update or not. */
76     u_char nat_missed;          /* How many updates missed */
77     u_short nat_tgms;           /* # of telegrams to be announced */
78     u_short nat_ann;            /* # of annos pending */
79     u_short nat_minused;        /* number of minutes used today */
80     short nat_btu;              /* bureaucratic time units */
81     long nat_reserve;           /* military reserves */
82     long nat_money;             /* moola */
83     time_t nat_last_login;      /* time of last login */
84     time_t nat_last_logout;     /* time of last logout */
85     time_t nat_newstim;         /* date news last read */
86     time_t nat_annotim;         /* date annos last read */
87     float nat_level[4];         /* technology, etc */
88     struct boundstr nat_b[MAXNOR];      /* realm bounds */
89     short nat_relate[MAXNOC];
90     short nat_contact[MAXNOC];
91     short nat_rejects[(MAXNOC + 3) / 4]; /* four bits for each country */
92     s_char nat_priorities[PRI_MAX+1]; /* budget priority */
93     long nat_flags;             /* nation flags */
94     char nat_spare[15];
95 };
96
97         /* nation status types */
98 #define STAT_INUSE      bit(0)  /* cnum in use */
99 #define STAT_SANCT      bit(1)  /* country in sanctuary */
100 #define STAT_NORM       bit(2)  /* normal country */
101 #define STAT_GOD        bit(3)  /* deity powers */
102 #define STAT_ABS        bit(4)  /* abs coords */
103 #define STAT_NEW        bit(5)  /* just initialized */
104
105         /* Update fields. */
106 #define WUPD_WANT       bit(0)
107
108         /* nstat values */
109 #define VIS             STAT_INUSE
110 #define NORM            (STAT_INUSE|STAT_NORM)
111 #define GOD             (STAT_INUSE|STAT_GOD)
112 #define SANCT           (STAT_INUSE|STAT_SANCT)
113 #define CAP             bit(6)
114 #define MONEY           bit(7)
115
116         /* nation relation codes */
117 #define AT_WAR          0
118 #define SITZKRIEG       1
119 #define MOBILIZATION    2
120 #define HOSTILE         3
121 #define NEUTRAL         4
122 #define FRIENDLY        5
123 #define ALLIED          6
124
125         /* nation reject codes */
126 #define REJ_TELE        bit(0)  /* dont allow telegrams to be sent */
127 #define REJ_TREA        bit(1)  /* dont allow treaties to be offered */
128 #define REJ_ANNO        bit(2)  /* don't receive announcements */
129 #define REJ_LOAN        bit(3)  /* don't allow loans to be offered */
130
131 #define NAT_TLEV        0
132 #define NAT_RLEV        1
133 #define NAT_ELEV        2
134 #define NAT_HLEV        3
135
136 #define FOUND_FLY       3       /* Number of updates contact lasts */
137 #define FOUND_LOOK      5       /* These are only useful with the */
138 #define FOUND_SPY       6       /* LOSE_CONTACT option (and HIDDEN) */
139 #define FOUND_TELE      3
140 #define FOUND_COAST     3
141
142 extern s_char *relates[];
143
144 /* procedures relating to nation stuff */
145
146 #define putnat(n) \
147         ef_write(EF_NATION, n->nat_cnum, n)
148 #define getnatp(n) \
149         (struct natstr *) ef_ptr(EF_NATION, (int)n)
150
151 extern double tfact(natid cn, double mult);
152 extern double tfactfire(natid cn, double mult);
153 extern double techfact(int level, double mult);
154
155 extern s_char *cname(natid n);
156 extern s_char *relatename(struct natstr *np, natid other);
157 extern s_char *rejectname(struct natstr *np, natid other);
158 extern s_char *natstate(struct natstr *np);
159 extern int getrel(struct natstr *np, natid them);
160 extern int getrejects(natid them, struct natstr *np);
161 extern int getcontact(struct natstr *np, natid them);
162 extern void putrel(struct natstr *np, natid them, int relate);
163 extern void putreject(struct natstr *np, natid them, int how, int what);
164 extern void putcontact(struct natstr *np, natid them, int contact);
165 extern void agecontact(struct natstr *np);
166
167 /* nation flags */
168 #define NF_INFORM       bit(0)  /* Inform me of telegrams right away */
169 #define NF_FLASH        bit(1)  /* Allow other players to flash me (sicko :) */
170 #define NF_BEEP         bit(2)  /* Make beeping sounds when appropriate */
171 #define NF_COASTWATCH   bit(3)  /* Turn auto-coastwatch on */
172 #define NF_SONAR        bit(4)  /* Turn auto-sonar on */
173 #define NF_TECHLISTS    bit(5)  /* Sort lists by tech not type */
174 #define NF_SACKED       bit(6)  /* Capital was sacked, and hasn't been reset yet */
175
176 #endif /* _NAT_H_ */