From 539abbffb67b3342eac245df9f3598220f26eeaf Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Fri, 26 Mar 2010 21:17:56 +0000 Subject: [PATCH] Ignore case-sensitivity for cfile_init/close/size and PHYSFSX_openReadBuffered; Give error message if default sound file cannot be opened so user knows what's going on --- CHANGELOG.txt | 1 + include/cfile.h | 27 ++++++++++++++++++--------- include/physfsx.h | 6 ++++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 752793654..cc91d5735 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ D1X-Rebirth Changelog -------- main/endlevel.c, main/gameseq.c, main/mission.c, main/mission.h, main/titles.c, main/titles.h: In Endlevel sequence, re-align big explosion to draw in front of exit model, relative to viewer; Re-organized tex files for Briefings and Endings and created more general code to play them; Re-aligned Dravis' head main/automap.c, main/gamecntl.c, main/kconfig.c, main/net_ipx.c, main/net_udp.c, main/newmenu.c, main/scores.c: Make all windows except game and editor use EVENT_KEY_COMMAND, returning 1 if handled; pass NULL instead of userdata for the PCX filename, for newmenu_do1 +include/cfile.h, include/physfsx.h: Ignore case-sensitivity for cfile_init/close/size and PHYSFSX_openReadBuffered 20100324 -------- diff --git a/include/cfile.h b/include/cfile.h index 17d5bd20e..5bde3e620 100644 --- a/include/cfile.h +++ b/include/cfile.h @@ -53,16 +53,19 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. //Specify the name of the hogfile. Returns 1 if hogfile found & had files static inline int cfile_init(char *hogname, int add_to_end) { - char pathname[PATH_MAX]; + char hogname2[PATH_MAX], pathname[PATH_MAX]; - if (!PHYSFSX_getRealPath(hogname, pathname)) + snprintf(hogname2, strlen(hogname)+1, hogname); + PHYSFSEXT_locateCorrectCase(hogname2); + + if (!PHYSFSX_getRealPath(hogname2, pathname)) return 0; if (!PHYSFS_addToSearchPath(pathname, add_to_end)) { // try the 'Data' directory for old Mac Descent directories compatibility char std_path[PATH_MAX] = "Data/"; - strncat(std_path, hogname, PATH_MAX - 1 - strlen(std_path)); + strncat(std_path, hogname2, PATH_MAX - 1 - strlen(std_path)); std_path[PATH_MAX - 1] = 0; if (!PHYSFSX_getRealPath(std_path, pathname)) @@ -76,16 +79,19 @@ static inline int cfile_init(char *hogname, int add_to_end) static inline int cfile_close(char *hogname) { - char pathname[PATH_MAX]; + char hogname2[PATH_MAX], pathname[PATH_MAX]; - if (!PHYSFSX_getRealPath(hogname, pathname)) + snprintf(hogname2, strlen(hogname)+1, hogname); + PHYSFSEXT_locateCorrectCase(hogname2); + + if (!PHYSFSX_getRealPath(hogname2, pathname)) return 0; if (!PHYSFS_removeFromSearchPath(pathname)) { char std_path[PATH_MAX] = "Data/"; - strncat(std_path, hogname, PATH_MAX - 1 - strlen(std_path)); + strncat(std_path, hogname2, PATH_MAX - 1 - strlen(std_path)); std_path[PATH_MAX - 1] = 0; if (!PHYSFSX_getRealPath(std_path, pathname)) @@ -97,18 +103,21 @@ static inline int cfile_close(char *hogname) return 1; } - static inline int cfile_size(char *hogname) { PHYSFS_file *fp; + char hogname2[PATH_MAX]; int size; - fp = PHYSFS_openRead(hogname); + snprintf(hogname2, strlen(hogname)+1, hogname); + PHYSFSEXT_locateCorrectCase(hogname2); + + fp = PHYSFS_openRead(hogname2); if (fp == NULL) { char std_path[PATH_MAX] = "Data/"; - strncat(std_path, hogname, PATH_MAX - 1 - strlen(std_path)); + strncat(std_path, hogname2, PATH_MAX - 1 - strlen(std_path)); std_path[PATH_MAX - 1] = 0; if (!(fp = PHYSFS_openRead(std_path))) diff --git a/include/physfsx.h b/include/physfsx.h index 2d6c70f69..35515cbef 100644 --- a/include/physfsx.h +++ b/include/physfsx.h @@ -369,6 +369,7 @@ static inline PHYSFS_file *PHYSFSX_openReadBuffered(char *filename) { PHYSFS_file *fp; PHYSFS_uint64 bufSize; + char filename2[PATH_MAX]; if (filename[0] == '\x01') { @@ -376,9 +377,10 @@ static inline PHYSFS_file *PHYSFSX_openReadBuffered(char *filename) filename++; } - PHYSFSEXT_locateCorrectCase(filename); + snprintf(filename2, strlen(filename)+1, filename); + PHYSFSEXT_locateCorrectCase(filename2); - fp = PHYSFS_openRead(filename); + fp = PHYSFS_openRead(filename2); if (!fp) return NULL;