Clean up how game state file sizes are checked

New struct empfile member nent replaces ef_open() parameter nelt.
Cleaner, because the expected size is a property of the file, not of
how it's used.  Also fixes empdump to check file sizes.

Complication: with EFF_CREATE, ef_open() creates an empty file, to be
extended to the correct size.  Callers passed nelt argument -1 along
with EFF_CREATE, to make ef_open() accept the empty file.  Can't do
the same for empfile member nent.  Instead, make ef_open() not check
the (zero) size then.

Replaces commit 5750107b, v4.3.15.
This commit is contained in:
Markus Armbruster 2011-05-01 14:18:24 +02:00
parent 516ab86a6e
commit 0fcd935999
7 changed files with 68 additions and 64 deletions

View file

@ -261,7 +261,7 @@ main(int argc, char *argv[])
fprintf(stderr, "Can't chdir to %s (%s)\n", gamedir, strerror(errno));
exit(EXIT_FAILURE);
}
if (!ef_open(EF_SECTOR, EFF_MEM | EFF_NOTIME, WORLD_SZ())) {
if (!ef_open(EF_SECTOR, EFF_MEM | EFF_NOTIME)) {
perror("ef_open");
exit(1);
}