Remove a few unused functions reported by callcatcher (#11658)

This commit is contained in:
SmallJoker 2021-10-12 20:12:20 +02:00 committed by GitHub
parent 6de8d77e17
commit ecc6f4ba25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 6 additions and 799 deletions

@ -142,11 +142,6 @@ u32 ChatBuffer::getRows() const
return m_rows;
}
void ChatBuffer::scrollTop()
{
m_scroll = getTopScrollPos();
}
void ChatBuffer::reformat(u32 cols, u32 rows)
{
if (cols == 0 || rows == 0)

@ -110,8 +110,6 @@ public:
void scrollAbsolute(s32 scroll);
// Scroll to bottom of buffer (newest)
void scrollBottom();
// Scroll to top of buffer (oldest)
void scrollTop();
// Functions for keeping track of whether the lines were modified by any
// preceding operations

@ -498,592 +498,3 @@ scene::IMesh* convertNodeboxesToMesh(const std::vector<aabb3f> &boxes,
}
return dst_mesh;
}
struct vcache
{
core::array<u32> tris;
float score;
s16 cachepos;
u16 NumActiveTris;
};
struct tcache
{
u16 ind[3];
float score;
bool drawn;
};
const u16 cachesize = 32;
float FindVertexScore(vcache *v)
{
const float CacheDecayPower = 1.5f;
const float LastTriScore = 0.75f;
const float ValenceBoostScale = 2.0f;
const float ValenceBoostPower = 0.5f;
const float MaxSizeVertexCache = 32.0f;
if (v->NumActiveTris == 0)
{
// No tri needs this vertex!
return -1.0f;
}
float Score = 0.0f;
int CachePosition = v->cachepos;
if (CachePosition < 0)
{
// Vertex is not in FIFO cache - no score.
}
else
{
if (CachePosition < 3)
{
// This vertex was used in the last triangle,
// so it has a fixed score.
Score = LastTriScore;
}
else
{
// Points for being high in the cache.
const float Scaler = 1.0f / (MaxSizeVertexCache - 3);
Score = 1.0f - (CachePosition - 3) * Scaler;
Score = powf(Score, CacheDecayPower);
}
}
// Bonus points for having a low number of tris still to
// use the vert, so we get rid of lone verts quickly.
float ValenceBoost = powf(v->NumActiveTris,
-ValenceBoostPower);
Score += ValenceBoostScale * ValenceBoost;
return Score;
}
/*
A specialized LRU cache for the Forsyth algorithm.
*/
class f_lru
{
public:
f_lru(vcache *v, tcache *t): vc(v), tc(t)
{
for (int &i : cache) {
i = -1;
}
}
// Adds this vertex index and returns the highest-scoring triangle index
u32 add(u16 vert, bool updatetris = false)
{
bool found = false;
// Mark existing pos as empty
for (u16 i = 0; i < cachesize; i++)
{
if (cache[i] == vert)
{
// Move everything down
for (u16 j = i; j; j--)
{
cache[j] = cache[j - 1];
}
found = true;
break;
}
}
if (!found)
{
if (cache[cachesize-1] != -1)
vc[cache[cachesize-1]].cachepos = -1;
// Move everything down
for (u16 i = cachesize - 1; i; i--)
{
cache[i] = cache[i - 1];
}
}
cache[0] = vert;
u32 highest = 0;
float hiscore = 0;
if (updatetris)
{
// Update cache positions
for (u16 i = 0; i < cachesize; i++)
{
if (cache[i] == -1)
break;
vc[cache[i]].cachepos = i;
vc[cache[i]].score = FindVertexScore(&vc[cache[i]]);
}
// Update triangle scores
for (int i : cache) {
if (i == -1)
break;
const u16 trisize = vc[i].tris.size();
for (u16 t = 0; t < trisize; t++)
{
tcache *tri = &tc[vc[i].tris[t]];
tri->score =
vc[tri->ind[0]].score +
vc[tri->ind[1]].score +
vc[tri->ind[2]].score;
if (tri->score > hiscore)
{
hiscore = tri->score;
highest = vc[i].tris[t];
}
}
}
}
return highest;
}
private:
s32 cache[cachesize];
vcache *vc;
tcache *tc;
};
/**
Vertex cache optimization according to the Forsyth paper:
http://home.comcast.net/~tom_forsyth/papers/fast_vert_cache_opt.html
The function is thread-safe (read: you can optimize several meshes in different threads)
\param mesh Source mesh for the operation. */
scene::IMesh* createForsythOptimizedMesh(const scene::IMesh *mesh)
{
if (!mesh)
return 0;
scene::SMesh *newmesh = new scene::SMesh();
newmesh->BoundingBox = mesh->getBoundingBox();
const u32 mbcount = mesh->getMeshBufferCount();
for (u32 b = 0; b < mbcount; ++b)
{
const scene::IMeshBuffer *mb = mesh->getMeshBuffer(b);
if (mb->getIndexType() != video::EIT_16BIT)
{
//os::Printer::log("Cannot optimize a mesh with 32bit indices", ELL_ERROR);
newmesh->drop();
return 0;
}
const u32 icount = mb->getIndexCount();
const u32 tcount = icount / 3;
const u32 vcount = mb->getVertexCount();
const u16 *ind = mb->getIndices();
vcache *vc = new vcache[vcount];
tcache *tc = new tcache[tcount];
f_lru lru(vc, tc);
// init
for (u16 i = 0; i < vcount; i++)
{
vc[i].score = 0;
vc[i].cachepos = -1;
vc[i].NumActiveTris = 0;
}
// First pass: count how many times a vert is used
for (u32 i = 0; i < icount; i += 3)
{
vc[ind[i]].NumActiveTris++;
vc[ind[i + 1]].NumActiveTris++;
vc[ind[i + 2]].NumActiveTris++;
const u32 tri_ind = i/3;
tc[tri_ind].ind[0] = ind[i];
tc[tri_ind].ind[1] = ind[i + 1];
tc[tri_ind].ind[2] = ind[i + 2];
}
// Second pass: list of each triangle
for (u32 i = 0; i < tcount; i++)
{
vc[tc[i].ind[0]].tris.push_back(i);
vc[tc[i].ind[1]].tris.push_back(i);
vc[tc[i].ind[2]].tris.push_back(i);
tc[i].drawn = false;
}
// Give initial scores
for (u16 i = 0; i < vcount; i++)
{
vc[i].score = FindVertexScore(&vc[i]);
}
for (u32 i = 0; i < tcount; i++)
{
tc[i].score =
vc[tc[i].ind[0]].score +
vc[tc[i].ind[1]].score +
vc[tc[i].ind[2]].score;
}
switch(mb->getVertexType())
{
case video::EVT_STANDARD:
{
video::S3DVertex *v = (video::S3DVertex *) mb->getVertices();
scene::SMeshBuffer *buf = new scene::SMeshBuffer();
buf->Material = mb->getMaterial();
buf->Vertices.reallocate(vcount);
buf->Indices.reallocate(icount);
core::map<const video::S3DVertex, const u16> sind; // search index for fast operation
typedef core::map<const video::S3DVertex, const u16>::Node snode;
// Main algorithm
u32 highest = 0;
u32 drawcalls = 0;
for (;;)
{
if (tc[highest].drawn)
{
bool found = false;
float hiscore = 0;
for (u32 t = 0; t < tcount; t++)
{
if (!tc[t].drawn)
{
if (tc[t].score > hiscore)
{
highest = t;
hiscore = tc[t].score;
found = true;
}
}
}
if (!found)
break;
}
// Output the best triangle
u16 newind = buf->Vertices.size();
snode *s = sind.find(v[tc[highest].ind[0]]);
if (!s)
{
buf->Vertices.push_back(v[tc[highest].ind[0]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[0]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
}
s = sind.find(v[tc[highest].ind[1]]);
if (!s)
{
buf->Vertices.push_back(v[tc[highest].ind[1]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[1]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
}
s = sind.find(v[tc[highest].ind[2]]);
if (!s)
{
buf->Vertices.push_back(v[tc[highest].ind[2]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[2]], newind);
}
else
{
buf->Indices.push_back(s->getValue());
}
vc[tc[highest].ind[0]].NumActiveTris--;
vc[tc[highest].ind[1]].NumActiveTris--;
vc[tc[highest].ind[2]].NumActiveTris--;
tc[highest].drawn = true;
for (u16 j : tc[highest].ind) {
vcache *vert = &vc[j];
for (u16 t = 0; t < vert->tris.size(); t++)
{
if (highest == vert->tris[t])
{
vert->tris.erase(t);
break;
}
}
}
lru.add(tc[highest].ind[0]);
lru.add(tc[highest].ind[1]);
highest = lru.add(tc[highest].ind[2], true);
drawcalls++;
}
buf->setBoundingBox(mb->getBoundingBox());
newmesh->addMeshBuffer(buf);
buf->drop();
}
break;
case video::EVT_2TCOORDS:
{
video::S3DVertex2TCoords *v = (video::S3DVertex2TCoords *) mb->getVertices();
scene::SMeshBufferLightMap *buf = new scene::SMeshBufferLightMap();
buf->Material = mb->getMaterial();
buf->Vertices.reallocate(vcount);
buf->Indices.reallocate(icount);
core::map<const video::S3DVertex2TCoords, const u16> sind; // search index for fast operation
typedef core::map<const video::S3DVertex2TCoords, const u16>::Node snode;
// Main algorithm
u32 highest = 0;
u32 drawcalls = 0;
for (;;)
{
if (tc[highest].drawn)
{
bool found = false;
float hiscore = 0;
for (u32 t = 0; t < tcount; t++)
{
if (!tc[t].drawn)
{
if (tc[t].score > hiscore)
{
highest = t;
hiscore = tc[t].score;
found = true;
}
}
}
if (!found)
break;
}
// Output the best triangle
u16 newind = buf->Vertices.size();
snode *s = sind.find(v[tc[highest].ind[0]]);
if (!s)
{
buf->Vertices.push_back(v[tc[highest].ind[0]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[0]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
}
s = sind.find(v[tc[highest].ind[1]]);
if (!s)
{
buf->Vertices.push_back(v[tc[highest].ind[1]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[1]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
}
s = sind.find(v[tc[highest].ind[2]]);
if (!s)
{
buf->Vertices.push_back(v[tc[highest].ind[2]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[2]], newind);
}
else
{
buf->Indices.push_back(s->getValue());
}
vc[tc[highest].ind[0]].NumActiveTris--;
vc[tc[highest].ind[1]].NumActiveTris--;
vc[tc[highest].ind[2]].NumActiveTris--;
tc[highest].drawn = true;
for (u16 j : tc[highest].ind) {
vcache *vert = &vc[j];
for (u16 t = 0; t < vert->tris.size(); t++)
{
if (highest == vert->tris[t])
{
vert->tris.erase(t);
break;
}
}
}
lru.add(tc[highest].ind[0]);
lru.add(tc[highest].ind[1]);
highest = lru.add(tc[highest].ind[2]);
drawcalls++;
}
buf->setBoundingBox(mb->getBoundingBox());
newmesh->addMeshBuffer(buf);
buf->drop();
}
break;
case video::EVT_TANGENTS:
{
video::S3DVertexTangents *v = (video::S3DVertexTangents *) mb->getVertices();
scene::SMeshBufferTangents *buf = new scene::SMeshBufferTangents();
buf->Material = mb->getMaterial();
buf->Vertices.reallocate(vcount);
buf->Indices.reallocate(icount);
core::map<const video::S3DVertexTangents, const u16> sind; // search index for fast operation
typedef core::map<const video::S3DVertexTangents, const u16>::Node snode;
// Main algorithm
u32 highest = 0;
u32 drawcalls = 0;
for (;;)
{
if (tc[highest].drawn)
{
bool found = false;
float hiscore = 0;
for (u32 t = 0; t < tcount; t++)
{
if (!tc[t].drawn)
{
if (tc[t].score > hiscore)
{
highest = t;
hiscore = tc[t].score;
found = true;
}
}
}
if (!found)
break;
}
// Output the best triangle
u16 newind = buf->Vertices.size();
snode *s = sind.find(v[tc[highest].ind[0]]);
if (!s)
{
buf->Vertices.push_back(v[tc[highest].ind[0]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[0]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
}
s = sind.find(v[tc[highest].ind[1]]);
if (!s)
{
buf->Vertices.push_back(v[tc[highest].ind[1]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[1]], newind);
newind++;
}
else
{
buf->Indices.push_back(s->getValue());
}
s = sind.find(v[tc[highest].ind[2]]);
if (!s)
{
buf->Vertices.push_back(v[tc[highest].ind[2]]);
buf->Indices.push_back(newind);
sind.insert(v[tc[highest].ind[2]], newind);
}
else
{
buf->Indices.push_back(s->getValue());
}
vc[tc[highest].ind[0]].NumActiveTris--;
vc[tc[highest].ind[1]].NumActiveTris--;
vc[tc[highest].ind[2]].NumActiveTris--;
tc[highest].drawn = true;
for (u16 j : tc[highest].ind) {
vcache *vert = &vc[j];
for (u16 t = 0; t < vert->tris.size(); t++)
{
if (highest == vert->tris[t])
{
vert->tris.erase(t);
break;
}
}
}
lru.add(tc[highest].ind[0]);
lru.add(tc[highest].ind[1]);
highest = lru.add(tc[highest].ind[2]);
drawcalls++;
}
buf->setBoundingBox(mb->getBoundingBox());
newmesh->addMeshBuffer(buf);
buf->drop();
}
break;
}
delete [] vc;
delete [] tc;
} // for each meshbuffer
return newmesh;
}

@ -133,10 +133,3 @@ void recalculateBoundingBox(scene::IMesh *src_mesh);
We assume normal to be valid when it's 0 < length < Inf. and not NaN
*/
bool checkMeshNormals(scene::IMesh *mesh);
/*
Vertex cache optimization according to the Forsyth paper:
http://home.comcast.net/~tom_forsyth/papers/fast_vert_cache_opt.html
Ported from irrlicht 1.8
*/
scene::IMesh* createForsythOptimizedMesh(const scene::IMesh *mesh);

@ -714,31 +714,6 @@ void ClientInterface::sendToAll(NetworkPacket *pkt)
}
}
void ClientInterface::sendToAllCompat(NetworkPacket *pkt, NetworkPacket *legacypkt,
u16 min_proto_ver)
{
RecursiveMutexAutoLock clientslock(m_clients_mutex);
for (auto &client_it : m_clients) {
RemoteClient *client = client_it.second;
NetworkPacket *pkt_to_send = nullptr;
if (client->net_proto_version >= min_proto_ver) {
pkt_to_send = pkt;
} else if (client->net_proto_version != 0) {
pkt_to_send = legacypkt;
} else {
warningstream << "Client with unhandled version to handle: '"
<< client->net_proto_version << "'";
continue;
}
m_con->Send(client->peer_id,
clientCommandFactoryTable[pkt_to_send->getCommand()].channel,
pkt_to_send,
clientCommandFactoryTable[pkt_to_send->getCommand()].reliable);
}
}
RemoteClient* ClientInterface::getClientNoEx(session_t peer_id, ClientState state_min)
{
RecursiveMutexAutoLock clientslock(m_clients_mutex);

@ -465,7 +465,6 @@ public:
/* send to all clients */
void sendToAll(NetworkPacket *pkt);
void sendToAllCompat(NetworkPacket *pkt, NetworkPacket *legacypkt, u16 min_proto_ver);
/* delete a client */
void DeleteClient(session_t peer_id);

@ -367,12 +367,6 @@ bool EmergeManager::isBlockInQueue(v3s16 pos)
//
// TODO(hmmmm): Move this to ServerMap
v3s16 EmergeManager::getContainingChunk(v3s16 blockpos)
{
return getContainingChunk(blockpos, mgparams->chunksize);
}
// TODO(hmmmm): Move this to ServerMap
v3s16 EmergeManager::getContainingChunk(v3s16 blockpos, s16 chunksize)
{
@ -396,17 +390,6 @@ int EmergeManager::getSpawnLevelAtPoint(v2s16 p)
}
int EmergeManager::getGroundLevelAtPoint(v2s16 p)
{
if (m_mapgens.empty() || !m_mapgens[0]) {
errorstream << "EmergeManager: getGroundLevelAtPoint() called"
" before mapgen init" << std::endl;
return 0;
}
return m_mapgens[0]->getGroundLevelAtPoint(p);
}
// TODO(hmmmm): Move this to ServerMap
bool EmergeManager::isBlockUnderground(v3s16 blockpos)
{

@ -176,13 +176,10 @@ public:
bool isBlockInQueue(v3s16 pos);
v3s16 getContainingChunk(v3s16 blockpos);
Mapgen *getCurrentMapgen();
// Mapgen helpers methods
int getSpawnLevelAtPoint(v2s16 p);
int getGroundLevelAtPoint(v2s16 p);
bool isBlockUnderground(v3s16 blockpos);
static v3s16 getContainingChunk(v3s16 blockpos, s16 chunksize);

@ -560,11 +560,6 @@ u32 InventoryList::getUsedSlots() const
return num;
}
u32 InventoryList::getFreeSlots() const
{
return getSize() - getUsedSlots();
}
const ItemStack& InventoryList::getItem(u32 i) const
{
assert(i < m_size); // Pre-condition

@ -211,7 +211,6 @@ public:
u32 getWidth() const;
// Count used slots
u32 getUsedSlots() const;
u32 getFreeSlots() const;
// Get reference to item
const ItemStack& getItem(u32 i) const;

@ -139,13 +139,6 @@ MapBlock * Map::getBlockNoCreate(v3s16 p3d)
return block;
}
bool Map::isNodeUnderground(v3s16 p)
{
v3s16 blockpos = getNodeBlockPos(p);
MapBlock *block = getBlockNoCreateNoEx(blockpos);
return block && block->getIsUnderground();
}
bool Map::isValidPosition(v3s16 p)
{
v3s16 blockpos = getNodeBlockPos(p);

@ -167,9 +167,6 @@ public:
inline const NodeDefManager * getNodeDefManager() { return m_nodedef; }
// Returns InvalidPositionException if not found
bool isNodeUnderground(v3s16 p);
bool isValidPosition(v3s16 p);
// throws InvalidPositionException if not found

@ -218,31 +218,6 @@ void MapBlock::expireDayNightDiff()
m_day_night_differs_expired = true;
}
s16 MapBlock::getGroundLevel(v2s16 p2d)
{
if(isDummy())
return -3;
try
{
s16 y = MAP_BLOCKSIZE-1;
for(; y>=0; y--)
{
MapNode n = getNodeRef(p2d.X, y, p2d.Y);
if (m_gamedef->ndef()->get(n).walkable) {
if(y == MAP_BLOCKSIZE-1)
return -2;
return y;
}
}
return -1;
}
catch(InvalidPositionException &e)
{
return -3;
}
}
/*
Serialization
*/

@ -363,20 +363,6 @@ public:
return m_day_night_differs;
}
////
//// Miscellaneous stuff
////
/*
Tries to measure ground level.
Return value:
-1 = only air
-2 = only ground
-3 = random fail
0...MAP_BLOCKSIZE-1 = ground level
*/
s16 getGroundLevel(v2s16 p2d);
////
//// Timestamp (see m_timestamp)
////

@ -360,19 +360,6 @@ int MapgenV6::getSpawnLevelAtPoint(v2s16 p)
//////////////////////// Noise functions
float MapgenV6::getMudAmount(v2s16 p)
{
int index = (p.Y - node_min.Z) * ystride + (p.X - node_min.X);
return getMudAmount(index);
}
bool MapgenV6::getHaveBeach(v2s16 p)
{
int index = (p.Y - node_min.Z) * ystride + (p.X - node_min.X);
return getHaveBeach(index);
}
BiomeV6Type MapgenV6::getBiome(v2s16 p)
{

@ -154,9 +154,7 @@ public:
float getHumidity(v2s16 p);
float getTreeAmount(v2s16 p);
bool getHaveAppleTree(v2s16 p);
float getMudAmount(v2s16 p);
virtual float getMudAmount(int index);
bool getHaveBeach(v2s16 p);
float getMudAmount(int index);
bool getHaveBeach(int index);
BiomeV6Type getBiome(v2s16 p);
BiomeV6Type getBiome(int index, v2s16 p);

@ -312,51 +312,6 @@ float noise2d_perlin(float x, float y, s32 seed,
}
float noise2d_perlin_abs(float x, float y, s32 seed,
int octaves, float persistence, bool eased)
{
float a = 0;
float f = 1.0;
float g = 1.0;
for (int i = 0; i < octaves; i++) {
a += g * std::fabs(noise2d_gradient(x * f, y * f, seed + i, eased));
f *= 2.0;
g *= persistence;
}
return a;
}
float noise3d_perlin(float x, float y, float z, s32 seed,
int octaves, float persistence, bool eased)
{
float a = 0;
float f = 1.0;
float g = 1.0;
for (int i = 0; i < octaves; i++) {
a += g * noise3d_gradient(x * f, y * f, z * f, seed + i, eased);
f *= 2.0;
g *= persistence;
}
return a;
}
float noise3d_perlin_abs(float x, float y, float z, s32 seed,
int octaves, float persistence, bool eased)
{
float a = 0;
float f = 1.0;
float g = 1.0;
for (int i = 0; i < octaves; i++) {
a += g * std::fabs(noise3d_gradient(x * f, y * f, z * f, seed + i, eased));
f *= 2.0;
g *= persistence;
}
return a;
}
float contour(float v)
{
v = std::fabs(v);

@ -224,15 +224,6 @@ float noise3d_gradient(float x, float y, float z, s32 seed, bool eased=false);
float noise2d_perlin(float x, float y, s32 seed,
int octaves, float persistence, bool eased=true);
float noise2d_perlin_abs(float x, float y, s32 seed,
int octaves, float persistence, bool eased=true);
float noise3d_perlin(float x, float y, float z, s32 seed,
int octaves, float persistence, bool eased=false);
float noise3d_perlin_abs(float x, float y, float z, s32 seed,
int octaves, float persistence, bool eased=false);
inline float easeCurve(float t)
{
return t * t * t * (t * (6.f * t - 15.f) + 10.f);

@ -941,12 +941,6 @@ void RollbackManager::addAction(const RollbackAction & action)
}
}
std::list<RollbackAction> RollbackManager::getEntriesSince(time_t first_time)
{
flush();
return getActionsSince(first_time);
}
std::list<RollbackAction> RollbackManager::getNodeActors(v3s16 pos, int range,
time_t seconds, int limit)
{

@ -46,7 +46,6 @@ public:
void flush();
void addAction(const RollbackAction & action);
std::list<RollbackAction> getEntriesSince(time_t first_time);
std::list<RollbackAction> getNodeActors(v3s16 pos, int range,
time_t seconds, int limit);
std::list<RollbackAction> getRevertActions(

@ -421,19 +421,6 @@ void InvRef::create(lua_State *L, const InventoryLocation &loc)
luaL_getmetatable(L, className);
lua_setmetatable(L, -2);
}
void InvRef::createPlayer(lua_State *L, RemotePlayer *player)
{
NO_MAP_LOCK_REQUIRED;
InventoryLocation loc;
loc.setPlayer(player->getName());
create(L, loc);
}
void InvRef::createNodeMeta(lua_State *L, v3s16 p)
{
InventoryLocation loc;
loc.setNodeMeta(p);
create(L, loc);
}
void InvRef::Register(lua_State *L)
{

@ -111,8 +111,6 @@ public:
// Creates an InvRef and leaves it on top of stack
// Not callable from Lua; all references are created on the C side.
static void create(lua_State *L, const InventoryLocation &loc);
static void createPlayer(lua_State *L, RemotePlayer *player);
static void createNodeMeta(lua_State *L, v3s16 p);
static void Register(lua_State *L);
};

@ -89,7 +89,10 @@ int NodeMetaRef::l_get_inventory(lua_State *L)
NodeMetaRef *ref = checkobject(L, 1);
ref->getmeta(true); // try to ensure the metadata exists
InvRef::createNodeMeta(L, ref->m_p);
InventoryLocation loc;
loc.setNodeMeta(ref->m_p);
InvRef::create(L, loc);
return 1;
}

@ -104,8 +104,7 @@ Settings *Settings::createLayer(SettingsLayer sl, const std::string &end_tag)
Settings *Settings::getLayer(SettingsLayer sl)
{
sanity_check((int)sl >= 0 && sl < SL_TOTAL_COUNT);
return g_hierarchy.layers[(int)sl];
return g_hierarchy.getLayer(sl);
}