diff options
author | kwolekr <kwolekr@minetest.net> | 2015-01-15 16:20:05 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-01-15 16:48:56 -0500 |
commit | 9736548720a96c9c7f739edb0435d9ba4ad80652 (patch) | |
tree | 3f92b63d017e9baac042ed3837bbdf040d40c73f /src/database-leveldb.cpp | |
parent | 0330cec7ec55126c9cc441373cde1253bed895ee (diff) | |
download | minetest-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.cpp | 13 |
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()); |