/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
- * Ken Stevens, Steve McClure
+ * Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Ken Stevens, Steve McClure, Markus Armbruster
*
- * This program is free software; you can redistribute it and/or modify
+ * Empire is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ---
*
* ---
*
* nat.h: Definitions for things having to do with nations
- *
+ *
* Known contributors to this file:
* Thomas Ruschak
* Ken Stevens, 1995
* Steve McClure, 1998-2000
+ * Ron Koenderink, 2005-2008
+ * Markus Armbruster, 2005-2011
*/
#ifndef NAT_H
#include <time.h>
#include "types.h"
-#define MAXNOR 50 /* max # realms */
+#define NATID_BAD 255
+
+#define MAXNOR 50 /* max # realms */
/* Nation status */
-typedef enum {
+enum nat_status {
/*
* Don't change order without checking inequality comparisons and
* array initializers!
STAT_SANCT, /* still in sanctuary */
STAT_ACTIVE, /* active (sanctuary broken) */
STAT_GOD /* deity powers */
-} nat_status;
+};
/*
*/
struct realmstr {
/* initial part must match struct empobj */
- short ef_type;
+ signed ef_type: 8;
+ unsigned r_seqno: 12;
+ unsigned r_generation: 12;
+ int r_uid; /* realm table index */
+ time_t r_timestamp; /* Last time this realm was touched */
natid r_cnum; /* country number */
/* end of part matching struct empobj */
- short r_uid; /* realm table index */
unsigned short r_realm; /* realm number */
- short r_xl, r_xh; /* horizontal bounds */
- short r_yl, r_yh; /* vertical bounds */
- time_t r_timestamp; /* Last time this realm was touched */
+ coord r_xl, r_xh; /* horizontal bounds */
+ coord r_yl, r_yh; /* vertical bounds */
};
struct natstr {
/* initial part must match struct empobj */
- short ef_type;
+ signed ef_type: 8;
+ unsigned nat_seqno: 12;
+ unsigned nat_generation: 12;
+ int nat_uid; /* equals nat_cnum */
+ time_t nat_timestamp;
natid nat_cnum; /* our country number */
/* end of part matching struct empobj */
- nat_status nat_stat;
+ enum nat_status nat_stat;
char nat_cnam[20]; /* country name */
char nat_pnam[20]; /* representative */
- char nat_hostaddr[32]; /* host addr of last user */
+ char nat_hostaddr[46]; /* host addr of last user */
char nat_hostname[512]; /* hostname of last user, may be empty */
char nat_userid[32]; /* userid of last user, may be empty */
coord nat_xcap, nat_ycap; /* cap location in abs coords */
coord nat_xorg, nat_yorg; /* origin location in abs coords */
- signed char nat_dayno; /* day of the year mod 128 */
signed char nat_update; /* Want an update or not. */
unsigned short nat_tgms; /* # of telegrams to be announced */
unsigned short nat_ann; /* # of annos pending */
- unsigned short nat_minused; /* number of minutes used today */
+ int nat_timeused; /* number of seconds used today */
short nat_btu; /* bureaucratic time units */
short nat_access; /* The tick when BTUs were last updated */
long nat_reserve; /* military reserves */
long nat_flags; /* nation flags */
};
- /* nstat values */
-#define VIS bit(0)
-#define SANCT (bit(1) | VIS)
-#define NORM (bit(2) | VIS)
-#define GOD (bit(3) | NORM | VIS)
-#define CAP bit(6)
-#define MONEY bit(7)
-
/* nation relation codes */
-#define AT_WAR 0
-#define SITZKRIEG 1
-#define MOBILIZATION 2
-#define HOSTILE 3
-#define NEUTRAL 4
-#define FRIENDLY 5
-#define ALLIED 6
+#define AT_WAR 0
+#define HOSTILE 1
+#define NEUTRAL 2
+#define FRIENDLY 3
+#define ALLIED 4
/* nation reject codes */
-#define REJ_TELE bit(0) /* dont allow telegrams to be sent */
-#define REJ_TREA bit(1) /* dont allow treaties to be offered */
-#define REJ_ANNO bit(2) /* don't receive announcements */
-#define REJ_LOAN bit(3) /* don't allow loans to be offered */
+#define REJ_TELE bit(0) /* dont allow telegrams to be sent */
+#define REJ_TREA bit(1) /* dont allow treaties to be offered */
+#define REJ_ANNO bit(2) /* don't receive announcements */
+#define REJ_LOAN bit(3) /* don't allow loans to be offered */
-#define NAT_TLEV 0
-#define NAT_RLEV 1
-#define NAT_ELEV 2
-#define NAT_HLEV 3
+#define NAT_TLEV 0
+#define NAT_RLEV 1
+#define NAT_ELEV 2
+#define NAT_HLEV 3
/*
* Number of updates contact lasts for various ways of making contact.
extern char *rejectname(struct natstr *np, natid other);
extern char *natstate(struct natstr *np);
extern int getrel(struct natstr *np, natid them);
+extern int relations_with(natid, natid);
extern int getrejects(natid them, struct natstr *np);
extern int getcontact(struct natstr *np, natid them);
extern void putrel(struct natstr *np, natid them, int relate);
extern void putcontact(struct natstr *np, natid them, int contact);
extern void agecontact(struct natstr *np);
extern int influx(struct natstr *np);
+extern struct natstr *nat_reset(struct natstr *, natid, char *, char *,
+ enum nat_status);
+
+extern int check_nat_name(char *, natid);
-extern int grant_btus(struct natstr *, int );
+extern int grant_btus(struct natstr *, int);
/* nation flags */
-#define NF_INFORM bit(0) /* Inform me of telegrams right away */
-#define NF_FLASH bit(1) /* Allow other players to flash me (sicko :) */
-#define NF_BEEP bit(2) /* Make beeping sounds when appropriate */
+#define NF_INFORM bit(0) /* Inform me of telegrams right away */
+#define NF_FLASH bit(1) /* Allow other players to flash me (sicko :) */
+#define NF_BEEP bit(2) /* Make beeping sounds when appropriate */
#define NF_COASTWATCH bit(3) /* Turn auto-coastwatch on */
#define NF_SONAR bit(4) /* Turn auto-sonar on */
-#define NF_TECHLISTS bit(5) /* Sort lists by tech not type */
-#define NF_SACKED bit(6) /* Capital was sacked, and hasn't been reset yet */
+#define NF_TECHLISTS bit(5) /* Sort lists by tech not type */
+#define NF_SACKED bit(6) /* Capital was sacked, and hasn't been reset yet */
#endif