diff options
author | Philipp Sehmisch <mana@crushnet.org> | 2010-08-29 14:54:14 +0200 |
---|---|---|
committer | Freeyorp <Freeyorp101@hotmail.com> | 2010-08-30 02:12:54 +1200 |
commit | 64432a11e3135d82c37c65b6c8560312091453cd (patch) | |
tree | 41dee6e861ab321357e8e36ae32cae7e03ad1dfc /src | |
parent | 7fc50c2d31e1d289e9d2a950271c6d399fe0896a (diff) | |
download | manaserv-64432a11e3135d82c37c65b6c8560312091453cd.tar.gz manaserv-64432a11e3135d82c37c65b6c8560312091453cd.tar.bz2 manaserv-64432a11e3135d82c37c65b6c8560312091453cd.tar.xz manaserv-64432a11e3135d82c37c65b6c8560312091453cd.zip |
Added @mute chat command.
The @mute command stops another character from talking in the
public chat for a specified amount of seconds. It doesn't survive
a reconnect of the client, but I don't think that this is necessary
because a mute by a GM is usually intended as a slap on the wrist
with more severe consequences to follow (like @ban).
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/being.hpp | 3 | ||||
-rw-r--r-- | src/game-server/character.hpp | 7 | ||||
-rw-r--r-- | src/game-server/commandhandler.cpp | 52 | ||||
-rw-r--r-- | src/game-server/gamehandler.cpp | 11 |
4 files changed, 69 insertions, 4 deletions
diff --git a/src/game-server/being.hpp b/src/game-server/being.hpp index 5e365f50..0fb60a29 100644 --- a/src/game-server/being.hpp +++ b/src/game-server/being.hpp @@ -55,7 +55,8 @@ enum TimerID T_M_KILLSTEAL_PROTECTED, // killsteal protection time T_M_DECAY, // time until dead monster is removed T_M_ATTACK_TIME, // time until monster can attack again - T_B_HP_REGEN // time until hp is regenerated again + T_B_HP_REGEN, // time until hp is regenerated again + T_C_MUTE // time until the character can chat again }; struct Status diff --git a/src/game-server/character.hpp b/src/game-server/character.hpp index 5581fc7a..45612567 100644 --- a/src/game-server/character.hpp +++ b/src/game-server/character.hpp @@ -393,6 +393,13 @@ class Character : public Being virtual unsigned char getWalkMask() const { return 0x82; } // blocked by walls and monsters ( bin 1000 0010) + /** Makes it impossible to chat for a while */ + void mute(int seconds) + { setTimerHard(T_C_MUTE, seconds * 10); } + + bool isMuted() const + { return isTimerRunning(T_C_MUTE); } + protected: /** * Gets the way the actor blocks pathfinding for other objects diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp index cf5673ba..eb894b5c 100644 --- a/src/game-server/commandhandler.cpp +++ b/src/game-server/commandhandler.cpp @@ -32,6 +32,7 @@ #include "game-server/monstermanager.hpp" #include "game-server/state.hpp" +#include "common/configuration.hpp" #include "common/permissionmanager.hpp" #include "common/transaction.hpp" @@ -63,6 +64,7 @@ static void handleGivePermission(Character*, std::string&); static void handleTakePermission(Character*, std::string&); static void handleAnnounce(Character*, std::string&); static void handleHistory(Character*, std::string&); +static void handleMute(Character*, std::string&); static CmdRef const cmdRef[] = { @@ -102,6 +104,8 @@ static CmdRef const cmdRef[] = "Sends a chat message to all characters in the game", &handleAnnounce}, {"history", "<number of transactions>", "Shows the last transactions", &handleHistory}, + {"mute","<character> <length in seconds>", + "Prevents the character from talking for the specified number of seconds. Use 0 seconds to unmute.", &handleMute}, {NULL, NULL, NULL, NULL} }; @@ -923,6 +927,54 @@ static void handleHistory(Character *player, std::string &args) } +static void handleMute(Character *player, std::string &args) +{ Character *other; + int length; + + // get arguments + std::string character = getArgument(args); + std::string valuestr = getArgument(args); + + + // check for valid player + other = getPlayer(character); + if (!other) + { + say("Invalid character", player); + return; + } + + // change the length to an integer + if (valuestr.empty()) + { + length = Configuration::getValue("defaultMuteLength", 60); + } else { + length = utils::stringToInt(valuestr); + } + if (length < 0) + { + say("Invalid length, using default", player); + length = Configuration::getValue("defaultMuteLength", 60); + } + + // mute the player + other->mute(length); + + // feedback + std::stringstream targetMsg; + std::stringstream userMsg; + if (length > 0) + { + targetMsg << player->getName() << " muted you for " << length << " seconds."; + userMsg << "You muted " << other->getName() << " for " << length << " seconds."; + } else { + targetMsg << player->getName() << " unmuted you."; + userMsg << "You unmuted " << other->getName() << "."; + } + GameState::sayTo(other, NULL, targetMsg.str()); + GameState::sayTo(player, NULL, userMsg.str()); +} + void CommandHandler::handleCommand(Character *player, const std::string &command) { diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp index fcefa276..95478d82 100644 --- a/src/game-server/gamehandler.cpp +++ b/src/game-server/gamehandler.cpp @@ -196,9 +196,14 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message) CommandHandler::handleCommand(computer.character, say); break; } - GameState::sayAround(computer.character, say); - std::string msg = computer.character->getName() + " said " + say; - accountHandler->sendTransaction(computer.character->getDatabaseID(), TRANS_MSG_PUBLIC, msg); + if (!computer.character->isMuted()) + { + GameState::sayAround(computer.character, say); + std::string msg = computer.character->getName() + " said " + say; + accountHandler->sendTransaction(computer.character->getDatabaseID(), TRANS_MSG_PUBLIC, msg); + }else { + GameState::sayTo(computer.character, NULL, "You are not allowed to talk right now."); + } } break; case PGMSG_NPC_TALK: |