mirror of https://github.com/minetest/minetest.git
Merge a23e03534d
into b2057a5da7
This commit is contained in:
commit
91df347723
|
@ -136,6 +136,19 @@ void ObjDefManager::clear()
|
|||
}
|
||||
|
||||
|
||||
void ObjDefManager::clearByName(const std::string &name)
|
||||
{
|
||||
for (auto it = m_objects.begin(); it != m_objects.end(); ++it) {
|
||||
auto obj = *it;
|
||||
if (obj && !strcasecmp(name.c_str(), obj->name.c_str())) {
|
||||
delete obj;
|
||||
m_objects.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
u32 ObjDefManager::validateHandle(ObjDefHandle handle) const
|
||||
{
|
||||
ObjDefType type;
|
||||
|
|
|
@ -78,6 +78,7 @@ public:
|
|||
virtual const char *getObjectTitle() const { return "ObjDef"; }
|
||||
|
||||
virtual void clear();
|
||||
virtual void clearByName(const std::string &name);
|
||||
virtual ObjDef *getByName(const std::string &name) const;
|
||||
|
||||
//// Add new/get/set object definitions by handle
|
||||
|
|
|
@ -1526,6 +1526,20 @@ int ModApiMapgen::l_clear_registered_decorations(lua_State *L)
|
|||
}
|
||||
|
||||
|
||||
// clear_decoration(name)
|
||||
int ModApiMapgen::l_clear_decoration(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
luaL_checktype(L, 1, LUA_TSTRING);
|
||||
const char *name = lua_tostring(L, 1);
|
||||
|
||||
DecorationManager *dmgr =
|
||||
getServer(L)->getEmergeManager()->getWritableDecorationManager();
|
||||
dmgr->clearByName(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// clear_registered_ores()
|
||||
int ModApiMapgen::l_clear_registered_ores(lua_State *L)
|
||||
{
|
||||
|
@ -2027,6 +2041,7 @@ void ModApiMapgen::Initialize(lua_State *L, int top)
|
|||
|
||||
API_FCT(clear_registered_biomes);
|
||||
API_FCT(clear_registered_decorations);
|
||||
API_FCT(clear_decoration);
|
||||
API_FCT(clear_registered_ores);
|
||||
API_FCT(clear_registered_schematics);
|
||||
|
||||
|
|
|
@ -123,6 +123,9 @@ private:
|
|||
// clear_registered_decorations()
|
||||
static int l_clear_registered_decorations(lua_State *L);
|
||||
|
||||
// clear_decoration()
|
||||
static int l_clear_decoration(lua_State *L);
|
||||
|
||||
// clear_registered_schematics()
|
||||
static int l_clear_registered_schematics(lua_State *L);
|
||||
|
||||
|
|
Loading…
Reference in New Issue