mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-06-19 23:20:57 +00:00
fixed count forcing null byte at the end of query string
This commit is contained in:
@@ -14,6 +14,7 @@ struct VersionParser {
|
|||||||
explicit VersionParser(const std::string& from_string);
|
explicit VersionParser(const std::string& from_string);
|
||||||
std::strong_ordering operator<=>(VersionParser const& rhs) const noexcept;
|
std::strong_ordering operator<=>(VersionParser const& rhs) const noexcept;
|
||||||
bool operator==(VersionParser const& rhs) const noexcept;
|
bool operator==(VersionParser const& rhs) const noexcept;
|
||||||
|
std::vector<std::string> split;
|
||||||
std::vector<size_t> data;
|
std::vector<size_t> data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -50,7 +50,7 @@ std::string QueryValue(HKEY& hKey, const char* Name) {
|
|||||||
DWORD keySize;
|
DWORD keySize;
|
||||||
BYTE buffer[16384];
|
BYTE buffer[16384];
|
||||||
if(RegQueryValueExA(hKey, Name, nullptr, nullptr, buffer, &keySize) == ERROR_SUCCESS) {
|
if(RegQueryValueExA(hKey, Name, nullptr, nullptr, buffer, &keySize) == ERROR_SUCCESS) {
|
||||||
return {(char*)buffer, keySize};
|
return {(char*)buffer, keySize-1};
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ std::string Launcher::GetLocalAppdata() {
|
|||||||
if(!Path.empty()) {
|
if(!Path.empty()) {
|
||||||
Path += "\\BeamNG.drive\\";
|
Path += "\\BeamNG.drive\\";
|
||||||
VersionParser GameVer(BeamVersion);
|
VersionParser GameVer(BeamVersion);
|
||||||
Path += std::to_string(GameVer.data[0]) + '.' + std::to_string(GameVer.data[1]) + '\\';
|
Path += GameVer.split[0] + '.' + GameVer.split[1] + '\\';
|
||||||
return Path;
|
return Path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,9 +78,9 @@ void Launcher::QueryRegistry() {
|
|||||||
RegCloseKey(BeamNG);
|
RegCloseKey(BeamNG);
|
||||||
if(BeamUserPath.empty() && !BeamVersion.empty()) {
|
if(BeamUserPath.empty() && !BeamVersion.empty()) {
|
||||||
BeamUserPath = GetLocalAppdata();
|
BeamUserPath = GetLocalAppdata();
|
||||||
} else if(!BeamUserPath.empty()) {
|
} else if(!BeamUserPath.empty() && !BeamVersion.empty()) {
|
||||||
VersionParser GameVer(BeamVersion);
|
VersionParser GameVer(BeamVersion);
|
||||||
BeamUserPath += std::to_string(GameVer.data[0]) + '.' + std::to_string(GameVer.data[1]) + '\\';
|
BeamUserPath += GameVer.split[0] + '.' + GameVer.split[1] + '\\';
|
||||||
}
|
}
|
||||||
if(!BeamRoot.empty() && !BeamVersion.empty() && !BeamUserPath.empty())return;
|
if(!BeamRoot.empty() && !BeamVersion.empty() && !BeamUserPath.empty())return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ VersionParser::VersionParser(const std::string &from_string) {
|
|||||||
std::istringstream tokenStream(from_string);
|
std::istringstream tokenStream(from_string);
|
||||||
while (std::getline(tokenStream, token, '.')) {
|
while (std::getline(tokenStream, token, '.')) {
|
||||||
data.emplace_back(std::stol(token));
|
data.emplace_back(std::stol(token));
|
||||||
|
split.emplace_back(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user