From 20ae2ead8f445eae9164cdb2eaa5dfd43cce11a5 Mon Sep 17 00:00:00 2001 From: darkrose Date: Mon, 18 Aug 2014 02:37:05 +1000 Subject: [PATCH] some optimisations and tweaks --- src/client.cpp | 9 --------- src/mapblock_mesh.cpp | 45 +++--------------------------------------- src/mapblock_nodemod.h | 2 +- src/voxel.cpp | 16 +++++++-------- src/voxel.h | 10 ---------- 5 files changed, 12 insertions(+), 70 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index c7c0cd4..6cb2cfb 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -881,15 +881,6 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) block->deSerialize(istr, ser_version); sector->insertBlock(block); - //DEBUG - /*NodeMod mod; - mod.type = NODEMOD_CHANGECONTENT; - mod.param = CONTENT_MESE; - block->setTempMod(v3s16(8,10,8), mod); - block->setTempMod(v3s16(8,9,8), mod); - block->setTempMod(v3s16(8,8,8), mod); - block->setTempMod(v3s16(8,7,8), mod); - block->setTempMod(v3s16(8,6,8), mod);*/ } #if 0 diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index 8673896..8079935 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -249,10 +249,6 @@ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir, */ NodeMod mod; if (temp_mods.get(p, &mod)) { - if (mod == NODEMOD_CHANGECONTENT) { - MapNode mn2(mod.param); - spec = mn2.getTile(face_dir); - } if (mod == NODEMOD_CRACK) { /* Get texture id, translate it to name, append stuff to @@ -306,10 +302,6 @@ TileSpec getMetaTile(MapNode mn, v3s16 p, v3s16 face_dir, */ NodeMod mod; if (temp_mods.get(p, &mod)) { - if (mod == NODEMOD_CHANGECONTENT) { - MapNode mn2(mod.param); - spec = mn2.getMetaTile(face_dir); - } if (mod == NODEMOD_CRACK) { /* Get texture id, translate it to name, append stuff to @@ -348,32 +340,6 @@ TileSpec getMetaTile(MapNode mn, v3s16 p, v3s16 face_dir, return spec; } -content_t getNodeContent(v3s16 p, MapNode mn, NodeModMap &temp_mods) -{ - /* - Check temporary modifications on this node - */ - NodeMod mod; - if (temp_mods.get(p, &mod)) { - if(mod == NODEMOD_CHANGECONTENT) - return mod.param; - /*if(mod.type == NODEMOD_CRACK) - { - Content doesn't change. - - face_contents works just like it should, because - there should not be faces between differently cracked - nodes. - - If a semi-transparent node is cracked in front an - another one, it really doesn't matter whether there - is a cracked face drawn in between or not. - }*/ - } - - return mn.getContent(); -} - v3s16 dirs8[8] = { v3s16(0,0,0), v3s16(0,0,1), @@ -468,14 +434,9 @@ void getTileInfo( { MapNode n0 = vmanip.getNodeNoEx(blockpos_nodes + p); MapNode n1 = vmanip.getNodeNoEx(blockpos_nodes + p + face_dir); - TileSpec tile0 = getNodeTile(n0, p, face_dir, temp_mods); - TileSpec tile1 = getNodeTile(n1, p + face_dir, -face_dir, temp_mods); - // This is hackish - content_t content0 = getNodeContent(p, n0, temp_mods); - content_t content1 = getNodeContent(p + face_dir, n1, temp_mods); bool equivalent = false; - u8 mf = face_contents(content0, content1, &equivalent); + u8 mf = face_contents(n0.getContent(), n1.getContent(), &equivalent); if (mf == 0) { makes_face = false; @@ -485,11 +446,11 @@ void getTileInfo( makes_face = true; if (mf == 1) { - tile = tile0; + tile = getNodeTile(n0, p, face_dir, temp_mods); p_corrected = p; face_dir_corrected = face_dir; }else{ - tile = tile1; + tile = getNodeTile(n1, p + face_dir, -face_dir, temp_mods); p_corrected = p + face_dir; face_dir_corrected = -face_dir; } diff --git a/src/mapblock_nodemod.h b/src/mapblock_nodemod.h index 4720ba9..5ce602b 100644 --- a/src/mapblock_nodemod.h +++ b/src/mapblock_nodemod.h @@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc., enum NodeModType { NODEMOD_NONE = 0x0, - NODEMOD_CHANGECONTENT = 0x01, //param is content id + NODEMOD_UNUSED = 0x01, // used to be CHANGECONTENT - no longer used NODEMOD_CRACK = 0x02, // param is crack progression NODEMOD_SELECTION = 0x04 // param is ignored }; diff --git a/src/voxel.cpp b/src/voxel.cpp index 74303f7..c3e4237 100644 --- a/src/voxel.cpp +++ b/src/voxel.cpp @@ -186,11 +186,10 @@ void VoxelManipulator::addArea(VoxelArea area) // Allocate and clear new data MapNode *new_data = new MapNode[new_size]; + assert(new_data); u8 *new_flags = new u8[new_size]; - for(s32 i=0; i