Fixed wrong values for unsigned, >= 16-bit props in GetEntProp (bug 5105, r=fyren).

This commit is contained in:
Nicholas Hastings 2011-10-11 19:41:56 -04:00
parent 8888e88dc4
commit 14919c65d9

View File

@ -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:
@ -1215,13 +1217,27 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params)
return *(int32_t *)((uint8_t *)pEntity + offset); return *(int32_t *)((uint8_t *)pEntity + offset);
} }
else if (bit_count >= 9) else if (bit_count >= 9)
{
if (is_unsigned)
{
return *(uint16_t *)((uint8_t *)pEntity + offset);
}
else
{ {
return *(int16_t *)((uint8_t *)pEntity + offset); return *(int16_t *)((uint8_t *)pEntity + offset);
} }
}
else if (bit_count >= 2) else if (bit_count >= 2)
{
if (is_unsigned)
{
return *(uint8_t *)((uint8_t *)pEntity + offset);
}
else
{ {
return *(int8_t *)((uint8_t *)pEntity + offset); return *(int8_t *)((uint8_t *)pEntity + offset);
} }
}
else else
{ {
return *(bool *)((uint8_t *)pEntity + offset) ? 1 : 0; return *(bool *)((uint8_t *)pEntity + offset) ? 1 : 0;