diff --git a/src/asset/asset.c b/src/asset/asset.c index 69a7d75..a7a6358 100644 --- a/src/asset/asset.c +++ b/src/asset/asset.c @@ -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; } diff --git a/src/asset/asset.h b/src/asset/asset.h index 571a0fa..c5368ea 100644 --- a/src/asset/asset.h +++ b/src/asset/asset.h @@ -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) diff --git a/src/asset/assettype.h b/src/asset/assettype.h index a61759c..d1fd812 100644 --- a/src/asset/assettype.h +++ b/src/asset/assettype.h @@ -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;