Fix reading the GOG and Steam paths for Win64 builds.

git-svn-id: https://svn.eduke32.com/eduke32@3671 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2013-04-13 03:50:37 +00:00
parent 33ab42e7b4
commit 670ede9f60

View file

@ -13,6 +13,10 @@
#ifdef _WIN32 #ifdef _WIN32
# include "winbits.h" # include "winbits.h"
# include <shlwapi.h> # include <shlwapi.h>
# include <winnt.h>
# ifndef KEY_WOW64_32KEY
# define KEY_WOW64_32KEY 0x0200
# endif
#endif #endif
#include "common.h" #include "common.h"
@ -226,16 +230,20 @@ const char * G_GetInstallPath(int32_t insttype)
static int32_t success[NUMINSTPATHS] = { -1, -1 }; static int32_t success[NUMINSTPATHS] = { -1, -1 };
int32_t siz = BMAX_PATH; int32_t siz = BMAX_PATH;
// this still needs to be fixed for win64 builds
if (success[insttype] == -1) if (success[insttype] == -1)
{ {
HKEY HKLM32;
LONG keygood = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NULL, 0, KEY_READ | KEY_WOW64_32KEY, &HKLM32);
// KEY_WOW64_32KEY gets us around Wow6432Node on 64-bit builds
if (keygood == ERROR_SUCCESS)
switch (insttype) switch (insttype)
{ {
case INSTPATH_STEAM: case INSTPATH_STEAM:
success[insttype] = SHGetValueA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 225140", "InstallLocation", NULL, spath[insttype], (LPDWORD)&siz); success[insttype] = SHGetValueA(HKLM32, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 225140", "InstallLocation", NULL, spath[insttype], (LPDWORD)&siz);
break; break;
case INSTPATH_GOG: case INSTPATH_GOG:
success[insttype] = SHGetValueA(HKEY_LOCAL_MACHINE, "SOFTWARE\\GOG.com\\GOGDUKE3D", "PATH", NULL, spath[insttype], (LPDWORD)&siz); success[insttype] = SHGetValueA(HKLM32, "SOFTWARE\\GOG.com\\GOGDUKE3D", "PATH", NULL, spath[insttype], (LPDWORD)&siz);
break; break;
} }
} }
@ -260,18 +268,19 @@ void G_AddSearchPaths(void)
#elif defined (_WIN32) #elif defined (_WIN32)
// detect Steam and GOG versions of Duke3D // detect Steam and GOG versions of Duke3D
char buf[BMAX_PATH]; char buf[BMAX_PATH];
const char* instpath;
if (G_GetInstallPath(INSTPATH_STEAM)) if ((instpath = G_GetInstallPath(INSTPATH_STEAM)))
{ {
Bsprintf(buf, "%s/gameroot", G_GetInstallPath(INSTPATH_STEAM)); Bsprintf(buf, "%s/gameroot", instpath);
addsearchpath(buf); addsearchpath(buf);
Bsprintf(buf, "%s/gameroot/addons", G_GetInstallPath(INSTPATH_STEAM)); Bsprintf(buf, "%s/gameroot/addons", instpath);
addsearchpath(buf); addsearchpath(buf);
} }
if (G_GetInstallPath(INSTPATH_GOG)) if ((instpath = G_GetInstallPath(INSTPATH_GOG)))
addsearchpath(G_GetInstallPath(INSTPATH_GOG)); addsearchpath(instpath);
#endif #endif
} }
@ -279,18 +288,19 @@ void G_CleanupSearchPaths(void)
{ {
#ifdef _WIN32 #ifdef _WIN32
char buf[BMAX_PATH]; char buf[BMAX_PATH];
const char* instpath;
if (G_GetInstallPath(INSTPATH_STEAM)) if ((instpath = G_GetInstallPath(INSTPATH_STEAM)))
{ {
Bsprintf(buf, "%s/gameroot", G_GetInstallPath(INSTPATH_STEAM)); Bsprintf(buf, "%s/gameroot", instpath);
removesearchpath(buf); removesearchpath(buf);
Bsprintf(buf, "%s/gameroot/addons", G_GetInstallPath(INSTPATH_STEAM)); Bsprintf(buf, "%s/gameroot/addons", instpath);
removesearchpath(buf); removesearchpath(buf);
} }
if (G_GetInstallPath(INSTPATH_GOG)) if ((instpath = G_GetInstallPath(INSTPATH_GOG)))
removesearchpath(G_GetInstallPath(INSTPATH_GOG)); removesearchpath(instpath);
#endif #endif
} }