3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MAPBLOCK_NODEMOD_HEADER
21 #define MAPBLOCK_NODEMOD_HEADER
26 NODEMOD_CHANGECONTENT, //param is content id
27 NODEMOD_CRACK // param is crack progression
32 NodeMod(enum NodeModType a_type=NODEMOD_NONE, u16 a_param=0)
37 bool operator==(const NodeMod &other)
39 return (type == other.type && param == other.param);
41 enum NodeModType type;
49 returns true if the mod was different last time
51 bool set(v3s16 p, const NodeMod &mod)
53 // See if old is different, cancel if it is not different.
54 core::map<v3s16, NodeMod>::Node *n = m_mods.find(p);
57 NodeMod old = n->getValue();
65 m_mods.insert(p, mod);
70 // Returns true if there was one
71 bool get(v3s16 p, NodeMod *mod)
73 core::map<v3s16, NodeMod>::Node *n;
92 if(m_mods.size() == 0)
97 void copy(NodeModMap &dest)
101 for(core::map<v3s16, NodeMod>::Iterator
102 i = m_mods.getIterator();
103 i.atEnd() == false; i++)
105 dest.m_mods.insert(i.getNode()->getKey(), i.getNode()->getValue());
110 core::map<v3s16, NodeMod> m_mods;