9 #include "nodemetadata.h"
15 #include "util/directiontables.h"
16 #include "rollback_interface.h"
21 static s32 unsignedToSigned(s32 i, s32 max_positive)
26 return i - 2*max_positive;
29 // modulo of a negative number does not work consistently in C
30 static s64 pythonmodulo(s64 i, s64 mod)
34 return mod - ((-i) % mod);
37 long long Database::getBlockAsInteger(const v3s16 pos) {
38 return (unsigned long long)pos.Z*16777216 +
39 (unsigned long long)pos.Y*4096 +
40 (unsigned long long)pos.X;
43 v3s16 Database::getIntegerAsBlock(long long i) {
44 s32 x = unsignedToSigned(pythonmodulo(i, 4096), 2048);
46 s32 y = unsignedToSigned(pythonmodulo(i, 4096), 2048);
48 s32 z = unsignedToSigned(pythonmodulo(i, 4096), 2048);