summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2010-12-27 18:11:27 +0100
committerPhilipp Sehmisch <mana@crushnet.org>2010-12-27 18:11:27 +0100
commitd1ac4d5cd3b605526f2b1a3caa3339718962d415 (patch)
tree2b8e43ae739eed4583d9a82c7d9613fd781a930f
parenta1514113093733b65e36224dad81f6867edcb93c (diff)
downloadmanaserv-d1ac4d5cd3b605526f2b1a3caa3339718962d415.tar.gz
manaserv-d1ac4d5cd3b605526f2b1a3caa3339718962d415.tar.bz2
manaserv-d1ac4d5cd3b605526f2b1a3caa3339718962d415.tar.xz
manaserv-d1ac4d5cd3b605526f2b1a3caa3339718962d415.zip
Added @kick and @kill commands.
@kick disconnects the client connection of a character. The new error- code 11 (ERRMSG_ADMINISTRATIVE_LOGOFF) is not supported by the client yet. It will show a generic "The connection to server was lost" message instead. @kill kills the character by setting its HP to 0. Added @kick transaction code I forgot in last commit. Considering that this was just minutes ago I think that noone updated his database yet. So I don't think that a new database version is justified for this. Reviewed-by: Bertram
-rw-r--r--src/common/transaction.h3
-rw-r--r--src/game-server/commandhandler.cpp71
-rw-r--r--src/sql/mysql/createTables.sql1
-rw-r--r--src/sql/mysql/updates/update_12_to_13.sql1
-rw-r--r--src/sql/sqlite/createTables.sql1
-rw-r--r--src/sql/sqlite/updates/update_12_to_13.sql1
6 files changed, 77 insertions, 1 deletions
diff --git a/src/common/transaction.h b/src/common/transaction.h
index bc5d2a55..fdd0b8f7 100644
--- a/src/common/transaction.h
+++ b/src/common/transaction.h
@@ -82,7 +82,8 @@ enum
TRANS_CMD_SHUTDOWN_ALL,
TRANS_CMD_RESTART_THIS,
TRANS_CMD_RESTART_ALL,
- TRANS_CMD_ATTRIBUTE
+ TRANS_CMD_ATTRIBUTE,
+ TRANS_CMD_KICK
};
#endif
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp
index 5fbcb211..ef0b6017 100644
--- a/src/game-server/commandhandler.cpp
+++ b/src/game-server/commandhandler.cpp
@@ -68,6 +68,8 @@ static void handleAnnounce(Character*, std::string&);
static void handleHistory(Character*, std::string&);
static void handleMute(Character*, std::string&);
static void handleDie(Character*, std::string&);
+static void handleKill(Character*, std::string&);
+static void handleKick(Character*, std::string&);
static CmdRef const cmdRef[] =
{
@@ -113,6 +115,10 @@ static CmdRef const cmdRef[] =
"Prevents the character from talking for the specified number of seconds. Use 0 seconds to unmute.", &handleMute},
{"die", "",
"Kills you.", &handleDie},
+ {"kill", "<character>",
+ "Kills the character.", &handleKill},
+ {"kick", "<character>",
+ "Disconnects the client of character.", &handleKick},
{NULL, NULL, NULL, NULL}
};
@@ -1119,6 +1125,71 @@ static void handleDie(Character *player, std::string &args)
say("You've killed yourself.", player);
}
+static void handleKill(Character *player, std::string &args)
+{
+ Character *other;
+
+ // get arguments
+ std::string character = getArgument(args);
+
+ // check for valid player
+ other = getPlayer(character);
+ if (!other)
+ {
+ say("Invalid character", player);
+ return;
+ }
+
+ // kill the player
+ player->setAttribute(ATTR_HP, 0);
+
+ // feedback
+ std::stringstream targetMsg;
+ std::stringstream userMsg;
+ targetMsg << "You were killed by server command from "<< player->getName() << ".";
+ userMsg << "You killed " << other->getName() << ".";
+ say(targetMsg.str(), other);
+ say(userMsg.str(), player);
+
+ // log transaction
+ std::stringstream logMsg;
+ logMsg << "User killed " << other->getName();
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_KILL, logMsg.str());
+}
+
+static void handleKick(Character *player, std::string &args)
+{
+ Character *other;
+
+ // get arguments
+ std::string character = getArgument(args);
+
+ // check for valid player
+ other = getPlayer(character);
+ if (!other)
+ {
+ say("Invalid character", player);
+ return;
+ }
+
+ // send feedback
+ std::stringstream userMsg;
+ userMsg << "You kicked " << other->getName() << ".";
+ say(userMsg.str(), player);
+
+ // disconnect the client
+ MessageOut msg(GPMSG_CONNECT_RESPONSE);
+ msg.writeInt8(ERRMSG_ADMINISTRATIVE_LOGOFF);
+ other->getClient()->disconnect(msg);
+
+ // log transaction
+ std::stringstream logMsg;
+ logMsg << "User kicked " << other->getName();
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_KICK, logMsg.str());
+}
+
+
+
void CommandHandler::handleCommand(Character *player,
const std::string &command)
{
diff --git a/src/sql/mysql/createTables.sql b/src/sql/mysql/createTables.sql
index ab07cbda..eb62d869 100644
--- a/src/sql/mysql/createTables.sql
+++ b/src/sql/mysql/createTables.sql
@@ -477,3 +477,4 @@ INSERT INTO mana_transaction_codes VALUES ( 50, 'Command SHUTDOWN_ALL', 'Com
INSERT INTO mana_transaction_codes VALUES ( 51, 'Command RESTART_THIS', 'Commands' );
INSERT INTO mana_transaction_codes VALUES ( 52, 'Command RESTART_ALL', 'Commands' );
INSERT INTO mana_transaction_codes VALUES ( 53, 'Command ATTRIBUTE', 'Commands' );
+INSERT INTO mana_transaction_codes VALUES ( 54, 'Command KICK', 'Commands' );
diff --git a/src/sql/mysql/updates/update_12_to_13.sql b/src/sql/mysql/updates/update_12_to_13.sql
index 27cb8340..a2387cd2 100644
--- a/src/sql/mysql/updates/update_12_to_13.sql
+++ b/src/sql/mysql/updates/update_12_to_13.sql
@@ -20,6 +20,7 @@ INSERT INTO mana_transaction_codes VALUES ( 50, 'Command SHUTDOWN_ALL', 'Com
INSERT INTO mana_transaction_codes VALUES ( 51, 'Command RESTART_THIS', 'Commands' );
INSERT INTO mana_transaction_codes VALUES ( 52, 'Command RESTART_ALL', 'Commands' );
INSERT INTO mana_transaction_codes VALUES ( 53, 'Command ATTRIBUTE', 'Commands' );
+INSERT INTO mana_transaction_codes VALUES ( 54, 'Command KICK', 'Commands' );
-- Update database version.
UPDATE mana_world_states
diff --git a/src/sql/sqlite/createTables.sql b/src/sql/sqlite/createTables.sql
index e279aece..3ab59d76 100644
--- a/src/sql/sqlite/createTables.sql
+++ b/src/sql/sqlite/createTables.sql
@@ -462,3 +462,4 @@ INSERT INTO mana_transaction_codes VALUES ( 50, 'Command SHUTDOWN_ALL', 'Com
INSERT INTO mana_transaction_codes VALUES ( 51, 'Command RESTART_THIS', 'Commands' );
INSERT INTO mana_transaction_codes VALUES ( 52, 'Command RESTART_ALL', 'Commands' );
INSERT INTO mana_transaction_codes VALUES ( 53, 'Command ATTRIBUTE', 'Commands' );
+INSERT INTO mana_transaction_codes VALUES ( 54, 'Command KICK', 'Commands' );
diff --git a/src/sql/sqlite/updates/update_12_to_13.sql b/src/sql/sqlite/updates/update_12_to_13.sql
index af639df7..9f28fc16 100644
--- a/src/sql/sqlite/updates/update_12_to_13.sql
+++ b/src/sql/sqlite/updates/update_12_to_13.sql
@@ -20,6 +20,7 @@ INSERT INTO mana_transaction_codes VALUES ( 50, 'Command SHUTDOWN_ALL', 'Com
INSERT INTO mana_transaction_codes VALUES ( 51, 'Command RESTART_THIS', 'Commands' );
INSERT INTO mana_transaction_codes VALUES ( 52, 'Command RESTART_ALL', 'Commands' );
INSERT INTO mana_transaction_codes VALUES ( 53, 'Command ATTRIBUTE', 'Commands' );
+INSERT INTO mana_transaction_codes VALUES ( 54, 'Command KICK', 'Commands' );
-- update the database version, and set date of update
UPDATE mana_world_states