fix nlohmann potential throw in ped outfit (#2894)

This commit is contained in:
Quentin 2024-03-30 18:42:04 +01:00 committed by GitHub
parent 1f556a8c78
commit 629cff293a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,11 +1,11 @@
#include "backend/looped/looped.hpp" #include "backend/looped/looped.hpp"
#include "core/scr_globals.hpp"
#include "file_manager.hpp" #include "file_manager.hpp"
#include "gta/enums.hpp"
#include "logger/logger.hpp" #include "logger/logger.hpp"
#include "natives.hpp" #include "natives.hpp"
#include "pointers.hpp" #include "pointers.hpp"
#include "services/outfit/outfit_service.hpp" #include "services/outfit/outfit_service.hpp"
#include "gta/enums.hpp"
#include "core/scr_globals.hpp"
#include "services/tunables/tunables_service.hpp" #include "services/tunables/tunables_service.hpp"
namespace big namespace big
@ -54,10 +54,27 @@ namespace big
{ {
persisting_outfit = g.self.persist_outfit; persisting_outfit = g.self.persist_outfit;
folder saved_outfit_path = g_file_manager.get_project_folder("saved_outfits"); folder saved_outfit_path = g_file_manager.get_project_folder("saved_outfits");
std::ifstream i(saved_outfit_path.get_file(persisting_outfit).get_path()); const auto persist_outfit_file_path = saved_outfit_path.get_file(persisting_outfit).get_path();
if (std::filesystem::exists(persist_outfit_file_path))
{
std::ifstream i(persist_outfit_file_path);
if (i.is_open())
{
outfit.clear(); outfit.clear();
try
{
i >> outfit; i >> outfit;
} }
catch (const std::exception& e)
{
LOG(INFO) << e.what();
outfit = {};
g.self.persist_outfit = "";
}
}
}
}
if (outfit.contains("model") && outfit["model"].get<uint32_t>() == model) if (outfit.contains("model") && outfit["model"].get<uint32_t>() == model)
outfit_service::apply_outfit(outfit, false); outfit_service::apply_outfit(outfit, false);