summaryrefslogtreecommitdiff
path: root/src/mapblock.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-01-17 14:57:37 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-01-17 14:57:37 +0200
commit0fa0e0752a28eeb43195f2288c018d5c0b24520b (patch)
tree72c05dc4cd98663d92a6a312c6b8128c18791590 /src/mapblock.h
parentbd26be262d30eeb0ca818b634891704de4365893 (diff)
downloadminetest-0fa0e0752a28eeb43195f2288c018d5c0b24520b.tar.gz
minetest-0fa0e0752a28eeb43195f2288c018d5c0b24520b.tar.bz2
minetest-0fa0e0752a28eeb43195f2288c018d5c0b24520b.zip
old water removed, some fixes here and there
Diffstat (limited to 'src/mapblock.h')
-rw-r--r--src/mapblock.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/mapblock.h b/src/mapblock.h
index b3fa76bb7..e4f93a031 100644
--- a/src/mapblock.h
+++ b/src/mapblock.h
@@ -32,8 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapblockobject.h"
#include "voxel.h"
-#define MAP_BLOCKSIZE 16
-
// Named by looking towards z+
enum{
FACE_BACK=0,
@@ -64,6 +62,10 @@ struct NodeMod
type = a_type;
param = a_param;
}
+ bool operator==(const NodeMod &other)
+ {
+ return (type == other.type && param == other.param);
+ }
enum NodeModType type;
u16 param;
};
@@ -393,8 +395,10 @@ public:
/*
Methods for setting temporary modifications to nodes for
drawing
+
+ returns true if the mod was different last time
*/
- void setTempMod(v3s16 p, NodeMod mod)
+ bool setTempMod(v3s16 p, NodeMod mod)
{
/*dstream<<"setTempMod called on block"
<<" ("<<p.X<<","<<p.Y<<","<<p.Z<<")"
@@ -402,7 +406,18 @@ public:
<<", mod.param="<<mod.param
<<std::endl;*/
JMutexAutoLock lock(m_temp_mods_mutex);
+
+ // See if old is different, cancel if it is not different.
+ core::map<v3s16, NodeMod>::Node *n = m_temp_mods.find(p);
+ if(n)
+ {
+ NodeMod old = n->getValue();
+ if(old == mod)
+ return false;
+ }
+
m_temp_mods[p] = mod;
+ return true;
}
// Returns true if there was one
bool getTempMod(v3s16 p, struct NodeMod *mod)
@@ -416,16 +431,23 @@ public:
*mod = n->getValue();
return true;
}
- void clearTempMod(v3s16 p)
+ bool clearTempMod(v3s16 p)
{
JMutexAutoLock lock(m_temp_mods_mutex);
if(m_temp_mods.find(p))
+ {
m_temp_mods.remove(p);
+ return true;
+ }
+ return false;
}
- void clearTempMods()
+ bool clearTempMods()
{
JMutexAutoLock lock(m_temp_mods_mutex);
+ if(m_temp_mods.size() == 0)
+ return false;
m_temp_mods.clear();
+ return true;
}
#endif