ManaPlus
Public Member Functions
EAthena::CharServerHandler Class Reference

#include <charserverhandler.h>

Inheritance diagram for EAthena::CharServerHandler:
Ea::CharServerHandler Net::CharServerHandler

Public Member Functions

 CharServerHandler ()
 
 ~CharServerHandler ()
 
void chooseCharacter (Net::Character *const character) const
 
void newCharacter (const std::string &name, const int slot, const GenderT gender, const int hairstyle, const int hairColor, const unsigned char race, const uint16_t look, const std::vector< int > &stats) const
 
void renameCharacter (const BeingId id, const std::string &newName) const
 
void deleteCharacter (Net::Character *const character, const std::string &email) const
 
void switchCharacter () const
 
void connect () const
 
void setNewPincode (const BeingId accountId, const std::string &pin) const
 
void sendCheckPincode (const BeingId accountId, const std::string &pin) const
 
void changePincode (const BeingId accountId, const std::string &oldPin, const std::string &newPin) const
 
void setCharCreateDialog (CharCreateDialog *const window) const
 
void changeSlot (const int oldSlot, const int newSlot) const
 
void ping () const
 
unsigned int hatSprite () const A_CONST
 
- Public Member Functions inherited from Ea::CharServerHandler
void setCharSelectDialog (CharSelectDialog *const window) const
 
void requestCharacters () const
 
unsigned int baseSprite () const A_CONST
 
unsigned int hairSprite () const A_CONST
 
unsigned int maxSprite () const A_CONST
 
void clear () const
 

Additional Inherited Members

- Static Public Member Functions inherited from Net::CharServerHandler
static void updateCharSelectDialog ()
 
static void unlockCharSelectDialog ()
 
- Static Public Attributes inherited from Net::CharServerHandler
static Net::Characters mCharacters
 
static CharSelectDialogmCharSelectDialog = 0
 
static CharCreateDialogmCharCreateDialog = 0
 
static Net::CharactermSelectedCharacter = 0
 
- Protected Member Functions inherited from Ea::CharServerHandler
 CharServerHandler ()
 
- Protected Member Functions inherited from Net::CharServerHandler
 CharServerHandler ()
 

Detailed Description

Deals with incoming messages from the character server.

Definition at line 35 of file charserverhandler.h.

Constructor & Destructor Documentation

◆ CharServerHandler()

EAthena::CharServerHandler::CharServerHandler ( )

Definition at line 50 of file charserverhandler.cpp.

50  :
52 {
55 
56  charServerHandler = this;
57 }
const BeingId BeingId_zero
Definition: beingid.h:30
Net::CharServerHandler * charServerHandler
Definition: net.cpp:85

References BeingId_zero, charServerHandler, EAthena::CharServerRecv::mNewName, and EAthena::CharServerRecv::mRenameId.

◆ ~CharServerHandler()

EAthena::CharServerHandler::~CharServerHandler ( )
virtual

Reimplemented from Ea::CharServerHandler.

Definition at line 59 of file charserverhandler.cpp.

60 {
61  charServerHandler = nullptr;
62 }

References charServerHandler.

Member Function Documentation

◆ changePincode()

void EAthena::CharServerHandler::changePincode ( const BeingId  accountId,
const std::string &  oldPin,
const std::string &  newPin 
) const
virtual

Implements Net::CharServerHandler.

Definition at line 217 of file charserverhandler.cpp.

220 {
221  createOutPacket(CMSG_CHAR_PIN_CHANGE);
222  outMsg.writeBeingId(accountId, "account id");
223  outMsg.writeString(oldPin, 4, "old encrypted pin");
224  outMsg.writeString(newPin, 4, "new encrypted pin");
225 }
#define createOutPacket(name)
Definition: messageout.h:37

References createOutPacket.

◆ changeSlot()

void EAthena::CharServerHandler::changeSlot ( const int  oldSlot,
const int  newSlot 
) const
virtual

Implements Net::CharServerHandler.

Definition at line 237 of file charserverhandler.cpp.

239 {
240  createOutPacket(CMSG_CHAR_CHANGE_SLOT);
241  outMsg.writeInt16(CAST_S16(oldSlot), "old slot");
242  outMsg.writeInt16(CAST_S16(newSlot), "new slot");
243  outMsg.writeInt16(0, "unused");
244 }
#define CAST_S16
Definition: cast.h:28

References CAST_S16, and createOutPacket.

◆ chooseCharacter()

void EAthena::CharServerHandler::chooseCharacter ( Net::Character *const  character) const
virtual

Implements Net::CharServerHandler.

Definition at line 64 of file charserverhandler.cpp.

65 {
66  if (character == nullptr)
67  return;
68 
69  mSelectedCharacter = character;
70  mCharSelectDialog = nullptr;
71 
72  createOutPacket(CMSG_CHAR_SELECT);
73  outMsg.writeInt8(CAST_U8(
74  mSelectedCharacter->slot), "slot");
75 }
#define CAST_U8
Definition: cast.h:27
static Net::Character * mSelectedCharacter
static CharSelectDialog * mCharSelectDialog
uint16_t slot
Definition: character.h:58

References CAST_U8, createOutPacket, Net::CharServerHandler::mCharSelectDialog, Net::CharServerHandler::mSelectedCharacter, and Net::Character::slot.

◆ connect()

void EAthena::CharServerHandler::connect ( ) const
virtual

Implements Ea::CharServerHandler.

Definition at line 164 of file charserverhandler.cpp.

165 {
166  const Token &token =
167  static_cast<LoginHandler*>(loginHandler)->getToken();
168 
169  if (Network::mInstance == nullptr)
170  return;
171 
174  createOutPacket(CMSG_CHAR_SERVER_CONNECT);
175  outMsg.writeBeingId(token.account_ID, "account id");
176  outMsg.writeInt32(token.session_ID1, "session id1");
177  outMsg.writeInt32(token.session_ID2, "session id2");
178  outMsg.writeInt16(CLIENT_PROTOCOL_VERSION, "client protocol version");
179  outMsg.writeInt8(Being::genderToInt(token.sex), "gender");
180 
181  // We get 4 useless bytes before the real answer comes in (what are these?)
183 }
static uint8_t genderToInt(const GenderT sex) A_CONST
Definition: being.h:927
static Network * mInstance
Definition: network.h:57
bool connect(const ServerInfo &server)
Definition: network.cpp:101
void skip(const int len)
Definition: network.cpp:181
void disconnect()
Definition: network.cpp:139
#define CLIENT_PROTOCOL_VERSION
Definition: network.h:33
Net::LoginHandler * loginHandler
Definition: net.cpp:90
ServerInfo charServer
Definition: token.h:31
int session_ID2
Definition: token.h:43
GenderT sex
Definition: token.h:44
BeingId account_ID
Definition: token.h:41
int session_ID1
Definition: token.h:42

References Token::account_ID, EAthena::charServer, CLIENT_PROTOCOL_VERSION, Ea::Network::connect(), createOutPacket, Ea::Network::disconnect(), Being::genderToInt(), loginHandler, EAthena::Network::mInstance, Token::session_ID1, Token::session_ID2, Token::sex, and Ea::Network::skip().

◆ deleteCharacter()

void EAthena::CharServerHandler::deleteCharacter ( Net::Character *const  character,
const std::string &  email 
) const
virtual

Implements Net::CharServerHandler.

Definition at line 141 of file charserverhandler.cpp.

143 {
144  if (character == nullptr)
145  return;
146 
147  mSelectedCharacter = character;
148 
149  createOutPacket(CMSG_CHAR_DELETE);
150  outMsg.writeBeingId(mSelectedCharacter->dummy->getId(), "id?");
151  if (email.empty())
152  outMsg.writeString("[email protected]", 40, "email");
153  else
154  outMsg.writeString(email, 40, "email");
155 }
BeingId getId() const
Definition: actorsprite.h:64
LocalPlayer * dummy
Definition: character.h:56

References createOutPacket, Net::Character::dummy, ActorSprite::getId(), and Net::CharServerHandler::mSelectedCharacter.

◆ hatSprite()

unsigned int EAthena::CharServerHandler::hatSprite ( ) const
virtual

Implements Net::CharServerHandler.

Definition at line 252 of file charserverhandler.cpp.

253 {
254  return 7;
255 }

◆ newCharacter()

void EAthena::CharServerHandler::newCharacter ( const std::string &  name,
const int  slot,
const GenderT  gender,
const int  hairstyle,
const int  hairColor,
const unsigned char  race,
const uint16_t  look,
const std::vector< int > &  stats 
) const
virtual

Implements Net::CharServerHandler.

Definition at line 77 of file charserverhandler.cpp.

84 {
85  createOutPacket(CMSG_CHAR_CREATE);
86  outMsg.writeString(name, 24, "login");
87  if (serverVersion > 0)
88  {
89  outMsg.writeInt8(CAST_U8(slot), "slot");
90  outMsg.writeInt16(CAST_S16(hairColor), "hair color");
91  outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
93  outMsg.writeInt16(CAST_S16(race), "race");
95  {
96  uint8_t sex = 0;
97  if (gender == Gender::UNSPECIFIED)
98  sex = 99;
99  else
100  sex = Being::genderToInt(gender);
101  outMsg.writeInt8(sex, "gender");
102  }
104  outMsg.writeInt16(CAST_S16(look), "look");
105  }
106  else
107  {
108  if (packetVersion >= 20151001)
109  {
110  outMsg.writeInt8(CAST_U8(slot), "slot");
111  outMsg.writeInt16(CAST_S16(hairColor), "hair color");
112  outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
113  outMsg.writeInt32(CAST_S16(0), "starting job id");
114  uint8_t sex = 0;
115  if (gender == Gender::UNSPECIFIED)
116  sex = 99;
117  else
118  sex = Being::genderToInt(gender);
119  outMsg.writeInt8(sex, "gender");
120  }
121  else if (packetVersion >= 20120307)
122  {
123  outMsg.writeInt8(CAST_U8(slot), "slot");
124  outMsg.writeInt16(CAST_S16(hairColor), "hair color");
125  outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
126  }
127  else
128  { // < 20120307
129  // +++ here need send stat points
130  // sending 5 for each stat for now
131  for (int i = 0; i < 6; i++)
132  outMsg.writeInt8(CAST_U8(5), "stat");
133 
134  outMsg.writeInt8(CAST_U8(slot), "slot");
135  outMsg.writeInt16(CAST_S16(hairColor), "hair color");
136  outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
137  }
138  }
139 }
virtual bool haveCreateCharGender() const =0
virtual bool haveRaceSelection() const =0
virtual bool haveLookSelection() const =0
int serverVersion
Definition: client.cpp:124
int packetVersion
Definition: client.cpp:125
@ UNSPECIFIED
Definition: gender.h:33
Net::ServerFeatures * serverFeatures
Definition: net.cpp:101

References CAST_S16, CAST_U8, createOutPacket, Being::genderToInt(), Net::ServerFeatures::haveCreateCharGender(), Net::ServerFeatures::haveLookSelection(), Net::ServerFeatures::haveRaceSelection(), packetVersion, serverFeatures, serverVersion, and Gender::UNSPECIFIED.

◆ ping()

void EAthena::CharServerHandler::ping ( ) const
virtual

Implements Net::CharServerHandler.

Definition at line 246 of file charserverhandler.cpp.

247 {
248  createOutPacket(CMSG_CHAR_PING);
249  outMsg.writeInt32(0, "unused");
250 }

References createOutPacket.

◆ renameCharacter()

void EAthena::CharServerHandler::renameCharacter ( const BeingId  id,
const std::string &  newName 
) const
virtual

Implements Net::CharServerHandler.

Definition at line 227 of file charserverhandler.cpp.

229 {
230  createOutPacket(CMSG_CHAR_CHECK_RENAME);
232  CharServerRecv::mNewName = newName;
233  outMsg.writeBeingId(id, "char id");
234  outMsg.writeString(newName, 24, "name");
235 }

References createOutPacket, EAthena::CharServerRecv::mNewName, and EAthena::CharServerRecv::mRenameId.

◆ sendCheckPincode()

void EAthena::CharServerHandler::sendCheckPincode ( const BeingId  accountId,
const std::string &  pin 
) const
virtual

Implements Net::CharServerHandler.

Definition at line 209 of file charserverhandler.cpp.

211 {
212  createOutPacket(CMSG_CHAR_PIN_CHECK);
213  outMsg.writeBeingId(accountId, "account id");
214  outMsg.writeString(pin, 4, "encrypted pin");
215 }

References createOutPacket.

◆ setCharCreateDialog()

void EAthena::CharServerHandler::setCharCreateDialog ( CharCreateDialog *const  window) const
virtual

Sets the character create dialog. The handler will clean up this dialog when a new character is successfully created, and will unlock the dialog when a new character failed to be created.

Implements Net::CharServerHandler.

Definition at line 185 of file charserverhandler.cpp.

187 {
188  mCharCreateDialog = window;
189 
190  if (mCharCreateDialog == nullptr)
191  return;
192 
193  StringVect attributes;
194 
195  const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
196 
197  mCharCreateDialog->setAttributes(attributes, 0, 0, 0);
199 }
void setDefaultGender(const GenderT gender)
void setAttributes(const StringVect &labels, int available, const int min, const int max)
static CharCreateDialog * mCharCreateDialog
std::vector< std::string > StringVect
Definition: stringvector.h:29

References loginHandler, Net::CharServerHandler::mCharCreateDialog, CharCreateDialog::setAttributes(), CharCreateDialog::setDefaultGender(), and Token::sex.

Referenced by EAthena::GeneralHandler::reload().

◆ setNewPincode()

void EAthena::CharServerHandler::setNewPincode ( const BeingId  accountId,
const std::string &  pin 
) const
virtual

Implements Net::CharServerHandler.

Definition at line 201 of file charserverhandler.cpp.

203 {
204  createOutPacket(CMSG_CHAR_CREATE_PIN);
205  outMsg.writeBeingId(accountId, "account id");
206  outMsg.writeString(pin, 4, "encrypted pin");
207 }

References createOutPacket.

◆ switchCharacter()

void EAthena::CharServerHandler::switchCharacter ( ) const
virtual

Implements Net::CharServerHandler.

Definition at line 157 of file charserverhandler.cpp.

158 {
159  // This is really a map-server packet
160  createOutPacket(CMSG_PLAYER_RESTART);
161  outMsg.writeInt8(1, "flag");
162 }

References createOutPacket.


The documentation for this class was generated from the following files: