/*
* Evaluate VAL.
* If VAL is symbolic, evaluate it into a promoted value type.
- * Use country CNUM's coordinate system and access control.
+ * Translate it for country CNUM (coordinate system and contact
+ * status), except when CNUM is NATID_BAD.
* PTR points to a context object of the type that was used to compile
* the value.
* Unless WANT is NSC_NOTYPE, coerce the value to promoted value type
char *memb_ptr;
enum nsc_type valtype;
int idx;
+ coord c;
struct natstr *natp;
if (CANT_HAPPEN(want != NSC_NOTYPE && !NSC_IS_PROMOTED(want)))
val->val_as.lng = ((long *)memb_ptr)[idx];
break;
case NSC_XCOORD:
- val->val_as.lng = xrel(getnatp(cnum), ((short *)memb_ptr)[idx]);
+ c = ((short *)memb_ptr)[idx];
+ if (cnum == NATID_BAD) {
+ /* FIXME use variant of xrel() that takes orig instead of nation */
+ if (c >= WORLD_X / 2)
+ c -= WORLD_X;
+ } else
+ c = xrel(getnatp(cnum), c);
+ val->val_as.lng = c;
break;
case NSC_YCOORD:
- val->val_as.lng = yrel(getnatp(cnum), ((short *)memb_ptr)[idx]);
+ c = ((short *)memb_ptr)[idx];
+ if (cnum == NATID_BAD) {
+ /* FIXME use variant of yrel() that takes orig instead of nation */
+ if (c >= WORLD_Y / 2)
+ c -= WORLD_Y;
+ } else
+ c = yrel(getnatp(cnum), c);
+ val->val_as.lng = c;
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];
+ if (!opt_HIDDEN && cnum != NATID_BAD) {
+ natp = getnatp(cnum);
+ if (natp->nat_stat != STAT_GOD
+ && !(getcontact(natp, idx) && getcontact(ptr, idx)))
+ break;
+ }
+ val->val_as.lng = ((unsigned char *)memb_ptr)[idx];
break;
case NSC_FLOAT:
val->val_as.dbl = ((float *)memb_ptr)[idx];
#include "xdump.h"
/*
- * Initialize XD to dump for country CNUM.
+ * Initialize XD.
+ * Translate dump for country CNUM, except when CNUM is NATID_BAD.
* If HUMAN, dump in human-readable format.
* Dump is to be delivered through callback PR.
* Return XD.
xdinit(struct xdstr *xd, natid cnum, int human, void (*pr)(char *fmt, ...))
{
xd->cnum = cnum;
- xd->divine = getnatp(cnum)->nat_stat == STAT_GOD;
+ xd->divine = cnum == NATID_BAD || getnatp(cnum)->nat_stat == STAT_GOD;
xd->human = human;
xd->pr = pr;
return xd;
#include <unistd.h>
#include "file.h"
#include "optlist.h"
+#include "nat.h"
#include "prototypes.h"
#include "version.h"
#include "xdump.h"
if (!ca)
return;
- xdinit(&xd, 0, human, printf_wrapper);
+ xdinit(&xd, NATID_BAD, human, printf_wrapper);
xdhdr(&xd, ef_nameof(type), 0);
xdcolhdr(&xd, ca);
for (i = 0; (p = ef_ptr(type, i)); i++) {