From 9736548720a96c9c7f739edb0435d9ba4ad80652 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Thu, 15 Jan 2015 16:20:05 -0500 Subject: Add ability to delete MapBlocks from map Also add a Lua API and chatcommand for this --- src/database-redis.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/database-redis.cpp') diff --git a/src/database-redis.cpp b/src/database-redis.cpp index 028a0ab4d..b086f899d 100644 --- a/src/database-redis.cpp +++ b/src/database-redis.cpp @@ -123,6 +123,30 @@ std::string Database_Redis::loadBlock(v3s16 blockpos) return str; } +bool Database_Redis::deleteBlock(v3s16 blockpos) +{ + std::string tmp = i64tos(getBlockAsInteger(blockpos)); + + redisReply *reply = (redisReply *)redisCommand(ctx, "HDEL %s %s", + hash.c_str(), tmp.c_str()); + if (!reply) { + errorstream << "WARNING: deleteBlock: redis command 'HDEL' failed on " + "block " << PP(blockpos) << ": " << ctx->errstr << std::endl; + freeReplyObject(reply); + return false; + } + + if (reply->type == REDIS_REPLY_ERROR) { + errorstream << "WARNING: deleteBlock: deleting block " << PP(blockpos) + << "failed" << std::endl; + freeReplyObject(reply); + return false; + } + + freeReplyObject(reply); + return true; +} + void Database_Redis::listAllLoadableBlocks(std::list &dst) { redisReply *reply; -- cgit v1.2.3