From 691b18c41b74a1dfcbe360f492b4bb2ff9e22610 Mon Sep 17 00:00:00 2001
From: Craig Robbins <kde.psych@gmail.com>
Date: Mon, 1 Dec 2014 22:05:36 +1000
Subject: [PATCH] Fix node 0,0,0 being highlighted when
 enable_node_highlighting == false

Without this patch node 0,0,0 is highlighted when enable_node_highligting is false
There is a minor lighting issue remaining, however it seems to be related to a different bug (https://github.com/minetest/minetest/issues/1887)
---
 src/client.cpp | 9 +++++----
 src/client.h   | 4 ++--
 src/game.cpp   | 3 ++-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/client.cpp b/src/client.cpp
index e9172e6fc..c7fea6a11 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -255,10 +255,11 @@ Client::Client(
 	m_inventory_updated(false),
 	m_inventory_from_server(NULL),
 	m_inventory_from_server_age(0.0),
-	m_show_hud(true),
+	m_show_highlighted(false),
 	m_animation_time(0),
 	m_crack_level(-1),
 	m_crack_pos(0,0,0),
+	m_highlighted_pos(0,0,0),
 	m_map_seed(0),
 	m_password(password),
 	m_access_denied(false),
@@ -2515,9 +2516,9 @@ int Client::getCrackLevel()
 	return m_crack_level;
 }
 
-void Client::setHighlighted(v3s16 pos, bool show_hud)
+void Client::setHighlighted(v3s16 pos, bool show_highlighted)
 {
-	m_show_hud = show_hud;
+	m_show_highlighted = show_highlighted;
 	v3s16 old_highlighted_pos = m_highlighted_pos;
 	m_highlighted_pos = pos;
 	addUpdateMeshTaskForNode(old_highlighted_pos, false, true);
@@ -2607,7 +2608,7 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server, bool urgent)
 		// Debug: 1-6ms, avg=2ms
 		data->fill(b);
 		data->setCrack(m_crack_level, m_crack_pos);
-		data->setHighlighted(m_highlighted_pos, m_show_hud);
+		data->setHighlighted(m_highlighted_pos, m_show_highlighted);
 		data->setSmoothLighting(g_settings->getBool("smooth_lighting"));
 	}
 
diff --git a/src/client.h b/src/client.h
index e871dee93..b91f12b53 100644
--- a/src/client.h
+++ b/src/client.h
@@ -398,7 +398,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
 	int getCrackLevel();
 	void setCrack(int level, v3s16 pos);
 
-	void setHighlighted(v3s16 pos, bool show_hud);
+	void setHighlighted(v3s16 pos, bool show_higlighted);
 	v3s16 getHighlighted(){ return m_highlighted_pos; }
 
 	u16 getHP();
@@ -509,7 +509,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
 	float m_inventory_from_server_age;
 	std::set<v3s16> m_active_blocks;
 	PacketCounter m_packetcounter;
-	bool m_show_hud;
+	bool m_show_highlighted;
 	// Block mesh animation parameters
 	float m_animation_time;
 	int m_crack_level;
diff --git a/src/game.cpp b/src/game.cpp
index b6f96acc3..aa12e6c3f 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -2697,7 +2697,8 @@ void Game::toggleHud(float *statustext_time, bool *flag)
 	*flag = !*flag;
 	*statustext_time = 0;
 	statustext = msg[*flag];
-	client->setHighlighted(client->getHighlighted(), *flag);
+	if (g_settings->getBool("enable_node_highlighting"))
+		client->setHighlighted(client->getHighlighted(), *flag);
 }
 
 
-- 
GitLab