Add cancel button to password change menu. (#5720)
[oweals/minetest.git] / src / game.cpp
index 9d52e4326e85bca01e1ea773492fa69c0e683d01..9de4732311b5ad801c9b0dbd01421c51fe48a98f 100644 (file)
@@ -60,7 +60,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "version.h"
 #include "minimap.h"
 #include "mapblock_mesh.h"
-#include "script/clientscripting.h"
+#include "script/scripting_client.h"
 
 #include "sound.h"
 
@@ -79,14 +79,15 @@ extern Profiler *g_profiler;
        Text input system
 */
 
-struct TextDestNodeMetadata : public TextDest {
+struct TextDestNodeMetadata : public TextDest
+{
        TextDestNodeMetadata(v3s16 p, Client *client)
        {
                m_p = p;
                m_client = client;
        }
        // This is deprecated I guess? -celeron55
-       void gotText(std::wstring text)
+       void gotText(const std::wstring &text)
        {
                std::string ntext = wide_to_utf8(text);
                infostream << "Submitting 'text' field of node at (" << m_p.X << ","
@@ -104,13 +105,14 @@ struct TextDestNodeMetadata : public TextDest {
        Client *m_client;
 };
 
-struct TextDestPlayerInventory : public TextDest {
+struct TextDestPlayerInventory : public TextDest
+{
        TextDestPlayerInventory(Client *client)
        {
                m_client = client;
                m_formname = "";
        }
-       TextDestPlayerInventory(Client *client, std::string formname)
+       TextDestPlayerInventory(Client *client, const std::string &formname)
        {
                m_client = client;
                m_formname = formname;
@@ -125,23 +127,18 @@ struct TextDestPlayerInventory : public TextDest {
 
 struct LocalFormspecHandler : public TextDest
 {
-       LocalFormspecHandler(std::string formname):
-               m_client(0)
+       LocalFormspecHandler(const std::string &formname):
+               m_client(NULL)
        {
                m_formname = formname;
        }
 
-       LocalFormspecHandler(std::string formname, Client *client):
+       LocalFormspecHandler(const std::string &formname, Client *client):
                m_client(client)
        {
                m_formname = formname;
        }
 
-       void gotText(std::wstring message)
-       {
-               errorstream << "LocalFormspecHandler::gotText old style message received" << std::endl;
-       }
-
        void gotText(const StringMap &fields)
        {
                if (m_formname == "MT_PAUSE_MENU") {
@@ -205,7 +202,8 @@ public:
 
                return meta->getString("formspec");
        }
-       std::string resolveText(std::string str)
+
+       virtual std::string resolveText(const std::string &str)
        {
                NodeMetadata *meta = m_map->getNodeMetadata(m_p);
 
@@ -478,6 +476,7 @@ class SoundMaker
        ISoundManager *m_sound;
        INodeDefManager *m_ndef;
 public:
+       bool makes_footstep_sound;
        float m_player_step_timer;
 
        SimpleSoundSpec m_player_step_sound;
@@ -487,6 +486,7 @@ public:
        SoundMaker(ISoundManager *sound, INodeDefManager *ndef):
                m_sound(sound),
                m_ndef(ndef),
+               makes_footstep_sound(true),
                m_player_step_timer(0)
        {
        }
@@ -495,7 +495,8 @@ public:
        {
                if (m_player_step_timer <= 0 && m_player_step_sound.exists()) {
                        m_player_step_timer = 0.03;
-                       m_sound->playSound(m_player_step_sound, false);
+                       if (makes_footstep_sound)
+                               m_sound->playSound(m_player_step_sound, false);
                }
        }
 
@@ -569,27 +570,35 @@ public:
 class GameOnDemandSoundFetcher: public OnDemandSoundFetcher
 {
        std::set<std::string> m_fetched;
+private:
+       void paths_insert(std::set<std::string> &dst_paths,
+               const std::string &base,
+               const std::string &name)
+       {
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".ogg");
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".0.ogg");
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".1.ogg");
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".2.ogg");
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".3.ogg");
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".4.ogg");
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".5.ogg");
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".6.ogg");
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".7.ogg");
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".8.ogg");
+               dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".9.ogg");
+       }
 public:
        void fetchSounds(const std::string &name,
-                       std::set<std::string> &dst_paths,
-                       std::set<std::string> &dst_datas)
+               std::set<std::string> &dst_paths,
+               std::set<std::string> &dst_datas)
        {
                if (m_fetched.count(name))
                        return;
 
                m_fetched.insert(name);
-               std::string base = porting::path_share + DIR_DELIM + "sounds";
-               dst_paths.insert(base + DIR_DELIM + name + ".ogg");
-               dst_paths.insert(base + DIR_DELIM + name + ".0.ogg");
-               dst_paths.insert(base + DIR_DELIM + name + ".1.ogg");
-               dst_paths.insert(base + DIR_DELIM + name + ".2.ogg");
-               dst_paths.insert(base + DIR_DELIM + name + ".3.ogg");
-               dst_paths.insert(base + DIR_DELIM + name + ".4.ogg");
-               dst_paths.insert(base + DIR_DELIM + name + ".5.ogg");
-               dst_paths.insert(base + DIR_DELIM + name + ".6.ogg");
-               dst_paths.insert(base + DIR_DELIM + name + ".7.ogg");
-               dst_paths.insert(base + DIR_DELIM + name + ".8.ogg");
-               dst_paths.insert(base + DIR_DELIM + name + ".9.ogg");
+
+               paths_insert(dst_paths, porting::path_share, name);
+               paths_insert(dst_paths, porting::path_user,  name);
        }
 };
 
@@ -1034,11 +1043,17 @@ void KeyCache::populate()
        key[KeyType::INVENTORY]    = getKeySetting("keymap_inventory");
        key[KeyType::CHAT]         = getKeySetting("keymap_chat");
        key[KeyType::CMD]          = getKeySetting("keymap_cmd");
+       key[KeyType::CMD_LOCAL]    = getKeySetting("keymap_cmd_local");
        key[KeyType::CONSOLE]      = getKeySetting("keymap_console");
        key[KeyType::MINIMAP]      = getKeySetting("keymap_minimap");
        key[KeyType::FREEMOVE]     = getKeySetting("keymap_freemove");
        key[KeyType::FASTMOVE]     = getKeySetting("keymap_fastmove");
        key[KeyType::NOCLIP]       = getKeySetting("keymap_noclip");
+       key[KeyType::HOTBAR_PREV]  = getKeySetting("keymap_hotbar_previous");
+       key[KeyType::HOTBAR_NEXT]  = getKeySetting("keymap_hotbar_next");
+       key[KeyType::MUTE]         = getKeySetting("keymap_mute");
+       key[KeyType::INC_VOLUME]   = getKeySetting("keymap_increase_volume");
+       key[KeyType::DEC_VOLUME]   = getKeySetting("keymap_decrease_volume");
        key[KeyType::CINEMATIC]    = getKeySetting("keymap_cinematic");
        key[KeyType::SCREENSHOT]   = getKeySetting("keymap_screenshot");
        key[KeyType::TOGGLE_HUD]   = getKeySetting("keymap_toggle_hud");
@@ -1110,6 +1125,7 @@ struct GameRunData {
        PointedThing pointed_old;
        bool digging;
        bool ldown_for_dig;
+       bool dig_instantly;
        bool left_punch;
        bool update_wielded_item_trigger;
        bool reset_jump_timer;
@@ -1189,7 +1205,7 @@ protected:
                        u16 port,
                        const SubgameSpec &gamespec);
        bool initSound();
-       bool createSingleplayerServer(const std::string map_dir,
+       bool createSingleplayerServer(const std::string &map_dir,
                        const SubgameSpec &gamespec, u16 port, std::string *address);
 
        // Client creation
@@ -1621,10 +1637,26 @@ void Game::run()
                        && client->checkPrivilege("fast");
 #endif
 
+       irr::core::dimension2d<u32> previous_screen_size(g_settings->getU16("screenW"),
+               g_settings->getU16("screenH"));
+
        while (device->run()
                        && !(*kill || g_gamecallback->shutdown_requested
                        || (server && server->getShutdownRequested()))) {
 
+               const irr::core::dimension2d<u32> &current_screen_size =
+                       device->getVideoDriver()->getScreenSize();
+               // Verify if window size has changed and save it if it's the case
+               // Ensure evaluating settings->getBool after verifying screensize
+               // First condition is cheaper
+               if (previous_screen_size != current_screen_size &&
+                               current_screen_size != irr::core::dimension2d<u32>(0,0) &&
+                               g_settings->getBool("autosave_screensize")) {
+                       g_settings->setU16("screenW", current_screen_size.Width);
+                       g_settings->setU16("screenH", current_screen_size.Height);
+                       previous_screen_size = current_screen_size;
+               }
+
                /* Must be called immediately after a device->run() call because it
                 * uses device->getTimer()->getTime()
                 */
@@ -1724,9 +1756,10 @@ bool Game::init(
                u16 port,
                const SubgameSpec &gamespec)
 {
+       texture_src = createTextureSource(device);
+
        showOverlayMessage(wgettext("Loading..."), 0, 0);
 
-       texture_src = createTextureSource(device);
        shader_src = createShaderSource(device);
 
        itemdef_manager = createItemDefManager();
@@ -1778,7 +1811,7 @@ bool Game::initSound()
        return true;
 }
 
-bool Game::createSingleplayerServer(const std::string map_dir,
+bool Game::createSingleplayerServer(const std::string &map_dir,
                const SubgameSpec &gamespec, u16 port, std::string *address)
 {
        showOverlayMessage(wgettext("Creating server..."), 0, 5);
@@ -2035,7 +2068,7 @@ bool Game::connectToServer(const std::string &playername,
        }
 
        client = new Client(device,
-                       playername.c_str(), password,
+                       playername.c_str(), password, *address,
                        *draw_control, texture_src, shader_src,
                        itemdef_manager, nodedef_manager, sound, eventmgr,
                        connect_address.isIPv6(), &flags);
@@ -2047,7 +2080,7 @@ bool Game::connectToServer(const std::string &playername,
        connect_address.print(&infostream);
        infostream << std::endl;
 
-       client->connect(connect_address, *address,
+       client->connect(connect_address,
                simple_singleplayer_mode || local_server_mode);
 
        /*
@@ -2182,17 +2215,21 @@ bool Game::getServerContent(bool *aborted)
                if (!client->itemdefReceived()) {
                        const wchar_t *text = wgettext("Item definitions...");
                        progress = 25;
-                       draw_load_screen(text, device, guienv, dtime, progress);
+                       draw_load_screen(text, device, guienv, texture_src,
+                               dtime, progress);
                        delete[] text;
                } else if (!client->nodedefReceived()) {
                        const wchar_t *text = wgettext("Node definitions...");
                        progress = 30;
-                       draw_load_screen(text, device, guienv, dtime, progress);
+                       draw_load_screen(text, device, guienv, texture_src,
+                               dtime, progress);
                        delete[] text;
                } else {
                        std::stringstream message;
-                       message.precision(3);
-                       message << gettext("Media...");
+                       std::fixed(message);
+                       message.precision(0);
+                       message << gettext("Media...") << " " << (client->mediaReceiveProgress()*100) << "%";
+                       message.precision(2);
 
                        if ((USE_CURL == 0) ||
                                        (!g_settings->getBool("enable_remote_media_server"))) {
@@ -2209,7 +2246,7 @@ bool Game::getServerContent(bool *aborted)
 
                        progress = 30 + client->mediaReceiveProgress() * 35 + 0.5;
                        draw_load_screen(utf8_to_wide(message.str()), device,
-                                       guienv, dtime, progress);
+                                       guienv, texture_src, dtime, progress);
                }
        }
 
@@ -2449,6 +2486,8 @@ void Game::processKeyInput()
                openConsole(0.2, L"");
        } else if (wasKeyDown(KeyType::CMD)) {
                openConsole(0.2, L"/");
+       } else if (wasKeyDown(KeyType::CMD_LOCAL)) {
+               openConsole(0.2, L".");
        } else if (wasKeyDown(KeyType::CONSOLE)) {
                openConsole(core::clamp(g_settings->getFloat("console_height"), 0.1f, 1.0f));
        } else if (wasKeyDown(KeyType::FREEMOVE)) {
@@ -2459,6 +2498,30 @@ void Game::processKeyInput()
                toggleFast();
        } else if (wasKeyDown(KeyType::NOCLIP)) {
                toggleNoClip();
+       } else if (wasKeyDown(KeyType::MUTE)) {
+               float volume = g_settings->getFloat("sound_volume");
+               if (volume < 0.001f) {
+                       g_settings->setFloat("sound_volume", 1.0f);
+                       m_statustext = narrow_to_wide(gettext("Volume changed to 100%"));
+               } else {
+                       g_settings->setFloat("sound_volume", 0.0f);
+                       m_statustext = narrow_to_wide(gettext("Volume changed to 0%"));
+               }
+               runData.statustext_time = 0;
+       } else if (wasKeyDown(KeyType::INC_VOLUME)) {
+               float new_volume = rangelim(g_settings->getFloat("sound_volume") + 0.1f, 0.0f, 1.0f);
+               char buf[100];
+               g_settings->setFloat("sound_volume", new_volume);
+               snprintf(buf, sizeof(buf), gettext("Volume changed to %d%%"), myround(new_volume * 100));
+               m_statustext = narrow_to_wide(buf);
+               runData.statustext_time = 0;
+       } else if (wasKeyDown(KeyType::DEC_VOLUME)) {
+               float new_volume = rangelim(g_settings->getFloat("sound_volume") - 0.1f, 0.0f, 1.0f);
+               char buf[100];
+               g_settings->setFloat("sound_volume", new_volume);
+               snprintf(buf, sizeof(buf), gettext("Volume changed to %d%%"), myround(new_volume * 100));
+               m_statustext = narrow_to_wide(buf);
+               runData.statustext_time = 0;
        } else if (wasKeyDown(KeyType::CINEMATIC)) {
                toggleCinematic();
        } else if (wasKeyDown(KeyType::SCREENSHOT)) {
@@ -2526,11 +2589,13 @@ void Game::processItemSelection(u16 *new_playeritem)
 
        s32 dir = wheel;
 
-       if (input->joystick.wasKeyDown(KeyType::SCROLL_DOWN)) {
+       if (input->joystick.wasKeyDown(KeyType::SCROLL_DOWN) ||
+                       wasKeyDown(KeyType::HOTBAR_NEXT)) {
                dir = -1;
        }
 
-       if (input->joystick.wasKeyDown(KeyType::SCROLL_UP)) {
+       if (input->joystick.wasKeyDown(KeyType::SCROLL_UP) ||
+                       wasKeyDown(KeyType::HOTBAR_PREV)) {
                dir = 1;
        }
 
@@ -3040,11 +3105,10 @@ inline void Game::step(f32 *dtime)
 
 void Game::processClientEvents(CameraOrientation *cam)
 {
-       ClientEvent event = client->getClientEvent();
-
        LocalPlayer *player = client->getEnv().getLocalPlayer();
 
-       for ( ; event.type != CE_NONE; event = client->getClientEvent()) {
+       while (client->hasClientEvents()) {
+               ClientEvent event = client->getClientEvent();
 
                switch (event.type) {
                case CE_PLAYER_DAMAGE:
@@ -3241,6 +3305,8 @@ void Game::processClientEvents(CameraOrientation *cam)
 
                case CE_SET_SKY:
                        sky->setVisible(false);
+                       // Whether clouds are visible in front of a custom skybox
+                       sky->setCloudsEnabled(event.set_sky.clouds);
 
                        if (skybox) {
                                skybox->remove();
@@ -3250,6 +3316,7 @@ void Game::processClientEvents(CameraOrientation *cam)
                        // Handle according to type
                        if (*event.set_sky.type == "regular") {
                                sky->setVisible(true);
+                               sky->setCloudsEnabled(true);
                        } else if (*event.set_sky.type == "skybox" &&
                                        event.set_sky.params->size() == 6) {
                                sky->setFallbackBgColor(*event.set_sky.bgcolor);
@@ -3281,6 +3348,19 @@ void Game::processClientEvents(CameraOrientation *cam)
                                        event.override_day_night_ratio.ratio_f * 1000);
                        break;
 
+               case CE_CLOUD_PARAMS:
+                       if (clouds) {
+                               clouds->setDensity(event.cloud_params.density);
+                               clouds->setColorBright(video::SColor(event.cloud_params.color_bright));
+                               clouds->setColorAmbient(video::SColor(event.cloud_params.color_ambient));
+                               clouds->setHeight(event.cloud_params.height);
+                               clouds->setThickness(event.cloud_params.thickness);
+                               clouds->setSpeed(v2f(
+                                               event.cloud_params.speed_x,
+                                               event.cloud_params.speed_y));
+                       }
+                       break;
+
                default:
                        // unknown or unhandled type
                        break;
@@ -3373,11 +3453,14 @@ void Game::updateSound(f32 dtime)
                              camera->getCameraNode()->getUpVector());
        sound->setListenerGain(g_settings->getFloat("sound_volume"));
 
+       LocalPlayer *player = client->getEnv().getLocalPlayer();
 
-       //      Update sound maker
-       soundmaker->step(dtime);
+       // Tell the sound maker whether to make footstep sounds
+       soundmaker->makes_footstep_sound = player->makes_footstep_sound;
 
-       LocalPlayer *player = client->getEnv().getLocalPlayer();
+       //      Update sound maker
+       if (player->makes_footstep_sound)
+               soundmaker->step(dtime);
 
        ClientMap &map = client->getEnv().getClientMap();
        MapNode n = map.getNodeNoEx(player->getFootstepNodePos());
@@ -3397,13 +3480,11 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
                        playeritem = mlist->getItem(client->getPlayerItem());
        }
 
-       if (playeritem.getDefinition(itemdef_manager).name.empty()) { // override the hand
-               InventoryList *hlist = local_inventory->getList("hand");
-               if (hlist)
-                       playeritem = hlist->getItem(0);
-       }
        const ItemDefinition &playeritem_def =
                        playeritem.getDefinition(itemdef_manager);
+       InventoryList *hlist = local_inventory->getList("hand");
+       const ItemDefinition &hand_def =
+               hlist ? hlist->getItem(0).getDefinition(itemdef_manager) : itemdef_manager->get("");
 
        v3f player_position  = player->getPosition();
        v3f camera_position  = camera->getPosition();
@@ -3416,7 +3497,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
        */
 
        f32 d = playeritem_def.range; // max. distance
-       f32 d_hand = itemdef_manager->get("").range;
+       f32 d_hand = hand_def.range;
 
        if (d < 0 && d_hand >= 0)
                d = d_hand;
@@ -3483,6 +3564,10 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
                        client->setCrack(-1, v3s16(0, 0, 0));
                        runData.dig_time = 0.0;
                }
+       } else if (runData.dig_instantly && getLeftReleased()) {
+               // Remove e.g. torches faster when clicking instead of holding LMB
+               runData.nodig_delay_timer = 0;
+               runData.dig_instantly = false;
        }
 
        if (!runData.digging && runData.ldown_for_dig && !isLeftPressed()) {
@@ -3499,11 +3584,15 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
                runData.repeat_rightclick_timer = 0;
 
        if (playeritem_def.usable && isLeftPressed()) {
-               if (getLeftClicked())
+               if (getLeftClicked() && (!client->moddingEnabled()
+                               || !client->getScript()->on_item_use(playeritem, pointed)))
                        client->interact(4, pointed);
        } else if (pointed.type == POINTEDTHING_NODE) {
                ToolCapabilities playeritem_toolcap =
                                playeritem.getToolCapabilities(itemdef_manager);
+               if (playeritem.name.empty()) {
+                       playeritem_toolcap = *hand_def.tool_capabilities;
+               }
                handlePointingAtNode(pointed, playeritem_def, playeritem_toolcap, dtime);
        } else if (pointed.type == POINTEDTHING_OBJECT) {
                handlePointingAtObject(pointed, playeritem, player_position, show_debug);
@@ -3710,6 +3799,9 @@ void Game::handlePointingAtNode(const PointedThing &pointed, const ItemDefinitio
                                // Read the sound
                                soundmaker->m_player_rightpunch_sound =
                                                playeritem_def.sound_place;
+
+                               if (client->moddingEnabled())
+                                       client->getScript()->on_placenode(pointed, playeritem_def);
                        } else {
                                soundmaker->m_player_rightpunch_sound =
                                                SimpleSoundSpec();
@@ -3763,9 +3855,16 @@ void Game::handlePointingAtObject(const PointedThing &pointed, const ItemStack &
                        // Report direct punch
                        v3f objpos = runData.selected_object->getPosition();
                        v3f dir = (objpos - player_position).normalize();
+                       ItemStack item = playeritem;
+                       if (playeritem.name.empty()) {
+                               InventoryList *hlist = local_inventory->getList("hand");
+                               if (hlist) {
+                                       item = hlist->getItem(0);
+                               }
+                       }
 
                        bool disable_send = runData.selected_object->directReportPunch(
-                                       dir, &playeritem, runData.time_from_last_punch);
+                                       dir, &item, runData.time_from_last_punch);
                        runData.time_from_last_punch = 0;
 
                        if (!disable_send)
@@ -3785,15 +3884,6 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
        ClientMap &map = client->getEnv().getClientMap();
        MapNode n = client->getEnv().getClientMap().getNodeNoEx(nodepos);
 
-       if (!runData.digging) {
-               infostream << "Started digging" << std::endl;
-               if (client->moddingEnabled() && client->getScript()->on_punchnode(nodepos, n))
-                       return;
-               client->interact(0, pointed);
-               runData.digging = true;
-               runData.ldown_for_dig = true;
-       }
-
        // NOTE: Similar piece of code exists on the server side for
        // cheat detection.
        // Get digging parameters
@@ -3802,13 +3892,25 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
 
        // If can't dig, try hand
        if (!params.diggable) {
-               const ItemDefinition &hand = itemdef_manager->get("");
+               InventoryList *hlist = local_inventory->getList("hand");
+               const ItemDefinition &hand =
+                       hlist ? hlist->getItem(0).getDefinition(itemdef_manager) : itemdef_manager->get("");
                const ToolCapabilities *tp = hand.tool_capabilities;
 
                if (tp)
                        params = getDigParams(nodedef_manager->get(n).groups, tp);
        }
 
+       if (!runData.digging) {
+               infostream << "Started digging" << std::endl;
+               runData.dig_instantly = params.time == 0;
+               if (client->moddingEnabled() && client->getScript()->on_punchnode(nodepos, n))
+                       return;
+               client->interact(0, pointed);
+               runData.digging = true;
+               runData.ldown_for_dig = true;
+       }
+
        if (!params.diggable) {
                // I guess nobody will wait for this long
                runData.dig_time_complete = 10000000.0;
@@ -3823,12 +3925,12 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
                }
        }
 
-       if (runData.dig_time_complete >= 0.001) {
+       if (!runData.dig_instantly) {
                runData.dig_index = (float)crack_animation_length
                                * runData.dig_time
                                / runData.dig_time_complete;
        } else {
-               // This is for torches
+               // This is for e.g. torches
                runData.dig_index = crack_animation_length;
        }
 
@@ -3863,17 +3965,12 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
                runData.nodig_delay_timer =
                                runData.dig_time_complete / (float)crack_animation_length;
 
-               // We don't want a corresponding delay to
-               // very time consuming nodes
+               // We don't want a corresponding delay to very time consuming nodes
+               // and nodes without digging time (e.g. torches) get a fixed delay.
                if (runData.nodig_delay_timer > 0.3)
                        runData.nodig_delay_timer = 0.3;
-
-               // We want a slight delay to very little
-               // time consuming nodes
-               const float mindelay = 0.15;
-
-               if (runData.nodig_delay_timer < mindelay)
-                       runData.nodig_delay_timer = mindelay;
+               else if (runData.dig_instantly)
+                       runData.nodig_delay_timer = 0.15;
 
                bool is_valid_position;
                MapNode wasnode = map.getNodeNoEx(nodepos, &is_valid_position);
@@ -4342,7 +4439,8 @@ inline void Game::limitFps(FpsControl *fps_timings, f32 *dtime)
 void Game::showOverlayMessage(const wchar_t *msg, float dtime,
                int percent, bool draw_clouds)
 {
-       draw_load_screen(msg, device, guienv, dtime, percent, draw_clouds);
+       draw_load_screen(msg, device, guienv, texture_src, dtime, percent,
+               draw_clouds);
        delete[] msg;
 }