]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/xdump.c
Update copyright notice.
[empserver] / src / lib / commands / xdump.c
index 650d4a27e4b9c7c1b349289046119f333d64c5c2..9f35f6bc11f92742cc9aa78dee56c41df17ac6da 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -139,6 +139,7 @@ static struct castr mchr_ca[] = {
     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_speed), "speed"},
     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_visib), "visib"},
     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_vrnge), "vrnge"},
+    {NSC_INT, 0, 0, offsetof(struct mchrstr, m_frnge), "frnge"},
     {NSC_INT, 0, 0, offsetof(struct mchrstr, m_glim), "glim"},
     {NSC_UCHAR, 0, 0, offsetof(struct mchrstr, m_nxlight), "nxlight"},
     {NSC_UCHAR, 0, 0, offsetof(struct mchrstr, m_nchoppers), "nchoppers"},
@@ -270,7 +271,7 @@ chridx_by_name(char *name)
 }
 
 /*
- * Evaluate a attribute of an object into VAL.
+ * Evaluate a attribute of an object into VAL, return VAL.
  * TYPE is the attribute's type.
  * PTR points to the context object.
  * The attribute is stored there at offset OFF + IDX * S, where S is
@@ -292,7 +293,7 @@ xdeval(struct valstr *val, nsc_type type, void *ptr, ptrdiff_t off, int idx)
 static char *
 xdprval(struct valstr *val, char *sep)
 {
-    char *s, *e;
+    unsigned char *s, *e;
 
     switch (val->val_type) {
     case NSC_TYPEID:
@@ -303,11 +304,11 @@ xdprval(struct valstr *val, char *sep)
        pr("%s%g", sep, val->val_as.dbl);
        break;
     case NSC_STRING:
-       s = val->val_as.str;
+       s = (unsigned char *)val->val_as.str;
        if (s) {
            pr("%s\"", sep);
            while (*s) {
-               for (e = s; *e != '"' && *e != '\\' && isprint(*e); ++e) ;
+               for (e = s; *e != '"' && *e != '\\' && isgraph(*e); ++e) ;
                pr("%.*s", (int)(e-s), s);
                if (*e)
                    pr("\\%03o", *e++);
@@ -491,6 +492,36 @@ xdopt(void)
     return RET_OK;
 }
 
+static int
+xdver(void)
+{
+    struct keymatch *kp;
+    char *sep;
+    struct valstr val;
+
+    xdhdr1("version");
+
+    sep = "";
+    for (kp = configkeys; kp->km_key; ++kp) {
+       if (kp->km_type != NSC_NOTYPE && !(kp->km_flags & KM_INTERNAL)) {
+           pr("%s%s", sep, kp->km_key);
+           sep = " ";
+       }
+    }
+    pr("\n");
+    
+    sep = "";
+    for (kp = configkeys; kp->km_key; ++kp) {
+       if (kp->km_type != NSC_NOTYPE && !(kp->km_flags & KM_INTERNAL)) {
+           xdeval(&val, kp->km_type, kp->km_data, 0, 0);
+           sep = xdprval(&val, sep);
+       }
+    }
+    pr("\n");
+
+    return RET_OK;
+}
+
 /* Experimental extended dump command */
 int
 xdump(void)
@@ -510,6 +541,8 @@ xdump(void)
        return xdchr(chridx_by_name(player->argp[2]));
     } else if (!strncmp(p, "opt", strlen(p))) {
        return xdopt();
+    } else if (!strncmp(p, "ver", strlen(p))) {
+       return xdver();
     }
 
     return RET_SYN;