2020-08-28 18:02:03 +00:00
|
|
|
#pragma once
|
|
|
|
#include "CNStructs.hpp"
|
|
|
|
#include "Player.hpp"
|
|
|
|
#include <string>
|
2020-09-01 22:37:09 +00:00
|
|
|
#include <vector>
|
2020-08-28 18:02:03 +00:00
|
|
|
|
|
|
|
namespace Database {
|
2020-09-14 13:53:48 +00:00
|
|
|
#pragma region DatabaseStructs
|
2020-09-01 22:37:09 +00:00
|
|
|
|
2020-10-19 17:26:14 +00:00
|
|
|
struct Account {
|
2020-09-02 15:53:39 +00:00
|
|
|
int AccountID;
|
|
|
|
std::string Login;
|
|
|
|
std::string Password;
|
|
|
|
int Selected;
|
2020-09-21 19:43:53 +00:00
|
|
|
uint64_t Created;
|
|
|
|
uint64_t LastLogin;
|
2020-09-02 15:53:39 +00:00
|
|
|
};
|
2020-10-19 17:26:14 +00:00
|
|
|
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
|
|
|
};
|
2020-10-19 17:26:14 +00:00
|
|
|
struct DbPlayer {
|
2020-09-02 15:53:39 +00:00
|
|
|
int PlayerID;
|
|
|
|
int AccountID;
|
|
|
|
short int slot;
|
|
|
|
std::string FirstName;
|
|
|
|
std::string LastName;
|
2020-09-21 19:43:53 +00:00
|
|
|
uint64_t Created;
|
|
|
|
uint64_t LastLogin;
|
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;
|
2020-09-14 13:53:48 +00:00
|
|
|
short int Height;
|
2020-09-02 15:53:39 +00:00
|
|
|
short int NameCheck;
|
|
|
|
short int PayZoneFlag;
|
|
|
|
short int SkinColor;
|
|
|
|
bool TutorialFlag;
|
2020-09-22 02:26:12 +00:00
|
|
|
int AccountLevel;
|
2020-09-02 15:53:39 +00:00
|
|
|
int FusionMatter;
|
|
|
|
int Taros;
|
|
|
|
int x_coordinates;
|
|
|
|
int y_coordinates;
|
|
|
|
int z_coordinates;
|
2020-09-02 22:22:00 +00:00
|
|
|
int angle;
|
|
|
|
short int PCState;
|
2020-09-21 19:43:53 +00:00
|
|
|
int BatteryW;
|
|
|
|
int BatteryN;
|
|
|
|
int16_t Mentor;
|
2020-09-13 18:45:51 +00:00
|
|
|
std::vector<char> QuestFlag;
|
2020-09-21 19:43:53 +00:00
|
|
|
int32_t CurrentMissionID;
|
|
|
|
int32_t WarpLocationFlag;
|
|
|
|
int64_t SkywayLocationFlag1;
|
|
|
|
int64_t SkywayLocationFlag2;
|
|
|
|
};
|
|
|
|
struct DbQuest {
|
|
|
|
int PlayerId;
|
|
|
|
int32_t TaskId;
|
|
|
|
int RemainingNPCCount1;
|
|
|
|
int RemainingNPCCount2;
|
|
|
|
int RemainingNPCCount3;
|
2020-09-02 15:53:39 +00:00
|
|
|
};
|
2020-11-08 17:42:27 +00:00
|
|
|
struct Buddyship {
|
|
|
|
int PlayerAId;
|
|
|
|
int PlayerBId;
|
|
|
|
int16_t Status;
|
|
|
|
};
|
2020-09-14 13:53:48 +00:00
|
|
|
|
2020-09-01 22:37:09 +00:00
|
|
|
|
|
|
|
#pragma endregion DatabaseStructs
|
|
|
|
|
2020-09-14 14:03:30 +00:00
|
|
|
// handles migrations
|
2020-09-02 15:53:39 +00:00
|
|
|
void open();
|
2020-09-21 19:43:53 +00:00
|
|
|
int getAccountsCount();
|
|
|
|
int getPlayersCount();
|
2020-09-14 14:03:30 +00:00
|
|
|
// 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);
|
2020-09-14 14:03:30 +00:00
|
|
|
// 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);
|
2020-09-14 14:03:30 +00:00
|
|
|
// called after finishing creation
|
2020-09-02 15:53:39 +00:00
|
|
|
void finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character);
|
2020-09-14 14:03:30 +00:00
|
|
|
// called after tutorial
|
2020-09-02 15:53:39 +00:00
|
|
|
void finishTutorial(int PlayerID);
|
2020-09-14 14:03:30 +00:00
|
|
|
// returns slot number
|
2020-09-13 20:29:30 +00:00
|
|
|
int deleteCharacter(int characterID, int userID);
|
2020-09-02 15:53:39 +00:00
|
|
|
std::vector <Player> getCharacters(int userID);
|
2020-09-14 14:03:30 +00:00
|
|
|
// accepting/declining custom name
|
2020-09-14 13:20:55 +00:00
|
|
|
enum class CustomName {
|
|
|
|
APPROVE = 1,
|
|
|
|
DISAPPROVE = 2
|
2020-09-02 15:53:39 +00:00
|
|
|
};
|
2020-09-14 13:20:55 +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);
|
2020-09-01 22:37:09 +00:00
|
|
|
|
2020-09-14 14:03:30 +00:00
|
|
|
// parsing DbPlayer
|
2020-09-14 13:20:55 +00:00
|
|
|
DbPlayer playerToDb(Player *player);
|
2020-09-02 15:53:39 +00:00
|
|
|
Player DbToPlayer(DbPlayer player);
|
2020-09-01 22:37:09 +00:00
|
|
|
|
2020-09-14 14:03:30 +00:00
|
|
|
// 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);
|
2020-09-01 22:37:09 +00:00
|
|
|
|
2020-09-14 13:20:55 +00:00
|
|
|
void updatePlayer(Player *player);
|
|
|
|
void updateInventory(Player *player);
|
|
|
|
void updateNanos(Player *player);
|
2020-09-21 19:43:53 +00:00
|
|
|
void updateQuests(Player* player);
|
2020-11-08 17:42:27 +00:00
|
|
|
void updateBuddies(Player* player);
|
2020-09-07 00:16:44 +00:00
|
|
|
|
|
|
|
void getInventory(Player* player);
|
2020-09-22 11:16:09 +00:00
|
|
|
void removeExpiredVehicles(Player* player);
|
2020-09-07 00:16:44 +00:00
|
|
|
void getNanos(Player* player);
|
2020-09-21 19:43:53 +00:00
|
|
|
void getQuests(Player* player);
|
2020-11-08 17:42:27 +00:00
|
|
|
void getBuddies(Player* player);
|
|
|
|
int getNumBuddies(Player* player);
|
2020-09-21 19:43:53 +00:00
|
|
|
|
2020-10-19 17:26:14 +00:00
|
|
|
// parsing blobs
|
2020-09-21 19:43:53 +00:00
|
|
|
void appendBlob(std::vector<char>*blob, int64_t input);
|
|
|
|
int64_t blobToInt64(std::vector<char>::iterator it);
|
2020-09-01 22:37:09 +00:00
|
|
|
}
|