some work-in-progress
authorPerttu Ahola <celeron55@gmail.com>
Wed, 22 Dec 2010 01:33:58 +0000 (03:33 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Wed, 22 Dec 2010 01:33:58 +0000 (03:33 +0200)
20 files changed:
Makefile
data/pauseMenu.gui
minetest.vcproj
src/client.cpp
src/constants.h
src/debug.cpp
src/environment.cpp
src/guiPauseMenu.cpp
src/guiPauseMenu.h
src/inventory.h
src/main.cpp
src/map.cpp
src/mapblockobject.cpp
src/mapblockobject.h
src/player.cpp
src/player.h
src/server.h
src/servermain.cpp
src/test.cpp
src/voxel.cpp

index 7aacb4c4adc542eeb569f0f5a653a9ab63dd94fa..aaeb9d7e3ed68e5534869f6f92f250301eca69ec 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 # It's usually sufficient to change just the target name and source file list\r
 # and be sure that CXX is set to a valid compiler\r
 TARGET = test\r
-SOURCE_FILES = irrlichtwrapper.cpp guiPauseMenu.cpp defaultsettings.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp\r
+SOURCE_FILES = guiInventoryMenu.cpp irrlichtwrapper.cpp guiPauseMenu.cpp defaultsettings.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp\r
 SOURCES = $(addprefix src/, $(SOURCE_FILES))\r
 BUILD_DIR = build\r
 OBJECTS = $(addprefix $(BUILD_DIR)/, $(SOURCE_FILES:.cpp=.o))\r
@@ -69,7 +69,7 @@ $(SERVER_BUILD_DIR):
 $(DESTPATH): $(OBJECTS)\r
        $(CXX) -o $@ $(OBJECTS) $(LDFLAGS)\r
 \r
-$(FAST_DESTPATH): $(SOURCES)\r
+$(FAST_DESTPATH): $(OBJECTS)\r
        $(CXX) -o $@ $(OBJECTS) $(LDFLAGS) -DUNITTEST_DISABLE\r
 \r
 $(SERVER_DESTPATH): $(SERVER_OBJECTS)\r
index 543b3fb8a3b7db03f6bf08d9d945570608c23db2..0cf6c7adc430e125dd91812fbd608b0d23f8b0ee 100644 (file)
Binary files a/data/pauseMenu.gui and b/data/pauseMenu.gui differ
index 632feffffc54ac1a43b85118254e4189bb039f68..4c99e6bb49939b11f49cb1be77c4d65c58bf7bcf 100644 (file)
                                RelativePath=".\src\debug.cpp"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\src\defaultsettings.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\src\environment.cpp"\r
                                >\r
                                RelativePath=".\src\inventory.cpp"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\src\irrlichtwrapper.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\src\light.cpp"\r
                                >\r
index d99b8d8df101bf2aa3aca89523da3d2870a87d77..a5d035d3f53ed3a044bcc074dff7810f379a740d 100644 (file)
@@ -24,14 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "jmutexautolock.h"
 #include "main.h"
 #include <sstream>
-
-#ifdef _WIN32
-       #include <windows.h>
-       #define sleep_ms(x) Sleep(x)
-#else
-       #include <unistd.h>
-       #define sleep_ms(x) usleep(x*1000)
-#endif
+#include "porting.h"
 
 void * ClientUpdateThread::Thread()
 {
index 7668c74515cd4cced4d69a370bf7a8d0585bbdab..8b7e77c4240c16c8f7a351220138d4fa4c82539e 100644 (file)
@@ -57,7 +57,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 // Viewing range stuff
 
 //#define FREETIME_RATIO 0.15
-#define FREETIME_RATIO 0.0
+//#define FREETIME_RATIO 0.0
+#define FREETIME_RATIO 0.05
 
 // Sectors are split to SECTOR_HEIGHTMAP_SPLIT^2 heightmaps
 #define SECTOR_HEIGHTMAP_SPLIT 2
index 346405939fd229b65fccbe0b9ee8f9965fdcb7f2..df8cbeb2268c7c593e0144d582e55ed88fdb93be 100644 (file)
@@ -21,15 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "debug.h"
 #include <stdio.h>
 #include <stdlib.h>
-
-#ifdef _WIN32
-       #define WIN32_LEAN_AND_MEAN
-       #include <windows.h>
-       #define sleep_ms(x) Sleep(x)
-#else
-       #include <unistd.h>
-       #define sleep_ms(x) usleep(x*1000)
-#endif
+#include "porting.h"
 
 /*
        Debug output
index 386eb124dfb168cd856c03308bb505ca3e909df9..7c236c3556a54324eca746e5980a43c8078df006 100644 (file)
@@ -103,6 +103,8 @@ void Environment::step(float dtime)
                                i != m_players.end(); i++)
                {
                        Player *player = *i;
+
+                       v3f playerpos = player->getPosition();
                        
                        // Apply physics to local player
                        if(player->isLocal())
@@ -135,12 +137,22 @@ void Environment::step(float dtime)
                        */
                        player->move(dtime_part, *m_map);
                        
+                       /*
+                               Update lighting on remote players on client
+                       */
+                       u8 light = LIGHT_MAX;
+                       try{
+                               // Get node at feet
+                               v3s16 p = floatToInt(playerpos + v3f(0,BS/4,0));
+                               MapNode n = m_map->getNode(p);
+                               light = n.getLightBlend(m_daynight_ratio);
+                       }
+                       catch(InvalidPositionException &e) {}
+                       player->updateLight(light);
+
                        /*
                                Add footsteps to grass
                        */
-                       //TimeTaker footsteptimer("footstep", g_device);
-                       // 0ms
-                       v3f playerpos = player->getPosition();
                        // Get node that is at BS/4 under player
                        v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0));
                        try{
@@ -163,7 +175,6 @@ void Environment::step(float dtime)
                        catch(InvalidPositionException &e)
                        {
                        }
-                       //footsteptimer.stop();
                }
        }
        while(dtime > 0.001);
index 676c145f25a10163e39e8925d0a631dd7753c366..73e406e18096f879949f2119e1e8bec00190f2fc 100644 (file)
@@ -21,8 +21,145 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 \r
 \r
 #include "guiPauseMenu.h"\r
+#include "debug.h"\r
 \r
-void guiPauseMenu::scaleGui() // this function scales gui from the size stored in file to screen size\r
+GUIPauseMenu::GUIPauseMenu(gui::IGUIEnvironment* env,\r
+               gui::IGUIElement* parent, s32 id,\r
+               IrrlichtDevice *dev):\r
+       IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,\r
+                       core::rect<s32>(0,0,100,100))\r
+{\r
+       m_dev = dev;\r
+       m_screensize_old = v2u32(0,0);\r
+       \r
+       resizeGui();\r
+\r
+       setVisible(false);\r
+}\r
+\r
+GUIPauseMenu::~GUIPauseMenu()\r
+{\r
+}\r
+\r
+void GUIPauseMenu::resizeGui()\r
+{\r
+       video::IVideoDriver* driver = Environment->getVideoDriver();\r
+       v2u32 screensize = driver->getScreenSize();\r
+       if(screensize == m_screensize_old)\r
+               return;\r
+       m_screensize_old = screensize;\r
+\r
+       {\r
+               gui::IGUIElement *e = getElementFromId(256);\r
+               if(e != NULL)\r
+                       e->remove();\r
+       }\r
+       {\r
+               gui::IGUIElement *e = getElementFromId(257);\r
+               if(e != NULL)\r
+                       e->remove();\r
+       }\r
+\r
+       core::rect<s32> rect(\r
+                       screensize.X/2 - 560/2,\r
+                       screensize.Y/2 - 300/2,\r
+                       screensize.X/2 + 560/2,\r
+                       screensize.Y/2 + 300/2\r
+       );\r
+       \r
+       DesiredRect = rect;\r
+       recalculateAbsolutePosition(false);\r
+\r
+       v2s32 size = rect.getSize();\r
+\r
+       {\r
+               core::rect<s32> rect(0, 0, 140, 30);\r
+               rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2-25);\r
+               Environment->addButton(rect, this, 256, L"Continue");\r
+       }\r
+       {\r
+               core::rect<s32> rect(0, 0, 140, 30);\r
+               rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25);\r
+               Environment->addButton(rect, this, 257, L"Exit");\r
+       }\r
+}\r
+\r
+void GUIPauseMenu::draw()\r
+{\r
+       if(!IsVisible)\r
+               return;\r
+               \r
+       gui::IGUISkin* skin = Environment->getSkin();\r
+       if (!skin)\r
+               return;\r
+       video::IVideoDriver* driver = Environment->getVideoDriver();\r
+       \r
+       video::SColor bgcolor(140,0,0,0);\r
+       driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);\r
+\r
+       gui::IGUIElement::draw();\r
+}\r
+\r
+bool GUIPauseMenu::OnEvent(const SEvent& event)\r
+{\r
+       if(event.EventType==EET_KEY_INPUT_EVENT)\r
+       {\r
+               if(event.KeyInput.Key==KEY_ESCAPE && event.KeyInput.PressedDown)\r
+               {\r
+                       setVisible(false);\r
+                       return true;\r
+               }\r
+       }\r
+       if(event.EventType==EET_GUI_EVENT)\r
+       {\r
+               if(event.GUIEvent.EventType==gui::EGET_ELEMENT_FOCUS_LOST\r
+                               && isVisible())\r
+               {\r
+                       if(!canTakeFocus(event.GUIEvent.Element))\r
+                       {\r
+                               dstream<<"GUIPauseMenu: Not allowing focus change."\r
+                                               <<std::endl;\r
+                               // Returning true disables focus change\r
+                               return true;\r
+                       }\r
+               }\r
+               if(event.GUIEvent.EventType==gui::EGET_BUTTON_CLICKED)\r
+               {\r
+                       switch(event.GUIEvent.Caller->getID())\r
+                       {\r
+                       case 256: // continue\r
+                               setVisible(false);\r
+                               break;\r
+                       case 257: // exit\r
+                               m_dev->closeDevice();\r
+                               break;\r
+                       }\r
+               }\r
+       }\r
+\r
+       return Parent ? Parent->OnEvent(event) : false;\r
+}\r
+\r
+#if 0\r
+GUIPauseMenu::GUIPauseMenu(IrrlichtDevice *device, IEventReceiver *recv):\r
+       dev(device),\r
+       oldRecv(recv)\r
+{\r
+       if(!dev)\r
+               return;\r
+       guienv=dev->getGUIEnvironment();\r
+\r
+       if (!loadMenu())\r
+               return;\r
+\r
+       device->setEventReceiver(this); // now WE are the input receiver! ahhaha! \r
+}\r
+\r
+GUIPauseMenu::~GUIPauseMenu(void)\r
+{\r
+}\r
+\r
+void GUIPauseMenu::scaleGui() // this function scales gui from the size stored in file to screen size\r
 {\r
        core::dimension2du screen=dev->getVideoDriver()->getScreenSize();\r
        core::vector2di real=root->getAbsolutePosition().LowerRightCorner; // determine gui size stored in file (which is size of my menu root node)\r
@@ -30,7 +167,7 @@ void guiPauseMenu::scaleGui() // this function scales gui from the size stored i
        float factorY=(float)screen.Height/(float)real.Y;\r
        scaleGui(guienv->getRootGUIElement(),factorX,factorY);\r
 }\r
-void guiPauseMenu::scaleGui(gui::IGUIElement *node,float factorX,float factorY) // recursive set scale\r
+void GUIPauseMenu::scaleGui(gui::IGUIElement *node,float factorX,float factorY) // recursive set scale\r
 {\r
        if((node->getParent() && node->getParent()->getID()==255) || node->getID()==255) // modify only menu's elements\r
        {\r
@@ -47,7 +184,7 @@ void guiPauseMenu::scaleGui(gui::IGUIElement *node,float factorX,float factorY)
                scaleGui((*it),factorX,factorY);\r
 }\r
 \r
-bool guiPauseMenu::loadMenu()\r
+bool GUIPauseMenu::loadMenu()\r
 {\r
        guienv->loadGUI("../data/pauseMenu.gui");\r
 \r
@@ -65,19 +202,7 @@ bool guiPauseMenu::loadMenu()
        return true;\r
 }\r
 \r
-guiPauseMenu::guiPauseMenu(IrrlichtDevice *device, IEventReceiver *recv) : dev(device), oldRecv(recv)\r
-{\r
-       if(!dev)\r
-               return;\r
-       guienv=dev->getGUIEnvironment();\r
-\r
-       if (!loadMenu())\r
-               return;\r
-\r
-       device->setEventReceiver(this); // now WE are the input receiver! ahhaha! \r
-}\r
-\r
-bool guiPauseMenu::OnEvent(const SEvent& event)\r
+bool GUIPauseMenu::OnEvent(const SEvent& event)\r
 {\r
        if(!dev->isWindowFocused())\r
                setVisible(true);\r
@@ -114,7 +239,5 @@ bool guiPauseMenu::OnEvent(const SEvent& event)
 \r
        return false;\r
 }\r
+#endif\r
 \r
-guiPauseMenu::~guiPauseMenu(void)\r
-{\r
-}\r
index 28ac02bc94a19be20d58713a8fd5e6f3d0aba3af..f26a261494ea8e1386b7be699f18809ad4622b64 100644 (file)
@@ -23,31 +23,64 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #ifndef GUIPAUSEMENU_HEADER\r
 #define GUIPAUSEMENU_HEADER\r
 \r
-#include <irrlicht.h>\r
-using namespace irr;\r
+#include "common_irrlicht.h"\r
 \r
-class guiPauseMenu : public IEventReceiver\r
+class GUIPauseMenu : public gui::IGUIElement\r
 {\r
-private:\r
-       IrrlichtDevice *dev;\r
-       gui::IGUIEnvironment *guienv;\r
-       IEventReceiver *oldRecv;\r
+public:\r
+       GUIPauseMenu(gui::IGUIEnvironment* env,\r
+                       gui::IGUIElement* parent, s32 id,\r
+                       IrrlichtDevice *dev);\r
+       ~GUIPauseMenu();\r
+       \r
+       /*\r
+               Remove and re-add (or reposition) stuff\r
+       */\r
+       void resizeGui();\r
 \r
-       gui::IGUIStaticText *root;\r
+       void draw();\r
 \r
-       bool loadMenu();\r
-       void scaleGui();\r
-       void scaleGui(gui::IGUIElement *node,float factorX,float factorY);\r
+       void launch()\r
+       {\r
+               setVisible(true);\r
+               Environment->setFocus(this);\r
+       }\r
+\r
+       bool canTakeFocus(gui::IGUIElement *e)\r
+       {\r
+               return (e && (e == this || isMyChild(e)));\r
+       }\r
+\r
+       bool OnEvent(const SEvent& event);\r
+       \r
+private:\r
+       IrrlichtDevice *m_dev;\r
+       v2u32 m_screensize_old;\r
+};\r
+\r
+/*class GUIPauseMenu : public IEventReceiver\r
+{\r
 public:\r
-       guiPauseMenu(IrrlichtDevice *device,IEventReceiver *recv);\r
+       void scaleGui();\r
+\r
+       GUIPauseMenu(IrrlichtDevice *device,IEventReceiver *recv);\r
+       ~GUIPauseMenu(void);\r
 \r
        void setVisible(bool visible){root->setVisible(visible);};\r
        bool isVisible(){return root->isVisible();};\r
 \r
        bool OnEvent(const SEvent& event);\r
 \r
-       ~guiPauseMenu(void);\r
-};\r
+private:\r
+       bool loadMenu();\r
+       void scaleGui(gui::IGUIElement *node,float factorX,float factorY);\r
+\r
+       IrrlichtDevice *dev;\r
+       gui::IGUIEnvironment *guienv;\r
+       IEventReceiver *oldRecv;\r
+\r
+       gui::IGUIStaticText *root;\r
+};*/\r
 \r
 #endif\r
 \r
index 354111045852e0e893171c44bdcd67dbfd002362..c18aa5dce20997fe89fff24936d28cf7d43af570 100644 (file)
@@ -196,7 +196,6 @@ private:
        std::string m_inventorystring;
 };
 
-//SUGGESTION: Split into ClientInventory and ServerInventory
 class Inventory
 {
 public:
index 8325680f253080f72757d930a9537f75285aa323..4b696236d7814cbb974f21e94d8331987122e5b5 100644 (file)
@@ -161,17 +161,17 @@ TODO: Remove LazyMeshUpdater. It is not used as supposed.
 TODO: TOSERVER_LEAVE\r
 \r
 TODO: Better handling of objects and mobs\r
-      - Update brightness according to day-night blended light of node\r
-           in position\r
       - Scripting?\r
+      - There has to be some way to do it with less spaghetti code\r
+         - Make separate classes for client and server\r
+           - Client should not discriminate between blocks, server should\r
+           - Make other players utilize the same framework\r
+\r
+SUGG: Split Inventory into ClientInventory and ServerInventory\r
 \r
 Doing now:\r
 ======================================================================\r
 \r
-TODO: Get rid of g_irrlicht for server build\r
-\r
-TODO: Implement getGlobalTime for server build\r
-      - It is needed for controlling the time used for flowing water\r
 \r
 ======================================================================\r
 \r
@@ -208,15 +208,6 @@ TODO: Implement getGlobalTime for server build
 //#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")\r
 #endif\r
 \r
-#ifdef _WIN32\r
-       #define WIN32_LEAN_AND_MEAN\r
-       #include <windows.h>\r
-       #define sleep_ms(x) Sleep(x)\r
-#else\r
-       #include <unistd.h>\r
-       #define sleep_ms(x) usleep(x*1000)\r
-#endif\r
-\r
 #include <iostream>\r
 #include <fstream>\r
 #include <jmutexautolock.h>\r
@@ -237,6 +228,8 @@ TODO: Implement getGlobalTime for server build
 #include "guiPauseMenu.h"\r
 #include "irrlichtwrapper.h"\r
 #include "gettime.h"\r
+#include "porting.h"\r
+#include "guiInventoryMenu.h"\r
 \r
 IrrlichtWrapper *g_irrlicht;\r
 \r
@@ -276,7 +269,9 @@ extern void set_default_settings();
 //u16 g_selected_material = 0;\r
 u16 g_selected_item = 0;\r
 \r
-bool g_esc_pressed = false;\r
+gui::IGUIEnvironment* guienv = NULL;\r
+GUIPauseMenu *pauseMenu = NULL;\r
+GUIInventoryMenu *inventoryMenu = NULL;\r
 \r
 std::wstring g_text_buffer;\r
 bool g_text_buffer_accepted = false;\r
@@ -354,13 +349,35 @@ public:
                                        }\r
                                }\r
                                \r
-                               if(event.KeyInput.Key == irr::KEY_ESCAPE)\r
+                               if(pauseMenu != NULL)\r
                                {\r
-                                       //TODO: Not used anymore?\r
-                                       if(g_game_focused == true)\r
+                                       if(event.KeyInput.Key == irr::KEY_ESCAPE)\r
                                        {\r
-                                               dstream<<DTIME<<"ESC pressed"<<std::endl;\r
-                                               g_esc_pressed = true;\r
+                                               if(g_game_focused == true\r
+                                                               && !pauseMenu->isVisible()\r
+                                                               && !inventoryMenu->isVisible())\r
+                                               {\r
+                                                       dstream<<DTIME<<"MyEventReceiver: "\r
+                                                                       <<"Launching pause menu"<<std::endl;\r
+                                                       pauseMenu->launch();\r
+                                                       return true;\r
+                                               }\r
+                                       }\r
+                               }\r
+\r
+                               if(inventoryMenu != NULL)\r
+                               {\r
+                                       if(event.KeyInput.Key == irr::KEY_KEY_I)\r
+                                       {\r
+                                               if(g_game_focused == true\r
+                                                               && !inventoryMenu->isVisible()\r
+                                                               && !pauseMenu->isVisible())\r
+                                               {\r
+                                                       dstream<<DTIME<<"MyEventReceiver: "\r
+                                                                       <<"Launching inventory"<<std::endl;\r
+                                                       inventoryMenu->launch();\r
+                                                       return true;\r
+                                               }\r
                                        }\r
                                }\r
 \r
@@ -411,6 +428,7 @@ public:
 \r
                if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)\r
                {\r
+                       //dstream<<"MyEventReceiver: mouse input"<<std::endl;\r
                        left_active = event.MouseInput.isLeftPressed();\r
                        middle_active = event.MouseInput.isMiddlePressed();\r
                        right_active = event.MouseInput.isRightPressed();\r
@@ -1137,8 +1155,6 @@ int main(int argc, char *argv[])
        <<"|  Y Y  \\  |   |  \\  ___/|  | \\  ___/ \\___ \\  |  |  "<<std::endl\r
        <<"|__|_|  /__|___|  /\\___  >__|  \\___  >____  > |__|  "<<std::endl\r
        <<"      \\/        \\/     \\/          \\/     \\/        "<<std::endl\r
-       <<std::endl\r
-       <<"Now with more waterish water!"\r
        <<std::endl;\r
 \r
        std::cout<<std::endl;\r
@@ -1298,10 +1314,7 @@ int main(int argc, char *argv[])
 \r
        scene::ISceneManager* smgr = device->getSceneManager();\r
        \r
-       // Pause menu\r
-       guiPauseMenu pauseMenu(device, &receiver);\r
-\r
-       gui::IGUIEnvironment* guienv = device->getGUIEnvironment();\r
+       guienv = device->getGUIEnvironment();\r
        gui::IGUISkin* skin = guienv->getSkin();\r
        gui::IGUIFont* font = guienv->getFont("../data/fontlucida.png");\r
        if(font)\r
@@ -1457,12 +1470,33 @@ int main(int argc, char *argv[])
        \r
        gui_loadingtext->remove();\r
 \r
-       pauseMenu.setVisible(true);\r
-\r
        /*\r
                Add some gui stuff\r
        */\r
        \r
+       // This is a copy of the inventory that the client's environment has\r
+       Inventory local_inventory(PLAYER_INVENTORY_SIZE);\r
+       \r
+       GUIQuickInventory *quick_inventory = new GUIQuickInventory\r
+                       (guienv, NULL, v2s32(10, 70), 5, &local_inventory);\r
+       \r
+       /*\r
+               We need some kind of a root node to be able to add\r
+               custom elements directly on the screen.\r
+               Otherwise they won't be automatically drawn.\r
+       */\r
+       gui::IGUIStaticText *root = guienv->addStaticText(L"",\r
+                       core::rect<s32>(0, 0, 10000, 10000));\r
+       \r
+       // Pause menu\r
+       pauseMenu = new GUIPauseMenu(guienv, root, -1, device);\r
+       \r
+       // Inventory menu\r
+       inventoryMenu = new GUIInventoryMenu(guienv, root, -1, &local_inventory);\r
+\r
+       pauseMenu->launch();\r
+       //inventoryMenu->launch();\r
+\r
        // First line of debug text\r
        gui::IGUIStaticText *guitext = guienv->addStaticText(\r
                        L"Minetest-c55",\r
@@ -1481,12 +1515,6 @@ int main(int argc, char *argv[])
                        core::rect<s32>(100, 70, 100+400, 70+(textsize.Y+5)),\r
                        false, false);\r
        \r
-       // This is a copy of the inventory that the client's environment has\r
-       Inventory local_inventory(PLAYER_INVENTORY_SIZE);\r
-       \r
-       GUIQuickInventory *quick_inventory = new GUIQuickInventory\r
-                       (guienv, NULL, v2s32(10, 70), 5, &local_inventory);\r
-       \r
        /*\r
                Some statistics are collected in these\r
        */\r
@@ -1529,11 +1557,6 @@ int main(int argc, char *argv[])
        //gui::IGUIWindow* input_window = NULL;\r
        gui::IGUIStaticText* input_guitext = NULL;\r
 \r
-       /*\r
-               Digging animation\r
-       */\r
-       //f32 \r
-\r
        /*\r
                Main loop\r
        */\r
@@ -1557,6 +1580,9 @@ int main(int argc, char *argv[])
                */\r
                v2u32 screensize = driver->getScreenSize();\r
                core::vector2d<s32> displaycenter(screensize.X/2,screensize.Y/2);\r
+               \r
+               pauseMenu->resizeGui();\r
+               inventoryMenu->resizeGui();\r
 \r
                // Hilight boxes collected during the loop and displayed\r
                core::list< core::aabbox3d<f32> > hilightboxes;\r
@@ -1714,6 +1740,11 @@ int main(int argc, char *argv[])
                {\r
                        break;\r
                }*/\r
+               /*if(g_i_pressed)\r
+               {\r
+                       inventoryMenu->setVisible(true);\r
+                       g_i_pressed = false;\r
+               }*/\r
 \r
                /*\r
                        Player speed control\r
@@ -1773,7 +1804,11 @@ int main(int argc, char *argv[])
                        Mouse and camera control\r
                */\r
                \r
-               if((device->isWindowActive() && g_game_focused && !pauseMenu.isVisible())\r
+               if((device->isWindowActive()\r
+                               && g_game_focused\r
+                               && !pauseMenu->isVisible()\r
+                               && !inventoryMenu->isVisible()\r
+                               )\r
                                || random_input)\r
                {\r
                        if(!random_input)\r
@@ -2250,6 +2285,7 @@ int main(int argc, char *argv[])
                        client.getLocalInventory(local_inventory);\r
                        quick_inventory->setSelection(g_selected_item);\r
                        quick_inventory->update();\r
+                       inventoryMenu->update();\r
                }\r
 \r
                if(input_guitext != NULL)\r
index 9a0952c753567cd1cdadd6800a1ab0af9aae68bf..839efbf5bd1cf9e048015332040d959b4efae3fb 100644 (file)
@@ -24,14 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "filesys.h"
 #include "utility.h"
 #include "voxel.h"
-
-#ifdef _WIN32
-       #include <windows.h>
-       #define sleep_ms(x) Sleep(x)
-#else
-       #include <unistd.h>
-       #define sleep_ms(x) usleep(x*1000)
-#endif
+#include "porting.h"
 
 MapBlockPointerCache::MapBlockPointerCache(Map *map)
 {
index 779fe3fa71d0257c208c20d00082f880039e4259..d5c9c997a40a832d21ed96ed8aabea64ef073c6a 100644 (file)
@@ -282,6 +282,7 @@ void RatObject::addToScene(scene::ISceneManager *smgr)
        buf->getMaterial().setTexture
                        (0, driver->getTexture("../data/rat.png"));
        buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+       buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
        buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
        // Add to mesh
        mesh->addMeshBuffer(buf);
@@ -292,6 +293,73 @@ void RatObject::addToScene(scene::ISceneManager *smgr)
 }
 #endif
 
+#ifndef SERVER
+/*
+       PlayerObject
+*/
+void PlayerObject::addToScene(scene::ISceneManager *smgr)
+{
+       if(m_node != NULL)
+               return;
+       
+       video::IVideoDriver* driver = smgr->getVideoDriver();
+
+       // Attach a simple mesh to the player for showing an image
+       scene::SMesh *mesh = new scene::SMesh();
+       { // Front
+       scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+       video::SColor c(255,255,255,255);
+       video::S3DVertex vertices[4] =
+       {
+               video::S3DVertex(-BS/2,0,0, 0,0,0, c, 0,1),
+               video::S3DVertex(BS/2,0,0, 0,0,0, c, 1,1),
+               video::S3DVertex(BS/2,BS*2,0, 0,0,0, c, 1,0),
+               video::S3DVertex(-BS/2,BS*2,0, 0,0,0, c, 0,0),
+       };
+       u16 indices[] = {0,1,2,2,3,0};
+       buf->append(vertices, 4, indices, 6);
+       // Set material
+       buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+       //buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
+       buf->getMaterial().setTexture(0, driver->getTexture("../data/player.png"));
+       buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+       buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
+       //buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
+       buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+       // Add to mesh
+       mesh->addMeshBuffer(buf);
+       buf->drop();
+       }
+       { // Back
+       scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+       video::SColor c(255,255,255,255);
+       video::S3DVertex vertices[4] =
+       {
+               video::S3DVertex(BS/2,0,0, 0,0,0, c, 1,1),
+               video::S3DVertex(-BS/2,0,0, 0,0,0, c, 0,1),
+               video::S3DVertex(-BS/2,BS*2,0, 0,0,0, c, 0,0),
+               video::S3DVertex(BS/2,BS*2,0, 0,0,0, c, 1,0),
+       };
+       u16 indices[] = {0,1,2,2,3,0};
+       buf->append(vertices, 4, indices, 6);
+       // Set material
+       buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+       //buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
+       buf->getMaterial().setTexture(0, driver->getTexture("../data/player_back.png"));
+       buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+       buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
+       buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+       // Add to mesh
+       mesh->addMeshBuffer(buf);
+       buf->drop();
+       }
+       
+       m_node = smgr->addMeshSceneNode(mesh, NULL);
+       mesh->drop();
+       updateNodePos();
+}
+#endif
+
 /*
        MapBlockObjectList
 */
index c479bc959bfa07d40b2c37de8f36c4fe96111678..30fa797f4928253cbd34bf40c22e1150c449c53c 100644 (file)
@@ -28,8 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "constants.h"
 #include "debug.h"
 
-#define MAPBLOCKOBJECT_TYPE_TEST 0
-#define MAPBLOCKOBJECT_TYPE_TEST2 1
+#define MAPBLOCKOBJECT_TYPE_PLAYER 0
 #define MAPBLOCKOBJECT_TYPE_SIGN 2
 #define MAPBLOCKOBJECT_TYPE_RAT 3
 // Used for handling selecting special stuff
@@ -432,6 +431,7 @@ public:
                buf->getMaterial().setTexture
                                (0, driver->getTexture("../data/sign.png"));
                buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+               buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
                buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
                // Add to mesh
                mesh->addMeshBuffer(buf);
@@ -455,6 +455,7 @@ public:
                buf->getMaterial().setTexture
                                (0, driver->getTexture("../data/sign_back.png"));
                buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+               buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
                buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
                // Add to mesh
                mesh->addMeshBuffer(buf);
@@ -710,10 +711,129 @@ protected:
 
        float m_counter1;
        float m_counter2;
-       v3f m_oldpos;
        float m_age;
 };
 
+/*
+       NOTE: Not used.
+*/
+class PlayerObject : public MovingObject
+{
+public:
+       PlayerObject(MapBlock *block, s16 id, v3f pos):
+               MovingObject(block, id, pos),
+               m_node(NULL)
+       {
+               m_collision_box = new core::aabbox3d<f32>
+                               (-BS*0.3,-BS*.25,-BS*0.3, BS*0.3,BS*0.25,BS*0.3);
+               /*m_selection_box = new core::aabbox3d<f32>
+                               (-BS*0.3,-BS*.25,-BS*0.3, BS*0.3,BS*0.25,BS*0.3);*/
+       }
+       virtual ~PlayerObject()
+       {
+               if(m_collision_box)
+                       delete m_collision_box;
+               if(m_selection_box)
+                       delete m_selection_box;
+       }
+       
+       /*
+               Implementation interface
+       */
+       virtual u16 getTypeId() const
+       {
+               return MAPBLOCKOBJECT_TYPE_PLAYER;
+       }
+       virtual void serialize(std::ostream &os, u8 version)
+       {
+               // Object data is generated from actual player
+       }
+       virtual void update(std::istream &is, u8 version)
+       {
+               MovingObject::update(is, version);
+               u8 buf[2];
+               
+               // Read yaw * 10
+               is.read((char*)buf, 2);
+               s16 yaw_i = readS16(buf);
+               m_yaw = (f32)yaw_i / 10;
+
+               updateNodePos();
+       }
+
+       virtual bool serverStep(float dtime, u32 daynight_ratio)
+       {
+               // Player is handled elsewhere.
+               // Die.
+               //return true;
+               // Actually, fail very loudly:
+               assert(0);
+       }
+
+#ifndef SERVER
+       virtual void clientStep(float dtime)
+       {
+               MovingObject::simpleMove(dtime);
+
+               updateNodePos();
+       }
+       
+       virtual void addToScene(scene::ISceneManager *smgr);
+
+       virtual void removeFromScene()
+       {
+               if(m_node == NULL)
+                       return;
+
+               m_node->remove();
+               m_node = NULL;
+       }
+
+       virtual void updateLight(u8 light_at_pos)
+       {
+               if(m_node == NULL)
+                       return;
+
+               u8 li = decode_light(light_at_pos);
+               video::SColor color(255,li,li,li);
+
+               scene::IMesh *mesh = m_node->getMesh();
+               
+               u16 mc = mesh->getMeshBufferCount();
+               for(u16 j=0; j<mc; j++)
+               {
+                       scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
+                       video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
+                       u16 vc = buf->getVertexCount();
+                       for(u16 i=0; i<vc; i++)
+                       {
+                               vertices[i].Color = color;
+                       }
+               }
+       }
+       
+#endif
+
+       /*
+               Special methods
+       */
+       
+       void updateNodePos()
+       {
+               if(m_node == NULL)
+                       return;
+
+               m_node->setPosition(getAbsoluteShowPos());
+               m_node->setRotation(v3f(0, -m_yaw+180, 0));
+       }
+       
+protected:
+       scene::IMeshSceneNode *m_node;
+       float m_yaw;
+
+       v3f m_oldpos;
+};
+
 struct DistanceSortedObject
 {
        DistanceSortedObject(MapBlockObject *a_obj, f32 a_d)
index 2c04f1f7637a7b2fe80b7c166f4fa6d471b940c9..d38d5eac8ad60f995a41862d494a3f508c3e2353 100644 (file)
@@ -41,7 +41,159 @@ Player::~Player()
 {
 }
 
-void Player::move(f32 dtime, Map &map)
+// Y direction is ignored
+void Player::accelerate(v3f target_speed, f32 max_increase)
+{
+       if(m_speed.X < target_speed.X - max_increase)
+               m_speed.X += max_increase;
+       else if(m_speed.X > target_speed.X + max_increase)
+               m_speed.X -= max_increase;
+       else if(m_speed.X < target_speed.X)
+               m_speed.X = target_speed.X;
+       else if(m_speed.X > target_speed.X)
+               m_speed.X = target_speed.X;
+
+       if(m_speed.Z < target_speed.Z - max_increase)
+               m_speed.Z += max_increase;
+       else if(m_speed.Z > target_speed.Z + max_increase)
+               m_speed.Z -= max_increase;
+       else if(m_speed.Z < target_speed.Z)
+               m_speed.Z = target_speed.Z;
+       else if(m_speed.Z > target_speed.Z)
+               m_speed.Z = target_speed.Z;
+}
+
+/*
+       RemotePlayer
+*/
+
+#ifndef SERVER
+
+RemotePlayer::RemotePlayer(
+               scene::ISceneNode* parent,
+               IrrlichtDevice *device,
+               s32 id):
+       scene::ISceneNode(parent, (device==NULL)?NULL:device->getSceneManager(), id),
+       m_text(NULL)
+{
+       m_box = core::aabbox3d<f32>(-BS/2,0,-BS/2,BS/2,BS*2,BS/2);
+
+       if(parent != NULL && device != NULL)
+       {
+               // ISceneNode stores a member called SceneManager
+               scene::ISceneManager* mgr = SceneManager;
+               video::IVideoDriver* driver = mgr->getVideoDriver();
+               gui::IGUIEnvironment* gui = device->getGUIEnvironment();
+
+               // Add a text node for showing the name
+               wchar_t wname[1] = {0};
+               m_text = mgr->addTextSceneNode(gui->getBuiltInFont(),
+                               wname, video::SColor(255,255,255,255), this);
+               m_text->setPosition(v3f(0, (f32)BS*2.1, 0));
+
+               // Attach a simple mesh to the player for showing an image
+               scene::SMesh *mesh = new scene::SMesh();
+               { // Front
+               scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+               video::SColor c(255,255,255,255);
+               video::S3DVertex vertices[4] =
+               {
+                       video::S3DVertex(-BS/2,0,0, 0,0,0, c, 0,1),
+                       video::S3DVertex(BS/2,0,0, 0,0,0, c, 1,1),
+                       video::S3DVertex(BS/2,BS*2,0, 0,0,0, c, 1,0),
+                       video::S3DVertex(-BS/2,BS*2,0, 0,0,0, c, 0,0),
+               };
+               u16 indices[] = {0,1,2,2,3,0};
+               buf->append(vertices, 4, indices, 6);
+               // Set material
+               buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+               //buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
+               buf->getMaterial().setTexture(0, driver->getTexture("../data/player.png"));
+               buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+               //buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
+               buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+               // Add to mesh
+               mesh->addMeshBuffer(buf);
+               buf->drop();
+               }
+               { // Back
+               scene::IMeshBuffer *buf = new scene::SMeshBuffer();
+               video::SColor c(255,255,255,255);
+               video::S3DVertex vertices[4] =
+               {
+                       video::S3DVertex(BS/2,0,0, 0,0,0, c, 1,1),
+                       video::S3DVertex(-BS/2,0,0, 0,0,0, c, 0,1),
+                       video::S3DVertex(-BS/2,BS*2,0, 0,0,0, c, 0,0),
+                       video::S3DVertex(BS/2,BS*2,0, 0,0,0, c, 1,0),
+               };
+               u16 indices[] = {0,1,2,2,3,0};
+               buf->append(vertices, 4, indices, 6);
+               // Set material
+               buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
+               //buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
+               buf->getMaterial().setTexture(0, driver->getTexture("../data/player_back.png"));
+               buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
+               buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+               // Add to mesh
+               mesh->addMeshBuffer(buf);
+               buf->drop();
+               }
+               m_node = mgr->addMeshSceneNode(mesh, this);
+               mesh->drop();
+               m_node->setPosition(v3f(0,0,0));
+       }
+}
+
+RemotePlayer::~RemotePlayer()
+{
+       if(SceneManager != NULL)
+               ISceneNode::remove();
+}
+
+void RemotePlayer::updateName(const char *name)
+{
+       Player::updateName(name);
+       if(m_text != NULL)
+       {
+               wchar_t wname[PLAYERNAME_SIZE];
+               mbstowcs(wname, m_name, strlen(m_name)+1);
+               m_text->setText(wname);
+       }
+}
+
+void RemotePlayer::move(f32 dtime, Map &map)
+{
+       m_pos_animation_time_counter += dtime;
+       m_pos_animation_counter += dtime;
+       v3f movevector = m_position - m_oldpos;
+       f32 moveratio;
+       if(m_pos_animation_time < 0.001)
+               moveratio = 1.0;
+       else
+               moveratio = m_pos_animation_counter / m_pos_animation_time;
+       if(moveratio > 1.5)
+               moveratio = 1.5;
+       m_showpos = m_oldpos + movevector * moveratio;
+       
+       ISceneNode::setPosition(m_showpos);
+}
+
+#endif
+
+#ifndef SERVER
+/*
+       LocalPlayer
+*/
+
+LocalPlayer::LocalPlayer()
+{
+}
+
+LocalPlayer::~LocalPlayer()
+{
+}
+
+void LocalPlayer::move(f32 dtime, Map &map)
 {
        v3f position = getPosition();
        v3f oldpos = position;
@@ -202,141 +354,6 @@ void Player::move(f32 dtime, Map &map)
        setPosition(position);
 }
 
-// Y direction is ignored
-void Player::accelerate(v3f target_speed, f32 max_increase)
-{
-       if(m_speed.X < target_speed.X - max_increase)
-               m_speed.X += max_increase;
-       else if(m_speed.X > target_speed.X + max_increase)
-               m_speed.X -= max_increase;
-       else if(m_speed.X < target_speed.X)
-               m_speed.X = target_speed.X;
-       else if(m_speed.X > target_speed.X)
-               m_speed.X = target_speed.X;
-
-       if(m_speed.Z < target_speed.Z - max_increase)
-               m_speed.Z += max_increase;
-       else if(m_speed.Z > target_speed.Z + max_increase)
-               m_speed.Z -= max_increase;
-       else if(m_speed.Z < target_speed.Z)
-               m_speed.Z = target_speed.Z;
-       else if(m_speed.Z > target_speed.Z)
-               m_speed.Z = target_speed.Z;
-}
-
-/*
-       RemotePlayer
-*/
-
-#ifndef SERVER
-
-RemotePlayer::RemotePlayer(
-               scene::ISceneNode* parent,
-               IrrlichtDevice *device,
-               s32 id):
-       scene::ISceneNode(parent, (device==NULL)?NULL:device->getSceneManager(), id),
-       m_text(NULL)
-{
-       m_box = core::aabbox3d<f32>(-BS/2,0,-BS/2,BS/2,BS*2,BS/2);
-
-       if(parent != NULL && device != NULL)
-       {
-               // ISceneNode stores a member called SceneManager
-               scene::ISceneManager* mgr = SceneManager;
-               video::IVideoDriver* driver = mgr->getVideoDriver();
-               gui::IGUIEnvironment* gui = device->getGUIEnvironment();
-
-               // Add a text node for showing the name
-               wchar_t wname[1] = {0};
-               m_text = mgr->addTextSceneNode(gui->getBuiltInFont(),
-                               wname, video::SColor(255,255,255,255), this);
-               m_text->setPosition(v3f(0, (f32)BS*2.1, 0));
-
-               // Attach a simple mesh to the player for showing an image
-               scene::SMesh *mesh = new scene::SMesh();
-               { // Front
-               scene::IMeshBuffer *buf = new scene::SMeshBuffer();
-               video::SColor c(255,255,255,255);
-               video::S3DVertex vertices[4] =
-               {
-                       video::S3DVertex(-BS/2,0,0, 0,0,0, c, 0,1),
-                       video::S3DVertex(BS/2,0,0, 0,0,0, c, 1,1),
-                       video::S3DVertex(BS/2,BS*2,0, 0,0,0, c, 1,0),
-                       video::S3DVertex(-BS/2,BS*2,0, 0,0,0, c, 0,0),
-               };
-               u16 indices[] = {0,1,2,2,3,0};
-               buf->append(vertices, 4, indices, 6);
-               // Set material
-               buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
-               //buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
-               buf->getMaterial().setTexture(0, driver->getTexture("../data/player.png"));
-               buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
-               //buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
-               buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
-               // Add to mesh
-               mesh->addMeshBuffer(buf);
-               buf->drop();
-               }
-               { // Back
-               scene::IMeshBuffer *buf = new scene::SMeshBuffer();
-               video::SColor c(255,255,255,255);
-               video::S3DVertex vertices[4] =
-               {
-                       video::S3DVertex(BS/2,0,0, 0,0,0, c, 1,1),
-                       video::S3DVertex(-BS/2,0,0, 0,0,0, c, 0,1),
-                       video::S3DVertex(-BS/2,BS*2,0, 0,0,0, c, 0,0),
-                       video::S3DVertex(BS/2,BS*2,0, 0,0,0, c, 1,0),
-               };
-               u16 indices[] = {0,1,2,2,3,0};
-               buf->append(vertices, 4, indices, 6);
-               // Set material
-               buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
-               //buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
-               buf->getMaterial().setTexture(0, driver->getTexture("../data/player_back.png"));
-               buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
-               buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
-               // Add to mesh
-               mesh->addMeshBuffer(buf);
-               buf->drop();
-               }
-               scene::IMeshSceneNode *node = mgr->addMeshSceneNode(mesh, this);
-               mesh->drop();
-               node->setPosition(v3f(0,0,0));
-       }
-}
-
-RemotePlayer::~RemotePlayer()
-{
-       if(SceneManager != NULL)
-               ISceneNode::remove();
-}
-
-void RemotePlayer::updateName(const char *name)
-{
-       Player::updateName(name);
-       if(m_text != NULL)
-       {
-               wchar_t wname[PLAYERNAME_SIZE];
-               mbstowcs(wname, m_name, strlen(m_name)+1);
-               m_text->setText(wname);
-       }
-}
-
-#endif
-
-#ifndef SERVER
-/*
-       LocalPlayer
-*/
-
-LocalPlayer::LocalPlayer()
-{
-}
-
-LocalPlayer::~LocalPlayer()
-{
-}
-
 void LocalPlayer::applyControl(float dtime)
 {
        // Random constants
index 7337eb6db3e654634ee3b72b044aa488fcfcfafb..0b9f014c1274d1a93fdac3bba00055979181f687 100644 (file)
@@ -37,7 +37,8 @@ public:
        Player();
        virtual ~Player();
 
-       void move(f32 dtime, Map &map);
+       //void move(f32 dtime, Map &map);
+       virtual void move(f32 dtime, Map &map) = 0;
 
        v3f getSpeed()
        {
@@ -94,6 +95,8 @@ public:
 
        virtual bool isLocal() const = 0;
 
+       virtual void updateLight(u8 light_at_pos) {};
+
        bool touching_ground;
        bool in_water;
        
@@ -124,6 +127,10 @@ public:
                return false;
        }
 
+       void move(f32 dtime, Map &map)
+       {
+       }
+
 private:
 };
 
@@ -163,8 +170,18 @@ public:
 
        void setPosition(v3f position)
        {
+               m_oldpos = m_showpos;
+               
+               if(m_pos_animation_time < 0.001 || m_pos_animation_time > 1.0)
+                       m_pos_animation_time = m_pos_animation_time_counter;
+               else
+                       m_pos_animation_time = m_pos_animation_time * 0.9
+                                       + m_pos_animation_time_counter * 0.1;
+               m_pos_animation_time_counter = 0;
+               m_pos_animation_counter = 0;
+               
                Player::setPosition(position);
-               ISceneNode::setPosition(position);
+               //ISceneNode::setPosition(position);
        }
 
        virtual void setYaw(f32 yaw)
@@ -180,9 +197,41 @@ public:
 
        void updateName(const char *name);
 
+       virtual void updateLight(u8 light_at_pos)
+       {
+               if(m_node == NULL)
+                       return;
+
+               u8 li = decode_light(light_at_pos);
+               video::SColor color(255,li,li,li);
+
+               scene::IMesh *mesh = m_node->getMesh();
+               
+               u16 mc = mesh->getMeshBufferCount();
+               for(u16 j=0; j<mc; j++)
+               {
+                       scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
+                       video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
+                       u16 vc = buf->getVertexCount();
+                       for(u16 i=0; i<vc; i++)
+                       {
+                               vertices[i].Color = color;
+                       }
+               }
+       }
+       
+       void move(f32 dtime, Map &map);
+
 private:
+       scene::IMeshSceneNode *m_node;
        scene::ITextSceneNode* m_text;
        core::aabbox3d<f32> m_box;
+
+       v3f m_oldpos;
+       f32 m_pos_animation_counter;
+       f32 m_pos_animation_time;
+       f32 m_pos_animation_time_counter;
+       v3f m_showpos;
 };
 
 #endif
@@ -242,6 +291,8 @@ public:
                return true;
        }
 
+       void move(f32 dtime, Map &map);
+
        void applyControl(float dtime);
        
        PlayerControl control;
index c5a285490aa34e20ea21995ab72c1bb4fdbc48b7..d002d9f4c9cf1afb390cc5828dd2eac0023002f4 100644 (file)
@@ -29,14 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "common_irrlicht.h"
 #include <string>
 #include "utility.h"
-
-#ifdef _WIN32
-       #include <windows.h>
-       #define sleep_ms(x) Sleep(x)
-#else
-       #include <unistd.h>
-       #define sleep_ms(x) usleep(x*1000)
-#endif
+#include "porting.h"
 
 struct QueuedBlockEmerge
 {
index ce0243e123f1b7894637fabe3d4a4c73d44782c4..0c2faa7ec9285546401d636a3037a96111ab6095 100644 (file)
@@ -271,8 +271,6 @@ int main(int argc, char *argv[])
        <<"|  Y Y  \\  |   |  \\  ___/|  | \\  ___/ \\___ \\  |  |  "<<std::endl
        <<"|__|_|  /__|___|  /\\___  >__|  \\___  >____  > |__|  "<<std::endl
        <<"      \\/        \\/     \\/          \\/     \\/        "<<std::endl
-       <<std::endl
-       <<"Now with more waterish water!"
        <<std::endl;
 
        std::cout<<std::endl;
index 3ed6425120f60b81e32d88582ec26cb433c48d3d..142918df622edd414b42a7788cd010b32fb3af5a 100644 (file)
@@ -30,14 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "serialization.h"
 #include "voxel.h"
 #include <sstream>
-
-#ifdef _WIN32
-       #include <windows.h>
-       #define sleep_ms(x) Sleep(x)
-#else
-       #include <unistd.h>
-       #define sleep_ms(x) usleep(x*1000)
-#endif
+#include "porting.h"
 
 /*
        Asserts that the exception occurs
index 282ff5e7c6cc12216a7e2e369a1f61e305751d6e..55cd73893c3a6cae96f2ab27bf8785902dd3ed1b 100644 (file)
@@ -804,8 +804,10 @@ bool VoxelManipulator::flowWater(v3s16 removed_pos,
        if(stoptime != 0)
        {
                u32 timenow = getTimeMs();
-               if(timenow >= stoptime ||
-                               (stoptime < 0x80000000 && timenow > 0x80000000))
+               // Well, it is a bit hard to guess because we don't know the
+               // start time...
+               bool overflow = timenow < stoptime - 100000;
+               if(timenow >= stoptime || overflow)
                {
                        dstream<<"flowWater: stoptime reached"<<std::endl;
                        throw ProcessingLimitException("flowWater stoptime reached");