Database saving update (#104)

* implemented saving BatteryN and BatteryW

* implemented saving mentor

* moved int64->blob parsing to a separate function

* moved parsing blob->int64 to a separate function

* added functions for parsing int32->blob and vice versa

* added functions for parsing int16->blob and vice versa

* WIP saving quest items and active tasks

* Quest items are stored in inventory table instead of blob

* added sanity check for missionId

* saving active missions works

* removed unneccesary include

* implemented saving warplocationflag, skywaylocationflag and currentmissionid in database

* INFO DB message now shows how many accounts and player characters are in the database

* fixed dbsaveinterval being in [login] instead of [shard]

* fixed mission quit:
- fixed wrong json name, causing qitems not deleting properly
- quitting mission now resets npc kill count

* adjusted saving active missions

* removed blob parsing functions that ended up being unused

* removed accidentaly added include

* removed sending PCStyle2 on Player Enter

* added a sanity check in itemMoveHandler

* removed MapNum from PCLoad, as client doesn't even read it

* set BuddyWarpCooldown to 60s on PCLoad

* fixed a bug causing EXIT DUPLICATE not working

* added creation and last login timestamps to accounts and players

* added a sanity check for P_CL2LS_REQ_PC_EXIT_DUPLICATE

* implemented web api support, toggled by new setting (off by default)

* add usewebapi to config

Co-authored-by: Gent <gentsemaj@live.com>
This commit is contained in:
kamilprzyb
2020-09-21 21:43:53 +02:00
committed by GitHub
parent 321dca3f79
commit 5e0948ea93
11 changed files with 332 additions and 58 deletions

View File

@@ -13,6 +13,8 @@ namespace Database {
std::string Login;
std::string Password;
int Selected;
uint64_t Created;
uint64_t LastLogin;
};
struct Inventory
{
@@ -36,6 +38,8 @@ namespace Database {
short int slot;
std::string FirstName;
std::string LastName;
uint64_t Created;
uint64_t LastLogin;
short int Level;
int Nano1;
int Nano2;
@@ -62,15 +66,30 @@ namespace Database {
int z_coordinates;
int angle;
short int PCState;
int BatteryW;
int BatteryN;
int16_t Mentor;
std::vector<char> QuestFlag;
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;
};
#pragma endregion DatabaseStructs
// handles migrations
void open();
int getAccountsCount();
int getPlayersCount();
// returns ID
int addAccount(std::string login, std::string password);
void updateSelected(int accountId, int playerId);
@@ -104,7 +123,13 @@ namespace Database {
void updatePlayer(Player *player);
void updateInventory(Player *player);
void updateNanos(Player *player);
void updateQuests(Player* player);
void getInventory(Player* player);
void getNanos(Player* player);
void getQuests(Player* player);
//parsing blobs
void appendBlob(std::vector<char>*blob, int64_t input);
int64_t blobToInt64(std::vector<char>::iterator it);
}