Translated using Weblate (Japanese)
[oweals/minetest.git] / src / game.cpp
index 6655fe820c8371d2eb446ffe2dcb398bafed0dd1..840d627b6796916716d2ac0d0514068a2cc72f06 100644 (file)
@@ -375,7 +375,7 @@ PointedThing getPointedThing(Client *client, v3f player_position,
 
                                for (std::vector<aabb3f>::const_iterator
                                                i = boxes.begin();
-                                               i != boxes.end(); i++) {
+                                               i != boxes.end(); ++i) {
                                        aabb3f box = *i;
                                        box.MinEdge += npf;
                                        box.MaxEdge += npf;
@@ -420,7 +420,7 @@ PointedThing getPointedThing(Client *client, v3f player_position,
                                                if (!g_settings->getBool("enable_node_highlighting")) {
                                                        for (std::vector<aabb3f>::const_iterator
                                                                        i2 = boxes.begin();
-                                                                       i2 != boxes.end(); i2++) {
+                                                                       i2 != boxes.end(); ++i2) {
                                                                aabb3f box = *i2;
                                                                box.MinEdge += npf + v3f(-d, -d, -d) - intToFloat(camera_offset, BS);
                                                                box.MaxEdge += npf + v3f(d, d, d) - intToFloat(camera_offset, BS);
@@ -514,11 +514,11 @@ public:
                std::map<std::string, Meta> m_meta;
 
                for (std::vector<Piece>::const_iterator k = m_log.begin();
-                               k != m_log.end(); k++) {
+                               k != m_log.end(); ++k) {
                        const Piece &piece = *k;
 
                        for (Profiler::GraphValues::const_iterator i = piece.values.begin();
-                                       i != piece.values.end(); i++) {
+                                       i != piece.values.end(); ++i) {
                                const std::string &id = i->first;
                                const float &value = i->second;
                                std::map<std::string, Meta>::iterator j =
@@ -550,7 +550,7 @@ public:
                u32 next_color_i = 0;
 
                for (std::map<std::string, Meta>::iterator i = m_meta.begin();
-                               i != m_meta.end(); i++) {
+                               i != m_meta.end(); ++i) {
                        Meta &meta = i->second;
                        video::SColor color(255, 200, 200, 200);
 
@@ -566,7 +566,7 @@ public:
                s32 meta_i = 0;
 
                for (std::map<std::string, Meta>::const_iterator i = m_meta.begin();
-                               i != m_meta.end(); i++) {
+                               i != m_meta.end(); ++i) {
                        const std::string &id = i->first;
                        const Meta &meta = i->second;
                        s32 x = x_left;
@@ -602,7 +602,7 @@ public:
                        bool lastscaledvalue_exists = false;
 
                        for (std::vector<Piece>::const_iterator j = m_log.begin();
-                                       j != m_log.end(); j++) {
+                                       j != m_log.end(); ++j) {
                                const Piece &piece = *j;
                                float value = 0;
                                bool value_exists = false;
@@ -1497,7 +1497,7 @@ protected:
 
        void toggleChat(float *statustext_time, bool *flag);
        void toggleHud(float *statustext_time, bool *flag);
-       void toggleMinimap(float *statustext_time, bool *flag1, bool *flag2,
+       void toggleMinimap(float *statustext_time, bool *flag, bool show_hud,
                        bool shift_pressed);
        void toggleFog(float *statustext_time, bool *flag);
        void toggleDebug(float *statustext_time, bool *show_debug,
@@ -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();
        }
 }
 
@@ -2642,7 +2645,7 @@ void Game::processKeyboardInput(VolatileRunFlags *flags,
        } else if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_TOGGLE_HUD])) {
                toggleHud(statustext_time, &flags->show_hud);
        } else if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_MINIMAP])) {
-               toggleMinimap(statustext_time, &flags->show_minimap, &flags->show_hud,
+               toggleMinimap(statustext_time, &flags->show_minimap, flags->show_hud,
                        input->isKeyDown(keycache.key[KeyCache::KEYMAP_ID_SNEAK]));
        } else if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_TOGGLE_CHAT])) {
                toggleChat(statustext_time, &flags->show_chat);
@@ -2864,43 +2867,54 @@ void Game::toggleHud(float *statustext_time, bool *flag)
                client->setHighlighted(client->getHighlighted(), *flag);
 }
 
-void Game::toggleMinimap(float *statustext_time, bool *flag, bool *show_hud, bool shift_pressed)
+void Game::toggleMinimap(float *statustext_time, bool *flag,
+       bool show_hud, bool shift_pressed)
 {
-       if (*show_hud && g_settings->getBool("enable_minimap")) {
-               if (shift_pressed) {
-                       mapper->toggleMinimapShape();
-                       return;
-               }
-               MinimapMode mode = mapper->getMinimapMode();
-               mode = (MinimapMode)((int)(mode) + 1);
-               *flag = true;
-               switch (mode) {
-                       case MINIMAP_MODE_SURFACEx1:
-                               statustext = L"Minimap in surface mode, Zoom x1";
-                               break;
-                       case MINIMAP_MODE_SURFACEx2:
-                               statustext = L"Minimap in surface mode, Zoom x2";
-                               break;
-                       case MINIMAP_MODE_SURFACEx4:
-                               statustext = L"Minimap in surface mode, Zoom x4";
-                               break;
-                       case MINIMAP_MODE_RADARx1:
-                               statustext = L"Minimap in radar mode, Zoom x1";
-                               break;
-                       case MINIMAP_MODE_RADARx2:
-                               statustext = L"Minimap in radar mode, Zoom x2";
-                               break;
-                       case MINIMAP_MODE_RADARx4:
-                               statustext = L"Minimap in radar mode, Zoom x4";
-                               break;
-                       default:
-                               mode = MINIMAP_MODE_OFF;
-                               *flag = false;
-                               statustext = L"Minimap hidden";
-               }
-               *statustext_time = 0;
-               mapper->setMinimapMode(mode);
+       if (!show_hud || !g_settings->getBool("enable_minimap"))
+               return;
+
+       if (shift_pressed) {
+               mapper->toggleMinimapShape();
+               return;
        }
+
+       u32 hud_flags = client->getEnv().getLocalPlayer()->hud_flags;
+
+       MinimapMode mode = MINIMAP_MODE_OFF;
+       if (hud_flags & HUD_FLAG_MINIMAP_VISIBLE) {
+               mode = mapper->getMinimapMode();
+               mode = (MinimapMode)((int)mode + 1);
+       }
+
+       *flag = true;
+       switch (mode) {
+               case MINIMAP_MODE_SURFACEx1:
+                       statustext = L"Minimap in surface mode, Zoom x1";
+                       break;
+               case MINIMAP_MODE_SURFACEx2:
+                       statustext = L"Minimap in surface mode, Zoom x2";
+                       break;
+               case MINIMAP_MODE_SURFACEx4:
+                       statustext = L"Minimap in surface mode, Zoom x4";
+                       break;
+               case MINIMAP_MODE_RADARx1:
+                       statustext = L"Minimap in radar mode, Zoom x1";
+                       break;
+               case MINIMAP_MODE_RADARx2:
+                       statustext = L"Minimap in radar mode, Zoom x2";
+                       break;
+               case MINIMAP_MODE_RADARx4:
+                       statustext = L"Minimap in radar mode, Zoom x4";
+                       break;
+               default:
+                       mode = MINIMAP_MODE_OFF;
+                       *flag = false;
+                       statustext = (hud_flags & HUD_FLAG_MINIMAP_VISIBLE) ?
+                               L"Minimap hidden" : L"Minimap disabled by server";
+       }
+
+       *statustext_time = 0;
+       mapper->setMinimapMode(mode);
 }
 
 void Game::toggleFog(float *statustext_time, bool *flag)