Fixed asset header compare incosistenty

This commit is contained in:
2025-11-09 10:24:45 -06:00
parent 5a3004f1d1
commit eff5fc3d9a
3 changed files with 15 additions and 2 deletions

View File

@@ -64,7 +64,17 @@ errorret_t assetLoad(const char_t *filename, void *output) {
for(uint_fast8_t i = 0; i < ASSET_TYPE_COUNT; i++) { for(uint_fast8_t i = 0; i < ASSET_TYPE_COUNT; i++) {
const assettypedef_t *cmp = &ASSET_TYPE_DEFINITIONS[i]; const assettypedef_t *cmp = &ASSET_TYPE_DEFINITIONS[i];
if(cmp->header == NULL) continue; if(cmp->header == NULL) continue;
if(strcmp(header.header, cmp->header) != 0) continue;
// strcmp didn't work because it's a fixed char_t[3] I think, or maybe
// because of the packed struct?
bool_t match = true;
for(size_t h = 0; h < ASSET_HEADER_SIZE; h++) {
if(header.header[h] == cmp->header[h]) continue;
match = false;
break;
}
if(!match) continue;
def = cmp; def = cmp;
break; break;
} }

View File

@@ -15,6 +15,7 @@
#endif #endif
#define ASSET_FILE "dusk.dsk" #define ASSET_FILE "dusk.dsk"
#define ASSET_HEADER_SIZE 3
static const char_t *ASSET_SEARCH_PATHS[] = { static const char_t *ASSET_SEARCH_PATHS[] = {
"%s/%s", "%s/%s",
@@ -28,7 +29,7 @@ static const char_t *ASSET_SEARCH_PATHS[] = {
#pragma pack(push, 1) #pragma pack(push, 1)
typedef struct { typedef struct {
char_t header[3]; char_t header[ASSET_HEADER_SIZE];
} assetheader_t; } assetheader_t;
#pragma pack(pop) #pragma pack(pop)

View File

@@ -13,9 +13,11 @@
typedef enum { typedef enum {
ASSET_TYPE_NULL, ASSET_TYPE_NULL,
ASSET_TYPE_PALETTE_IMAGE, ASSET_TYPE_PALETTE_IMAGE,
ASSET_TYPE_ALPHA_IMAGE, ASSET_TYPE_ALPHA_IMAGE,
ASSET_TYPE_LANGUAGE, ASSET_TYPE_LANGUAGE,
ASSET_TYPE_COUNT, ASSET_TYPE_COUNT,
} assettype_t; } assettype_t;