OpenFusion/src/Database.hpp

111 lines
2.8 KiB
C++
Raw Normal View History

#pragma once
#include "CNStructs.hpp"
#include "Player.hpp"
#include <string>
#include <vector>
namespace Database {
#pragma region DatabaseStructs
2020-09-02 15:53:39 +00:00
struct Account
{
int AccountID;
std::string Login;
std::string Password;
int Selected;
};
struct Inventory
{
2020-09-07 00:16:44 +00:00
int playerId;
int slot;
int16_t Type;
int16_t id;
int32_t Opt;
int32_t TimeLimit;
};
struct Nano {
int playerId;
int16_t iID;
int16_t iSkillID;
int16_t iStamina;
2020-09-02 15:53:39 +00:00
};
struct DbPlayer
{
int PlayerID;
int AccountID;
short int slot;
std::string FirstName;
std::string LastName;
2020-09-07 00:16:44 +00:00
short int Level;
int Nano1;
int Nano2;
int Nano3;
2020-09-02 15:53:39 +00:00
short int AppearanceFlag;
short int Body;
short int Class;
short int EyeColor;
short int FaceStyle;
short int Gender;
int HP;
short int HairColor;
short int HairStyle;
short int Height;
2020-09-02 15:53:39 +00:00
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;
int angle;
short int PCState;
2020-09-13 18:45:51 +00:00
std::vector<char> QuestFlag;
2020-09-02 15:53:39 +00:00
};
#pragma endregion DatabaseStructs
// handles migrations
2020-09-02 15:53:39 +00:00
void open();
// returns ID
2020-09-02 15:53:39 +00:00
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
2020-09-02 15:53:39 +00:00
int createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID);
// called after finishing creation
2020-09-02 15:53:39 +00:00
void finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character);
// called after tutorial
2020-09-02 15:53:39 +00:00
void finishTutorial(int PlayerID);
// returns slot number
int deleteCharacter(int characterID, int userID);
2020-09-02 15:53:39 +00:00
std::vector <Player> getCharacters(int userID);
// accepting/declining custom name
enum class CustomName {
APPROVE = 1,
DISAPPROVE = 2
2020-09-02 15:53:39 +00:00
};
void evaluateCustomName(int characterID, CustomName decision);
2020-09-02 15:53:39 +00:00
void changeName(sP_CL2LS_REQ_CHANGE_CHAR_NAME* save);
// parsing DbPlayer
DbPlayer playerToDb(Player *player);
2020-09-02 15:53:39 +00:00
Player DbToPlayer(DbPlayer player);
// getting players
2020-09-02 15:53:39 +00:00
DbPlayer getDbPlayerById(int id);
2020-09-07 00:16:44 +00:00
Player getPlayer(int id);
void updatePlayer(Player *player);
void updateInventory(Player *player);
void updateNanos(Player *player);
2020-09-07 00:16:44 +00:00
void getInventory(Player* player);
void getNanos(Player* player);
}