Fix bug with BP and not having a trailing slash by default

This commit is contained in:
Vali0004 2025-08-02 00:21:40 -04:00
parent 7a4b24d616
commit f27d3c6120
3 changed files with 8 additions and 9 deletions

View File

@ -236,7 +236,7 @@ namespace Utils {
for (size_t i = 0; i < sha256_len; i++) { for (size_t i = 0; i < sha256_len; i++) {
char buf[3]; char buf[3];
sprintf(buf, "%02x", sha256_value[i]); sprintf(buf, "%02x", sha256_value[i]);
buf[2] = NULL; buf[2] = '\0';
result += buf; result += buf;
} }
return result; return result;
@ -280,7 +280,7 @@ namespace Utils {
for (size_t i = 0; i < sha256_len; i++) { for (size_t i = 0; i < sha256_len; i++) {
char buf[3]; char buf[3];
sprintf(buf, "%02x", sha256_value[i]); sprintf(buf, "%02x", sha256_value[i]);
buf[2] = NULL; buf[2] = '\0';
result += buf; result += buf;
} }
return result; return result;

View File

@ -98,7 +98,7 @@ beammp_fs_string GetEP(const beammp_fs_char* P) {
return Ret; return Ret;
} }
beammp_fs_string GetBP(const beammp_fs_char* P) { fs::path GetBP(const beammp_fs_char* P) {
fs::path fspath = {}; fs::path fspath = {};
#if defined(_WIN32) #if defined(_WIN32)
beammp_fs_char path[256]; beammp_fs_char path[256];
@ -202,7 +202,7 @@ void CheckForUpdates(const std::string& CV) {
transform(LatestHash.begin(), LatestHash.end(), LatestHash.begin(), ::tolower); transform(LatestHash.begin(), LatestHash.end(), LatestHash.begin(), ::tolower);
beammp_fs_string BP(GetBP() / GetEN()), Back(GetBP() / beammp_wide("BeamMP-Launcher.back")); beammp_fs_string BP(GetBP() / GetEN()), Back(GetBP() / beammp_wide("BeamMP-Launcher.back"));
std::string FileHash = Utils::GetSha256HashReallyFastFile(EP); std::string FileHash = Utils::GetSha256HashReallyFastFile(BP);
if (FileHash != LatestHash && IsOutdated(Version(VersionStrToInts(GetVer() + GetPatch())), Version(VersionStrToInts(LatestVersion)))) { if (FileHash != LatestHash && IsOutdated(Version(VersionStrToInts(GetVer() + GetPatch())), Version(VersionStrToInts(LatestVersion)))) {
if (!options.no_update) { if (!options.no_update) {
@ -215,16 +215,16 @@ void CheckForUpdates(const std::string& CV) {
"https://backend.beammp.com/builds/launcher?download=true" "https://backend.beammp.com/builds/launcher?download=true"
"&pk=" "&pk="
+ PublicKey + "&branch=" + Branch, + PublicKey + "&branch=" + Branch,
beammp_wide("new_") + EP, LatestHash); beammp_wide("new_") + BP, LatestHash);
std::error_code ec; std::error_code ec;
fs::remove(Back, ec); fs::remove(Back, ec);
if (ec == std::errc::permission_denied) { if (ec == std::errc::permission_denied) {
error("Failed to remove old backup file: " + ec.message() + ". Using alternative name."); error("Failed to remove old backup file: " + ec.message() + ". Using alternative name.");
fs::rename(EP, Back + beammp_wide(".") + Utils::ToWString(FileHash.substr(0, 8))); fs::rename(BP, Back + beammp_wide(".") + Utils::ToWString(FileHash.substr(0, 8)));
} else { } else {
fs::rename(EP, Back); fs::rename(BP, Back);
} }
fs::rename(beammp_wide("new_") + EP, EP); fs::rename(beammp_wide("new_") + BP, BP);
URelaunch(); URelaunch();
#endif #endif
} else { } else {

View File

@ -39,7 +39,6 @@ int main(int argc, const char** argv) try {
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
GetEP(Utils::ToWString(std::string(argv[0])).c_str()); GetEP(Utils::ToWString(std::string(argv[0])).c_str());
info("BP Path: " + GetBP(Utils::ToWString(std::string(argv[0])).c_str()));
InitLog(); InitLog();
ConfigInit(); ConfigInit();