[General] Housekeeping stuff and a NPE fix

This commit is contained in:
TheApadayo 2017-02-06 15:09:41 -05:00
parent 547fec18bd
commit d524092944
7 changed files with 21 additions and 18 deletions

View File

@ -41,7 +41,7 @@ namespace Components
{ {
if (Auth::TokenContainer.command.empty()) if (Auth::TokenContainer.command.empty())
{ {
Game::MessageBox(Utils::String::VA("Your new security level is %d", Auth::GetSecurityLevel()), "Success"); Game::ShowMessageBox(Utils::String::VA("Your new security level is %d", Auth::GetSecurityLevel()), "Success");
} }
else else
{ {

View File

@ -484,7 +484,10 @@ namespace Components
Friends::ClearPresence("iw4x_playing"); Friends::ClearPresence("iw4x_playing");
#ifdef DEBUG #ifdef DEBUG
if (Steam::Proxy::SteamFriends)
{
Steam::Proxy::SteamFriends->ClearRichPresence(); Steam::Proxy::SteamFriends->ClearRichPresence();
}
#endif #endif
if(Steam::Proxy::SteamLegacyFriends) if(Steam::Proxy::SteamLegacyFriends)
@ -525,9 +528,8 @@ namespace Components
Steam::Proxy::UnregisterCallback(336); Steam::Proxy::UnregisterCallback(336);
Steam::Proxy::UnregisterCallback(304); Steam::Proxy::UnregisterCallback(304);
{
std::lock_guard<std::recursive_mutex> _(Friends::Mutex); std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
Friends::FriendsList.clear(); Friends::FriendsList.clear();
}
} }
} }

View File

@ -521,13 +521,13 @@ namespace Components
{ {
if (map == std::string(mapname)) if (map == std::string(mapname))
{ {
if(error) Components::Logger::SoftError("Missing DLC pack %s (%d) containing map %s (%s).\nPlease download it to play this map.", Components::Logger::SoftError("Missing DLC pack %s (%d) containing map %s (%s).\nPlease download it to play this map.",
pack.name.data(), pack.index, Game::UI_LocalizeMapName(mapname), mapname); pack.name.data(), pack.index, Game::UI_LocalizeMapName(mapname), mapname);
} }
} }
} }
if (error) Components::Logger::SoftError("Missing map file %s.\nYou may have a damaged installation or are attempting to load a non-existant map.", mapname); Components::Logger::SoftError("Missing map file %s.\nYou may have a damaged installation or are attempting to load a non-existant map.", mapname);
return false; return false;
} }
@ -561,7 +561,7 @@ namespace Components
} }
} }
Game::MessageBox(Utils::String::VA("DLC %d does not exist!", dlc), "ERROR"); Game::ShowMessageBox(Utils::String::VA("DLC %d does not exist!", dlc), "ERROR");
}); });
}); });

View File

@ -149,7 +149,7 @@ namespace Components
{ {
Localization::ClearTemp(); Localization::ClearTemp();
Command::Execute("closemenu popup_reconnectingtoparty", false); Command::Execute("closemenu popup_reconnectingtoparty", false);
Game::MessageBox("Failed to download the updater!", "Error"); Game::ShowMessageBox("Failed to download the updater!", "Error");
} }
else else
{ {

View File

@ -292,7 +292,7 @@ namespace Components
if (!object.is_array()) if (!object.is_array())
{ {
Logger::Print("Favourites storage file is invalid!\n"); Logger::Print("Favourites storage file is invalid!\n");
Game::MessageBox("Favourites storage file is invalid!", "Error"); Game::ShowMessageBox("Favourites storage file is invalid!", "Error");
return; return;
} }
@ -303,7 +303,7 @@ namespace Components
if (!storedServers[i].is_string()) continue; if (!storedServers[i].is_string()) continue;
if (storedServers[i].string_value() == server) if (storedServers[i].string_value() == server)
{ {
Game::MessageBox("Server already marked as favourite.", "Error"); Game::ShowMessageBox("Server already marked as favourite.", "Error");
return; return;
} }
@ -315,7 +315,7 @@ namespace Components
json11::Json data = json11::Json(servers); json11::Json data = json11::Json(servers);
Utils::IO::WriteFile("players/favourites.json", data.dump()); Utils::IO::WriteFile("players/favourites.json", data.dump());
Game::MessageBox("Server added to favourites.", "Success"); Game::ShowMessageBox("Server added to favourites.", "Success");
} }
void ServerList::RemoveFavourite(std::string server) void ServerList::RemoveFavourite(std::string server)
@ -330,7 +330,7 @@ namespace Components
if (!object.is_array()) if (!object.is_array())
{ {
Logger::Print("Favourites storage file is invalid!\n"); Logger::Print("Favourites storage file is invalid!\n");
Game::MessageBox("Favourites storage file is invalid!", "Error"); Game::ShowMessageBox("Favourites storage file is invalid!", "Error");
return; return;
} }
@ -351,7 +351,7 @@ namespace Components
ServerList::RefreshVisibleList(UIScript::Token()); ServerList::RefreshVisibleList(UIScript::Token());
Game::MessageBox("Server removed from favourites.", "Success"); Game::ShowMessageBox("Server removed from favourites.", "Success");
} }
void ServerList::LoadFavourties() void ServerList::LoadFavourties()
@ -367,7 +367,7 @@ namespace Components
if (!object.is_array()) if (!object.is_array())
{ {
Logger::Print("Favourites storage file is invalid!\n"); Logger::Print("Favourites storage file is invalid!\n");
Game::MessageBox("Favourites storage file is invalid!", "Error"); Game::ShowMessageBox("Favourites storage file is invalid!", "Error");
return; return;
} }

View File

@ -508,7 +508,8 @@ namespace Game
} }
} }
void MessageBox(std::string message, std::string title) // this cant be MessageBox because windows.h has a define that converts it to MessageBoxW. which is just stupid
void ShowMessageBox(std::string message, std::string title)
{ {
if (!Game::CL_IsCgameInitialized()) if (!Game::CL_IsCgameInitialized())
{ {

View File

@ -719,7 +719,7 @@ namespace Game
void FS_AddLocalizedGameDirectory(const char *path, const char *dir); void FS_AddLocalizedGameDirectory(const char *path, const char *dir);
void MessageBox(std::string message, std::string title); void ShowMessageBox(std::string message, std::string title);
unsigned int R_HashString(const char* string); unsigned int R_HashString(const char* string);
void R_LoadSunThroughDvars(const char* mapname, sunflare_t* sun); void R_LoadSunThroughDvars(const char* mapname, sunflare_t* sun);