/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
*
* ---
*
- * xdump.c: Experimental extended dump
+ * xdump.c: Extended dump
*
* Known contributors to this file:
- * Markus Armbruster, 2004-2006
+ * Markus Armbruster, 2004-2007
*/
-#include <config.h>
-
-#include <stddef.h>
-#include "misc.h"
-#include "file.h"
-#include "match.h"
-#include "news.h"
-#include "nsc.h"
-#include "optlist.h"
-#include "version.h"
-#include "commands.h"
-
/*
* Dump everything under the sun
*
* - News item characteristics: rpt[]
* - News page headings: page_headings[]
* - Commands: player_coms[] (TODO)
+ * - Update schedule: update_time[] (not really static)
* - Configuration: configkeys[]
*
* Dynamic game data:
* - Market: EF_COMM
*/
-/* FIXME document dump format */
+/*
+ * See doc/xdump for motivation, syntax, semantics, and rationale.
+ * Make sure to keep it up-to-date!
+ */
+
/* TODO don't dump stuff that's useless due to options */
+#include <config.h>
+
+#include <ctype.h>
+#include <stddef.h>
+#include "commands.h"
+#include "empobj.h"
+#include "match.h"
+#include "news.h"
+#include "optlist.h"
+#include "treaty.h"
+#include "version.h"
+
/*
* Evaluate a attribute of an object into VAL, return VAL.
* TYPE is the attribute's type.
unsigned char *s, *e, *l;
switch (val->val_type) {
- case NSC_TYPEID:
case NSC_LONG:
pr("%s%ld", sep, val->val_as.lng);
break;
l = s + val->val_as.str.maxsz;
/* FIXME maxsz == INT_MAX ! */
for (;;) {
- for (e=s; e<l && *e != '"' && *e != '\\' && isgraph(*e); ++e) ;
+ for (e = s;
+ e < l && *e != '"' && *e != '\\' && isgraph(*e);
+ ++e)
+ ;
pr("%.*s", (int)(e-s), s);
if (e < l && *e)
pr("\\%03o", *e++);
pr("%snil", sep);
break;
default:
- CANT_HAPPEN("Bad VAL type");
+ CANT_REACH();
pr("0");
}
return " ";
static int
xdvisible(int type, void *p)
{
- struct genitem *gp = p;
+ struct empobj *gp = p;
struct trtstr *tp = p;
struct lonstr *lp = p;
struct natstr *natp;
switch (type) {
case EF_SECTOR:
+ case EF_REALM:
return gp->own == player->cnum || player->god;
case EF_SHIP:
case EF_PLANE:
case EF_LOST:
return gp->own != 0 && (gp->own == player->cnum || player->god);
case EF_NATION:
- if (gp->own == player->cnum || player->god)
- return 1;
- /* fall through */
- case EF_COUNTRY:
return ((struct natstr *)p)->nat_stat != STAT_UNUSED;
+ case EF_COUNTRY:
+ return gp->own == player->cnum;
case EF_NEWS:
return ((struct nwsstr *)p)->nws_vrb != 0
&& (!opt_HIDDEN || player->god); /* FIXME */
return player->god || tlev <= (int)(1.25 * natp->nat_level[NAT_TLEV]);
case EF_NUKE_CHR:
tlev = ((struct nchrstr *)p)->n_tech;
- if (opt_DRNUKE) {
+ if (drnuke_const > MIN_DRNUKE_CONST) {
natp = getnatp(player->cnum);
if (tlev > (int)((int)(1.25 * natp->nat_level[NAT_RLEV])
/ drnuke_const))
static int
xditem(int type, char *arg)
{
- int check_owner = !player->god && (ef_flags(type) & EFF_OWNER) != 0;
struct castr *ca;
struct nstr_item ni;
int n;
char buf[1024];
int type;
int meta = 0;
+ struct natstr *natp;
- if (!opt_GUINEA_PIGS) {
- pr("You are not a guinea pig!\n");
- return RET_FAIL;
- }
-
- p = getstarg(player->argp[1], "What? ", buf);
+ p = getstarg(player->argp[1], "Table name, or meta? ", buf);
if (p && strcmp(p, "meta") == 0) {
meta = 1;
- p = getstarg(player->argp[2], "What? ", buf);
+ p = getstarg(player->argp[2], "Table name? ", buf);
}
- if (!p)
+ if (!p || !*p)
return RET_SYN;
+ natp = getnatp(player->cnum);
type = isdigit(p[0]) ? atoi(p) : ef_byname(p);
if (type >= 0 && type < EF_MAX) {
if (meta)
return xdmeta(type);
- else
+ else if ((EF_IS_GAME_STATE(type) || EF_IS_VIEW(type))
+ && !(natp->nat_stat == STAT_ACTIVE || player->god)) {
+ pr("Access to table %s denied\n", ef_nameof(type));
+ return RET_FAIL;
+ } else
return xditem(type, player->argp[2]);
} else if (!strncmp(p, "ver", strlen(p))) {
return xdver(meta);