Skip to content

Commit

Permalink
- New: On Windows, the game now checks the registry to see if you hav…
Browse files Browse the repository at this point in the history
…e Steam

  installed. If so, it checks your SteamApps directory for any IWADs you may
  have purchased through Steam and adds any it finds to the list of available
  IWADs you can play. This means that if you bought your id games through
  Steam, you can just extract ZDoom anywhere you like and run it without doing
  any additional setup.


SVN r581 (trunk)
  • Loading branch information
Randy Heit committed Dec 6, 2007
1 parent 1eca84d commit 1dede60
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/rh-log.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
December 6, 2007
- New: On Windows, the game now checks the registry to see if you have Steam
installed. If so, it checks your SteamApps directory for any IWADs you may
have purchased through Steam and adds any it finds to the list of available
IWADs you can play. This means that if you bought your id games through
Steam, you can just extract ZDoom anywhere you like and run it without doing
any additional setup.
- Fixed: The FLAC/makefile.mgw should use md5.o as an OBJ, not md5.c.
- Fixed: The Linux makefile probably shouldn't be using the bundled zlib headers,
either.
Expand Down
22 changes: 21 additions & 1 deletion src/d_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1629,14 +1629,34 @@ static EIWADType IdentifyVersion (const char *zdoom_wad)
}
}
}
#ifdef _WIN32
FString steam_path = I_GetSteamPath();
if (steam_path.IsNotEmpty())
{
static const char *const steam_dirs[] =
{
"doom 2/base",
"final doom/base",
"heretic shadow of the serpent riders/base",
"hexen/base",
"hexen deathkings of the dark citadel/base",
"ultimate doom/base"
};
steam_path += "/SteamApps/common/";
for (i = 0; i < countof(steam_dirs); ++i)
{
CheckIWAD (steam_path + steam_dirs[i], wads);
}
}
#endif
}

if (iwadparm != NULL && !wads[0].Path.IsEmpty())
{
iwadparmfound = true;
}

for (i = numwads = 0; i < sizeof(IWADNames)/sizeof(char *); i++)
for (i = numwads = 0; i < countof(IWADNames); i++)
{
if (!wads[i].Path.IsEmpty())
{
Expand Down
42 changes: 42 additions & 0 deletions src/win32/i_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,3 +793,45 @@ int I_FindClose (void *handle)
{
return FindClose ((HANDLE)handle);
}

static bool QueryPathKey(HKEY key, const char *keypath, const char *valname, FString &value)
{
HKEY steamkey;
DWORD pathtype;
DWORD pathlen;
LONG res;

if(ERROR_SUCCESS == RegOpenKeyEx(key, keypath, 0, KEY_QUERY_VALUE, &steamkey))
{
if (ERROR_SUCCESS == RegQueryValueEx(steamkey, valname, 0, &pathtype, NULL, &pathlen) &&
pathtype == REG_SZ && pathlen != 0)
{
// Don't include terminating null in count
char *chars = value.LockNewBuffer(pathlen - 1);
res = RegQueryValueEx(steamkey, valname, 0, NULL, (LPBYTE)chars, &pathlen);
value.UnlockBuffer();
if (res != ERROR_SUCCESS)
{
value = "";
}
}
RegCloseKey(steamkey);
}
return value.IsNotEmpty();
}

FString I_GetSteamPath()
{
FString path;

if (QueryPathKey(HKEY_CURRENT_USER, "Software\\Valve\\Steam", "SteamPath", path))
{
return path;
}
if (QueryPathKey(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", "InstallPath", path))
{
return path;
}
path = "";
return path;
}
4 changes: 4 additions & 0 deletions src/win32/i_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ extern const IWADInfo *DoomStartupInfo;
// [RH] Used by the display code to set the normal window procedure
void I_SetWndProc();

// [RH] Checks the registry for Steam's install path, so we can scan its
// directories for IWADs if the user purchased any through Steam.
FString I_GetSteamPath();

// Damn Microsoft for doing Get/SetWindowLongPtr half-assed. Instead of
// giving them proper prototypes under Win32, they are just macros for
// Get/SetWindowLong, meaning they take LONGs and not LONG_PTRs.
Expand Down
9 changes: 9 additions & 0 deletions src/zstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ FString::~FString ()
Data()->Release();
}

char *FString::LockNewBuffer(size_t len)
{
Data()->Release();
AllocBuffer(len);
assert(Data()->RefCount == 1);
Data()->RefCount = -1;
return Chars;
}

char *FString::LockBuffer()
{
if (Data()->RefCount == 1)
Expand Down
4 changes: 4 additions & 0 deletions src/zstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class FString

~FString ();

// Discard string's contents, create a new buffer, and lock it.
char *LockNewBuffer(size_t len);

char *LockBuffer(); // Obtain write access to the character buffer
void UnlockBuffer(); // Allow shared access to the character buffer

Expand Down Expand Up @@ -232,6 +235,7 @@ class FString

size_t Len() const { return Data()->Len; }
bool IsEmpty() const { return Len() == 0; }
bool IsNotEmpty() const { return Len() != 0; }

void Truncate (long newlen);

Expand Down

0 comments on commit 1dede60

Please sign in to comment.