From 6ccb5835ff55d85156be91473c598eca9d6cb9a6 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 4 Nov 2020 16:57:41 +0100 Subject: Revert "Make Lint Happy" This reverts commit ad148587dcf5244c2d2011dba339786c765c54c4. --- src/database/database.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/database/database.cpp') diff --git a/src/database/database.cpp b/src/database/database.cpp index 01cb2b5fc..12e0e1a0f 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "database.h" #include "irrlichttypes.h" + /**************** * Black magic! * **************** @@ -36,6 +37,7 @@ static inline s16 unsigned_to_signed(u16 i, u16 max_positive) return i - (max_positive * 2); } + // Modulo of a negative number does not work consistently in C static inline s64 pythonmodulo(s64 i, s16 mod) { @@ -45,11 +47,15 @@ static inline s64 pythonmodulo(s64 i, s16 mod) return mod - ((-i) % mod); } + s64 MapDatabase::getBlockAsInteger(const v3s16 &pos) { - return (u64)pos.Z * 0x1000000 + (u64)pos.Y * 0x1000 + (u64)pos.X; + return (u64) pos.Z * 0x1000000 + + (u64) pos.Y * 0x1000 + + (u64) pos.X; } + v3s16 MapDatabase::getIntegerAsBlock(s64 i) { v3s16 pos; @@ -60,3 +66,4 @@ v3s16 MapDatabase::getIntegerAsBlock(s64 i) pos.Z = unsigned_to_signed(pythonmodulo(i, 4096), 2048); return pos; } + -- cgit v1.2.3