alliedmodders / amxmodx

AMX Mod X - Half-Life 1 Scripting and Administration
http://www.amxmodx.org/
499 stars 203 forks source link

Simplify create_cvar boundary params #574

Open WPMGPRoSToTeMa opened 6 years ago

WPMGPRoSToTeMa commented 6 years ago

I think we can remove has_min and has_max params and replace min_val/max_val default values with -Infinity and +Infinity respectively.

OciXCrom commented 6 years ago

cellmin and cellmax? I agree, there's no need for those two arguments.

WPMGPRoSToTeMa commented 6 years ago

@OciXCrom cellmin and cellmax are for integers, but min_val and max_val are floats. I'm talking about this:

Two infinities: +∞ and −∞.

rsKliPPy commented 6 years ago

We have to implement IEEE-754+Infinity and -Infinity then. Might as well have NaN then.

OciXCrom commented 6 years ago

Yup, I didn't notice the params are floats.

WPMGPRoSToTeMa commented 6 years ago

@rsKliPPy I think:

const Float:Infinity = Float:0x7F800000;

should just work.

rsKliPPy commented 6 years ago

We have to make sure all FP operations will work correctly (according to the spec) when operating on Infinity, -Infinity and NaN. Creating constants is just the start.

WPMGPRoSToTeMa commented 6 years ago

There is another option. We can add NULL_FLOAT and change create_cvar signature to:

native create_cvar(const name[], const string[], flags = FCVAR_NONE, const description[] = "", const &Float:min_val = NULL_FLOAT, const &Float:max_val = NULL_FLOAT);

BUT we need to implement compiler support for passing compile-time constants as const &.