summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Root.cpp14
-rw-r--r--src/Server.cpp59
2 files changed, 45 insertions, 28 deletions
diff --git a/src/Root.cpp b/src/Root.cpp
index c20cf0d21..f72f0bae3 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -462,16 +462,6 @@ void cRoot::QueueExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCall
void cRoot::QueueExecuteConsoleCommand(const AString & a_Cmd)
{
- // Some commands are built-in:
- if (a_Cmd == "stop")
- {
- m_bStop = true;
- }
- else if (a_Cmd == "restart")
- {
- m_bRestart = true;
- }
-
// Put the command into a queue (Alleviates FS #363):
cCSLock Lock(m_CSPendingCommands);
m_PendingCommands.push_back(cCommand(a_Cmd, new cLogCommandDeleteSelfOutputCallback));
@@ -483,14 +473,16 @@ void cRoot::QueueExecuteConsoleCommand(const AString & a_Cmd)
void cRoot::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallback & a_Output)
{
- // Some commands are built-in:
+ // cRoot handles stopping and restarting due to our access to controlling variables
if (a_Cmd == "stop")
{
m_bStop = true;
+ return;
}
else if (a_Cmd == "restart")
{
m_bRestart = true;
+ return;
}
LOG("Executing console command: \"%s\"", a_Cmd.c_str());
diff --git a/src/Server.cpp b/src/Server.cpp
index 42ad133f1..4524ece76 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -457,33 +457,34 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
return;
}
- // Special handling: "stop" and "restart" are built in
- if ((split[0].compare("stop") == 0) || (split[0].compare("restart") == 0))
- {
- return;
- }
+ // "stop" and "restart" are handled in cRoot::ExecuteConsoleCommand, our caller, due to its access to controlling variables
// "help" and "reload" are to be handled by MCS, so that they work no matter what
if (split[0] == "help")
{
PrintHelp(split, a_Output);
+ a_Output.Finished();
return;
}
if (split[0] == "reload")
{
cPluginManager::Get()->ReloadPlugins();
cRoot::Get()->ReloadGroups();
+ a_Output.Out("Plugins and groups reloaded");
+ a_Output.Finished();
return;
}
if (split[0] == "reloadplugins")
{
cPluginManager::Get()->ReloadPlugins();
+ a_Output.Out("Plugins reloaded");
+ a_Output.Finished();
return;
}
if (split[0] == "reloadgroups")
{
cRoot::Get()->ReloadGroups();
- a_Output.Out("Groups reloaded!");
+ a_Output.Out("Groups reloaded");
a_Output.Finished();
return;
}
@@ -491,31 +492,54 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
{
if (split.size() > 1)
{
- cPluginManager::Get()->LoadPlugin(split[1]);
-
- return;
+ a_Output.Out(cPluginManager::Get()->LoadPlugin(split[1]) ? "Plugin loaded" : "Error occurred loading plugin");
}
else
{
- a_Output.Out("No plugin given! Command: load <pluginname>");
- a_Output.Finished();
- return;
+ a_Output.Out("Usage: load <pluginname>");
}
+ a_Output.Finished();
+ return;
}
-
if (split[0] == "unload")
{
if (split.size() > 1)
{
cPluginManager::Get()->RemovePlugin(cPluginManager::Get()->GetPlugin(split[1]));
- return;
+ a_Output.Out("Plugin unloaded");
}
else
{
- a_Output.Out("No plugin given! Command: unload <pluginname>");
- a_Output.Finished();
- return;
+ a_Output.Out("Usage: unload <pluginname>");
}
+ a_Output.Finished();
+ return;
+ }
+ if (split[0] == "destroyentities")
+ {
+ class WorldCallback : public cWorldListCallback
+ {
+ virtual bool Item(cWorld * a_World) override
+ {
+ class EntityCallback : public cEntityCallback
+ {
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ if (!a_Entity->IsPlayer())
+ {
+ a_Entity->Destroy();
+ }
+ return false;
+ }
+ } EC;
+ a_World->ForEachEntity(EC);
+ return false;
+ }
+ } WC;
+ cRoot::Get()->ForEachWorld(WC);
+ a_Output.Out("Destroyed all entities");
+ a_Output.Finished();
+ return;
}
// There is currently no way a plugin can do these (and probably won't ever be):
@@ -610,6 +634,7 @@ void cServer::BindBuiltInConsoleCommands(void)
PlgMgr->BindConsoleCommand("chunkstats", NULL, " - Displays detailed chunk memory statistics");
PlgMgr->BindConsoleCommand("load <pluginname>", NULL, " - Adds and enables the specified plugin");
PlgMgr->BindConsoleCommand("unload <pluginname>", NULL, " - Disables the specified plugin");
+ PlgMgr->BindConsoleCommand("destroyentities", NULL, " - Destroys all entities in all worlds");
#if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER)
PlgMgr->BindConsoleCommand("dumpmem", NULL, " - Dumps all used memory blocks together with their callstacks into memdump.xml");