(EF_COUNTRY, cou_ca): New.
(empfile): Add it. (xdvisible): Deal with it. (ef_open_srv, ef_close_srv): Set it up. (ef_init_view, ef_fina_view): New.
This commit is contained in:
parent
21e3c9d55e
commit
9eba732cc3
6 changed files with 44 additions and 6 deletions
|
@ -145,6 +145,9 @@ enum {
|
||||||
EF_PACKING,
|
EF_PACKING,
|
||||||
EF_RESOURCES,
|
EF_RESOURCES,
|
||||||
EF_NATION_STATUS,
|
EF_NATION_STATUS,
|
||||||
|
/* Views */
|
||||||
|
EF_COUNTRY,
|
||||||
|
/* Number of types: */
|
||||||
EF_MAX
|
EF_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -212,6 +212,7 @@ extern struct castr lost_ca[];
|
||||||
extern struct castr commodity_ca[];
|
extern struct castr commodity_ca[];
|
||||||
extern struct castr trade_ca[];
|
extern struct castr trade_ca[];
|
||||||
extern struct castr nat_ca[];
|
extern struct castr nat_ca[];
|
||||||
|
extern struct castr cou_ca[];
|
||||||
extern struct castr realm_ca[];
|
extern struct castr realm_ca[];
|
||||||
extern struct castr intrchr_ca[];
|
extern struct castr intrchr_ca[];
|
||||||
extern struct castr rpt_ca[];
|
extern struct castr rpt_ca[];
|
||||||
|
|
|
@ -204,8 +204,11 @@ xdvisible(int type, void *p)
|
||||||
case EF_LOST:
|
case EF_LOST:
|
||||||
return gp->own != 0 && (gp->own == player->cnum || player->god);
|
return gp->own != 0 && (gp->own == player->cnum || player->god);
|
||||||
case EF_NATION:
|
case EF_NATION:
|
||||||
return ((struct natstr *)p)->nat_stat != STAT_UNUSED
|
if (gp->own == player->cnum || player->god)
|
||||||
&& (gp->own == player->cnum || player->god);
|
return 1;
|
||||||
|
/* fall through */
|
||||||
|
case EF_COUNTRY:
|
||||||
|
return ((struct natstr *)p)->nat_stat != STAT_UNUSED;
|
||||||
case EF_NEWS:
|
case EF_NEWS:
|
||||||
return ((struct nwsstr *)p)->nws_vrb != 0
|
return ((struct nwsstr *)p)->nws_vrb != 0
|
||||||
&& (!opt_HIDDEN || player->god); /* FIXME */
|
&& (!opt_HIDDEN || player->god); /* FIXME */
|
||||||
|
|
|
@ -190,6 +190,9 @@ struct empfile empfile[] = {
|
||||||
{EF_NATION_STATUS, "nation-status", NULL, symbol_ca,
|
{EF_NATION_STATUS, "nation-status", NULL, symbol_ca,
|
||||||
PTR_CACHE(nation_status, EFF_CFG)},
|
PTR_CACHE(nation_status, EFF_CFG)},
|
||||||
|
|
||||||
|
/* Views */
|
||||||
|
{EF_COUNTRY, "country", NULL, cou_ca, UNMAPPED_CACHE(struct natstr, 0)},
|
||||||
|
|
||||||
/* Sentinel */
|
/* Sentinel */
|
||||||
{EF_BAD, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL},
|
{EF_BAD, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, -1, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
|
@ -400,7 +400,6 @@ struct castr nchr_ca[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct castr treaty_ca[] = {
|
struct castr treaty_ca[] = {
|
||||||
/* FIXME disclose only to cna, cnb */
|
|
||||||
{NSC_SHORT, 0, 0, fldoff(trtstr, trt_uid), "uid", EF_TREATY},
|
{NSC_SHORT, 0, 0, fldoff(trtstr, trt_uid), "uid", EF_TREATY},
|
||||||
{NSC_NATID, 0, 0, fldoff(trtstr, trt_cna), "cna", EF_NATION},
|
{NSC_NATID, 0, 0, fldoff(trtstr, trt_cna), "cna", EF_NATION},
|
||||||
{NSC_NATID, 0, 0, fldoff(trtstr, trt_cnb), "cnb", EF_NATION},
|
{NSC_NATID, 0, 0, fldoff(trtstr, trt_cnb), "cnb", EF_NATION},
|
||||||
|
@ -415,7 +414,6 @@ struct castr treaty_ca[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct castr loan_ca[] = {
|
struct castr loan_ca[] = {
|
||||||
/* FIXME disclose only to loaner, loanee and partially to all if signed */
|
|
||||||
{NSC_SHORT, 0, 0, fldoff(lonstr, l_uid), "uid", EF_LOAN},
|
{NSC_SHORT, 0, 0, fldoff(lonstr, l_uid), "uid", EF_LOAN},
|
||||||
{NSC_NATID, 0, 0, fldoff(lonstr, l_loner), "loaner", EF_NATION},
|
{NSC_NATID, 0, 0, fldoff(lonstr, l_loner), "loaner", EF_NATION},
|
||||||
{NSC_NATID, 0, 0, fldoff(lonstr, l_lonee), "loanee", EF_NATION},
|
{NSC_NATID, 0, 0, fldoff(lonstr, l_lonee), "loanee", EF_NATION},
|
||||||
|
@ -431,7 +429,6 @@ struct castr loan_ca[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct castr news_ca[] = {
|
struct castr news_ca[] = {
|
||||||
/* FIXME if HIDDEN disclose requires contact with actor and victim, and new */
|
|
||||||
{NSC_SHORT, 0, 0, fldoff(nwsstr, nws_uid), "uid", EF_NEWS},
|
{NSC_SHORT, 0, 0, fldoff(nwsstr, nws_uid), "uid", EF_NEWS},
|
||||||
{NSC_NATID, 0, 0, fldoff(nwsstr, nws_ano), "actor", EF_NATION},
|
{NSC_NATID, 0, 0, fldoff(nwsstr, nws_ano), "actor", EF_NATION},
|
||||||
{NSC_CHAR, 0, 0, fldoff(nwsstr, nws_vrb), "action", EF_NEWS_CHR},
|
{NSC_CHAR, 0, 0, fldoff(nwsstr, nws_vrb), "action", EF_NEWS_CHR},
|
||||||
|
@ -515,7 +512,6 @@ struct castr nat_ca[] = {
|
||||||
EF_BAD},
|
EF_BAD},
|
||||||
{NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_HLEV]), "happiness",
|
{NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_HLEV]), "happiness",
|
||||||
EF_BAD},
|
EF_BAD},
|
||||||
/* FIXME nat_b[] */
|
|
||||||
{NSC_SHORT, 0, MAXNOC, fldoff(natstr, nat_relate), "relations",
|
{NSC_SHORT, 0, MAXNOC, fldoff(natstr, nat_relate), "relations",
|
||||||
EF_NATION_RELATIONS},
|
EF_NATION_RELATIONS},
|
||||||
{NSC_UCHAR, NSC_DEITY, MAXNOC, fldoff(natstr, nat_contact), "contacts",
|
{NSC_UCHAR, NSC_DEITY, MAXNOC, fldoff(natstr, nat_contact), "contacts",
|
||||||
|
@ -526,6 +522,14 @@ struct castr nat_ca[] = {
|
||||||
{NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
|
{NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct castr cou_ca[] = {
|
||||||
|
{NSC_NATID, 0, 0, fldoff(natstr, nat_cnum), "cnum", EF_NATION},
|
||||||
|
{NSC_CHAR, 0, 0, fldoff(natstr, nat_stat), "stat",
|
||||||
|
EF_NATION_STATUS},
|
||||||
|
{NSC_STRINGY, 0, 20, fldoff(natstr, nat_cnam), "cname", EF_BAD},
|
||||||
|
{NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
|
||||||
|
};
|
||||||
|
|
||||||
struct castr realm_ca[] = {
|
struct castr realm_ca[] = {
|
||||||
{NSC_SHORT, 0, 0, fldoff(realmstr, r_uid), "uid", EF_REALM},
|
{NSC_SHORT, 0, 0, fldoff(realmstr, r_uid), "uid", EF_REALM},
|
||||||
{NSC_NATID, 0, 0, fldoff(realmstr, r_cnum), "cnum", EF_NATION},
|
{NSC_NATID, 0, 0, fldoff(realmstr, r_cnum), "cnum", EF_NATION},
|
||||||
|
|
|
@ -54,6 +54,8 @@ static struct fileinit fileinit[] = {
|
||||||
|
|
||||||
static void ef_open_srv(void);
|
static void ef_open_srv(void);
|
||||||
static void ef_close_srv(void);
|
static void ef_close_srv(void);
|
||||||
|
static int ef_init_view(int, int);
|
||||||
|
static void ef_fina_view(int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize empfile for full server operations.
|
* Initialize empfile for full server operations.
|
||||||
|
@ -107,6 +109,7 @@ ef_open_srv(void)
|
||||||
failed |= !ef_open(EF_COMM, 0);
|
failed |= !ef_open(EF_COMM, 0);
|
||||||
failed |= !ef_open(EF_LOST, 0);
|
failed |= !ef_open(EF_LOST, 0);
|
||||||
failed |= !ef_open(EF_REALM, EFF_MEM);
|
failed |= !ef_open(EF_REALM, EFF_MEM);
|
||||||
|
failed |= ef_init_view(EF_COUNTRY, EF_NATION);
|
||||||
if (failed) {
|
if (failed) {
|
||||||
logerror("Missing files, giving up");
|
logerror("Missing files, giving up");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -116,6 +119,7 @@ ef_open_srv(void)
|
||||||
static void
|
static void
|
||||||
ef_close_srv(void)
|
ef_close_srv(void)
|
||||||
{
|
{
|
||||||
|
ef_fina_view(EF_COUNTRY);
|
||||||
ef_close(EF_NATION);
|
ef_close(EF_NATION);
|
||||||
ef_close(EF_SECTOR);
|
ef_close(EF_SECTOR);
|
||||||
ef_close(EF_SHIP);
|
ef_close(EF_SHIP);
|
||||||
|
@ -133,3 +137,23 @@ ef_close_srv(void)
|
||||||
ef_close(EF_LOST);
|
ef_close(EF_LOST);
|
||||||
ef_close(EF_REALM);
|
ef_close(EF_REALM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
ef_init_view(int type, int base)
|
||||||
|
{
|
||||||
|
if (CANT_HAPPEN(!(empfile[base].flags & EFF_MEM)))
|
||||||
|
return -1;
|
||||||
|
empfile[type].cache = empfile[base].cache;
|
||||||
|
empfile[type].csize = empfile[base].csize;
|
||||||
|
empfile[type].flags |= EFF_MEM;
|
||||||
|
empfile[type].baseid = empfile[base].baseid;
|
||||||
|
empfile[type].cids = empfile[base].cids;
|
||||||
|
empfile[type].fids = empfile[base].fids;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ef_fina_view(int type)
|
||||||
|
{
|
||||||
|
empfile[type].cache = NULL;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue