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++) {
const assettypedef_t *cmp = &ASSET_TYPE_DEFINITIONS[i];
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;
break;
}

View File

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

View File

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