summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--accountserver.cbp3
-rw-r--r--gameserver.cbp217
-rw-r--r--src/account-server/accounthandler.cpp2
-rw-r--r--src/account-server/dalstorage.hpp4
-rw-r--r--src/account-server/serverhandler.cpp15
-rw-r--r--src/chat-server/chathandler.cpp2
-rw-r--r--src/common/transaction.hpp (renamed from src/account-server/transaction.hpp)19
-rw-r--r--src/defines.h1
-rw-r--r--src/game-server/accountconnection.cpp9
-rw-r--r--src/game-server/accountconnection.hpp5
-rw-r--r--src/game-server/commandhandler.cpp43
-rw-r--r--src/game-server/gamehandler.cpp75
12 files changed, 277 insertions, 118 deletions
diff --git a/accountserver.cbp b/accountserver.cbp
index 1cfd0bb..b72f68b 100644
--- a/accountserver.cbp
+++ b/accountserver.cbp
@@ -68,8 +68,6 @@
<Unit filename="src/account-server/main-account.cpp" />
<Unit filename="src/account-server/serverhandler.cpp" />
<Unit filename="src/account-server/serverhandler.hpp" />
- <Unit filename="src/account-server/transaction.cpp" />
- <Unit filename="src/account-server/transaction.hpp" />
<Unit filename="src/chat-server/chatchannel.cpp" />
<Unit filename="src/chat-server/chatchannel.hpp" />
<Unit filename="src/chat-server/chatchannelmanager.cpp" />
@@ -90,6 +88,7 @@
<Unit filename="src/common/configuration.cpp" />
<Unit filename="src/common/configuration.hpp" />
<Unit filename="src/common/inventorydata.hpp" />
+ <Unit filename="src/common/transaction.hpp" />
<Unit filename="src/dal/dalexcept.h" />
<Unit filename="src/dal/dataprovider.cpp" />
<Unit filename="src/dal/dataprovider.h" />
diff --git a/gameserver.cbp b/gameserver.cbp
index 0311d10..27fcbdb 100644
--- a/gameserver.cbp
+++ b/gameserver.cbp
@@ -23,7 +23,7 @@
</Linker>
</Target>
<Target title="unix">
- <Option output="bin\gameserver" prefix_auto="1" extension_auto="1" />
+ <Option output="bin/gameserver" prefix_auto="1" extension_auto="1" />
<Option working_dir="bin" />
<Option type="1" />
<Option compiler="gcc" />
@@ -31,12 +31,12 @@
<Compiler>
<Add option="-g" />
<Add directory="src" />
- <Add directory="\usr\local\include\libxml2" />
- <Add directory="\usr\local\include\lua51" />
+ <Add directory="/usr/local/include/libxml2" />
+ <Add directory="/usr/local/include/lua51" />
</Compiler>
<Linker>
<Add library="pthread" />
- <Add directory="\usr\local\lib\lua51" />
+ <Add directory="/usr/local/lib/lua51" />
</Linker>
</Target>
</Build>
@@ -53,110 +53,111 @@
<Add library="z" />
<Add library="lua" />
</Linker>
- <Unit filename="src\common\configuration.cpp" />
- <Unit filename="src\common\configuration.hpp" />
- <Unit filename="src\common\inventorydata.hpp" />
- <Unit filename="src\defines.h" />
- <Unit filename="src\game-server\accountconnection.cpp" />
- <Unit filename="src\game-server\accountconnection.hpp" />
- <Unit filename="src\game-server\attackzone.cpp" />
- <Unit filename="src\game-server\attackzone.hpp" />
- <Unit filename="src\game-server\being.cpp" />
- <Unit filename="src\game-server\being.hpp" />
- <Unit filename="src\game-server\buysell.cpp" />
- <Unit filename="src\game-server\buysell.hpp" />
- <Unit filename="src\game-server\character.cpp" />
- <Unit filename="src\game-server\character.hpp" />
- <Unit filename="src\game-server\collisiondetection.cpp" />
- <Unit filename="src\game-server\collisiondetection.hpp" />
- <Unit filename="src\game-server\commandhandler.cpp" />
- <Unit filename="src\game-server\commandhandler.hpp" />
- <Unit filename="src\game-server\effect.cpp" />
- <Unit filename="src\game-server\effect.hpp" />
- <Unit filename="src\game-server\eventlistener.hpp" />
- <Unit filename="src\game-server\gamehandler.cpp" />
- <Unit filename="src\game-server\gamehandler.hpp" />
- <Unit filename="src\game-server\inventory.cpp" />
- <Unit filename="src\game-server\inventory.hpp" />
- <Unit filename="src\game-server\item.cpp" />
- <Unit filename="src\game-server\item.hpp" />
- <Unit filename="src\game-server\itemmanager.cpp" />
- <Unit filename="src\game-server\itemmanager.hpp" />
- <Unit filename="src\game-server\main-game.cpp" />
- <Unit filename="src\game-server\map.cpp" />
- <Unit filename="src\game-server\map.hpp" />
- <Unit filename="src\game-server\mapcomposite.cpp" />
- <Unit filename="src\game-server\mapcomposite.hpp" />
- <Unit filename="src\game-server\mapmanager.cpp" />
- <Unit filename="src\game-server\mapmanager.hpp" />
- <Unit filename="src\game-server\mapreader.cpp" />
- <Unit filename="src\game-server\mapreader.hpp" />
- <Unit filename="src\game-server\monster.cpp" />
- <Unit filename="src\game-server\monster.hpp" />
- <Unit filename="src\game-server\monstermanager.cpp" />
- <Unit filename="src\game-server\monstermanager.hpp" />
- <Unit filename="src\game-server\movingobject.cpp" />
- <Unit filename="src\game-server\movingobject.hpp" />
- <Unit filename="src\game-server\npc.cpp" />
- <Unit filename="src\game-server\npc.hpp" />
- <Unit filename="src\game-server\object.hpp" />
- <Unit filename="src\game-server\postman.hpp" />
- <Unit filename="src\game-server\quest.cpp" />
- <Unit filename="src\game-server\quest.hpp" />
- <Unit filename="src\game-server\resourcemanager.cpp" />
- <Unit filename="src\game-server\resourcemanager.hpp" />
- <Unit filename="src\game-server\spawnarea.cpp" />
- <Unit filename="src\game-server\spawnarea.hpp" />
- <Unit filename="src\game-server\state.cpp" />
- <Unit filename="src\game-server\state.hpp" />
- <Unit filename="src\game-server\thing.cpp" />
- <Unit filename="src\game-server\thing.hpp" />
- <Unit filename="src\game-server\trade.cpp" />
- <Unit filename="src\game-server\trade.hpp" />
- <Unit filename="src\game-server\trigger.cpp" />
- <Unit filename="src\game-server\trigger.hpp" />
- <Unit filename="src\net\bandwidth.cpp" />
- <Unit filename="src\net\bandwidth.hpp" />
- <Unit filename="src\net\connection.cpp" />
- <Unit filename="src\net\connection.hpp" />
- <Unit filename="src\net\connectionhandler.cpp" />
- <Unit filename="src\net\connectionhandler.hpp" />
- <Unit filename="src\net\messagein.cpp" />
- <Unit filename="src\net\messagein.hpp" />
- <Unit filename="src\net\messageout.cpp" />
- <Unit filename="src\net\messageout.hpp" />
- <Unit filename="src\net\netcomputer.cpp" />
- <Unit filename="src\net\netcomputer.hpp" />
- <Unit filename="src\point.h" />
- <Unit filename="src\scripting\lua.cpp" />
- <Unit filename="src\scripting\luascript.cpp" />
- <Unit filename="src\scripting\luascript.hpp" />
- <Unit filename="src\scripting\luautil.cpp" />
- <Unit filename="src\scripting\luautil.hpp" />
- <Unit filename="src\scripting\script.cpp" />
- <Unit filename="src\scripting\script.hpp" />
- <Unit filename="src\utils\base64.cpp" />
- <Unit filename="src\utils\base64.h" />
- <Unit filename="src\utils\logger.cpp" />
- <Unit filename="src\utils\logger.h" />
- <Unit filename="src\utils\mathutils.cpp" />
- <Unit filename="src\utils\mathutils.h" />
- <Unit filename="src\utils\processorutils.cpp" />
- <Unit filename="src\utils\processorutils.hpp" />
- <Unit filename="src\utils\string.cpp" />
- <Unit filename="src\utils\string.hpp" />
- <Unit filename="src\utils\stringfilter.cpp" />
- <Unit filename="src\utils\stringfilter.h" />
- <Unit filename="src\utils\timer.cpp" />
- <Unit filename="src\utils\timer.h" />
- <Unit filename="src\utils\tokencollector.cpp" />
- <Unit filename="src\utils\tokencollector.hpp" />
- <Unit filename="src\utils\tokendispenser.cpp" />
- <Unit filename="src\utils\tokendispenser.hpp" />
- <Unit filename="src\utils\xml.cpp" />
- <Unit filename="src\utils\xml.hpp" />
- <Unit filename="src\utils\zlib.cpp" />
- <Unit filename="src\utils\zlib.hpp" />
+ <Unit filename="src/common/configuration.cpp" />
+ <Unit filename="src/common/configuration.hpp" />
+ <Unit filename="src/common/inventorydata.hpp" />
+ <Unit filename="src/common/transaction.hpp" />
+ <Unit filename="src/defines.h" />
+ <Unit filename="src/game-server/accountconnection.cpp" />
+ <Unit filename="src/game-server/accountconnection.hpp" />
+ <Unit filename="src/game-server/attackzone.cpp" />
+ <Unit filename="src/game-server/attackzone.hpp" />
+ <Unit filename="src/game-server/being.cpp" />
+ <Unit filename="src/game-server/being.hpp" />
+ <Unit filename="src/game-server/buysell.cpp" />
+ <Unit filename="src/game-server/buysell.hpp" />
+ <Unit filename="src/game-server/character.cpp" />
+ <Unit filename="src/game-server/character.hpp" />
+ <Unit filename="src/game-server/collisiondetection.cpp" />
+ <Unit filename="src/game-server/collisiondetection.hpp" />
+ <Unit filename="src/game-server/commandhandler.cpp" />
+ <Unit filename="src/game-server/commandhandler.hpp" />
+ <Unit filename="src/game-server/effect.cpp" />
+ <Unit filename="src/game-server/effect.hpp" />
+ <Unit filename="src/game-server/eventlistener.hpp" />
+ <Unit filename="src/game-server/gamehandler.cpp" />
+ <Unit filename="src/game-server/gamehandler.hpp" />
+ <Unit filename="src/game-server/inventory.cpp" />
+ <Unit filename="src/game-server/inventory.hpp" />
+ <Unit filename="src/game-server/item.cpp" />
+ <Unit filename="src/game-server/item.hpp" />
+ <Unit filename="src/game-server/itemmanager.cpp" />
+ <Unit filename="src/game-server/itemmanager.hpp" />
+ <Unit filename="src/game-server/main-game.cpp" />
+ <Unit filename="src/game-server/map.cpp" />
+ <Unit filename="src/game-server/map.hpp" />
+ <Unit filename="src/game-server/mapcomposite.cpp" />
+ <Unit filename="src/game-server/mapcomposite.hpp" />
+ <Unit filename="src/game-server/mapmanager.cpp" />
+ <Unit filename="src/game-server/mapmanager.hpp" />
+ <Unit filename="src/game-server/mapreader.cpp" />
+ <Unit filename="src/game-server/mapreader.hpp" />
+ <Unit filename="src/game-server/monster.cpp" />
+ <Unit filename="src/game-server/monster.hpp" />
+ <Unit filename="src/game-server/monstermanager.cpp" />
+ <Unit filename="src/game-server/monstermanager.hpp" />
+ <Unit filename="src/game-server/movingobject.cpp" />
+ <Unit filename="src/game-server/movingobject.hpp" />
+ <Unit filename="src/game-server/npc.cpp" />
+ <Unit filename="src/game-server/npc.hpp" />
+ <Unit filename="src/game-server/object.hpp" />
+ <Unit filename="src/game-server/postman.hpp" />
+ <Unit filename="src/game-server/quest.cpp" />
+ <Unit filename="src/game-server/quest.hpp" />
+ <Unit filename="src/game-server/resourcemanager.cpp" />
+ <Unit filename="src/game-server/resourcemanager.hpp" />
+ <Unit filename="src/game-server/spawnarea.cpp" />
+ <Unit filename="src/game-server/spawnarea.hpp" />
+ <Unit filename="src/game-server/state.cpp" />
+ <Unit filename="src/game-server/state.hpp" />
+ <Unit filename="src/game-server/thing.cpp" />
+ <Unit filename="src/game-server/thing.hpp" />
+ <Unit filename="src/game-server/trade.cpp" />
+ <Unit filename="src/game-server/trade.hpp" />
+ <Unit filename="src/game-server/trigger.cpp" />
+ <Unit filename="src/game-server/trigger.hpp" />
+ <Unit filename="src/net/bandwidth.cpp" />
+ <Unit filename="src/net/bandwidth.hpp" />
+ <Unit filename="src/net/connection.cpp" />
+ <Unit filename="src/net/connection.hpp" />
+ <Unit filename="src/net/connectionhandler.cpp" />
+ <Unit filename="src/net/connectionhandler.hpp" />
+ <Unit filename="src/net/messagein.cpp" />
+ <Unit filename="src/net/messagein.hpp" />
+ <Unit filename="src/net/messageout.cpp" />
+ <Unit filename="src/net/messageout.hpp" />
+ <Unit filename="src/net/netcomputer.cpp" />
+ <Unit filename="src/net/netcomputer.hpp" />
+ <Unit filename="src/point.h" />
+ <Unit filename="src/scripting/lua.cpp" />
+ <Unit filename="src/scripting/luascript.cpp" />
+ <Unit filename="src/scripting/luascript.hpp" />
+ <Unit filename="src/scripting/luautil.cpp" />
+ <Unit filename="src/scripting/luautil.hpp" />
+ <Unit filename="src/scripting/script.cpp" />
+ <Unit filename="src/scripting/script.hpp" />
+ <Unit filename="src/utils/base64.cpp" />
+ <Unit filename="src/utils/base64.h" />
+ <Unit filename="src/utils/logger.cpp" />
+ <Unit filename="src/utils/logger.h" />
+ <Unit filename="src/utils/mathutils.cpp" />
+ <Unit filename="src/utils/mathutils.h" />
+ <Unit filename="src/utils/processorutils.cpp" />
+ <Unit filename="src/utils/processorutils.hpp" />
+ <Unit filename="src/utils/string.cpp" />
+ <Unit filename="src/utils/string.hpp" />
+ <Unit filename="src/utils/stringfilter.cpp" />
+ <Unit filename="src/utils/stringfilter.h" />
+ <Unit filename="src/utils/timer.cpp" />
+ <Unit filename="src/utils/timer.h" />
+ <Unit filename="src/utils/tokencollector.cpp" />
+ <Unit filename="src/utils/tokencollector.hpp" />
+ <Unit filename="src/utils/tokendispenser.cpp" />
+ <Unit filename="src/utils/tokendispenser.hpp" />
+ <Unit filename="src/utils/xml.cpp" />
+ <Unit filename="src/utils/xml.hpp" />
+ <Unit filename="src/utils/zlib.cpp" />
+ <Unit filename="src/utils/zlib.hpp" />
<Extensions>
<code_completion />
<debugger />
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp
index a1280e3..425a42a 100644
--- a/src/account-server/accounthandler.cpp
+++ b/src/account-server/accounthandler.cpp
@@ -28,9 +28,9 @@
#include "account-server/character.hpp"
#include "account-server/dalstorage.hpp"
#include "account-server/serverhandler.hpp"
-#include "account-server/transaction.hpp"
#include "chat-server/chathandler.hpp"
#include "common/configuration.hpp"
+#include "common/transaction.hpp"
#include "net/connectionhandler.hpp"
#include "net/messagein.hpp"
#include "net/messageout.hpp"
diff --git a/src/account-server/dalstorage.hpp b/src/account-server/dalstorage.hpp
index 131cf81..8ff796a 100644
--- a/src/account-server/dalstorage.hpp
+++ b/src/account-server/dalstorage.hpp
@@ -25,9 +25,9 @@
#include <map>
#include <vector>
-#include "dal/dataprovider.h"
+#include "../dal/dataprovider.h"
-#include "transaction.hpp"
+#include "../common/transaction.hpp"
class Account;
class Character;
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp
index 23f2cd3..f5409b6 100644
--- a/src/account-server/serverhandler.cpp
+++ b/src/account-server/serverhandler.cpp
@@ -30,6 +30,7 @@
#include "account-server/character.hpp"
#include "account-server/dalstorage.hpp"
#include "chat-server/post.hpp"
+#include "common/transaction.hpp"
#include "net/connectionhandler.hpp"
#include "net/messageout.hpp"
#include "net/netcomputer.hpp"
@@ -465,6 +466,20 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
result.writeByte(ERRMSG_OK);
} break;
+ case GAMSG_TRANSACTION:
+ {
+ LOG_DEBUG("TRANSACTION");
+ int id = msg.readLong();
+ int action = msg.readLong();
+ std::string message = msg.readString();
+
+ Transaction trans;
+ trans.mCharacterId = id;
+ trans.mAction = action;
+ trans.mMessage = message;
+ storage->addTransaction(trans);
+ } break;
+
default:
LOG_WARN("ServerHandler::processMessage, Invalid message type: "
<< msg.getId());
diff --git a/src/chat-server/chathandler.cpp b/src/chat-server/chathandler.cpp
index 555c1a0..8def67f 100644
--- a/src/chat-server/chathandler.cpp
+++ b/src/chat-server/chathandler.cpp
@@ -27,11 +27,11 @@
#include "defines.h"
#include "account-server/character.hpp"
#include "account-server/dalstorage.hpp"
-#include "account-server/transaction.hpp"
#include "chat-server/guildmanager.hpp"
#include "chat-server/chatchannelmanager.hpp"
#include "chat-server/chatclient.hpp"
#include "chat-server/chathandler.hpp"
+#include "common/transaction.hpp"
#include "net/connectionhandler.hpp"
#include "net/messagein.hpp"
#include "net/messageout.hpp"
diff --git a/src/account-server/transaction.hpp b/src/common/transaction.hpp
index fa007df..21a00de 100644
--- a/src/account-server/transaction.hpp
+++ b/src/common/transaction.hpp
@@ -43,6 +43,25 @@ enum
TRANS_CHANNEL_LIST,
TRANS_CHANNEL_USERLIST,
TRANS_CHANNEL_TOPIC,
+ TRANS_CMD_BAN,
+ TRANS_CMD_DROP,
+ TRANS_CMD_ITEM,
+ TRANS_CMD_MONEY,
+ TRANS_CMD_SETGROUP,
+ TRANS_CMD_SPAWN,
+ TRANS_CMD_WARP,
+ TRANS_ITEM_PICKUP,
+ TRANS_ITEM_USED,
+ TRANS_ITEM_DROP,
+ TRANS_ITEM_MOVE,
+ TRANS_ATTACK_TARGET,
+ TRANS_ACTION_CHANGE,
+ TRANS_TRADE_REQUEST,
+ TRANS_TRADE_END,
+ TRANS_TRADE_MONEY,
+ TRANS_TRADE_ITEM,
+ TRANS_ATTR_INCREASE,
+ TRANS_ATTR_DECREASE,
};
#endif
diff --git a/src/defines.h b/src/defines.h
index b03d2bb..e4421e0 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -259,6 +259,7 @@ enum {
CGMSG_POST_RESPONSE = 0x05A1, // L receiver id, { S sender name, S letter, W num attachments { W attachment item id, W quantity } }
GCMSG_STORE_POST = 0x05A5, // L sender id, S receiver name, S letter, { W attachment item id, W quantity }
CGMSG_STORE_POST_RESPONSE = 0x05A6, // L id, B error
+ GAMSG_TRANSACTION = 0x0600, // L character id, L action, S message
XXMSG_INVALID = 0x7FFF
};
diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp
index a69c5ea..10bc6b4 100644
--- a/src/game-server/accountconnection.cpp
+++ b/src/game-server/accountconnection.cpp
@@ -376,3 +376,12 @@ void AccountConnection::updateOnlineStatus(int charId, bool online)
mSyncBuffer->writeByte(online ? 0x01 : 0x00);
syncChanges();
}
+
+void AccountConnection::sendTransaction(int id, int action, const std::string &message)
+{
+ MessageOut msg(GAMSG_TRANSACTION);
+ msg.writeLong(id);
+ msg.writeLong(action);
+ msg.writeString(message);
+ send(msg);
+}
diff --git a/src/game-server/accountconnection.hpp b/src/game-server/accountconnection.hpp
index 6e7bd1b..da42ea9 100644
--- a/src/game-server/accountconnection.hpp
+++ b/src/game-server/accountconnection.hpp
@@ -153,6 +153,11 @@ class AccountConnection : public Connection
*/
void updateOnlineStatus(int charId, bool online);
+ /**
+ * Send transaction to account server
+ */
+ void sendTransaction(int id, int action, const std::string &message);
+
protected:
/**
* Processes server messages.
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp
index 3c716da..3e61fe8 100644
--- a/src/game-server/commandhandler.cpp
+++ b/src/game-server/commandhandler.cpp
@@ -34,6 +34,8 @@
#include "monstermanager.hpp"
#include "state.hpp"
+#include "../common/transaction.hpp"
+
#include "../utils/string.hpp"
static void say(const std::string error, Character *player)
@@ -132,6 +134,7 @@ static void handleHelp(Character *player, std::string &args)
say("@reload", player);
say("@setgroup <character> <AL level>", player);
say("@announce <message>", player);
+ say("@history <number of transactions>", player);
}
}
else
@@ -220,6 +223,10 @@ static void handleWarp(Character *player, std::string &args)
// now warp the player
GameState::warp(other, map, x, y);
+
+ // log transaction
+ std::string msg = "User warped to " + xstr + "x" + ystr;
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_WARP, msg);
}
static void handleItem(Character *player, std::string &args)
@@ -293,6 +300,11 @@ static void handleItem(Character *player, std::string &args)
// insert the item into the inventory
Inventory(other).insert(ic->getDatabaseID(), value);
+
+ // log transaction
+ std::stringstream str;
+ str << "User created item " << ic->getDatabaseID();
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_ITEM, str.str());
}
static void handleDrop(Character *player, std::string &args)
@@ -344,6 +356,11 @@ static void handleDrop(Character *player, std::string &args)
item->setMap(player->getMap());
item->setPosition(player->getPosition());
GameState::insertSafe(item);
+
+ // log transaction
+ std::stringstream str;
+ str << "User created item " << ic->getDatabaseID();
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_DROP, str.str());
}
static void handleMoney(Character *player, std::string &args)
@@ -391,6 +408,10 @@ static void handleMoney(Character *player, std::string &args)
// change how much money the player has
Inventory(other).changeMoney(value);
+
+ // log transaction
+ std::string msg = "User created " + valuestr + " money";
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_MONEY, msg);
}
static void handleSpawn(Character *player, std::string &args)
@@ -451,6 +472,10 @@ static void handleSpawn(Character *player, std::string &args)
// The map is full. Break out.
break;
}
+
+ // log transaction
+ std::string msg = "User created monster " + monster->getName();
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_SPAWN, msg);
}
}
@@ -562,6 +587,10 @@ static void handleBan(Character *player, std::string &args)
// ban the player
accountHandler->banCharacter(other, length);
+
+ // log transaction
+ std::string msg = "User banned " + other->getName();
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_BAN, msg);
}
static void handleSetGroup(Character *player, std::string &args)
@@ -628,6 +657,10 @@ static void handleSetGroup(Character *player, std::string &args)
// change the player's account level
accountHandler->changeAccountLevel(other, level);
+
+ // log transaction
+ std::string msg = "User changed account level of " + other->getName() + " to " + levelstr;
+ accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_SETGROUP, msg);
}
static void handleAttribute(Character *player, std::string &args)
@@ -750,7 +783,10 @@ static void handleRights(Character *player)
say(str.str(), player);
}
-
+static void handleHistory(Character *player, std::string args)
+{
+ // TODO: Get args number of transactions and show them to the player
+}
void CommandHandler::handleCommand(Character *player,
const std::string &command)
@@ -842,6 +878,11 @@ void CommandHandler::handleCommand(Character *player,
if (checkPermission(player, AL_ADMIN))
handleAnnounce(player, args);
}
+ else if (type == "history")
+ {
+ if (checkPermission(player, AL_ADMIN))
+ handleHistory(player, args);
+ }
else
{
say("Command not found. Enter @help to view the list of available commands.", player);
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 675a0fc..7caa719 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -24,6 +24,7 @@
#include "game-server/gamehandler.hpp"
+#include "common/transaction.hpp"
#include "game-server/accountconnection.hpp"
#include "game-server/buysell.hpp"
#include "game-server/commandhandler.hpp"
@@ -195,6 +196,8 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
break;
}
GameState::sayAround(computer.character, say);
+ std::string msg = computer.character->getName() + " said " + say;
+ accountHandler->sendTransaction(computer.character->getDatabaseID(), TRANS_MSG_PUBLIC, msg);
} break;
case PGMSG_NPC_TALK:
@@ -242,6 +245,12 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
Inventory(computer.character)
.insert(ic->getDatabaseID(), item->getAmount());
GameState::remove(item);
+ // log transaction
+ std::stringstream str;
+ str << "User picked up item " << ic->getDatabaseID()
+ << " at " << opos.x << "x" << opos.y;
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_ITEM_PICKUP, str.str());
break;
}
}
@@ -257,6 +266,12 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
if (ic->use(computer.character))
{
inv.removeFromSlot(slot, 1);
+ // log transaction
+ std::stringstream str;
+ str << "User used item " << ic->getDatabaseID()
+ << " from slot " << slot;
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_ITEM_USED, str.str());
}
}
} break;
@@ -277,7 +292,15 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
// The map is full. Put back into inventory.
inv.insert(ic->getDatabaseID(), amount - nb);
delete item;
+ break;
}
+ // log transaction
+ Point pt = computer.character->getPosition();
+ std::stringstream str;
+ str << "User dropped item " << ic->getDatabaseID()
+ << " at " << pt.x << "x" << pt.y;
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_ITEM_DROP, str.str());
}
} break;
@@ -307,6 +330,12 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
int slot2 = message.readByte();
int amount = message.readByte();
Inventory(computer.character).move(slot1, slot2, amount);
+ // log transaction
+ std::stringstream str;
+ str << "User moved item "
+ << " from slot " << slot1 << " to slot " << slot2;
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_ITEM_MOVE, str.str());
} break;
case PGMSG_ATTACK:
@@ -346,6 +375,13 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
break;
}
+ // log transaction
+ std::stringstream str;
+ str << "User changed action from " << current
+ << " to " << action;
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_ACTION_CHANGE, str.str());
+
} break;
case PGMSG_DIRECTION_CHANGE:
@@ -398,6 +434,12 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
}
new Trade(computer.character, q);
+
+ // log transaction
+ std::string str;
+ str = "User requested trade with " + q->getName();
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_TRADE_REQUEST, str);
} break;
case PGMSG_TRADE_CANCEL:
@@ -405,6 +447,7 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
case PGMSG_TRADE_ADD_ITEM:
case PGMSG_TRADE_SET_MONEY:
{
+ std::stringstream str;
Trade *t = computer.character->getTrading();
if (!t) break;
@@ -415,14 +458,28 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
break;
case PGMSG_TRADE_ACCEPT :
t->accept(computer.character);
+ // log transaction
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_TRADE_END, "User finished trading");
break;
case PGMSG_TRADE_SET_MONEY:
- t->setMoney(computer.character, message.readLong());
- break;
+ {
+ int money = message.readLong();
+ t->setMoney(computer.character, money);
+ // log transaction
+ str << "User added " << money << " money to trade.";
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_TRADE_MONEY, str.str());
+ } break;
case PGMSG_TRADE_ADD_ITEM:
+ {
int slot = message.readByte();
t->addItem(computer.character, slot, message.readByte());
- break;
+ // log transaction
+ str << "User add item from slot " << slot;
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_TRADE_ITEM, str.str());
+ } break;
}
} break;
@@ -452,6 +509,12 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
computer.character->getCorrectionPoints(),
attribute,
computer.character->getAttribute(attribute));
+
+ // log transaction
+ std::stringstream str;
+ str << "User increased attribute " << attribute;
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_ATTR_INCREASE, str.str());
}
} break;
@@ -472,6 +535,12 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
computer.character->getCorrectionPoints(),
attribute,
computer.character->getAttribute(attribute));
+
+ // log transaction
+ std::stringstream str;
+ str << "User decreased attribute " << attribute;
+ accountHandler->sendTransaction(computer.character->getDatabaseID(),
+ TRANS_ATTR_DECREASE, str.str());
}
} break;