When the Ex memory regions are close to full, it is possible for
the game to fail to purge objects and then crash with an OOM error
even if it isn't actually out of memory. This patch calculates the
amount of free memory truly needed when allocating to Ex memory to
allow exactly the entire frame & text regions to be used, instead
previously where a hard-coded amount of free space to maintain was
used, which guaranteed that the entire memory region could not
actually be used by the game.
This change may be masking some underlying memory leak, or it may
just be that near the end of the game the game naturally comes
close to reaching the maximum memory region size. For the moment,
I am assuming the latter.
This commit also adds some assertion checks to the memory transfer
functions to make sure the regions don't quietly overflow in other
cases, since pickupConts performs transfers in a manner that
doesn't ensure enough free memory exists for them to be successful.
Fixes Trac#6820.
It could re-delete previously deleted objects, causing
ex data (frame/text) corruption. This is the likely cause of bug #3591088.
Asm conversion error from eaf87bdfa7ac279f736c03b25af94ac1df3b31ce.
This is partly for readability and partly to avoid any possible
portability issues i.e. though they should be the same, size_t is
defined by system headers, whereas uint is defined within our build
system.
Also, replaced a array size calculation with our ARRAYSIZE macro.
SetObject::name and DynObject::id are stored at the exact same offset,
and have the exact same meaning (see also objectMatches()). Now they
also have the same name, objId.
This has been done by an automated search/replace, culling unused
variables in the process. The remaining variables in data are all stored
in savegames.
This reverts commit 4c66f74b58e9a2c191f22a37f485047dd19be131.
These functions aren't ready to be moved yet till the remaining two are
finished, and they're so crossreferenced that the safest thing to do is
revert this commit and break it down to smaller chunks