time_t nat_newstim; /* date news last read */
time_t nat_annotim; /* date annos last read */
float nat_level[4]; /* technology, etc */
- unsigned char nat_relate[MAXNOC];
+ unsigned char nat_relate[MAXNOC]; /* enum relations */
};
- /* nation relation codes */
-#define AT_WAR 0
-#define HOSTILE 1
-#define NEUTRAL 2
-#define FRIENDLY 3
-#define ALLIED 4
-
#define NAT_TLEV 0
#define NAT_RLEV 1
#define NAT_ELEV 2
#define NAT_HLEV 3
+/* Diplomatic relations */
+enum relations {
+ /*
+ * Don't change order without checking inequality comparisons and
+ * array initializers!
+ */
+ AT_WAR,
+ HOSTILE,
+ NEUTRAL,
+ FRIENDLY,
+ ALLIED
+};
+
/*
* Number of updates contact lasts for various ways of making contact.
* These are only useful with option LOSE_CONTACT, which implies
extern char *cname(natid n);
extern char *relatename(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 enum relations getrel(struct natstr *np, natid them);
+extern enum relations relations_with(natid, natid);
extern int nat_accepts(natid, natid, enum rej_comm);
extern int in_contact(natid, natid);
extern void agecontact(struct natstr *np);
extern int grant_btus(struct natstr *, int);
/* src/lib/subs/rej.c */
-extern void setrel(natid, natid, int);
+extern void setrel(natid, natid, enum relations);
extern void setcont(natid, natid, int);
extern void setrej(natid, natid, int, enum rej_comm);
struct emp_qelem *qp;
struct ulist *llp;
struct lndstr *lp;
- int rel;
+ enum relations rel;
pr("Trying to sneak on shore...\n");
decl(void)
{
struct natstr nat;
- int rel;
+ enum relations rel;
int who;
struct nstr_item ni;
char *p;
spy(void)
{
natid own;
- int relat;
+ enum relations relat;
coord x, y;
coord nx, ny;
int military;
static char *
player_relstr(natid them)
{
- int rel = relations_with(player->cnum, them);
+ enum relations rel = relations_with(player->cnum, them);
if (rel == ALLIED)
return "Allied";
#include "tel.h"
char *relates[] = {
- /* must follow nation relation defines in nat.h */
+ /* must match enum relations */
"At War", "Hostile", "Neutral", "Friendly", "Allied"
};
}
/* This returns the relations that np has with them */
-int
+enum relations
getrel(struct natstr *np, natid them)
{
return np->nat_relate[them];
* Return relations @us has with @them.
* Countries are considered allied to themselves.
*/
-int
+enum relations
relations_with(natid us, natid them)
{
return us == them ? ALLIED : getrel(getnatp(us), them);
static void ac_landflak(struct emp_qelem *, coord, coord);
static void ac_shipflak(struct emp_qelem *, coord, coord);
static void ac_fireflak(struct emp_qelem *, natid, int);
-static void getilists(struct emp_qelem *, unsigned char *, natid);
+static void getilists(struct emp_qelem *, enum relations[], natid);
static int do_evade(struct emp_qelem *, struct emp_qelem *);
void
int dir;
unsigned char gotships[MAXNOC];
unsigned char gotlands[MAXNOC];
- unsigned char rel[MAXNOC];
+ enum relations rel[MAXNOC];
int overfly[MAXNOC];
int flags;
struct emp_qelem ilist[MAXNOC];
* Get planes available for interception duties.
*/
static void
-getilists(struct emp_qelem *list, unsigned char *rel, natid intruder)
+getilists(struct emp_qelem *list, enum relations rel[], natid intruder)
{
natid cn;
struct plchrstr *pcp;
coord newx;
coord newy;
int move;
- int rel;
+ enum relations rel;
int oldown;
if (CANT_HAPPEN(QEMPTY(list)))
unit_interdict(coord x, coord y, natid victim, char *s, int hardtarget,
int mission)
{
- int cn, rel, newdam, osubs;
+ int cn, newdam, osubs;
+ enum relations rel;
int dam = -1;
unsigned char plane_act[MAXNOC], other_act[MAXNOC];
struct genlist mi[MAXNOC];
#include "update.h"
void
-setrel(natid us, natid them, int rel)
+setrel(natid us, natid them, enum relations rel)
{
struct natstr *mynp = getnatp(us);
- int oldrel;
+ enum relations oldrel;
char *whichway;
int n_up = 0;
int n_down = 0;