diff --git a/Standard Gaming Platform/CMakeLists.txt b/Standard Gaming Platform/CMakeLists.txt index 4d0137a5..f4f43c3f 100644 --- a/Standard Gaming Platform/CMakeLists.txt +++ b/Standard Gaming Platform/CMakeLists.txt @@ -14,7 +14,6 @@ set(SGPSrc "${CMAKE_CURRENT_SOURCE_DIR}/himage.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/impTGA.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/input.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/Install.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Ja2 Libs.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LibraryDataBase.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/line.cpp" @@ -23,7 +22,6 @@ set(SGPSrc "${CMAKE_CURRENT_SOURCE_DIR}/PCX.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/PngLoader.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Random.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/RegInst.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/sgp.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/sgp_logger.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/shading.cpp" diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index f392d6d8..6ad5bcf5 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -35,7 +35,6 @@ #include "FileMan.h" #include "MemMan.h" #include "Debug.h" - #include "RegInst.h" #include "LibraryDataBase.h" #include "io.h" #include "sgp_logger.h" diff --git a/Standard Gaming Platform/Install.cpp b/Standard Gaming Platform/Install.cpp deleted file mode 100644 index 672cb7b1..00000000 --- a/Standard Gaming Platform/Install.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//************************************************************************** -// -// Filename : Install.c -// -// Purpose : install routines -// -// Modification history : -// -// 02dec96:HJH - Creation -// -//************************************************************************** - -//************************************************************************** -// -// Includes -// -//************************************************************************** - - #include "types.h" - #include - #include "Install.h" - #include "RegInst.h" - -//************************************************************************** -// -// Defines -// -//************************************************************************** - -//************************************************************************** -// -// Typedefs -// -//************************************************************************** - -//************************************************************************** -// -// Functions -// -//************************************************************************** - -BOOLEAN InstallApplication( STR strAppname, STR strPath ) -{ - HKEY hKey; - BOOL fRet = TRUE; - - hKey = GetAppRegistryKey(); - RegCloseKey( hKey ); - - //hKeySection = GetSectionKey("Startup"); - //RegCloseKey( hKeySection ); - - fRet = fRet && WriteProfileChar( "Startup", "InstPath", strPath ); - - return(fRet); -} diff --git a/Standard Gaming Platform/Install.h b/Standard Gaming Platform/Install.h deleted file mode 100644 index 3bedaa66..00000000 --- a/Standard Gaming Platform/Install.h +++ /dev/null @@ -1,52 +0,0 @@ -//************************************************************************** -// -// Filename : Install.h -// -// Purpose : prototypes for the install routines -// -// Modification history : -// -// 02dec96:HJH - Creation -// -//************************************************************************** - -#ifndef _Install_h -#define _Install_h - -//************************************************************************** -// -// Includes -// -//************************************************************************** - -#include "types.h" - -//************************************************************************** -// -// Defines -// -//************************************************************************** - -//************************************************************************** -// -// Typedefs -// -//************************************************************************** - -//************************************************************************** -// -// Function Prototypes -// -//************************************************************************** - -#ifdef __cplusplus -extern "C" { -#endif - -extern BOOLEAN InstallApplication( STR strAppname, STR strPath ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Standard Gaming Platform/RegInst.cpp b/Standard Gaming Platform/RegInst.cpp deleted file mode 100644 index d77a845e..00000000 --- a/Standard Gaming Platform/RegInst.cpp +++ /dev/null @@ -1,380 +0,0 @@ -//************************************************************************** -// -// Filename : RegInst.c -// -// Purpose : registry routines -// -// Modification history : -// -// 02dec96:HJH - Creation -// -//************************************************************************** - -//************************************************************************** -// -// Includes -// -//************************************************************************** - - #include "types.h" - #include "RegInst.h" - #include "WCheck.h" - -//************************************************************************** -// -// Defines -// -//************************************************************************** - -#define REG_KEY_SIZE 50 - -//************************************************************************** -// -// Variables -// -//************************************************************************** - -// INI strings are not localized -static const TCHAR szSoftware[] = _T("Software"); - -static CHAR gszRegistryKey[REG_KEY_SIZE]; -static CHAR gszAppName[REG_KEY_SIZE]; -static CHAR gszProfileName[REG_KEY_SIZE]; - -//************************************************************************** -// -// Functions -// -//************************************************************************** - -BOOLEAN InitializeRegistryKeys(STR lpszAppName, STR lpszRegistryKey) -{ - CHECKF(lpszAppName != NULL); - CHECKF(lpszRegistryKey != NULL); - //CHECKF(gpszRegistryKey == NULL); - //CHECKF(gpszAppName == NULL); - //CHECKF(gpszProfileName == NULL); - - // Note: this will leak the original gpszProfileName, but it - // will be freed when the application exits. No assumptions - // can be made on how gpszProfileName was allocated. - - strcpy( gszAppName, lpszAppName); - strcpy( gszRegistryKey, lpszRegistryKey ); - strcpy( gszProfileName, gszAppName); - - return(TRUE); -} - -// returns key for HKEY_CURRENT_USER\"Software"\RegistryKey\ProfileName -// creating it if it doesn't exist -// responsibility of the caller to call RegCloseKey() on the returned HKEY -HKEY GetAppRegistryKey() -{ - HKEY hAppKey = NULL; - HKEY hSoftKey = NULL; - HKEY hCompanyKey = NULL; - - assert(gszRegistryKey[0] != '\0'); - //assert(gpszProfileName != NULL); - - if (RegOpenKeyEx(HKEY_CURRENT_USER, szSoftware, 0, KEY_WRITE|KEY_READ, - &hSoftKey) == ERROR_SUCCESS) - { - DWORD dw; - if (RegCreateKeyEx(hSoftKey, gszRegistryKey, 0, REG_NONE, - REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL, - &hCompanyKey, &dw) == ERROR_SUCCESS) - { - RegCreateKeyEx(hCompanyKey, gszProfileName, 0, REG_NONE, - REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL, - &hAppKey, &dw); - } - } - if (hSoftKey != NULL) - RegCloseKey(hSoftKey); - if (hCompanyKey != NULL) - RegCloseKey(hCompanyKey); - - return hAppKey; -} - -// returns key for: -// HKEY_CURRENT_USER\"Software"\RegistryKey\AppName\lpszSection -// creating it if it doesn't exist. -// responsibility of the caller to call RegCloseKey() on the returned HKEY -HKEY GetSectionKey(STR lpszSection) -{ - HKEY hSectionKey = NULL; - HKEY hAppKey = GetAppRegistryKey(); - DWORD dw; - - assert(lpszSection != NULL); - - if (hAppKey == NULL) - return NULL; - - RegCreateKeyEx(hAppKey, lpszSection, 0, REG_NONE, - REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL, - &hSectionKey, &dw); - RegCloseKey(hAppKey); - return hSectionKey; -} - -UINT GetProfileInteger(STR lpszSection, STR lpszEntry, int nDefault) -{ - DWORD dwValue; - DWORD dwType; - DWORD dwCount = sizeof(DWORD); - LONG lResult; - - assert(lpszSection != NULL); - assert(lpszEntry != NULL); - - if (gszRegistryKey[0] != '\0') // use registry - { - HKEY hSecKey = GetSectionKey(lpszSection); - if (hSecKey == NULL) - return nDefault; - lResult = RegQueryValueEx(hSecKey, (LPTSTR)lpszEntry, NULL, &dwType, - (LPBYTE)&dwValue, &dwCount); - RegCloseKey(hSecKey); - if (lResult == ERROR_SUCCESS) - { - assert(dwType == REG_DWORD); - assert(dwCount == sizeof(dwValue)); - return (UINT)dwValue; - } - return nDefault; - } - else - { - assert(gszProfileName[0] != '\0'); - return GetPrivateProfileInt(lpszSection, lpszEntry, nDefault, - gszProfileName); - } -} - -BOOLEAN GetProfileChar(STR lpszSection, STR lpszEntry, STR lpszDefault, STR lpszValue) -{ - DWORD dwType, dwCount; - LONG lResult; - BOOLEAN fRet = TRUE; - CHAR strValue[200]; - - assert(lpszSection != NULL); - assert(lpszEntry != NULL); - assert(lpszDefault != NULL); - - if (gszRegistryKey[0] != '\0') - { - HKEY hSecKey = GetSectionKey(lpszSection); - if (hSecKey == NULL) - { - strcpy( lpszValue, lpszDefault ); - return(TRUE); - } - lResult = RegQueryValueEx(hSecKey, (LPTSTR)lpszEntry, NULL, &dwType, - NULL, &dwCount); - if (lResult == ERROR_SUCCESS) - { - assert(dwType == REG_SZ); - lResult = RegQueryValueEx(hSecKey, (LPTSTR)lpszEntry, NULL, &dwType, - (LPBYTE)strValue, &dwCount); - } - RegCloseKey(hSecKey); - if (lResult == ERROR_SUCCESS) - { - assert(dwType == REG_SZ); - strcpy( lpszValue, strValue ); - return(TRUE); - } - strcpy( lpszValue, lpszDefault ); - return(TRUE); - } -// else -// { -// assert(gpszProfileName != NULL); -// -// if (lpszDefault == NULL) -// lpszDefault = &afxChNil; // don't pass in NULL -// TCHAR szT[4096]; -// DWORD dw = ::GetPrivateProfileString(lpszSection, lpszEntry, -// lpszDefault, szT, _countof(szT), gpszProfileName); -// assert(dw < 4095); -// return szT; -// } - - return( fRet ); -} - -BOOL GetProfileBinary(STR lpszSection, STR lpszEntry, - BYTE** ppData, UINT* pBytes) -{ -// DWORD dwType, dwCount; -// LONG lResult; -// -// assert(lpszSection != NULL); -// assert(lpszEntry != NULL); -// assert(ppData != NULL); -// assert(pBytes != NULL); -// *ppData = NULL; -// *pBytes = 0; -// -// if (gpszRegistryKey != NULL) -// { -// LPBYTE lpByte = NULL; -// HKEY hSecKey = GetSectionKey(lpszSection); -// if (hSecKey == NULL) -// return FALSE; -// -// lResult = RegQueryValueEx(hSecKey, (LPTSTR)lpszEntry, NULL, &dwType, -// NULL, &dwCount); -// *pBytes = dwCount; -// if (lResult == ERROR_SUCCESS) -// { -// assert(dwType == REG_BINARY); -// *ppData = new BYTE[*pBytes]; -// lResult = RegQueryValueEx(hSecKey, (LPTSTR)lpszEntry, NULL, &dwType, -// *ppData, &dwCount); -// } -// RegCloseKey(hSecKey); -// if (lResult == ERROR_SUCCESS) -// { -// assert(dwType == REG_BINARY); -// return TRUE; -// } -// else -// { -// delete [] *ppData; -// *ppData = NULL; -// } -// return FALSE; -// } -// else -// { -// //assert(gpszProfileName != NULL); -// // -// //CString str = GetProfileString(lpszSection, lpszEntry, NULL); -// //if (str.IsEmpty()) -// // return FALSE; -// //assert(str.GetLength()%2 == 0); -// //int nLen = str.GetLength(); -// //*pBytes = nLen/2; -// //*ppData = new BYTE[*pBytes]; -// //for (int i=0;i> 4) & 0x0F) + _T('A')); //high nibble -// } -// lpsz[i*2] = 0; -// -// assert(gpszProfileName != NULL); -// -// BOOL bResult = WriteProfileString(lpszSection, lpszEntry, lpsz); -// delete[] lpsz; -// return bResult; - return TRUE; -} diff --git a/Standard Gaming Platform/RegInst.h b/Standard Gaming Platform/RegInst.h deleted file mode 100644 index 660d65ba..00000000 --- a/Standard Gaming Platform/RegInst.h +++ /dev/null @@ -1,75 +0,0 @@ -//************************************************************************** -// -// Filename : RegInst.h -// -// Purpose : prototypes for the registry stuff -// -// Modification history : -// -// 02dec96:HJH - Creation -// -//************************************************************************** - -#ifndef _RegInst_h -#define _RegInst_h - -//************************************************************************** -// -// Includes -// -//************************************************************************** - -#include -#include -#include - -#include "types.h" - -//************************************************************************** -// -// Defines -// -//************************************************************************** - -//************************************************************************** -// -// Typedefs -// -//************************************************************************** - -//************************************************************************** -// -// Function Prototypes -// -//************************************************************************** - -#ifdef __cplusplus -extern "C" { -#endif - -// call once per execution of application: -extern BOOLEAN InitializeRegistryKeys(STR strAppName, STR strRegistryKey); - -// returns key for HKEY_CURRENT_USER\"Software"\RegistryKey\ProfileName -// creating it if it doesn't exist -// responsibility of the caller to call RegCloseKey() on the returned HKEY -extern HKEY GetAppRegistryKey(); - -// returns key for: -// HKEY_CURRENT_USER\"Software"\RegistryKey\AppName\lpszSection -// creating it if it doesn't exist. -// responsibility of the caller to call RegCloseKey() on the returned HKEY -extern HKEY GetSectionKey(STR lpszSection); - -extern UINT GetProfileInteger(STR lpszSection, STR lpszEntry, int nDefault); -extern BOOLEAN GetProfileChar(STR lpszSection, STR lpszEntry, STR lpszDefault, STR lpszValue); -extern BOOL GetProfileBinary(STR lpszSection, STR lpszEntry, BYTE** ppData, UINT* pBytes); -extern BOOL WriteProfileInt(STR lpszSection, STR lpszEntry, int nValue); -extern BOOL WriteProfileChar(STR lpszSection, STR lpszEntry, STR lpszValue); -extern BOOL WriteProfileBinary(STR lpszSection, STR lpszEntry, LPBYTE pData, UINT nBytes); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Standard Gaming Platform/sgp.cpp b/Standard Gaming Platform/sgp.cpp index e5f601ee..121dce70 100644 --- a/Standard Gaming Platform/sgp.cpp +++ b/Standard Gaming Platform/sgp.cpp @@ -6,7 +6,6 @@ #include #include #include "sgp.h" - #include "RegInst.h" #include "vobject.h" #include "font.h" #include "local.h" @@ -420,11 +419,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow) // now required by all (even JA2) in order to call ShutdownSGP atexit(SafeSGPExit); - // First, initialize the registry keys. - InitializeRegistryKeys( "Wizardry8", "Wizardry8key" ); - - // For rendering DLLs etc. - // Second, read in settings GetRuntimeSettings( );