/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2017, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
* nat.c: Nation subroutines
*
* Known contributors to this file:
- * Markus Armbruster, 2009-2011
+ * Markus Armbruster, 2009-2013
* Ron Koenderink, 2008-2009
*/
#include <config.h>
-#include <string.h>
#include <ctype.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include "file.h"
#include "nat.h"
-#include "optlist.h"
#include "prototypes.h"
-#include "tel.h"
-
-/*
- * Initialize NATP for country #CNUM in status STAT.
- * STAT must be STAT_UNUSED, STAT_NEW, STAT_VIS or STAT_GOD.
- * Also wipe realms and telegrams.
- */
-struct natstr *
-nat_reset(struct natstr *natp, natid cnum, enum nat_status stat)
-{
- struct realmstr newrealm;
- char buf[1024];
- int i;
-
- ef_blank(EF_NATION, cnum, natp);
- natp->nat_stat = stat;
- for (i = 0; i < MAXNOR; i++) {
- ef_blank(EF_REALM, i + cnum * MAXNOR, &newrealm);
- putrealm(&newrealm);
- }
- close(creat(mailbox(buf, cnum),
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP));
- /* FIXME natp->nat_ann = #annos */
- natp->nat_level[NAT_HLEV] = start_happiness;
- natp->nat_level[NAT_RLEV] = start_research;
- natp->nat_level[NAT_TLEV] = start_technology;
- natp->nat_level[NAT_ELEV] = start_education;
- for (i = 0; i < MAXNOC; i++)
- natp->nat_relate[i] = NEUTRAL;
- natp->nat_flags =
- NF_FLASH | NF_BEEP | NF_COASTWATCH | NF_SONAR | NF_TECHLISTS;
- return natp;
-}
int
check_nat_name(char *cname, natid cnum)
}
return 1;
}
+
+char *
+prnat(struct natstr *np)
+{
+ return prbuf("%s (#%d)", np->nat_cnam, np->nat_cnum);
+}
+
+char *
+prnatid(natid cnum)
+{
+ struct natstr *np = getnatp(cnum);
+
+ if (CANT_HAPPEN(!np))
+ return prbuf("%d (#%d)", cnum, cnum);
+ return prnat(np);
+}