
(boundstr, realmstr): Rename, new members ef_type, r_cnum, r_uid, r_realm, r_timestamp. (natstr): Remove member nat_b[]. (EF_REALM, realm_ca): New. (empfile): Add it. (ef_open_srv, ef_close_srv, main): Deal with new file. (getrealm, putrealm): New. (add, new, real, list_realm, sarg_getrange): Use them.
210 lines
7 KiB
C
210 lines
7 KiB
C
/*
|
|
* Empire - A multi-player, client/server Internet based war game.
|
|
* Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
|
|
* Ken Stevens, Steve McClure
|
|
*
|
|
* This program 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
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* 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
|
|
*
|
|
* ---
|
|
*
|
|
* See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
|
|
* related information and legal notices. It is expected that any future
|
|
* projects/authors will amend these files as needed.
|
|
*
|
|
* ---
|
|
*
|
|
* nat.h: Definitions for things having to do with nations
|
|
*
|
|
* Known contributors to this file:
|
|
* Thomas Ruschak
|
|
* Ken Stevens, 1995
|
|
* Steve McClure, 1998-2000
|
|
*/
|
|
|
|
#ifndef NAT_H
|
|
#define NAT_H
|
|
|
|
#include "sect.h"
|
|
|
|
#define MAXNOR 50 /* max # realms */
|
|
|
|
/* Nation status */
|
|
typedef enum {
|
|
/*
|
|
* Don't change order without checking inequality comparisons and
|
|
* array initializers!
|
|
*/
|
|
STAT_UNUSED, /* not in use */
|
|
STAT_NEW, /* just initialized */
|
|
STAT_VIS, /* visitor */
|
|
STAT_SANCT, /* still in sanctuary */
|
|
STAT_ACTIVE, /* active (sanctuary broken) */
|
|
STAT_GOD /* deity powers */
|
|
} nat_status;
|
|
|
|
enum { /* Priorities */
|
|
/* sector types are also priorities */
|
|
PRI_SMAINT = SCT_MAXDEF+1, /* ship maintenance */
|
|
PRI_PMAINT, /* plane maintenance */
|
|
PRI_LMAINT, /* land unit maintenance */
|
|
PRI_SBUILD, /* ship building */
|
|
PRI_PBUILD, /* plane building */
|
|
PRI_LBUILD, /* land building */
|
|
PRI_MAX = PRI_LBUILD
|
|
};
|
|
|
|
|
|
/*
|
|
* TODO
|
|
*
|
|
* One of (r_cnum, r_realm) and r_uid is redundant, provided MAXNOR is known.
|
|
*
|
|
* The only user of b_cnum and b_realm appears to be xdump.
|
|
* If we had working virtual selectors, we could remove b_cnum and b_realm.
|
|
*
|
|
*/
|
|
struct realmstr {
|
|
short ef_type;
|
|
natid r_cnum; /* country number */
|
|
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 */
|
|
};
|
|
|
|
struct natstr {
|
|
/* initial part must match struct genitem */
|
|
short ef_type;
|
|
natid nat_cnum; /* our country number */
|
|
/* end of part matching struct genitem */
|
|
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_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 */
|
|
s_char nat_dayno; /* day of the year mod 128 */
|
|
s_char nat_update; /* Want an update or not. */
|
|
u_char nat_missed; /* How many updates missed */
|
|
u_short nat_tgms; /* # of telegrams to be announced */
|
|
u_short nat_ann; /* # of annos pending */
|
|
u_short nat_minused; /* number of minutes used today */
|
|
short nat_btu; /* bureaucratic time units */
|
|
long nat_reserve; /* military reserves */
|
|
long nat_money; /* moola */
|
|
time_t nat_last_login; /* time of last login, 0 menas never */
|
|
time_t nat_last_logout; /* time of last logout, 0 means never */
|
|
time_t nat_newstim; /* date news last read */
|
|
time_t nat_annotim; /* date annos last read */
|
|
float nat_level[4]; /* technology, etc */
|
|
short nat_relate[MAXNOC];
|
|
unsigned char nat_contact[MAXNOC];
|
|
short nat_rejects[(MAXNOC + 3) / 4]; /* four bits for each country */
|
|
s_char nat_priorities[PRI_MAX+1]; /* budget priority */
|
|
long nat_flags; /* nation flags */
|
|
char nat_spare[15];
|
|
};
|
|
|
|
/* Update fields. */
|
|
#define WUPD_WANT bit(0)
|
|
|
|
/* 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
|
|
|
|
/* 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 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.
|
|
* These are only useful with option LOSE_CONTACT option, which
|
|
* implies option HIDDEN.
|
|
*/
|
|
/* Planes spotting and being spotted */
|
|
#define FOUND_FLY 3
|
|
/* Lookout */
|
|
#define FOUND_LOOK 5
|
|
/* Spies and ground combat */
|
|
#define FOUND_SPY 6
|
|
/* Communication */
|
|
#define FOUND_TELE 3
|
|
/* Coastwatch and skywatch */
|
|
#define FOUND_COAST 3
|
|
|
|
extern char *relates[];
|
|
|
|
/* procedures relating to nation stuff */
|
|
|
|
#define putnat(n) \
|
|
ef_write(EF_NATION, n->nat_cnum, n)
|
|
#define getnatp(n) \
|
|
(struct natstr *) ef_ptr(EF_NATION, (int)n)
|
|
|
|
#define putrealm(p) \
|
|
ef_write(EF_REALM, (int)(p)->r_uid, p)
|
|
#define getrealm(r, n, p) \
|
|
ef_read(EF_REALM, (int)(r + (n * MAXNOR)), p)
|
|
|
|
extern double tfact(natid cn, double mult);
|
|
extern double tfactfire(natid cn, double mult);
|
|
extern double techfact(int level, double mult);
|
|
|
|
extern char *cname(natid n);
|
|
extern char *relatename(struct natstr *np, natid other);
|
|
extern char *rejectname(struct natstr *np, natid other);
|
|
extern char *natstate(struct natstr *np);
|
|
extern int getrel(struct natstr *np, natid them);
|
|
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 putreject(struct natstr *np, natid them, int how, int what);
|
|
extern void putcontact(struct natstr *np, natid them, int contact);
|
|
extern void agecontact(struct natstr *np);
|
|
extern int influx(struct natstr *np);
|
|
|
|
/* 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_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 */
|
|
|
|
#endif
|