2020-08-28 18:02:03 +00:00
|
|
|
#pragma once
|
2021-03-17 19:07:40 +00:00
|
|
|
|
2020-08-28 18:02:03 +00:00
|
|
|
#include "Player.hpp"
|
2021-03-17 19:07:40 +00:00
|
|
|
|
2020-08-28 18:02:03 +00:00
|
|
|
#include <string>
|
2020-09-01 22:37:09 +00:00
|
|
|
#include <vector>
|
2020-12-06 19:29:48 +00:00
|
|
|
|
2021-08-13 04:47:09 +00:00
|
|
|
#define DATABASE_VERSION 4
|
2020-08-28 18:02:03 +00:00
|
|
|
|
|
|
|
namespace Database {
|
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 Password;
|
|
|
|
int Selected;
|
2020-12-05 23:03:52 +00:00
|
|
|
time_t BannedUntil;
|
2020-12-17 11:18:04 +00:00
|
|
|
std::string BanReason;
|
2020-09-02 15:53:39 +00:00
|
|
|
};
|
2021-03-14 23:35:54 +00:00
|
|
|
|
2020-11-07 01:50:17 +00:00
|
|
|
struct EmailData {
|
|
|
|
int PlayerId;
|
|
|
|
int MsgIndex;
|
|
|
|
int32_t ReadFlag;
|
|
|
|
int32_t ItemFlag;
|
|
|
|
int SenderId;
|
|
|
|
std::string SenderFirstName;
|
|
|
|
std::string SenderLastName;
|
|
|
|
std::string SubjectLine;
|
|
|
|
std::string MsgBody;
|
|
|
|
int Taros;
|
|
|
|
uint64_t SendTime;
|
|
|
|
uint64_t DeleteTime;
|
|
|
|
};
|
2021-03-14 23:35:54 +00:00
|
|
|
|
2020-12-19 01:32:49 +00:00
|
|
|
struct RaceRanking {
|
|
|
|
int EPID;
|
|
|
|
int PlayerID;
|
|
|
|
int Score;
|
|
|
|
int RingCount;
|
|
|
|
uint64_t Time;
|
|
|
|
uint64_t Timestamp;
|
|
|
|
};
|
2020-12-06 19:29:48 +00:00
|
|
|
|
2020-09-02 15:53:39 +00:00
|
|
|
void open();
|
2020-12-04 00:22:53 +00:00
|
|
|
void close();
|
2020-12-03 13:11:02 +00:00
|
|
|
|
|
|
|
void findAccount(Account* account, std::string login);
|
2021-03-14 23:35:54 +00:00
|
|
|
// returns ID, 0 if something failed
|
2020-09-02 15:53:39 +00:00
|
|
|
int addAccount(std::string login, std::string password);
|
2021-03-14 23:35:54 +00:00
|
|
|
|
|
|
|
// interface for the /ban command
|
2021-03-06 21:29:52 +00:00
|
|
|
bool banPlayer(int playerId, std::string& reason);
|
|
|
|
bool unbanPlayer(int playerId);
|
|
|
|
|
2022-12-06 00:07:21 +00:00
|
|
|
void updateSelected(int accountId, int slot);
|
|
|
|
void updateSelectedByPlayerId(int accountId, int playerId);
|
2020-12-03 13:11:02 +00:00
|
|
|
|
2020-11-17 02:21:41 +00:00
|
|
|
bool validateCharacter(int characterID, int userID);
|
2020-11-25 23:39:41 +00:00
|
|
|
bool isNameFree(std::string firstName, std::string lastName);
|
2020-11-26 00:15:30 +00:00
|
|
|
bool isSlotFree(int accountId, int slotNum);
|
2020-12-03 13:11:02 +00:00
|
|
|
/// returns ID, 0 if something failed
|
2020-09-02 15:53:39 +00:00
|
|
|
int createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID);
|
2020-12-03 13:11:02 +00:00
|
|
|
/// returns true if query succeeded
|
|
|
|
bool finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character, int accountId);
|
|
|
|
/// returns true if query succeeded
|
|
|
|
bool finishTutorial(int playerID, int accountID);
|
|
|
|
/// returns slot number if query succeeded
|
2020-09-13 20:29:30 +00:00
|
|
|
int deleteCharacter(int characterID, int userID);
|
2020-12-03 13:11:02 +00:00
|
|
|
void getCharInfo(std::vector <sP_LS2CL_REP_CHAR_INFO>* result, int userID);
|
2021-03-14 23:35:54 +00:00
|
|
|
|
2020-12-03 13:11:02 +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-12-03 13:11:02 +00:00
|
|
|
/// returns true if query succeeded
|
2020-12-02 21:51:02 +00:00
|
|
|
bool changeName(sP_CL2LS_REQ_CHANGE_CHAR_NAME* save, int accountId);
|
2020-09-01 22:37:09 +00:00
|
|
|
|
2020-09-14 14:03:30 +00:00
|
|
|
// getting players
|
2020-12-02 21:51:02 +00:00
|
|
|
void getPlayer(Player* plr, int id);
|
2022-12-05 21:29:23 +00:00
|
|
|
bool _updatePlayer(Player *player);
|
2020-09-14 13:20:55 +00:00
|
|
|
void updatePlayer(Player *player);
|
2022-12-05 21:29:23 +00:00
|
|
|
void commitTrade(Player *plr1, Player *plr2);
|
2020-12-03 13:11:02 +00:00
|
|
|
|
2020-11-09 10:01:51 +00:00
|
|
|
// buddies
|
2020-12-03 13:11:02 +00:00
|
|
|
int getNumBuddies(Player* player);
|
2020-11-09 10:01:51 +00:00
|
|
|
void addBuddyship(int playerA, int playerB);
|
|
|
|
void removeBuddyship(int playerA, int playerB);
|
2020-12-05 00:29:08 +00:00
|
|
|
|
|
|
|
// blocking
|
|
|
|
void addBlock(int playerId, int blockedPlayerId);
|
|
|
|
void removeBlock(int playerId, int blockedPlayerId);
|
2020-11-09 10:01:51 +00:00
|
|
|
|
2020-11-07 01:50:17 +00:00
|
|
|
// email
|
|
|
|
int getUnreadEmailCount(int playerID);
|
|
|
|
std::vector<EmailData> getEmails(int playerID, int page);
|
|
|
|
EmailData getEmail(int playerID, int index);
|
|
|
|
sItemBase* getEmailAttachments(int playerID, int index);
|
|
|
|
void updateEmailContent(EmailData* data);
|
|
|
|
void deleteEmailAttachments(int playerID, int index, int slot);
|
|
|
|
void deleteEmails(int playerID, int64_t* indices);
|
|
|
|
int getNextEmailIndex(int playerID);
|
2022-12-05 21:29:23 +00:00
|
|
|
bool sendEmail(EmailData* data, std::vector<sItemBase> attachments, Player *sender);
|
2020-12-19 01:32:49 +00:00
|
|
|
|
|
|
|
// racing
|
2020-12-14 21:59:34 +00:00
|
|
|
RaceRanking getTopRaceRanking(int epID, int playerID);
|
2020-12-19 01:32:49 +00:00
|
|
|
void postRaceRanking(RaceRanking ranking);
|
2021-01-19 02:44:02 +00:00
|
|
|
|
|
|
|
// code items
|
|
|
|
bool isCodeRedeemed(int playerId, std::string code);
|
|
|
|
void recordCodeRedemption(int playerId, std::string code);
|
2020-09-01 22:37:09 +00:00
|
|
|
}
|