extensions/sdktools/gamerulesnatives.cpp
changeset 3711 c6e64c3a9bed
parent 3710 5559ea22b6b5
child 3712 ea253cc4fbf6
     1.1 --- a/extensions/sdktools/gamerulesnatives.cpp	Mon Dec 17 14:34:44 2012 -0500
     1.2 +++ b/extensions/sdktools/gamerulesnatives.cpp	Tue Dec 18 17:53:45 2012 -0500
     1.3 @@ -160,6 +160,7 @@
     1.4  	int element = params[3];
     1.5  	int offset;
     1.6  	int bit_count;
     1.7 +	bool is_unsigned;
     1.8  
     1.9  	if (!g_pGameRules || !g_szGameRulesProxy || !strcmp(g_szGameRulesProxy, ""))
    1.10  		return pContext->ThrowNativeError("Gamerules lookup failed.");
    1.11 @@ -169,6 +170,7 @@
    1.12  	int elementCount = 1;
    1.13  
    1.14  	FIND_PROP_SEND(DPT_Int, "integer");
    1.15 +	is_unsigned = ((info.prop->GetFlags() & SPROP_UNSIGNED) == SPROP_UNSIGNED);
    1.16  
	if (bit_count < 1)
    1.17  	{
    1.18  		bit_count = params[2] * 8;
    1.19 @@ -182,11 +184,25 @@
    1.20  	}
    1.21  	else if (bit_count >= 9)
    1.22  	{
    1.23 -		return *(int16_t *)((intptr_t)pGameRules + offset);
    1.24 +		if (is_unsigned)
    1.25 +		{
    1.26 +			return *(uint16_t *)((intptr_t)pGameRules + offset);
    1.27 +		}
    1.28 +		else
    1.29 +		{
    1.30 +			return *(int16_t *)((intptr_t)pGameRules + offset);
    1.31 +		}
    1.32  	}
    1.33  	else if (bit_count >= 2)
    1.34  	{
    1.35 -		return *(int8_t *)((intptr_t)pGameRules + offset);
    1.36 +		if (is_unsigned)
    1.37 +		{
    1.38 +			return *(uint8_t *)((intptr_t)pGameRules + offset);
    1.39 +		}
    1.40 +		else
    1.41 +		{
    1.42 +			return *(int8_t *)((intptr_t)pGameRules + offset);
    1.43 +		}
    1.44  	}
    1.45  	else
    1.46  	{