mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
tr2/level: perform check on sprite texture count
This ensures we do not exceed the allocated sprite texture limit when reading a level. Resolves #2338.
This commit is contained in:
parent
7af0328236
commit
8b1392a4f6
5 changed files with 7 additions and 2 deletions
|
@ -19,6 +19,7 @@
|
|||
- fixed Lara never stepping backwards off a step using her right foot (#1602)
|
||||
- fixed blood spawning on Lara from gunshots using incorrect positioning data (#2253)
|
||||
- fixed ghost meshes appearing near statics in custom levels (#2310)
|
||||
- fixed potential memory corruption when reading a custom level with more than 512 sprite textures (#2338)
|
||||
- fixed Lara activating triggers one frame too early (#2205, regression from 0.7)
|
||||
- fixed savegame incompatibility with OG (#2271, regression from 0.8)
|
||||
- fixed stopwatch showing wrong UI in some circumstances (#2221, regression from 0.8)
|
||||
|
|
|
@ -344,6 +344,9 @@ static void M_LoadSprites(VFILE *const file)
|
|||
BENCHMARK *const benchmark = Benchmark_Start();
|
||||
const int32_t num_textures = VFile_ReadS32(file);
|
||||
LOG_DEBUG("sprite textures: %d", num_textures);
|
||||
if (num_textures > MAX_SPRITE_TEXTURES) {
|
||||
Shell_ExitSystem("Too many sprite textures in level");
|
||||
}
|
||||
for (int32_t i = 0; i < num_textures; i++) {
|
||||
SPRITE_TEXTURE *const sprite = &g_SpriteTextures[i];
|
||||
sprite->tex_page = VFile_ReadU16(file);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#define MAX_CD_TRACKS 64
|
||||
#define MAX_TEXTURE_PAGES 32
|
||||
#define MAX_OBJECT_TEXTURES 2048
|
||||
#define MAX_SPRITE_TEXTURES 512
|
||||
#define MAX_PALETTES 16
|
||||
#define MAX_ROOMS 1024
|
||||
#define MAX_ROOMS_TO_DRAW 100
|
||||
|
|
|
@ -29,7 +29,7 @@ bool g_GymInvOpenEnabled = true; // TODO: make me configurable
|
|||
int32_t g_MidSort = 0;
|
||||
GOURAUD_ENTRY g_GouraudTable[256];
|
||||
int32_t g_PhdWinTop;
|
||||
SPRITE_TEXTURE g_SpriteTextures[512];
|
||||
SPRITE_TEXTURE g_SpriteTextures[MAX_SPRITE_TEXTURES];
|
||||
int32_t g_LsAdder;
|
||||
float g_FltWinBottom;
|
||||
float g_FltResZBuf;
|
||||
|
|
|
@ -27,7 +27,7 @@ extern bool g_GymInvOpenEnabled;
|
|||
extern int32_t g_MidSort;
|
||||
extern GOURAUD_ENTRY g_GouraudTable[256];
|
||||
extern int32_t g_PhdWinTop;
|
||||
extern SPRITE_TEXTURE g_SpriteTextures[];
|
||||
extern SPRITE_TEXTURE g_SpriteTextures[MAX_SPRITE_TEXTURES];
|
||||
extern int32_t g_LsAdder;
|
||||
extern float g_FltWinBottom;
|
||||
extern float g_FltResZBuf;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue