diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2015-02-17 20:09:36 +0100 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2015-02-18 09:36:42 +0100 |
commit | 4208fdfd2273b715eeddb8b9877c2def8346d447 (patch) | |
tree | f06bb591b996c1facb14d18a1b4cc88793a1b70d /src | |
parent | 4875213168ed877ab708e81d539923109977a5c8 (diff) | |
download | minetest-4208fdfd2273b715eeddb8b9877c2def8346d447.tar.gz minetest-4208fdfd2273b715eeddb8b9877c2def8346d447.tar.bz2 minetest-4208fdfd2273b715eeddb8b9877c2def8346d447.zip |
Fix unused (and so, broken) enable_rollback_recording. This option must be reloaded at server loop but loaded when server starts, for data consistency (not a hot load variable)
Diffstat (limited to 'src')
-rw-r--r-- | src/map.cpp | 4 | ||||
-rw-r--r-- | src/script/lua_api/l_rollback.cpp | 10 | ||||
-rw-r--r-- | src/server.cpp | 13 |
3 files changed, 18 insertions, 9 deletions
diff --git a/src/map.cpp b/src/map.cpp index d8f018742..efa53ca08 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1863,11 +1863,11 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks) // Find out whether there is a suspect for this action std::string suspect; - if(m_gamedef->rollback()){ + if(m_gamedef->rollback()) { suspect = m_gamedef->rollback()->getSuspect(p0, 83, 1); } - if(!suspect.empty()){ + if(m_gamedef->rollback() && !suspect.empty()){ // Blame suspect RollbackScopeActor rollback_scope(m_gamedef->rollback(), suspect, true); // Get old node for rollback diff --git a/src/script/lua_api/l_rollback.cpp b/src/script/lua_api/l_rollback.cpp index f55a72d1b..5744e6813 100644 --- a/src/script/lua_api/l_rollback.cpp +++ b/src/script/lua_api/l_rollback.cpp @@ -44,6 +44,9 @@ int ModApiRollback::l_rollback_get_node_actions(lua_State *L) int limit = luaL_checknumber(L, 4); Server *server = getServer(L); IRollbackManager *rollback = server->getRollbackManager(); + if (rollback == NULL) { + return 0; + } std::list<RollbackAction> actions = rollback->getNodeActors(pos, range, seconds, limit); std::list<RollbackAction>::iterator iter = actions.begin(); @@ -80,6 +83,13 @@ int ModApiRollback::l_rollback_revert_actions_by(lua_State *L) int seconds = luaL_checknumber(L, 2); Server *server = getServer(L); IRollbackManager *rollback = server->getRollbackManager(); + + // If rollback is disabled, tell it's not a success. + if (rollback == NULL) { + lua_pushboolean(L, false); + lua_newtable(L); + return 2; + } std::list<RollbackAction> actions = rollback->getRevertActions(actor, seconds); std::list<std::string> log; bool success = server->rollbackRevertActions(actions, &log); diff --git a/src/server.cpp b/src/server.cpp index 399c41b70..2d84ad032 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -244,9 +244,6 @@ Server::Server( std::string ban_path = m_path_world + DIR_DELIM "ipban.txt"; m_banmanager = new BanManager(ban_path); - // Create rollback manager - m_rollback = new RollbackManager(m_path_world, this); - ModConfiguration modconf(m_path_world); m_mods = modconf.getMods(); std::vector<ModSpec> unsatisfied_mods = modconf.getUnsatisfiedMods(); @@ -354,6 +351,12 @@ Server::Server( // Initialize mapgens m_emerge->initMapgens(); + m_enable_rollback_recording = g_settings->getBool("enable_rollback_recording"); + if (m_enable_rollback_recording) { + // Create rollback manager + m_rollback = new RollbackManager(m_path_world, this); + } + // Give environment reference to scripting api m_script->initializeEnvironment(m_env); @@ -1108,10 +1111,6 @@ void Server::AsyncRunStep(bool initial_step) counter = 0.0; m_emerge->startThreads(); - - // Update m_enable_rollback_recording here too - m_enable_rollback_recording = - g_settings->getBool("enable_rollback_recording"); } } |