From 735525758dd7cc5da0f347c1170c6dc8d8b0166f Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Mon, 8 Dec 2014 07:32:58 +0000 Subject: [PATCH] Refine the previous commit a bit. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4802 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/compat.h | 3 +- polymer/eduke32/build/include/osxbits.h | 4 +-- polymer/eduke32/build/src/compat.c | 15 ++-------- polymer/eduke32/build/src/osxbits.m | 20 ++++++------- polymer/eduke32/source/common.c | 38 ++++++++++++++++--------- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index 33e323f8d..ffcce6161 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -651,7 +651,7 @@ FORCE_INLINE uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7fff # define Bstrncpy strncpy # define Bstrcmp strcmp # define Bstrncmp strncmp -# if defined(_MSC_VER) +# if defined(_MSC_VER) # define Bstrcasecmp _stricmp # define Bstrncasecmp _strnicmp # elif defined(__QNX__) @@ -761,7 +761,6 @@ char *Bgetenv(const char *name); #endif char *Bgethomedir(void); -char *Bgetsupportdir(void); char *Bgetappdir(void); uint32_t Bgetsysmemsize(void); int32_t Bcorrectfilename(char *filename, int32_t removefn); diff --git a/polymer/eduke32/build/include/osxbits.h b/polymer/eduke32/build/include/osxbits.h index c4a25b5f9..8add4d686 100644 --- a/polymer/eduke32/build/include/osxbits.h +++ b/polymer/eduke32/build/include/osxbits.h @@ -10,9 +10,9 @@ int32_t osx_msgbox(const char *name, const char *msg); int32_t osx_ynbox(const char *name, const char *msg); char *osx_gethomedir(void); -char *osx_getsupportdir(void); +char *osx_getsupportdir(int32_t local); char *osx_getappdir(void); -char *osx_getapplicationsdir(void); +char *osx_getapplicationsdir(int32_t local); #ifdef __cplusplus } diff --git a/polymer/eduke32/build/src/compat.c b/polymer/eduke32/build/src/compat.c index 4a9c61c6c..8d5639620 100644 --- a/polymer/eduke32/build/src/compat.c +++ b/polymer/eduke32/build/src/compat.c @@ -419,22 +419,13 @@ char *Bgethomedir(void) #endif } -char *Bgetsupportdir(void) -{ -#if defined __APPLE__ - return osx_getsupportdir(); -#else - return Bgethomedir(); -#endif -} - char *Bgetappdir(void) { char *dir = NULL; - + #ifdef _WIN32 TCHAR appdir[MAX_PATH]; - + if (GetModuleFileName(NULL, appdir, MAX_PATH) > 0) { // trim off the filename char *slash = strrchr(appdir, '\\'); @@ -472,7 +463,7 @@ char *Bgetappdir(void) dir = strdup(dirname(buf)); } #endif - + return dir; } diff --git a/polymer/eduke32/build/src/osxbits.m b/polymer/eduke32/build/src/osxbits.m index a138b3a89..d5818c513 100644 --- a/polymer/eduke32/build/src/osxbits.m +++ b/polymer/eduke32/build/src/osxbits.m @@ -73,15 +73,15 @@ char *osx_gethomedir(void) return returnpath; } -char *osx_getsupportdir(void) +char *osx_getsupportdir(int32_t local) { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, local ? NSUserDomainMask : NSLocalDomainMask, YES); char *returnpath = NULL; if ([paths count] > 0) { const char *Cpath = [[paths objectAtIndex:0] UTF8String]; - + if (Cpath) returnpath = Bstrdup(Cpath); } @@ -98,12 +98,12 @@ char *osx_getappdir(void) CFStringRef str; const char *s; char *dir = NULL; - + mainBundle = CFBundleGetMainBundle(); if (!mainBundle) { return NULL; } - + resUrl = CFBundleCopyResourcesDirectoryURL(mainBundle); CFRelease(mainBundle); if (!resUrl) { @@ -120,25 +120,25 @@ char *osx_getappdir(void) if (!str) { return NULL; } - + s = CFStringGetCStringPtr(str, CFStringGetSystemEncoding()); if (s) { dir = strdup(s); } CFRelease(str); - + return dir; } -char *osx_getapplicationsdir(void) +char *osx_getapplicationsdir(int32_t local) { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSAllApplicationsDirectory, NSLocalDomainMask, YES); + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSAllApplicationsDirectory, local ? NSUserDomainMask : NSLocalDomainMask, YES); char *returnpath = NULL; if ([paths count] > 0) { const char *Cpath = [[paths objectAtIndex:0] UTF8String]; - + if (Cpath) returnpath = Bstrdup(Cpath); } diff --git a/polymer/eduke32/source/common.c b/polymer/eduke32/source/common.c index 27e2797df..cfd3c808d 100644 --- a/polymer/eduke32/source/common.c +++ b/polymer/eduke32/source/common.c @@ -801,25 +801,35 @@ void G_AddSearchPaths(void) addsearchpath("/usr/local/share/games/eduke32"); #elif defined(__APPLE__) char buf[BMAX_PATH]; - char *applications = osx_getapplicationsdir(); - char *support = Bgetsupportdir(); + int32_t i; + char *applications[] = { osx_getapplicationsdir(0), osx_getapplicationsdir(1) }; + char *support[] = { osx_getsupportdir(0), osx_getsupportdir(1) }; - Bsnprintf(buf, sizeof(buf), "%s/Steam", support); - G_AddSteamPathsApple(buf); + for (i = 0; i < 2; i++) + { + Bsnprintf(buf, sizeof(buf), "%s/Steam", support[i]); + G_AddSteamPathsApple(buf); - Bsnprintf(buf, sizeof(buf), "%s/Steam/steamapps/libraryfolders.vdf", support); - G_ParseSteamKeyValuesForPaths(buf); + Bsnprintf(buf, sizeof(buf), "%s/Steam/steamapps/libraryfolders.vdf", support[i]); + G_ParseSteamKeyValuesForPaths(buf); - Bsnprintf(buf, sizeof(buf), "%s/Duke Nukem 3D.app/Contents/Resources/Duke Nukem 3D.boxer/C.harddisk", applications); - addsearchpath(buf); + Bsnprintf(buf, sizeof(buf), "%s/Duke Nukem 3D.app/Contents/Resources/Duke Nukem 3D.boxer/C.harddisk", applications[i]); + addsearchpath(buf); + } - Bsnprintf(buf, sizeof(buf), "%s/JFDuke3D", support); - addsearchpath(buf); - Bsnprintf(buf, sizeof(buf), "%s/EDuke32", support); - addsearchpath(buf); + for (i = 0; i < 2; i++) + { + Bsnprintf(buf, sizeof(buf), "%s/JFDuke3D", support[i]); + addsearchpath(buf); + Bsnprintf(buf, sizeof(buf), "%s/EDuke32", support[i]); + addsearchpath(buf); + } - Bfree(applications); - Bfree(support); + for (i = 0; i < 2; i++) + { + Bfree(applications[i]); + Bfree(support[i]); + } #elif defined (_WIN32) char buf[BMAX_PATH]; const char* instpath;