/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
*
* Known contributors to this file:
* Ron Koenderink, 2005
- * Markus Armbruster, 2005
+ * Markus Armbruster, 2005-2006
*/
/*
#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include <ctype.h>
-#include <string.h>
#include <stdarg.h>
+#include <stdio.h>
#include <time.h>
-
#include "file.h"
#include "match.h"
#include "nsc.h"
#include "optlist.h"
#include "prototypes.h"
-static unsigned char initialized[EF_MAX];
static char *fname;
static int lineno;
static int human;
static int ellipsis, is_partial;
static int cur_type, cur_id;
static void *cur_obj;
+static int cur_obj_is_blank;
static int nflds;
static struct castr **fldca;
static int *fldidx;
struct castr *ca = ef_cadef(cur_type);
int i = fldca[fldno] - ca;
- return (initialized[cur_type] && (fldca[fldno]->ca_flags & NSC_CONST))
+ return (!cur_obj_is_blank && (fldca[fldno]->ca_flags & NSC_CONST))
|| caseen[i];
}
if (!cur_obj) {
if (ca->ca_table == cur_type)
cur_id = altid;
- if (cur_id >= ep->fids) {
+ cur_obj_is_blank = cur_id >= ep->fids;
+ if (cur_obj_is_blank) {
/* TODO grow cache (and posssibly file) unless EFF_STATIC */
if (cur_id < ep->csize - !!need_sentinel)
ep->cids = ep->fids = cur_id + 1;
ca = getfld(fldno, &idx);
if (!ca)
return -1;
- must_match = fldval_must_match(fldno);
memb_ptr = getobj(ca, cur_id);
if (!memb_ptr)
return -1;
memb_ptr += ca->ca_off;
+ must_match = fldval_must_match(fldno);
switch (ca->ca_type) {
case NSC_STRING:
len = ca->ca_len;
if (strlen(str) > len)
return gripe("Field %d takes at most %d characters",
- fldno + 1, len);
+ fldno + 1, (int)len);
old = memb_ptr;
if (!must_match)
strncpy(memb_ptr, str, len);
if (must_match) {
if (old && (!str || strncmp(old, str, len)))
return gripe("Value for field %d must be \"%.*s\"",
- fldno + 1, len, old);
+ fldno + 1, (int)len, old);
if (!old && str)
return gripe("Value for field %d must be nil", fldno + 1);
}
mtsymset(int fldno, long *set)
{
struct castr *ca;
- struct symbol *symtab;
ca = getfld(fldno, NULL);
if (!ca)
add2symset(int fldno, long *set, char *sym)
{
struct castr *ca;
- struct symbol *symtab;
int i;
ca = getfld(fldno, NULL);
lineno++;
ungetc(ch, fp);
- initialized[type] = 1;
return type;
}