aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-09-01 03:07:02 +0200
committerest31 <MTest31@outlook.com>2015-09-01 19:00:33 +0200
commit0903190ba2ed2134c464f2efe694d7281ead1c09 (patch)
tree94d4a169560be1e9ef4b69574b9f1c8ab0b0c06c
parentdce9468925b2208b8178722af218d9cd30a35a64 (diff)
downloadminetest-0903190ba2ed2134c464f2efe694d7281ead1c09.tar.gz
minetest-0903190ba2ed2134c464f2efe694d7281ead1c09.tar.bz2
minetest-0903190ba2ed2134c464f2efe694d7281ead1c09.zip
Hide minimap if it has been disabled by server
-rw-r--r--src/client.cpp1
-rw-r--r--src/client.h4
-rw-r--r--src/game.cpp3
-rw-r--r--src/hud.h4
-rw-r--r--src/network/clientpackethandler.cpp12
5 files changed, 22 insertions, 2 deletions
diff --git a/src/client.cpp b/src/client.cpp
index dda0f5191..4a9398f70 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -228,6 +228,7 @@ Client::Client(
m_particle_manager(&m_env),
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, ipv6, this),
m_device(device),
+ m_minimap_disabled_by_server(false),
m_server_ser_ver(SER_FMT_VER_INVALID),
m_proto_ver(0),
m_playeritem(0),
diff --git a/src/client.h b/src/client.h
index 75fd0c984..5b57aa52a 100644
--- a/src/client.h
+++ b/src/client.h
@@ -510,6 +510,9 @@ public:
Mapper* getMapper ()
{ return m_mapper; }
+ bool isMinimapDisabledByServer()
+ { return m_minimap_disabled_by_server; }
+
// IGameDef interface
virtual IItemDefManager* getItemDefManager();
virtual INodeDefManager* getNodeDefManager();
@@ -590,6 +593,7 @@ private:
con::Connection m_con;
IrrlichtDevice *m_device;
Mapper *m_mapper;
+ bool m_minimap_disabled_by_server;
// Server serialization version
u8 m_server_ser_ver;
diff --git a/src/game.cpp b/src/game.cpp
index 0e26493a2..840d627b6 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1857,6 +1857,9 @@ void Game::run()
updateFrame(highlight_boxes, &graph, &stats, &runData, dtime,
flags, cam_view);
updateProfilerGraphs(&graph);
+
+ // Update if minimap has been disabled by the server
+ flags.show_minimap &= !client->isMinimapDisabledByServer();
}
}
diff --git a/src/hud.h b/src/hud.h
index 614e7c92d..65453aec1 100644
--- a/src/hud.h
+++ b/src/hud.h
@@ -33,8 +33,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define HUD_CORNER_CENTER 2
// Note that these visibility flags do not determine if the hud items are
-// actually drawn, but rather, allows the item to be drawn should the rest of
-// the game state permit it.
+// actually drawn, but rather, whether to draw the item should the rest
+// of the game state permit it.
#define HUD_FLAG_HOTBAR_VISIBLE (1 << 0)
#define HUD_FLAG_HEALTHBAR_VISIBLE (1 << 1)
#define HUD_FLAG_CROSSHAIR_VISIBLE (1 << 2)
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index 04f94c58b..d49c96029 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h"
#include "map.h"
#include "mapsector.h"
+#include "minimap.h"
#include "nodedef.h"
#include "serialization.h"
#include "server.h"
@@ -1094,8 +1095,19 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt)
Player *player = m_env.getLocalPlayer();
assert(player != NULL);
+ bool was_minimap_visible = player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE;
+
player->hud_flags &= ~mask;
player->hud_flags |= flags;
+
+ m_minimap_disabled_by_server = !(player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE);
+
+ // Hide minimap if it has been disabled by the server
+ if (m_minimap_disabled_by_server && was_minimap_visible) {
+ // defers a minimap update, therefore only call it if really
+ // needed, by checking that minimap was visible before
+ m_mapper->setMinimapMode(MINIMAP_MODE_OFF);
+ }
}
void Client::handleCommand_HudSetParam(NetworkPacket* pkt)