diff options
author | est31 <MTest31@outlook.com> | 2015-05-31 06:23:10 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-05-31 06:24:41 +0200 |
commit | 06a2eee692e0e55c1dfb9f14e982ad146ba4ce49 (patch) | |
tree | 4e6f7cede27c7d1348f4e669636e7196c8240746 /src/mapblock.h | |
parent | b4dfaa3a7a9251cdb0f0867fc29240c808268b1b (diff) | |
download | minetest-06a2eee692e0e55c1dfb9f14e982ad146ba4ce49.tar.gz minetest-06a2eee692e0e55c1dfb9f14e982ad146ba4ce49.tar.bz2 minetest-06a2eee692e0e55c1dfb9f14e982ad146ba4ce49.zip |
Mapblock: nodecount refactor
Spare direct multoplication, use constant MapBlock::nodecount instead of
local nodecount variables.
Also use strides at one place instead of multiplications.
Diffstat (limited to 'src/mapblock.h')
-rw-r--r-- | src/mapblock.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mapblock.h b/src/mapblock.h index 9e36fe113..92ca4b485 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -145,9 +145,8 @@ public: void reallocate() { delete[] data; - u32 datasize = MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE; - data = new MapNode[datasize]; - for (u32 i = 0; i < datasize; i++) + data = new MapNode[nodecount]; + for (u32 i = 0; i < nodecount; i++) data[i] = MapNode(CONTENT_IGNORE); raiseModified(MOD_STATE_WRITE_NEEDED, MOD_REASON_REALLOCATE); @@ -294,7 +293,7 @@ public: if (!*valid_position) return MapNode(CONTENT_IGNORE); - return data[z * MAP_BLOCKSIZE * MAP_BLOCKSIZE + y * MAP_BLOCKSIZE + x]; + return data[z * zstride + y * ystride + x]; } inline MapNode getNode(v3s16 p, bool *valid_position) @@ -553,6 +552,8 @@ public: static const u32 ystride = MAP_BLOCKSIZE; static const u32 zstride = MAP_BLOCKSIZE * MAP_BLOCKSIZE; + static const u32 nodecount = MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE; + private: /* Private member variables |