Skip to content

Commit

Permalink
Clearobjects: Send progress messages to terminal using actionstream
Browse files Browse the repository at this point in the history
Change default mode to 'quick' as 'full' can lock up a server for a
long time.
  • Loading branch information
paramat committed Nov 24, 2017
1 parent f7733f4 commit 912ba1e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions builtin/game/chatcommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -896,10 +896,10 @@ core.register_chatcommand("clearobjects", {
privs = {server=true},
func = function(name, param)
local options = {}
if param == "" or param == "full" then
options.mode = "full"
elseif param == "quick" then
if param == "" or param == "quick" then
options.mode = "quick"
elseif param == "full" then
options.mode = "full"
else
return false, "Invalid usage, see /help clearobjects."
end
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ int ModApiEnvMod::l_clear_objects(lua_State *L)
{
GET_ENV_PTR;

ClearObjectsMode mode = CLEAR_OBJECTS_MODE_FULL;
ClearObjectsMode mode = CLEAR_OBJECTS_MODE_QUICK;
if (lua_istable(L, 1)) {
mode = (ClearObjectsMode)getenumfield(L, 1, "mode",
ModApiEnvMod::es_ClearObjectsMode, mode);
Expand Down
6 changes: 3 additions & 3 deletions src/serverenvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)
loadable_blocks = loaded_blocks;
}

infostream << "ServerEnvironment::clearObjects(): "
actionstream << "ServerEnvironment::clearObjects(): "
<< "Now clearing objects in " << loadable_blocks.size()
<< " blocks" << std::endl;

Expand Down Expand Up @@ -1070,7 +1070,7 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)
num_blocks_checked % report_interval == 0) {
float percent = 100.0 * (float)num_blocks_checked /
loadable_blocks.size();
infostream << "ServerEnvironment::clearObjects(): "
actionstream << "ServerEnvironment::clearObjects(): "
<< "Cleared " << num_objs_cleared << " objects"
<< " in " << num_blocks_cleared << " blocks ("
<< percent << "%)" << std::endl;
Expand All @@ -1090,7 +1090,7 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)

m_last_clear_objects_time = m_game_time;

infostream << "ServerEnvironment::clearObjects(): "
actionstream << "ServerEnvironment::clearObjects(): "
<< "Finished: Cleared " << num_objs_cleared << " objects"
<< " in " << num_blocks_cleared << " blocks" << std::endl;
}
Expand Down

0 comments on commit 912ba1e

Please sign in to comment.