mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
fix nlohmann potential throw in ped outfit (#2894)
This commit is contained in:
parent
d63f712e5e
commit
6e0358737f
@ -1,11 +1,11 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "core/scr_globals.hpp"
|
||||
#include "file_manager.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "logger/logger.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "pointers.hpp"
|
||||
#include "services/outfit/outfit_service.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "core/scr_globals.hpp"
|
||||
#include "services/tunables/tunables_service.hpp"
|
||||
|
||||
namespace big
|
||||
@ -15,13 +15,13 @@ namespace big
|
||||
int offset = 0;
|
||||
switch (model)
|
||||
{
|
||||
case "mp_m_freemode_01"_J: break;
|
||||
case "mp_f_freemode_01"_J:
|
||||
{
|
||||
offset = 1;
|
||||
break;
|
||||
}
|
||||
default: return false; //For non-normal models
|
||||
case "mp_m_freemode_01"_J: break;
|
||||
case "mp_f_freemode_01"_J:
|
||||
{
|
||||
offset = 1;
|
||||
break;
|
||||
}
|
||||
default: return false; //For non-normal models
|
||||
}
|
||||
|
||||
return PED::GET_PED_DRAWABLE_VARIATION(self::ped, ComponentId::AUXILIARY) == 15 && PED::GET_PED_DRAWABLE_VARIATION(self::ped, ComponentId::TORSO) == 15 && PED::GET_PED_DRAWABLE_VARIATION(self::ped, ComponentId::LEGS) == (14 + offset);
|
||||
@ -52,11 +52,28 @@ namespace big
|
||||
|
||||
if (persisting_outfit != g.self.persist_outfit)
|
||||
{
|
||||
persisting_outfit = g.self.persist_outfit;
|
||||
folder saved_outfit_path = g_file_manager.get_project_folder("saved_outfits");
|
||||
std::ifstream i(saved_outfit_path.get_file(persisting_outfit).get_path());
|
||||
outfit.clear();
|
||||
i >> outfit;
|
||||
persisting_outfit = g.self.persist_outfit;
|
||||
folder saved_outfit_path = g_file_manager.get_project_folder("saved_outfits");
|
||||
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();
|
||||
try
|
||||
{
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user