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:
parent
5a91e3a240
commit
055ab7c38a
@ -28,7 +28,7 @@ extern "C" {
|
|||||||
#include "common/c_converter.h"
|
#include "common/c_converter.h"
|
||||||
#include "common/c_internal.h"
|
#include "common/c_internal.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#define CHECK_TYPE(index, name, type) do { \
|
#define CHECK_TYPE(index, name, type) do { \
|
||||||
int t = lua_type(L, (index)); \
|
int t = lua_type(L, (index)); \
|
||||||
@ -41,8 +41,8 @@ extern "C" {
|
|||||||
} while(0)
|
} while(0)
|
||||||
#define CHECK_POS_COORD(name) CHECK_TYPE(-1, "position coordinate '" name "'", LUA_TNUMBER)
|
#define CHECK_POS_COORD(name) CHECK_TYPE(-1, "position coordinate '" name "'", LUA_TNUMBER)
|
||||||
#define CHECK_FLOAT_RANGE(value, name) \
|
#define CHECK_FLOAT_RANGE(value, name) \
|
||||||
if (value < F1000_MIN || value > F1000_MAX) { \
|
if (value < F1000_MIN || value > F1000_MAX || std::isnan(value) || std::isinf(value) ) { \
|
||||||
warningstream << "Invalid float vector dimension range '" name "' " << \
|
warningstream << "Invalid float vector dimension range or null value given '" name "' " << \
|
||||||
"(expected " << F1000_MIN << " < " name " < " << F1000_MAX << \
|
"(expected " << F1000_MIN << " < " name " < " << F1000_MAX << \
|
||||||
" got " << value << "). restarted to max / min" << std::endl; \
|
" got " << value << "). restarted to max / min" << std::endl; \
|
||||||
if (value < F1000_MIN) \
|
if (value < F1000_MIN) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user