Tons of cleanup / formatting

This commit is contained in:
Akkadius
2019-07-03 02:50:16 -05:00
parent 9e0f440106
commit 217c9751a8
19 changed files with 1515 additions and 1129 deletions
+132 -91
View File
@@ -1,20 +1,23 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net)
/**
* EQEmulator: Everquest Server Emulator
* Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY except by those people which sell it, which
* are required to give you total support for your newly bought product;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EQEMU_CLIENT_H
#define EQEMU_CLIENT_H
@@ -24,19 +27,15 @@
#include "../common/eq_stream_intf.h"
#include "../common/net/dns.h"
#include "../common/net/daybreak_connection.h"
#include "login_structures.h"
#include <memory>
enum LSClientVersion
{
enum LSClientVersion {
cv_titanium,
cv_sod
};
enum LSClientStatus
{
enum LSClientStatus {
cs_not_sent_session_ready,
cs_waiting_for_login,
cs_creating_account,
@@ -45,144 +44,186 @@ enum LSClientStatus
};
/**
* Client class, controls a single client and it's
* connection to the login server.
*/
class Client
{
* Client class, controls a single client and it's connection to the login server
*/
class Client {
public:
/**
* Constructor, sets our connection to c and version to v
*/
* Constructor, sets our connection to c and version to v
*
* @param c
* @param v
*/
Client(std::shared_ptr<EQStreamInterface> c, LSClientVersion v);
/**
* Destructor.
*/
~Client() { }
* Destructor
*/
~Client() {}
/**
* Processes the client's connection and does various actions.
*/
* Processes the client's connection and does various actions
*
* @return
*/
bool Process();
/**
* Sends our reply to session ready packet.
*/
void Handle_SessionReady(const char* data, unsigned int size);
* Sends our reply to session ready packet
*
* @param data
* @param size
*/
void Handle_SessionReady(const char *data, unsigned int size);
/**
* Verifies login and send a reply.
*/
void Handle_Login(const char* data, unsigned int size);
* Verifies login and send a reply
*
* @param data
* @param size
*/
void Handle_Login(const char *data, unsigned int size);
/**
* Sends a packet to the requested server to see if the client is allowed or not.
*/
void Handle_Play(const char* data);
* Sends a packet to the requested server to see if the client is allowed or not
*
* @param data
*/
void Handle_Play(const char *data);
/**
* Sends a server list packet to the client.
*/
* Sends a server list packet to the client
*
* @param seq
*/
void SendServerListPacket(uint32 seq);
/**
* Sends the input packet to the client and clears our play response states.
*/
* Sends the input packet to the client and clears our play response states
*
* @param outapp
*/
void SendPlayResponse(EQApplicationPacket *outapp);
/**
* Generates a random login key for the client during login.
*/
* Generates a random login key for the client during login
*/
void GenerateKey();
/**
* Gets the account id of this client.
*/
* Gets the account id of this client
*
* @return
*/
unsigned int GetAccountID() const { return account_id; }
/**
* Gets the loginserver name of this client.
*/
* Gets the loginserver name of this client
*
* @return
*/
std::string GetLoginServerName() const { return loginserver_name; }
/**
* Gets the account name of this client.
*/
* Gets the account name of this client
*
* @return
*/
std::string GetAccountName() const { return account_name; }
/**
* Gets the key generated at login for this client.
*/
* Gets the key generated at login for this client
*
* @return
*/
std::string GetKey() const { return key; }
/**
* Gets the server selected to be played on for this client.
*/
* Gets the server selected to be played on for this client
*
* @return
*/
unsigned int GetPlayServerID() const { return play_server_id; }
/**
* Gets the play sequence state for this client.
*/
* Gets the play sequence state for this client
*
* @return
*/
unsigned int GetPlaySequence() const { return play_sequence_id; }
/**
* Gets the connection for this client.
*/
* Gets the connection for this client
*
* @return
*/
std::shared_ptr<EQStreamInterface> GetConnection() { return connection; }
/**
* Attempts to create a login account
*/
* Attempts to create a login account
*
* @param user
* @param pass
* @param loginserver
*/
void AttemptLoginAccountCreation(const std::string &user, const std::string &pass, const std::string &loginserver);
/**
* Does a failed login
*/
* Does a failed login
*/
void DoFailedLogin();
/**
* Verifies a login hash, will also attempt to update a login hash if needed.
*/
bool VerifyLoginHash(const std::string &user, const std::string &loginserver, const std::string &cred, const std::string &hash);
* Verifies a login hash, will also attempt to update a login hash if needed
*
* @param user
* @param loginserver
* @param cred
* @param hash
* @return
*/
bool VerifyLoginHash(
const std::string &user,
const std::string &loginserver,
const std::string &cred,
const std::string &hash
);
/**
* Does a successful login
*/
void DoSuccessfulLogin(const std::string &user, int db_account_id, const std::string &db_loginserver);
/**
* Creates a local account
*/
void CreateLocalAccount(const std::string &user, const std::string &pass);
/**
* Creates an eqemu account
*/
void CreateEQEmuAccount(const std::string &user, const std::string &pass, unsigned int id);
private:
EQEmu::Random random;
EQEmu::Random random;
std::shared_ptr<EQStreamInterface> connection;
LSClientVersion version;
LSClientStatus status;
LSClientVersion version;
LSClientStatus status;
std::string account_name;
std::string account_name;
unsigned int account_id;
std::string loginserver_name;
std::string loginserver_name;
unsigned int play_server_id;
unsigned int play_sequence_id;
std::string key;
std::string key;
std::unique_ptr<EQ::Net::DaybreakConnectionManager> login_connection_manager;
std::shared_ptr<EQ::Net::DaybreakConnection> login_connection;
LoginLoginRequest_Struct llrs;
std::shared_ptr<EQ::Net::DaybreakConnection> login_connection;
LoginLoginRequest_Struct llrs;
std::string stored_user;
std::string stored_pass;
void LoginOnNewConnection(std::shared_ptr<EQ::Net::DaybreakConnection> connection);
void LoginOnStatusChange(std::shared_ptr<EQ::Net::DaybreakConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to);
void LoginOnStatusChangeIgnored(std::shared_ptr<EQ::Net::DaybreakConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to);
void LoginOnStatusChange(
std::shared_ptr<EQ::Net::DaybreakConnection> conn,
EQ::Net::DbProtocolStatus from,
EQ::Net::DbProtocolStatus to
);
void LoginOnStatusChangeIgnored(
std::shared_ptr<EQ::Net::DaybreakConnection> conn,
EQ::Net::DbProtocolStatus from,
EQ::Net::DbProtocolStatus to
);
void LoginOnPacketRecv(std::shared_ptr<EQ::Net::DaybreakConnection> conn, const EQ::Net::Packet &p);
void LoginSendSessionReady();
void LoginSendLogin();