ManaPlus
Functions
EAthena::LoginRecv Namespace Reference

Functions

void processLoginError2 (Net::MessageIn &msg)
 
void processUpdateHost2 (Net::MessageIn &msg)
 
void processServerVersion (Net::MessageIn &msg)
 
void processCondingKey (Net::MessageIn &msg)
 
void processCharPasswordResponse (Net::MessageIn &msg)
 
void processLoginData (Net::MessageIn &msg)
 
void processLoginOtp1 (Net::MessageIn &msg)
 
void processLoginOtp2 (Net::MessageIn &msg)
 
void processLoginOtp3 (Net::MessageIn &msg)
 
void processMobileOtp (Net::MessageIn &msg)
 

Function Documentation

◆ processCharPasswordResponse()

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

Definition at line 207 of file loginrecv.cpp.

208 {
209  // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short
210  const uint8_t errMsg = msg.readUInt8("result code");
211  // Successful pass change
212  if (errMsg == 1)
213  {
215  }
216  // pass change failed
217  else
218  {
219  switch (errMsg)
220  {
221  case 0:
222  errorMessage =
223  // TRANSLATORS: error message
224  _("Account was not found. Please re-login.");
225  break;
226  case 2:
227  // TRANSLATORS: error message
228  errorMessage = _("Old password incorrect.");
229  break;
230  case 3:
231  // TRANSLATORS: error message
232  errorMessage = _("New password too short.");
233  break;
234  default:
235  // TRANSLATORS: error message
236  errorMessage = _("Unknown error.");
237  break;
238  }
240  }
241 }
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().

◆ processCondingKey()

void EAthena::LoginRecv::processCondingKey ( Net::MessageIn msg)

Definition at line 200 of file loginrecv.cpp.

201 {
203  const int sz = msg.readInt16("len") - 4;
204  msg.readString(sz, "coding key");
205 }
#define UNIMPLEMENTEDPACKET
Definition: logger.h:56

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processLoginData()

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

Definition at line 243 of file loginrecv.cpp.

244 {
245  msg.readInt16("len");
246 
248 
249  int offset = 0;
250  int serverLen = 0;
251  if (msg.getVersion() >= 20170315)
252  {
253  offset = 47 + 17;
254  serverLen = 32 + 128;
255  }
256  else
257  {
258  offset = 47;
259  serverLen = 32;
260  }
261 
262  const int worldCount = (msg.getLength() - offset) / serverLen;
263 
264  Ea::LoginRecv::mToken.session_ID1 = msg.readInt32("session id1");
265  Ea::LoginRecv::mToken.account_ID = msg.readBeingId("accound id");
266  Ea::LoginRecv::mToken.session_ID2 = msg.readInt32("session id2");
267  msg.readInt32("old ip");
268  loginData.lastLogin = msg.readString(24, "last login");
269  msg.readInt16("unused");
270 
271  // reserve bits for future usage
273  msg.readUInt8("gender") & 3U));
274 
275  if (msg.getVersion() >= 20170315)
276  {
277  msg.readString(16, "twitter auth token");
278  msg.readUInt8("twitter flag");
279  }
280 
281  for (int i = 0; i < worldCount; i++)
282  {
283  WorldInfo *const world = new WorldInfo;
284 
285  world->address = msg.readInt32("ip address");
286  world->port = msg.readInt16("port");
287  world->name = msg.readString(20, "name");
288  world->online_users = msg.readInt16("online number");
291  msg.readInt16("maintenance");
292  msg.readInt16("new");
293  if (msg.getVersion() >= 20170315)
294  {
295  for (int f = 0; f < 32; f ++)
296  msg.readInt32("unused2");
297  }
298 
299  logger->log("Network: Server: %s (%s:%d)", world->name.c_str(),
300  ipToString(world->address), world->port);
301 
302  Ea::LoginRecv::mWorlds.push_back(world);
303  }
305 }
#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.

◆ processLoginError2()

void EAthena::LoginRecv::processLoginError2 ( Net::MessageIn msg)

Definition at line 60 of file loginrecv.cpp.

61 {
62  const uint32_t code = msg.readInt32("error");
63  msg.readString(20, "error message");
64  logger->log("Login::error code: %u", code);
65 
66  switch (code)
67  {
68  case 0:
69  // TRANSLATORS: error message
70  errorMessage = _("Unregistered ID.");
71  break;
72  case 1:
73  // TRANSLATORS: error message
74  errorMessage = _("Wrong password.");
76  break;
77  case 2:
78  // TRANSLATORS: error message
79  errorMessage = _("Account expired.");
80  break;
81  case 3:
82  // TRANSLATORS: error message
83  errorMessage = _("Rejected from server.");
84  break;
85  case 4:
86  // TRANSLATORS: error message
87  errorMessage = _("You have been permanently banned from "
88  "the game. Please contact the GM team.");
89  break;
90  case 5:
91  // TRANSLATORS: error message
92  errorMessage = _("Client too old or wrong server type.\n"
93  "Please update client on http://manaplus.org");
94  break;
95  case 6:
96  // TRANSLATORS: error message
97  errorMessage = strprintf(_("You have been temporarily "
98  "banned from the game until "
99  "%s.\nPlease contact the GM "
100  "team via the forums."),
101  msg.readString(20, "date").c_str());
102  break;
103  case 7:
104  // look like unused
105  // TRANSLATORS: error message
106  errorMessage = _("Server overpopulated.");
107  break;
108  case 9:
109  // look like unused
110  // TRANSLATORS: error message
111  errorMessage = _("This user name is already taken.");
112  break;
113  case 10:
114  // look like unused
115  // TRANSLATORS: error message
116  errorMessage = _("Wrong name.");
117  break;
118  case 11:
119  // look like unused
120  // TRANSLATORS: error message
121  errorMessage = _("Incorrect email.");
122  break;
123  case 99:
124  // look like unused
125  // TRANSLATORS: error message
126  errorMessage = _("Username permanently erased.");
127  break;
128  default:
129  // TRANSLATORS: error message
130  errorMessage = _("Unknown error.");
132  break;
133  }
135 }
static std::string savedPassword
Definition: logindialog.h:80
#define UNIMPLEMENTEDPACKETFIELD(field)
Definition: logger.h:59
@ ERROR
Definition: state.h:35
std::string strprintf(const char *const format,...)

References _, client, State::ERROR, errorMessage, Logger::log(), logger, Actions::msg(), LoginDialog::savedPassword, Client::setState(), strprintf(), and UNIMPLEMENTEDPACKETFIELD.

◆ processLoginOtp1()

void EAthena::LoginRecv::processLoginOtp1 ( Net::MessageIn msg)

Definition at line 307 of file loginrecv.cpp.

308 {
310  const int tokenLen = msg.readInt16("len") - 8;
311  msg.readInt32("login flag");
312  msg.readString(tokenLen, "token");
313 }

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processLoginOtp2()

void EAthena::LoginRecv::processLoginOtp2 ( Net::MessageIn msg)

Definition at line 315 of file loginrecv.cpp.

316 {
318  const int tokenLen = msg.readInt16("len") - 14;
319  msg.readInt32("login flag");
320  msg.readString(6, "login flag2");
321  msg.readString(tokenLen, "token");
322 }

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processLoginOtp3()

void EAthena::LoginRecv::processLoginOtp3 ( Net::MessageIn msg)

Definition at line 324 of file loginrecv.cpp.

325 {
327  const int tokenLen = msg.readInt16("len") - 28;
328  msg.readInt32("login flag");
329  msg.readString(20, "login flag2");
330  msg.readString(tokenLen, "token");
331 }

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processMobileOtp()

void EAthena::LoginRecv::processMobileOtp ( Net::MessageIn msg)

Definition at line 333 of file loginrecv.cpp.

334 {
336  msg.readBeingId("accound id");
337 }

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processServerVersion()

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

Definition at line 160 of file loginrecv.cpp.

161 {
162  const int len = msg.readInt16("len");
163  msg.readInt32("unused");
164  serverVersion = msg.readInt32("server version");
165  if (serverVersion > 0)
166  {
167  logger->log("Evol2 server version: %d", serverVersion);
168  packetVersion = msg.readInt32("packet version");
169  logger->log("Hercules packet version: %d", packetVersion);
170  if (packetVersion == 20150000)
171  {
172  packetVersion = 20141022;
173  logger->log("autofix Hercules packet version to: %d",
174  packetVersion);
175  }
176  if (len >= 18)
177  {
178  evolPacketOffset = msg.readInt16("evol packet offset");
179  }
180  if (len >= 20)
181  {
182  packetsType = msg.readInt16("server packets type");
183  packets_re = (packetsType & 1) != 0;
184  packets_zero = (packetsType & 2) != 0;
185  if (packets_re == false &&
186  packets_zero == false)
187  {
188  packets_main = true;
189  }
190  }
191  }
192  else
193  {
194  logger->log("Hercules without version");
195  }
196  updateProtocol();
198 }
int serverVersion
Definition: client.cpp:124
bool packets_zero
Definition: client.cpp:133
int packetsType
Definition: client.cpp:129
bool packets_re
Definition: client.cpp:132
bool packets_main
Definition: client.cpp:131
int evolPacketOffset
Definition: net.cpp:40
int packetVersion
Definition: client.cpp:125
void updateProtocol()
@ LOGIN
Definition: state.h:40

References client, evolPacketOffset, Logger::log(), logger, State::LOGIN, Actions::msg(), packets_main, packets_re, packets_zero, packetsType, packetVersion, serverVersion, Client::setState(), and EAthena::updateProtocol().

◆ processUpdateHost2()

void EAthena::LoginRecv::processUpdateHost2 ( Net::MessageIn msg)

Definition at line 137 of file loginrecv.cpp.

138 {
139  const int len = msg.readInt16("len") - 4;
140  const std::string updateHost = msg.readString(len, "host");
141 
142  splitToStringVector(loginData.updateHosts, updateHost, '|');
144  {
145  if (!checkPath(*it))
146  {
147  logger->log1("Warning: incorrect update server name");
148  loginData.updateHosts.clear();
149  break;
150  }
151  }
152 
153  logger->log("Received update hosts \"%s\" from login server.",
154  updateHost.c_str());
155 
156  if (client->getState() == State::PRE_LOGIN)
158 }
StateT getState() const
Definition: client.h:69
void log1(const char *const log_text)
Definition: logger.cpp:238
StringVect updateHosts
Definition: logindata.h:63
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
@ PRE_LOGIN
Definition: state.h:39
bool checkPath(const std::string &path)
Definition: paths.cpp:121
void splitToStringVector(StringVect &tokens, const std::string &text, const char separator)
StringVect::iterator StringVectIter
Definition: stringvector.h:30

References checkPath(), client, FOR_EACH, Client::getState(), Logger::log(), Logger::log1(), logger, State::LOGIN, loginData, Actions::msg(), State::PRE_LOGIN, Client::setState(), splitToStringVector(), and LoginData::updateHosts.