Per-map ART tiles: don't back up or restore reserved tiles.

This prevents a crash and maybe other badnesses when e.g. loading a map
with ART tiles, doing something that allocates a reserved tile (such as
looking into a viewscreen), then loading another map where the tilesiz*
of TILE_VIEWSCR is restored to 0.

git-svn-id: https://svn.eduke32.com/eduke32@4259 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-01-15 20:29:09 +00:00
parent 63464e3693
commit b79ee42553

View file

@ -9738,20 +9738,21 @@ static void E_RecalcPicSiz(void)
} }
#define RESTORE_MAPART_ARRAY(origar, bakar) do { \ #define RESTORE_MAPART_ARRAY(origar, bakar) do { \
Bmemcpy(origar, bakar, sizeof(origar)); \ EDUKE32_STATIC_ASSERT(sizeof(origar[0]) == sizeof(bakar[0])); \
Bmemcpy(origar, bakar, MAXUSERTILES*sizeof(origar[0])); \
DO_FREE_AND_NULL(bakar); \ DO_FREE_AND_NULL(bakar); \
} while (0) } while (0)
// Allocate per-map ART backup array and back up the original! // Allocate per-map ART backup array and back up the original!
#define ALLOC_MAPART_ARRAY(origar, bakar) do { \ #define ALLOC_MAPART_ARRAY(origar, bakar) do { \
bakar = Bmalloc(sizeof(origar)); \ bakar = Bmalloc(MAXUSERTILES*sizeof(origar[0])); \
if (bakar == NULL) \ if (bakar == NULL) \
{ \ { \
initprintf("OUT OF MEMORY allocating per-map ART backup arrays!\n"); \ initprintf("OUT OF MEMORY allocating per-map ART backup arrays!\n"); \
uninitengine(); \ uninitengine(); \
exit(12); \ exit(12); \
} \ } \
Bmemcpy(bakar, origar, sizeof(origar)); \ Bmemcpy(bakar, origar, MAXUSERTILES*sizeof(origar[0])); \
} while (0) } while (0)
void E_MapArt_Clear(void) void E_MapArt_Clear(void)