diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-04-06 16:05:54 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-04-06 16:07:03 -0600 |
commit | 8209e4672c5e11e5d7bbfb1fcfb081eda1763a6d (patch) | |
tree | 461c06a2e42fc54684bd61ef5ae9ff8cc83d8f07 /src/net | |
parent | bbebd24b5561e9cd806dca8ccd6fe4b4dcb1301d (diff) | |
download | mana-client-8209e4672c5e11e5d7bbfb1fcfb081eda1763a6d.tar.gz mana-client-8209e4672c5e11e5d7bbfb1fcfb081eda1763a6d.tar.bz2 mana-client-8209e4672c5e11e5d7bbfb1fcfb081eda1763a6d.tar.xz mana-client-8209e4672c5e11e5d7bbfb1fcfb081eda1763a6d.zip |
Implement TMWServ's CharHandler
Also cleanup character creation, which isn't functional at the moment.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/charhandler.h | 8 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.cpp | 36 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.h | 10 | ||||
-rw-r--r-- | src/net/net.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwserv/charserverhandler.cpp | 55 | ||||
-rw-r--r-- | src/net/tmwserv/charserverhandler.h | 19 |
6 files changed, 111 insertions, 21 deletions
diff --git a/src/net/charhandler.h b/src/net/charhandler.h index fa2820e9..7d1b9ab2 100644 --- a/src/net/charhandler.h +++ b/src/net/charhandler.h @@ -25,15 +25,21 @@ #include "localplayer.h" #include <iosfwd> +#include <vector> + +class CharCreateDialog; namespace Net { class CharHandler { public: + virtual void setCharCreateDialog(CharCreateDialog *window) = 0; + virtual void chooseCharacter(int slot, LocalPlayer* character) = 0; virtual void newCharacter(const std::string &name, int slot, - bool gender, int hairstyle, int hairColor) = 0; + bool gender, int hairstyle, int hairColor, + std::vector<int> stats) = 0; virtual void deleteCharacter(int slot, LocalPlayer* character) = 0; }; diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 822c15c4..377cd2dd 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -31,7 +31,7 @@ #include "logindata.h" #include "main.h" -#include "gui/char_select.h" +#include "gui/charcreatedialog.h" #include "gui/ok_dialog.h" #include "utils/gettext.h" @@ -39,6 +39,8 @@ Net::CharHandler *charHandler; +namespace EAthena { + CharServerHandler::CharServerHandler(): mCharCreateDialog(0) { @@ -239,6 +241,24 @@ 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(_("Vitality:")); + attributes.push_back(_("Intelligence:")); + attributes.push_back(_("Dexterity:")); + attributes.push_back(_("Luck:")); + + mCharCreateDialog->setAttributes(attributes, 30, 1, 9); + mCharCreateDialog->setFixedGender(true); +} + void CharServerHandler::chooseCharacter(int slot, LocalPlayer* character) { MessageOut outMsg(CMSG_CHAR_SELECT); @@ -246,16 +266,14 @@ void CharServerHandler::chooseCharacter(int slot, LocalPlayer* character) } void CharServerHandler::newCharacter(const std::string &name, int slot, - bool gender, int hairstyle, int hairColor) + bool gender, int hairstyle, int hairColor, std::vector<int> stats) { MessageOut outMsg(CMSG_CHAR_CREATE); outMsg.writeString(name, 24); - outMsg.writeInt8(5); - outMsg.writeInt8(5); - outMsg.writeInt8(5); - outMsg.writeInt8(5); - outMsg.writeInt8(5); - outMsg.writeInt8(5); + for (int i = 0; i < 6; i++) + { + outMsg.writeInt8(stats[i]); + } outMsg.writeInt8(slot); outMsg.writeInt16(hairColor); outMsg.writeInt16(hairstyle); @@ -267,3 +285,5 @@ void CharServerHandler::deleteCharacter(int slot, LocalPlayer* character) outMsg.writeInt32(character->mCharId); outMsg.writeString("a@a.com", 40); } + +} // namespace EAthena diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h index e499ab74..48392ac4 100644 --- a/src/net/ea/charserverhandler.h +++ b/src/net/ea/charserverhandler.h @@ -27,10 +27,11 @@ #include "lockedarray.h" -class CharCreateDialog; class LocalPlayer; class LoginData; +namespace EAthena { + /** * Deals with incoming messages from the character server. */ @@ -52,13 +53,12 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler * dialog when a new character is succesfully created, and will unlock * the dialog when a new character failed to be created. */ - void setCharCreateDialog(CharCreateDialog *window) - { mCharCreateDialog = window; } + void setCharCreateDialog(CharCreateDialog *window); void chooseCharacter(int slot, LocalPlayer* character); void newCharacter(const std::string &name, int slot, bool gender, - int hairstyle, int hairColor); + int hairstyle, int hairColor, std::vector<int> stats); void deleteCharacter(int slot, LocalPlayer* character); @@ -70,6 +70,6 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler LocalPlayer *readPlayerData(MessageIn &msg, int &slot); }; -extern Net::CharHandler *charHandler; +} // namespace EAthena #endif // NET_EA_CHARSERVERHANDLER_H diff --git a/src/net/net.cpp b/src/net/net.cpp index 7c5024b1..5c36f4e1 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -36,6 +36,7 @@ #include "net/tradehandler.h" extern Net::AdminHandler *adminHandler; +extern Net::CharHandler *charHandler; extern Net::ChatHandler *chatHandler; extern Net::InventoryHandler *inventoryHandler; extern Net::MapHandler *mapHandler; @@ -51,8 +52,7 @@ Net::AdminHandler *Net::getAdminHandler() Net::CharHandler *Net::getCharHandler() { - // TODO - return 0; + return charHandler; } Net::ChatHandler *Net::getChatHandler() 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 diff --git a/src/net/tmwserv/charserverhandler.h b/src/net/tmwserv/charserverhandler.h index e1e13b55..a5e1fa50 100644 --- a/src/net/tmwserv/charserverhandler.h +++ b/src/net/tmwserv/charserverhandler.h @@ -22,18 +22,20 @@ #ifndef NET_TMWSERV_CHARSERVERHANDLER_H #define NET_TMWSERV_CHARSERVERHANDLER_H +#include "net/charhandler.h" #include "net/messagehandler.h" #include "lockedarray.h" -class CharCreateDialog; class LocalPlayer; class LoginData; +namespace TmwServ { + /** * Deals with incoming messages related to character selection. */ -class CharServerHandler : public MessageHandler +class CharServerHandler : public MessageHandler, public Net::CharHandler { public: CharServerHandler(); @@ -50,8 +52,15 @@ class CharServerHandler : public MessageHandler * dialog when a new character is succesfully created, and will unlock * the dialog when a new character failed to be created. */ - void setCharCreateDialog(CharCreateDialog *window) - { mCharCreateDialog = window; } + void setCharCreateDialog(CharCreateDialog *window); + + void chooseCharacter(int slot, LocalPlayer* character); + + void newCharacter(const std::string &name, int slot, + bool gender, int hairstyle, int hairColor, + std::vector<int> stats); + + void deleteCharacter(int slot, LocalPlayer* character); protected: void handleCharCreateResponse(MessageIn &msg); @@ -65,4 +74,6 @@ class CharServerHandler : public MessageHandler readPlayerData(MessageIn &msg, int &slot); }; +} // namespace TmwServ + #endif |