diff options
author | sfan5 <sfan5@live.de> | 2022-06-07 21:27:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-07 21:27:05 +0200 |
commit | 3ac5a24b12950a2d92860d000b9477a11c1ad68b (patch) | |
tree | a4f6730c1bf7c93841b9a2bea63df3331c9ffe99 /src/util | |
parent | 3107c9859114336989855a2c9ee2cbde0e88e3d3 (diff) | |
download | minetest-3ac5a24b12950a2d92860d000b9477a11c1ad68b.tar.gz minetest-3ac5a24b12950a2d92860d000b9477a11c1ad68b.tar.bz2 minetest-3ac5a24b12950a2d92860d000b9477a11c1ad68b.zip |
Sanitize player position and speed server-side (#12396)
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/serialize.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/serialize.h b/src/util/serialize.h index 15bdd050d..2203fff0c 100644 --- a/src/util/serialize.h +++ b/src/util/serialize.h @@ -439,6 +439,18 @@ MAKE_STREAM_WRITE_FXN(video::SColor, ARGB8, 4); //// More serialization stuff //// +inline void clampToF1000(float &v) +{ + v = core::clamp(v, F1000_MIN, F1000_MAX); +} + +inline void clampToF1000(v3f &v) +{ + clampToF1000(v.X); + clampToF1000(v.Y); + clampToF1000(v.Z); +} + // Creates a string with the length as the first two bytes std::string serializeString16(const std::string &plain); |