NOTE: iostream.imbue(std::locale("C")) is very slow\r
NOTE: Global locale is now set at initialization\r
\r
+Random suggeestions:\r
+--------------------\r
+\r
SUGG: Fix address to be ipv6 compatible\r
\r
NOTE: When a new sector is generated, it may change the ground level\r
\r
SUGG: MovingObject::move and Player::move are basically the same.\r
combine them.\r
-\r
-SUGG: Implement a "Fast check queue" (a queue with a map for checking\r
- if something is already in it)\r
- - Use it in active block queue in water flowing\r
+ - NOTE: Player::move is more up-to-date.\r
\r
SUGG: Precalculate lighting translation table at runtime (at startup)\r
- This is not doable because it is currently hand-made and not\r
based on some mathematical function.\r
+ - Note: This has been changing lately\r
\r
SUGG: A version number to blocks, which increments when the block is\r
modified (node add/remove, water update, lighting update)\r
\r
SUGG: Meshes of blocks could be split into 6 meshes facing into\r
different directions and then only those drawn that need to be\r
- - Also an 1-dimensional tile map would be nice probably\r
+\r
+SUGG: Calculate lighting per vertex to get a lighting effect like in\r
+ bartwe's game\r
\r
Gaming ideas:\r
-------------\r
\r
-- How would some GTA-style ideas work?\r
- - Cars? Stealing? Unlawful stuff and cops? Lots of guns?\r
+- Aim for something like controlling a single dwarf in Dwarf Fortress\r
\r
-- RPG style?\r
+- The player could go faster by a crafting a boat, or riding an animal\r
\r
-- Space racer style?\r
+- Random NPC traders. what else?\r
\r
Documentation:\r
--------------\r
Build system / running:\r
-----------------------\r
\r
-NOTE: The following fixme is not apparently valid, and it does work.\r
-FIXME: Graphical mode seems to segfault with Irrlicht 1.7.1 on 64-bit\r
- systems. (Ubuntu)\r
- - http://pastebin.no/32bo\r
- - Might be just a bad build, too\r
- - Doesn't affect Irrlicht 1.7.2 or 32-bit 1.7.1. (Arch/Debian)\r
- - A similar error occurs when getTexture is called from a thread\r
- when the texture has not been already loaded from disk:\r
- http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=68830\r
-\r
-FIXME: Some network errors on Windows that cause local game to not work\r
- - See siggjen's emails.\r
-\r
Networking and serialization:\r
-----------------------------\r
\r
meshbuffers? It should go quite fast.\r
- This is not easy; There'd need to be a buffer somewhere\r
that would contain the night and day lighting values.\r
+ - Actually if FastFaces would be stored, they could\r
+ hold both values\r
\r
-TODO: Combine MapBlock's face caches to so big pieces that VBO\r
+FEATURE: Combine MapBlock's face caches to so big pieces that VBO\r
gets used\r
- That is >500 vertices\r
- This is not easy; all the MapBlocks close to the player would\r
\r
TODO: Flowing water animation\r
\r
+* Combine meshes to bigger ones in ClientMap and set them EHM_STATIC\r
+\r
+SUGG: Draw cubes in inventory directly with 3D drawing commands, so that\r
+ animating them is easier.\r
+\r
Configuration:\r
--------------\r
\r
-TODO: Make the video backend selectable\r
-\r
Client:\r
-------\r
\r
TODO: Untie client network operations from framerate\r
- Needs some input queues or something\r
- - Not really necessary?\r
\r
-TODO: Make morning and evening shorter\r
+SUGG: Make morning and evening transition more smooth and maybe shorter\r
+\r
+SUGG: Don't update all meshes always on single node changes, but\r
+ check which ones should be updated\r
+ - implement Map::updateNodeMeshes()\r
+\r
+TODO: Remove IrrlichtWrapper\r
\r
Server:\r
-------\r
\r
TODO: When player dies, throw items on map\r
\r
-TODO: Make an option to the server to disable building and digging near\r
+SUGG: Make an option to the server to disable building and digging near\r
the starting position\r
\r
-TODO: Save players with inventories to disk\r
-TODO: Players to be saved as text in map/players/<name>\r
-\r
TODO: Copy the text of the last picked sign to inventory in creative\r
mode\r
\r
TODO: Check what goes wrong with caching map to disk (Kray)\r
- Nothing?\r
\r
-TODO: When server sees that client is removing an inexistent block or\r
- adding a block to an existent position, resend the MapBlock.\r
+FIXME: Server sometimes goes into some infinite PeerNotFoundException loop\r
+\r
+* Fix the problem with the server constantly saving one or a few\r
+ blocks? List the first saved block, maybe it explains.\r
+ - It is probably caused by oscillating water\r
+* Make a small history check to transformLiquids to detect and log\r
+ continuous oscillations, in such detail that they can be fixed.\r
\r
Objects:\r
--------\r
\r
-TODO: Better handling of objects and mobs\r
- - Scripting?\r
- - There has to be some way to do it with less messy 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
- - This is also needed for objects that don't get sent to client\r
- but are used for triggers etc\r
-\r
TODO: There has to be some better way to handle static objects than to\r
send them all the time. This affects signs and item objects.\r
SUGG: Signs could be done in the same way as torches. For this, blocks\r
- TODO: For incoming blocks, time difference is calculated and\r
objects are stepped according to it.\r
\r
-Map:\r
-----\r
-\r
-NOTE: There are some lighting-related todos and fixmes in\r
- ServerMap::emergeBlock. And there always will be. 8)\r
-\r
-TODO: Map generator version 2\r
- - Create surface areas based on central points; a given point's\r
- area type is given by the nearest central point\r
- - Separate points for heightmap, caves, plants and minerals?\r
- - Flat land, mountains, forest, jungle\r
- - Cliffs, arcs\r
- - There could be a certain height (to which mountains only reach)\r
- where some minerals are found\r
- - Create a system that allows a huge amount of different "map\r
- generator modules/filters"\r
+- When an active object goes far from a player, either delete\r
+ it or store it statically.\r
+- When a statically stored active object comes near a player,\r
+ recreate the active object\r
\r
-TODO: Change AttributeList to split the area into smaller sections so\r
- that searching won't be as heavy.\r
-TODO: Change AttributeList to be 2D, as it would be too slow to search\r
- in 3D fields anyway.\r
+* Continue making the scripting system:\r
+ * Make updateNodeMesh for a less verbose mesh update on add/removenode\r
+ * Switch to using a safe way for the self and env pointers\r
+ * Make some global environment hooks, like node placed and general\r
+ on_step()\r
+* Add a global Lua spawn handler and such\r
+* Get rid of MapBlockObjects\r
+* Other players could be sent to clients as LuaCAOs\r
\r
-FIXME: The new pre-sunlight-propagation code messes up with initial\r
- water lighting. Does it any more?\r
+Map:\r
+----\r
\r
-TODO: Remove HMParams\r
+TODO: Mineral and ground material properties\r
+ - This way mineral ground toughness can be calculated with just\r
+ some formula, as well as tool strengths\r
\r
TODO: Flowing water to actually contain flow direction information\r
\r
-TODO: Faster lighting using VoxelManipulator\r
-\r
-Doing now:\r
-----------\r
+FEATURE: Create a system that allows a huge amount of different "map\r
+ generator modules/filters"\r
+\r
+FEATURE: Erosion simulation at map generation time\r
+ - Simulate water flows, which would carve out dirt fast and\r
+ then turn stone into gravel and sand and relocate it.\r
+ - How about relocating minerals, too? Coal and gold in\r
+ downstream sand and gravel would be kind of cool\r
+ - This would need a better way of handling minerals, mainly\r
+ to have mineral content as a separate field. the first\r
+ parameter field is free for this.\r
+ - Simulate rock falling from cliffs when water has removed\r
+ enough solid rock from the bottom\r
+\r
+Mapgen v2 (not doing):\r
+* only_from_disk might not work anymore - check and fix it.\r
+* Make the generator to run in background and not blocking block\r
+ placement and transfer\r
+* Add some kind of erosion and other stuff that now is possible\r
+* Make client to fetch stuff asynchronously\r
+ - Needs method SyncProcessData\r
+* Better water generation (spread it to underwater caverns but don't\r
+ fill dungeons that don't touch big water masses)\r
+* When generating a chunk and the neighboring chunk doesn't have mud\r
+ and stuff yet and the ground is fairly flat, the mud will flow to\r
+ the other chunk making nasty straight walls when the other chunk\r
+ is generated. Fix it.\r
+\r
+Mapgen v4 (not doing):\r
+* only_from_disk might not work anymore - check and fix it.\r
+* Make the generator to run in background and not blocking block\r
+ placement and transfer\r
+* Make chunks to be tiled vertically too\r
+* MAKE IT FASTER\r
+\r
+Mapgen v3 (not doing):\r
+* Generate trees better\r
+ - Add a "trees_added" flag to sector, or something\r
+* How 'bout making turbulence controlled so that for a given 2d position\r
+ it can be completely turned off, and is usually so. This way generation\r
+ can be sped up a lot.\r
+* Add a way to generate a block partly, so that trees are not added, like\r
+ the chunks in v2\r
+* Add mud "discretely", not by guessing from the noise\r
+\r
+Mapgen v4:\r
+* This will be the final way.\r
+* Generate blocks in the same way as chunks, by copying a VoxelManipulator\r
+ from the map that is one block larger in all directions.\r
+\r
+Misc. stuff:\r
+------------\r
+* Make an "environment metafile" to store at least time of day\r
+* Move digging property stuff from material.{h,cpp} to mapnode.cpp...\r
+ - Or maybe move content_features to material.{h,cpp}?\r
+* Maybe:\r
+ Make a system for pregenerating quick information for mapblocks, so\r
+ that the client can show them as cubes before they are actually sent\r
+ or even generated.\r
+* Optimize VoxelManipulator lighting implementation by using indices\r
+ in place of coordinates?\r
+\r
+Making it more portable:\r
+------------------------\r
+* Some MSVC: std::sto* are defined without a namespace and collide\r
+ with the ones in utility.h\r
\r
======================================================================\r
\r
#endif\r
\r
#ifdef _MSC_VER\r
-#pragma comment(lib, "Irrlicht.lib")\r
-//#pragma comment(lib, "jthread.lib")\r
-#pragma comment(lib, "zlibwapi.lib")\r
-// This would get rid of the console window\r
-//#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")\r
+ #pragma comment(lib, "Irrlicht.lib")\r
+ //#pragma comment(lib, "jthread.lib")\r
+ #pragma comment(lib, "zlibwapi.lib")\r
+ #pragma comment(lib, "Shell32.lib")\r
+ // This would get rid of the console window\r
+ //#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")\r
#endif\r
\r
#include <iostream>\r
#include <fstream>\r
#include <jmutexautolock.h>\r
#include <locale.h>\r
+#include "main.h"\r
#include "common_irrlicht.h"\r
#include "debug.h"\r
#include "map.h"\r
#include "player.h"\r
-#include "main.h"\r
#include "test.h"\r
-#include "environment.h"\r
+//#include "environment.h"\r
#include "server.h"\r
#include "client.h"\r
-#include "serialization.h"\r
+//#include "serialization.h"\r
#include "constants.h"\r
-#include "strfnd.h"\r
+//#include "strfnd.h"\r
#include "porting.h"\r
#include "irrlichtwrapper.h"\r
#include "gettime.h"\r
#include "filesys.h"\r
#include "config.h"\r
#include "guiMainMenu.h"\r
+#include "mineral.h"\r
+#include "noise.h"\r
+#include "tile.h"\r
\r
-IrrlichtWrapper *g_irrlicht;\r
+// TODO: Remove this\r
+IrrlichtWrapper *g_irrlicht = NULL;\r
+\r
+// This makes textures\r
+ITextureSource *g_texturesource = NULL;\r
\r
MapDrawControl draw_control;\r
\r
IrrlichtDevice *g_device = NULL;\r
Client *g_client = NULL;\r
\r
+/*const s16 quickinv_size = 40;\r
+const s16 quickinv_padding = 8;\r
+const s16 quickinv_spacing = quickinv_size + quickinv_padding;\r
+const s16 quickinv_outer_padding = 4;\r
+const s16 quickinv_itemcount = 8;*/\r
+\r
+const s32 hotbar_itemcount = 8;\r
+const s32 hotbar_imagesize = 36;\r
+\r
/*\r
GUI Stuff\r
*/\r
\r
u16 g_selected_item = 0;\r
\r
+bool g_show_map_plot = false;\r
+bool g_refresh_map_plot = false;\r
+\r
/*\r
Debug streams\r
*/\r
}\r
void gotText(std::wstring text)\r
{\r
+ // Discard empty line\r
+ if(text == L"")\r
+ return;\r
+ \r
+ // Parse command (server command starts with "/#")\r
+ if(text[0] == L'/' && text[1] != L'#')\r
+ {\r
+ std::wstring reply = L"Local: ";\r
+\r
+ reply += L"Local commands not yet supported. "\r
+ L"Server prefix is \"/#\".";\r
+ \r
+ m_client->addChatMessage(reply);\r
+ return;\r
+ }\r
+\r
+ // Send to others\r
m_client->sendChatMessage(text);\r
+ // Show locally\r
m_client->addChatMessage(text);\r
}\r
\r
if(event.KeyInput.PressedDown)\r
{\r
//dstream<<"Pressed key: "<<(char)event.KeyInput.Key<<std::endl;\r
+ if(g_show_map_plot)\r
+ {\r
+ if(event.KeyInput.Key == irr::KEY_ESCAPE\r
+ || event.KeyInput.Key == irr::KEY_KEY_M)\r
+ {\r
+ g_show_map_plot = false;\r
+ }\r
+ return true;\r
+ }\r
\r
/*\r
Launch menus\r
}\r
}\r
\r
- // Material selection\r
- if(event.KeyInput.Key == irr::KEY_KEY_F)\r
+ // Item selection\r
+ if(event.KeyInput.Key >= irr::KEY_KEY_0\r
+ && event.KeyInput.Key <= irr::KEY_KEY_9)\r
{\r
- if(g_selected_item < PLAYER_INVENTORY_SIZE-1)\r
- g_selected_item++;\r
- else\r
- g_selected_item = 0;\r
+ u16 s1 = event.KeyInput.Key - irr::KEY_KEY_0;\r
+ if(event.KeyInput.Key == irr::KEY_KEY_0)\r
+ s1 = 10;\r
+ if(s1 < PLAYER_INVENTORY_SIZE && s1 < hotbar_itemcount)\r
+ g_selected_item = s1-1;\r
dstream<<DTIME<<"Selected item: "\r
<<g_selected_item<<std::endl;\r
}\r
<<std::endl;\r
debug_stacks_print();\r
}\r
+\r
+ // Map plot\r
+ if(event.KeyInput.Key == irr::KEY_KEY_M)\r
+ {\r
+ dstream<<"Map plot requested"<<std::endl;\r
+ g_show_map_plot = !g_show_map_plot;\r
+ if(g_show_map_plot)\r
+ g_refresh_map_plot = true;\r
+ }\r
+ \r
}\r
}\r
\r
{\r
/*dstream<<"event.MouseInput.Wheel="\r
<<event.MouseInput.Wheel<<std::endl;*/\r
+ \r
+ u16 max_item = MYMIN(PLAYER_INVENTORY_SIZE-1,\r
+ hotbar_itemcount-1);\r
if(event.MouseInput.Wheel < 0)\r
{\r
- if(g_selected_item < PLAYER_INVENTORY_SIZE-1)\r
+ if(g_selected_item < max_item)\r
g_selected_item++;\r
else\r
g_selected_item = 0;\r
if(g_selected_item > 0)\r
g_selected_item--;\r
else\r
- g_selected_item = PLAYER_INVENTORY_SIZE-1;\r
+ g_selected_item = max_item;\r
}\r
}\r
}\r
public:\r
RandomInputHandler()\r
{\r
+ leftdown = false;\r
+ rightdown = false;\r
leftclicked = false;\r
rightclicked = false;\r
+ leftreleased = false;\r
+ rightreleased = false;\r
for(u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)\r
keydown[i] = false;\r
}\r
\r
virtual bool getLeftState()\r
{\r
- return false;\r
+ return leftdown;\r
}\r
virtual bool getRightState()\r
{\r
- return false;\r
+ return rightdown;\r
}\r
\r
virtual bool getLeftClicked()\r
\r
virtual bool getLeftReleased()\r
{\r
- return false;\r
+ return leftreleased;\r
}\r
virtual bool getRightReleased()\r
{\r
- return false;\r
+ return rightreleased;\r
}\r
virtual void resetLeftReleased()\r
{\r
+ leftreleased = false;\r
}\r
virtual void resetRightReleased()\r
{\r
+ rightreleased = false;\r
}\r
\r
virtual void step(float dtime)\r
{\r
- {\r
- static float counter1 = 0;\r
- counter1 -= dtime;\r
- if(counter1 < 0.0)\r
- {\r
- counter1 = 0.1*Rand(1,10);\r
- /*if(g_selected_material < USEFUL_CONTENT_COUNT-1)\r
- g_selected_material++;\r
- else\r
- g_selected_material = 0;*/\r
- if(g_selected_item < PLAYER_INVENTORY_SIZE-1)\r
- g_selected_item++;\r
- else\r
- g_selected_item = 0;\r
- }\r
- }\r
{\r
static float counter1 = 0;\r
counter1 -= dtime;\r
if(counter1 < 0.0)\r
{\r
counter1 = 0.1*Rand(1, 40);\r
- keydown[irr::KEY_KEY_2] = !keydown[irr::KEY_KEY_2];\r
+ keydown[irr::KEY_KEY_E] = !keydown[irr::KEY_KEY_E];\r
}\r
}\r
{\r
if(counter1 < 0.0)\r
{\r
counter1 = 0.1*Rand(1, 30);\r
- leftclicked = true;\r
+ leftdown = !leftdown;\r
+ if(leftdown)\r
+ leftclicked = true;\r
+ if(!leftdown)\r
+ leftreleased = true;\r
}\r
}\r
{\r
counter1 -= dtime;\r
if(counter1 < 0.0)\r
{\r
- counter1 = 0.1*Rand(1, 20);\r
- rightclicked = true;\r
+ counter1 = 0.1*Rand(1, 15);\r
+ rightdown = !rightdown;\r
+ if(rightdown)\r
+ rightclicked = true;\r
+ if(!rightdown)\r
+ rightreleased = true;\r
}\r
}\r
mousepos += mousespeed;\r
bool keydown[KEY_KEY_CODES_COUNT];\r
v2s32 mousepos;\r
v2s32 mousespeed;\r
+ bool leftdown;\r
+ bool rightdown;\r
bool leftclicked;\r
bool rightclicked;\r
+ bool leftreleased;\r
+ bool rightreleased;\r
};\r
\r
void updateViewingRange(f32 frametime_in, Client *client)\r
f32 wanted_frametime_change = wanted_frametime - frametime;\r
//dstream<<"wanted_frametime_change="<<wanted_frametime_change<<std::endl;\r
\r
- // If needed frametime change is very small, just return\r
- if(fabs(wanted_frametime_change) < wanted_frametime*0.2)\r
+ // If needed frametime change is small, just return\r
+ if(fabs(wanted_frametime_change) < wanted_frametime*0.4)\r
{\r
//dstream<<"ignoring small wanted_frametime_change"<<std::endl;\r
return;\r
frametime_old = frametime;\r
}\r
\r
-class GUIQuickInventory : public IEventReceiver\r
+void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font,\r
+ v2s32 centerlowerpos, s32 imgsize, s32 itemcount,\r
+ Inventory *inventory)\r
{\r
-public:\r
- GUIQuickInventory(\r
- gui::IGUIEnvironment* env,\r
- gui::IGUIElement* parent,\r
- v2s32 pos,\r
- s32 itemcount,\r
- Inventory *inventory):\r
- m_itemcount(itemcount),\r
- m_inventory(inventory)\r
+ InventoryList *mainlist = inventory->getList("main");\r
+ if(mainlist == NULL)\r
{\r
- core::rect<s32> imgsize(0,0,48,48);\r
- core::rect<s32> textsize(0,0,48,16);\r
- v2s32 spacing(0, 64);\r
- for(s32 i=0; i<m_itemcount; i++)\r
- {\r
- m_images.push_back(env->addImage(\r
- imgsize + pos + spacing*i\r
- ));\r
- m_images[i]->setScaleImage(true);\r
- m_texts.push_back(env->addStaticText(\r
- L"",\r
- textsize + pos + spacing*i,\r
- false, false\r
- ));\r
- m_texts[i]->setBackgroundColor(\r
- video::SColor(128,0,0,0));\r
- m_texts[i]->setTextAlignment(\r
- gui::EGUIA_CENTER,\r
- gui::EGUIA_UPPERLEFT);\r
- }\r
+ dstream<<"WARNING: draw_hotbar(): mainlist == NULL"<<std::endl;\r
+ return;\r
}\r
+ \r
+ s32 padding = imgsize/12;\r
+ //s32 height = imgsize + padding*2;\r
+ s32 width = itemcount*(imgsize+padding*2);\r
+ \r
+ // Position of upper left corner of bar\r
+ v2s32 pos = centerlowerpos - v2s32(width/2, imgsize+padding*2);\r
+ \r
+ // Draw background color\r
+ /*core::rect<s32> barrect(0,0,width,height);\r
+ barrect += pos;\r
+ video::SColor bgcolor(255,128,128,128);\r
+ driver->draw2DRectangle(bgcolor, barrect, NULL);*/\r
+\r
+ core::rect<s32> imgrect(0,0,imgsize,imgsize);\r
\r
- ~GUIQuickInventory()\r
+ for(s32 i=0; i<itemcount; i++)\r
{\r
- for(u32 i=0; i<m_texts.size(); i++)\r
+ InventoryItem *item = mainlist->getItem(i);\r
+ \r
+ core::rect<s32> rect = imgrect + pos\r
+ + v2s32(padding+i*(imgsize+padding*2), padding);\r
+ \r
+ if(g_selected_item == i)\r
{\r
- m_texts[i]->remove();\r
+ driver->draw2DRectangle(video::SColor(255,255,0,0),\r
+ core::rect<s32>(rect.UpperLeftCorner - v2s32(1,1)*padding,\r
+ rect.LowerRightCorner + v2s32(1,1)*padding),\r
+ NULL);\r
}\r
- for(u32 i=0; i<m_images.size(); i++)\r
+ else\r
{\r
- m_images[i]->remove();\r
+ video::SColor bgcolor2(128,0,0,0);\r
+ driver->draw2DRectangle(bgcolor2, rect, NULL);\r
}\r
- }\r
-\r
- virtual bool OnEvent(const SEvent& event)\r
- {\r
- return false;\r
- }\r
-\r
- void setSelection(s32 i)\r
- {\r
- m_selection = i;\r
- }\r
-\r
- void update()\r
- {\r
- s32 start = 0;\r
-\r
- start = m_selection - m_itemcount / 2;\r
-\r
- InventoryList *mainlist = m_inventory->getList("main");\r
\r
- for(s32 i=0; i<m_itemcount; i++)\r
+ if(item != NULL)\r
{\r
- s32 j = i + start;\r
-\r
- if(j > (s32)mainlist->getSize() - 1)\r
- j -= mainlist->getSize();\r
- if(j < 0)\r
- j += mainlist->getSize();\r
- \r
- InventoryItem *item = mainlist->getItem(j);\r
- // Null items\r
- if(item == NULL)\r
- {\r
- m_images[i]->setImage(NULL);\r
+ drawInventoryItem(driver, font, item, rect, NULL);\r
+ }\r
+ }\r
+}\r
\r
- wchar_t t[10];\r
- if(m_selection == j)\r
- swprintf(t, 10, L"<-");\r
- else\r
- swprintf(t, 10, L"");\r
- m_texts[i]->setText(t);\r
+video::ITexture *g_map_plot_texture = NULL;\r
+float g_map_plot_texture_scale = 4;\r
\r
- // The next ifs will segfault with a NULL pointer\r
- continue;\r
- }\r
- \r
- \r
- m_images[i]->setImage(item->getImage());\r
+void updateMapPlotTexture(v2f centerpos, video::IVideoDriver* driver,\r
+ Client *client)\r
+{\r
+ assert(driver);\r
+ assert(client);\r
+\r
+ core::dimension2d<u32> dim(640,480);\r
+ video::IImage *img = driver->createImage(video::ECF_A8R8G8B8, dim);\r
+ assert(img);\r
+ for(u32 y=0; y<dim.Height; y++)\r
+ for(u32 x=0; x<dim.Width; x++)\r
+ {\r
+ v2f pf = v2f(x, dim.Height-y) - v2f(dim.Width, dim.Height)/2;\r
+ pf *= g_map_plot_texture_scale;\r
+ pf += centerpos;\r
+ double h = base_rock_level_2d(client->getMapSeed(), pf);\r
+ video::SColor c;\r
+ //double d1 = 50;\r
+ /*s32 ux = x - centerpos.X / g_map_plot_texture_scale;\r
+ s32 uy = y - centerpos.Y / g_map_plot_texture_scale;*/\r
\r
- wchar_t t[10];\r
- if(m_selection == j)\r
- swprintf(t, 10, SWPRINTF_CHARSTRING L" <-", item->getText().c_str());\r
- else\r
- swprintf(t, 10, SWPRINTF_CHARSTRING, item->getText().c_str());\r
- m_texts[i]->setText(t);\r
+ // Screen coordinates that are based on multiples of\r
+ // 1000/g_map_plot_texture_scale and never negative\r
+ u32 ux = x + (u32)(1000/g_map_plot_texture_scale) * 10;\r
+ u32 uy = y + (u32)(1000/g_map_plot_texture_scale) * 10;\r
+ // Offset to center of image\r
+ ux -= dim.Width/2;\r
+ uy -= dim.Height/2;\r
+\r
+ if(uy % (u32)(1000/g_map_plot_texture_scale) == 0\r
+ || ux % (u32)(1000/g_map_plot_texture_scale) == 0)\r
+ c.set(255, 255, 255, 255);\r
+ else if(uy % (u32)(100/g_map_plot_texture_scale) == 0\r
+ || ux % (u32)(100/g_map_plot_texture_scale) == 0)\r
+ c.set(255, 160, 160, 160);\r
+ else if(h < WATER_LEVEL - 0.5) // Water\r
+ c.set(255, 50, 50, 255);\r
+#if 0\r
+ else if(get_have_sand_ground(client->getMapSeed(), pf)\r
+ || (h < WATER_LEVEL + 2\r
+ && get_have_sand_coast(client->getMapSeed(), pf)))\r
+ {\r
+ h -= WATER_LEVEL;\r
+ h /= 50.0;\r
+ h = 1.0 - exp(-h);\r
+\r
+ video::SColor c1(255,237,201,175);\r
+ //video::SColor c2(255,20,20,20);\r
+ video::SColor c2(255,150,0,0);\r
+ c = c2.getInterpolated(c1, h);\r
+ }\r
+ else\r
+ {\r
+ h -= WATER_LEVEL;\r
+ h /= 50.0;\r
+ h = 1.0 - exp(-h);\r
+\r
+ video::SColor c1(255,110,185,90);\r
+ //video::SColor c2(255,20,20,20);\r
+ video::SColor c2(255,150,0,0);\r
+ c = c2.getInterpolated(c1, h);\r
+ }\r
+#endif\r
+#if 1\r
+#if 0\r
+ else if(get_have_sand_ground(client->getMapSeed(), pf))\r
+ {\r
+ h -= WATER_LEVEL;\r
+ h /= 20.0;\r
+ h = 1.0 - exp(-h);\r
+\r
+ video::SColor c1(255,237,201,175);\r
+ //video::SColor c2(255,20,20,20);\r
+ video::SColor c2(255,150,0,0);\r
+ c = c2.getInterpolated(c1, h);\r
+ }\r
+#endif\r
+ // Sand\r
+ else if(h < WATER_LEVEL + 2\r
+ && get_have_sand_coast(client->getMapSeed(), pf))\r
+ c.set(255, 237, 201, 175);\r
+#if 1\r
+ else if(h < WATER_LEVEL + 10)\r
+ c.set(255, 50, 150, 50); // Green\r
+ else if(h < WATER_LEVEL + 20)\r
+ c.set(255, 110, 185, 50); // Yellowish green\r
+ else if(h < WATER_LEVEL + 40)\r
+ c.set(255, 180, 210, 50); // Greenish yellow\r
+ else if(h < WATER_LEVEL + 60)\r
+ c.set(255, 220, 220, 50); // Yellow\r
+ else if(h < WATER_LEVEL + 80)\r
+ c.set(255, 200, 200, 110); // Yellowish white\r
+ else if(h < WATER_LEVEL + 100)\r
+ c.set(255, 190, 190, 190); // Grey\r
+ else\r
+ c.set(255, 255, 255, 255); // White\r
+#endif\r
+#endif\r
+#if 0\r
+ else\r
+ {\r
+ h -= WATER_LEVEL;\r
+ h /= 20.0;\r
+ h = 1.0 - exp(-h);\r
+\r
+ video::SColor c1(255,200,200,50);\r
+ video::SColor c2(255,0,150,0);\r
+ c = c1.getInterpolated(c2, h);\r
+\r
+ /*u32 a = (u32)(h*255);\r
+ if(a > 255)\r
+ a = 255;\r
+ a = 255-a;\r
+ c.set(255, a, a, a);*/\r
+ }\r
+#endif\r
+#if 1\r
+ if(h >= WATER_LEVEL - 0.5\r
+ && get_have_sand_ground(client->getMapSeed(), pf))\r
+ {\r
+ video::SColor c1(255,237,201,175);\r
+ c = c.getInterpolated(c1, 0.5);\r
}\r
+#endif\r
+#if 1\r
+ double tf = get_turbulence_factor_2d(client->getMapSeed(), pf);\r
+ if(tf > 0.001)\r
+ {\r
+ video::SColor c1(255,255,0,0);\r
+ c = c.getInterpolated(c1, 1.0-(0.5*tf));\r
+ }\r
+#endif\r
+ img->setPixel(x, y, c);\r
}\r
-\r
-private:\r
- s32 m_itemcount;\r
- core::array<gui::IGUIStaticText*> m_texts;\r
- core::array<gui::IGUIImage*> m_images;\r
- Inventory *m_inventory;\r
- s32 m_selection;\r
-};\r
+ g_map_plot_texture = driver->addTexture("map_plot", img);\r
+ img->drop();\r
+ assert(g_map_plot_texture);\r
+}\r
\r
// Chat data\r
struct ChatLine\r
std::wstring text;\r
};\r
\r
-int main(int argc, char *argv[])\r
-{\r
- /*\r
- Low-level initialization\r
- */\r
+// These are defined global so that they're not optimized too much.\r
+// Can't change them to volatile.\r
+s16 temp16;\r
+f32 tempf;\r
+v3f tempv3f1;\r
+v3f tempv3f2;\r
+std::string tempstring;\r
+std::string tempstring2;\r
\r
- bool disable_stderr = false;\r
-#ifdef _WIN32\r
- disable_stderr = true;\r
-#endif\r
+void SpeedTests()\r
+{\r
+ {\r
+ dstream<<"The following test should take around 20ms."<<std::endl;\r
+ TimeTaker timer("Testing std::string speed");\r
+ const u32 jj = 10000;\r
+ for(u32 j=0; j<jj; j++)\r
+ {\r
+ tempstring = "";\r
+ tempstring2 = "";\r
+ const u32 ii = 10;\r
+ for(u32 i=0; i<ii; i++){\r
+ tempstring2 += "asd";\r
+ }\r
+ for(u32 i=0; i<ii+1; i++){\r
+ tempstring += "asd";\r
+ if(tempstring == tempstring2)\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ \r
+ dstream<<"All of the following tests should take around 100ms each."\r
+ <<std::endl;\r
\r
- // Initialize debug streams\r
- debugstreams_init(disable_stderr, DEBUGFILE);\r
- // Initialize debug stacks\r
- debug_stacks_init();\r
+ {\r
+ TimeTaker timer("Testing floating-point conversion speed");\r
+ tempf = 0.001;\r
+ for(u32 i=0; i<4000000; i++){\r
+ temp16 += tempf;\r
+ tempf += 0.001;\r
+ }\r
+ }\r
+ \r
+ {\r
+ TimeTaker timer("Testing floating-point vector speed");\r
\r
- DSTACK(__FUNCTION_NAME);\r
+ tempv3f1 = v3f(1,2,3);\r
+ tempv3f2 = v3f(4,5,6);\r
+ for(u32 i=0; i<10000000; i++){\r
+ tempf += tempv3f1.dotProduct(tempv3f2);\r
+ tempv3f2 += v3f(7,8,9);\r
+ }\r
+ }\r
\r
- porting::initializePaths();\r
- // Create user data directory\r
- fs::CreateDir(porting::path_userdata);\r
+ {\r
+ TimeTaker timer("Testing core::map speed");\r
+ \r
+ core::map<v2s16, f32> map1;\r
+ tempf = -324;\r
+ const s16 ii=300;\r
+ for(s16 y=0; y<ii; y++){\r
+ for(s16 x=0; x<ii; x++){\r
+ map1.insert(v2s16(x,y), tempf);\r
+ tempf += 1;\r
+ }\r
+ }\r
+ for(s16 y=ii-1; y>=0; y--){\r
+ for(s16 x=0; x<ii; x++){\r
+ tempf = map1[v2s16(x,y)];\r
+ }\r
+ }\r
+ }\r
\r
- initializeMaterialProperties();\r
+ {\r
+ dstream<<"Around 5000/ms should do well here."<<std::endl;\r
+ TimeTaker timer("Testing mutex speed");\r
+ \r
+ JMutex m;\r
+ m.Init();\r
+ u32 n = 0;\r
+ u32 i = 0;\r
+ do{\r
+ n += 10000;\r
+ for(; i<n; i++){\r
+ m.Lock();\r
+ m.Unlock();\r
+ }\r
+ }\r
+ // Do at least 10ms\r
+ while(timer.getTime() < 10);\r
\r
- BEGIN_DEBUG_EXCEPTION_HANDLER\r
+ u32 dtime = timer.stop();\r
+ u32 per_ms = n / dtime;\r
+ std::cout<<"Done. "<<dtime<<"ms, "\r
+ <<per_ms<<"/ms"<<std::endl;\r
+ }\r
+}\r
\r
- // Print startup message\r
- dstream<<DTIME<<"minetest-c55"\r
- " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST\r
- <<", "<<BUILD_INFO\r
- <<std::endl;\r
- \r
+int main(int argc, char *argv[])\r
+{\r
/*\r
Parse command line\r
*/\r
allowed_options.insert("disable-unittests", ValueSpec(VALUETYPE_FLAG));\r
allowed_options.insert("enable-unittests", ValueSpec(VALUETYPE_FLAG));\r
allowed_options.insert("map-dir", ValueSpec(VALUETYPE_STRING));\r
+#ifdef _WIN32\r
+ allowed_options.insert("dstream-on-stderr", ValueSpec(VALUETYPE_FLAG));\r
+#endif\r
+ allowed_options.insert("speedtests", ValueSpec(VALUETYPE_FLAG));\r
\r
Settings cmd_args;\r
\r
\r
return cmd_args.getFlag("help") ? 0 : 1;\r
}\r
+ \r
+ /*\r
+ Low-level initialization\r
+ */\r
+\r
+ bool disable_stderr = false;\r
+#ifdef _WIN32\r
+ if(cmd_args.getFlag("dstream-on-stderr") == false)\r
+ disable_stderr = true;\r
+#endif\r
+\r
+ // Initialize debug streams\r
+ debugstreams_init(disable_stderr, DEBUGFILE);\r
+ // Initialize debug stacks\r
+ debug_stacks_init();\r
+\r
+ DSTACK(__FUNCTION_NAME);\r
+\r
+ porting::signal_handler_init();\r
+ bool &kill = *porting::signal_handler_killstatus();\r
+ \r
+ porting::initializePaths();\r
+ // Create user data directory\r
+ fs::CreateDir(porting::path_userdata);\r
+ \r
+ // C-style stuff initialization\r
+ initializeMaterialProperties();\r
\r
+ // Debug handler\r
+ BEGIN_DEBUG_EXCEPTION_HANDLER\r
\r
+ // Print startup message\r
+ dstream<<DTIME<<"minetest-c55"\r
+ " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST\r
+ <<", "<<BUILD_INFO\r
+ <<std::endl;\r
+ \r
/*\r
Basic initialization\r
*/\r
break;\r
}\r
}\r
+ \r
+ // If no path found, use the first one (menu creates the file)\r
+ if(configpath == "")\r
+ configpath = filenames[0];\r
}\r
\r
// Initialize random seed\r
srand(time(0));\r
mysrand(time(0));\r
\r
+ /*\r
+ Pre-initialize some stuff with a dummy irrlicht wrapper.\r
+\r
+ These are needed for unit tests at least.\r
+ */\r
+ \r
+ // Initial call with g_texturesource not set.\r
+ init_mapnode();\r
+\r
/*\r
Run unit tests\r
*/\r
+\r
if((ENABLE_TESTS && cmd_args.getFlag("disable-unittests") == false)\r
|| cmd_args.getFlag("enable-unittests") == true)\r
{\r
run_tests();\r
}\r
\r
- // Read map parameters from settings\r
-\r
- HMParams hm_params;\r
- /*hm_params.blocksize = g_settings.getU16("heightmap_blocksize");\r
- hm_params.randmax = g_settings.get("height_randmax");\r
- hm_params.randfactor = g_settings.get("height_randfactor");\r
- hm_params.base = g_settings.get("height_base");*/\r
-\r
- MapParams map_params;\r
- map_params.plants_amount = g_settings.getFloat("plants_amount");\r
- map_params.ravines_amount = g_settings.getFloat("ravines_amount");\r
-\r
+ /*for(s16 y=-100; y<100; y++)\r
+ for(s16 x=-100; x<100; x++)\r
+ {\r
+ std::cout<<noise2d_gradient((double)x/10,(double)y/10, 32415)<<std::endl;\r
+ }\r
+ return 0;*/\r
+ \r
/*\r
Some parameters\r
*/\r
DSTACK("Dedicated server branch");\r
\r
// Create server\r
- Server server(map_dir.c_str(), hm_params, map_params);\r
+ Server server(map_dir.c_str());\r
server.start(port);\r
\r
// Run server\r
- dedicated_server_loop(server);\r
+ dedicated_server_loop(server, kill);\r
\r
return 0;\r
}\r
\r
std::string playername = g_settings.get("name");\r
\r
- /*\r
- Resolution selection\r
- */\r
+ // Resolution selection\r
\r
bool fullscreen = false;\r
u16 screenW = g_settings.getU16("screenW");\r
u16 screenH = g_settings.getU16("screenH");\r
\r
- //\r
-\r
- MyEventReceiver receiver;\r
+ // Determine driver\r
\r
video::E_DRIVER_TYPE driverType;\r
-\r
-#ifdef _WIN32\r
- //driverType = video::EDT_DIRECT3D9;\r
- driverType = video::EDT_OPENGL;\r
-#else\r
- driverType = video::EDT_OPENGL;\r
- //driverType = video::EDT_BURNINGSVIDEO;\r
-#endif\r
+ \r
+ std::string driverstring = g_settings.get("video_driver");\r
+\r
+ if(driverstring == "null")\r
+ driverType = video::EDT_NULL;\r
+ else if(driverstring == "software")\r
+ driverType = video::EDT_SOFTWARE;\r
+ else if(driverstring == "burningsvideo")\r
+ driverType = video::EDT_BURNINGSVIDEO;\r
+ else if(driverstring == "direct3d8")\r
+ driverType = video::EDT_DIRECT3D8;\r
+ else if(driverstring == "direct3d9")\r
+ driverType = video::EDT_DIRECT3D9;\r
+ else if(driverstring == "opengl")\r
+ driverType = video::EDT_OPENGL;\r
+ else\r
+ {\r
+ dstream<<"WARNING: Invalid video_driver specified; defaulting "\r
+ "to opengl"<<std::endl;\r
+ driverType = video::EDT_OPENGL;\r
+ }\r
\r
// create device and exit if creation failed\r
\r
+ MyEventReceiver receiver;\r
+\r
IrrlichtDevice *device;\r
device = createDevice(driverType,\r
core::dimension2d<u32>(screenW, screenH),\r
\r
g_device = device;\r
g_irrlicht = new IrrlichtWrapper(device);\r
+ TextureSource *texturesource = new TextureSource(device);\r
+ g_texturesource = texturesource;\r
\r
- //g_device = device;\r
+ /*\r
+ Speed tests (done after irrlicht is loaded to get timer)\r
+ */\r
+ if(cmd_args.getFlag("speedtests"))\r
+ {\r
+ dstream<<"Running speed tests"<<std::endl;\r
+ SpeedTests();\r
+ return 0;\r
+ }\r
\r
device->setResizable(true);\r
\r
video::IVideoDriver* driver = device->getVideoDriver();\r
\r
/*\r
- This changes the minimum allowed number of vertices in a VBO\r
+ This changes the minimum allowed number of vertices in a VBO.\r
+ Default is 500.\r
*/\r
//driver->setMinHardwareBufferVertexCount(50);\r
\r
scene::ISceneManager* smgr = device->getSceneManager();\r
- \r
+\r
guienv = device->getGUIEnvironment();\r
gui::IGUISkin* skin = guienv->getSkin();\r
gui::IGUIFont* font = guienv->getFont(porting::getDataPath("fontlucida.png").c_str());\r
skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255,0,0,0));\r
\r
/*\r
- Preload some textures\r
+ Preload some textures and stuff\r
*/\r
\r
init_content_inventory_texture_paths();\r
- init_tile_textures();\r
+ init_mapnode(); // Second call with g_texturesource set\r
+ init_mineral();\r
\r
/*\r
GUI stuff\r
// Object infos are shown in this\r
gui::IGUIStaticText *guitext_info = guienv->addStaticText(\r
L"",\r
- core::rect<s32>(100, 70, 100+400, 70+(text_height+5)),\r
+ core::rect<s32>(0,0,400,text_height+5) + v2s32(100,200),\r
false, false);\r
\r
// Chat text\r
gui::IGUIStaticText *guitext_chat = guienv->addStaticText(\r
L"",\r
core::rect<s32>(0,0,0,0),\r
- false, true);\r
- guitext_chat->setBackgroundColor(video::SColor(96,0,0,0));\r
+ false, false); // Disable word wrap as of now\r
+ //false, true);\r
+ //guitext_chat->setBackgroundColor(video::SColor(96,0,0,0));\r
core::list<ChatLine> chat_lines;\r
\r
/*\r
/*\r
Menu-game loop\r
*/\r
- while(g_device->run())\r
+ while(g_device->run() && kill == false)\r
{\r
\r
// This is used for catching disconnects\r
{\r
\r
/*\r
- Out-of-game menu loop\r
+ Out-of-game menu loop.\r
+\r
+ Loop quits when menu returns proper parameters.\r
*/\r
- \r
- // Wait for proper parameters\r
- for(;;)\r
+ while(kill == false)\r
{\r
// Cursor can be non-visible when coming from the game\r
device->getCursorControl()->setVisible(true);\r
\r
dstream<<"Created main menu"<<std::endl;\r
\r
- while(g_device->run())\r
+ while(g_device->run() && kill == false)\r
{\r
// Run global IrrlichtWrapper's main thread processing stuff\r
g_irrlicht->Run();\r
}\r
\r
// Break out of menu-game loop to shut down cleanly\r
- if(g_device->run() == false)\r
+ if(g_device->run() == false || kill == true)\r
break;\r
\r
dstream<<"Dropping main menu"<<std::endl;\r
\r
menu->drop();\r
+ \r
+ // Delete map if requested\r
+ if(menudata.delete_map)\r
+ {\r
+ bool r = fs::RecursiveDeleteContent(map_dir);\r
+ if(r == false)\r
+ error_message = L"Delete failed";\r
+ continue;\r
+ }\r
\r
playername = wide_to_narrow(menudata.name);\r
address = wide_to_narrow(menudata.address);\r
*/\r
{\r
\r
+ // This is set to true at the end of the scope\r
+ g_irrlicht->Shutdown(false);\r
+\r
/*\r
Draw "Loading" screen\r
*/\r
*/\r
SharedPtr<Server> server;\r
if(address == ""){\r
- server = new Server(map_dir, hm_params, map_params);\r
+ server = new Server(map_dir);\r
server->start(port);\r
}\r
\r
Address connect_address(0,0,0,0, port);\r
try{\r
if(address == "")\r
- connect_address.Resolve("localhost");\r
+ //connect_address.Resolve("localhost");\r
+ connect_address.setAddress(127,0,0,1);\r
else\r
connect_address.Resolve(address.c_str());\r
}\r
continue;\r
}\r
\r
- std::cout<<DTIME<<"Connecting to server..."<<std::endl;\r
+ dstream<<DTIME<<"Connecting to server at ";\r
+ connect_address.print(&dstream);\r
+ dstream<<std::endl;\r
client.connect(connect_address);\r
\r
try{\r
\r
if(camera == NULL)\r
return 1;\r
- \r
- video::SColor skycolor = video::SColor(255,90,140,200);\r
+\r
+ //video::SColor skycolor = video::SColor(255,90,140,200);\r
+ //video::SColor skycolor = video::SColor(255,166,202,244);\r
+ video::SColor skycolor = video::SColor(255,120,185,244);\r
\r
camera->setFOV(FOV_ANGLE);\r
\r
// Just so big a value that everything rendered is visible\r
camera->setFarValue(100000*BS);\r
+ \r
+ /*\r
+ Lighting test code. Doesn't quite work this way.\r
+ The CPU-computed lighting is good.\r
+ */\r
+\r
+ /*\r
+ smgr->addLightSceneNode(NULL,\r
+ v3f(0, BS*1000000, 0),\r
+ video::SColorf(0.3,0.3,0.3),\r
+ BS*10000000);\r
+\r
+ smgr->setAmbientLight(video::SColorf(0.0, 0.0, 0.0));\r
+\r
+ scene::ILightSceneNode *light = smgr->addLightSceneNode(camera,\r
+ v3f(0, 0, 0), video::SColorf(0.5,0.5,0.5), BS*4);\r
+ */\r
\r
f32 camera_yaw = 0; // "right/left"\r
f32 camera_pitch = 0; // "up/down"\r
Add some gui stuff\r
*/\r
\r
- GUIQuickInventory *quick_inventory = new GUIQuickInventory\r
- (guienv, NULL, v2s32(10, 70), 5, &local_inventory);\r
+ /*GUIQuickInventory *quick_inventory = new GUIQuickInventory\r
+ (guienv, NULL, v2s32(10, 70), 5, &local_inventory);*/\r
+ /*GUIQuickInventory *quick_inventory = new GUIQuickInventory\r
+ (guienv, NULL, v2s32(0, 0), quickinv_itemcount, &local_inventory);*/\r
\r
// Test the text input system\r
/*(new GUITextInputMenu(guienv, guiroot, -1, &g_menumgr,\r
guitext2->setVisible(true);\r
guitext_info->setVisible(true);\r
guitext_chat->setVisible(true);\r
+\r
+ //s32 guitext_chat_pad_bottom = 70;\r
+\r
+ v2u32 screensize(0,0);\r
+ v2u32 last_screensize(0,0);\r
\r
/*\r
Some statistics are collected in these\r
// A test\r
//throw con::PeerNotFoundException("lol");\r
\r
+ core::list<float> frametime_log;\r
+\r
/*\r
Main loop\r
*/\r
// NOTE: So we have to use getTime() and call run()s between them\r
u32 lasttime = device->getTimer()->getTime();\r
\r
- while(device->run())\r
+ while(device->run() && kill == false)\r
{\r
if(g_disconnect_requested)\r
{\r
*/\r
g_irrlicht->Run();\r
\r
+ /*\r
+ Process TextureSource's queue\r
+ */\r
+ texturesource->processQueue();\r
+\r
/*\r
Random calculations\r
*/\r
- v2u32 screensize = driver->getScreenSize();\r
- core::vector2d<s32> displaycenter(screensize.X/2,screensize.Y/2);\r
+ last_screensize = screensize;\r
+ screensize = driver->getScreenSize();\r
+ v2s32 displaycenter(screensize.X/2,screensize.Y/2);\r
+ //bool screensize_changed = screensize != last_screensize;\r
\r
// Hilight boxes collected during the loop and displayed\r
core::list< core::aabbox3d<f32> > hilightboxes;\r
// Info text\r
std::wstring infotext;\r
\r
+ // When screen size changes, update positions and sizes of stuff\r
+ /*if(screensize_changed)\r
+ {\r
+ v2s32 pos(displaycenter.X-((quickinv_itemcount-1)*quickinv_spacing+quickinv_size)/2, screensize.Y-quickinv_spacing);\r
+ quick_inventory->updatePosition(pos);\r
+ }*/\r
+\r
//TimeTaker //timer1("//timer1");\r
\r
// Time of frame without fps limit\r
dtime = 0;\r
lasttime = time;\r
\r
+ /*\r
+ Log frametime for visualization\r
+ */\r
+ frametime_log.push_back(dtime);\r
+ if(frametime_log.size() > 100)\r
+ {\r
+ core::list<float>::Iterator i = frametime_log.begin();\r
+ frametime_log.erase(i);\r
+ }\r
+\r
+ /*\r
+ Visualize frametime in terminal\r
+ */\r
+ /*for(u32 i=0; i<dtime*400; i++)\r
+ std::cout<<"X";\r
+ std::cout<<std::endl;*/\r
+\r
/*\r
Time average and jitter calculation\r
*/\r
dtime_jitter1_max_fraction\r
= dtime_jitter1_max_sample / (dtime_avg1+0.001);\r
jitter1_max = 0.0;\r
- \r
- /*\r
- Control freetime ratio\r
- */\r
- /*if(dtime_jitter1_max_fraction > DTIME_JITTER_MAX_FRACTION)\r
- {\r
- if(g_freetime_ratio < FREETIME_RATIO_MAX)\r
- g_freetime_ratio += 0.01;\r
- }\r
- else\r
- {\r
- if(g_freetime_ratio > FREETIME_RATIO_MIN)\r
- g_freetime_ratio -= 0.01;\r
- }*/\r
}\r
}\r
\r
*/\r
g_input->step(dtime);\r
\r
+ /*\r
+ Misc. stuff\r
+ */\r
+\r
/*\r
Player speed control\r
*/\r
bool a_right,\r
bool a_jump,\r
bool a_superspeed,\r
+ bool a_sneak,\r
float a_pitch,\r
float a_yaw*/\r
PlayerControl control(\r
g_input->isKeyDown(irr::KEY_KEY_A),\r
g_input->isKeyDown(irr::KEY_KEY_D),\r
g_input->isKeyDown(irr::KEY_SPACE),\r
- g_input->isKeyDown(irr::KEY_KEY_2),\r
+ g_input->isKeyDown(irr::KEY_KEY_E),\r
+ g_input->isKeyDown(irr::KEY_LSHIFT)\r
+ || g_input->isKeyDown(irr::KEY_RSHIFT),\r
camera_pitch,\r
camera_yaw\r
);\r
camera_direction.rotateXZBy(camera_yaw);\r
\r
// This is at the height of the eyes of the current figure\r
- v3f camera_position = player_position + v3f(0, BS+BS/2, 0);\r
+ //v3f camera_position = player_position + v3f(0, BS+BS/2, 0);\r
// This is more like in minecraft\r
- //v3f camera_position = player_position + v3f(0, BS+BS*0.625, 0);\r
+ v3f camera_position = player_position + v3f(0, BS+BS*0.625, 0);\r
\r
camera->setPosition(camera_position);\r
// *100.0 helps in large map coordinates\r
camera->setTarget(camera_position + camera_direction * 100.0);\r
\r
if(FIELD_OF_VIEW_TEST){\r
- //client.m_env.getMap().updateCamera(v3f(0,0,0), v3f(0,0,1));\r
client.updateCamera(v3f(0,0,0), v3f(0,0,1));\r
}\r
else{\r
- //client.m_env.getMap().updateCamera(camera_position, camera_direction);\r
//TimeTaker timer("client.updateCamera");\r
client.updateCamera(camera_position, camera_direction);\r
}\r
bool nodefound = false;\r
v3s16 nodepos;\r
v3s16 neighbourpos;\r
- core::aabbox3d<f32> nodefacebox;\r
+ core::aabbox3d<f32> nodehilightbox;\r
f32 mindistance = BS * 1001;\r
\r
- v3s16 pos_i = floatToInt(player_position);\r
+ v3s16 pos_i = floatToInt(player_position, BS);\r
\r
/*std::cout<<"pos_i=("<<pos_i.X<<","<<pos_i.Y<<","<<pos_i.Z<<")"\r
<<std::endl;*/\r
}\r
\r
v3s16 np(x,y,z);\r
- v3f npf = intToFloat(np);\r
+ v3f npf = intToFloat(np, BS);\r
\r
f32 d = 0.01;\r
\r
nodepos = np;\r
neighbourpos = np;\r
mindistance = distance;\r
- nodefacebox = box;\r
+ nodehilightbox = box;\r
}\r
}\r
}\r
nodepos = np;\r
neighbourpos = np + dirs[i];\r
mindistance = distance;\r
- nodefacebox = facebox;\r
+\r
+ //nodehilightbox = facebox;\r
+\r
+ const float d = 0.502;\r
+ core::aabbox3d<f32> nodebox\r
+ (-BS*d, -BS*d, -BS*d, BS*d, BS*d, BS*d);\r
+ v3f nodepos_f = intToFloat(nodepos, BS);\r
+ nodebox.MinEdge += nodepos_f;\r
+ nodebox.MaxEdge += nodepos_f;\r
+ nodehilightbox = nodebox;\r
}\r
} // if distance < mindistance\r
} // for dirs\r
\r
static float dig_time = 0.0;\r
static u16 dig_index = 0;\r
+ \r
+ // Visualize selection\r
\r
- hilightboxes.push_back(nodefacebox);\r
+ hilightboxes.push_back(nodehilightbox);\r
+\r
+ // Handle digging\r
\r
if(g_input->getLeftReleased())\r
{\r
\r
if(dig_index < CRACK_ANIMATION_LENGTH)\r
{\r
+ //TimeTaker timer("client.setTempMod");\r
//dstream<<"dig_index="<<dig_index<<std::endl;\r
client.setTempMod(nodepos, NodeMod(NODEMOD_CRACK, dig_index));\r
}\r
}\r
// We want a slight delay to very little\r
// time consuming nodes\r
- //float mindelay = 0.15;\r
- float mindelay = 0.20;\r
+ float mindelay = 0.15;\r
if(nodig_delay_counter < mindelay)\r
{\r
nodig_delay_counter = mindelay;\r
camera->setAspectRatio((f32)screensize.X / (f32)screensize.Y);\r
\r
u32 daynight_ratio = client.getDayNightRatio();\r
- /*video::SColor bgcolor = video::SColor(\r
- 255,\r
- skycolor.getRed() * daynight_ratio / 1000,\r
- skycolor.getGreen() * daynight_ratio / 1000,\r
- skycolor.getBlue() * daynight_ratio / 1000);*/\r
-\r
u8 l = decode_light((daynight_ratio * LIGHT_SUN) / 1000);\r
video::SColor bgcolor = video::SColor(\r
255,\r
\r
if(g_settings.getBool("enable_fog") == true)\r
{\r
- f32 range = draw_control.wanted_range * BS;\r
+ //f32 range = draw_control.wanted_range * BS + MAP_BLOCKSIZE/2*BS;\r
+ f32 range = draw_control.wanted_range * BS + 0.8*MAP_BLOCKSIZE*BS;\r
+ //f32 range = draw_control.wanted_range * BS + 0.0*MAP_BLOCKSIZE*BS;\r
if(draw_control.range_all)\r
range = 100000*BS;\r
\r
driver->setFog(\r
bgcolor,\r
video::EFT_FOG_LINEAR,\r
- range*0.6,\r
- range,\r
+ range*0.4,\r
+ range*1.0,\r
+ 0.01,\r
+ false, // pixel fog\r
+ false // range fog\r
+ );\r
+ }\r
+ else\r
+ {\r
+ driver->setFog(\r
+ bgcolor,\r
+ video::EFT_FOG_LINEAR,\r
+ 100000*BS,\r
+ 110000*BS,\r
0.01,\r
false, // pixel fog\r
false // range fog\r
- );\r
+ );\r
}\r
\r
\r
//TimeTaker guiupdatetimer("Gui updating");\r
\r
{\r
- wchar_t temptext[150];\r
-\r
static float drawtime_avg = 0;\r
drawtime_avg = drawtime_avg * 0.95 + (float)drawtime*0.05;\r
static float beginscenetime_avg = 0;\r
static float endscenetime_avg = 0;\r
endscenetime_avg = endscenetime_avg * 0.95 + (float)endscenetime*0.05;\r
\r
- swprintf(temptext, 150, L"Minetest-c55 ("\r
- L"F: item=%i"\r
- L", R: range_all=%i"\r
- L")"\r
- L" drawtime=%.0f, beginscenetime=%.0f, scenetime=%.0f, endscenetime=%.0f",\r
+ char temptext[300];\r
+ snprintf(temptext, 300, "Minetest-c55 ("\r
+ "F: item=%i"\r
+ ", R: range_all=%i"\r
+ ")"\r
+ " drawtime=%.0f, beginscenetime=%.0f"\r
+ ", scenetime=%.0f, endscenetime=%.0f",\r
g_selected_item,\r
draw_control.range_all,\r
drawtime_avg,\r
endscenetime_avg\r
);\r
\r
- guitext->setText(temptext);\r
+ guitext->setText(narrow_to_wide(temptext).c_str());\r
}\r
\r
{\r
- wchar_t temptext[150];\r
- swprintf(temptext, 150,\r
- L"(% .1f, % .1f, % .1f)"\r
- L" (% .3f < btime_jitter < % .3f"\r
- L", dtime_jitter = % .1f %%"\r
- L", v_range = %.1f)",\r
+ char temptext[300];\r
+ snprintf(temptext, 300,\r
+ "(% .1f, % .1f, % .1f)"\r
+ " (% .3f < btime_jitter < % .3f"\r
+ ", dtime_jitter = % .1f %%"\r
+ ", v_range = %.1f)",\r
player_position.X/BS,\r
player_position.Y/BS,\r
player_position.Z/BS,\r
draw_control.wanted_range\r
);\r
\r
- guitext2->setText(temptext);\r
+ guitext2->setText(narrow_to_wide(temptext).c_str());\r
}\r
\r
{\r
chat_lines.erase(it);\r
}\r
guitext_chat->setText(whole.c_str());\r
+\r
// Update gui element size and position\r
+\r
+ /*core::rect<s32> rect(\r
+ 10,\r
+ screensize.Y - guitext_chat_pad_bottom\r
+ - text_height*chat_lines.size(),\r
+ screensize.X - 10,\r
+ screensize.Y - guitext_chat_pad_bottom\r
+ );*/\r
core::rect<s32> rect(\r
10,\r
- screensize.Y - 10 - text_height*chat_lines.size(),\r
+ 50,\r
screensize.X - 10,\r
- screensize.Y - 10\r
+ 50 + text_height*chat_lines.size()\r
);\r
+\r
guitext_chat->setRelativePosition(rect);\r
\r
if(chat_lines.size() == 0)\r
old_selected_item = g_selected_item;\r
//std::cout<<"Updating local inventory"<<std::endl;\r
client.getLocalInventory(local_inventory);\r
- quick_inventory->setSelection(g_selected_item);\r
- quick_inventory->update();\r
+ /*quick_inventory->setSelection(g_selected_item);\r
+ quick_inventory->update();*/\r
}\r
\r
/*\r
//TimeTaker //timer10("//timer10");\r
\r
video::SMaterial m;\r
- m.Thickness = 10;\r
+ //m.Thickness = 10;\r
+ m.Thickness = 3;\r
m.Lighting = false;\r
driver->setMaterial(m);\r
\r
driver->draw3DBox(*i, video::SColor(255,0,0,0));\r
}\r
\r
+ /*\r
+ Frametime log\r
+ */\r
+ if(g_settings.getBool("frametime_graph") == true)\r
+ {\r
+ s32 x = 10;\r
+ for(core::list<float>::Iterator\r
+ i = frametime_log.begin();\r
+ i != frametime_log.end();\r
+ i++)\r
+ {\r
+ driver->draw2DLine(v2s32(x,50),\r
+ v2s32(x,50+(*i)*1000),\r
+ video::SColor(255,255,255,255));\r
+ x++;\r
+ }\r
+ }\r
+\r
+ /*\r
+ Draw map plot\r
+ */\r
+ if(g_show_map_plot && g_map_plot_texture)\r
+ {\r
+ core::dimension2d<u32> drawdim(640,480);\r
+ core::rect<s32> dest(v2s32(0,0), drawdim);\r
+ dest += v2s32(\r
+ (screensize.X-drawdim.Width)/2,\r
+ (screensize.Y-drawdim.Height)/2\r
+ );\r
+ core::rect<s32> source(v2s32(0,0), g_map_plot_texture->getSize());\r
+ driver->draw2DImage(g_map_plot_texture, dest, source);\r
+ }\r
+\r
/*\r
Draw crosshair\r
*/\r
displaycenter + core::vector2d<s32>(0,10),\r
video::SColor(255,255,255,255));\r
\r
- }\r
+ } // timer\r
\r
//timer10.stop();\r
//TimeTaker //timer11("//timer11");\r
*/\r
// 0-1ms\r
guienv->drawAll();\r
+\r
+ /*\r
+ Draw hotbar\r
+ */\r
+ {\r
+ draw_hotbar(driver, font, v2s32(displaycenter.X, screensize.Y),\r
+ hotbar_imagesize, hotbar_itemcount, &local_inventory);\r
+ }\r
\r
// End drawing\r
{\r
drawtime = drawtimer.stop(true);\r
\r
/*\r
- Drawing ends\r
+ End of drawing\r
*/\r
+\r
+ /*\r
+ Refresh map plot if player has moved considerably\r
+ */\r
+ if(g_refresh_map_plot)\r
+ {\r
+ static v3f old_player_pos = v3f(1,1,1) * 10000000;\r
+ v3f p = client.getPlayerPosition() / BS;\r
+ if(old_player_pos.getDistanceFrom(p) > 4 * g_map_plot_texture_scale)\r
+ {\r
+ updateMapPlotTexture(v2f(p.X,p.Z), driver, &client);\r
+ old_player_pos = p;\r
+ }\r
+ g_refresh_map_plot = false;\r
+ }\r
\r
static s16 lastFPS = 0;\r
//u16 fps = driver->getFPS();\r
device->yield();*/\r
}\r
\r
- delete quick_inventory;\r
+ //delete quick_inventory;\r
+\r
+ /*\r
+ Disable texture fetches and other stuff that is queued\r
+ to be processed by the main loop.\r
+\r
+ This has to be done before client goes out of scope.\r
+ */\r
+ g_irrlicht->Shutdown(true);\r
\r
} // client and server are deleted at this point\r
\r