forked from Mirrorlandia_minetest/minetest
some work-in-progress
This commit is contained in:
parent
3f5bad938a
commit
b94a007864
4
Makefile
4
Makefile
@ -2,7 +2,7 @@
|
|||||||
# It's usually sufficient to change just the target name and source file list
|
# It's usually sufficient to change just the target name and source file list
|
||||||
# and be sure that CXX is set to a valid compiler
|
# and be sure that CXX is set to a valid compiler
|
||||||
TARGET = test
|
TARGET = test
|
||||||
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
|
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
|
||||||
SOURCES = $(addprefix src/, $(SOURCE_FILES))
|
SOURCES = $(addprefix src/, $(SOURCE_FILES))
|
||||||
BUILD_DIR = build
|
BUILD_DIR = build
|
||||||
OBJECTS = $(addprefix $(BUILD_DIR)/, $(SOURCE_FILES:.cpp=.o))
|
OBJECTS = $(addprefix $(BUILD_DIR)/, $(SOURCE_FILES:.cpp=.o))
|
||||||
@ -69,7 +69,7 @@ $(SERVER_BUILD_DIR):
|
|||||||
$(DESTPATH): $(OBJECTS)
|
$(DESTPATH): $(OBJECTS)
|
||||||
$(CXX) -o $@ $(OBJECTS) $(LDFLAGS)
|
$(CXX) -o $@ $(OBJECTS) $(LDFLAGS)
|
||||||
|
|
||||||
$(FAST_DESTPATH): $(SOURCES)
|
$(FAST_DESTPATH): $(OBJECTS)
|
||||||
$(CXX) -o $@ $(OBJECTS) $(LDFLAGS) -DUNITTEST_DISABLE
|
$(CXX) -o $@ $(OBJECTS) $(LDFLAGS) -DUNITTEST_DISABLE
|
||||||
|
|
||||||
$(SERVER_DESTPATH): $(SERVER_OBJECTS)
|
$(SERVER_DESTPATH): $(SERVER_OBJECTS)
|
||||||
|
Binary file not shown.
@ -186,6 +186,10 @@
|
|||||||
RelativePath=".\src\debug.cpp"
|
RelativePath=".\src\debug.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\defaultsettings.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\environment.cpp"
|
RelativePath=".\src\environment.cpp"
|
||||||
>
|
>
|
||||||
@ -206,6 +210,10 @@
|
|||||||
RelativePath=".\src\inventory.cpp"
|
RelativePath=".\src\inventory.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\irrlichtwrapper.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\light.cpp"
|
RelativePath=".\src\light.cpp"
|
||||||
>
|
>
|
||||||
|
@ -24,14 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "jmutexautolock.h"
|
#include "jmutexautolock.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include "porting.h"
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#define sleep_ms(x) Sleep(x)
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#define sleep_ms(x) usleep(x*1000)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void * ClientUpdateThread::Thread()
|
void * ClientUpdateThread::Thread()
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
// Viewing range stuff
|
// Viewing range stuff
|
||||||
|
|
||||||
//#define FREETIME_RATIO 0.15
|
//#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
|
// Sectors are split to SECTOR_HEIGHTMAP_SPLIT^2 heightmaps
|
||||||
#define SECTOR_HEIGHTMAP_SPLIT 2
|
#define SECTOR_HEIGHTMAP_SPLIT 2
|
||||||
|
@ -21,15 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "porting.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
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Debug output
|
Debug output
|
||||||
|
@ -104,6 +104,8 @@ void Environment::step(float dtime)
|
|||||||
{
|
{
|
||||||
Player *player = *i;
|
Player *player = *i;
|
||||||
|
|
||||||
|
v3f playerpos = player->getPosition();
|
||||||
|
|
||||||
// Apply physics to local player
|
// Apply physics to local player
|
||||||
if(player->isLocal())
|
if(player->isLocal())
|
||||||
{
|
{
|
||||||
@ -135,12 +137,22 @@ void Environment::step(float dtime)
|
|||||||
*/
|
*/
|
||||||
player->move(dtime_part, *m_map);
|
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
|
Add footsteps to grass
|
||||||
*/
|
*/
|
||||||
//TimeTaker footsteptimer("footstep", g_device);
|
|
||||||
// 0ms
|
|
||||||
v3f playerpos = player->getPosition();
|
|
||||||
// Get node that is at BS/4 under player
|
// Get node that is at BS/4 under player
|
||||||
v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0));
|
v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0));
|
||||||
try{
|
try{
|
||||||
@ -163,7 +175,6 @@ void Environment::step(float dtime)
|
|||||||
catch(InvalidPositionException &e)
|
catch(InvalidPositionException &e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
//footsteptimer.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(dtime > 0.001);
|
while(dtime > 0.001);
|
||||||
|
@ -21,8 +21,145 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
|
|
||||||
#include "guiPauseMenu.h"
|
#include "guiPauseMenu.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
void guiPauseMenu::scaleGui() // this function scales gui from the size stored in file to screen size
|
GUIPauseMenu::GUIPauseMenu(gui::IGUIEnvironment* env,
|
||||||
|
gui::IGUIElement* parent, s32 id,
|
||||||
|
IrrlichtDevice *dev):
|
||||||
|
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
|
||||||
|
core::rect<s32>(0,0,100,100))
|
||||||
|
{
|
||||||
|
m_dev = dev;
|
||||||
|
m_screensize_old = v2u32(0,0);
|
||||||
|
|
||||||
|
resizeGui();
|
||||||
|
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
GUIPauseMenu::~GUIPauseMenu()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUIPauseMenu::resizeGui()
|
||||||
|
{
|
||||||
|
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||||
|
v2u32 screensize = driver->getScreenSize();
|
||||||
|
if(screensize == m_screensize_old)
|
||||||
|
return;
|
||||||
|
m_screensize_old = screensize;
|
||||||
|
|
||||||
|
{
|
||||||
|
gui::IGUIElement *e = getElementFromId(256);
|
||||||
|
if(e != NULL)
|
||||||
|
e->remove();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
gui::IGUIElement *e = getElementFromId(257);
|
||||||
|
if(e != NULL)
|
||||||
|
e->remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
core::rect<s32> rect(
|
||||||
|
screensize.X/2 - 560/2,
|
||||||
|
screensize.Y/2 - 300/2,
|
||||||
|
screensize.X/2 + 560/2,
|
||||||
|
screensize.Y/2 + 300/2
|
||||||
|
);
|
||||||
|
|
||||||
|
DesiredRect = rect;
|
||||||
|
recalculateAbsolutePosition(false);
|
||||||
|
|
||||||
|
v2s32 size = rect.getSize();
|
||||||
|
|
||||||
|
{
|
||||||
|
core::rect<s32> rect(0, 0, 140, 30);
|
||||||
|
rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2-25);
|
||||||
|
Environment->addButton(rect, this, 256, L"Continue");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
core::rect<s32> rect(0, 0, 140, 30);
|
||||||
|
rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25);
|
||||||
|
Environment->addButton(rect, this, 257, L"Exit");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUIPauseMenu::draw()
|
||||||
|
{
|
||||||
|
if(!IsVisible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gui::IGUISkin* skin = Environment->getSkin();
|
||||||
|
if (!skin)
|
||||||
|
return;
|
||||||
|
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||||
|
|
||||||
|
video::SColor bgcolor(140,0,0,0);
|
||||||
|
driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
|
||||||
|
|
||||||
|
gui::IGUIElement::draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GUIPauseMenu::OnEvent(const SEvent& event)
|
||||||
|
{
|
||||||
|
if(event.EventType==EET_KEY_INPUT_EVENT)
|
||||||
|
{
|
||||||
|
if(event.KeyInput.Key==KEY_ESCAPE && event.KeyInput.PressedDown)
|
||||||
|
{
|
||||||
|
setVisible(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(event.EventType==EET_GUI_EVENT)
|
||||||
|
{
|
||||||
|
if(event.GUIEvent.EventType==gui::EGET_ELEMENT_FOCUS_LOST
|
||||||
|
&& isVisible())
|
||||||
|
{
|
||||||
|
if(!canTakeFocus(event.GUIEvent.Element))
|
||||||
|
{
|
||||||
|
dstream<<"GUIPauseMenu: Not allowing focus change."
|
||||||
|
<<std::endl;
|
||||||
|
// Returning true disables focus change
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(event.GUIEvent.EventType==gui::EGET_BUTTON_CLICKED)
|
||||||
|
{
|
||||||
|
switch(event.GUIEvent.Caller->getID())
|
||||||
|
{
|
||||||
|
case 256: // continue
|
||||||
|
setVisible(false);
|
||||||
|
break;
|
||||||
|
case 257: // exit
|
||||||
|
m_dev->closeDevice();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Parent ? Parent->OnEvent(event) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
GUIPauseMenu::GUIPauseMenu(IrrlichtDevice *device, IEventReceiver *recv):
|
||||||
|
dev(device),
|
||||||
|
oldRecv(recv)
|
||||||
|
{
|
||||||
|
if(!dev)
|
||||||
|
return;
|
||||||
|
guienv=dev->getGUIEnvironment();
|
||||||
|
|
||||||
|
if (!loadMenu())
|
||||||
|
return;
|
||||||
|
|
||||||
|
device->setEventReceiver(this); // now WE are the input receiver! ahhaha!
|
||||||
|
}
|
||||||
|
|
||||||
|
GUIPauseMenu::~GUIPauseMenu(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUIPauseMenu::scaleGui() // this function scales gui from the size stored in file to screen size
|
||||||
{
|
{
|
||||||
core::dimension2du screen=dev->getVideoDriver()->getScreenSize();
|
core::dimension2du screen=dev->getVideoDriver()->getScreenSize();
|
||||||
core::vector2di real=root->getAbsolutePosition().LowerRightCorner; // determine gui size stored in file (which is size of my menu root node)
|
core::vector2di real=root->getAbsolutePosition().LowerRightCorner; // determine gui size stored in file (which is size of my menu root node)
|
||||||
@ -30,7 +167,7 @@ void guiPauseMenu::scaleGui() // this function scales gui from the size stored i
|
|||||||
float factorY=(float)screen.Height/(float)real.Y;
|
float factorY=(float)screen.Height/(float)real.Y;
|
||||||
scaleGui(guienv->getRootGUIElement(),factorX,factorY);
|
scaleGui(guienv->getRootGUIElement(),factorX,factorY);
|
||||||
}
|
}
|
||||||
void guiPauseMenu::scaleGui(gui::IGUIElement *node,float factorX,float factorY) // recursive set scale
|
void GUIPauseMenu::scaleGui(gui::IGUIElement *node,float factorX,float factorY) // recursive set scale
|
||||||
{
|
{
|
||||||
if((node->getParent() && node->getParent()->getID()==255) || node->getID()==255) // modify only menu's elements
|
if((node->getParent() && node->getParent()->getID()==255) || node->getID()==255) // modify only menu's elements
|
||||||
{
|
{
|
||||||
@ -47,7 +184,7 @@ void guiPauseMenu::scaleGui(gui::IGUIElement *node,float factorX,float factorY)
|
|||||||
scaleGui((*it),factorX,factorY);
|
scaleGui((*it),factorX,factorY);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool guiPauseMenu::loadMenu()
|
bool GUIPauseMenu::loadMenu()
|
||||||
{
|
{
|
||||||
guienv->loadGUI("../data/pauseMenu.gui");
|
guienv->loadGUI("../data/pauseMenu.gui");
|
||||||
|
|
||||||
@ -65,19 +202,7 @@ bool guiPauseMenu::loadMenu()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
guiPauseMenu::guiPauseMenu(IrrlichtDevice *device, IEventReceiver *recv) : dev(device), oldRecv(recv)
|
bool GUIPauseMenu::OnEvent(const SEvent& event)
|
||||||
{
|
|
||||||
if(!dev)
|
|
||||||
return;
|
|
||||||
guienv=dev->getGUIEnvironment();
|
|
||||||
|
|
||||||
if (!loadMenu())
|
|
||||||
return;
|
|
||||||
|
|
||||||
device->setEventReceiver(this); // now WE are the input receiver! ahhaha!
|
|
||||||
}
|
|
||||||
|
|
||||||
bool guiPauseMenu::OnEvent(const SEvent& event)
|
|
||||||
{
|
{
|
||||||
if(!dev->isWindowFocused())
|
if(!dev->isWindowFocused())
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
@ -114,7 +239,5 @@ bool guiPauseMenu::OnEvent(const SEvent& event)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
guiPauseMenu::~guiPauseMenu(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
@ -23,31 +23,64 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#ifndef GUIPAUSEMENU_HEADER
|
#ifndef GUIPAUSEMENU_HEADER
|
||||||
#define GUIPAUSEMENU_HEADER
|
#define GUIPAUSEMENU_HEADER
|
||||||
|
|
||||||
#include <irrlicht.h>
|
#include "common_irrlicht.h"
|
||||||
using namespace irr;
|
|
||||||
|
|
||||||
class guiPauseMenu : public IEventReceiver
|
class GUIPauseMenu : public gui::IGUIElement
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
IrrlichtDevice *dev;
|
|
||||||
gui::IGUIEnvironment *guienv;
|
|
||||||
IEventReceiver *oldRecv;
|
|
||||||
|
|
||||||
gui::IGUIStaticText *root;
|
|
||||||
|
|
||||||
bool loadMenu();
|
|
||||||
void scaleGui();
|
|
||||||
void scaleGui(gui::IGUIElement *node,float factorX,float factorY);
|
|
||||||
public:
|
public:
|
||||||
guiPauseMenu(IrrlichtDevice *device,IEventReceiver *recv);
|
GUIPauseMenu(gui::IGUIEnvironment* env,
|
||||||
|
gui::IGUIElement* parent, s32 id,
|
||||||
|
IrrlichtDevice *dev);
|
||||||
|
~GUIPauseMenu();
|
||||||
|
|
||||||
|
/*
|
||||||
|
Remove and re-add (or reposition) stuff
|
||||||
|
*/
|
||||||
|
void resizeGui();
|
||||||
|
|
||||||
|
void draw();
|
||||||
|
|
||||||
|
void launch()
|
||||||
|
{
|
||||||
|
setVisible(true);
|
||||||
|
Environment->setFocus(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool canTakeFocus(gui::IGUIElement *e)
|
||||||
|
{
|
||||||
|
return (e && (e == this || isMyChild(e)));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OnEvent(const SEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
IrrlichtDevice *m_dev;
|
||||||
|
v2u32 m_screensize_old;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*class GUIPauseMenu : public IEventReceiver
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void scaleGui();
|
||||||
|
|
||||||
|
GUIPauseMenu(IrrlichtDevice *device,IEventReceiver *recv);
|
||||||
|
~GUIPauseMenu(void);
|
||||||
|
|
||||||
void setVisible(bool visible){root->setVisible(visible);};
|
void setVisible(bool visible){root->setVisible(visible);};
|
||||||
bool isVisible(){return root->isVisible();};
|
bool isVisible(){return root->isVisible();};
|
||||||
|
|
||||||
bool OnEvent(const SEvent& event);
|
bool OnEvent(const SEvent& event);
|
||||||
|
|
||||||
~guiPauseMenu(void);
|
private:
|
||||||
};
|
bool loadMenu();
|
||||||
|
void scaleGui(gui::IGUIElement *node,float factorX,float factorY);
|
||||||
|
|
||||||
|
IrrlichtDevice *dev;
|
||||||
|
gui::IGUIEnvironment *guienv;
|
||||||
|
IEventReceiver *oldRecv;
|
||||||
|
|
||||||
|
gui::IGUIStaticText *root;
|
||||||
|
};*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -196,7 +196,6 @@ private:
|
|||||||
std::string m_inventorystring;
|
std::string m_inventorystring;
|
||||||
};
|
};
|
||||||
|
|
||||||
//SUGGESTION: Split into ClientInventory and ServerInventory
|
|
||||||
class Inventory
|
class Inventory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
118
src/main.cpp
118
src/main.cpp
@ -161,17 +161,17 @@ TODO: Remove LazyMeshUpdater. It is not used as supposed.
|
|||||||
TODO: TOSERVER_LEAVE
|
TODO: TOSERVER_LEAVE
|
||||||
|
|
||||||
TODO: Better handling of objects and mobs
|
TODO: Better handling of objects and mobs
|
||||||
- Update brightness according to day-night blended light of node
|
|
||||||
in position
|
|
||||||
- Scripting?
|
- Scripting?
|
||||||
|
- There has to be some way to do it with less spaghetti code
|
||||||
|
- Make separate classes for client and server
|
||||||
|
- Client should not discriminate between blocks, server should
|
||||||
|
- Make other players utilize the same framework
|
||||||
|
|
||||||
|
SUGG: Split Inventory into ClientInventory and ServerInventory
|
||||||
|
|
||||||
Doing now:
|
Doing now:
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
TODO: Get rid of g_irrlicht for server build
|
|
||||||
|
|
||||||
TODO: Implement getGlobalTime for server build
|
|
||||||
- It is needed for controlling the time used for flowing water
|
|
||||||
|
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
||||||
@ -208,15 +208,6 @@ TODO: Implement getGlobalTime for server build
|
|||||||
//#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
|
//#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#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 <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <jmutexautolock.h>
|
#include <jmutexautolock.h>
|
||||||
@ -237,6 +228,8 @@ TODO: Implement getGlobalTime for server build
|
|||||||
#include "guiPauseMenu.h"
|
#include "guiPauseMenu.h"
|
||||||
#include "irrlichtwrapper.h"
|
#include "irrlichtwrapper.h"
|
||||||
#include "gettime.h"
|
#include "gettime.h"
|
||||||
|
#include "porting.h"
|
||||||
|
#include "guiInventoryMenu.h"
|
||||||
|
|
||||||
IrrlichtWrapper *g_irrlicht;
|
IrrlichtWrapper *g_irrlicht;
|
||||||
|
|
||||||
@ -276,7 +269,9 @@ extern void set_default_settings();
|
|||||||
//u16 g_selected_material = 0;
|
//u16 g_selected_material = 0;
|
||||||
u16 g_selected_item = 0;
|
u16 g_selected_item = 0;
|
||||||
|
|
||||||
bool g_esc_pressed = false;
|
gui::IGUIEnvironment* guienv = NULL;
|
||||||
|
GUIPauseMenu *pauseMenu = NULL;
|
||||||
|
GUIInventoryMenu *inventoryMenu = NULL;
|
||||||
|
|
||||||
std::wstring g_text_buffer;
|
std::wstring g_text_buffer;
|
||||||
bool g_text_buffer_accepted = false;
|
bool g_text_buffer_accepted = false;
|
||||||
@ -354,13 +349,35 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.KeyInput.Key == irr::KEY_ESCAPE)
|
if(pauseMenu != NULL)
|
||||||
{
|
{
|
||||||
//TODO: Not used anymore?
|
if(event.KeyInput.Key == irr::KEY_ESCAPE)
|
||||||
if(g_game_focused == true)
|
|
||||||
{
|
{
|
||||||
dstream<<DTIME<<"ESC pressed"<<std::endl;
|
if(g_game_focused == true
|
||||||
g_esc_pressed = true;
|
&& !pauseMenu->isVisible()
|
||||||
|
&& !inventoryMenu->isVisible())
|
||||||
|
{
|
||||||
|
dstream<<DTIME<<"MyEventReceiver: "
|
||||||
|
<<"Launching pause menu"<<std::endl;
|
||||||
|
pauseMenu->launch();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(inventoryMenu != NULL)
|
||||||
|
{
|
||||||
|
if(event.KeyInput.Key == irr::KEY_KEY_I)
|
||||||
|
{
|
||||||
|
if(g_game_focused == true
|
||||||
|
&& !inventoryMenu->isVisible()
|
||||||
|
&& !pauseMenu->isVisible())
|
||||||
|
{
|
||||||
|
dstream<<DTIME<<"MyEventReceiver: "
|
||||||
|
<<"Launching inventory"<<std::endl;
|
||||||
|
inventoryMenu->launch();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,6 +428,7 @@ public:
|
|||||||
|
|
||||||
if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)
|
if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)
|
||||||
{
|
{
|
||||||
|
//dstream<<"MyEventReceiver: mouse input"<<std::endl;
|
||||||
left_active = event.MouseInput.isLeftPressed();
|
left_active = event.MouseInput.isLeftPressed();
|
||||||
middle_active = event.MouseInput.isMiddlePressed();
|
middle_active = event.MouseInput.isMiddlePressed();
|
||||||
right_active = event.MouseInput.isRightPressed();
|
right_active = event.MouseInput.isRightPressed();
|
||||||
@ -1137,8 +1155,6 @@ int main(int argc, char *argv[])
|
|||||||
<<"| Y Y \\ | | \\ ___/| | \\ ___/ \\___ \\ | | "<<std::endl
|
<<"| Y Y \\ | | \\ ___/| | \\ ___/ \\___ \\ | | "<<std::endl
|
||||||
<<"|__|_| /__|___| /\\___ >__| \\___ >____ > |__| "<<std::endl
|
<<"|__|_| /__|___| /\\___ >__| \\___ >____ > |__| "<<std::endl
|
||||||
<<" \\/ \\/ \\/ \\/ \\/ "<<std::endl
|
<<" \\/ \\/ \\/ \\/ \\/ "<<std::endl
|
||||||
<<std::endl
|
|
||||||
<<"Now with more waterish water!"
|
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
|
|
||||||
std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
@ -1298,10 +1314,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
scene::ISceneManager* smgr = device->getSceneManager();
|
scene::ISceneManager* smgr = device->getSceneManager();
|
||||||
|
|
||||||
// Pause menu
|
guienv = device->getGUIEnvironment();
|
||||||
guiPauseMenu pauseMenu(device, &receiver);
|
|
||||||
|
|
||||||
gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
|
|
||||||
gui::IGUISkin* skin = guienv->getSkin();
|
gui::IGUISkin* skin = guienv->getSkin();
|
||||||
gui::IGUIFont* font = guienv->getFont("../data/fontlucida.png");
|
gui::IGUIFont* font = guienv->getFont("../data/fontlucida.png");
|
||||||
if(font)
|
if(font)
|
||||||
@ -1457,12 +1470,33 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
gui_loadingtext->remove();
|
gui_loadingtext->remove();
|
||||||
|
|
||||||
pauseMenu.setVisible(true);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Add some gui stuff
|
Add some gui stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// This is a copy of the inventory that the client's environment has
|
||||||
|
Inventory local_inventory(PLAYER_INVENTORY_SIZE);
|
||||||
|
|
||||||
|
GUIQuickInventory *quick_inventory = new GUIQuickInventory
|
||||||
|
(guienv, NULL, v2s32(10, 70), 5, &local_inventory);
|
||||||
|
|
||||||
|
/*
|
||||||
|
We need some kind of a root node to be able to add
|
||||||
|
custom elements directly on the screen.
|
||||||
|
Otherwise they won't be automatically drawn.
|
||||||
|
*/
|
||||||
|
gui::IGUIStaticText *root = guienv->addStaticText(L"",
|
||||||
|
core::rect<s32>(0, 0, 10000, 10000));
|
||||||
|
|
||||||
|
// Pause menu
|
||||||
|
pauseMenu = new GUIPauseMenu(guienv, root, -1, device);
|
||||||
|
|
||||||
|
// Inventory menu
|
||||||
|
inventoryMenu = new GUIInventoryMenu(guienv, root, -1, &local_inventory);
|
||||||
|
|
||||||
|
pauseMenu->launch();
|
||||||
|
//inventoryMenu->launch();
|
||||||
|
|
||||||
// First line of debug text
|
// First line of debug text
|
||||||
gui::IGUIStaticText *guitext = guienv->addStaticText(
|
gui::IGUIStaticText *guitext = guienv->addStaticText(
|
||||||
L"Minetest-c55",
|
L"Minetest-c55",
|
||||||
@ -1481,12 +1515,6 @@ int main(int argc, char *argv[])
|
|||||||
core::rect<s32>(100, 70, 100+400, 70+(textsize.Y+5)),
|
core::rect<s32>(100, 70, 100+400, 70+(textsize.Y+5)),
|
||||||
false, false);
|
false, false);
|
||||||
|
|
||||||
// This is a copy of the inventory that the client's environment has
|
|
||||||
Inventory local_inventory(PLAYER_INVENTORY_SIZE);
|
|
||||||
|
|
||||||
GUIQuickInventory *quick_inventory = new GUIQuickInventory
|
|
||||||
(guienv, NULL, v2s32(10, 70), 5, &local_inventory);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Some statistics are collected in these
|
Some statistics are collected in these
|
||||||
*/
|
*/
|
||||||
@ -1529,11 +1557,6 @@ int main(int argc, char *argv[])
|
|||||||
//gui::IGUIWindow* input_window = NULL;
|
//gui::IGUIWindow* input_window = NULL;
|
||||||
gui::IGUIStaticText* input_guitext = NULL;
|
gui::IGUIStaticText* input_guitext = NULL;
|
||||||
|
|
||||||
/*
|
|
||||||
Digging animation
|
|
||||||
*/
|
|
||||||
//f32
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Main loop
|
Main loop
|
||||||
*/
|
*/
|
||||||
@ -1558,6 +1581,9 @@ int main(int argc, char *argv[])
|
|||||||
v2u32 screensize = driver->getScreenSize();
|
v2u32 screensize = driver->getScreenSize();
|
||||||
core::vector2d<s32> displaycenter(screensize.X/2,screensize.Y/2);
|
core::vector2d<s32> displaycenter(screensize.X/2,screensize.Y/2);
|
||||||
|
|
||||||
|
pauseMenu->resizeGui();
|
||||||
|
inventoryMenu->resizeGui();
|
||||||
|
|
||||||
// Hilight boxes collected during the loop and displayed
|
// Hilight boxes collected during the loop and displayed
|
||||||
core::list< core::aabbox3d<f32> > hilightboxes;
|
core::list< core::aabbox3d<f32> > hilightboxes;
|
||||||
|
|
||||||
@ -1714,6 +1740,11 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}*/
|
}*/
|
||||||
|
/*if(g_i_pressed)
|
||||||
|
{
|
||||||
|
inventoryMenu->setVisible(true);
|
||||||
|
g_i_pressed = false;
|
||||||
|
}*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Player speed control
|
Player speed control
|
||||||
@ -1773,7 +1804,11 @@ int main(int argc, char *argv[])
|
|||||||
Mouse and camera control
|
Mouse and camera control
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if((device->isWindowActive() && g_game_focused && !pauseMenu.isVisible())
|
if((device->isWindowActive()
|
||||||
|
&& g_game_focused
|
||||||
|
&& !pauseMenu->isVisible()
|
||||||
|
&& !inventoryMenu->isVisible()
|
||||||
|
)
|
||||||
|| random_input)
|
|| random_input)
|
||||||
{
|
{
|
||||||
if(!random_input)
|
if(!random_input)
|
||||||
@ -2250,6 +2285,7 @@ int main(int argc, char *argv[])
|
|||||||
client.getLocalInventory(local_inventory);
|
client.getLocalInventory(local_inventory);
|
||||||
quick_inventory->setSelection(g_selected_item);
|
quick_inventory->setSelection(g_selected_item);
|
||||||
quick_inventory->update();
|
quick_inventory->update();
|
||||||
|
inventoryMenu->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(input_guitext != NULL)
|
if(input_guitext != NULL)
|
||||||
|
@ -24,14 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "filesys.h"
|
#include "filesys.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "voxel.h"
|
#include "voxel.h"
|
||||||
|
#include "porting.h"
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#define sleep_ms(x) Sleep(x)
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#define sleep_ms(x) usleep(x*1000)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MapBlockPointerCache::MapBlockPointerCache(Map *map)
|
MapBlockPointerCache::MapBlockPointerCache(Map *map)
|
||||||
{
|
{
|
||||||
|
@ -282,6 +282,7 @@ void RatObject::addToScene(scene::ISceneManager *smgr)
|
|||||||
buf->getMaterial().setTexture
|
buf->getMaterial().setTexture
|
||||||
(0, driver->getTexture("../data/rat.png"));
|
(0, driver->getTexture("../data/rat.png"));
|
||||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
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;
|
||||||
// Add to mesh
|
// Add to mesh
|
||||||
mesh->addMeshBuffer(buf);
|
mesh->addMeshBuffer(buf);
|
||||||
@ -292,6 +293,73 @@ void RatObject::addToScene(scene::ISceneManager *smgr)
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
MapBlockObjectList
|
||||||
*/
|
*/
|
||||||
|
@ -28,8 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#define MAPBLOCKOBJECT_TYPE_TEST 0
|
#define MAPBLOCKOBJECT_TYPE_PLAYER 0
|
||||||
#define MAPBLOCKOBJECT_TYPE_TEST2 1
|
|
||||||
#define MAPBLOCKOBJECT_TYPE_SIGN 2
|
#define MAPBLOCKOBJECT_TYPE_SIGN 2
|
||||||
#define MAPBLOCKOBJECT_TYPE_RAT 3
|
#define MAPBLOCKOBJECT_TYPE_RAT 3
|
||||||
// Used for handling selecting special stuff
|
// Used for handling selecting special stuff
|
||||||
@ -432,6 +431,7 @@ public:
|
|||||||
buf->getMaterial().setTexture
|
buf->getMaterial().setTexture
|
||||||
(0, driver->getTexture("../data/sign.png"));
|
(0, driver->getTexture("../data/sign.png"));
|
||||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
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;
|
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||||
// Add to mesh
|
// Add to mesh
|
||||||
mesh->addMeshBuffer(buf);
|
mesh->addMeshBuffer(buf);
|
||||||
@ -455,6 +455,7 @@ public:
|
|||||||
buf->getMaterial().setTexture
|
buf->getMaterial().setTexture
|
||||||
(0, driver->getTexture("../data/sign_back.png"));
|
(0, driver->getTexture("../data/sign_back.png"));
|
||||||
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
|
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;
|
buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||||
// Add to mesh
|
// Add to mesh
|
||||||
mesh->addMeshBuffer(buf);
|
mesh->addMeshBuffer(buf);
|
||||||
@ -710,10 +711,129 @@ protected:
|
|||||||
|
|
||||||
float m_counter1;
|
float m_counter1;
|
||||||
float m_counter2;
|
float m_counter2;
|
||||||
v3f m_oldpos;
|
|
||||||
float m_age;
|
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
|
struct DistanceSortedObject
|
||||||
{
|
{
|
||||||
DistanceSortedObject(MapBlockObject *a_obj, f32 a_d)
|
DistanceSortedObject(MapBlockObject *a_obj, f32 a_d)
|
||||||
|
289
src/player.cpp
289
src/player.cpp
@ -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 position = getPosition();
|
||||||
v3f oldpos = position;
|
v3f oldpos = position;
|
||||||
@ -202,141 +354,6 @@ void Player::move(f32 dtime, Map &map)
|
|||||||
setPosition(position);
|
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)
|
void LocalPlayer::applyControl(float dtime)
|
||||||
{
|
{
|
||||||
// Random constants
|
// Random constants
|
||||||
|
55
src/player.h
55
src/player.h
@ -37,7 +37,8 @@ public:
|
|||||||
Player();
|
Player();
|
||||||
virtual ~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()
|
v3f getSpeed()
|
||||||
{
|
{
|
||||||
@ -94,6 +95,8 @@ public:
|
|||||||
|
|
||||||
virtual bool isLocal() const = 0;
|
virtual bool isLocal() const = 0;
|
||||||
|
|
||||||
|
virtual void updateLight(u8 light_at_pos) {};
|
||||||
|
|
||||||
bool touching_ground;
|
bool touching_ground;
|
||||||
bool in_water;
|
bool in_water;
|
||||||
|
|
||||||
@ -124,6 +127,10 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void move(f32 dtime, Map &map)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -163,8 +170,18 @@ public:
|
|||||||
|
|
||||||
void setPosition(v3f position)
|
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);
|
Player::setPosition(position);
|
||||||
ISceneNode::setPosition(position);
|
//ISceneNode::setPosition(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setYaw(f32 yaw)
|
virtual void setYaw(f32 yaw)
|
||||||
@ -180,9 +197,41 @@ public:
|
|||||||
|
|
||||||
void updateName(const char *name);
|
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:
|
private:
|
||||||
|
scene::IMeshSceneNode *m_node;
|
||||||
scene::ITextSceneNode* m_text;
|
scene::ITextSceneNode* m_text;
|
||||||
core::aabbox3d<f32> m_box;
|
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
|
#endif
|
||||||
@ -242,6 +291,8 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void move(f32 dtime, Map &map);
|
||||||
|
|
||||||
void applyControl(float dtime);
|
void applyControl(float dtime);
|
||||||
|
|
||||||
PlayerControl control;
|
PlayerControl control;
|
||||||
|
@ -29,14 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "common_irrlicht.h"
|
#include "common_irrlicht.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
#include "porting.h"
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#define sleep_ms(x) Sleep(x)
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#define sleep_ms(x) usleep(x*1000)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct QueuedBlockEmerge
|
struct QueuedBlockEmerge
|
||||||
{
|
{
|
||||||
|
@ -271,8 +271,6 @@ int main(int argc, char *argv[])
|
|||||||
<<"| Y Y \\ | | \\ ___/| | \\ ___/ \\___ \\ | | "<<std::endl
|
<<"| Y Y \\ | | \\ ___/| | \\ ___/ \\___ \\ | | "<<std::endl
|
||||||
<<"|__|_| /__|___| /\\___ >__| \\___ >____ > |__| "<<std::endl
|
<<"|__|_| /__|___| /\\___ >__| \\___ >____ > |__| "<<std::endl
|
||||||
<<" \\/ \\/ \\/ \\/ \\/ "<<std::endl
|
<<" \\/ \\/ \\/ \\/ \\/ "<<std::endl
|
||||||
<<std::endl
|
|
||||||
<<"Now with more waterish water!"
|
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
|
|
||||||
std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
|
@ -30,14 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "serialization.h"
|
#include "serialization.h"
|
||||||
#include "voxel.h"
|
#include "voxel.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include "porting.h"
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#define sleep_ms(x) Sleep(x)
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#define sleep_ms(x) usleep(x*1000)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Asserts that the exception occurs
|
Asserts that the exception occurs
|
||||||
|
@ -804,8 +804,10 @@ bool VoxelManipulator::flowWater(v3s16 removed_pos,
|
|||||||
if(stoptime != 0)
|
if(stoptime != 0)
|
||||||
{
|
{
|
||||||
u32 timenow = getTimeMs();
|
u32 timenow = getTimeMs();
|
||||||
if(timenow >= stoptime ||
|
// Well, it is a bit hard to guess because we don't know the
|
||||||
(stoptime < 0x80000000 && timenow > 0x80000000))
|
// start time...
|
||||||
|
bool overflow = timenow < stoptime - 100000;
|
||||||
|
if(timenow >= stoptime || overflow)
|
||||||
{
|
{
|
||||||
dstream<<"flowWater: stoptime reached"<<std::endl;
|
dstream<<"flowWater: stoptime reached"<<std::endl;
|
||||||
throw ProcessingLimitException("flowWater stoptime reached");
|
throw ProcessingLimitException("flowWater stoptime reached");
|
||||||
|
Loading…
Reference in New Issue
Block a user