(xufooter, xubody): Rename some variables. No functional change.
This commit is contained in:
parent
9394ca0630
commit
4b2afc1e95
1 changed files with 20 additions and 20 deletions
|
@ -722,20 +722,20 @@ xufldhdr(FILE *fp, struct castr ca[])
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xufooter(FILE *fp, struct castr ca[], int row)
|
xufooter(FILE *fp, struct castr ca[], int recs)
|
||||||
{
|
{
|
||||||
int res, rows, i;
|
int res, n, i;
|
||||||
|
|
||||||
res = -1;
|
res = -1;
|
||||||
if (human) {
|
if (human) {
|
||||||
if (fscanf(fp, "config%n", &res) != 0 || res < 0)
|
if (fscanf(fp, "config%n", &res) != 0 || res < 0)
|
||||||
return gripe("Malformed table footer");
|
return gripe("Malformed table footer");
|
||||||
} else {
|
} else {
|
||||||
if (fscanf(fp, "%d", &rows) != 1)
|
if (fscanf(fp, "%d", &n) != 1)
|
||||||
return gripe("Malformed table footer");
|
return gripe("Malformed table footer");
|
||||||
if (row != rows)
|
if (recs != n)
|
||||||
return gripe("Read %d rows, which doesn't match footer "
|
return gripe("Read %d rows, which doesn't match footer "
|
||||||
"%d rows", row, rows);
|
"%d rows", recs, n);
|
||||||
}
|
}
|
||||||
if (skipfs(fp) != '\n')
|
if (skipfs(fp) != '\n')
|
||||||
return gripe("Junk after table footer");
|
return gripe("Junk after table footer");
|
||||||
|
@ -819,41 +819,41 @@ xubody(FILE *fp)
|
||||||
{
|
{
|
||||||
struct empfile *ep = &empfile[cur_type];
|
struct empfile *ep = &empfile[cur_type];
|
||||||
int need_sentinel = !EF_IS_GAME_STATE(cur_type);
|
int need_sentinel = !EF_IS_GAME_STATE(cur_type);
|
||||||
int row, n, ch;
|
int i, maxid, ch;
|
||||||
|
|
||||||
n = 0;
|
maxid = 0;
|
||||||
for (row = 0;; ++row) {
|
for (i = 0;; ++i) {
|
||||||
while ((ch = skipfs(fp)) == '\n')
|
while ((ch = skipfs(fp)) == '\n')
|
||||||
lineno++;
|
lineno++;
|
||||||
if (ch == '/')
|
if (ch == '/')
|
||||||
break;
|
break;
|
||||||
ungetc(ch, fp);
|
ungetc(ch, fp);
|
||||||
cur_obj = NULL;
|
cur_obj = NULL;
|
||||||
cur_id = row;
|
cur_id = i;
|
||||||
if (xuflds(fp, xufld) < 0)
|
if (xuflds(fp, xufld) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
n = MAX(n, cur_id + 1);
|
maxid = MAX(maxid, cur_id + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CANT_HAPPEN(n > ep->fids))
|
if (CANT_HAPPEN(maxid > ep->fids))
|
||||||
n = ep->fids;
|
maxid = ep->fids;
|
||||||
if (n < ep->fids) {
|
if (maxid < ep->fids) {
|
||||||
if (EF_IS_GAME_STATE(cur_type) && n != ep->csize)
|
if (EF_IS_GAME_STATE(cur_type) && maxid != ep->csize)
|
||||||
/* TODO truncate file */
|
/* TODO truncate file */
|
||||||
gripe("Warning: should resize table %s from %d to %d, not implemented",
|
gripe("Warning: should resize table %s from %d to %d, not implemented",
|
||||||
ef_nameof(cur_type), ep->csize, n);
|
ef_nameof(cur_type), ep->csize, maxid);
|
||||||
else if (cur_type >= EF_SHIP_CHR && cur_type <= EF_NUKE_CHR)
|
else if (cur_type >= EF_SHIP_CHR && cur_type <= EF_NUKE_CHR)
|
||||||
ep->cids = ep->fids = n;
|
ep->cids = ep->fids = maxid;
|
||||||
else
|
else
|
||||||
return gripe("Table %s requires %d rows, got %d",
|
return gripe("Table %s requires %d rows, got %d",
|
||||||
ef_nameof(cur_type), ep->fids, n);
|
ef_nameof(cur_type), ep->fids, maxid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_sentinel) {
|
if (need_sentinel) {
|
||||||
if (CANT_HAPPEN(n >= ep->csize))
|
if (CANT_HAPPEN(maxid >= ep->csize))
|
||||||
return gripe("No space for sentinel");
|
return gripe("No space for sentinel");
|
||||||
memset(ep->cache + ep->size * n, 0, ep->size);
|
memset(ep->cache + ep->size * maxid, 0, ep->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return row;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue