summaryrefslogtreecommitdiff
path: root/src/mapblock.h
diff options
context:
space:
mode:
authorLars Hofhansl <larsh@apache.org>2017-01-04 11:11:55 -0800
committersfan5 <sfan5@live.de>2017-01-04 21:37:29 +0100
commitca3629637cb20cea318b8811e717e2caab579dc0 (patch)
tree76f21d687974e641bfa7ff8795f55f10514b3832 /src/mapblock.h
parentad10b8b762d8097092f307867a36e55049d69546 (diff)
downloadminetest-ca3629637cb20cea318b8811e717e2caab579dc0.tar.gz
minetest-ca3629637cb20cea318b8811e717e2caab579dc0.tar.bz2
minetest-ca3629637cb20cea318b8811e717e2caab579dc0.zip
Fixes for using std:vector in ABMHander and further perf improvements
Diffstat (limited to 'src/mapblock.h')
-rw-r--r--src/mapblock.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/mapblock.h b/src/mapblock.h
index 5adfcf3fb..c737b4c37 100644
--- a/src/mapblock.h
+++ b/src/mapblock.h
@@ -305,8 +305,7 @@ public:
inline MapNode getNodeNoEx(v3s16 p)
{
bool is_valid;
- MapNode node = getNode(p.X, p.Y, p.Z, &is_valid);
- return is_valid ? node : MapNode(CONTENT_IGNORE);
+ return getNode(p.X, p.Y, p.Z, &is_valid);
}
inline void setNode(s16 x, s16 y, s16 z, MapNode & n)
@@ -341,6 +340,22 @@ public:
return getNodeNoCheck(p.X, p.Y, p.Z, valid_position);
}
+ ////
+ //// Non-checking, unsafe variants of the above
+ //// MapBlock must be loaded by another function in the same scope/function
+ //// Caller must ensure that this is not a dummy block (by calling isDummy())
+ ////
+
+ inline const MapNode &getNodeUnsafe(s16 x, s16 y, s16 z)
+ {
+ return data[z * zstride + y * ystride + x];
+ }
+
+ inline const MapNode &getNodeUnsafe(v3s16 &p)
+ {
+ return getNodeUnsafe(p.X, p.Y, p.Z);
+ }
+
inline void setNodeNoCheck(s16 x, s16 y, s16 z, MapNode & n)
{
if (data == NULL)
@@ -512,7 +527,6 @@ public:
void serializeNetworkSpecific(std::ostream &os, u16 net_proto_version);
void deSerializeNetworkSpecific(std::istream &is);
-
private:
/*
Private methods