ManaPlus
Functions
TmwAthena::LoginRecv Namespace Reference

Functions

void processServerVersion (Net::MessageIn &msg)
 
void processCharPasswordResponse (Net::MessageIn &msg)
 
void processLoginData (Net::MessageIn &msg)
 

Function Documentation

◆ processCharPasswordResponse()

void TmwAthena::LoginRecv::processCharPasswordResponse ( Net::MessageIn msg)

Definition at line 102 of file loginrecv.cpp.

103 {
104  // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short
105  const uint8_t errMsg = msg.readUInt8("result code");
106  // Successful pass change
107  if (errMsg == 1)
108  {
110  }
111  // pass change failed
112  else
113  {
114  switch (errMsg)
115  {
116  case 0:
117  errorMessage =
118  // TRANSLATORS: error message
119  _("Account was not found. Please re-login.");
120  break;
121  case 2:
122  // TRANSLATORS: error message
123  errorMessage = _("Old password incorrect.");
124  break;
125  case 3:
126  // TRANSLATORS: error message
127  errorMessage = _("New password too short.");
128  break;
129  default:
130  // TRANSLATORS: error message
131  errorMessage = _("Unknown error.");
132  break;
133  }
135  }
136 }
void setState(const StateT state)
Definition: client.h:66
Client * client
Definition: client.cpp:118
std::string errorMessage
Definition: client.cpp:116
#define _(s)
Definition: gettext.h:35
bool msg(InputEvent &event)
Definition: chat.cpp:39
@ ACCOUNTCHANGE_ERROR
Definition: state.h:52
@ CHANGEPASSWORD_SUCCESS
Definition: state.h:58

References _, State::ACCOUNTCHANGE_ERROR, State::CHANGEPASSWORD_SUCCESS, client, errorMessage, Actions::msg(), and Client::setState().

◆ processLoginData()

void TmwAthena::LoginRecv::processLoginData ( Net::MessageIn msg)

Definition at line 138 of file loginrecv.cpp.

139 {
140  msg.readInt16("len");
141 
143 
144  const int worldCount = (msg.getLength() - 47) / 32;
145 
146  Ea::LoginRecv::mToken.session_ID1 = msg.readInt32("session id1");
147  Ea::LoginRecv::mToken.account_ID = msg.readBeingId("accound id");
148  Ea::LoginRecv::mToken.session_ID2 = msg.readInt32("session id2");
149  msg.readInt32("old ip");
150  loginData.lastLogin = msg.readString(24, "last login");
151  msg.readInt16("unused");
152 
153  // reserve bits for future usage
155  msg.readUInt8("gender") & 3U));
156 
157  for (int i = 0; i < worldCount; i++)
158  {
159  WorldInfo *const world = new WorldInfo;
160 
161  world->address = msg.readInt32("ip address");
162  world->port = msg.readInt16("port");
163  world->name = msg.readString(20, "name");
164  world->online_users = msg.readInt16("online number");
167  msg.readInt16("maintenance");
168  msg.readInt16("new");
169 
170  logger->log("Network: Server: %s (%s:%d)", world->name.c_str(),
171  ipToString(world->address), world->port);
172 
173  Ea::LoginRecv::mWorlds.push_back(world);
174  }
176 }
#define CAST_U8
Definition: cast.h:27
static GenderT intToGender(const uint8_t sex) A_CONST
Definition: being.h:941
void setValue(const std::string &key, const std::string &value)
void log(const char *const log_text,...)
Definition: logger.cpp:269
std::string lastLogin
Definition: logindata.h:64
virtual void clearWorlds() const =0
Configuration config
Logger * logger
Definition: logger.cpp:89
Net::LoginHandler * loginHandler
Definition: net.cpp:90
LoginData loginData
Definition: client.cpp:185
std::string mUpdateHost
Definition: loginrecv.cpp:44
Worlds mWorlds
Definition: loginrecv.cpp:45
@ WORLD_SELECT
Definition: state.h:42
const char * ipToString(const uint32_t address)
Definition: stringutils.cpp:86
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
uint16_t port
Definition: worldinfo.h:54
std::string updateHost
Definition: worldinfo.h:56
std::string name
Definition: worldinfo.h:53
int address
Definition: worldinfo.h:52
int online_users
Definition: worldinfo.h:55

References Token::account_ID, WorldInfo::address, CAST_U8, Net::LoginHandler::clearWorlds(), client, config, Being::intToGender(), ipToString(), LoginData::lastLogin, Logger::log(), logger, loginData, loginHandler, Actions::msg(), Ea::LoginRecv::mToken, Ea::LoginRecv::mUpdateHost, Ea::LoginRecv::mWorlds, WorldInfo::name, WorldInfo::online_users, WorldInfo::port, Token::session_ID1, Token::session_ID2, Client::setState(), Configuration::setValue(), Token::sex, WorldInfo::updateHost, and State::WORLD_SELECT.

◆ processServerVersion()

void TmwAthena::LoginRecv::processServerVersion ( Net::MessageIn msg)

Definition at line 57 of file loginrecv.cpp.

58 {
59  packetVersion = 0;
60  itemIdLen = 2;
61  const uint8_t b1 = msg.readUInt8("b1"); // -1
62  const uint8_t b2 = msg.readUInt8("b2");
63  const uint8_t b3 = msg.readUInt8("b3");
64  msg.readUInt8("b4");
65  if (b1 == 255)
66  { // old TMWA
67  const unsigned int options = msg.readInt32("options");
69  ((options & FLAG_REGISTRATION) != 0U);
70  serverVersion = 0;
71  tmwServerVersion = 0;
72  }
73  else if (b1 >= 0x0d)
74  { // new TMWA
75  const unsigned int options = msg.readInt32("options");
77  ((options & FLAG_REGISTRATION) != 0U);
78  serverVersion = 0;
79  tmwServerVersion = (b1 << 16) | (b2 << 8) | b3;
80  }
81  else
82  { // eAthena
83  const unsigned int options = msg.readInt32("options");
85  ((options & FLAG_REGISTRATION) != 0U);
86  serverVersion = 0;
87  tmwServerVersion = 0;
88  }
89  if (tmwServerVersion > 0)
90  logger->log("Tmw server version: x%06x", tmwServerVersion);
91  else
92  logger->log("Server without version");
94 
95  if (client->getState() != State::LOGIN)
97 
98  // Leave this last
100 }
StateT getState() const
Definition: client.h:69
int serverVersion
Definition: client.cpp:124
int packetVersion
Definition: client.cpp:125
void updateProtocol()
bool mVersionResponse
Definition: loginrecv.cpp:47
bool mRegistrationEnabled
Definition: loginrecv.cpp:48
@ LOGIN
Definition: state.h:40
@ FLAG_REGISTRATION
Definition: loginrecv.cpp:54
unsigned int tmwServerVersion
Definition: client.cpp:134
int itemIdLen
Definition: client.cpp:130

References client, TmwAthena::FLAG_REGISTRATION, Client::getState(), itemIdLen, Logger::log(), logger, State::LOGIN, Ea::LoginRecv::mRegistrationEnabled, Actions::msg(), Ea::LoginRecv::mVersionResponse, packetVersion, serverVersion, Client::setState(), tmwServerVersion, and TmwAthena::updateProtocol().