Adap the "Remove unnecessary float limits from script API" to checks of floats

* backport 8ff3fadba0
* issues related:
    * https://github.com/minetest/minetest/issues/11742
    * https://github.com/minetest/minetest/issues/6129
* really close #4
* TODO adapt to use FLOAT checks
This commit is contained in:
mckaygerhard 2022-07-20 22:01:31 +02:00
parent 5a91e3a240
commit 055ab7c38a

View File

@ -28,7 +28,7 @@ extern "C" {
#include "common/c_converter.h"
#include "common/c_internal.h"
#include "constants.h"
#include <cmath>
#define CHECK_TYPE(index, name, type) do { \
int t = lua_type(L, (index)); \
@ -41,8 +41,8 @@ extern "C" {
} while(0)
#define CHECK_POS_COORD(name) CHECK_TYPE(-1, "position coordinate '" name "'", LUA_TNUMBER)
#define CHECK_FLOAT_RANGE(value, name) \
if (value < F1000_MIN || value > F1000_MAX) { \
warningstream << "Invalid float vector dimension range '" name "' " << \
if (value < F1000_MIN || value > F1000_MAX || std::isnan(value) || std::isinf(value) ) { \
warningstream << "Invalid float vector dimension range or null value given '" name "' " << \
"(expected " << F1000_MIN << " < " name " < " << F1000_MAX << \
" got " << value << "). restarted to max / min" << std::endl; \
if (value < F1000_MIN) \