engine: add checks to verify resource_t, customization_t and HPAK data structs sizes

This commit is contained in:
Alibek Omarov 2024-07-30 15:10:58 +03:00
parent 2f26fcdc2a
commit a7d63649f8
2 changed files with 12 additions and 0 deletions

View File

@ -76,6 +76,8 @@ typedef struct
int infotableofs; int infotableofs;
} hpak_header_t; } hpak_header_t;
STATIC_ASSERT( sizeof( hpak_header_t ) == 12, "invalid hpak_header_t size" );
typedef struct typedef struct
{ {
dresource_t resource; dresource_t resource;
@ -83,6 +85,8 @@ typedef struct
int disksize; int disksize;
} hpak_lump_t; } hpak_lump_t;
STATIC_ASSERT( sizeof( hpak_lump_t ) == 144, "invalid hpak_lump_t size" );
typedef struct typedef struct
{ {
int count; int count;

View File

@ -90,4 +90,12 @@ typedef struct customization_s
#define FCUST_WIPEDATA ( 1<<1 ) #define FCUST_WIPEDATA ( 1<<1 )
#define FCUST_IGNOREINIT ( 1<<2 ) #define FCUST_IGNOREINIT ( 1<<2 )
#if !XASH_64BIT
STATIC_ASSERT( sizeof( customization_t ) == 164, "invalid customization_t size, broken API" );
STATIC_ASSERT( sizeof( resource_t ) == 136, "invalid resource_t size, broken API" );
#else
STATIC_ASSERT( sizeof( customization_t ) == 192, "invalid customization_t size, broken API" );
STATIC_ASSERT( sizeof( resource_t ) == 144, "invalid resource_t size, broken API" );
#endif
#endif // CUSTOM_H #endif // CUSTOM_H