summaryrefslogtreecommitdiff
path: root/src/game-server/commandhandler.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <mana@crushnet.org>2010-12-27 17:33:41 +0100
committerPhilipp Sehmisch <mana@crushnet.org>2010-12-27 17:33:41 +0100
commita1514113093733b65e36224dad81f6867edcb93c (patch)
tree2379ed168c9de7f8f6a920dc850210246c79fc5f /src/game-server/commandhandler.cpp
parent3f559162b2e3cb0b434095d0bac297f67ff53d86 (diff)
downloadmanaserv-a1514113093733b65e36224dad81f6867edcb93c.tar.gz
manaserv-a1514113093733b65e36224dad81f6867edcb93c.tar.bz2
manaserv-a1514113093733b65e36224dad81f6867edcb93c.tar.xz
manaserv-a1514113093733b65e36224dad81f6867edcb93c.zip
Transaction logging of various command, new transaction codes and style fix.
The @mute, @goto, @attribute and @announce commands now logs transactions to the database. Added new transaction codes to database. I've preliminarily added a lot of codes for not yet supported commands so that we needn't do a database update with every single commit which implements one. Also using the equivalent "say" helper function in place of the "GameState::sayTo" method in the command handler. Reviewed-by: Kage
Diffstat (limited to 'src/game-server/commandhandler.cpp')
-rw-r--r--src/game-server/commandhandler.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp
index 1daa6acc..5fbcb211 100644
--- a/src/game-server/commandhandler.cpp
+++ b/src/game-server/commandhandler.cpp
@@ -705,6 +705,11 @@ static void handleGoto(Character *player, std::string &args)
MapComposite *map = other->getMap();
const Point &pos = other->getPosition();
GameState::warp(player, map, pos.x, pos.y);
+
+ // log transaction
+ std::stringstream msg;
+ msg << "User warped own character to " << other->getName();
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_GOTO, msg.str());
}
static void handleRecall(Character *player, std::string &args)
@@ -901,7 +906,7 @@ static void handleTakePermission(Character *player, std::string &args)
accountHandler->changeAccountLevel(other, permission);
// log transaction
- std::string msg = "User took right " + strPermission + " to " + other->getName();
+ std::string msg = "User took right " + strPermission + " from " + other->getName();
accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_SETGROUP, msg);
say("Sorry, "+player->getName()+" revoked your rights of a "+strPermission, other);
}
@@ -969,6 +974,12 @@ static void handleAttribute(Character *player, std::string &args)
// change the player's attribute
other->setAttribute(attr, value);
+
+ // log transaction
+ std::stringstream msg;
+ msg << "User changed attribute " << attr << " of player " << other->getName()
+ << " to " << value;
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_ATTRIBUTE, msg.str());
}
static void handleReport(Character *player, std::string &args)
@@ -995,6 +1006,9 @@ static void handleAnnounce(Character *player, std::string &msg)
}
GameState::sayToAll(msg);
+
+ // log transaction
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_ANNOUNCE, msg);
}
static void handleWhere(Character *player, std::string &)
@@ -1085,14 +1099,24 @@ static void handleMute(Character *player, std::string &args)
targetMsg << player->getName() << " unmuted you.";
userMsg << "You unmuted " << other->getName() << ".";
}
- GameState::sayTo(other, NULL, targetMsg.str());
- GameState::sayTo(player, NULL, userMsg.str());
+ say(targetMsg.str(), other);
+ say(userMsg.str(), player);
+
+ // log transaction
+ std::stringstream msg;
+ if (length > 0)
+ {
+ msg << "User muted " << other->getName() << " for " << length << " seconds.";
+ } else {
+ msg << "User unmuted " << other->getName();
+ }
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_MUTE, msg.str());
}
static void handleDie(Character *player, std::string &args)
{
player->setAttribute(ATTR_HP, 0);
- GameState::sayTo(player, NULL, "You've killed yourself.");
+ say("You've killed yourself.", player);
}
void CommandHandler::handleCommand(Character *player,