-
-
Notifications
You must be signed in to change notification settings - Fork 630
Description
๐ฆ What modules are you seeing the problem on?
ScriptHookVDotNet3.dll (v3 SDK/API)
๐ ๏ธ SHVDN Version
Between fa83ade and 110abdd (including any stable versions between v3.0.0 and v3.6.0)
๐ฎ Game Version
Any game versions
๐ Bug Description
PedProp.IsVariationValid doesn't actually test if the variation is valid but silently preload it into memory by calling the native NATIVE FUNC INT SET_PED_PRELOAD_PROP_DATA(PED_INDEX PedIndex, PED_PROP_POSITION Anchor, INT PropId, int TexId = 0) (if the variation is valid). Yes, the native was referenced as fa83ade73975b47243cdf3b71ddcc54a95b2b719 by the modding community at the time fa83ade was commited, but now we know the correct name by a leak of sch header files. Fortunately, the leak of the game's codebase reveals how SET_PED_PROP_INDEX tests the pre-conditions. We could fix the issue by testing the values of the anchor point, prop ID, and texture ID.
The defect of the method was reported by @ILaCHu (Discord: c0rsair1675), though I found out how it behaved incorrectly and how to reproduce the issue.
๐ Steps To Reproduce
- Call
PedProp.IsVariationValidon aPedfor more than 36 different variations - The method will return false after preloading 36 different variations.
You can easily test with a Ped with "mp_f_freemode_01" or "mp_m_freemode_01". Example snippet;
// test this with a Ped with "mp_f_freemode_01" or "mp_m_freemode_01"!
bool PedProp_IsVariationValid_WorksForAllHeadPropDrawables(Ped ped)
{
int headPropDrawableCount = Function.Call<int>(Hash.GET_NUMBER_OF_PED_PROP_DRAWABLE_VARIATIONS, _ped.Handle, (int)PedPropAnchorPoint.Head);
for (int i = 0; i < headPropDrawableCount; i++)
{
if (!ped.Style[PedPropAnchorPoint.Head].IsVariationValid(i, 0))
{
return false;
}
}
return true;
}๐ Link To Code Example
No response
โ ๏ธ Current Behavior
PedProp.IsVariationValid returns false after preloading 36 different variations on the ped, even if the variation is actually valid. Also the method silently preload the variation composed of the passed arguments if it's valid.
๐ฏ Expected Behavior
PedProp.IsVariationValid returns true if the variation is valid, without preloading the variation.