Clean mapnode.h and fix other files accordingly
authorPerttu Ahola <celeron55@gmail.com>
Tue, 15 Nov 2011 19:00:39 +0000 (21:00 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 29 Nov 2011 17:13:44 +0000 (19:13 +0200)
15 files changed:
src/client.h
src/content_cao.cpp
src/content_mapnode.cpp
src/content_nodemeta.cpp
src/content_sao.cpp
src/farmesh.cpp
src/inventory.cpp
src/inventory.h
src/map.h
src/mapblock_mesh.cpp
src/mapnode.cpp
src/mapnode.h
src/player.cpp
src/player.h
src/server.h

index 148acc0721d08b0fd543fcd2d2351a1cc9ff094c..b160a3bc914a1520169138bb4ef993f8f4dfc3ce 100644 (file)
@@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 struct MeshMakeData;
 class IGameDef;
+class IWritableTextureSource;
 class IWritableToolDefManager;
 class IWritableNodeDefManager;
 
index c6ec0761a07e1295af1988e22460bb2a23692383..bd99787c072ff98b504c4f182e1d7533c4456475 100644 (file)
@@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "environment.h"
 #include "settings.h"
 #include <ICameraSceneNode.h>
+#include "serialization.h" // For decompressZlib
 
 core::map<u16, ClientActiveObject::Factory> ClientActiveObject::m_types;
 
index 58eaff108679e21bea491e51b910e558c131941a..1ef3fe0d14f4990d7e629502ee452bb25633d50e 100644 (file)
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "mapnode.h"
 #include "content_nodemeta.h"
 #include "nodedef.h"
+#include "utility.h"
 
 #define WATER_ALPHA 160
 
index adaee33b4a792c128bcda00dcbfa49e90baebd64..50dcbd080c0866595e50184a09439754a12355f1 100644 (file)
@@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "inventory.h"
 #include "content_mapnode.h"
 #include "log.h"
+#include "utility.h"
 
 /*
        SignNodeMetadata
index a7cee83ab1807e9f0e741304521c381717683f63..dc112275fe6c22b78c70c3099c9ab461139ace1b 100644 (file)
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "settings.h"
 #include "main.h" // For g_profiler
 #include "profiler.h"
+#include "serialization.h" // For compressZlib
 
 core::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types;
 
index 8f91e3a1ab4ddc427cf05a3032acb04e16549d1c..fdc81057bc27fe52897fbf0282e984b748e74864 100644 (file)
@@ -23,13 +23,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 #include "farmesh.h"
+
 #include "constants.h"
 #include "debug.h"
 #include "noise.h"
 #include "map.h"
 #include "client.h"
+#include "tile.h" // ITextureSource
 
-#include "mapgen.h"
+#include "mapgen.h" // Shouldn't really be done this way
 
 FarMesh::FarMesh(
                scene::ISceneNode* parent,
@@ -47,7 +49,7 @@ FarMesh::FarMesh(
 {
        dstream<<__FUNCTION_NAME<<std::endl;
        
-       video::IVideoDriver* driver = mgr->getVideoDriver();
+       //video::IVideoDriver* driver = mgr->getVideoDriver();
 
        m_materials[0].setFlag(video::EMF_LIGHTING, false);
        m_materials[0].setFlag(video::EMF_BACK_FACE_CULLING, true);
@@ -62,8 +64,7 @@ FarMesh::FarMesh(
        m_materials[1].setFlag(video::EMF_BACK_FACE_CULLING, false);
        m_materials[1].setFlag(video::EMF_BILINEAR_FILTER, false);
        m_materials[1].setFlag(video::EMF_FOG_ENABLE, false);
-       m_materials[1].setTexture
-                       (0, driver->getTexture(getTexturePath("treeprop.png").c_str()));
+       m_materials[1].setTexture(0, client->tsrc()->getTextureRaw("treeprop.png"));
        m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
        m_materials[1].setFlag(video::EMF_FOG_ENABLE, true);
 
index 8ddbd3ac8add37e1ad0e83b170ee76a357a3fddf..1929761a58213897a00fa4637f08df0784f4c6af 100644 (file)
@@ -800,6 +800,28 @@ static std::string describeC(const struct InventoryContext *c)
                return std::string("current_player=") + c->current_player->getName();
 }
 
+IMoveAction::IMoveAction(std::istream &is)
+{
+       std::string ts;
+
+       std::getline(is, ts, ' ');
+       count = stoi(ts);
+
+       std::getline(is, from_inv, ' ');
+
+       std::getline(is, from_list, ' ');
+
+       std::getline(is, ts, ' ');
+       from_i = stoi(ts);
+
+       std::getline(is, to_inv, ' ');
+
+       std::getline(is, to_list, ' ');
+
+       std::getline(is, ts, ' ');
+       to_i = stoi(ts);
+}
+
 void IMoveAction::apply(InventoryContext *c, InventoryManager *mgr)
 {
        Inventory *inv_from = mgr->getInventory(c, from_inv);
index 29b97ccad95b6e2be7dc5ddf343b03846e728069..5401ff1b947f32977754a4679bea28eeabb9a63c 100644 (file)
@@ -520,27 +520,8 @@ struct IMoveAction : public InventoryAction
                from_i = -1;
                to_i = -1;
        }
-       IMoveAction(std::istream &is)
-       {
-               std::string ts;
-
-               std::getline(is, ts, ' ');
-               count = stoi(ts);
-
-               std::getline(is, from_inv, ' ');
-
-               std::getline(is, from_list, ' ');
-
-               std::getline(is, ts, ' ');
-               from_i = stoi(ts);
-
-               std::getline(is, to_inv, ' ');
-
-               std::getline(is, to_list, ' ');
-
-               std::getline(is, ts, ' ');
-               to_i = stoi(ts);
-       }
+       
+       IMoveAction(std::istream &is);
 
        u16 getType() const
        {
index 3def571b8189a5c3c65127032ba20f53d9fbf689..413a7fc05453d37d9a86a3caec9ab8ada9e91d6f 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "mapblock_nodemod.h"
 #include "constants.h"
 #include "voxel.h"
+#include "utility.h" // Needed for UniqueQueue, a member of Map
 
 extern "C" {
        #include "sqlite3.h"
index 5d8c0b737474cf322a9c0b88d43839a53e361bf3..c051dda5046b816e630aeca69d1124db45a254cb 100644 (file)
@@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "tile.h"
 #include "gamedef.h"
 #include "content_mapblock.h"
+#include "mineral.h" // For mineral_block_texture
 
 void MeshMakeData::fill(u32 daynight_ratio, MapBlock *block)
 {
@@ -249,6 +250,61 @@ static void makeFastFace(TileSpec tile, u8 li0, u8 li1, u8 li2, u8 li3, v3f p,
        dest.push_back(face);
 }
        
+static TileSpec getTile(const MapNode &node, v3s16 dir,
+               ITextureSource *tsrc, INodeDefManager *nodemgr)
+{
+       const ContentFeatures &f = nodemgr->get(node);
+       
+       if(f.param_type == CPT_FACEDIR_SIMPLE)
+               dir = facedir_rotate(node.param1, dir);
+       
+       TileSpec spec;
+       
+       s32 dir_i = -1;
+       
+       if(dir == v3s16(0,0,0))
+               dir_i = -1;
+       else if(dir == v3s16(0,1,0))
+               dir_i = 0;
+       else if(dir == v3s16(0,-1,0))
+               dir_i = 1;
+       else if(dir == v3s16(1,0,0))
+               dir_i = 2;
+       else if(dir == v3s16(-1,0,0))
+               dir_i = 3;
+       else if(dir == v3s16(0,0,1))
+               dir_i = 4;
+       else if(dir == v3s16(0,0,-1))
+               dir_i = 5;
+       
+       if(dir_i == -1)
+               // Non-directional
+               spec = f.tiles[0];
+       else 
+               spec = f.tiles[dir_i];
+       
+       /*
+               If it contains some mineral, change texture id
+       */
+       if(f.param_type == CPT_MINERAL && tsrc)
+       {
+               u8 mineral = node.getMineral(nodemgr);
+               std::string mineral_texture_name = mineral_block_texture(mineral);
+               if(mineral_texture_name != "")
+               {
+                       u32 orig_id = spec.texture.id;
+                       std::string texture_name = tsrc->getTextureName(orig_id);
+                       //texture_name += "^blit:";
+                       texture_name += "^";
+                       texture_name += mineral_texture_name;
+                       u32 new_id = tsrc->getTextureId(texture_name);
+                       spec.texture = tsrc->getTexture(new_id);
+               }
+       }
+
+       return spec;
+}
+
 /*
        Gets node tile from any place relative to block.
        Returns TILE_NODE if doesn't exist or should not be drawn.
@@ -257,7 +313,7 @@ static TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir,
                NodeModMap &temp_mods, ITextureSource *tsrc, INodeDefManager *ndef)
 {
        TileSpec spec;
-       spec = mn.getTile(face_dir, tsrc, ndef);
+       spec = getTile(mn, face_dir, tsrc, ndef);
        
        /*
                Check temporary modifications on this node
@@ -274,7 +330,7 @@ static TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir,
                if(mod.type == NODEMOD_CHANGECONTENT)
                {
                        MapNode mn2(mod.param);
-                       spec = mn2.getTile(face_dir, tsrc, ndef);
+                       spec = getTile(mn2, face_dir, tsrc, ndef);
                }
                if(mod.type == NODEMOD_CRACK)
                {
index 1e8915b03035adb1d48904ec388ce5a49f83ab24..2fbc81dd28d4fc984b59f470ecb6adf5aa7cb272 100644 (file)
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "main.h" // For g_settings
 #include "nodedef.h"
 #include "content_mapnode.h" // For mapnode_translate_*_internal
+#include "serialization.h" // For ser_ver_supported
 
 #ifndef SERVER
 /*
@@ -208,61 +209,6 @@ u8 MapNode::getLightBanksWithSource(INodeDefManager *nodemgr) const
        return (lightday&0x0f) | ((lightnight<<4)&0xf0);
 }
 
-#ifndef SERVER
-TileSpec MapNode::getTile(v3s16 dir, ITextureSource *tsrc,
-               INodeDefManager *nodemgr) const
-{
-       if(nodemgr->get(*this).param_type == CPT_FACEDIR_SIMPLE)
-               dir = facedir_rotate(param1, dir);
-       
-       TileSpec spec;
-       
-       s32 dir_i = -1;
-       
-       if(dir == v3s16(0,0,0))
-               dir_i = -1;
-       else if(dir == v3s16(0,1,0))
-               dir_i = 0;
-       else if(dir == v3s16(0,-1,0))
-               dir_i = 1;
-       else if(dir == v3s16(1,0,0))
-               dir_i = 2;
-       else if(dir == v3s16(-1,0,0))
-               dir_i = 3;
-       else if(dir == v3s16(0,0,1))
-               dir_i = 4;
-       else if(dir == v3s16(0,0,-1))
-               dir_i = 5;
-       
-       if(dir_i == -1)
-               // Non-directional
-               spec = nodemgr->get(*this).tiles[0];
-       else 
-               spec = nodemgr->get(*this).tiles[dir_i];
-       
-       /*
-               If it contains some mineral, change texture id
-       */
-       if(nodemgr->get(*this).param_type == CPT_MINERAL && tsrc)
-       {
-               u8 mineral = getMineral(nodemgr);
-               std::string mineral_texture_name = mineral_block_texture(mineral);
-               if(mineral_texture_name != "")
-               {
-                       u32 orig_id = spec.texture.id;
-                       std::string texture_name = tsrc->getTextureName(orig_id);
-                       //texture_name += "^blit:";
-                       texture_name += "^";
-                       texture_name += mineral_texture_name;
-                       u32 new_id = tsrc->getTextureId(texture_name);
-                       spec.texture = tsrc->getTexture(new_id);
-               }
-       }
-
-       return spec;
-}
-#endif
-
 u8 MapNode::getMineral(INodeDefManager *nodemgr) const
 {
        if(nodemgr->get(*this).param_type == CPT_MINERAL)
index 7fe2054631fb31d1b8b1cd5449386bb2399ad5e6..12dbf45c52fe18b1b47e8a6b22cf86b71939fb76 100644 (file)
@@ -20,14 +20,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #ifndef MAPNODE_HEADER
 #define MAPNODE_HEADER
 
-#include <iostream>
 #include "irrlichttypes.h"
 #include "light.h"
-#include "exceptions.h"
-#include "serialization.h"
-#ifndef SERVER
-#include "tile.h"
-#endif
 
 class INodeDefManager;
 
@@ -215,18 +209,6 @@ struct MapNode
                return mix;
        }*/
 
-       // In mapnode.cpp
-#ifndef SERVER
-       /*
-               Get tile of a face of the node.
-               dir: direction of face
-               Returns: TileSpec. Can contain miscellaneous texture coordinates,
-                        which must be obeyed so that the texture atlas can be used.
-       */
-       TileSpec getTile(v3s16 dir, ITextureSource *tsrc,
-                       INodeDefManager *nodemgr) const;
-#endif
-       
        /*
                Gets mineral content of node, if there is any.
                MINERAL_NONE if doesn't contain or isn't able to contain mineral.
index 8e73f350150edb3f318b5a98fc7ceb6795acd283..4dc7ff21961fd6eade0a0d73ff490c99524ed1b2 100644 (file)
@@ -108,6 +108,11 @@ void Player::accelerate(v3f target_speed, f32 max_increase)
 #endif
 }
 
+v3s16 Player::getLightPosition() const
+{
+       return floatToInt(m_position + v3f(0,BS+BS/2,0), BS);
+}
+
 void Player::serialize(std::ostream &os)
 {
        // Utilize a Settings object for storing values
index ecde59ce1931b6c5cd554536da070c62b198dd50..56bb5083cce17adb84ed678e0b167689f6689d80 100644 (file)
@@ -62,10 +62,7 @@ public:
                return m_position;
        }
 
-       v3s16 getLightPosition() const
-       {
-               return floatToInt(m_position + v3f(0,BS+BS/2,0), BS);
-       }
+       v3s16 getLightPosition() const;
 
        v3f getEyeOffset()
        {
index a8cdd1a85ef080b231b28364aca1670807f6ec78..4ba28e3322fbb3c733b3f83ae9846a50395de23b 100644 (file)
@@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "auth.h"
 #include "ban.h"
 #include "gamedef.h"
+#include "serialization.h" // For SER_FMT_VER_INVALID
 struct LuaState;
 typedef struct lua_State lua_State;
 class IWritableToolDefManager;