From 31e944af6443a5ad75f81faae482d78c1a55a564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Wed, 25 Oct 2023 18:52:07 +0200 Subject: [PATCH] ensure vfs_load() properly loads .hdr map --- engine/joint/v4k.h | 18 ++++++++++-------- engine/split/v4k_file.c | 18 ++++++++++-------- engine/v4k.c | 18 ++++++++++-------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 0903f8e..d81df12 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -337092,7 +337092,7 @@ char *file_id(const char *pathfile) { char *ext = strchr(base, '.'); if (ext) ext[0] = '\0'; // remove all extensions #else // extensionless for audio/images only (materials: diffuse.tga and diffuse.png will match) char *ext = strrchr(base, '.'); //if (ext) ext[0] = '\0'; // remove all extensions - if(ext) if( strstr(".jpg.png.bmp.tga.hdr"".", ext) || strstr(".ogg.mp3.wav.mod.xm.flac"".", ext) || strstr(".mp4.ogv.avi.mkv.wmv.mpg.mpeg"".", ext) ) { + if(ext) if( strstr(".jpg.png.bmp.tga"".", ext) || strstr(".ogg.mp3.wav.mod.xm.flac"".", ext) || strstr(".mp4.ogv.avi.mkv.wmv.mpg.mpeg"".", ext) ) { ext = strchr(base, '.'); ext[0] = '\0'; //strcpy(ext, "_xxx"); } @@ -337720,13 +337720,13 @@ char* vfs_load(const char *pathfile, int *size_out) { // @todo: fix leaks, vfs_u while( pathfile[0] == '.' && (pathfile[1] == '/' || pathfile[1] == '\\') ) pathfile += 2; // if (pathfile[0] == '/' || pathfile[1] == ':') return file_load(pathfile, size_out); // @fixme: handle current cooked /home/V4K or C:/V4K path cases within zipfiles -if( size_out ) *size_out = 0; -if( strend(pathfile, "/") ) return 0; // it's a dir -static __thread map(char*,int) misses = 0, *init = 0; if(!init) init = misses, map_init(misses, less_str, hash_str); -int *found = map_find_or_add_allocated_key(misses, STRDUP(pathfile), -1); // [-1]non-init,[false]could not cook,[true]cooked -if( found && *found == 0 ) { - return 0; -} + if( size_out ) *size_out = 0; + if( strend(pathfile, "/") ) return 0; // it's a dir + static __thread map(char*,int) misses = 0, *init = 0; if(!init) init = misses, map_init(misses, less_str, hash_str); + int *found = map_find_or_add_allocated_key(misses, STRDUP(pathfile), -1); // [-1]non-init,[false]could not cook,[true]cooked + if( found && *found == 0 ) { + return 0; + } //{ // exclude garbage from material names @@ -337751,6 +337751,8 @@ if( found && *found == 0 ) { } //} + // PRINTF("VFS: %s\n", pathfile); + int size = 0; void *ptr = 0; diff --git a/engine/split/v4k_file.c b/engine/split/v4k_file.c index 79f8630..d515ee6 100644 --- a/engine/split/v4k_file.c +++ b/engine/split/v4k_file.c @@ -161,7 +161,7 @@ char *file_id(const char *pathfile) { char *ext = strchr(base, '.'); if (ext) ext[0] = '\0'; // remove all extensions #else // extensionless for audio/images only (materials: diffuse.tga and diffuse.png will match) char *ext = strrchr(base, '.'); //if (ext) ext[0] = '\0'; // remove all extensions - if(ext) if( strstr(".jpg.png.bmp.tga.hdr"".", ext) || strstr(".ogg.mp3.wav.mod.xm.flac"".", ext) || strstr(".mp4.ogv.avi.mkv.wmv.mpg.mpeg"".", ext) ) { + if(ext) if( strstr(".jpg.png.bmp.tga"".", ext) || strstr(".ogg.mp3.wav.mod.xm.flac"".", ext) || strstr(".mp4.ogv.avi.mkv.wmv.mpg.mpeg"".", ext) ) { ext = strchr(base, '.'); ext[0] = '\0'; //strcpy(ext, "_xxx"); } @@ -789,13 +789,13 @@ char* vfs_load(const char *pathfile, int *size_out) { // @todo: fix leaks, vfs_u while( pathfile[0] == '.' && (pathfile[1] == '/' || pathfile[1] == '\\') ) pathfile += 2; // if (pathfile[0] == '/' || pathfile[1] == ':') return file_load(pathfile, size_out); // @fixme: handle current cooked /home/V4K or C:/V4K path cases within zipfiles -if( size_out ) *size_out = 0; -if( strend(pathfile, "/") ) return 0; // it's a dir -static __thread map(char*,int) misses = 0, *init = 0; if(!init) init = misses, map_init(misses, less_str, hash_str); -int *found = map_find_or_add_allocated_key(misses, STRDUP(pathfile), -1); // [-1]non-init,[false]could not cook,[true]cooked -if( found && *found == 0 ) { - return 0; -} + if( size_out ) *size_out = 0; + if( strend(pathfile, "/") ) return 0; // it's a dir + static __thread map(char*,int) misses = 0, *init = 0; if(!init) init = misses, map_init(misses, less_str, hash_str); + int *found = map_find_or_add_allocated_key(misses, STRDUP(pathfile), -1); // [-1]non-init,[false]could not cook,[true]cooked + if( found && *found == 0 ) { + return 0; + } //{ // exclude garbage from material names @@ -820,6 +820,8 @@ if( found && *found == 0 ) { } //} + // PRINTF("VFS: %s\n", pathfile); + int size = 0; void *ptr = 0; diff --git a/engine/v4k.c b/engine/v4k.c index f3fb7d3..cb57788 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -5143,7 +5143,7 @@ char *file_id(const char *pathfile) { char *ext = strchr(base, '.'); if (ext) ext[0] = '\0'; // remove all extensions #else // extensionless for audio/images only (materials: diffuse.tga and diffuse.png will match) char *ext = strrchr(base, '.'); //if (ext) ext[0] = '\0'; // remove all extensions - if(ext) if( strstr(".jpg.png.bmp.tga.hdr"".", ext) || strstr(".ogg.mp3.wav.mod.xm.flac"".", ext) || strstr(".mp4.ogv.avi.mkv.wmv.mpg.mpeg"".", ext) ) { + if(ext) if( strstr(".jpg.png.bmp.tga"".", ext) || strstr(".ogg.mp3.wav.mod.xm.flac"".", ext) || strstr(".mp4.ogv.avi.mkv.wmv.mpg.mpeg"".", ext) ) { ext = strchr(base, '.'); ext[0] = '\0'; //strcpy(ext, "_xxx"); } @@ -5771,13 +5771,13 @@ char* vfs_load(const char *pathfile, int *size_out) { // @todo: fix leaks, vfs_u while( pathfile[0] == '.' && (pathfile[1] == '/' || pathfile[1] == '\\') ) pathfile += 2; // if (pathfile[0] == '/' || pathfile[1] == ':') return file_load(pathfile, size_out); // @fixme: handle current cooked /home/V4K or C:/V4K path cases within zipfiles -if( size_out ) *size_out = 0; -if( strend(pathfile, "/") ) return 0; // it's a dir -static __thread map(char*,int) misses = 0, *init = 0; if(!init) init = misses, map_init(misses, less_str, hash_str); -int *found = map_find_or_add_allocated_key(misses, STRDUP(pathfile), -1); // [-1]non-init,[false]could not cook,[true]cooked -if( found && *found == 0 ) { - return 0; -} + if( size_out ) *size_out = 0; + if( strend(pathfile, "/") ) return 0; // it's a dir + static __thread map(char*,int) misses = 0, *init = 0; if(!init) init = misses, map_init(misses, less_str, hash_str); + int *found = map_find_or_add_allocated_key(misses, STRDUP(pathfile), -1); // [-1]non-init,[false]could not cook,[true]cooked + if( found && *found == 0 ) { + return 0; + } //{ // exclude garbage from material names @@ -5802,6 +5802,8 @@ if( found && *found == 0 ) { } //} + // PRINTF("VFS: %s\n", pathfile); + int size = 0; void *ptr = 0;