Fix empdump not to grow game state files with fixed size

empdump -i now complains about extra rows instead of silently growing
the file to a size the server will reject.  Affects tables sector,
nation, realms, game.

Bonus fix: better error message on I/O error or insufficient memory.
This commit is contained in:
Markus Armbruster 2011-05-03 07:53:37 +02:00
parent 73bd5d6aa3
commit 58ed1d1b9e
3 changed files with 32 additions and 5 deletions

View file

@ -487,16 +487,20 @@ static void *
getobj(void)
{
struct empfile *ep = &empfile[cur_type];
int max_id;
if (!cur_obj) {
cur_obj_is_blank = cur_id >= ep->fids;
if (cur_obj_is_blank) {
if (ef_ensure_space(cur_type, cur_id, 1))
max_id = ef_id_limit(cur_type);
if (cur_id > max_id)
gripe("Can't put ID %d into table %s, it holds only 0..%d",
cur_id, ep->name, max_id);
else if (!ef_ensure_space(cur_type, cur_id, 1))
gripe("Can't put ID %d into table %s",
cur_id, ep->name);
else
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 - 1);
} else
cur_obj = ef_ptr(cur_type, cur_id);
}