Make xdump code available for future use outside the server Move the bits useful there from src/lib/commands/xdump.c to new include/xdump.h and src/lib/common/xdump.c.
Use get_empobj() instead of get_empobjp() in unit_map() The get_FOOp() macros are generally avoided outside the update, because direct access to the sector cache needs synchronization to be safe. unit_map() didn't access the cache directly until it was converted from get_ship() & friends to get_empobjp() in commit fec9878c. Switching to get_empobj() reverts the change to direct access while keeping the simplification.
Fix put_empobj() for types other than units put_empobj() used struct empobj member uid, which is valid only for units. Existing users pass only units, fortunately. Fix by making it take type and uid parameters.
Make sector types signed get_empobj_chr() and emp_obj_chr_name() access struct sctstr member sct_type through struct empobj member type. This is technically non-portable, because the two differ in signedness. It was also undocumented. Fix by making sct_type signed. sct_newtype as well, for consistency. map_char() uses unsigned char for a sector type argument. Change that to int. Matches how this is done elsewhere.
Make xundump capable of extending tables Use ef_ensure_space() in getobj(). This also makes sure objects are properly initialized before undumping writes to them. Clean up how sentinels are appended: instead of keeping its slot reserved while undumping, keep it in the table, and strip it off when done.
Generalize ef_extend() to non-file-backed tables ef_extend() extended the file bypassing the cache, which screws up the cache if it's EFF_MEM. It fixed that by closing and reopening the table. Cheesy, and worked only for file-backed tables. Rewrite ef_extend() to remap the cache properly for EFF_MEM. While there, simplify the !EFF_MEM case: steal a cache slot instead of allocating a buffer. Factor cache mapping out of ef_open() and ef_extend() into new ef_remap_cache().
Replace EFF_RDONLY by EFF_PRIVATE Read-only was a bit of a misnomer: you could write to the table by obtaining a pointer into it from ef_ptr(), you just couldn't write to the backing file. Semantic changes: * ef_flush() is now allowed when the table is file-backed or privately mapped. Before, it had to be file-backed. Flushing a privately mapped table does nothing, just like flushing a read-only table did. * ef_write() is now allowed when the table is file-backed or fully cached. Before, it had to be file-backed and not read-only. Writing to a privately mapped file-backed table doesn't write to the file. * ef_extend() is not implemented for privately mapped tables, just like it wasn't implemented for read-only tables.