re-added old float rounding native
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40842
This commit is contained in:
parent
4db651b4de
commit
f4390609b3
@ -230,6 +230,42 @@ static cell_t sm_ArcTangent2(IPluginContext *pCtx, const cell_t *params)
|
|||||||
return sp_ftoc(val1);
|
return sp_ftoc(val1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t sm_FloatRound(IPluginContext *pCtx, const cell_t *params)
|
||||||
|
{
|
||||||
|
float val = sp_ctof(params[1]);
|
||||||
|
|
||||||
|
switch (params[2])
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
val = floor(val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
val = ceil(val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
if (val >= 0.0f)
|
||||||
|
{
|
||||||
|
val = floor(val);
|
||||||
|
} else {
|
||||||
|
val = ceil(val);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
val = (float)floor(val + 0.5f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return static_cast<int>(val);
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_NATIVES(floatnatives)
|
REGISTER_NATIVES(floatnatives)
|
||||||
{
|
{
|
||||||
{"float", sm_float},
|
{"float", sm_float},
|
||||||
@ -255,5 +291,6 @@ REGISTER_NATIVES(floatnatives)
|
|||||||
{"ArcCosine", sm_ArcCosine},
|
{"ArcCosine", sm_ArcCosine},
|
||||||
{"ArcSine", sm_ArcSine},
|
{"ArcSine", sm_ArcSine},
|
||||||
{"ArcTangent2", sm_ArcTangent2},
|
{"ArcTangent2", sm_ArcTangent2},
|
||||||
|
{"FloatRound", sm_FloatRound}, /* Backwards compat shim */
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -212,6 +212,23 @@ native Float:ArcSine(Float:angle);
|
|||||||
*/
|
*/
|
||||||
native Float:ArcTangent2(Float:x, Float:y);
|
native Float:ArcTangent2(Float:x, Float:y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Different methods of rounding.
|
||||||
|
*/
|
||||||
|
enum floatround_method
|
||||||
|
{
|
||||||
|
floatround_round = 0, /**< Standard IEEE rounding */
|
||||||
|
floatround_floor, /**< Next lowest integer value. */
|
||||||
|
floatround_ceil, /**< Next highest integer value. */
|
||||||
|
floatround_tozero /** Closest integer to zero. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Backwards compatibility - use RoundToNearest or any of the other rounding natives.
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
native FloatRound(Float:value, floatround_method:method=floatround_round);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User defined operators.
|
* User defined operators.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user