mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-17 03:20:06 +00:00
306a75f469
Was getting frustrated by the inconsistency in our include statements, which were causing me problems. As a result, I went through and manually re-organized every include statement in non-core files. I'm just gonna copy my rant from Discord: FOR HEADER FILES (.hpp): - everything you use IN THE HEADER must be EXPLICITLY INCLUDED with the exception of things that fall under Core.hpp - you may NOT include ANYTHING ELSE FOR SOURCE FILES (.cpp): - you can #include whatever you want as long as the partner header is included first - anything that gets included by another include is fair game - redundant includes are ok because they'll be harmless AS LONG AS our header files stay lean. the point of this is NOT to optimize the number of includes used all around or make things more efficient necessarily. it's to improve readability & coherence and make it easier to avoid cyclical issues
56 lines
1.9 KiB
C++
56 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "core/Core.hpp"
|
|
|
|
#include "Player.hpp"
|
|
|
|
#include <map>
|
|
|
|
struct CNLoginData {
|
|
int userID;
|
|
time_t lastHeartbeat;
|
|
};
|
|
|
|
enum class LoginError {
|
|
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
|
|
};
|
|
|
|
// 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;
|
|
|
|
static void login(CNSocket* sock, CNPacketData* data);
|
|
static void nameCheck(CNSocket* sock, CNPacketData* data);
|
|
static void nameSave(CNSocket* sock, CNPacketData* data);
|
|
static void characterCreate(CNSocket* sock, CNPacketData* data);
|
|
static void characterDelete(CNSocket* sock, CNPacketData* data);
|
|
static void characterSelect(CNSocket* sock, CNPacketData* data);
|
|
static void finishTutorial(CNSocket* sock, CNPacketData* data);
|
|
static void changeName(CNSocket* sock, CNPacketData* data);
|
|
static void duplicateExit(CNSocket* sock, CNPacketData* data);
|
|
|
|
static bool isLoginDataGood(std::string login, std::string password);
|
|
static bool isPasswordCorrect(std::string actualPassword, std::string tryPassword);
|
|
static bool isAccountInUse(int accountId);
|
|
static bool isCharacterNameGood(std::string Firstname, std::string Lastname);
|
|
static void newAccount(CNSocket* sock, std::string userLogin, std::string userPassword, int32_t clientVerC);
|
|
// returns true if success
|
|
static bool exitDuplicate(int accountId);
|
|
public:
|
|
CNLoginServer(uint16_t p);
|
|
|
|
void newConnection(CNSocket* cns);
|
|
void killConnection(CNSocket* cns);
|
|
void onStep();
|
|
};
|