Merge remote-tracking branch 'minetest/master'

master
proller 2016-05-18 16:38:10 +03:00
commit 6b06bf433d
18 changed files with 81 additions and 86 deletions

View File

@ -20,7 +20,7 @@ set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
set(VERSION_TWEAK 8)
# Change to false for releases
set(DEVELOPMENT_BUILD FALSE)
set(DEVELOPMENT_BUILD TRUE)
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_TWEAK}")
if(VERSION_EXTRA)

View File

@ -752,7 +752,7 @@ clean_assets :
apk: local.properties assets $(ICONV_LIB) $(IRRLICHT_LIB) $(CURL_LIB) $(GMP_LIB) $(LEVELDB_TARGET) \
$(OPENAL_LIB) $(OGG_LIB) prep_srcdir $(ANDR_ROOT)/jni/src/android_version.h \
$(ANDR_ROOT)/jni/src/android_version_githash.h sqlite3_download
@${ANDROID_NDK}/ndk-build NDK_MODULE_PATH=${NDK_MODULE_PATH} \
+ @${ANDROID_NDK}/ndk-build NDK_MODULE_PATH=${NDK_MODULE_PATH} \
GPROF=${GPROF} APP_ABI=${TARGET_ABI} HAVE_LEVELDB=${HAVE_LEVELDB} \
APP_PLATFORM=${APP_PLATFORM} \
TARGET_LIBDIR=${TARGET_LIBDIR} \

View File

@ -272,3 +272,8 @@ function on_dignode(p, node)
nodeupdate(p)
end
core.register_on_dignode(on_dignode)
function on_punchnode(p, node)
nodeupdate(p)
end
core.register_on_punchnode(on_punchnode)

View File

@ -848,8 +848,6 @@ map_generation_limit (Map generation limit) int 31000 0 31000
# Global map generation attributes.
# In Mapgen v6 the 'decorations' flag controls all decorations except trees
# and junglegrass, in all other mapgens this flag controls all decorations.
# The default flags set in the engine are: caves, light, decorations
# The flags string modifies the engine defaults.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
mg_flags (Mapgen flags) flags caves,dungeons,light,decorations caves,dungeons,light,decorations,nocaves,nodungeons,nolight,nodecorations
@ -910,8 +908,6 @@ mgv5_np_cave2 (Mapgen v5 cave2 noise parameters) noise_params 0, 12, (50, 50, 50
# Map generation attributes specific to Mapgen v6.
# When snowbiomes are enabled jungles are automatically enabled, the 'jungles' flag is ignored.
# The default flags set in the engine are: biomeblend, mudflow
# The flags string modifies the engine defaults.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
mgv6_spflags (Mapgen v6 flags) flags jungles,biomeblend,mudflow,snowbiomes,trees jungles,biomeblend,mudflow,snowbiomes,flat,trees,nojungles,nobiomeblend,nomudflow,nosnowbiomes,noflat,notrees
@ -937,8 +933,6 @@ mgv6_np_apple_trees (Mapgen v6 apple trees noise parameters) noise_params 0, 1,
# Map generation attributes specific to Mapgen v7.
# The 'ridges' flag controls the rivers.
# The default flags set in the engine are: mountains, ridges
# The flags string modifies the engine defaults.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
mgv7_spflags (Mapgen v7 flags) flags mountains,ridges mountains,ridges,nomountains,noridges
@ -962,8 +956,6 @@ mgv7_np_cave2 (Mapgen v7 cave2 noise parameters) noise_params 0, 12, (100, 100,
# Map generation attributes specific to Mapgen flat.
# Occasional lakes and hills can be added to the flat world.
# The default flags set in the engine are: none
# The flags string modifies the engine defaults.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
mgflat_spflags (Mapgen flat flags) flags lakes,hills,,nolakes,nohills
@ -1079,8 +1071,6 @@ mgfractal_np_cave2 (Mapgen fractal cave2 noise parameters) noise_params 0, 12, (
# 'altitude_chill' makes higher elevations colder, which may cause biome issues.
# 'humid_rivers' modifies the humidity around rivers and in areas where water would tend to pool,
# it may interfere with delicately adjusted biomes.
# The default flags set in the engine are: altitude_chill, humid_rivers
# The flags string modifies the engine defaults.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
mg_valleys_spflags (Valleys C Flags) flags altitude_chill,humid_rivers altitude_chill,noaltitude_chill,humid_rivers,nohumid_rivers

View File

@ -115,7 +115,7 @@ if(CURSES_USE_NCURSESW)
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
find_path(CURSES_INCLUDE_PATH
NAMES ncursesw/ncurses.h ncursesw/curses.h
NAMES ncursesw/ncurses.h ncursesw/curses.h ncurses.h curses.h
HINTS "${_cursesParentDir}/include"
)

View File

@ -1046,8 +1046,6 @@
# Global map generation attributes.
# In Mapgen v6 the 'decorations' flag controls all decorations except trees
# and junglegrass, in all other mapgens this flag controls all decorations.
# The default flags set in the engine are: caves, light, decorations
# The flags string modifies the engine defaults.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
# type: flags possible values: caves, dungeons, light, decorations, nocaves, nodungeons, nolight, nodecorations
@ -1121,8 +1119,6 @@
# Map generation attributes specific to Mapgen v6.
# When snowbiomes are enabled jungles are automatically enabled, the 'jungles' flag is ignored.
# The default flags set in the engine are: biomeblend, mudflow
# The flags string modifies the engine defaults.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
# type: flags possible values: jungles, biomeblend, mudflow, snowbiomes, flat, trees, nojungles, nobiomeblend, nomudflow, nosnowbiomes, noflat, notrees
@ -1173,8 +1169,6 @@
# Map generation attributes specific to Mapgen v7.
# The 'ridges' flag controls the rivers.
# The default flags set in the engine are: mountains, ridges
# The flags string modifies the engine defaults.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
# type: flags possible values: mountains, ridges, nomountains, noridges
@ -1221,8 +1215,6 @@
# Map generation attributes specific to Mapgen flat.
# Occasional lakes and hills can be added to the flat world.
# The default flags set in the engine are: none
# The flags string modifies the engine defaults.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
# type: flags possible values: lakes, hills, , nolakes, nohills
@ -1367,8 +1359,6 @@
# 'altitude_chill' makes higher elevations colder, which may cause biome issues.
# 'humid_rivers' modifies the humidity around rivers and in areas where water would tend to pool,
# it may interfere with delicately adjusted biomes.
# The default flags set in the engine are: altitude_chill, humid_rivers
# The flags string modifies the engine defaults.
# Flags that are not specified in the flag string are not modified from the default.
# Flags starting with 'no' are used to explicitly disable them.
# type: flags possible values: altitude_chill, noaltitude_chill, humid_rivers, nohumid_rivers

View File

@ -32,14 +32,15 @@ bool Database_Dummy::saveBlock(const v3s16 &pos, const std::string &data)
return true;
}
std::string Database_Dummy::loadBlock(const v3s16 &pos)
void Database_Dummy::loadBlock(const v3s16 &pos, std::string *block)
{
auto i = getBlockAsString(pos);
auto lock = m_database.lock_shared_rec();
auto it = m_database.find(i);
if (it == m_database.end())
return "";
return it->second;
*block = "";
return;
*block = it->second;
}
bool Database_Dummy::deleteBlock(const v3s16 &pos)

View File

@ -32,10 +32,10 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
class Database_Dummy : public Database
{
public:
virtual bool saveBlock(const v3s16 &pos, const std::string &data);
virtual std::string loadBlock(const v3s16 &pos);
virtual bool deleteBlock(const v3s16 &pos);
virtual void listAllLoadableBlocks(std::vector<v3s16> &dst);
bool saveBlock(const v3s16 &pos, const std::string &data);
void loadBlock(const v3s16 &pos, std::string *block);
bool deleteBlock(const v3s16 &pos);
void listAllLoadableBlocks(std::vector<v3s16> &dst);
private:
concurrent_map<std::string, std::string> m_database;

View File

@ -35,7 +35,7 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#define ENSURE_STATUS_OK(s) \
if (!(s).ok()) { \
throw FileNotGoodException(std::string("LevelDB error: ") + \
throw DatabaseException(std::string("LevelDB error: ") + \
(s).ToString()); \
}
@ -61,18 +61,21 @@ bool Database_LevelDB::saveBlock(const v3s16 &pos, const std::string &data)
return true;
}
std::string Database_LevelDB::loadBlock(const v3s16 &pos)
void Database_LevelDB::loadBlock(const v3s16 &pos, std::string *block)
{
/*
std::string datastr;
*/
m_database.get(getBlockAsString(pos), datastr);
if (datastr.length())
return datastr;
m_database.get(getBlockAsString(pos), *block);
if (block->length())
return;
m_database.get(i64tos(getBlockAsInteger(pos)), datastr);
return datastr;
m_database.get(i64tos(getBlockAsInteger(pos)), *block);
/*
*block = (status.ok()) ? datastr : "";
*/
}
bool Database_LevelDB::deleteBlock(const v3s16 &pos)

View File

@ -37,13 +37,13 @@ public:
Database_LevelDB(const std::string &savedir);
~Database_LevelDB();
virtual void open() { m_database.open(); };
virtual void close() { m_database.close(); };
void open() { m_database.open(); };
void close() { m_database.close(); };
virtual bool saveBlock(const v3s16 &pos, const std::string &data);
virtual std::string loadBlock(const v3s16 &pos);
virtual bool deleteBlock(const v3s16 &pos);
virtual void listAllLoadableBlocks(std::vector<v3s16> &dst);
bool saveBlock(const v3s16 &pos, const std::string &data);
void loadBlock(const v3s16 &pos, std::string *block);
bool deleteBlock(const v3s16 &pos);
void listAllLoadableBlocks(std::vector<v3s16> &dst);
private:
//leveldb::DB *m_database;

View File

@ -44,11 +44,11 @@ Database_Redis::Database_Redis(Settings &conf)
int port = conf.exists("redis_port") ? conf.getU16("redis_port") : 6379;
ctx = redisConnect(addr, port);
if (!ctx) {
throw FileNotGoodException("Cannot allocate redis context");
throw DatabaseException("Cannot allocate redis context");
} else if (ctx->err) {
std::string err = std::string("Connection error: ") + ctx->errstr;
redisFree(ctx);
throw FileNotGoodException(err);
throw DatabaseException(err);
}
}
@ -60,7 +60,7 @@ Database_Redis::~Database_Redis()
void Database_Redis::beginSave() {
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "MULTI"));
if (!reply) {
throw FileNotGoodException(std::string(
throw DatabaseException(std::string(
"Redis command 'MULTI' failed: ") + ctx->errstr);
}
freeReplyObject(reply);
@ -69,7 +69,7 @@ void Database_Redis::beginSave() {
void Database_Redis::endSave() {
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "EXEC"));
if (!reply) {
throw FileNotGoodException(std::string(
throw DatabaseException(std::string(
"Redis command 'EXEC' failed: ") + ctx->errstr);
}
freeReplyObject(reply);
@ -99,42 +99,45 @@ bool Database_Redis::saveBlock(const v3s16 &pos, const std::string &data)
return true;
}
std::string Database_Redis::loadBlock(const v3s16 &pos)
void Database_Redis::loadBlock(const v3s16 &pos, std::string *block)
{
std::string tmp = i64tos(getBlockAsInteger(pos));
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx,
"HGET %s %s", hash.c_str(), tmp.c_str()));
if (!reply) {
throw FileNotGoodException(std::string(
throw DatabaseException(std::string(
"Redis command 'HGET %s %s' failed: ") + ctx->errstr);
}
switch (reply->type) {
case REDIS_REPLY_STRING: {
std::string str(reply->str, reply->len);
*block = std::string(reply->str, reply->len);
// std::string copies the memory so this won't cause any problems
freeReplyObject(reply);
return str;
return;
}
case REDIS_REPLY_ERROR: {
std::string errstr(reply->str, reply->len);
freeReplyObject(reply);
errorstream << "loadBlock: loading block " << PP(pos)
<< " failed: " << errstr << std::endl;
throw FileNotGoodException(std::string(
throw DatabaseException(std::string(
"Redis command 'HGET %s %s' errored: ") + errstr);
}
case REDIS_REPLY_NIL: {
*block = "";
// block not found in database
freeReplyObject(reply);
return "";
return;
}
}
errorstream << "loadBlock: loading block " << PP(pos)
<< " returned invalid reply type " << reply->type
<< ": " << std::string(reply->str, reply->len) << std::endl;
freeReplyObject(reply);
throw FileNotGoodException(std::string(
throw DatabaseException(std::string(
"Redis command 'HGET %s %s' gave invalid reply."));
}
@ -145,7 +148,7 @@ bool Database_Redis::deleteBlock(const v3s16 &pos)
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx,
"HDEL %s %s", hash.c_str(), tmp.c_str()));
if (!reply) {
throw FileNotGoodException(std::string(
throw DatabaseException(std::string(
"Redis command 'HDEL %s %s' failed: ") + ctx->errstr);
} else if (reply->type == REDIS_REPLY_ERROR) {
warningstream << "deleteBlock: deleting block " << PP(pos)
@ -162,7 +165,7 @@ void Database_Redis::listAllLoadableBlocks(std::vector<v3s16> &dst)
{
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "HKEYS %s", hash.c_str()));
if (!reply) {
throw FileNotGoodException(std::string(
throw DatabaseException(std::string(
"Redis command 'HKEYS %s' failed: ") + ctx->errstr);
}
switch (reply->type) {
@ -174,7 +177,7 @@ void Database_Redis::listAllLoadableBlocks(std::vector<v3s16> &dst)
}
break;
case REDIS_REPLY_ERROR:
throw FileNotGoodException(std::string(
throw DatabaseException(std::string(
"Failed to get keys from database: ") +
std::string(reply->str, reply->len));
}

View File

@ -36,13 +36,13 @@ public:
Database_Redis(Settings &conf);
~Database_Redis();
virtual void beginSave();
virtual void endSave();
void beginSave();
void endSave();
virtual bool saveBlock(const v3s16 &pos, const std::string &data);
virtual std::string loadBlock(const v3s16 &pos);
virtual bool deleteBlock(const v3s16 &pos);
virtual void listAllLoadableBlocks(std::vector<v3s16> &dst);
bool saveBlock(const v3s16 &pos, const std::string &data);
void loadBlock(const v3s16 &pos, std::string *block);
bool deleteBlock(const v3s16 &pos);
void listAllLoadableBlocks(std::vector<v3s16> &dst);
private:
redisContext *ctx;

View File

@ -50,7 +50,7 @@ SQLite format specification:
#define SQLRES(s, r, m) \
if ((s) != (r)) { \
throw FileNotGoodException(std::string(m) + ": " +\
throw DatabaseException(std::string(m) + ": " +\
sqlite3_errmsg(m_database)); \
}
#define SQLOK(s, m) SQLRES(s, SQLITE_OK, m)
@ -242,7 +242,7 @@ bool Database_SQLite3::saveBlock(const v3s16 &pos, const std::string &data)
return true;
}
std::string Database_SQLite3::loadBlock(const v3s16 &pos)
void Database_SQLite3::loadBlock(const v3s16 &pos, std::string *block)
{
std::lock_guard<Mutex> lock(mutex);
@ -252,20 +252,17 @@ std::string Database_SQLite3::loadBlock(const v3s16 &pos)
if (sqlite3_step(m_stmt_read) != SQLITE_ROW) {
sqlite3_reset(m_stmt_read);
return "";
return;
}
const char *data = (const char *) sqlite3_column_blob(m_stmt_read, 0);
size_t len = sqlite3_column_bytes(m_stmt_read, 0);
std::string s;
if (data)
s = std::string(data, len);
*block = (data) ? std::string(data, len) : "";
sqlite3_step(m_stmt_read);
// We should never get more than 1 row, so ok to reset
sqlite3_reset(m_stmt_read);
return s;
}
void Database_SQLite3::createDatabase()

View File

@ -40,17 +40,17 @@ class Database_SQLite3 : public Database
{
public:
Database_SQLite3(const std::string &savedir);
virtual void beginSave();
virtual void endSave();
virtual bool saveBlock(const v3s16 &pos, const std::string &data);
virtual std::string loadBlock(const v3s16 &pos);
virtual bool deleteBlock(const v3s16 &pos);
virtual void listAllLoadableBlocks(std::vector<v3s16> &dst);
virtual bool initialized() const { return m_initialized; }
~Database_SQLite3();
void beginSave();
void endSave();
bool saveBlock(const v3s16 &pos, const std::string &data);
void loadBlock(const v3s16 &pos, std::string *block);
bool deleteBlock(const v3s16 &pos);
void listAllLoadableBlocks(std::vector<v3s16> &dst);
bool initialized() const { return m_initialized; }
private:
// Open the database
void openDatabase();

View File

@ -42,7 +42,7 @@ public:
virtual void endSave() {}
virtual bool saveBlock(const v3s16 &pos, const std::string &data) = 0;
virtual std::string loadBlock(const v3s16 &pos) = 0;
virtual void loadBlock(const v3s16 &pos, std::string *block) = 0;
virtual bool deleteBlock(const v3s16 &pos) = 0;
static s64 getBlockAsInteger(const v3s16 &pos);

View File

@ -66,6 +66,11 @@ public:
FileNotGoodException(const std::string &s): BaseException(s) {}
};
class DatabaseException : public BaseException {
public:
DatabaseException(const std::string &s): BaseException(s) {}
};
class SerializationError : public BaseException {
public:
SerializationError(const std::string &s): BaseException(s) {}

View File

@ -1039,7 +1039,8 @@ static bool migrate_database(const GameParams &game_params, const Settings &cmd_
}
*/
const std::string &data = old_db->loadBlock(*it);
std::string data;
old_db->loadBlock(*it, &data);
if (!data.empty()) {
new_db->saveBlock(*it, data);
} else {

View File

@ -3318,7 +3318,8 @@ MapBlock * ServerMap::loadBlock(v3s16 p3d)
const auto sector = this;
MapBlock *block = nullptr;
try {
auto blob = dbase->loadBlock(p3d);
std::string blob;
dbase->loadBlock(p3d, &blob);
if(!blob.length()) {
m_db_miss.set(p3d, 1);
return nullptr;
@ -3470,8 +3471,7 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
v2s16 p2d(blockpos.X, blockpos.Z);
std::string ret;
ret = dbase->loadBlock(blockpos);
dbase->loadBlock(blockpos, &ret);
if (ret != "") {
loadBlock(&ret, blockpos, createSector(p2d), false);
return getBlockNoCreateNoEx(blockpos);