]> git.lizzy.rs Git - minetest.git/blobdiff - src/mapblock.cpp
Remove FPS from being next to the version string
[minetest.git] / src / mapblock.cpp
index e45af9cdbc6775db4481194634497d02f67e03cf..8e8961e10f9bd488ffc41870fe556490cda17a95 100644 (file)
@@ -43,10 +43,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 MapBlock::MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy):
-               heat(0),
-               humidity(0),
-               heat_last_update(0),
-               humidity_last_update(0),
                m_parent(parent),
                m_pos(pos),
                m_gamedef(gamedef),
@@ -68,7 +64,6 @@ MapBlock::MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy):
                reallocate();
        
 #ifndef SERVER
-       //mesh_mutex.Init();
        mesh = NULL;
 #endif
 }
@@ -457,10 +452,16 @@ s16 MapBlock::getGroundLevel(v2s16 p2d)
 */
 // List relevant id-name pairs for ids in the block using nodedef
 // Renumbers the content IDs (starting at 0 and incrementing
+// use static memory requires about 65535 * sizeof(int) ram in order to be
+// sure we can handle all content ids. But it's absolutely worth it as it's
+// a speedup of 4 for one of the major time consuming functions on storing
+// mapblocks.
+static content_t getBlockNodeIdMapping_mapping[USHRT_MAX];
 static void getBlockNodeIdMapping(NameIdMapping *nimap, MapNode *nodes,
                INodeDefManager *nodedef)
 {
-       std::map<content_t, content_t> mapping;
+       memset(getBlockNodeIdMapping_mapping, 0xFF, USHRT_MAX * sizeof(content_t));
+
        std::set<content_t> unknown_contents;
        content_t id_counter = 0;
        for(u32 i=0; i<MAP_BLOCKSIZE*MAP_BLOCKSIZE*MAP_BLOCKSIZE; i++)
@@ -469,16 +470,14 @@ static void getBlockNodeIdMapping(NameIdMapping *nimap, MapNode *nodes,
                content_t id = CONTENT_IGNORE;
 
                // Try to find an existing mapping
-               std::map<content_t, content_t>::iterator j = mapping.find(global_id);
-               if(j != mapping.end())
-               {
-                       id = j->second;
+               if (getBlockNodeIdMapping_mapping[global_id] != 0xFFFF) {
+                       id = getBlockNodeIdMapping_mapping[global_id];
                }
                else
                {
                        // We have to assign a new mapping
                        id = id_counter++;
-                       mapping.insert(std::make_pair(global_id, id));
+                       getBlockNodeIdMapping_mapping[global_id] = id;
 
                        const ContentFeatures &f = nodedef->get(global_id);
                        const std::string &name = f.name;
@@ -648,8 +647,8 @@ void MapBlock::serializeNetworkSpecific(std::ostream &os, u16 net_proto_version)
        if(net_proto_version >= 21){
                int version = 1;
                writeU8(os, version);
-               writeF1000(os, heat);
-               writeF1000(os, humidity);
+               writeF1000(os, 0); // deprecated heat
+               writeF1000(os, 0); // deprecated humidity
        }
 }
 
@@ -765,8 +764,8 @@ void MapBlock::deSerializeNetworkSpecific(std::istream &is)
                //if(version != 1)
                //      throw SerializationError("unsupported MapBlock version");
                if(version >= 1) {
-                       heat = readF1000(is);
-                       humidity = readF1000(is);
+                       readF1000(is); // deprecated heat
+                       readF1000(is); // deprecated humidity
                }
        }
        catch(SerializationError &e)