aboutsummaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorJude Melton-Houghton <jwmhjwmh@gmail.com>2022-04-07 15:58:04 -0400
committerGitHub <noreply@github.com>2022-04-07 21:58:04 +0200
commit0b5b2b2633609f646a534d353a2c587af4be46fa (patch)
tree8c8d56ab26b173c57eb2c0cff319eeae2c8e6cab /src/map.cpp
parent1348d9aaf834faa613bf3efe3a9d8fee758e85d0 (diff)
downloadminetest-0b5b2b2633609f646a534d353a2c587af4be46fa.tar.gz
minetest-0b5b2b2633609f646a534d353a2c587af4be46fa.tar.bz2
minetest-0b5b2b2633609f646a534d353a2c587af4be46fa.zip
Disentangle map implementations (#12148)
Fixes violation of Liskov substitution principle Fixes #12144
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 1cbc55707..9c9324f5f 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -246,22 +246,6 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
action.setSetNode(p, rollback_oldnode, rollback_newnode);
m_gamedef->rollback()->reportAction(action);
}
-
- /*
- Add neighboring liquid nodes and this node to transform queue.
- (it's vital for the node itself to get updated last, if it was removed.)
- */
-
- for (const v3s16 &dir : g_7dirs) {
- v3s16 p2 = p + dir;
-
- bool is_valid_position;
- MapNode n2 = getNode(p2, &is_valid_position);
- if(is_valid_position &&
- (m_nodedef->get(n2).isLiquid() ||
- n2.getContent() == CONTENT_AIR))
- m_transforming_liquid.push_back(p2);
- }
}
void Map::removeNodeAndUpdate(v3s16 p,
@@ -342,7 +326,7 @@ struct TimeOrderedMapBlock {
void Map::timerUpdate(float dtime, float unload_timeout, u32 max_loaded_blocks,
std::vector<v3s16> *unloaded_blocks)
{
- bool save_before_unloading = (mapType() == MAPTYPE_SERVER);
+ bool save_before_unloading = maySaveBlocks();
// Profile modified reasons
Profiler modprofiler;
@@ -527,11 +511,11 @@ struct NodeNeighbor {
{ }
};
-void Map::transforming_liquid_add(v3s16 p) {
+void ServerMap::transforming_liquid_add(v3s16 p) {
m_transforming_liquid.push_back(p);
}
-void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
+void ServerMap::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
ServerEnvironment *env)
{
u32 loopcount = 0;
@@ -1565,6 +1549,29 @@ bool ServerMap::isBlockInQueue(v3s16 pos)
return m_emerge && m_emerge->isBlockInQueue(pos);
}
+void ServerMap::addNodeAndUpdate(v3s16 p, MapNode n,
+ std::map<v3s16, MapBlock*> &modified_blocks,
+ bool remove_metadata)
+{
+ Map::addNodeAndUpdate(p, n, modified_blocks, remove_metadata);
+
+ /*
+ Add neighboring liquid nodes and this node to transform queue.
+ (it's vital for the node itself to get updated last, if it was removed.)
+ */
+
+ for (const v3s16 &dir : g_7dirs) {
+ v3s16 p2 = p + dir;
+
+ bool is_valid_position;
+ MapNode n2 = getNode(p2, &is_valid_position);
+ if(is_valid_position &&
+ (m_nodedef->get(n2).isLiquid() ||
+ n2.getContent() == CONTENT_AIR))
+ m_transforming_liquid.push_back(p2);
+ }
+}
+
// N.B. This requires no synchronization, since data will not be modified unless
// the VoxelManipulator being updated belongs to the same thread.
void ServerMap::updateVManip(v3s16 pos)