Fixed wrong values for unsigned, >= 16-bit props in GetEntProp (bug 5105, r=fyren).
This commit is contained in:
parent
8888e88dc4
commit
14919c65d9
@ -1155,6 +1155,7 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params)
|
|||||||
const char *class_name;
|
const char *class_name;
|
||||||
edict_t *pEdict;
|
edict_t *pEdict;
|
||||||
int bit_count;
|
int bit_count;
|
||||||
|
bool is_unsigned = false;
|
||||||
|
|
||||||
int element = 0;
|
int element = 0;
|
||||||
if (params[0] >= 5)
|
if (params[0] >= 5)
|
||||||
@ -1197,6 +1198,7 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params)
|
|||||||
case Prop_Send:
|
case Prop_Send:
|
||||||
{
|
{
|
||||||
FIND_PROP_SEND(DPT_Int, "integer");
|
FIND_PROP_SEND(DPT_Int, "integer");
|
||||||
|
is_unsigned = ((info.prop->GetFlags() & SPROP_UNSIGNED) == SPROP_UNSIGNED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -1216,11 +1218,25 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params)
|
|||||||
}
|
}
|
||||||
else if (bit_count >= 9)
|
else if (bit_count >= 9)
|
||||||
{
|
{
|
||||||
return *(int16_t *)((uint8_t *)pEntity + offset);
|
if (is_unsigned)
|
||||||
|
{
|
||||||
|
return *(uint16_t *)((uint8_t *)pEntity + offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return *(int16_t *)((uint8_t *)pEntity + offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (bit_count >= 2)
|
else if (bit_count >= 2)
|
||||||
{
|
{
|
||||||
return *(int8_t *)((uint8_t *)pEntity + offset);
|
if (is_unsigned)
|
||||||
|
{
|
||||||
|
return *(uint8_t *)((uint8_t *)pEntity + offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return *(int8_t *)((uint8_t *)pEntity + offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user