Detailed debug info, clear log

This commit is contained in:
JackCarterSmith 2020-09-10 16:29:34 +02:00
parent a536991daa
commit 82dddcb5dc
No known key found for this signature in database
GPG Key ID: B05F75E5934B1D7F
2 changed files with 21 additions and 16 deletions

View File

@ -26,7 +26,7 @@ HMT_FILE *parseHMTFile(FILE *hmt_src) {
// Read textures
fseek(hmt_src, _buff->texture_offset, SEEK_SET);
fread(&(_buff->texture_count), 4, 1, hmt_src);
printf("[INFO] Textures detected: %d\n\n", _buff->texture_count);
printf("[INFO] Textures detected: %d\n", _buff->texture_count);
if (_buff->texture_count > 0) {
_buff->textures_list = calloc(_buff->texture_count, sizeof(HMT_TEXTURE)); // Create a big list of textures entries
for (i=0; i<_buff->texture_count; i++) {
@ -48,7 +48,7 @@ int readMaterial(HMT_MATERIAL *mat, FILE *hmt_src) {
if (_options & 0x1) {
if (mat->zero != 0 || mat->hex_a != 0x0A) printf("\n Uncommon file detected!\n");
printf("Material type: %d\nTexture index: %d\n", mat->type_, mat->texture_index);
printf(" Material type: %d\n Texture index: %d\n\n", mat->type_, mat->texture_index); //TODO: To develop?!
}
return EXIT_SUCCESS;
@ -87,14 +87,16 @@ int readTexture(HMT_TEXTURE *tex, FILE *hmt_src) {
tex->image.height = tex->height;
if (_options & VERBOSE_ENABLED) {
printf("\n");
printf(" Texture name: %s\n", tex->name);
printf(" Size w: %ld h: %ld\n", tex->width, tex->height);
printf("Texture subtype: %d\n", tex->image.type_);
printf(" u0: %d u1: %d\n", u0, u1);
printf(" Texture type: %d\n", tex->image.type_);
printf(" Samplebits: %d\n", tex->image.sampleBits);
printf(" Palette entries: %d\n", tex->image.paletteEntries);
printf(" Transparent color (RGB): %X %X %X\n", tex->image.alpha_color._red, tex->image.alpha_color._green, tex->image.alpha_color._blue);
printf(" Palette offset: %d\n", tex->palette_offset);
printf(" Data offset: %d\n", tex->data_offset);
printf("Transparent color (RGB): %X %X %X\n", tex->image.alpha_color._red, tex->image.alpha_color._green, tex->image.alpha_color._blue);
printf("u0: %d u1: %d\n", u0, u1);
printf("\n");
}
if (tex->palette_offset > 0) {

View File

@ -53,12 +53,12 @@ int checkArgs(char *args[], int arg_nbr) {
return -1;
} else if (strcmp(args[i], "-v") == 0) {
_o |= VERBOSE_ENABLED;
printf("[INFO] Verbose enabled.\n");
printf("[OPTN] Verbose enabled.\n");
} else if (strcmp(args[i], "-no-subdir") == 0) {
_o &= ~OUTPUT_DIR;
printf("[INFO] Extract to current directory.\n");
printf("[OPTN] Extract to current directory.\n");
} else {
printf("[INFO] Unknown option: %s\n", args[i]);
printf("[ERR] Unknown option: %s\n", args[i]);
}
}
_o = (i << 8) | (_o & 0x00FF);
@ -86,11 +86,11 @@ HMT_FILE *extractDatasFromHMT(char *hmt_filename) {
_hmtFile = fopen(hmt_filename, "rb");
if (_hmtFile != NULL) {
printf("\n[INFO] - Parsing file: %s\n", hmt_filename);
printf("\n=============================================\n[INFO] - Parsing file: %s ...\n", hmt_filename);
hmt_fdatas = parseHMTFile(_hmtFile);
if (hmt_fdatas == NULL) printf("[ERR] Failed to parse datas from %s\n", hmt_filename);
} else {
printf("[ERR] Input file %s not found!\n", hmt_filename);
printf("\n[ERR] Input file %s not found!\n", hmt_filename);
}
fclose(_hmtFile);
@ -109,10 +109,13 @@ int exportTextures(HMT_FILE *hmt_f, char *filename) {
case 3:
case 4:
case 5:
if (saveToPNG(&(hmt_f->textures_list[i].image), hmt_f->textures_list[i].name, filename)) return EXIT_FAILURE;
if (saveToPNG(&(hmt_f->textures_list[i].image), hmt_f->textures_list[i].name, filename)) {
printf("[ERR] Failed saving image file: %s\n", hmt_f->textures_list[i].name);
return EXIT_FAILURE;
} else printf("[INFO] Saved image file: %s\n", hmt_f->textures_list[i].name);
break;
default:
printf("[INFO] Image type %d not currently supported!\n", hmt_f->textures_list[i].image.type_);
printf("[WARN] Can't export %s ! Image type %d not currently supported! (WIP)\n", hmt_f->textures_list[i].name, hmt_f->textures_list[i].image.type_);
}
}