Skip to content

Commit

Permalink
Fix reading/writing float variant-based props
Browse files Browse the repository at this point in the history
When variant support was added for props, the validation checks in the
float related functions weren't updated to allow them.

Tested with the plugin from the forum thread with a spawned
`math_counter`.

Fixes #1501
  • Loading branch information
asherkin committed Jul 17, 2021
1 parent 54364d2 commit 3d5e060
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions core/smn_entities.cpp
Expand Up @@ -1132,7 +1132,7 @@ static cell_t SetEntDataString(IPluginContext *pContext, const cell_t *params)
auto *pVariant = (variant_t *)((intptr_t)pEntity + offset); \
if (pVariant->fieldType != type) \
{ \
return pContext->ThrowNativeError("Variant value for %s is not %s (%d)", \
return pContext->ThrowNativeError("Variant value for %s is not a %s (%d)", \
prop, \
typeName, \
pVariant->fieldType); \
Expand Down Expand Up @@ -1572,13 +1572,15 @@ static cell_t GetEntPropFloat(IPluginContext *pContext, const cell_t *params)
FIND_PROP_DATA(td);

if (td->fieldType != FIELD_FLOAT
&& td->fieldType != FIELD_TIME)
&& td->fieldType != FIELD_TIME
&& (td->fieldType != FIELD_CUSTOM || (td->flags & FTYPEDESC_OUTPUT) != FTYPEDESC_OUTPUT))
{
return pContext->ThrowNativeError("Data field %s is not a float (%d != [%d,%d])",
return pContext->ThrowNativeError("Data field %s is not a float (%d != [%d,%d,%d])",
prop,
td->fieldType,
FIELD_FLOAT,
FIELD_TIME);
FIELD_TIME,
FIELD_CUSTOM);
}

CHECK_SET_PROP_DATA_OFFSET();
Expand Down Expand Up @@ -1633,13 +1635,15 @@ static cell_t SetEntPropFloat(IPluginContext *pContext, const cell_t *params)
FIND_PROP_DATA(td);

if (td->fieldType != FIELD_FLOAT
&& td->fieldType != FIELD_TIME)
&& td->fieldType != FIELD_TIME
&& (td->fieldType != FIELD_CUSTOM || (td->flags & FTYPEDESC_OUTPUT) != FTYPEDESC_OUTPUT))
{
return pContext->ThrowNativeError("Data field %s is not a float (%d != [%d,%d])",
return pContext->ThrowNativeError("Data field %s is not a float (%d != [%d,%d,%d])",
prop,
td->fieldType,
FIELD_FLOAT,
FIELD_TIME);
FIELD_TIME,
FIELD_CUSTOM);
}

CHECK_SET_PROP_DATA_OFFSET();
Expand Down

0 comments on commit 3d5e060

Please sign in to comment.