LocalPlayer::accelerateHorizontal: cleanups
[oweals/minetest.git] / src / game.cpp
index f0c11cb98260ca9b497f043aa71d92719b4512b9..4588e21e0cf992b4d62197636ff9dd5e56507471 100644 (file)
@@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "game.h"
 
 #include <iomanip>
+#include <cmath>
 #include "client/renderingengine.h"
 #include "camera.h"
 #include "client.h"
@@ -995,7 +996,7 @@ static void updateChat(Client &client, f32 dtime, bool show_debug,
        s32 chat_y = 5;
 
        if (show_debug)
-               chat_y += 2 * line_height;
+               chat_y += 3 * line_height;
 
        // first pass to calculate height of text to be set
        const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
@@ -1106,6 +1107,11 @@ void KeyCache::populate()
 
        key[KeyType::DEBUG_STACKS]   = getKeySetting("keymap_print_debug_stacks");
 
+       for (int i = 0; i < 23; i++) {
+               std::string slot_key_name = "keymap_slot" + std::to_string(i + 1);
+               key[KeyType::SLOT_1 + i] = getKeySetting(slot_key_name.c_str());
+       }
+
        if (handler) {
                // First clear all keys, then re-add the ones we listen for
                handler->dontListenForKeys();
@@ -1114,9 +1120,6 @@ void KeyCache::populate()
                }
                handler->listenForKey(EscapeKey);
                handler->listenForKey(CancelKey);
-               for (size_t i = 0; i < 10; i++) {
-                       handler->listenForKey(NumberKey[i]);
-               }
        }
 }
 
@@ -2638,16 +2641,10 @@ void Game::processItemSelection(u16 *new_playeritem)
                *new_playeritem = *new_playeritem > 0 ? *new_playeritem - 1 : max_item;
        // else dir == 0
 
-       /* Item selection using keyboard
+       /* Item selection using hotbar slot keys
         */
-       for (u16 i = 0; i < 10; i++) {
-               static const KeyPress *item_keys[10] = {
-                       NumberKey + 1, NumberKey + 2, NumberKey + 3, NumberKey + 4,
-                       NumberKey + 5, NumberKey + 6, NumberKey + 7, NumberKey + 8,
-                       NumberKey + 9, NumberKey + 0,
-               };
-
-               if (input->wasKeyDown(*item_keys[i])) {
+       for (u16 i = 0; i < 23; i++) {
+               if (wasKeyDown((GameKeyType) (KeyType::SLOT_1 + i))) {
                        if (i < PLAYER_INVENTORY_SIZE && i < player->hud_hotbar_itemcount) {
                                *new_playeritem = i;
                                infostream << "Selected item: " << new_playeritem << std::endl;
@@ -2983,8 +2980,8 @@ void Game::decreaseViewRange()
 void Game::toggleFullViewRange()
 {
        static const wchar_t *msg[] = {
-               L"Disabled full viewing range",
-               L"Enabled full viewing range"
+               L"Normal view range",
+               L"Infinite view range"
        };
 
        draw_control->range_all = !draw_control->range_all;
@@ -3802,6 +3799,11 @@ void Game::handlePointingAtNode(const PointedThing &pointed,
 
                if (meta && meta->getString("formspec") != "" && !random_input
                                && !isKeyDown(KeyType::SNEAK)) {
+                       // Report right click to server
+                       if (nodedef_manager->get(map.getNodeNoEx(nodepos)).rightclickable) {
+                               client->interact(3, pointed);
+                       }
+
                        infostream << "Launching custom inventory view" << std::endl;
 
                        InventoryLocation inventoryloc;
@@ -4124,7 +4126,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
                                                .getInterpolated(video::SColor(255, 0, 0, 0), 0.9);
                                sky->overrideColors(clouds_dark, clouds->getColor());
                                sky->setBodiesVisible(false);
-                               runData.fog_range = 20.0f * BS;
+                               runData.fog_range = std::fmin(runData.fog_range * 0.5f, 32.0f * BS);
                                // do not draw clouds after all
                                clouds->setVisible(false);
                        }