diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-05-19 07:25:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-19 07:25:27 +0200 |
commit | e25a38e3fbb156ae2bc72cc66aef014ae3963407 (patch) | |
tree | f7f4f7e6e823650a60f4607e07d12d6705292eef | |
parent | 1c6d2f596df8fc2254916cf323bdbaf13905aebf (diff) | |
download | minetest-e25a38e3fbb156ae2bc72cc66aef014ae3963407.tar.gz minetest-e25a38e3fbb156ae2bc72cc66aef014ae3963407.tar.bz2 minetest-e25a38e3fbb156ae2bc72cc66aef014ae3963407.zip |
When minimap is disabled in configuration, really disable it (#5771)
* When minimap is disabled in configuration, really disable it
-rw-r--r-- | doc/client_lua_api.md | 1 | ||||
-rw-r--r-- | src/client.cpp | 7 | ||||
-rw-r--r-- | src/drawscene.cpp | 6 | ||||
-rw-r--r-- | src/drawscene.h | 2 | ||||
-rw-r--r-- | src/game.cpp | 26 | ||||
-rw-r--r-- | src/network/clientpackethandler.cpp | 2 | ||||
-rw-r--r-- | src/script/scripting_client.cpp | 3 |
7 files changed, 28 insertions, 19 deletions
diff --git a/doc/client_lua_api.md b/doc/client_lua_api.md index 9f59b4671..2c0351a11 100644 --- a/doc/client_lua_api.md +++ b/doc/client_lua_api.md @@ -800,6 +800,7 @@ Call these functions only at load time! ### UI * `minetest.ui.minimap` * Reference to the minimap object. See [`Minimap`](#minimap) class reference for methods. + * If client disabled minimap (using enable_minimap setting) this reference will be nil. * `minetest.camera` * Reference to the camera object. See [`Camera`](#camera) class reference for methods. * `minetest.show_formspec(formname, formspec)` : returns true on success diff --git a/src/client.cpp b/src/client.cpp index 1e17e7c11..6ab4002a5 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -93,6 +93,7 @@ Client::Client( m_address_name(address_name), m_device(device), m_camera(NULL), + m_minimap(NULL), m_minimap_disabled_by_server(false), m_server_ser_ver(SER_FMT_VER_INVALID), m_proto_ver(0), @@ -127,7 +128,9 @@ Client::Client( // Add local player m_env.setLocalPlayer(new LocalPlayer(this, playername)); - m_minimap = new Minimap(device, this); + if (g_settings->getBool("enable_minimap")) { + m_minimap = new Minimap(device, this); + } m_cache_save_interval = g_settings->getU16("server_map_save_interval"); m_modding_enabled = g_settings->getBool("enable_client_modding"); @@ -502,7 +505,7 @@ void Client::step(float dtime) delete r.mesh; } - if (do_mapper_update) + if (m_minimap && do_mapper_update) m_minimap->addBlock(r.p, minimap_mapblock); if (r.ack_block_to_server) { diff --git a/src/drawscene.cpp b/src/drawscene.cpp index 7d2d1d12f..59f9b8375 100644 --- a/src/drawscene.cpp +++ b/src/drawscene.cpp @@ -509,7 +509,7 @@ void draw_plain(Camera &camera, bool show_hud, void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr, Camera &camera, Client &client, LocalPlayer *player, Hud &hud, - Minimap &mapper, gui::IGUIEnvironment *guienv, + Minimap *mapper, gui::IGUIEnvironment *guienv, const v2u32 &screensize, const video::SColor &skycolor, bool show_hud, bool show_minimap) { @@ -584,8 +584,8 @@ void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr, hud.drawLuaElements(camera.getOffset()); camera.drawNametags(); - if (show_minimap) - mapper.drawMinimap(); + if (mapper && show_minimap) + mapper->drawMinimap(); } guienv->drawAll(); diff --git a/src/drawscene.h b/src/drawscene.h index 4a71b1f4e..99ff1a6bc 100644 --- a/src/drawscene.h +++ b/src/drawscene.h @@ -32,7 +32,7 @@ void draw_load_screen(const std::wstring &text, IrrlichtDevice *device, void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr, Camera &camera, Client &client, LocalPlayer *player, - Hud &hud, Minimap &mapper, gui::IGUIEnvironment *guienv, + Hud &hud, Minimap *mapper, gui::IGUIEnvironment *guienv, const v2u32 &screensize, const video::SColor &skycolor, bool show_hud, bool show_minimap); diff --git a/src/game.cpp b/src/game.cpp index f079f836b..f967e349c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -715,16 +715,19 @@ public: m_eye_position_pixel.set(eye_position_array, services); m_eye_position_vertex.set(eye_position_array, services); - float minimap_yaw_array[3]; - v3f minimap_yaw = m_client->getMinimap()->getYawVec(); + if (m_client->getMinimap()) { + float minimap_yaw_array[3]; + v3f minimap_yaw = m_client->getMinimap()->getYawVec(); #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8) - minimap_yaw_array[0] = minimap_yaw.X; - minimap_yaw_array[1] = minimap_yaw.Y; - minimap_yaw_array[2] = minimap_yaw.Z; + minimap_yaw_array[0] = minimap_yaw.X; + minimap_yaw_array[1] = minimap_yaw.Y; + minimap_yaw_array[2] = minimap_yaw.Z; #else - minimap_yaw.getAs3Values(minimap_yaw_array); + minimap_yaw.getAs3Values(minimap_yaw_array); #endif - m_minimap_yaw.set(minimap_yaw_array, services); + m_minimap_yaw.set(minimap_yaw_array, services); + + } SamplerLayer_t base_tex = 0, normal_tex = 1, @@ -1948,7 +1951,8 @@ bool Game::createClient(const std::string &playername, } mapper = client->getMinimap(); - mapper->setMinimapMode(MINIMAP_MODE_OFF); + if (mapper) + mapper->setMinimapMode(MINIMAP_MODE_OFF); return true; } @@ -2781,7 +2785,7 @@ void Game::toggleHud() void Game::toggleMinimap(bool shift_pressed) { - if (!flags.show_hud || !g_settings->getBool("enable_minimap")) + if (!mapper || !flags.show_hud || !g_settings->getBool("enable_minimap")) return; if (shift_pressed) { @@ -4194,7 +4198,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, TimeTaker tt_draw("mainloop: draw"); driver->beginScene(true, true, skycolor); - draw_scene(driver, smgr, *camera, *client, player, *hud, *mapper, + draw_scene(driver, smgr, *camera, *client, player, *hud, mapper, guienv, screensize, skycolor, flags.show_hud, flags.show_minimap); @@ -4229,7 +4233,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, /* Update minimap pos and rotation */ - if (flags.show_minimap && flags.show_hud) { + if (mapper && flags.show_minimap && flags.show_hud) { mapper->setPos(floatToInt(player->getPosition(), BS)); mapper->setAngle(player->getYaw()); } diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 0dd09c6d1..59669fe6d 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -1150,7 +1150,7 @@ void Client::handleCommand_HudSetFlags(NetworkPacket* pkt) 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) { + if (m_minimap && 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_minimap->setMinimapMode(MINIMAP_MODE_OFF); diff --git a/src/script/scripting_client.cpp b/src/script/scripting_client.cpp index 24f70b8c1..da289e564 100644 --- a/src/script/scripting_client.cpp +++ b/src/script/scripting_client.cpp @@ -51,7 +51,8 @@ ClientScripting::ClientScripting(Client *client): InitializeModApi(L, top); lua_pop(L, 1); - LuaMinimap::create(L, client->getMinimap()); + if (client->getMinimap()) + LuaMinimap::create(L, client->getMinimap()); // Push builtin initialization type lua_pushstring(L, "client"); |