fix mod loading

This commit is contained in:
Anonymous275 2022-08-28 15:38:56 +03:00
parent d5529fcf5b
commit c7e68ba10c

View File

@ -262,7 +262,7 @@ void Server::SyncResources() {
if (!std::all_of(FS->begin(), FS->end(), isdigit)) continue; if (!std::all_of(FS->begin(), FS->end(), isdigit)) continue;
if (fs::file_size(a) == std::stoull(*FS)) { if (fs::file_size(a) == std::stoull(*FS)) {
UpdateUl(false, std::to_string(Pos) + "/" + std::to_string(Amount) + UpdateUl(false, std::to_string(Pos) + "/" + std::to_string(Amount) +
": " + a.substr(a.find_last_of('/'))); ": " + a.substr(a.find_last_of("/\\")));
std::this_thread::sleep_for(std::chrono::milliseconds(50)); std::this_thread::sleep_for(std::chrono::milliseconds(50));
try { try {
if (!fs::exists(LauncherInstance->getMPUserPath())) { if (!fs::exists(LauncherInstance->getMPUserPath())) {
@ -270,7 +270,7 @@ void Server::SyncResources() {
} }
fs::copy_file(a, fs::copy_file(a,
LauncherInstance->getMPUserPath() / LauncherInstance->getMPUserPath() /
a.substr(a.find_last_of('/')+1), a.substr(a.find_last_of("/\\")+1),
fs::copy_options::overwrite_existing); fs::copy_options::overwrite_existing);
} catch (std::exception& e) { } catch (std::exception& e) {
LOG(ERROR) << "Failed copy to the mods folder! " << e.what(); LOG(ERROR) << "Failed copy to the mods folder! " << e.what();
@ -282,7 +282,7 @@ void Server::SyncResources() {
} else remove(a.c_str()); } else remove(a.c_str());
} }
CheckForDir(); CheckForDir();
std::string FName = a.substr(a.find_last_of('/')+1); std::string FName = a.substr(a.find_last_of("/\\")+1);
do { do {
TCPSend("f" + *FN); TCPSend("f" + *FN);
@ -313,7 +313,7 @@ void Server::SyncResources() {
if (!fs::exists(LauncherInstance->getMPUserPath())) { if (!fs::exists(LauncherInstance->getMPUserPath())) {
fs::create_directories(LauncherInstance->getMPUserPath()); fs::create_directories(LauncherInstance->getMPUserPath());
} }
fs::copy_file(a, LauncherInstance->getMPUserPath()/FName, fs::copy_file(a, LauncherInstance->getMPUserPath()/fs::path(FName).filename(),
fs::copy_options::overwrite_existing); fs::copy_options::overwrite_existing);
} }
WaitForConfirm(); WaitForConfirm();