feat(protection): model mismatch (#1014)
This commit is contained in:
parent
60b61cbce2
commit
5e3c08ce23
@ -552,6 +552,8 @@ namespace big
|
|||||||
|
|
||||||
inline bool is_crash_ped(uint32_t model)
|
inline bool is_crash_ped(uint32_t model)
|
||||||
{
|
{
|
||||||
|
if (!model_info::is_model_of_type(model, eModelType::Ped, eModelType::OnlineOnlyPed))
|
||||||
|
return true;
|
||||||
for (auto iterator : crash_peds)
|
for (auto iterator : crash_peds)
|
||||||
if (iterator == model)
|
if (iterator == model)
|
||||||
return true;
|
return true;
|
||||||
@ -560,6 +562,8 @@ namespace big
|
|||||||
|
|
||||||
inline bool is_crash_vehicle(uint32_t model)
|
inline bool is_crash_vehicle(uint32_t model)
|
||||||
{
|
{
|
||||||
|
if (!model_info::is_model_of_type(model, eModelType::Vehicle, eModelType::Unk133))
|
||||||
|
return true;
|
||||||
for (auto iterator : crash_vehicles)
|
for (auto iterator : crash_vehicles)
|
||||||
if (iterator == model)
|
if (iterator == model)
|
||||||
return true;
|
return true;
|
||||||
@ -568,6 +572,8 @@ namespace big
|
|||||||
|
|
||||||
inline bool is_crash_object(uint32_t model)
|
inline bool is_crash_object(uint32_t model)
|
||||||
{
|
{
|
||||||
|
if (!model_info::is_model_of_type(model, eModelType::Object, eModelType::Time, eModelType::Weapon, eModelType::Destructable, eModelType::WorldObject, eModelType::Sprinkler, eModelType::Unk65, eModelType::Plant, eModelType::LOD, eModelType::Unk132, eModelType::Building))
|
||||||
|
return true;
|
||||||
for (auto iterator : crash_objects)
|
for (auto iterator : crash_objects)
|
||||||
if (iterator == model)
|
if (iterator == model)
|
||||||
return true;
|
return true;
|
||||||
@ -614,6 +620,16 @@ namespace big
|
|||||||
|
|
||||||
switch (node_hash)
|
switch (node_hash)
|
||||||
{
|
{
|
||||||
|
case (RAGE_JOAAT("CVehicleCreationDataNode")):
|
||||||
|
{
|
||||||
|
const auto creation_node = (CVehicleCreationDataNode*)(node);
|
||||||
|
if (is_crash_vehicle(creation_node->m_model))
|
||||||
|
{
|
||||||
|
notify::crash_blocked(sender, "invalid vehicle model");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case RAGE_JOAAT("CDoorCreationDataNode"):
|
case RAGE_JOAAT("CDoorCreationDataNode"):
|
||||||
{
|
{
|
||||||
const auto creation_node = (CDoorCreationDataNode*)(node);
|
const auto creation_node = (CDoorCreationDataNode*)(node);
|
||||||
@ -627,7 +643,7 @@ namespace big
|
|||||||
case RAGE_JOAAT("CPickupCreationDataNode"):
|
case RAGE_JOAAT("CPickupCreationDataNode"):
|
||||||
{
|
{
|
||||||
const auto creation_node = (CPickupCreationDataNode*)(node);
|
const auto creation_node = (CPickupCreationDataNode*)(node);
|
||||||
if (is_crash_object(creation_node->m_custom_model))
|
if (creation_node->m_custom_model && is_crash_object(creation_node->m_custom_model))
|
||||||
{
|
{
|
||||||
notify::crash_blocked(sender, "invalid pickup model");
|
notify::crash_blocked(sender, "invalid pickup model");
|
||||||
return true;
|
return true;
|
||||||
|
@ -55,11 +55,16 @@ namespace big
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_model_of_type(const rage::joaat_t hash, const eModelType type)
|
template<typename T, typename ...Args>
|
||||||
|
static bool is_model_of_type(const rage::joaat_t hash, const T arg, const Args... args)
|
||||||
{
|
{
|
||||||
if (const auto model = model_info::get_model(hash); model && model->m_model_type == type)
|
bool of_type = false;
|
||||||
return true;
|
if (const auto model = model_info::get_model(hash))
|
||||||
return false;
|
{
|
||||||
|
of_type = model->m_model_type == arg;
|
||||||
|
([&of_type, &model](eModelType type) { of_type |= model->m_model_type == type; }(args), ...);
|
||||||
|
}
|
||||||
|
return of_type;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
Reference in New Issue
Block a user