aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-03-30 23:40:35 -0400
committerkwolekr <kwolekr@minetest.net>2015-03-31 01:11:51 -0400
commited10005d381580440558dc49277b4d350f081283 (patch)
treea1ac2b831d883f6c43193a1c2a55860bf7e0d6ed /src/util
parent6a48844eba16fb955ef4992bef539af66c595d0c (diff)
downloadminetest-ed10005d381580440558dc49277b4d350f081283.tar.gz
minetest-ed10005d381580440558dc49277b4d350f081283.tar.bz2
minetest-ed10005d381580440558dc49277b4d350f081283.zip
GenElementManager: Pass opaque handles to Lua and rename to ObjDefManager
Add core.clear_registered_schematics() and refactor schematics somewhat
Diffstat (limited to 'src/util')
-rw-r--r--src/util/numeric.cpp1
-rw-r--r--src/util/numeric.h22
2 files changed, 22 insertions, 1 deletions
diff --git a/src/util/numeric.cpp b/src/util/numeric.cpp
index a1f1fd0ab..2306976ec 100644
--- a/src/util/numeric.cpp
+++ b/src/util/numeric.cpp
@@ -183,7 +183,6 @@ u64 murmur_hash_64_ua(const void *key, int len, unsigned int seed)
return h;
}
-
/*
blockpos: position of block in block coordinates
camera_pos: position of camera in nodes
diff --git a/src/util/numeric.h b/src/util/numeric.h
index ccc9fbee4..74c1dfea6 100644
--- a/src/util/numeric.h
+++ b/src/util/numeric.h
@@ -249,6 +249,28 @@ int myrand_range(int min, int max);
Miscellaneous functions
*/
+inline u32 get_bits(u32 x, u32 pos, u32 len)
+{
+ u32 mask = (1 << len) - 1;
+ return (x >> pos) & mask;
+}
+
+inline void set_bits(u32 *x, u32 pos, u32 len, u32 val)
+{
+ u32 mask = (1 << len) - 1;
+ *x &= ~(mask << len);
+ *x |= (val & mask) << pos;
+}
+
+inline u32 calc_parity(u32 v)
+{
+ v ^= v >> 16;
+ v ^= v >> 8;
+ v ^= v >> 4;
+ v &= 0xf;
+ return (0x6996 >> v) & 1;
+}
+
u64 murmur_hash_64_ua(const void *key, int len, unsigned int seed);
bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir,