Use nat_reset() for POGO in files.c
Requires moving it from subs/natsub.c to common/nat.c.
This commit is contained in:
parent
5fd595a59a
commit
bb442abdcd
4 changed files with 47 additions and 49 deletions
|
@ -177,8 +177,8 @@ 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);
|
||||
|
||||
extern struct natstr *nat_reset(struct natstr *, natid, enum nat_status);
|
||||
|
||||
extern int check_nat_name(char *, natid);
|
||||
|
||||
extern int grant_btus(struct natstr *, int);
|
||||
|
|
|
@ -34,10 +34,16 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "file.h"
|
||||
#include "misc.h"
|
||||
#include "nat.h"
|
||||
#include "optlist.h"
|
||||
#include "sect.h"
|
||||
#include "tel.h"
|
||||
|
||||
char *relates[] = {
|
||||
/* must follow nation relation defines in nat.h */
|
||||
|
@ -178,3 +184,35 @@ influx(struct natstr *np)
|
|||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
|
|
@ -33,48 +33,10 @@
|
|||
|
||||
#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)
|
||||
|
|
|
@ -135,16 +135,6 @@ main(int argc, char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
ef_read(EF_NATION, 0, &nat);
|
||||
strcpy(nat.nat_cnam, "POGO");
|
||||
strcpy(nat.nat_pnam, "peter");
|
||||
nat.nat_stat = STAT_GOD;
|
||||
nat.nat_btu = 255;
|
||||
nat.nat_money = 123456789;
|
||||
nat.nat_flags =
|
||||
NF_FLASH | NF_BEEP | NF_COASTWATCH | NF_SONAR | NF_TECHLISTS;
|
||||
ef_write(EF_NATION, 0, &nat);
|
||||
printf("All praise to %s!\n", nat.nat_cnam);
|
||||
if (mkdir(teldir, S_IRWXU | S_IRWXG) < 0 && errno != EEXIST) {
|
||||
fprintf(stderr, "Can't make telegram directory %s (%s)\n",
|
||||
teldir, strerror(errno));
|
||||
|
@ -156,6 +146,14 @@ main(int argc, char *argv[])
|
|||
}
|
||||
close(creat(annfil, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP));
|
||||
|
||||
nat_reset(&nat, 0, STAT_GOD);
|
||||
strcpy(nat.nat_cnam, "POGO");
|
||||
strcpy(nat.nat_pnam, "peter");
|
||||
nat.nat_btu = 255;
|
||||
nat.nat_money = 123456789;
|
||||
putnat(&nat);
|
||||
printf("All praise to %s!\n", nat.nat_cnam);
|
||||
|
||||
for (i = 0; i < EF_MAX; i++) {
|
||||
if (!EF_IS_GAME_STATE(i))
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue