]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/camera.cpp
Fix script error reporting a bit
[dragonfireclient.git] / src / camera.cpp
index a32336714fdadcd4a53db4b55d7a5ae79b4bbf5b..8f421e6916852ade67b21f6a69a60d86939cb8dd 100644 (file)
@@ -27,6 +27,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <cmath>
 #include <SAnimatedMesh.h>
 #include "settings.h"
+#include "nodedef.h" // For wield visualization
+
+// In Irrlicht 1.8 the signature of ITexture::lock was changed from
+// (bool, u32) to (E_TEXTURE_LOCK_MODE, u32).
+#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 7
+#define MY_ETLM_READ_ONLY true
+#else
+#define MY_ETLM_READ_ONLY video::ETLM_READ_ONLY
+#endif
 
 Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control):
        m_smgr(smgr),
@@ -268,7 +277,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
 
        // Position the wielded item
        v3f wield_position = v3f(45, -35, 65);
-       v3f wield_rotation = v3f(-100, 110, -100);
+       v3f wield_rotation = v3f(-100, 120, -100);
        if (m_digging_button != -1)
        {
                f32 digfrac = m_digging_anim;
@@ -448,8 +457,11 @@ void Camera::updateSettings()
        m_wanted_frametime = 1.0 / wanted_fps;
 }
 
-void Camera::wield(const InventoryItem* item)
+void Camera::wield(const InventoryItem* item, IGameDef *gamedef)
 {
+       //ITextureSource *tsrc = gamedef->tsrc();
+       INodeDefManager *ndef = gamedef->ndef();
+
        if (item != NULL)
        {
                bool isCube = false;
@@ -460,11 +472,19 @@ void Camera::wield(const InventoryItem* item)
                        // A block-type material
                        MaterialItem* mat_item = (MaterialItem*) item;
                        content_t content = mat_item->getMaterial();
-                       if (content_features(content).solidness || content_features(content).visual_solidness)
-                       {
-                               m_wieldnode->setCube(content_features(content).tiles);
+                       switch(ndef->get(content).drawtype){
+                       case NDT_NORMAL:
+                       case NDT_LIQUID:
+                       case NDT_FLOWINGLIQUID:
+                       case NDT_GLASSLIKE:
+                       case NDT_ALLFACES:
+                       case NDT_ALLFACES_OPTIONAL:
+                               m_wieldnode->setCube(ndef->get(content).tiles);
                                m_wieldnode->setScale(v3f(30));
                                isCube = true;
+                               break;
+                       default:
+                               break;
                        }
                }
 
@@ -480,7 +500,9 @@ void Camera::wield(const InventoryItem* item)
        else
        {
                // Bare hands
-               m_wieldnode->setVisible(false);
+               m_wieldnode->setSprite(gamedef->tsrc()->getTextureRaw("wieldhand.png"));
+               m_wieldnode->setScale(v3f(40));
+               m_wieldnode->setVisible(true);
        }
 }
 
@@ -820,7 +842,7 @@ scene::IAnimatedMesh* ExtrudedSpriteSceneNode::extrude(video::ITexture* texture)
        {
                // Texture is in the correct color format, we can pass it
                // to extrudeARGB right away.
-               void* data = texture->lock(true);
+               void* data = texture->lock(MY_ETLM_READ_ONLY);
                if (data == NULL)
                        return NULL;
                mesh = extrudeARGB(size.Width, size.Height, (u8*) data);
@@ -830,7 +852,7 @@ scene::IAnimatedMesh* ExtrudedSpriteSceneNode::extrude(video::ITexture* texture)
        {
                video::IVideoDriver* driver = SceneManager->getVideoDriver();
 
-               video::IImage* img1 = driver->createImageFromData(format, size, texture->lock(true));
+               video::IImage* img1 = driver->createImageFromData(format, size, texture->lock(MY_ETLM_READ_ONLY));
                if (img1 == NULL)
                        return NULL;