/*\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
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
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
\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
* 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
//#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
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
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
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
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
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
}\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
return 0;\r
}\r
\r
+\r
/*\r
More parameters\r
*/\r
\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
*/\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
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
}\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
font,\r
map_dir,\r
playername,\r
+ password,\r
address,\r
port,\r
error_message\r