changeset 2341:d6407efaa4ea

Moving registry access stuff to Registry.h/cpp
author Grumpy7
date Sun, 06 Apr 2014 12:56:49 +0200
parents dc822157c98d
children d7f4dac06dc0
files AudioPlayer.cpp Build/Visual Studio 2012/World of Might and Magic.vcxproj Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Game.cpp Keyboard.cpp OSWindow.cpp Render.cpp mm7_2.cpp mm7_unsorted_subs.h
diffstat 9 files changed, 10 insertions(+), 179 deletions(-) [+]
line wrap: on
line diff
--- a/AudioPlayer.cpp	Sun Apr 06 12:50:35 2014 +0200
+++ b/AudioPlayer.cpp	Sun Apr 06 12:56:49 2014 +0200
@@ -20,6 +20,7 @@
 #include "Log.h"
 #include "ErrorHandling.h"
 #include "Level/Decoration.h"
+#include "Registry.h"
 
 #include "Bink_Smacker.h"
 
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj	Sun Apr 06 12:50:35 2014 +0200
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj	Sun Apr 06 12:56:49 2014 +0200
@@ -210,6 +210,7 @@
     <ClCompile Include="..\..\Party.cpp" />
     <ClCompile Include="..\..\Player.cpp" />
     <ClCompile Include="..\..\Random.cpp" />
+    <ClCompile Include="..\..\Registry.cpp" />
     <ClCompile Include="..\..\Render.cpp" />
     <ClCompile Include="..\..\SaveLoad.cpp" />
     <ClCompile Include="..\..\Spells.cpp" />
@@ -453,6 +454,7 @@
     <ClInclude Include="..\..\Player.h" />
     <ClInclude Include="..\..\PlayerFrameTable.h" />
     <ClInclude Include="..\..\Random.h" />
+    <ClInclude Include="..\..\Registry.h" />
     <ClInclude Include="..\..\Render.h" />
     <ClInclude Include="..\..\SaveLoad.h" />
     <ClInclude Include="..\..\Spells.h" />
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters	Sun Apr 06 12:50:35 2014 +0200
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters	Sun Apr 06 12:56:49 2014 +0200
@@ -386,6 +386,7 @@
     </ClCompile>
     <ClCompile Include="..\..\MediaPlayer.cpp" />
     <ClCompile Include="..\..\OurMath.cpp" />
+    <ClCompile Include="..\..\Registry.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\Level\Decoration.h" />
@@ -912,6 +913,7 @@
     <ClInclude Include="..\..\MediaPlayer.h" />
     <ClInclude Include="..\..\OpenALSoundProvider.h" />
     <ClInclude Include="..\..\stuff.h" />
+    <ClInclude Include="..\..\Registry.h" />
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\Player.swig" />
--- a/Game.cpp	Sun Apr 06 12:50:35 2014 +0200
+++ b/Game.cpp	Sun Apr 06 12:56:49 2014 +0200
@@ -48,6 +48,7 @@
 #include "SpriteObject.h"
 #include "mm7.h"
 #include "Sprites.h"
+#include "Registry.h"
 
 
 
--- a/Keyboard.cpp	Sun Apr 06 12:50:35 2014 +0200
+++ b/Keyboard.cpp	Sun Apr 06 12:56:49 2014 +0200
@@ -17,6 +17,7 @@
 #include "Indoor.h"
 #include "viewport.h"
 #include "AudioPlayer.h"
+#include "Registry.h"
 #include "Level/Decoration.h"
 
 #include <tuple>
--- a/OSWindow.cpp	Sun Apr 06 12:50:35 2014 +0200
+++ b/OSWindow.cpp	Sun Apr 06 12:56:49 2014 +0200
@@ -22,6 +22,7 @@
 #include "Log.h"
 #include "LOD.h"
 #include "Outdoor_stuff.h"
+#include "Registry.h"
 
 
 bool wizard_eye = false;         //включить на постоянно око чародея
--- a/Render.cpp	Sun Apr 06 12:50:35 2014 +0200
+++ b/Render.cpp	Sun Apr 06 12:56:49 2014 +0200
@@ -33,6 +33,7 @@
 #include "Lights.h"
 #include "Level/Decoration.h"
 #include "Vis.h"
+#include "Registry.h"
 
 //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib")
 //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib")
--- a/mm7_2.cpp	Sun Apr 06 12:50:35 2014 +0200
+++ b/mm7_2.cpp	Sun Apr 06 12:56:49 2014 +0200
@@ -60,6 +60,7 @@
 #include "Level/Decoration.h"
 #include "LuaVM.h"
 #include "MMT.h"
+#include "Registry.h"
 
 //#include "lib/lua/lua.h"
 
@@ -2460,181 +2461,6 @@
   _flushall();
 }
 
-//----- (004649EF) --------------------------------------------------------
-int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue)
-{
-  int v3; // [sp+4h] [bp-24h]@1
-  DWORD cbData; // [sp+8h] [bp-20h]@1
-  LPCSTR lpValueName; // [sp+Ch] [bp-1Ch]@1
-  DWORD dwDisposition; // [sp+10h] [bp-18h]@2
-  BYTE Data[4]; // [sp+14h] [bp-14h]@5
-  HKEY hKey; // [sp+18h] [bp-10h]@1
-  HKEY phkResult; // [sp+1Ch] [bp-Ch]@1
-  HKEY v10; // [sp+20h] [bp-8h]@1
-  HKEY v11; // [sp+24h] [bp-4h]@1
-
-  v3 = uDefValue;
-  lpValueName = pKey;
-  v11 = 0;
-  v10 = 0;
-  hKey = 0;
-  phkResult = 0;
-  cbData = 4;
-  if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) )// for 64 bit
-  {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
-    {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v10, &dwDisposition) )
-      {
-        if ( !RegCreateKeyExA(v10, "1.0", 0, "", 0, 0xF003Fu, 0, &v11, &dwDisposition) )
-        {
-          if ( RegQueryValueExA(v11, lpValueName, 0, 0, Data, &cbData) )
-          {
-            *(int *)Data = v3;
-            RegSetValueExA(v11, lpValueName, 0, 4u, Data, 4u);
-          }
-          RegCloseKey(v11);
-        }
-        RegCloseKey(v10);
-      }
-      RegCloseKey(phkResult);
-    }
-    RegCloseKey(hKey);
-  }
-  return *(int *)Data;
-}
-
-//----- (00464B02) --------------------------------------------------------
-void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString)
-{
-  size_t v2; // eax@5
-  const char *lpValueName; // [sp+4h] [bp-1Ch]@1
-  const char *Str; // [sp+8h] [bp-18h]@1
-  DWORD dwDisposition; // [sp+Ch] [bp-14h]@2
-  HKEY hKey; // [sp+10h] [bp-10h]@1
-  HKEY phkResult; // [sp+14h] [bp-Ch]@1
-  HKEY v8; // [sp+18h] [bp-8h]@1
-  HKEY v9; // [sp+1Ch] [bp-4h]@1
-
-  Str = pString;
-  lpValueName = pKey;
-  v9 = 0;
-  v8 = 0;
-  hKey = 0;
-  phkResult = 0;
-  if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
-  {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
-    {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
-      {
-        if ( !RegCreateKeyExA(v8, "1.0", 0, "", 0, 0xF003Fu, 0, &v9, &dwDisposition) )
-        {
-          v2 = strlen(Str);
-          RegSetValueExA(v9, lpValueName, 0, 1u, (const BYTE *)Str, v2 + 1);
-          RegCloseKey(v9);
-        }
-        RegCloseKey(v8);
-      }
-      RegCloseKey(phkResult);
-    }
-    RegCloseKey(hKey);
-  }
-}
-
-//----- (00464BEF) --------------------------------------------------------
-void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue)
-{
-  LSTATUS (__stdcall *v4)(HKEY); // esi@1
-  LSTATUS result; // eax@7
-  DWORD Type; // [sp+Ch] [bp-24h]@5
-  LPCSTR lpValueName; // [sp+10h] [bp-20h]@1
-  DWORD cbData; // [sp+14h] [bp-1Ch]@1
-  LPBYTE Dest; // [sp+18h] [bp-18h]@1
-  DWORD dwDisposition; // [sp+1Ch] [bp-14h]@2
-  HKEY phkResult; // [sp+20h] [bp-10h]@1
-  HKEY hKey; // [sp+24h] [bp-Ch]@1
-  HKEY v13; // [sp+28h] [bp-8h]@1
-  HKEY v14; // [sp+2Ch] [bp-4h]@1
-
-  cbData = uBufLen;
-  Dest = (LPBYTE)pOutString;
-  lpValueName = pKeyName;
-  v14 = 0;
-  v13 = 0;
-  hKey = 0;
-  phkResult = 0;
-  v4 = RegCloseKey;
-  if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey)
-    || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition)
-    || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v13, &dwDisposition)
-    || RegCreateKeyExA(v13, "1.0", 0, "", 0, 0xF003Fu, 0, &v14, &dwDisposition) )
-  {
-    result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
-  }
-  else if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) )
-  {
-    RegCloseKey(v14);
-    v14 = 0;
-    result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
-  }
-  else
-  {
-	v4 = RegCloseKey;
-	RegCloseKey(v14);
-	v14 = 0;
-	RegCloseKey(v13);
-	v13 = 0;
-	RegCloseKey(phkResult);
-	phkResult = 0;
-	result = RegCloseKey(hKey);
-	hKey = 0;
-  }
-  if ( v14 )
-    result = v4(v14);
-  if ( v13 )
-    result = v4(v13);
-  if ( hKey )
-    result = v4(hKey);
-  if ( phkResult )
-    result = v4(phkResult);
-}
-
-//----- (00464D32) --------------------------------------------------------
-void __fastcall WriteWindowsRegistryInt(const char *pKey, int val)
-{
-  const char *lpValueName; // [sp+4h] [bp-1Ch]@1
-  BYTE Data[4]; // [sp+8h] [bp-18h]@1
-  DWORD dwDisposition; // [sp+Ch] [bp-14h]@2
-  HKEY hKey; // [sp+10h] [bp-10h]@1
-  HKEY phkResult; // [sp+14h] [bp-Ch]@1
-  HKEY v7; // [sp+18h] [bp-8h]@1
-  HKEY v8; // [sp+1Ch] [bp-4h]@1
-
-  *(int *)Data = val;
-  lpValueName = pKey;
-  v8 = 0;
-  v7 = 0;
-  hKey = 0;
-  phkResult = 0;
-  if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
-  {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
-    {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v7, &dwDisposition) )
-      {
-        if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
-        {
-          RegSetValueExA(v8, lpValueName, 0, 4, Data, 4);
-          RegCloseKey(v8);
-        }
-        RegCloseKey(v7);
-      }
-      RegCloseKey(phkResult);
-    }
-    RegCloseKey(hKey);
-  }
-}
 
 //----- (00464E17) --------------------------------------------------------
 bool __fastcall CheckMM7CD(char c)
--- a/mm7_unsorted_subs.h	Sun Apr 06 12:50:35 2014 +0200
+++ b/mm7_unsorted_subs.h	Sun Apr 06 12:56:49 2014 +0200
@@ -93,10 +93,6 @@
 char Is_out15odm_underwater();
 void SetUnderwaterFog();
 void DoPrepareWorld(unsigned int bLoading, int _1_fullscreen_loading_2_box);
-int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue); // idb
-void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString);
-void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue);
-void __fastcall WriteWindowsRegistryInt(const char *pKey, int val);
 bool __fastcall CheckMM7CD(char c);
 void SecondaryInitialization();
 void CreateAsyncMouse();