alliedmodders / sourcemod

SourceMod - Source Engine Scripting and Administration
http://www.sourcemod.net/
975 stars 422 forks source link

Set/GetEntPropFloat doesn't work with math_counter's m_OutValue #1501

Closed asherkin closed 3 years ago

asherkin commented 3 years ago

https://forums.alliedmods.net/showthread.php?p=2749741#post2749741

This check bails before it gets to the variant handling check:

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

https://cs.alliedmods.net/sourcemod/source/core/smn_entities.cpp#1574-1586

The other type functions appear to all be correct, it is only the float ones affected.

Adrianilloo commented 3 years ago

I guess a proper fix would be employing a function similar to the MatchTypeDescAsInteger called here: https://cs.alliedmods.net/sourcemod/source/core/smn_entities.cpp#1352, but for floats instead (if it doesn't already exist).

asherkin commented 3 years ago

I guess a proper fix would be employing a function similar to the MatchTypeDescAsInteger called here: https://cs.alliedmods.net/sourcemod/source/core/smn_entities.cpp#1352, but for floats instead (if it doesn't already exist).

Nothing that complex, as floats are fixed-size, some form of && !(td->fieldType == FIELD_CUSTOM && (td->flags & FTYPEDESC_OUTPUT) == FTYPEDESC_OUTPUT) just needs adding to that if condition.