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:
parent
73bd5d6aa3
commit
58ed1d1b9e
3 changed files with 32 additions and 5 deletions
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
@ -931,3 +932,24 @@ ef_ensure_space(int type, int id, int count)
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return maximum ID acceptable for table TYPE.
|
||||
* Assuming infinite memory and disk space.
|
||||
*/
|
||||
int
|
||||
ef_id_limit(int type)
|
||||
{
|
||||
struct empfile *ep;
|
||||
|
||||
if (ef_check(type) < 0)
|
||||
return -1;
|
||||
ep = &empfile[type];
|
||||
if (ep->nent >= 0)
|
||||
return ep->nent - 1;
|
||||
if (ep->flags & EFF_MEM) {
|
||||
if (ep->flags & EFF_STATIC)
|
||||
return ep->csize - 1 - ((ep->flags & EFF_SENTINEL) != 0);
|
||||
}
|
||||
return INT_MAX;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue