diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/charhandler.h | 10 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.cpp | 34 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.h | 12 | ||||
-rw-r--r-- | src/net/ea/maphandler.cpp | 16 | ||||
-rw-r--r-- | src/net/ea/maphandler.h | 4 | ||||
-rw-r--r-- | src/net/ea/network.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/protocol.h | 5 | ||||
-rw-r--r-- | src/net/maphandler.h | 6 |
8 files changed, 78 insertions, 11 deletions
diff --git a/src/net/charhandler.h b/src/net/charhandler.h index e7871aab..fa2820e9 100644 --- a/src/net/charhandler.h +++ b/src/net/charhandler.h @@ -22,18 +22,20 @@ #ifndef CHARHANDLER_H #define CHARHANDLER_H +#include "localplayer.h" + #include <iosfwd> namespace Net { class CharHandler { public: - virtual void ChooseCharacter(int slot) {} + virtual void chooseCharacter(int slot, LocalPlayer* character) = 0; - virtual void NewCharacter(const std::string &name, bool gender, - int hairstyle, int hairColor) {} + virtual void newCharacter(const std::string &name, int slot, + bool gender, int hairstyle, int hairColor) = 0; - virtual void DeleteCharacter(int slot) {} + virtual void deleteCharacter(int slot, LocalPlayer* character) = 0; }; } diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index d212ebfe..822c15c4 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -24,9 +24,9 @@ #include "net/ea/protocol.h" #include "net/messagein.h" +#include "net/messageout.h" #include "game.h" -#include "localplayer.h" #include "log.h" #include "logindata.h" #include "main.h" @@ -37,6 +37,8 @@ #include "utils/gettext.h" #include "utils/stringutils.h" +Net::CharHandler *charHandler; + CharServerHandler::CharServerHandler(): mCharCreateDialog(0) { @@ -52,6 +54,7 @@ CharServerHandler::CharServerHandler(): 0 }; handledMessages = _messages; + charHandler = this; } void CharServerHandler::handleMessage(MessageIn &msg) @@ -235,3 +238,32 @@ LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot) return tempPlayer; } + +void CharServerHandler::chooseCharacter(int slot, LocalPlayer* character) +{ + MessageOut outMsg(CMSG_CHAR_SELECT); + outMsg.writeInt8(slot); +} + +void CharServerHandler::newCharacter(const std::string &name, int slot, + bool gender, int hairstyle, int hairColor) +{ + 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); + outMsg.writeInt8(slot); + outMsg.writeInt16(hairColor); + outMsg.writeInt16(hairstyle); +} + +void CharServerHandler::deleteCharacter(int slot, LocalPlayer* character) +{ + MessageOut outMsg(CMSG_CHAR_DELETE); + outMsg.writeInt32(character->mCharId); + outMsg.writeString("a@a.com", 40); +} diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h index ec21a357..e499ab74 100644 --- a/src/net/ea/charserverhandler.h +++ b/src/net/ea/charserverhandler.h @@ -23,6 +23,7 @@ #define NET_EA_CHARSERVERHANDLER_H #include "net/messagehandler.h" +#include "net/charhandler.h" #include "lockedarray.h" @@ -33,7 +34,7 @@ class LoginData; /** * Deals with incoming messages from the character server. */ -class CharServerHandler : public MessageHandler +class CharServerHandler : public MessageHandler, public Net::CharHandler { public: CharServerHandler(); @@ -54,6 +55,13 @@ class CharServerHandler : public MessageHandler void setCharCreateDialog(CharCreateDialog *window) { mCharCreateDialog = window; } + void chooseCharacter(int slot, LocalPlayer* character); + + void newCharacter(const std::string &name, int slot, bool gender, + int hairstyle, int hairColor); + + void deleteCharacter(int slot, LocalPlayer* character); + protected: LoginData *mLoginData; LockedArray<LocalPlayer*> *mCharInfo; @@ -62,4 +70,6 @@ class CharServerHandler : public MessageHandler LocalPlayer *readPlayerData(MessageIn &msg, int &slot); }; +extern Net::CharHandler *charHandler; + #endif // NET_EA_CHARSERVERHANDLER_H diff --git a/src/net/ea/maphandler.cpp b/src/net/ea/maphandler.cpp index fefeac86..d12106d6 100644 --- a/src/net/ea/maphandler.cpp +++ b/src/net/ea/maphandler.cpp @@ -96,9 +96,15 @@ void MapHandler::handleMessage(MessageIn &msg) } } -void MapHandler::connect() +void MapHandler::connect(LoginData *loginData) { - // TODO + // Send login infos + MessageOut outMsg(CMSG_MAP_SERVER_CONNECT); + outMsg.writeInt32(loginData->account_ID); + outMsg.writeInt32(player_node->mCharId); + outMsg.writeInt32(loginData->session_ID1); + outMsg.writeInt32(loginData->session_ID2); + outMsg.writeInt8(loginData->sex); } void MapHandler::mapLoaded(const std::string &mapName) @@ -115,3 +121,9 @@ void MapHandler::quit() { MessageOut outMsg(CMSG_CLIENT_QUIT); } + +void MapHandler::ping(int tick) +{ + MessageOut msg(CMSG_CLIENT_PING); + msg.writeInt32(tick); +} diff --git a/src/net/ea/maphandler.h b/src/net/ea/maphandler.h index 77811b4e..d4ccdbe2 100644 --- a/src/net/ea/maphandler.h +++ b/src/net/ea/maphandler.h @@ -33,13 +33,15 @@ class MapHandler : public MessageHandler, public Net::MapHandler void handleMessage(MessageIn &msg); - void connect(); + void connect(LoginData *loginData); void mapLoaded(const std::string &mapName); void who(); void quit(); + + void ping(int tick); }; extern MapHandler *mapHandler; diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index 4aecb268..8f55236f 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -72,7 +72,7 @@ short packet_lengths[] = { 8, 14, 10, 35, 6, 8, 4, 11, 54, 53, 60, 2, -1, 47, 33, 6, 30, 8, 34, 14, 2, 6, 26, 2, 28, 81, 6, 10, 26, 2, -1, -1, -1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10, -// #0x200 +// #0x2000 26, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h index 356b34a4..4dc7db36 100644 --- a/src/net/ea/protocol.h +++ b/src/net/ea/protocol.h @@ -122,6 +122,11 @@ static const int STORAGE_OFFSET = 1; /********************************** * Packets from client to server * **********************************/ +#define CMSG_CHAR_SELECT 0x0066 +#define CMSG_CHAR_CREATE 0x0067 +#define CMSG_CHAR_DELETE 0x0068 + +#define CMSG_MAP_SERVER_CONNECT 0x0072 #define CMSG_CLIENT_PING 0x007e /**< Send to server with tick */ #define CMSG_CLIENT_QUIT 0x018A #define CMSG_TRADE_RESPONSE 0x00e6 diff --git a/src/net/maphandler.h b/src/net/maphandler.h index 80f9183f..6c91f4ef 100644 --- a/src/net/maphandler.h +++ b/src/net/maphandler.h @@ -22,6 +22,8 @@ #ifndef MAPHANDLER_H #define MAPHANDLER_H +#include "logindata.h" + #include <iosfwd> namespace Net { @@ -29,13 +31,15 @@ namespace Net { class MapHandler { public: - virtual void connect() = 0; + virtual void connect(LoginData *loginData) = 0; virtual void mapLoaded(const std::string &mapName) = 0; virtual void who() = 0; virtual void quit() = 0; + + virtual void ping(int tick) = 0; }; } // namespace Net |