diff options
author | Matthew I <matttpt@gmail.com> | 2012-07-22 09:42:43 -0400 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-08-12 16:45:58 +0300 |
commit | b29d609b0bf54345f9c7cb8a1e3d6de6799fa147 (patch) | |
tree | 27fe7910ccc4e1487f0eb56b00868d62b41172a4 /src/server.cpp | |
parent | 8a3c777c40e2b61c1ba561ba0c60ab8d281886d2 (diff) | |
download | minetest-b29d609b0bf54345f9c7cb8a1e3d6de6799fa147.tar.gz minetest-b29d609b0bf54345f9c7cb8a1e3d6de6799fa147.tar.bz2 minetest-b29d609b0bf54345f9c7cb8a1e3d6de6799fa147.zip |
Move chat commands to Lua and remove servercommand.{cpp,h}
Commands moved:
/me
/status
/time
/shutdown
/ban
/clearobjects
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/src/server.cpp b/src/server.cpp index 85e361ced..ba99f4707 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "constants.h" #include "voxel.h" #include "config.h" -#include "servercommand.h" #include "filesys.h" #include "mapblock.h" #include "serverobject.h" @@ -2653,36 +2652,16 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) // Whether to send to other players bool send_to_others = false; - // Parse commands + // Commands are implemented in Lua, so only catch invalid + // commands that were not "eaten" and send an error back if(message[0] == L'/') { - size_t strip_size = 1; - if (message[1] == L'#') // support old-style commans - ++strip_size; - message = message.substr(strip_size); - - WStrfnd f1(message); - f1.next(L" "); // Skip over /#whatever - std::wstring paramstring = f1.next(L""); - - ServerCommandContext *ctx = new ServerCommandContext( - str_split(message, L' '), - paramstring, - this, - m_env, - player); - - std::wstring reply(processServerCommand(ctx)); - send_to_sender = ctx->flags & SEND_TO_SENDER; - send_to_others = ctx->flags & SEND_TO_OTHERS; - - if (ctx->flags & SEND_NO_PREFIX) - line += reply; + message = message.substr(1); + send_to_sender = true; + if(message.length() == 0) + line += L"-!- Empty command"; else - line += L"Server: " + reply; - - delete ctx; - + line += L"-!- Invalid command: " + str_split(message, L' ')[0]; } else { |