summaryrefslogtreecommitdiff
path: root/src/net/tmwserv/charserverhandler.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-04-06 16:05:54 -0600
committerJared Adams <jaxad0127@gmail.com>2009-04-06 16:07:03 -0600
commit8209e4672c5e11e5d7bbfb1fcfb081eda1763a6d (patch)
tree461c06a2e42fc54684bd61ef5ae9ff8cc83d8f07 /src/net/tmwserv/charserverhandler.cpp
parentbbebd24b5561e9cd806dca8ccd6fe4b4dcb1301d (diff)
downloadmana-8209e4672c5e11e5d7bbfb1fcfb081eda1763a6d.tar.gz
mana-8209e4672c5e11e5d7bbfb1fcfb081eda1763a6d.tar.bz2
mana-8209e4672c5e11e5d7bbfb1fcfb081eda1763a6d.tar.xz
mana-8209e4672c5e11e5d7bbfb1fcfb081eda1763a6d.zip
Implement TMWServ's CharHandler
Also cleanup character creation, which isn't functional at the moment.
Diffstat (limited to 'src/net/tmwserv/charserverhandler.cpp')
-rw-r--r--src/net/tmwserv/charserverhandler.cpp55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/net/tmwserv/charserverhandler.cpp b/src/net/tmwserv/charserverhandler.cpp
index 0779e499..9739367b 100644
--- a/src/net/tmwserv/charserverhandler.cpp
+++ b/src/net/tmwserv/charserverhandler.cpp
@@ -24,6 +24,9 @@
#include "net/tmwserv/connection.h"
#include "net/tmwserv/protocol.h"
+#include "net/tmwserv/accountserver/accountserver.h"
+#include "net/tmwserv/accountserver/account.h"
+
#include "net/messagein.h"
#include "game.h"
@@ -32,12 +35,18 @@
#include "logindata.h"
#include "main.h"
+#include "gui/charcreatedialog.h"
#include "gui/ok_dialog.h"
-#include "gui/char_select.h"
+
+#include "utils/gettext.h"
extern Net::Connection *gameServerConnection;
extern Net::Connection *chatServerConnection;
+Net::CharHandler *charHandler;
+
+namespace TmwServ {
+
CharServerHandler::CharServerHandler():
mCharCreateDialog(0)
{
@@ -49,6 +58,7 @@ CharServerHandler::CharServerHandler():
0
};
handledMessages = _messages;
+ charHandler = this;
}
void CharServerHandler::handleMessage(MessageIn &msg)
@@ -226,3 +236,46 @@ LocalPlayer* CharServerHandler::readPlayerData(MessageIn &msg, int &slot)
return tempPlayer;
}
+
+void CharServerHandler::setCharCreateDialog(CharCreateDialog *window)
+{
+ mCharCreateDialog = window;
+
+ if (!mCharCreateDialog) return;
+
+ std::vector<std::string> attributes;
+ attributes.push_back(_("Strength:"));
+ attributes.push_back(_("Agility:"));
+ attributes.push_back(_("Dexterity:"));
+ attributes.push_back(_("Vitality:"));
+ attributes.push_back(_("Intelligence:"));
+ attributes.push_back(_("Willpower:"));
+
+ mCharCreateDialog->setAttributes(attributes, 60, 1, 20);
+}
+
+void CharServerHandler::chooseCharacter(int slot, LocalPlayer* character)
+{
+ Net::AccountServer::Account::selectCharacter(slot);
+}
+
+void CharServerHandler::newCharacter(const std::string &name, int slot, bool gender,
+ int hairstyle, int hairColor, std::vector<int> stats)
+{
+ Net::AccountServer::Account::createCharacter(name, hairstyle, hairColor,
+ gender,
+ stats[0], // STR
+ stats[1], // AGI
+ stats[2], // DEX
+ stats[3], // VIT
+ stats[4], // INT
+ stats[5] // WILL
+ );
+}
+
+void CharServerHandler::deleteCharacter(int slot, LocalPlayer* character)
+{
+ Net::AccountServer::Account::deleteCharacter(slot);
+}
+
+} // namespace TmwServ