Merge pull request #391 from alliedmodders/dataprop-stringt-arrays
Fix quirks with Get/SetEntPropString on string_t arrays in datadesc
This commit is contained in:
commit
d6476728f9
@ -1924,18 +1924,24 @@ static cell_t GetEntPropString(IPluginContext *pContext, const cell_t *params)
|
|||||||
|
|
||||||
bIsStringIndex = (td->fieldType != FIELD_CHARACTER);
|
bIsStringIndex = (td->fieldType != FIELD_CHARACTER);
|
||||||
|
|
||||||
if (bIsStringIndex && (element < 0 || element >= td->fieldSize))
|
if (element != 0)
|
||||||
{
|
{
|
||||||
return pContext->ThrowNativeError("Element %d is out of bounds (Prop %s has %d elements).",
|
if (bIsStringIndex)
|
||||||
element,
|
{
|
||||||
prop,
|
if (element < 0 || element >= td->fieldSize)
|
||||||
td->fieldSize);
|
{
|
||||||
}
|
return pContext->ThrowNativeError("Element %d is out of bounds (Prop %s has %d elements).",
|
||||||
else if (element != 0)
|
element,
|
||||||
{
|
prop,
|
||||||
return pContext->ThrowNativeError("Prop %s is not an array. Element %d is invalid.",
|
td->fieldSize);
|
||||||
prop,
|
}
|
||||||
element);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Prop %s is not an array. Element %d is invalid.",
|
||||||
|
prop,
|
||||||
|
element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = info.actual_offset;
|
offset = info.actual_offset;
|
||||||
@ -2061,6 +2067,27 @@ static cell_t SetEntPropString(IPluginContext *pContext, const cell_t *params)
|
|||||||
offset = info.actual_offset;
|
offset = info.actual_offset;
|
||||||
|
|
||||||
bIsStringIndex = (td->fieldType != FIELD_CHARACTER);
|
bIsStringIndex = (td->fieldType != FIELD_CHARACTER);
|
||||||
|
|
||||||
|
if (element != 0)
|
||||||
|
{
|
||||||
|
if (bIsStringIndex)
|
||||||
|
{
|
||||||
|
if (element < 0 || element >= td->fieldSize)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Element %d is out of bounds (Prop %s has %d elements).",
|
||||||
|
element,
|
||||||
|
prop,
|
||||||
|
td->fieldSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Prop %s is not an array. Element %d is invalid.",
|
||||||
|
prop,
|
||||||
|
element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (bIsStringIndex)
|
if (bIsStringIndex)
|
||||||
{
|
{
|
||||||
offset += (element * (td->fieldSizeInBytes / td->fieldSize));
|
offset += (element * (td->fieldSizeInBytes / td->fieldSize));
|
||||||
|
Loading…
Reference in New Issue
Block a user