Skip to content

Commit 70728ad

Browse files
committed
Removed legacy registry settings & refactor
1 parent fe64085 commit 70728ad

File tree

9 files changed

+64
-71
lines changed

9 files changed

+64
-71
lines changed

Client/core/CCore.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ class CCore : public CCoreInterface, public CSingleton < CCore >
272272
void NotifyRenderingGrass ( bool bIsRenderingGrass );
273273
bool IsRenderingGrass ( void ) { return m_bIsRenderingGrass; }
274274
bool GetRightSizeTxdEnabled ( void );
275+
const char* GetProductRegistryPath ( void ) { return SharedUtil::GetProductRegistryPath(); }
276+
const char* GetProductCommonDataDir ( void ) { return SharedUtil::GetProductCommonDataDir(); }
277+
const char* GetProductVersion ( void ) { return SharedUtil::GetProductVersion(); }
275278

276279
private:
277280
// Core devices.

Client/core/CVersionUpdater.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,21 +1525,6 @@ void CVersionUpdater::_CheckSidegradeRequirements ( void )
15251525
bool bVersionMatch = ( strLaunchVersion == m_strSidegradeVersion );
15261526
bool bLaunchPathValid = ( strLaunchHash == CMD5Hasher::CalculateHexString ( m_strSidegradePath ) );
15271527

1528-
if ( !bVersionMatch || !bLaunchPathValid )
1529-
{
1530-
// Try again with datum from legacy registry settings
1531-
if ( m_strSidegradeVersion == "1.0" )
1532-
{
1533-
m_strSidegradePath = GetVersionRegistryValueLegacy ( m_strSidegradeVersion, "", "Last Run Path" );
1534-
strLaunchHash = GetVersionRegistryValueLegacy ( m_strSidegradeVersion, "", "Last Run Path Hash" );
1535-
strLaunchVersion = GetVersionRegistryValueLegacy ( m_strSidegradeVersion, "", "Last Run Path Version" );
1536-
1537-
// Re-validate
1538-
bVersionMatch = ( strLaunchVersion == m_strSidegradeVersion );
1539-
bLaunchPathValid = ( strLaunchHash == CMD5Hasher::CalculateHexString ( m_strSidegradePath ) );
1540-
}
1541-
}
1542-
15431528
if ( bVersionMatch && bLaunchPathValid )
15441529
{
15451530
// Check core.dll version in case user has installed over different major version

Client/loader/CInstallManager.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -638,15 +638,11 @@ SString CInstallManager::_ProcessLayoutChecks ( void )
638638
}
639639
}
640640

641-
// If aero option reg entry doesn't exist in new, but does in old place, move it
641+
// Set aero option if reg entry doesn't exist
642642
{
643643
if ( GetApplicationSetting ( "aero-enabled" ).empty () )
644644
{
645-
SString strLegacyValue = GetVersionRegistryValueLegacy ( GetMajorVersionString (), PathJoin ( "Settings", "general" ), "aero-enabled" );
646-
if ( !strLegacyValue.empty () )
647-
SetApplicationSettingInt ( "aero-enabled", atoi ( strLegacyValue ) );
648-
else
649-
SetApplicationSettingInt ( "aero-enabled", 1 );
645+
SetApplicationSettingInt ( "aero-enabled", 1 );
650646
}
651647
}
652648

Client/loader/Utils.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -698,12 +698,6 @@ void SetMTASAPathSource ( bool bReadFromRegistry )
698698
SetRegistryValue ( "", "Last Run Path Hash", strHash );
699699
SetRegistryValue ( "", "Last Run Path Version", MTA_DM_ASE_VERSION );
700700

701-
// Also save for legacy 1.0 to see
702-
SString strThisVersion = SStringX ( MTA_DM_ASE_VERSION ).TrimEnd ( "n" );
703-
SetVersionRegistryValueLegacy ( strThisVersion, "", "Last Run Path", strLaunchPathFilename );
704-
SetVersionRegistryValueLegacy ( strThisVersion, "", "Last Run Path Hash", strHash );
705-
SetVersionRegistryValueLegacy ( strThisVersion, "", "Last Run Path Version", MTA_DM_ASE_VERSION );
706-
707701
// Strip the module name out of the path.
708702
SString strLaunchPath = GetLaunchPath();
709703

@@ -792,11 +786,6 @@ ePathResult GetGamePath ( SString& strOutResult, bool bFindIfMissing )
792786

793787
// Try HKLM "SOFTWARE\\Multi Theft Auto: San Andreas All\\Common\\"
794788
pathList.push_back ( GetCommonRegistryValue ( "", "GTA:SA Path" ) );
795-
// Then HKCU "SOFTWARE\\Multi Theft Auto: San Andreas 1.0\\"
796-
pathList.push_back ( GetVersionRegistryValueLegacy ( "1.0", "", "GTA:SA Path" ) );
797-
// Then HKCU "SOFTWARE\\Multi Theft Auto: San Andreas 1.1\\"
798-
pathList.push_back ( GetVersionRegistryValueLegacy ( "1.1", "", "GTA:SA Path Backup" ) );
799-
800789

801790
// Unicode character check on first one
802791
if ( strlen( pathList[0].c_str () ) )
@@ -1750,7 +1739,7 @@ void MaybeShowCopySettingsDialog ( void )
17501739
// Copy some directories if empty
17511740
SString strCurrentNewsDir = PathJoin ( GetMTADataPath (), "news" );
17521741

1753-
SString strPreviousDataPath = PathJoin ( GetSystemCommonAppDataPath(), "MTA San Andreas All", strPreviousVersion );
1742+
SString strPreviousDataPath = PathJoin ( GetSystemCommonAppDataPath(), GetProductCommonDataDir(), strPreviousVersion );
17541743
SString strPreviousNewsDir = PathJoin ( strPreviousDataPath, "news" );
17551744

17561745
if ( IsDirectoryEmpty( strCurrentNewsDir ) && DirectoryExists( strPreviousNewsDir ) )

Client/sdk/core/CCoreInterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class CCoreInterface
172172
virtual bool GetRequiredDisplayResolution ( int& iOutWidth, int& iOutHeight, int& iOutColorBits, int& iOutAdapterIndex, bool& bOutAllowUnsafeResolutions ) = 0;
173173
virtual void NotifyRenderingGrass ( bool bIsRenderingGrass ) = 0;
174174
virtual bool GetRightSizeTxdEnabled ( void ) = 0;
175+
virtual const char* GetProductRegistryPath ( void ) = 0;
176+
virtual const char* GetProductCommonDataDir ( void ) = 0;
177+
virtual const char* GetProductVersion ( void ) = 0;
175178
};
176179

177180
class CClientTime

Client/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
#define _ASE_VERSION QUOTE_DEFINE(MTASA_VERSION_MAJOR) "." QUOTE_DEFINE(MTASA_VERSION_MINOR)
7777
#define _NETCODE_VERSION_BRANCH_ID 0x4 // Use 0x1 - 0xF to indicate an incompatible branch is being used (0x0 is reserved, 0x4 is trunk)
78-
#define _CLIENT_NET_MODULE_VERSION 0x09F // (0x000 - 0xfff) Lvl9 wizards only
78+
#define _CLIENT_NET_MODULE_VERSION 0x0A0 // (0x000 - 0xfff) Lvl9 wizards only
7979
#define _NETCODE_VERSION 0x1DA // (0x000 - 0xfff) Increment when net messages change (pre-release)
8080
#define MTA_DM_BITSTREAM_VERSION 0x067 // (0x000 - 0xfff) Increment when net messages change (post-release). (Changing will also require additional backward compatibility code).
8181

Shared/sdk/SharedUtil.File.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,12 @@ SString SharedUtil::GetSystemTempPath ( void )
375375

376376
SString SharedUtil::GetMTADataPath ( void )
377377
{
378-
return PathJoin ( GetSystemCommonAppDataPath(), "MTA San Andreas All", GetMajorVersionString () );
378+
return PathJoin ( GetSystemCommonAppDataPath(), GetProductCommonDataDir(), GetMajorVersionString () );
379379
}
380380

381381
SString SharedUtil::GetMTADataPathCommon ( void )
382382
{
383-
return PathJoin ( GetSystemCommonAppDataPath(), "MTA San Andreas All", "Common" );
383+
return PathJoin ( GetSystemCommonAppDataPath(), GetProductCommonDataDir(), "Common" );
384384
}
385385

386386
SString SharedUtil::GetMTATempPath ( void )

Shared/sdk/SharedUtil.Misc.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ namespace SharedUtil
3737
void SetCommonRegistryValue ( const SString& strPath, const SString& strName, const SString& strValue );
3838
SString GetCommonRegistryValue ( const SString& strPath, const SString& strName );
3939

40-
// Get/set registry values for particular version using the old (HKCU) layout
41-
void SetVersionRegistryValueLegacy ( const SString& strVersion, const SString& strPath, const SString& strName, const SString& strValue );
42-
SString GetVersionRegistryValueLegacy ( const SString& strVersion, const SString& strPath, const SString& strName );
43-
4440

4541
bool ShellExecuteBlocking ( const SString& strAction, const SString& strFile, const SString& strParameters = "", const SString& strDirectory = "", int nShowCmd = 1 );
4642
bool ShellExecuteNonBlocking ( const SString& strAction, const SString& strFile, const SString& strParameters = "", const SString& strDirectory = "", int nShowCmd = 1 );
@@ -123,6 +119,13 @@ namespace SharedUtil
123119
void WatchDogSetLastRunCrash ( bool bOn );
124120
void WatchDogUserDidInteractWithMenu ( void );
125121

122+
void SetProductRegistryPath ( const SString& strRegistryPath );
123+
const SString& GetProductRegistryPath ( void );
124+
void SetProductCommonDataDir ( const SString& strCommonDataDir );
125+
const SString& GetProductCommonDataDir ( void );
126+
void SetProductVersion ( const SString& strVersion );
127+
const SString& GetProductVersion ( void );
128+
126129
// BrowseToSolution flags
127130
enum
128131
{

Shared/sdk/SharedUtil.Misc.hpp

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434

3535
CCriticalSection CRefCountable::ms_CS;
3636
std::map < uint, uint > ms_ReportAmountMap;
37+
SString ms_strProductRegistryPath;
38+
SString ms_strProductCommonDataDir;
39+
SString ms_strProductVersion;
3740

3841
struct SReportLine
3942
{
@@ -46,6 +49,8 @@ CDuplicateLineFilter < SReportLine > ms_ReportLineFilter;
4649

4750
#ifdef MTA_CLIENT
4851

52+
#define PRODUCT_REGISTRY_PATH "Software\\Multi Theft Auto: San Andreas All" // HKLM
53+
#define PRODUCT_COMMON_DATA_DIR "MTA San Andreas All" // C:\ProgramData
4954
#define TROUBLE_URL1 "http://updatesa.multitheftauto.com/sa/trouble/?v=_VERSION_&id=_ID_&tr=_TROUBLE_"
5055

5156

@@ -192,36 +197,6 @@ SString SharedUtil::GetSystemRegistryValue ( uint hKey, const SString& strPath,
192197
}
193198

194199

195-
196-
// Old layout:
197-
// HKCU Software\\Multi Theft Auto: San Andreas\\ - For 1.0
198-
// HKCU Software\\Multi Theft Auto: San Andreas 1.1\\ - For 1.1
199-
//
200-
static SString MakeVersionRegistryPathLegacy ( const SString& strVersion, const SString& strPath )
201-
{
202-
SString strResult = "Software\\Multi Theft Auto: San Andreas";
203-
if ( strVersion != "1.0" )
204-
strResult += " " + strVersion;
205-
206-
strResult = PathJoin ( strResult, strPath );
207-
strResult = strResult.TrimEnd ( "\\" );
208-
return strResult;
209-
}
210-
211-
212-
// Get/set registry values for a version using the old (HKCU) layout
213-
void SharedUtil::SetVersionRegistryValueLegacy ( const SString& strVersion, const SString& strPath, const SString& strName, const SString& strValue )
214-
{
215-
WriteRegistryStringValue ( HKEY_CURRENT_USER, MakeVersionRegistryPathLegacy ( strVersion, strPath ), strName, strValue );
216-
}
217-
218-
SString SharedUtil::GetVersionRegistryValueLegacy ( const SString& strVersion, const SString& strPath, const SString& strName )
219-
{
220-
return ReadRegistryStringValue ( HKEY_CURRENT_USER, MakeVersionRegistryPathLegacy ( strVersion, strPath ), strName, NULL );
221-
}
222-
223-
224-
225200
//
226201
// New layout:
227202
// HKLM Software\\Multi Theft Auto: San Andreas All\\Common - For all versions
@@ -230,7 +205,7 @@ SString SharedUtil::GetVersionRegistryValueLegacy ( const SString& strVersion, c
230205
//
231206
static SString MakeVersionRegistryPath ( const SString& strVersion, const SString& strPath )
232207
{
233-
SString strResult = PathJoin ( "Software\\Multi Theft Auto: San Andreas All", strVersion, strPath );
208+
SString strResult = PathJoin ( GetProductRegistryPath(), strVersion, strPath );
234209
return strResult.TrimEnd ( "\\" );
235210
}
236211

@@ -542,6 +517,45 @@ void SharedUtil::WatchDogUserDidInteractWithMenu( void )
542517
}
543518

544519

520+
void SharedUtil::SetProductRegistryPath( const SString& strRegistryPath )
521+
{
522+
assert( ms_strProductRegistryPath.empty() && !strRegistryPath.empty() );
523+
ms_strProductRegistryPath = strRegistryPath;
524+
}
525+
526+
const SString& SharedUtil::GetProductRegistryPath( void )
527+
{
528+
if ( ms_strProductRegistryPath.empty() )
529+
ms_strProductRegistryPath = PRODUCT_REGISTRY_PATH;
530+
return ms_strProductRegistryPath;
531+
}
532+
533+
void SharedUtil::SetProductCommonDataDir( const SString& strCommonDataDir )
534+
{
535+
assert( ms_strProductCommonDataDir.empty() && !strCommonDataDir.empty() );
536+
ms_strProductCommonDataDir = strCommonDataDir;
537+
}
538+
539+
const SString& SharedUtil::GetProductCommonDataDir( void )
540+
{
541+
if ( ms_strProductCommonDataDir.empty() )
542+
ms_strProductCommonDataDir = PRODUCT_COMMON_DATA_DIR;
543+
return ms_strProductCommonDataDir;
544+
}
545+
546+
void SharedUtil::SetProductVersion( const SString& strVersion )
547+
{
548+
assert( ms_strProductVersion.empty() && !strVersion.empty() );
549+
ms_strProductVersion = strVersion;
550+
}
551+
552+
const SString& SharedUtil::GetProductVersion( void )
553+
{
554+
if ( ms_strProductVersion.empty() )
555+
ms_strProductVersion = SString( "%d.%d.%d-%d.%05d", MTASA_VERSION_MAJOR, MTASA_VERSION_MINOR, MTASA_VERSION_MAINTENANCE, MTASA_VERSION_TYPE, MTASA_VERSION_BUILD );
556+
return ms_strProductVersion;
557+
}
558+
545559
void SharedUtil::SetClipboardText ( const SString& strText )
546560
{
547561
// If we got something to copy

0 commit comments

Comments
 (0)