]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
made Sys_LoadLibrary search in the executable path if the normal load fails (this...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 31 May 2005 23:48:57 +0000 (23:48 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 31 May 2005 23:48:57 +0000 (23:48 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5367 d7cf8633-e32d-0410-b094-e92efae38249

sys_shared.c

index 6cd86758ad9d76a0edda0257ddfb8ac8b3603de9..feb3164a6ce6a8ba27b7d2955d0ccee1487a5e44 100644 (file)
@@ -61,7 +61,35 @@ qboolean Sys_LoadLibrary (const char** dllnames, dllhandle_t* handle, const dllf
 
        // No DLL found
        if (! dllhandle)
-               return false;
+       {
+               // see if the names can be loaded relative to the executable path
+               // (this is for Mac OSX which does not check next to the executable)
+               if (strrchr(com_argv[0], '/'))
+               {
+                       char path[MAX_OSPATH];
+                       strlcpy(path, com_argv[0], sizeof(path));
+                       *(strrchr(com_argv[0], '/')) = 0;
+                       for (i = 0; dllnames[i] != NULL; i++)
+                       {
+                               char temp[MAX_OSPATH];
+                               strlcpy(temp, path, sizeof(temp));
+                               strlcat(temp, dllnames[i], sizeof(temp));
+#ifdef WIN32
+                               dllhandle = LoadLibrary (temp);
+#else
+                               dllhandle = dlopen (temp, RTLD_LAZY);
+#endif
+                               if (dllhandle)
+                                       break;
+
+                               Con_Printf ("Can't load \"%s\".\n", temp);
+                       }
+                       if (! dllhandle)
+                               return false;
+               }
+               else
+                       return false;
+       }
 
        Con_Printf("\"%s\" loaded.\n", dllnames[i]);