Skip to content

Commit

Permalink
isValidModel update
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha committed Nov 26, 2024
1 parent cbad928 commit ab63086
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Client/mods/deathmatch/logic/luadefs/CLuaModelDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,22 @@ void CLuaModelDefs::LoadFunctions()
CLuaCFunctions::AddFunction(name, func);
}


bool CLuaModelDefs::IsValidModel(std::string modelPurpose, std::uint32_t id)
{
if (modelPurpose == "object")
return CClientObjectManager::IsValidModel(id);
else if (modelPurpose == "weapon")
return CClientPedManager::IsValidWeaponModel(id);
else if (modelPurpose == "upgrade")
return CVehicleUpgrades::IsUpgrade(id);
else if (modelPurpose == "building")
return CClientBuildingManager::IsValidModel(id);
else if (modelPurpose == "vehicle")
return CClientVehicleManager::IsValidModel(id);
else if (modelPurpose == "ped" || modelPurpose == "player")
return CClientPlayerManager::IsValidModel(id);

throw std::invalid_argument("Invalid model purpose passed, expected 'object' or 'building'");
throw std::invalid_argument("Invalid model purpose passed, expected [object, weapon, upgrade, building, vehicle, ped, player]");
}

std::variant<bool, std::uint32_t> CLuaModelDefs::GetLowLODModel(std::uint32_t hLODModel) noexcept
Expand All @@ -57,11 +64,14 @@ std::variant<bool, std::uint32_t> CLuaModelDefs::GetHighLODModel(std::uint32_t l

bool CLuaModelDefs::SetLowLODModel(std::string modelPurpose, std::uint32_t hLODModel, std::uint32_t lLODModel)
{
if (!(modelPurpose == "object" || modelPurpose == "building"))
throw std::invalid_argument("Invalid model purpose passed, the only options for LOD are 'object' or 'building'");

if (!IsValidModel(modelPurpose, hLODModel))
throw std::invalid_argument("Invalid model ID passed for High-LOD argument");
throw std::invalid_argument("Invalid High-LOD model ID passed");

if (!IsValidModel(modelPurpose, lLODModel))
throw std::invalid_argument("Invalid model ID passed for Low-LOD argument");
throw std::invalid_argument("Invalid Low-LOD model ID passed");

return CLodModels::SetLowLODModel(hLODModel, lLODModel);
}
Expand Down

0 comments on commit ab63086

Please sign in to comment.