fix guest account issue and uppercase mods

This commit is contained in:
gamingdoom 2023-10-17 20:39:40 -07:00
parent 8ead91c527
commit 1bf7faa34d
3 changed files with 24 additions and 11 deletions

View File

@ -224,10 +224,6 @@ std::string MultiDownload(SOCKET MSock,SOCKET DSock, uint64_t Size, const std::s
memcpy(&Ret[MSize],DData,DSize);
delete[]DData;
// std::string Ret = std::string(MData) + std::string(DData);
// delete []MData;
// delete []DData;
return Ret;
}
@ -287,7 +283,16 @@ void SyncResources(SOCKET Sock){
if(!fs::exists(GetGamePath() + "mods/multiplayer")){
fs::create_directories(GetGamePath() + "mods/multiplayer");
}
fs::copy_file(a, GetGamePath() + "mods/multiplayer" + a.substr(a.find_last_of('/')),
std::string FName = a.substr(a.find_last_of('/'));
// Linux version of the game doesnt support uppercase letters in mod names
#if defined(__linux__)
for(char &c : FName){
c = ::tolower(c);
}
#endif
fs::copy_file(a, GetGamePath() + "mods/multiplayer" + FName,
fs::copy_options::overwrite_existing);
} catch (std::exception& e) {
error("Failed copy to the mods folder! " + std::string(e.what()));
@ -328,6 +333,14 @@ void SyncResources(SOCKET Sock){
if(!fs::exists(GetGamePath() + "mods/multiplayer")){
fs::create_directories(GetGamePath() + "mods/multiplayer");
}
// Linux version of the game doesnt support uppercase letters in mod names
#if defined(__linux__)
for(char &c : FName){
c = ::tolower(c);
}
#endif
fs::copy_file(a,GetGamePath() + "mods/multiplayer" + FName, fs::copy_options::overwrite_existing);
}
WaitForConfirm();

View File

@ -58,17 +58,17 @@ std::string Login(const std::string& fields){
error(Buffer);
return GetFail("Invalid answer from authentication servers, please try again later!");
}
if(!d["success"].IsNull() && d["success"].GetBool()){
if(d.HasMember("success") && !d["success"].IsNull() && d["success"].GetBool()){
LoginAuth = true;
if(!d["private_key"].IsNull()){
if(d.HasMember("private_key") && !d["private_key"].IsNull()){
UpdateKey(d["private_key"].GetString());
}
if(!d["public_key"].IsNull()){
if(d.HasMember("public_key") && !d["public_key"].IsNull()){
PublicKey = d["public_key"].GetString();
}
info("Authentication successful!");
}else info("Authentication failed!");
if(!d["message"].IsNull()){
if(d.HasMember("message") && !d["message"].IsNull()){
d.RemoveMember("private_key");
d.RemoveMember("public_key");
rapidjson::StringBuffer buffer;
@ -104,7 +104,7 @@ void CheckLocalKey(){
info("Invalid answer from authentication servers.");
UpdateKey(nullptr);
}
if(d["success"].GetBool()){
if(d.HasMember("success") && d["success"].GetBool()){
LoginAuth = true;
UpdateKey(d["private_key"].GetString());
PublicKey = d["public_key"].GetString();

View File

@ -285,7 +285,7 @@ void EnableMP(){
//error("Failed to parse " + File); //TODO illegal formatting
return;
}
if(!d["mods"].IsNull() && !d["mods"]["multiplayerbeammp"].IsNull()){
if(d.HasMember("mods") && !d["mods"].IsNull() && d["mods"].HasMember("multiplayerbeammp") && !d["mods"]["multiplayerbeammp"].IsNull()){
d["mods"]["multiplayerbeammp"]["active"] = true;
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);