From 61e58ee9b75683834819b84a85ba1256e2033c3f Mon Sep 17 00:00:00 2001 From: Calinou Date: Sun, 24 Jun 2012 23:18:16 +0200 Subject: [PATCH] Message cleanups (consistency) and prevent /me when not allowed to shout --- builtin/chatcommands.lua | 2 +- src/server.cpp | 12 ++++++------ src/servercommand.cpp | 20 +++++++++++++------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/builtin/chatcommands.lua b/builtin/chatcommands.lua index 9f033aa1..a60d3028 100644 --- a/builtin/chatcommands.lua +++ b/builtin/chatcommands.lua @@ -41,7 +41,7 @@ end) -- -- Register C++ commands without functions -minetest.register_chatcommand("me", {params = nil, description = "chat action (eg. /me orders a pizza)"}) +minetest.register_chatcommand("me", {params = nil, description = "chat action (eg. /me orders a pizza)", privs = {shout=true}}) minetest.register_chatcommand("status", {description = "print server status line"}) minetest.register_chatcommand("shutdown", {params = "", description = "shutdown server", privs = {server=true}}) minetest.register_chatcommand("clearobjects", {params = "", description = "clear all objects in world", privs = {server=true}}) diff --git a/src/server.cpp b/src/server.cpp index d703f7d9..f793c770 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2280,7 +2280,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) std::wstring message; message += L"*** "; message += name; - message += L" joined game"; + message += L" joined the game."; BroadcastChatMessage(message); } } @@ -2288,7 +2288,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) // Warnings about protocol version can be issued here if(getClient(peer_id)->net_proto_version < PROTOCOL_VERSION) { - SendChatMessage(peer_id, L"# Server: WARNING: YOUR CLIENT IS OLD AND MAY WORK PROPERLY WITH THIS SERVER"); + SendChatMessage(peer_id, L"# Server: WARNING: YOUR CLIENT IS OLD AND MAY WORK PROPERLY WITH THIS SERVER!"); } /* @@ -2710,7 +2710,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) line += message; send_to_others = true; } else { - line += L"Server: You are not allowed to shout"; + line += L"-!- You don't have permission to shout."; send_to_sender = true; } } @@ -2819,11 +2819,11 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) bool success = scriptapi_set_password(m_lua, playername, newpwd); if(success){ actionstream<getName()<<" changes password"<getName()<<" tries to change password but " <<"it fails"<getName()); message += L"*** "; message += name; - message += L" left game"; + message += L" left the game."; if(c.timeout) message += L" (timed out)"; } diff --git a/src/servercommand.cpp b/src/servercommand.cpp index fc2f2208..f14e0fba 100644 --- a/src/servercommand.cpp +++ b/src/servercommand.cpp @@ -32,6 +32,12 @@ void cmd_status(std::wostringstream &os, void cmd_me(std::wostringstream &os, ServerCommandContext *ctx) { + if(!ctx->server->checkPriv(ctx->player->getName(), "shout")) + { + os<player->getName()); os << L"* " << name << L" " << ctx->paramstring; ctx->flags |= SEND_TO_OTHERS | SEND_NO_PREFIX; @@ -48,13 +54,13 @@ void cmd_time(std::wostringstream &os, if(!ctx->server->checkPriv(ctx->player->getName(), "settime")) { - os<parms[1])); ctx->server->setTimeOfDay(time); - os<player->getName()<<" sets time " <server->checkPriv(ctx->player->getName(), "server")) { - os<server->requestShutdown(); - os<flags |= SEND_TO_OTHERS; } @@ -82,7 +88,7 @@ void cmd_banunban(std::wostringstream &os, ServerCommandContext *ctx) { if(!ctx->server->checkPriv(ctx->player->getName(), "ban")) { - os<server->checkPriv(ctx->player->getName(), "server")) { - os<flags |= SEND_TO_OTHERS; } -- 2.30.2