Created
March 30, 2016 14:50
-
-
Save kahrl/e2f12da8f6dd62b3be6221c79bf62f8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp | |
index 6a83bd8..dbcc65e 100644 | |
--- a/src/content_mapblock.cpp | |
+++ b/src/content_mapblock.cpp | |
@@ -1376,8 +1376,8 @@ void mapblock_mesh_generate_special(MeshMakeData *data, | |
continue; | |
MapNode n_xy = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x + xz, y + y0, z)); | |
MapNode n_zy = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x, y + y0, z + xz)); | |
- ContentFeatures def_xy = nodedef->get(n_xy); | |
- ContentFeatures def_zy = nodedef->get(n_zy); | |
+ const ContentFeatures &def_xy = nodedef->get(n_xy); | |
+ const ContentFeatures &def_zy = nodedef->get(n_zy); | |
// Check if current node would connect with the rail | |
is_rail_x[index] = ((def_xy.drawtype == NDT_RAILLIKE | |
diff --git a/src/environment.cpp b/src/environment.cpp | |
index 902e2bd..34368b5 100644 | |
--- a/src/environment.cpp | |
+++ b/src/environment.cpp | |
@@ -2540,7 +2540,7 @@ void ClientEnvironment::step(float dtime) | |
// head | |
v3s16 p = floatToInt(pf + v3f(0, BS*1.6, 0), BS); | |
MapNode n = m_map->getNodeNoEx(p); | |
- ContentFeatures c = m_gamedef->ndef()->get(n); | |
+ const ContentFeatures &c = m_gamedef->ndef()->get(n); | |
u8 drowning_damage = c.drowning; | |
if(drowning_damage > 0 && lplayer->hp > 0){ | |
u16 breath = lplayer->getBreath(); | |
@@ -2565,7 +2565,7 @@ void ClientEnvironment::step(float dtime) | |
// head | |
v3s16 p = floatToInt(pf + v3f(0, BS*1.6, 0), BS); | |
MapNode n = m_map->getNodeNoEx(p); | |
- ContentFeatures c = m_gamedef->ndef()->get(n); | |
+ const ContentFeatures &c = m_gamedef->ndef()->get(n); | |
if (!lplayer->hp){ | |
lplayer->setBreath(11); | |
} | |
diff --git a/src/map.cpp b/src/map.cpp | |
index 4095042..1a7b561 100644 | |
--- a/src/map.cpp | |
+++ b/src/map.cpp | |
@@ -1675,7 +1675,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks) | |
s8 liquid_level = -1; | |
content_t liquid_kind = CONTENT_IGNORE; | |
content_t floodable_node = CONTENT_AIR; | |
- ContentFeatures cf = nodemgr->get(n0); | |
+ const ContentFeatures &cf = nodemgr->get(n0); | |
LiquidType liquid_type = cf.liquid_type; | |
switch (liquid_type) { | |
case LIQUID_SOURCE: | |
@@ -1721,7 +1721,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks) | |
} | |
v3s16 npos = p0 + dirs[i]; | |
NodeNeighbor nb(getNodeNoEx(npos), nt, npos); | |
- ContentFeatures cfnb = nodemgr->get(nb.n); | |
+ const ContentFeatures &cfnb = nodemgr->get(nb.n); | |
switch (nodemgr->get(nb.n.getContent()).liquid_type) { | |
case LIQUID_NONE: | |
if (cfnb.floodable) { | |
diff --git a/src/nodedef.h b/src/nodedef.h | |
index 58d0faf..870475f 100644 | |
--- a/src/nodedef.h | |
+++ b/src/nodedef.h | |
@@ -288,6 +288,9 @@ struct ContentFeatures | |
ContentFeatures(); | |
~ContentFeatures(); | |
+#if __cplusplus >= 201103L | |
+ explicit ContentFeatures(const ContentFeatures&) = default; | |
+#endif | |
void reset(); | |
void serialize(std::ostream &os, u16 protocol_version) const; | |
void deSerialize(std::istream &is); | |
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp | |
index 06e20c2..9bc17c9 100644 | |
--- a/src/script/common/c_content.cpp | |
+++ b/src/script/common/c_content.cpp | |
@@ -353,13 +353,11 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype) | |
} | |
/******************************************************************************/ | |
-ContentFeatures read_content_features(lua_State *L, int index) | |
+void read_content_features(lua_State *L, int index, ContentFeatures &f) | |
{ | |
if(index < 0) | |
index = lua_gettop(L) + 1 + index; | |
- ContentFeatures f; | |
- | |
/* Cache existence of some callbacks */ | |
lua_getfield(L, index, "on_construct"); | |
if(!lua_isnil(L, -1)) f.has_on_construct = true; | |
@@ -607,8 +605,6 @@ ContentFeatures read_content_features(lua_State *L, int index) | |
lua_pop(L, 1); | |
} | |
lua_pop(L, 1); | |
- | |
- return f; | |
} | |
/******************************************************************************/ | |
diff --git a/src/script/common/c_content.h b/src/script/common/c_content.h | |
index 46416ad..ab9d9f8 100644 | |
--- a/src/script/common/c_content.h | |
+++ b/src/script/common/c_content.h | |
@@ -62,7 +62,8 @@ struct NoiseParams; | |
class Schematic; | |
-ContentFeatures read_content_features (lua_State *L, int index); | |
+void read_content_features (lua_State *L, int index, | |
+ ContentFeatures &f); | |
TileDef read_tiledef (lua_State *L, int index, | |
u8 drawtype); | |
void read_soundspec (lua_State *L, int index, | |
diff --git a/src/script/lua_api/l_item.cpp b/src/script/lua_api/l_item.cpp | |
index 5381cba..5bd5ac8 100644 | |
--- a/src/script/lua_api/l_item.cpp | |
+++ b/src/script/lua_api/l_item.cpp | |
@@ -512,7 +512,8 @@ int ModApiItemMod::l_register_item_raw(lua_State *L) | |
// Read the node definition (content features) and register it | |
if(def.type == ITEM_NODE){ | |
- ContentFeatures f = read_content_features(L, table); | |
+ ContentFeatures f; | |
+ read_content_features(L, table, f); | |
content_t id = ndef->set(f.name, f); | |
if(id > MAX_REGISTERED_CONTENT){ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment