]> git.lizzy.rs Git - minetest.git/blobdiff - src/main.cpp
fixed a small memory leak in game.cpp
[minetest.git] / src / main.cpp
index 2122985633bb05f010b5ad97cec3d912f10accdf..816d921188b061cdb541c60c72a9dd8132498c37 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
 Minetest-c55\r
-Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>\r
+Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>\r
 \r
 This program is free software; you can redistribute it and/or modify\r
 it under the terms of the GNU General Public License as published by\r
@@ -81,18 +81,18 @@ SUGG: Calculate lighting per vertex to get a lighting effect like in
 SUGG: Background music based on cellular automata?\r
       http://www.earslap.com/projectslab/otomata\r
 \r
+SUGG: Simple light color information to air\r
 \r
 Gaming ideas:\r
 -------------\r
 \r
 - Aim for something like controlling a single dwarf in Dwarf Fortress\r
-\r
 - The player could go faster by a crafting a boat, or riding an animal\r
-\r
 - Random NPC traders. what else?\r
 \r
 Game content:\r
 -------------\r
+\r
 - When furnace is destroyed, move items to player's inventory\r
 - Add lots of stuff\r
 - Glass blocks\r
@@ -137,12 +137,8 @@ Build system / running:
 Networking and serialization:\r
 -----------------------------\r
 \r
-TODO: Get rid of GotSplitPacketException\r
-\r
-GUI:\r
-----\r
-\r
-TODO: Configuration menu, at least for keys\r
+User Interface:\r
+---------------\r
 \r
 Graphics:\r
 ---------\r
@@ -168,11 +164,6 @@ TODO: A setting for enabling bilinear filtering for textures
 \r
 TODO: Better control of draw_control.wanted_max_blocks\r
 \r
-TODO: Get player texture (and some others) from the specified texture\r
-      directory\r
-\r
-SUGG: Simple light color information to air\r
-\r
 TODO: Block mesh generator to tile properly on smooth lighting\r
 \r
 Configuration:\r
@@ -213,6 +204,9 @@ FIXME: Server sometimes goes into some infinite PeerNotFoundException loop
 * Make a small history check to transformLiquids to detect and log\r
   continuous oscillations, in such detail that they can be fixed.\r
 \r
+FIXME: The new optimized map sending doesn't sometimes send enough blocks\r
+       from big caves and such\r
+\r
 Objects:\r
 --------\r
 \r
@@ -325,6 +319,9 @@ Making it more portable:
 //#include "tile.h"\r
 #include "materials.h"\r
 #include "game.h"\r
+#include "keycode.h"\r
+#include "sha1.h"\r
+#include "base64.h"\r
 \r
 // This makes textures\r
 ITextureSource *g_texturesource = NULL;\r
@@ -720,7 +717,8 @@ class RandomInputHandler : public InputHandler
                        if(counter1 < 0.0)\r
                        {\r
                                counter1 = 0.1*Rand(1, 40);\r
-                               keydown[irr::KEY_SPACE] = !keydown[irr::KEY_SPACE];\r
+                               keydown[getKeySetting("keymap_jump")] =\r
+                                               !keydown[getKeySetting("keymap_jump")];\r
                        }\r
                }\r
                {\r
@@ -729,7 +727,8 @@ class RandomInputHandler : public InputHandler
                        if(counter1 < 0.0)\r
                        {\r
                                counter1 = 0.1*Rand(1, 40);\r
-                               keydown[irr::KEY_KEY_E] = !keydown[irr::KEY_KEY_E];\r
+                               keydown[getKeySetting("keymap_special1")] =\r
+                                               !keydown[getKeySetting("keymap_special1")];\r
                        }\r
                }\r
                {\r
@@ -738,7 +737,8 @@ class RandomInputHandler : public InputHandler
                        if(counter1 < 0.0)\r
                        {\r
                                counter1 = 0.1*Rand(1, 40);\r
-                               keydown[irr::KEY_KEY_W] = !keydown[irr::KEY_KEY_W];\r
+                               keydown[getKeySetting("keymap_forward")] =\r
+                                               !keydown[getKeySetting("keymap_forward")];\r
                        }\r
                }\r
                {\r
@@ -747,7 +747,8 @@ class RandomInputHandler : public InputHandler
                        if(counter1 < 0.0)\r
                        {\r
                                counter1 = 0.1*Rand(1, 40);\r
-                               keydown[irr::KEY_KEY_A] = !keydown[irr::KEY_KEY_A];\r
+                               keydown[getKeySetting("keymap_left")] =\r
+                                               !keydown[getKeySetting("keymap_left")];\r
                        }\r
                }\r
                {\r
@@ -907,7 +908,7 @@ void drawMenuBackground(video::IVideoDriver* driver)
        core::dimension2d<u32> screensize = driver->getScreenSize();\r
                \r
        video::ITexture *bgtexture =\r
-                       driver->getTexture(porting::getDataPath("mud.png").c_str());\r
+                       driver->getTexture(getTexturePath("mud.png").c_str());\r
        if(bgtexture)\r
        {\r
                s32 texturesize = 128;\r
@@ -927,7 +928,7 @@ void drawMenuBackground(video::IVideoDriver* driver)
        }\r
        \r
        video::ITexture *logotexture =\r
-                       driver->getTexture(porting::getDataPath("menulogo.png").c_str());\r
+                       driver->getTexture(getTexturePath("menulogo.png").c_str());\r
        if(logotexture)\r
        {\r
                v2s32 logosize(logotexture->getOriginalSize().Width,\r
@@ -1166,6 +1167,7 @@ int main(int argc, char *argv[])
                return 0;\r
        }\r
 \r
+\r
        /*\r
                More parameters\r
        */\r
@@ -1281,7 +1283,7 @@ int main(int argc, char *argv[])
 \r
        guienv = device->getGUIEnvironment();\r
        gui::IGUISkin* skin = guienv->getSkin();\r
-       gui::IGUIFont* font = guienv->getFont(porting::getDataPath("fontlucida.png").c_str());\r
+       gui::IGUIFont* font = guienv->getFont(getTexturePath("fontlucida.png").c_str());\r
        if(font)\r
                skin->setFont(font);\r
        else\r
@@ -1320,11 +1322,15 @@ int main(int argc, char *argv[])
        */\r
        std::wstring error_message = L"";\r
 \r
+       // The password entered during the menu screen,\r
+       std::string password;\r
+\r
        /*\r
                Menu-game loop\r
        */\r
        while(device->run() && kill == false)\r
        {\r
+\r
                // This is used for catching disconnects\r
                try\r
                {\r
@@ -1404,6 +1410,10 @@ int main(int argc, char *argv[])
                                        guienv->drawAll();\r
                                        \r
                                        driver->endScene();\r
+                                       \r
+                                       // On some computers framerate doesn't seem to be\r
+                                       // automatically limited\r
+                                       sleep_ms(25);\r
                                }\r
                                \r
                                // Break out of menu-game loop to shut down cleanly\r
@@ -1424,6 +1434,26 @@ int main(int argc, char *argv[])
                                }\r
 \r
                                playername = wide_to_narrow(menudata.name);\r
+\r
+                               // Get an sha-1 hash of the player's name combined with\r
+                               // the password entered. That's what the server uses as\r
+                               // their password. (Exception : if the password field is\r
+                               // blank, we send a blank password - this is for backwards\r
+                               // compatibility with password-less players).\r
+                               if(menudata.password.length() > 0)\r
+                               {\r
+                                               std::string slt=playername + wide_to_narrow(menudata.password);\r
+                                               SHA1 *sha1 = new SHA1();\r
+                                               sha1->addBytes(slt.c_str(), slt.length());\r
+                                               unsigned char *digest = sha1->getDigest();\r
+                                               password = base64_encode(digest, 20);\r
+                                               free(digest);\r
+                               }\r
+                               else\r
+                               {\r
+                                               password = "";\r
+                               }\r
+\r
                                address = wide_to_narrow(menudata.address);\r
                                int newport = stoi(wide_to_narrow(menudata.port));\r
                                if(newport != 0)\r
@@ -1470,6 +1500,7 @@ int main(int argc, char *argv[])
                                font,\r
                                map_dir,\r
                                playername,\r
+                               password,\r
                                address,\r
                                port,\r
                                error_message\r