]> git.lizzy.rs Git - minetest.git/blobdiff - src/mapblockobject.cpp
hopefully fixed the privilege problems
[minetest.git] / src / mapblockobject.cpp
index 653dbc332b230309883c972e8e25fcfe86ab5a83..009163a18e1d834abfb6901cb34809f0f6b658e8 100644 (file)
@@ -17,12 +17,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
+// This file contains the DEPRECATED MapBlockObject system
+
 #include "mapblockobject.h"
 #include "mapblock.h"
-// Only for ::getNodeBox, TODO: Get rid of this
+// For object wrapping
 #include "map.h"
 #include "inventory.h"
-#include "irrlichtwrapper.h"
+#include "utility.h"
 
 /*
        MapBlockObject
@@ -35,7 +37,7 @@ v3f MapBlockObject::getAbsolutePos()
                return m_pos;
        
        // getPosRelative gets nodepos relative to map origin
-       v3f blockpos = intToFloat(m_block->getPosRelative());
+       v3f blockpos = intToFloat(m_block->getPosRelative(), BS);
        return blockpos + m_pos;
 }
 
@@ -55,13 +57,13 @@ v3f MovingObject::getAbsoluteShowPos()
                return m_pos;
        
        // getPosRelative gets nodepos relative to map origin
-       v3f blockpos = intToFloat(m_block->getPosRelative());
+       v3f blockpos = intToFloat(m_block->getPosRelative(), BS);
        return blockpos + m_showpos;
 }
 
 void MovingObject::move(float dtime, v3f acceleration)
 {
-       DSTACK("%s: typeid=%i, pos=(%f,%f,%f), speed=(%f,%f,%f)"
+       DSTACKF("%s: typeid=%i, pos=(%f,%f,%f), speed=(%f,%f,%f)"
                        ", dtime=%f, acc=(%f,%f,%f)",
                        __FUNCTION_NAME,
                        getTypeId(),
@@ -71,7 +73,7 @@ void MovingObject::move(float dtime, v3f acceleration)
                        acceleration.X, acceleration.Y, acceleration.Z
                        );
        
-       v3s16 oldpos_i = floatToInt(m_pos);
+       v3s16 oldpos_i = floatToInt(m_pos, BS);
        
        if(m_block->isValidPosition(oldpos_i) == false)
        {
@@ -137,7 +139,7 @@ void MovingObject::move(float dtime, v3f acceleration)
                        Collision detection
                */
                
-               v3s16 pos_i = floatToInt(position);
+               v3s16 pos_i = floatToInt(position, BS);
                
                // The loop length is limited to the object moving a distance
                f32 d = (float)BS * 0.15;
@@ -168,8 +170,7 @@ void MovingObject::move(float dtime, v3f acceleration)
                                // walking over map borders
                        }
 
-                       core::aabbox3d<f32> nodebox = Map::getNodeBox(
-                                       v3s16(x,y,z));
+                       core::aabbox3d<f32> nodebox = getNodeBox(v3s16(x,y,z), BS);
                        
                        // See if the object is touching ground
                        if(
@@ -282,7 +283,7 @@ void RatObject::addToScene(scene::ISceneManager *smgr)
        buf->getMaterial().setFlag(video::EMF_LIGHTING, false);
        buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false);
        buf->getMaterial().setTexture
-                       (0, driver->getTexture("../data/rat.png"));
+                       (0, driver->getTexture(getTexturePath("rat.png").c_str()));
        buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
        buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
        buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
@@ -359,8 +360,6 @@ video::ITexture * ItemObject::getItemImage()
        InventoryItem *item = createInventoryItem();
        if(item)
                texture = item->getImage();
-       /*else
-               texture = g_irrlicht->getTexture("../data/cloud.png");*/
        if(item)
                delete item;
        return texture;
@@ -414,7 +413,7 @@ void PlayerObject::addToScene(scene::ISceneManager *smgr)
        // 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().setTexture(0, driver->getTexture(getTexturePath("player.png").c_str()));
        buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false);
        buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true);
        //buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
@@ -438,7 +437,7 @@ void PlayerObject::addToScene(scene::ISceneManager *smgr)
        // 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().setTexture(0, driver->getTexture(getTexturePath("player_back.png").c_str()));
        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;
@@ -614,7 +613,7 @@ void MapBlockObjectList::update(std::istream &is, u8 version,
                {
                        u8 light = LIGHT_MAX;
                        try{
-                               v3s16 relpos_i = floatToInt(obj->m_pos);
+                               v3s16 relpos_i = floatToInt(obj->m_pos, BS);
                                MapNode n = m_block->getNodeParent(relpos_i);
                                light = n.getLightBlend(daynight_ratio);
                        }
@@ -756,7 +755,7 @@ void MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio)
        core::map<s16, bool> ids_to_delete;
 
        {
-               DSTACK("%s: stepping objects", __FUNCTION_NAME);
+               DSTACKF("%s: stepping objects", __FUNCTION_NAME);
 
                for(core::map<s16, MapBlockObject*>::Iterator
                                i = m_objects.getIterator();
@@ -764,7 +763,7 @@ void MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio)
                {
                        MapBlockObject *obj = i.getNode()->getValue();
                        
-                       DSTACK("%s: stepping object type %i", __FUNCTION_NAME,
+                       DSTACKF("%s: stepping object type %i", __FUNCTION_NAME,
                                        obj->getTypeId());
 
                        if(server)
@@ -772,7 +771,7 @@ void MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio)
                                // Update light
                                u8 light = LIGHT_MAX;
                                try{
-                                       v3s16 relpos_i = floatToInt(obj->m_pos);
+                                       v3s16 relpos_i = floatToInt(obj->m_pos, BS);
                                        MapNode n = m_block->getNodeParent(relpos_i);
                                        light = n.getLightBlend(daynight_ratio);
                                }
@@ -792,7 +791,7 @@ void MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio)
        }
 
        {
-               DSTACK("%s: deleting objects", __FUNCTION_NAME);
+               DSTACKF("%s: deleting objects", __FUNCTION_NAME);
 
                // Delete objects in delete queue
                for(core::map<s16, bool>::Iterator
@@ -816,7 +815,7 @@ void MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio)
                return;
        
        {
-               DSTACK("%s: object wrap loop", __FUNCTION_NAME);
+               DSTACKF("%s: object wrap loop", __FUNCTION_NAME);
 
                for(core::map<s16, MapBlockObject*>::Iterator
                                i = m_objects.getIterator();
@@ -824,7 +823,7 @@ void MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio)
                {
                        MapBlockObject *obj = i.getNode()->getValue();
 
-                       v3s16 pos_i = floatToInt(obj->m_pos);
+                       v3s16 pos_i = floatToInt(obj->m_pos, BS);
 
                        if(m_block->isValidPosition(pos_i))
                        {
@@ -871,7 +870,7 @@ bool MapBlockObjectList::wrapObject(MapBlockObject *object)
        // Calculate blockpos on map
        v3s16 oldblock_pos_i_on_map = m_block->getPosRelative();
        v3f pos_f_on_oldblock = object->m_pos;
-       v3s16 pos_i_on_oldblock = floatToInt(pos_f_on_oldblock);
+       v3s16 pos_i_on_oldblock = floatToInt(pos_f_on_oldblock, BS);
        v3s16 pos_i_on_map = pos_i_on_oldblock + oldblock_pos_i_on_map;
        v3s16 pos_blocks_on_map = getNodeBlockPos(pos_i_on_map);
 
@@ -905,9 +904,9 @@ bool MapBlockObjectList::wrapObject(MapBlockObject *object)
        }
        
        // Calculate position on new block
-       v3f oldblock_pos_f_on_map = intToFloat(oldblock_pos_i_on_map);
+       v3f oldblock_pos_f_on_map = intToFloat(oldblock_pos_i_on_map, BS);
        v3s16 newblock_pos_i_on_map = newblock->getPosRelative();
-       v3f newblock_pos_f_on_map = intToFloat(newblock_pos_i_on_map);
+       v3f newblock_pos_f_on_map = intToFloat(newblock_pos_i_on_map, BS);
        v3f pos_f_on_newblock = pos_f_on_oldblock
                        - newblock_pos_f_on_map + oldblock_pos_f_on_map;