fix nlohmann potential throw in ped outfit (#2894)
This commit is contained in:
parent
1f556a8c78
commit
629cff293a
@ -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
|
||||||
@ -15,13 +15,13 @@ namespace big
|
|||||||
int offset = 0;
|
int offset = 0;
|
||||||
switch (model)
|
switch (model)
|
||||||
{
|
{
|
||||||
case "mp_m_freemode_01"_J: break;
|
case "mp_m_freemode_01"_J: break;
|
||||||
case "mp_f_freemode_01"_J:
|
case "mp_f_freemode_01"_J:
|
||||||
{
|
{
|
||||||
offset = 1;
|
offset = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: return false; //For non-normal models
|
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);
|
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)
|
if (persisting_outfit != g.self.persist_outfit)
|
||||||
{
|
{
|
||||||
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();
|
||||||
outfit.clear();
|
if (std::filesystem::exists(persist_outfit_file_path))
|
||||||
i >> outfit;
|
{
|
||||||
|
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)
|
if (outfit.contains("model") && outfit["model"].get<uint32_t>() == model)
|
||||||
|
Reference in New Issue
Block a user