Fix my name.
[oweals/minetest.git] / src / game.cpp
index f63a4a400228d1cb78e99704570924a1725d7e23..7954c8d8003ab6c7e12f9a51bfbb0aaf32e0980b 100644 (file)
@@ -40,7 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "clouds.h"
 #include "particles.h"
 #include "camera.h"
-#include "farmesh.h"
 #include "mapblock.h"
 #include "settings.h"
 #include "profiler.h"
@@ -66,6 +65,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
        #include "sound_openal.h"
 #endif
 #include "event_manager.h"
+#include <iomanip>
 #include <list>
 #include "util/directiontables.h"
 
@@ -134,6 +134,10 @@ struct TextDestPlayerInventory : public TextDest
                m_client->sendInventoryFields(m_formname, fields);
        }
 
+       void setFormName(std::string formname) {
+               m_formname = formname;
+       }
+
        Client *m_client;
        std::string m_formname;
 };
@@ -203,33 +207,6 @@ public:
        Client *m_client;
 };
 
-class FormspecFormSource: public IFormSource
-{
-public:
-       FormspecFormSource(std::string formspec,FormspecFormSource** game_formspec)
-       {
-               m_formspec = formspec;
-               m_game_formspec = game_formspec;
-       }
-
-       ~FormspecFormSource()
-       {
-               *m_game_formspec = 0;
-       }
-
-       void setForm(std::string formspec) {
-               m_formspec = formspec;
-       }
-
-       std::string getForm()
-       {
-               return m_formspec;
-       }
-
-       std::string m_formspec;
-       FormspecFormSource** m_game_formspec;
-};
-
 /*
        Check if a node is pointable
 */
@@ -724,6 +701,18 @@ public:
                sm->m_sound->playSound(sm->m_ndef->get(nde->n).sound_dug, false);
        }
 
+       static void playerDamage(MtEvent *e, void *data)
+       {
+               SoundMaker *sm = (SoundMaker*)data;
+               sm->m_sound->playSound(SimpleSoundSpec("player_damage", 0.5), false);
+       }
+
+       static void playerFallingDamage(MtEvent *e, void *data)
+       {
+               SoundMaker *sm = (SoundMaker*)data;
+               sm->m_sound->playSound(SimpleSoundSpec("player_falling_damage", 0.5), false);
+       }
+
        void registerReceiver(MtEventManager *mgr)
        {
                mgr->reg("ViewBobbingStep", SoundMaker::viewBobbingStep, this);
@@ -732,6 +721,8 @@ public:
                mgr->reg("CameraPunchLeft", SoundMaker::cameraPunchLeft, this);
                mgr->reg("CameraPunchRight", SoundMaker::cameraPunchRight, this);
                mgr->reg("NodeDug", SoundMaker::nodeDug, this);
+               mgr->reg("PlayerDamage", SoundMaker::playerDamage, this);
+               mgr->reg("PlayerFallingDamage", SoundMaker::playerFallingDamage, this);
        }
 
        void step(float dtime)
@@ -812,10 +803,19 @@ public:
                u32 daynight_ratio = m_client->getEnv().getDayNightRatio();
                float daynight_ratio_f = (float)daynight_ratio / 1000.0;
                services->setPixelShaderConstant("dayNightRatio", &daynight_ratio_f, 1);
+               
+               // Normal map texture layer
+               int layer = 1;
+               // before 1.8 there isn't a "integer interface", only float
+#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
+               services->setPixelShaderConstant("normalTexture" , (irr::f32*)&layer, 1);
+#else
+               services->setPixelShaderConstant("normalTexture" , (irr::s32*)&layer, 1);
+#endif
        }
 };
 
-void nodePlacementPrediction(Client &client,
+bool nodePlacementPrediction(Client &client,
                const ItemDefinition &playeritem_def,
                v3s16 nodepos, v3s16 neighbourpos)
 {
@@ -835,7 +835,7 @@ void nodePlacementPrediction(Client &client,
                        if(nodedef->get(n_under).buildable_to)
                                p = nodepos;
                        else if (!nodedef->get(map.getNode(p)).buildable_to)
-                               return;
+                               return false;
                }catch(InvalidPositionException &e){}
                // Find id of predicted node
                content_t id;
@@ -845,9 +845,9 @@ void nodePlacementPrediction(Client &client,
                                        <<playeritem_def.name<<" (places "
                                        <<prediction
                                        <<") - Name not known"<<std::endl;
-                       return;
+                       return false;
                }
-               // Predict param2
+               // Predict param2 for facedir and wallmounted nodes
                u8 param2 = 0;
                if(nodedef->get(id).param_type_2 == CPT2_WALLMOUNTED){
                        v3s16 dir = nodepos - neighbourpos;
@@ -859,13 +859,39 @@ void nodePlacementPrediction(Client &client,
                                param2 = dir.Z < 0 ? 5 : 4;
                        }
                }
-               // TODO: Facedir prediction
-               // TODO: If predicted node is in attached_node group, check attachment
+               if(nodedef->get(id).param_type_2 == CPT2_FACEDIR){
+                       v3s16 dir = nodepos - floatToInt(client.getEnv().getLocalPlayer()->getPosition(), BS);
+                       if(abs(dir.X) > abs(dir.Z)){
+                               param2 = dir.X < 0 ? 3 : 1;
+                       } else {
+                               param2 = dir.Z < 0 ? 2 : 0;
+                       }
+               }
+               assert(param2 >= 0 && param2 <= 5);
+               //Check attachment if node is in group attached_node
+               if(((ItemGroupList) nodedef->get(id).groups)["attached_node"] != 0){
+                       static v3s16 wallmounted_dirs[8] = {
+                               v3s16(0,1,0),
+                               v3s16(0,-1,0),
+                               v3s16(1,0,0),
+                               v3s16(-1,0,0),
+                               v3s16(0,0,1),
+                               v3s16(0,0,-1),
+                       };
+                       v3s16 pp;
+                       if(nodedef->get(id).param_type_2 == CPT2_WALLMOUNTED)
+                               pp = p + wallmounted_dirs[param2];
+                       else
+                               pp = p + v3s16(0,-1,0);
+                       if(!nodedef->get(map.getNode(pp)).walkable)
+                               return false;
+               }
                // Add node to client map
                MapNode n(id, 0, param2);
                try{
                        // This triggers the required mesh update too
                        client.addNode(p, n);
+                       return true;
                }catch(InvalidPositionException &e){
                        errorstream<<"Node placement prediction failed for "
                                        <<playeritem_def.name<<" (places "
@@ -873,6 +899,7 @@ void nodePlacementPrediction(Client &client,
                                        <<") - Position not loaded"<<std::endl;
                }
        }
+       return false;
 }
 
 
@@ -895,6 +922,7 @@ void the_game(
 )
 {
        FormspecFormSource* current_formspec = 0;
+       TextDestPlayerInventory* current_textdest = 0;
        video::IVideoDriver* driver = device->getVideoDriver();
        scene::ISceneManager* smgr = device->getSceneManager();
        
@@ -992,12 +1020,6 @@ void the_game(
        infostream<<"Creating client"<<std::endl;
        
        MapDrawControl draw_control;
-
-       Client client(device, playername.c_str(), password, draw_control,
-                       tsrc, shsrc, itemdef, nodedef, sound, &eventmgr);
-       
-       // Client acts as our GameDef
-       IGameDef *gamedef = &client;
        
        {
                wchar_t* text = wgettext("Resolving address...");
@@ -1007,18 +1029,39 @@ void the_game(
        Address connect_address(0,0,0,0, port);
        try{
                if(address == "")
+               {
                        //connect_address.Resolve("localhost");
-                       connect_address.setAddress(127,0,0,1);
+                       if(g_settings->getBool("enable_ipv6") && g_settings->getBool("ipv6_server"))
+                       {
+                               IPv6AddressBytes addr_bytes;
+                               addr_bytes.bytes[15] = 1;
+                               connect_address.setAddress(&addr_bytes);
+                       }
+                       else
+                       {
+                               connect_address.setAddress(127,0,0,1);
+                       }
+               }
                else
                        connect_address.Resolve(address.c_str());
        }
        catch(ResolveError &e)
        {
-               error_message = L"Couldn't resolve address";
+               error_message = L"Couldn't resolve address: " + narrow_to_wide(e.what());
                errorstream<<wide_to_narrow(error_message)<<std::endl;
                // Break out of client scope
                break;
        }
+       
+       /*
+               Create client
+       */
+       Client client(device, playername.c_str(), password, draw_control,
+               tsrc, shsrc, itemdef, nodedef, sound, &eventmgr,
+               connect_address.isIPv6());
+       
+       // Client acts as our GameDef
+       IGameDef *gamedef = &client;
 
        /*
                Attempt to connect to the server
@@ -1042,7 +1085,7 @@ void the_game(
                u32 lasttime = device->getTimer()->getTime();
                while(device->run())
                {
-                       f32 dtime=0; // in seconds
+                       f32 dtime = 0.033; // in seconds
                        if (cloud_menu_background) {
                                u32 time = device->getTimer()->getTime();
                                if(time > lasttime)
@@ -1136,7 +1179,7 @@ void the_game(
                u32 lasttime = device->getTimer()->getTime();
                while(device->run())
                {
-                       f32 dtime=0; // in seconds
+                       f32 dtime = 0.033; // in seconds
                        if (cloud_menu_background) {
                                u32 time = device->getTimer()->getTime();
                                if(time > lasttime)
@@ -1170,26 +1213,28 @@ void the_game(
                        }
                        
                        // Display status
-                       std::ostringstream ss;
                        int progress=0;
                        if (!client.itemdefReceived())
                        {
-                               ss << "Item definitions...";
+                               wchar_t* text = wgettext("Item definitions...");
                                progress = 0;
+                               draw_load_screen(text, device, font, dtime, progress);
+                               delete[] text;
                        }
                        else if (!client.nodedefReceived())
                        {
-                               ss << "Node definitions...";
+                               wchar_t* text = wgettext("Node definitions...");
                                progress = 25;
+                               draw_load_screen(text, device, font, dtime, progress);
+                               delete[] text;
                        }
                        else
                        {
-                               ss << "Media...";
+                               wchar_t* text = wgettext("Media...");
                                progress = 50+client.mediaReceiveProgress()*50+0.5;
+                               draw_load_screen(text, device, font, dtime, progress);
+                               delete[] text;
                        }
-                       wchar_t* text = wgettext(ss.str().c_str());
-                       draw_load_screen(text, device, font, dtime, progress);
-                       delete[] text;
                        
                        // On some computers framerate doesn't seem to be
                        // automatically limited
@@ -1261,16 +1306,6 @@ void the_game(
        Sky *sky = NULL;
        sky = new Sky(smgr->getRootSceneNode(), smgr, -1);
        
-       /*
-               FarMesh
-       */
-
-       FarMesh *farmesh = NULL;
-       if(g_settings->getBool("enable_farmesh"))
-       {
-               farmesh = new FarMesh(smgr->getRootSceneNode(), smgr, -1, client.getMapSeed(), &client);
-       }
-
        /*
                A copy of the local inventory
        */
@@ -1281,7 +1316,7 @@ void the_game(
        */
        int crack_animation_length = 5;
        {
-               video::ITexture *t = tsrc->getTextureRaw("crack_anylength.png");
+               video::ITexture *t = tsrc->getTexture("crack_anylength.png");
                v2u32 size = t->getOriginalSize();
                crack_animation_length = size.Y / size.X;
        }
@@ -1335,6 +1370,7 @@ void the_game(
                        false, false);
        guitext_profiler->setBackgroundColor(video::SColor(120,0,0,0));
        guitext_profiler->setVisible(false);
+       guitext_profiler->setWordWrap(true);
        
        /*
                Some statistics are collected in these
@@ -1359,7 +1395,6 @@ void the_game(
        bool ldown_for_dig = false;
 
        float damage_flash = 0;
-       s16 farmesh_range = 20*MAP_BLOCKSIZE;
 
        float jump_timer = 0;
        bool reset_jump_timer = false;
@@ -1653,6 +1688,10 @@ void the_game(
                {
                        input->clear();
                }
+               if (!guienv->hasFocus(gui_chat_console) && gui_chat_console->isOpen())
+               {
+                       gui_chat_console->closeConsoleAtOnce();
+               }
 
                // Input handler step() (used by the random input generator)
                input->step(dtime);
@@ -1962,7 +2001,7 @@ void the_game(
                {
                        s32 wheel = input->getMouseWheel();
                        u16 max_item = MYMIN(PLAYER_INVENTORY_SIZE-1,
-                                       hud.hotbar_itemcount-1);
+                                       player->hud_hotbar_itemcount-1);
 
                        if(wheel < 0)
                        {
@@ -1986,7 +2025,7 @@ void the_game(
                        const KeyPress *kp = NumberKey + (i + 1) % 10;
                        if(input->wasKeyDown(*kp))
                        {
-                               if(i < PLAYER_INVENTORY_SIZE && i < hud.hotbar_itemcount)
+                               if(i < PLAYER_INVENTORY_SIZE && i < player->hud_hotbar_itemcount)
                                {
                                        new_playeritem = i;
 
@@ -2167,6 +2206,9 @@ void the_game(
                                        player->hurt_tilt_timer = 1.5;
                                        player->hurt_tilt_strength = event.player_damage.amount/2;
                                        player->hurt_tilt_strength = rangelim(player->hurt_tilt_strength, 2.0, 10.0);
+
+                                       MtEvent *e = new SimpleTriggerEvent("PlayerDamage");
+                                       gamedef->event()->put(e);
                                }
                                else if(event.type == CE_PLAYER_FORCE_MOVE)
                                {
@@ -2211,19 +2253,23 @@ void the_game(
                                        if (current_formspec == 0)
                                        {
                                                /* Create menu */
+                                               /* Note: FormspecFormSource and TextDestPlayerInventory
+                                                * are deleted by guiFormSpecMenu                     */
                                                current_formspec = new FormspecFormSource(*(event.show_formspec.formspec),&current_formspec);
-
+                                               current_textdest = new TextDestPlayerInventory(&client,*(event.show_formspec.formname));
                                                GUIFormSpecMenu *menu =
                                                                new GUIFormSpecMenu(device, guiroot, -1,
                                                                                &g_menumgr,
                                                                                &client, gamedef);
                                                menu->setFormSource(current_formspec);
-                                               menu->setTextDest(new TextDestPlayerInventory(&client,*(event.show_formspec.formname)));
+                                               menu->setTextDest(current_textdest);
                                                menu->drop();
                                        }
                                        else
                                        {
+                                               assert(current_textdest != 0);
                                                /* update menu */
+                                               current_textdest->setFormName(*(event.show_formspec.formname));
                                                current_formspec->setForm(*(event.show_formspec.formspec));
                                        }
                                        delete(event.show_formspec.formspec);
@@ -2236,7 +2282,7 @@ void the_game(
                                else if(event.type == CE_SPAWN_PARTICLE)
                                {
                                        LocalPlayer* player = client.getEnv().getLocalPlayer();
-                                       AtlasPointer ap =
+                                       video::ITexture *texture =
                                                gamedef->tsrc()->getTexture(*(event.spawn_particle.texture));
 
                                        new Particle(gamedef, smgr, player, client.getEnv(),
@@ -2245,12 +2291,15 @@ void the_game(
                                                *event.spawn_particle.acc,
                                                 event.spawn_particle.expirationtime,
                                                 event.spawn_particle.size,
-                                                event.spawn_particle.collisiondetection, ap);
+                                                event.spawn_particle.collisiondetection,
+                                                texture,
+                                                v2f(0.0, 0.0),
+                                                v2f(1.0, 1.0));
                                }
                                else if(event.type == CE_ADD_PARTICLESPAWNER)
                                {
                                        LocalPlayer* player = client.getEnv().getLocalPlayer();
-                                       AtlasPointer ap =
+                                       video::ITexture *texture =
                                                gamedef->tsrc()->getTexture(*(event.add_particlespawner.texture));
 
                                        new ParticleSpawner(gamedef, smgr, player,
@@ -2267,7 +2316,7 @@ void the_game(
                                                 event.add_particlespawner.minsize,
                                                 event.add_particlespawner.maxsize,
                                                 event.add_particlespawner.collisiondetection,
-                                                ap,
+                                                texture,
                                                 event.add_particlespawner.id);
                                }
                                else if(event.type == CE_DELETE_PARTICLESPAWNER)
@@ -2395,10 +2444,12 @@ void the_game(
                float full_punch_interval = playeritem_toolcap.full_punch_interval;
                float tool_reload_ratio = time_from_last_punch / full_punch_interval;
                tool_reload_ratio = MYMIN(tool_reload_ratio, 1.0);
-               camera.update(player, busytime, screensize, tool_reload_ratio);
+               camera.update(player, dtime, busytime, screensize,
+                               tool_reload_ratio);
                camera.step(dtime);
 
                v3f player_position = player->getPosition();
+               v3s16 pos_i = floatToInt(player_position, BS);
                v3f camera_position = camera.getPosition();
                v3f camera_direction = camera.getDirection();
                f32 camera_fov = camera.getFovMax();
@@ -2432,7 +2483,12 @@ void the_game(
                
                //u32 t1 = device->getTimer()->getRealTime();
                
-               f32 d = 4; // max. distance
+               f32 d = playeritem_def.range; // max. distance
+               f32 d_hand = itemdef->get("").range;
+               if(d < 0 && d_hand >= 0)
+                       d = d_hand;
+               else if(d < 0)
+                       d = 4.0;
                core::line3d<f32> shootline(camera_position,
                                camera_position + camera_direction * BS * (d+1));
 
@@ -2532,7 +2588,8 @@ void the_game(
                                Handle digging
                        */
                        
-                       if(nodig_delay_timer <= 0.0 && input->getLeftState())
+                       if(nodig_delay_timer <= 0.0 && input->getLeftState()
+                                       && client.checkPrivilege("interact"))
                        {
                                if(!digging)
                                {
@@ -2555,20 +2612,6 @@ void the_game(
                                        if(tp)
                                                params = getDigParams(nodedef->get(n).groups, tp);
                                }
-                               
-                               SimpleSoundSpec sound_dig = nodedef->get(n).sound_dig;
-                               if(sound_dig.exists()){
-                                       if(sound_dig.name == "__group"){
-                                               if(params.main_group != ""){
-                                                       soundmaker.m_player_leftpunch_sound.gain = 0.5;
-                                                       soundmaker.m_player_leftpunch_sound.name =
-                                                                       std::string("default_dig_") +
-                                                                                       params.main_group;
-                                               }
-                                       } else{
-                                               soundmaker.m_player_leftpunch_sound = sound_dig;
-                                       }
-                               }
 
                                float dig_time_complete = 0.0;
 
@@ -2601,6 +2644,20 @@ void the_game(
                                        dig_index = crack_animation_length;
                                }
 
+                               SimpleSoundSpec sound_dig = nodedef->get(n).sound_dig;
+                               if(sound_dig.exists() && params.diggable){
+                                       if(sound_dig.name == "__group"){
+                                               if(params.main_group != ""){
+                                                       soundmaker.m_player_leftpunch_sound.gain = 0.5;
+                                                       soundmaker.m_player_leftpunch_sound.name =
+                                                                       std::string("default_dig_") +
+                                                                                       params.main_group;
+                                               }
+                                       } else{
+                                               soundmaker.m_player_leftpunch_sound = sound_dig;
+                                       }
+                               }
+
                                // Don't show cracks if not diggable
                                if(dig_time_complete >= 100000.0)
                                {
@@ -2649,13 +2706,20 @@ void the_game(
                                        gamedef->event()->put(e);
                                }
 
-                               dig_time += dtime;
+                               if(dig_time_complete < 100000.0)
+                                       dig_time += dtime;
+                               else {
+                                       dig_time = 0;
+                                       client.setCrack(-1, nodepos);
+                               }
 
                                camera.setDigging(0);  // left click animation
                        }
 
-                       if(input->getRightClicked() ||
-                                       repeat_rightclick_timer >= g_settings->getFloat("repeat_rightclick_time"))
+                       if((input->getRightClicked() ||
+                                       repeat_rightclick_timer >=
+                                               g_settings->getFloat("repeat_rightclick_time")) &&
+                                       client.checkPrivilege("interact"))
                        {
                                repeat_rightclick_timer = 0;
                                infostream<<"Ground right-clicked"<<std::endl;
@@ -2709,13 +2773,17 @@ void the_game(
                                        
                                        // If the wielded item has node placement prediction,
                                        // make that happen
-                                       nodePlacementPrediction(client,
+                                       bool placed = nodePlacementPrediction(client,
                                                        playeritem_def,
                                                        nodepos, neighbourpos);
                                        
                                        // Read the sound
-                                       soundmaker.m_player_rightpunch_sound =
-                                                       playeritem_def.sound_place;
+                                       if(placed)
+                                               soundmaker.m_player_rightpunch_sound =
+                                                               playeritem_def.sound_place;
+                                       else
+                                               soundmaker.m_player_rightpunch_sound =
+                                                               SimpleSoundSpec();
                                }
                        }
                }
@@ -2789,16 +2857,12 @@ void the_game(
                        Fog range
                */
        
-               if(farmesh)
-               {
-                       fog_range = BS*farmesh_range;
-               }
-               else
-               {
+               if(draw_control.range_all)
+                       fog_range = 100000*BS;
+               else {
                        fog_range = draw_control.wanted_range*BS + 0.0*MAP_BLOCKSIZE*BS;
+                       fog_range = MYMIN(fog_range, (draw_control.farthest_drawn+20)*BS);
                        fog_range *= 0.9;
-                       if(draw_control.range_all)
-                               fog_range = 100000*BS;
                }
 
                /*
@@ -2837,7 +2901,6 @@ void the_game(
                sky->update(time_of_day_smooth, time_brightness, direct_brightness,
                                sunlight_seen);
                
-               float brightness = sky->getBrightness();
                video::SColor bgcolor = sky->getBgColor();
                video::SColor skycolor = sky->getSkyColor();
 
@@ -2855,22 +2918,6 @@ void the_game(
                        }
                }
                
-               /*
-                       Update farmesh
-               */
-               if(farmesh)
-               {
-                       farmesh_range = draw_control.wanted_range * 10;
-                       if(draw_control.range_all && farmesh_range < 500)
-                               farmesh_range = 500;
-                       if(farmesh_range > 1000)
-                               farmesh_range = 1000;
-
-                       farmesh->step(dtime);
-                       farmesh->update(v2f(player_position.X, player_position.Z),
-                                       brightness, farmesh_range);
-               }
-
                /*
                        Update particles
                */
@@ -2927,21 +2974,20 @@ void the_game(
                        static float endscenetime_avg = 0;
                        endscenetime_avg = endscenetime_avg * 0.95 + (float)endscenetime*0.05;*/
                        
-                       char temptext[300];
-                       snprintf(temptext, 300, "%s ("
-                                       "R: range_all=%i"
-                                       ")"
-                                       " drawtime=%.0f, dtime_jitter = % .1f %%"
-                                       ", v_range = %.1f, RTT = %.3f",
-                                       program_name_and_version,
-                                       draw_control.range_all,
-                                       drawtime_avg,
-                                       dtime_jitter1_max_fraction * 100.0,
-                                       draw_control.wanted_range,
-                                       client.getRTT()
-                                       );
-                       
-                       guitext->setText(narrow_to_wide(temptext).c_str());
+                       std::ostringstream os(std::ios_base::binary);
+                       os<<std::fixed
+                               <<program_name_and_version
+                               <<" (R: range_all="<<draw_control.range_all<<")"
+                               <<std::setprecision(0)
+                               <<" drawtime = "<<drawtime_avg
+                               <<std::setprecision(1)
+                               <<", dtime_jitter = "
+                               <<(dtime_jitter1_max_fraction * 100.0)<<" %"
+                               <<std::setprecision(1)
+                               <<", v_range = "<<draw_control.wanted_range
+                               <<std::setprecision(3)
+                               <<", RTT = "<<client.getRTT();
+                       guitext->setText(narrow_to_wide(os.str()).c_str());
                        guitext->setVisible(true);
                }
                else if(show_hud || show_chat)
@@ -2956,17 +3002,17 @@ void the_game(
                
                if(show_debug)
                {
-                       char temptext[300];
-                       snprintf(temptext, 300,
-                                       "(% .1f, % .1f, % .1f)"
-                                       " (yaw = %.1f) (seed = %llu)",
-                                       player_position.X/BS,
-                                       player_position.Y/BS,
-                                       player_position.Z/BS,
-                                       wrapDegrees_0_360(camera_yaw),
-                                       (unsigned long long)client.getMapSeed());
-
-                       guitext2->setText(narrow_to_wide(temptext).c_str());
+                       std::ostringstream os(std::ios_base::binary);
+                       os<<std::setprecision(1)<<std::fixed
+                               <<"(" <<(player_position.X/BS)
+                               <<", "<<(player_position.Y/BS)
+                               <<", "<<(player_position.Z/BS)
+                               <<") (yaw="<<(wrapDegrees_0_360(camera_yaw))
+                               <<") (t="<<client.getEnv().getClientMap().getHeat(pos_i)
+                               <<"C, h="<<client.getEnv().getClientMap().getHumidity(pos_i)
+                               <<"%) (seed = "<<((unsigned long long)client.getMapSeed())
+                               <<")";
+                       guitext2->setText(narrow_to_wide(os.str()).c_str());
                        guitext2->setVisible(true);
                }
                else
@@ -3084,7 +3130,7 @@ void the_game(
                        ItemStack item;
                        if(mlist != NULL)
                                item = mlist->getItem(client.getPlayerItem());
-                       camera.wield(item);
+                       camera.wield(item, client.getPlayerItem());
                }
 
                /*
@@ -3251,7 +3297,7 @@ void the_game(
                if (show_hud)
                {
                        hud.drawHotbar(v2s32(displaycenter.X, screensize.Y),
-                                       client.getHP(), client.getPlayerItem());
+                                       client.getHP(), client.getPlayerItem(), client.getBreath());
                }
 
                /*
@@ -3402,6 +3448,7 @@ void the_game(
                infostream << "\t\t" << i << ":" << texture->getName().getPath().c_str()
                                << std::endl;
        }
+       clearTextureNameCache();
        infostream << "\tRemaining materials: "
                << driver-> getMaterialRendererCount ()
                << " (note: irrlicht doesn't support removing renderers)"<< std::endl;