]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/xundump.c
Update copyright notice
[empserver] / src / lib / common / xundump.c
index 69914c3377e01b186707bc5177a356d98149fb4c..022c0ee227e9b6172af1c1b4e0968bc47b9f65ca 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@
  *  ---
  *
  *  xundump.c: Load back xdump output
- * 
+ *
  *  Known contributors to this file:
  *     Ron Koenderink, 2005
  *     Markus Armbruster, 2005-2008
@@ -482,17 +482,16 @@ static void *
 getobj(void)
 {
     struct empfile *ep = &empfile[cur_type];
-    int need_sentinel = !EF_IS_GAME_STATE(cur_type);
 
     if (!cur_obj) {
-       cur_obj_is_blank = cur_id >= ep->fids - !!need_sentinel;
+       cur_obj_is_blank = cur_id >= ep->fids;
        if (cur_obj_is_blank) {
-           if (ef_ensure_space(cur_type, cur_id + !!need_sentinel, 1))
+           if (ef_ensure_space(cur_type, cur_id, 1))
                cur_obj = ef_ptr(cur_type, cur_id);
            /* FIXME diagnose out of dynamic memory vs. static table full */
            if (!cur_obj)
                gripe("Can't put ID %d into table %s, it holds only 0..%d.",
-                     cur_id, ep->name, ep->fids - !!need_sentinel - 1);
+                     cur_id, ep->name, ep->fids - 1);
        } else
            cur_obj = ef_ptr(cur_type, cur_id);
     }
@@ -672,9 +671,7 @@ symval(struct castr *ca, int i)
 {
     int type = ca->ca_table;
 
-    if (ef_check(type) < 0)
-       return -1;
-    if (ef_cadef(type) == symbol_ca)
+    if (type != EF_BAD && ef_cadef(type) == symbol_ca)
        /* symbol table, value is in the table */
        return ((struct symbol *)ef_ptr(type, i))->value;
     /* value is the table index */
@@ -962,13 +959,8 @@ static int
 xubody(FILE *fp)
 {
     struct empfile *ep = &empfile[cur_type];
-    int need_sentinel = !EF_IS_GAME_STATE(cur_type);
-    int old_maxid = ep->fids;
     int i, maxid, ch;
 
-    if (old_maxid == 0 && need_sentinel)
-       ef_ensure_space(cur_type, 0, 1);
-
     maxid = 0;
     for (i = 0;; ++i) {
        while ((ch = skipfs(fp)) == '\n')
@@ -983,12 +975,6 @@ xubody(FILE *fp)
        maxid = MAX(maxid, cur_id + 1);
     }
 
-    if (maxid >= old_maxid && need_sentinel) {
-       /* appended a sentinel, strip it off */
-       ep->fids--;
-       ep->cids--;
-    }
-
     if (CANT_HAPPEN(maxid > ep->fids))
        maxid = ep->fids;
     if (maxid < ep->fids) {