From 14919c65d93c6e718d55cd89e8a38fee1ef344f3 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 11 Oct 2011 19:41:56 -0400 Subject: [PATCH] Fixed wrong values for unsigned, >= 16-bit props in GetEntProp (bug 5105, r=fyren). --- core/smn_entities.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index 965e9260..49570434 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -1155,6 +1155,7 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params) const char *class_name; edict_t *pEdict; int bit_count; + bool is_unsigned = false; int element = 0; if (params[0] >= 5) @@ -1197,6 +1198,7 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params) case Prop_Send: { FIND_PROP_SEND(DPT_Int, "integer"); + is_unsigned = ((info.prop->GetFlags() & SPROP_UNSIGNED) == SPROP_UNSIGNED); break; } default: @@ -1216,11 +1218,25 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params) } 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) { - 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 {