diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-09-30 19:54:06 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-09-30 19:54:06 -0600 |
commit | d4f32a38fd498c180d562ced38a9129e0abf2252 (patch) | |
tree | e655b59ff686ad5fe2bdd11d6e072f5c3a4493b7 /src/net/ea/charserverhandler.cpp | |
parent | 6707d108790ab1fe1d4a3ef52d717966990fdf0a (diff) | |
download | mana-d4f32a38fd498c180d562ced38a9129e0abf2252.tar.gz mana-d4f32a38fd498c180d562ced38a9129e0abf2252.tar.bz2 mana-d4f32a38fd498c180d562ced38a9129e0abf2252.tar.xz mana-d4f32a38fd498c180d562ced38a9129e0abf2252.zip |
Merge login state machines for both clients
Also do some cleanup and refactoring of related code.
Diffstat (limited to 'src/net/ea/charserverhandler.cpp')
-rw-r--r-- | src/net/ea/charserverhandler.cpp | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 47d454a8..f854841f 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -21,6 +21,7 @@ #include "net/ea/charserverhandler.h" +#include "net/ea/generalhandler.h" #include "net/ea/network.h" #include "net/ea/protocol.h" @@ -43,6 +44,9 @@ Net::CharHandler *charHandler; namespace EAthena { +extern Token netToken; +extern ServerInfo charServer; +extern ServerInfo mapServer; CharServerHandler::CharServerHandler(): mCharCreateDialog(0) @@ -145,8 +149,8 @@ void CharServerHandler::handleMessage(MessageIn &msg) slot = mCharInfo->getPos(); msg.skip(4); // CharID, must be the same as player_node->charID map_path = msg.readString(16); - mLoginData->hostname = ipToString(msg.readInt32()); - mLoginData->port = msg.readInt16(); + mapServer.hostname = ipToString(msg.readInt32()); + mapServer.port = msg.readInt16(); mCharInfo->unlock(); mCharInfo->select(0); // Clear unselected players infos @@ -162,7 +166,8 @@ void CharServerHandler::handleMessage(MessageIn &msg) } while (mCharInfo->getPos()); mCharInfo->select(slot); - state = STATE_CONNECTING; + mNetwork->disconnect(); + state = STATE_CONNECT_GAME; break; } } @@ -170,7 +175,7 @@ void CharServerHandler::handleMessage(MessageIn &msg) LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot) { LocalPlayer *tempPlayer = new LocalPlayer(msg.readInt32(), 0, NULL); - tempPlayer->setGender(mLoginData->sex); + tempPlayer->setGender(netToken.sex); tempPlayer->setExp(msg.readInt32()); tempPlayer->setMoney(msg.readInt32()); @@ -229,24 +234,12 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *window) attributes.push_back(_("Luck:")); mCharCreateDialog->setAttributes(attributes, 30, 1, 9); - mCharCreateDialog->setFixedGender(true, mLoginData->sex); + mCharCreateDialog->setFixedGender(true, netToken.sex); } -void CharServerHandler::connect(LoginData *loginData) +void CharServerHandler::getCharacters() { - mLoginData = loginData; - - MessageOut outMsg(CMSG_CHAR_SERVER_CONNECT); - outMsg.writeInt32(loginData->account_ID); - outMsg.writeInt32(loginData->session_ID1); - outMsg.writeInt32(loginData->session_ID2); - // [Fate] The next word is unused by the old char server, so we squeeze in - // tmw client version information - outMsg.writeInt16(CLIENT_PROTOCOL_VERSION); - outMsg.writeInt8((loginData->sex == GENDER_MALE) ? 1 : 0); - - // We get 4 useless bytes before the real answer comes in (what are these?) - mNetwork->skip(4); + connect(); } void CharServerHandler::chooseCharacter(int slot, LocalPlayer* character) @@ -276,4 +269,21 @@ void CharServerHandler::deleteCharacter(int slot, LocalPlayer* character) outMsg.writeString("a@a.com", 40); } +void CharServerHandler::connect() +{ + mNetwork->disconnect(); + mNetwork->connect(charServer); + MessageOut outMsg(CMSG_CHAR_SERVER_CONNECT); + outMsg.writeInt32(netToken.account_ID); + outMsg.writeInt32(netToken.session_ID1); + outMsg.writeInt32(netToken.session_ID2); + // [Fate] The next word is unused by the old char server, so we squeeze in + // tmw client version information + outMsg.writeInt16(CLIENT_PROTOCOL_VERSION); + outMsg.writeInt8((netToken.sex == GENDER_MALE) ? 1 : 0); + + // We get 4 useless bytes before the real answer comes in (what are these?) + mNetwork->skip(4); +} + } // namespace EAthena |