1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-11-05 08:55:01 -05:00

Hide minimap if it has been disabled by server

This commit is contained in:
est31 2015-09-01 03:07:02 +02:00
parent dce9468925
commit 0903190ba2
5 changed files with 22 additions and 2 deletions

View File

@ -228,6 +228,7 @@ Client::Client(
m_particle_manager(&m_env), m_particle_manager(&m_env),
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, ipv6, this), m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, ipv6, this),
m_device(device), m_device(device),
m_minimap_disabled_by_server(false),
m_server_ser_ver(SER_FMT_VER_INVALID), m_server_ser_ver(SER_FMT_VER_INVALID),
m_proto_ver(0), m_proto_ver(0),
m_playeritem(0), m_playeritem(0),

View File

@ -510,6 +510,9 @@ public:
Mapper* getMapper () Mapper* getMapper ()
{ return m_mapper; } { return m_mapper; }
bool isMinimapDisabledByServer()
{ return m_minimap_disabled_by_server; }
// IGameDef interface // IGameDef interface
virtual IItemDefManager* getItemDefManager(); virtual IItemDefManager* getItemDefManager();
virtual INodeDefManager* getNodeDefManager(); virtual INodeDefManager* getNodeDefManager();
@ -590,6 +593,7 @@ private:
con::Connection m_con; con::Connection m_con;
IrrlichtDevice *m_device; IrrlichtDevice *m_device;
Mapper *m_mapper; Mapper *m_mapper;
bool m_minimap_disabled_by_server;
// Server serialization version // Server serialization version
u8 m_server_ser_ver; u8 m_server_ser_ver;

View File

@ -1857,6 +1857,9 @@ void Game::run()
updateFrame(highlight_boxes, &graph, &stats, &runData, dtime, updateFrame(highlight_boxes, &graph, &stats, &runData, dtime,
flags, cam_view); flags, cam_view);
updateProfilerGraphs(&graph); updateProfilerGraphs(&graph);
// Update if minimap has been disabled by the server
flags.show_minimap &= !client->isMinimapDisabledByServer();
} }
} }

View File

@ -33,8 +33,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define HUD_CORNER_CENTER 2 #define HUD_CORNER_CENTER 2
// Note that these visibility flags do not determine if the hud items are // 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 // actually drawn, but rather, whether to draw the item should the rest
// the game state permit it. // of the game state permit it.
#define HUD_FLAG_HOTBAR_VISIBLE (1 << 0) #define HUD_FLAG_HOTBAR_VISIBLE (1 << 0)
#define HUD_FLAG_HEALTHBAR_VISIBLE (1 << 1) #define HUD_FLAG_HEALTHBAR_VISIBLE (1 << 1)
#define HUD_FLAG_CROSSHAIR_VISIBLE (1 << 2) #define HUD_FLAG_CROSSHAIR_VISIBLE (1 << 2)

View File

@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h" #include "log.h"
#include "map.h" #include "map.h"
#include "mapsector.h" #include "mapsector.h"
#include "minimap.h"
#include "nodedef.h" #include "nodedef.h"
#include "serialization.h" #include "serialization.h"
#include "server.h" #include "server.h"
@ -1094,8 +1095,19 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt)
Player *player = m_env.getLocalPlayer(); Player *player = m_env.getLocalPlayer();
assert(player != NULL); assert(player != NULL);
bool was_minimap_visible = player->hud_flags & HUD_FLAG_MINIMAP_VISIBLE;
player->hud_flags &= ~mask; player->hud_flags &= ~mask;
player->hud_flags |= flags; 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) void Client::handleCommand_HudSetParam(NetworkPacket* pkt)