Rewrote DB to use ORM, added all remaining features to LoginServer and refactored it

This commit is contained in:
kamilprzyb
2020-09-02 00:37:09 +02:00
parent 4f6c77be4f
commit 11801c1f89
18 changed files with 14108 additions and 23570 deletions

View File

@@ -1,31 +1,91 @@
#pragma once
#include "CNStructs.hpp"
#include "Player.hpp"
#include <list>
#include <string>
#include <vector>
namespace Database {
#pragma region DatabaseStructs
struct Account
{
int AccountID;
std::string Login;
std::string Password;
int Selected;
};
struct Inventory
{
int AccountID;
};
struct DbPlayer
{
int PlayerID;
int AccountID;
short int slot;
std::string FirstName;
std::string LastName;
short int AppearanceFlag;
short int Body;
short int Class;
short int EquipFoot;
short int EquipLB;
short int EquipUB;
short int EquipWeapon1;
short int EquipWeapon2;
short int EyeColor;
short int FaceStyle;
short int Gender;
int HP;
short int HairColor;
short int HairStyle;
short int Height;
short int Level;
short int NameCheck;
short int PayZoneFlag;
short int SkinColor;
bool TutorialFlag;
bool isGM;
int FusionMatter;
int Taros;
int x_coordinates;
int y_coordinates;
int z_coordinates;
};
#pragma endregion DatabaseStructs
//handles migrations
void open();
//checks regex
bool isLoginDataGood(std::string login, std::string password);
void addAccount(std::string login, std::string password);
bool doesUserExist(std::string login);
bool isPasswordCorrect(std::string login, std::string password);
int getUserID(std::string login);
int getUserSlotsNum(int AccountId);
bool isNameFree(std::string First, std::string Second);
//after chosing name
void createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID);
//after finishing creation
//returns ID
int addAccount(std::string login, std::string password);
void updateSelected(int accountId, int playerId);
std::unique_ptr<Account> findAccount(std::string login);
bool isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck);
//called after chosing name, returns ID
int createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID);
//called after finishing creation
void finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character);
//called after tutorial
void finishTutorial(int PlayerID);
//returns slot nr if success
int deleteCharacter(int characterID, int accountID);
int getCharacterID(int AccountID, int slot);
std::list <Player> getCharacters(int userID);
//some json parsing crap
std::string CharacterToJson(sP_CL2LS_REQ_SAVE_CHAR_NAME* save);
std::string CharacterToJson(sP_CL2LS_REQ_CHAR_CREATE* character);
Player JsonToPlayer(std::string input, int PC_UID);
std::string PlayerToJson(Player player);
}
//returns slot number
int deleteCharacter(int characterID);
std::vector <Player> getCharacters(int userID);
//accepting/declining custom name
enum class CUSTOMNAME {
approve = 1,
disapprove = 2
};
void evaluateCustomName(int characterID, CUSTOMNAME decision);
void changeName(sP_CL2LS_REQ_CHANGE_CHAR_NAME* save);
//parsing DbPlayer
DbPlayer playerToDb(Player player);
Player DbToPlayer(DbPlayer player);
//getting players
DbPlayer getDbPlayerById(int id);
}