mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-06-18 14:40:56 +00:00
Fix for custom document location
This commit is contained in:
+9
-6
@@ -22,16 +22,19 @@ std::string GetGamePath(){
|
|||||||
LPCTSTR sk = "Software\\BeamNG\\BeamNG.drive";
|
LPCTSTR sk = "Software\\BeamNG\\BeamNG.drive";
|
||||||
LONG openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey);
|
LONG openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey);
|
||||||
if (openRes != ERROR_SUCCESS){
|
if (openRes != ERROR_SUCCESS){
|
||||||
fatal("Please launch the game at least once");
|
fatal("Please launch the game at least once!");
|
||||||
}
|
}
|
||||||
Path = QueryKey(hKey,4);
|
Path = QueryKey(hKey,4);
|
||||||
|
|
||||||
if(Path.empty()){
|
if(Path.empty()){
|
||||||
size_t RS;
|
sk = R"(SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders)";
|
||||||
getenv_s(&RS, nullptr, 0, "USERPROFILE");
|
|
||||||
std::string P(RS-1,0);
|
openRes = RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_ALL_ACCESS, &hKey);
|
||||||
getenv_s(&RS, &P[0], RS, "USERPROFILE");
|
if (openRes != ERROR_SUCCESS){
|
||||||
Path = P + R"(\Documents\BeamNG.drive\)";
|
fatal("Cannot get Documents directory!");
|
||||||
|
}
|
||||||
|
Path = QueryKey(hKey,5);
|
||||||
|
Path += "\\";
|
||||||
return Path;
|
return Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ std::string QueryKey(HKEY hKey,int ID){
|
|||||||
case 2: if(key == "Name" && data == "BeamNG.drive")return data;break;
|
case 2: if(key == "Name" && data == "BeamNG.drive")return data;break;
|
||||||
case 3: if(key == "rootpath")return data;break;
|
case 3: if(key == "rootpath")return data;break;
|
||||||
case 4: if(key == "userpath_override")return data;
|
case 4: if(key == "userpath_override")return data;
|
||||||
|
case 5: if(key == "Personal")return data;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user