Invalid float vector dimension range: clamp and warn instead of crash
* backported from https://github.com/minetest/minetest/pull/12389 * issues related: * https://github.com/minetest/minetest/issues/11742 * https://github.com/minetest/minetest/issues/6129 * close https://codeberg.org/minenux/minetest-engine-minetest/issues/4
This commit is contained in:
parent
df93c4be44
commit
700c0933fb
@ -42,11 +42,13 @@ extern "C" {
|
|||||||
#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::ostringstream error_text; \
|
warningstream << "Invalid float vector dimension range '" name "' " << \
|
||||||
error_text << "Invalid float vector dimension range '" name "' " << \
|
|
||||||
"(expected " << F1000_MIN << " < " name " < " << F1000_MAX << \
|
"(expected " << F1000_MIN << " < " name " < " << F1000_MAX << \
|
||||||
" got " << value << ")." << std::endl; \
|
" got " << value << "). restarted to max / min" << std::endl; \
|
||||||
throw LuaError(error_text.str()); \
|
if (value < F1000_MIN) \
|
||||||
|
value = F1000_MIN; \
|
||||||
|
else \
|
||||||
|
value = F1000_MAX; \
|
||||||
}
|
}
|
||||||
#define CHECK_POS_TAB(index) CHECK_TYPE(index, "position", LUA_TTABLE)
|
#define CHECK_POS_TAB(index) CHECK_TYPE(index, "position", LUA_TTABLE)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user