]> git.lizzy.rs Git - minetest.git/commitdiff
Invalid float vector dimension range: clamp and warn instead of crash clamp
authorElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 30 May 2022 16:17:28 +0000 (18:17 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 30 May 2022 16:17:28 +0000 (18:17 +0200)
src/script/common/c_converter.cpp

index b5ff52f73bcaf6572466b65cd3b20cd7d1f003f5..351121abf270008e0fcdd5a868863e0235e6cc36 100644 (file)
@@ -42,11 +42,13 @@ extern "C" {
 #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) { \
-       std::ostringstream error_text; \
-       error_text << "Invalid float vector dimension range '" name "' " << \
+       warningstream << "Invalid float vector dimension range '" name "' " << \
        "(expected " << F1000_MIN << " < " name " < " << F1000_MAX << \
        " got " << value << ")." << 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)