2020-08-23 17:14:54 +00:00
|
|
|
#pragma once
|
2020-08-18 20:42:30 +00:00
|
|
|
|
|
|
|
#include "CNProtocol.hpp"
|
2020-08-22 15:25:42 +00:00
|
|
|
#include "Defines.hpp"
|
2020-08-18 20:42:30 +00:00
|
|
|
#include "Player.hpp"
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
struct CNLoginData {
|
|
|
|
std::map<int64_t, Player> characters;
|
|
|
|
int64_t selectedChar;
|
2020-09-01 22:37:09 +00:00
|
|
|
int userID; int slot;
|
2020-08-28 18:02:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class LOGINERRORID {
|
|
|
|
database_error = 0,
|
|
|
|
id_doesnt_exist = 1,
|
|
|
|
id_and_password_do_not_match = 2,
|
|
|
|
id_already_in_use = 3,
|
|
|
|
login_error = 4,
|
|
|
|
client_version_outdated = 6,
|
|
|
|
you_are_not_an_authorized_beta_tester = 7,
|
|
|
|
authentication_connection_error = 8,
|
|
|
|
updated_euala_required = 9
|
2020-08-18 20:42:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// WARNING: THERE CAN ONLY BE ONE OF THESE SERVERS AT A TIME!!!!!! TODO: change loginSessions & packet handlers to be non-static
|
|
|
|
class CNLoginServer : public CNServer {
|
|
|
|
private:
|
|
|
|
static void handlePacket(CNSocket* sock, CNPacketData* data);
|
|
|
|
static std::map<CNSocket*, CNLoginData> loginSessions;
|
2020-09-01 22:37:09 +00:00
|
|
|
|
|
|
|
static bool isLoginDataGood(std::string login, std::string password);
|
|
|
|
static bool isPasswordCorrect(std::string actualPassword, std::string tryPassword);
|
|
|
|
static bool isAccountInUse(int accountId);
|
|
|
|
//returns true if success
|
|
|
|
static bool exitDuplicate(int accountId);
|
2020-08-18 20:42:30 +00:00
|
|
|
public:
|
|
|
|
CNLoginServer(uint16_t p);
|
|
|
|
|
2020-08-22 23:31:09 +00:00
|
|
|
void newConnection(CNSocket* cns);
|
2020-09-01 22:37:09 +00:00
|
|
|
void killConnection(CNSocket* cns);
|
2020-08-18 20:42:30 +00:00
|
|
|
};
|