diff --git a/include/nat.h b/include/nat.h index 0d0dc192..e9b5c61d 100644 --- a/include/nat.h +++ b/include/nat.h @@ -114,7 +114,7 @@ struct natstr { 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_relate[MAXNOC]; unsigned char nat_contact[MAXNOC]; unsigned char nat_rejects[MAXNOC]; signed char nat_priorities[PRI_MAX+1]; /* budget priority */ diff --git a/include/nsc.h b/include/nsc.h index 7cf466a7..76f0f1ee 100644 --- a/include/nsc.h +++ b/include/nsc.h @@ -57,6 +57,8 @@ typedef enum { NSC_INT, /* int */ NSC_XCOORD, /* coord that needs x conversion */ NSC_YCOORD, /* coord that needs y conversion */ + NSC_HIDDEN, /* unsigned char in struct natstr that + may need hiding */ NSC_TIME, /* time_t */ NSC_FLOAT, /* float */ NSC_STRINGY, /* char[], zero-terminated string */ diff --git a/src/lib/common/xundump.c b/src/lib/common/xundump.c index 6cbed564..f748609f 100644 --- a/src/lib/common/xundump.c +++ b/src/lib/common/xundump.c @@ -447,6 +447,7 @@ setnum(int fldno, double dbl) ((signed char *)memb_ptr)[idx] = (signed char)dbl; break; case NSC_UCHAR: + case NSC_HIDDEN: old = ((unsigned char *)memb_ptr)[idx]; ((unsigned char *)memb_ptr)[idx] = (unsigned char)dbl; break; diff --git a/src/lib/global/nsc.c b/src/lib/global/nsc.c index f53cff35..ee730314 100644 --- a/src/lib/global/nsc.c +++ b/src/lib/global/nsc.c @@ -527,7 +527,7 @@ struct castr nat_ca[] = { EF_BAD}, {NSC_FLOAT, 0, 0, fldoff(natstr, nat_level[NAT_HLEV]), "happiness", EF_BAD}, - {NSC_SHORT, 0, MAXNOC, fldoff(natstr, nat_relate), "relations", + {NSC_HIDDEN, 0, MAXNOC, fldoff(natstr, nat_relate), "relations", EF_NATION_RELATIONS}, /* should show mortals whether there's contact (obvious from relations?) */ {NSC_UCHAR, NSC_DEITY, MAXNOC, fldoff(natstr, nat_contact), "contacts", diff --git a/src/lib/global/symbol.c b/src/lib/global/symbol.c index a150c8bf..eb982786 100644 --- a/src/lib/global/symbol.c +++ b/src/lib/global/symbol.c @@ -94,6 +94,7 @@ struct symbol meta_type[] = { {NSC_INT, "d"}, {NSC_XCOORD, "d"}, {NSC_YCOORD, "d"}, + {NSC_HIDDEN, "d"}, {NSC_TIME, "d"}, {NSC_FLOAT, "g"}, {NSC_STRINGY,"c"}, @@ -124,6 +125,7 @@ struct symbol nation_flags[] = { }; struct symbol nation_relations[] = { + {-1, "unknown"}, {AT_WAR, "at-war"}, {SITZKRIEG, "sitzkrieg"}, {MOBILIZATION, "mobilization"}, diff --git a/src/lib/subs/nstr.c b/src/lib/subs/nstr.c index 656398eb..463a2534 100644 --- a/src/lib/subs/nstr.c +++ b/src/lib/subs/nstr.c @@ -40,6 +40,7 @@ #include "file.h" #include "match.h" #include "nsc.h" +#include "optlist.h" #include "prototypes.h" static char *nstr_parse_val(char *, struct valstr *); @@ -500,6 +501,7 @@ nstr_promote(int valtype) case NSC_INT: case NSC_XCOORD: case NSC_YCOORD: + case NSC_HIDDEN: case NSC_TIME: valtype = NSC_LONG; break; @@ -562,9 +564,10 @@ nstr_coerce_val(struct valstr *val, nsc_type to, char *str) } if (val->val_cat == NSC_VAL) { - /* coord literals don't occur, conversion not implemented */ + /* unimplemented conversions; don't currently occur here */ CANT_HAPPEN(val->val_type == NSC_XCOORD - || val->val_type == NSC_YCOORD); + || val->val_type == NSC_YCOORD + || val->val_type == NSC_HIDDEN); val->val_type = to; } @@ -587,6 +590,7 @@ nstr_exec_val(struct valstr *val, natid cnum, void *ptr, nsc_type want) char *memb_ptr; nsc_type valtype; int idx; + struct natstr *natp; switch (val->val_cat) { default: @@ -625,6 +629,16 @@ nstr_exec_val(struct valstr *val, natid cnum, void *ptr, nsc_type want) case NSC_YCOORD: val->val_as.lng = yrel(getnatp(cnum), ((short *)memb_ptr)[idx]); break; + case NSC_HIDDEN: + val->val_as.lng = -1; + if (CANT_HAPPEN(((struct natstr *)ptr)->ef_type != EF_NATION)) + break; + natp = getnatp(cnum); + if (!opt_HIDDEN + || natp->nat_stat == STAT_GOD + || (getcontact(natp, idx) && getcontact(ptr, idx))) + val->val_as.lng = ((unsigned char *)memb_ptr)[idx]; + break; case NSC_FLOAT: val->val_as.dbl = ((float *)memb_ptr)[idx]; valtype = NSC_DOUBLE;