summaryrefslogtreecommitdiff
path: root/src/database-leveldb.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-01-15 16:20:05 -0500
committerkwolekr <kwolekr@minetest.net>2015-01-15 16:48:56 -0500
commit9736548720a96c9c7f739edb0435d9ba4ad80652 (patch)
tree3f92b63d017e9baac042ed3837bbdf040d40c73f /src/database-leveldb.cpp
parent0330cec7ec55126c9cc441373cde1253bed895ee (diff)
downloadminetest-9736548720a96c9c7f739edb0435d9ba4ad80652.tar.gz
minetest-9736548720a96c9c7f739edb0435d9ba4ad80652.tar.bz2
minetest-9736548720a96c9c7f739edb0435d9ba4ad80652.zip
Add ability to delete MapBlocks from map
Also add a Lua API and chatcommand for this
Diffstat (limited to 'src/database-leveldb.cpp')
-rw-r--r--src/database-leveldb.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/database-leveldb.cpp b/src/database-leveldb.cpp
index 1681b0195..de510e533 100644
--- a/src/database-leveldb.cpp
+++ b/src/database-leveldb.cpp
@@ -80,6 +80,19 @@ std::string Database_LevelDB::loadBlock(v3s16 blockpos)
return "";
}
+bool Database_LevelDB::deleteBlock(v3s16 blockpos)
+{
+ leveldb::Status status = m_database->Delete(leveldb::WriteOptions(),
+ i64tos(getBlockAsInteger(blockpos)));
+ if (!status.ok()) {
+ errorstream << "WARNING: deleteBlock: LevelDB error deleting block "
+ << PP(blockpos) << ": " << status.ToString() << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
void Database_LevelDB::listAllLoadableBlocks(std::list<v3s16> &dst)
{
leveldb::Iterator* it = m_database->NewIterator(leveldb::ReadOptions());