34
34
35
35
CCriticalSection CRefCountable::ms_CS;
36
36
std::map < uint, uint > ms_ReportAmountMap;
37
+ SString ms_strProductRegistryPath;
38
+ SString ms_strProductCommonDataDir;
39
+ SString ms_strProductVersion;
37
40
38
41
struct SReportLine
39
42
{
@@ -46,6 +49,8 @@ CDuplicateLineFilter < SReportLine > ms_ReportLineFilter;
46
49
47
50
#ifdef MTA_CLIENT
48
51
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
49
54
#define TROUBLE_URL1 " http://updatesa.multitheftauto.com/sa/trouble/?v=_VERSION_&id=_ID_&tr=_TROUBLE_"
50
55
51
56
@@ -192,36 +197,6 @@ SString SharedUtil::GetSystemRegistryValue ( uint hKey, const SString& strPath,
192
197
}
193
198
194
199
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
-
225
200
//
226
201
// New layout:
227
202
// HKLM Software\\Multi Theft Auto: San Andreas All\\Common - For all versions
@@ -230,7 +205,7 @@ SString SharedUtil::GetVersionRegistryValueLegacy ( const SString& strVersion, c
230
205
//
231
206
static SString MakeVersionRegistryPath ( const SString& strVersion, const SString& strPath )
232
207
{
233
- SString strResult = PathJoin ( " Software \\ Multi Theft Auto: San Andreas All " , strVersion, strPath );
208
+ SString strResult = PathJoin ( GetProductRegistryPath () , strVersion, strPath );
234
209
return strResult.TrimEnd ( " \\ " );
235
210
}
236
211
@@ -542,6 +517,45 @@ void SharedUtil::WatchDogUserDidInteractWithMenu( void )
542
517
}
543
518
544
519
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
+
545
559
void SharedUtil::SetClipboardText ( const SString& strText )
546
560
{
547
561
// If we got something to copy
0 commit comments