ManaPlus
Public Member Functions
TmwAthena::CharServerHandler Class Reference

#include <charserverhandler.h>

Inheritance diagram for TmwAthena::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 deleteCharacter (Net::Character *const character, const std::string &email) const
 
void renameCharacter (const BeingId id, const std::string &newName) 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()

TmwAthena::CharServerHandler::CharServerHandler ( )

Definition at line 50 of file charserverhandler.cpp.

50  :
52 {
53  charServerHandler = this;
54 }
Net::CharServerHandler * charServerHandler
Definition: net.cpp:85

References charServerHandler.

◆ ~CharServerHandler()

TmwAthena::CharServerHandler::~CharServerHandler ( )
virtual

Reimplemented from Ea::CharServerHandler.

Definition at line 56 of file charserverhandler.cpp.

57 {
58  charServerHandler = nullptr;
59 }

References charServerHandler.

Member Function Documentation

◆ changePincode()

void TmwAthena::CharServerHandler::changePincode ( const BeingId  accountId,
const std::string &  oldPin,
const std::string &  newPin 
) const
inlinevirtual

Implements Net::CharServerHandler.

Definition at line 76 of file charserverhandler.h.

80  { }

◆ changeSlot()

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

Implements Net::CharServerHandler.

Definition at line 183 of file charserverhandler.cpp.

185 {
186 }

◆ chooseCharacter()

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

Implements Net::CharServerHandler.

Definition at line 61 of file charserverhandler.cpp.

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

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

◆ connect()

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

Implements Ea::CharServerHandler.

Definition at line 115 of file charserverhandler.cpp.

116 {
117  const Token &token =
118  static_cast<LoginHandler*>(loginHandler)->getToken();
119 
120  if (Network::mInstance == nullptr)
121  return;
122 
125  createOutPacket(CMSG_CHAR_SERVER_CONNECT);
126  outMsg.writeBeingId(token.account_ID, "account id");
127  outMsg.writeInt32(token.session_ID1, "session id1");
128  outMsg.writeInt32(token.session_ID2, "session id2");
129  // [Fate] The next word is unused by the old char server, so we squeeze in
130  // mana client version information
131  outMsg.writeInt16(CLIENT_PROTOCOL_VERSION,
132  "client protocol version");
133  outMsg.writeInt8(Being::genderToInt(token.sex), "gender");
134 
135  // We get 4 useless bytes before the real answer comes in (what are these?)
137 }
static uint8_t genderToInt(const GenderT sex) A_CONST
Definition: being.h:927
bool connect(const ServerInfo &server)
Definition: network.cpp:101
void skip(const int len)
Definition: network.cpp:181
void disconnect()
Definition: network.cpp:139
static Network * mInstance
Definition: network.h:54
#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, TmwAthena::charServer, CLIENT_PROTOCOL_VERSION, Ea::Network::connect(), createOutPacket, Ea::Network::disconnect(), Being::genderToInt(), loginHandler, TmwAthena::Network::mInstance, Token::session_ID1, Token::session_ID2, Token::sex, and Ea::Network::skip().

◆ deleteCharacter()

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

Implements Net::CharServerHandler.

Definition at line 94 of file charserverhandler.cpp.

97 {
98  if (character == nullptr)
99  return;
100 
101  mSelectedCharacter = character;
102 
103  createOutPacket(CMSG_CHAR_DELETE);
104  outMsg.writeBeingId(mSelectedCharacter->dummy->getId(), "id?");
105  outMsg.writeString("[email protected]", 40, "email");
106 }
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 TmwAthena::CharServerHandler::hatSprite ( ) const
virtual

Implements Net::CharServerHandler.

Definition at line 192 of file charserverhandler.cpp.

193 {
194  return 7;
195 }

◆ newCharacter()

void TmwAthena::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 74 of file charserverhandler.cpp.

81 {
82  createOutPacket(CMSG_CHAR_CREATE);
83  outMsg.writeString(name, 24, "name");
84  for (int i = 0; i < 6; i++)
85  outMsg.writeInt8(CAST_U8(stats[i]), "stat");
86 
87  outMsg.writeInt8(CAST_U8(slot), "slot");
88  outMsg.writeInt8(CAST_S8(hairColor), "hair color");
89  outMsg.writeInt8(0, "unused");
90  outMsg.writeInt8(CAST_S8(hairstyle), "hair style");
91  outMsg.writeInt8(0, "unused");
92 }
#define CAST_S8
Definition: cast.h:26

References CAST_S8, CAST_U8, and createOutPacket.

◆ ping()

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

Implements Net::CharServerHandler.

Definition at line 188 of file charserverhandler.cpp.

189 {
190 }

◆ renameCharacter()

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

Implements Net::CharServerHandler.

Definition at line 177 of file charserverhandler.cpp.

180 {
181 }

◆ sendCheckPincode()

void TmwAthena::CharServerHandler::sendCheckPincode ( const BeingId  accountId,
const std::string &  pin 
) const
inlinevirtual

Implements Net::CharServerHandler.

Definition at line 71 of file charserverhandler.h.

74  { }

◆ setCharCreateDialog()

void TmwAthena::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 139 of file charserverhandler.cpp.

141 {
142  mCharCreateDialog = window;
143 
144  if (mCharCreateDialog == nullptr)
145  return;
146 
147  StringVect attributes;
148  // TRANSLATORS: playe stat
149  attributes.push_back(_("Strength:"));
150  // TRANSLATORS: playe stat
151  attributes.push_back(_("Agility:"));
152  // TRANSLATORS: playe stat
153  attributes.push_back(_("Vitality:"));
154  // TRANSLATORS: playe stat
155  attributes.push_back(_("Intelligence:"));
156  // TRANSLATORS: playe stat
157  attributes.push_back(_("Dexterity:"));
158  // TRANSLATORS: playe stat
159  attributes.push_back(_("Luck:"));
160 
161  const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
162 
163  int minStat = CharDB::getMinStat();
164  if (minStat == 0)
165  minStat = 1;
166  int maxStat = CharDB::getMaxStat();
167  if (maxStat == 0)
168  maxStat = 9;
169  int sumStat = CharDB::getSumStat();
170  if (sumStat == 0)
171  sumStat = 30;
172 
173  mCharCreateDialog->setAttributes(attributes, sumStat, minStat, maxStat);
175 }
void setDefaultGender(const GenderT gender)
void setAttributes(const StringVect &labels, int available, const int min, const int max)
static CharCreateDialog * mCharCreateDialog
#define _(s)
Definition: gettext.h:35
unsigned getSumStat()
Definition: chardb.cpp:162
unsigned getMinStat()
Definition: chardb.cpp:152
unsigned getMaxStat()
Definition: chardb.cpp:157
std::vector< std::string > StringVect
Definition: stringvector.h:29

References _, CharDB::getMaxStat(), CharDB::getMinStat(), CharDB::getSumStat(), loginHandler, Net::CharServerHandler::mCharCreateDialog, CharCreateDialog::setAttributes(), CharCreateDialog::setDefaultGender(), and Token::sex.

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

◆ setNewPincode()

void TmwAthena::CharServerHandler::setNewPincode ( const BeingId  accountId,
const std::string &  pin 
) const
inlinevirtual

Implements Net::CharServerHandler.

Definition at line 66 of file charserverhandler.h.

69  { }

◆ switchCharacter()

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

Implements Net::CharServerHandler.

Definition at line 108 of file charserverhandler.cpp.

109 {
110  // This is really a map-server packet
111  createOutPacket(CMSG_PLAYER_RESTART);
112  outMsg.writeInt8(1, "flag");
113 }

References createOutPacket.


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