aboutsummaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-07-08 00:45:24 -0400
committerkwolekr <kwolekr@minetest.net>2015-07-08 01:50:31 -0400
commite234d8b3786d5adfbdf3d1a2123c3e8d91c21880 (patch)
tree2775448749ab7616a9b1e69b4bb4988aa0253539 /src/client.cpp
parentba15c98e4d5d7f4bc515e351d6af1a084d46092e (diff)
downloadminetest-e234d8b3786d5adfbdf3d1a2123c3e8d91c21880.tar.gz
minetest-e234d8b3786d5adfbdf3d1a2123c3e8d91c21880.tar.bz2
minetest-e234d8b3786d5adfbdf3d1a2123c3e8d91c21880.zip
Clean-up Minimap code
- Fixed race conditions - Fixed null dereference - Fixed out-of-bounds array access - MinimapMapblock is now allocated and added to update queue only when enabled - Removed dependency on LocalPlayer - Fixed code style - Simplified expressions and program logic - Cleaned minimap object interfaces
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 2f8babfa2..66aac6229 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -525,18 +525,23 @@ void Client::step(float dtime)
while (!m_mesh_update_thread.m_queue_out.empty())
{
num_processed_meshes++;
+
+ MinimapMapblock *minimap_mapblock = NULL;
+ bool do_mapper_update = true;
+
MeshUpdateResult r = m_mesh_update_thread.m_queue_out.pop_frontNoEx();
MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(r.p);
- MinimapMapblock *minimap_mapblock = NULL;
if (block) {
// Delete the old mesh
- if (block->mesh != NULL) {
+ if (block->mesh != NULL) {
delete block->mesh;
block->mesh = NULL;
}
- if (r.mesh)
+ if (r.mesh) {
minimap_mapblock = r.mesh->getMinimapMapblock();
+ do_mapper_update = (minimap_mapblock != NULL);
+ }
if (r.mesh && r.mesh->getMesh()->getMeshBufferCount() == 0) {
delete r.mesh;
@@ -550,7 +555,8 @@ void Client::step(float dtime)
minimap_mapblock = NULL;
}
- m_mapper->addBlock(r.p, minimap_mapblock);
+ if (do_mapper_update)
+ m_mapper->addBlock(r.p, minimap_mapblock);
if (r.ack_block_to_server) {
/*