mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Database.cpp refactoring
This commit is contained in:
parent
2551f74af1
commit
2a258a80f0
@ -349,15 +349,14 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
sP_CL2LS_REQ_CHAR_DELETE* del = (sP_CL2LS_REQ_CHAR_DELETE*)data->buf;
|
sP_CL2LS_REQ_CHAR_DELETE* del = (sP_CL2LS_REQ_CHAR_DELETE*)data->buf;
|
||||||
int operationResult = Database::deleteCharacter(del->iPC_UID, loginSessions[sock].userID);
|
int operationResult = Database::deleteCharacter(del->iPC_UID, loginSessions[sock].userID);
|
||||||
|
|
||||||
//success
|
// success
|
||||||
if (operationResult > 0) {
|
if (operationResult > 0) {
|
||||||
INITSTRUCT(sP_LS2CL_REP_CHAR_DELETE_SUCC, resp);
|
INITSTRUCT(sP_LS2CL_REP_CHAR_DELETE_SUCC, resp);
|
||||||
resp.iSlotNum = operationResult;
|
resp.iSlotNum = operationResult;
|
||||||
sock->sendPacket((void*)&resp, P_LS2CL_REP_CHAR_DELETE_SUCC, sizeof(sP_LS2CL_REP_CHAR_DELETE_SUCC));
|
sock->sendPacket((void*)&resp, P_LS2CL_REP_CHAR_DELETE_SUCC, sizeof(sP_LS2CL_REP_CHAR_DELETE_SUCC));
|
||||||
}
|
} else {
|
||||||
//failure
|
// failure
|
||||||
else {
|
// client doesnt't care about this packet and softlocks
|
||||||
//client doesnt't care about this packet and softlocks
|
|
||||||
INITSTRUCT(sP_LS2CL_REP_CHAR_DELETE_FAIL, resp);
|
INITSTRUCT(sP_LS2CL_REP_CHAR_DELETE_FAIL, resp);
|
||||||
resp.iErrorCode = 0;
|
resp.iErrorCode = 0;
|
||||||
sock->sendPacket((void*)&resp, P_LS2CL_REP_CHAR_DELETE_FAIL, sizeof(sP_LS2CL_REP_CHAR_DELETE_FAIL));
|
sock->sendPacket((void*)&resp, P_LS2CL_REP_CHAR_DELETE_FAIL, sizeof(sP_LS2CL_REP_CHAR_DELETE_FAIL));
|
||||||
|
182
src/Database.cpp
182
src/Database.cpp
@ -18,129 +18,187 @@ void Database::open() {
|
|||||||
//checking if database file exists
|
//checking if database file exists
|
||||||
std::ifstream file;
|
std::ifstream file;
|
||||||
file.open("data.db");
|
file.open("data.db");
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
file.close();
|
file.close();
|
||||||
//if exists, assign it
|
// if exists, assign it
|
||||||
db = sqlite3pp::database("data.db");
|
db = sqlite3pp::database("data.db");
|
||||||
DEBUGLOG(std::cout << "Database in operation" << std::endl; )
|
DEBUGLOG(std::cout << "Database in operation" << std::endl; )
|
||||||
}
|
} else {
|
||||||
else {
|
// if doesn't, create all the tables
|
||||||
//if doesn't, create all the tables
|
|
||||||
DEBUGLOG(std::cout << "Creating new database" << std::endl;)
|
DEBUGLOG(std::cout << "Creating new database" << std::endl;)
|
||||||
db = sqlite3pp::database("data.db");
|
db = sqlite3pp::database("data.db");
|
||||||
|
|
||||||
|
// creates accounts
|
||||||
db.execute("CREATE TABLE Accounts(AccountID INTEGER PRIMARY KEY AUTOINCREMENT, Login TEXT NOT NULL, Password TEXT NOT NULL);");
|
db.execute("CREATE TABLE Accounts(AccountID INTEGER PRIMARY KEY AUTOINCREMENT, Login TEXT NOT NULL, Password TEXT NOT NULL);");
|
||||||
|
// creates characters
|
||||||
db.execute("CREATE TABLE Players(PlayerID INTEGER PRIMARY KEY AUTOINCREMENT, AccountID INTEGER NOT NULL, Slot INTEGER NOT NULL, FirstName TEXT NOT NULL, LastName TEXT NOT NULL, CharData TEXT NOT NULL);");
|
db.execute("CREATE TABLE Players(PlayerID INTEGER PRIMARY KEY AUTOINCREMENT, AccountID INTEGER NOT NULL, Slot INTEGER NOT NULL, FirstName TEXT NOT NULL, LastName TEXT NOT NULL, CharData TEXT NOT NULL);");
|
||||||
|
|
||||||
DEBUGLOG(std::cout << "Done" << std::endl;)
|
DEBUGLOG(std::cout << "Done" << std::endl;)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// verifies that the username & passwords are valid
|
||||||
bool Database::isLoginDataGood(std::string login, std::string password) {
|
bool Database::isLoginDataGood(std::string login, std::string password) {
|
||||||
std::regex loginRegex("^([A-Za-z\\d_\\-]){5,20}$");
|
std::regex loginRegex("^([A-Za-z\\d_\\-]){5,20}$");
|
||||||
std::regex passwordRegex("^([A-Za-z\\d_\\-@$!%*#?&,.+:;<=>]){8,20}$");
|
std::regex passwordRegex("^([A-Za-z\\d_\\-@$!%*#?&,.+:;<=>]){2,20}$");
|
||||||
return (std::regex_match(login, loginRegex) && std::regex_match(password, passwordRegex));
|
return (std::regex_match(login, loginRegex) && std::regex_match(password, passwordRegex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::addAccount(std::string login, std::string password) {
|
void Database::addAccount(std::string login, std::string password) {
|
||||||
|
// generates prepared statment
|
||||||
sqlite3pp::command cmd(db, "INSERT INTO Accounts (Login, Password) VALUES (:login, :password)");
|
sqlite3pp::command cmd(db, "INSERT INTO Accounts (Login, Password) VALUES (:login, :password)");
|
||||||
|
|
||||||
|
// generates a hashed password!
|
||||||
password = BCrypt::generateHash(password);
|
password = BCrypt::generateHash(password);
|
||||||
|
|
||||||
|
// binds args to the command
|
||||||
cmd.bind(":login", login, sqlite3pp::nocopy);
|
cmd.bind(":login", login, sqlite3pp::nocopy);
|
||||||
cmd.bind(":password", password, sqlite3pp::nocopy);
|
cmd.bind(":password", password, sqlite3pp::nocopy);
|
||||||
cmd.execute();
|
cmd.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::doesUserExist(std::string login) {
|
bool Database::doesUserExist(std::string login) {
|
||||||
std::string q = "SELECT COUNT(AccountID) FROM Accounts WHERE Login = :login";
|
// generates prepared statement
|
||||||
const char* query = q.c_str();
|
sqlite3pp::query qry(db, "SELECT COUNT(AccountID) FROM Accounts WHERE Login = :login");
|
||||||
sqlite3pp::query qry(db, query);
|
// binds to the query
|
||||||
qry.bind(":login", login, sqlite3pp::nocopy);
|
qry.bind(":login", login, sqlite3pp::nocopy);
|
||||||
|
|
||||||
|
// executes
|
||||||
sqlite3pp::query::iterator i = qry.begin();
|
sqlite3pp::query::iterator i = qry.begin();
|
||||||
|
|
||||||
|
// grabs the first result (the count)
|
||||||
int result;
|
int result;
|
||||||
std::tie(result) = (*i).get_columns<int>(0);
|
std::tie(result) = (*i).get_columns<int>(0);
|
||||||
return (result != 0);
|
|
||||||
|
// if there is more than 0 results, the user exists :eyes:
|
||||||
|
return (result > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::isPasswordCorrect(std::string login, std::string password) {
|
bool Database::isPasswordCorrect(std::string login, std::string password) {
|
||||||
std::string q = "SELECT Password FROM Accounts WHERE Login = :login";
|
// generates prepared statement
|
||||||
const char* query = q.c_str();
|
sqlite3pp::query qry(db, "SELECT Password FROM Accounts WHERE Login = :login");
|
||||||
sqlite3pp::query qry(db, query);
|
// binds username to the query
|
||||||
qry.bind(":login", login, sqlite3pp::nocopy);
|
qry.bind(":login", login, sqlite3pp::nocopy);
|
||||||
|
|
||||||
|
// executes
|
||||||
sqlite3pp::query::iterator i = qry.begin();
|
sqlite3pp::query::iterator i = qry.begin();
|
||||||
|
|
||||||
|
// grabs the first result
|
||||||
const char* actual;
|
const char* actual;
|
||||||
std::tie(actual) = (*i).get_columns<const char*>(0);
|
std::tie(actual) = (*i).get_columns<const char*>(0);
|
||||||
|
|
||||||
|
// validate password hash with provded password
|
||||||
return BCrypt::validatePassword(password, actual);
|
return BCrypt::validatePassword(password, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::getUserID(std::string login) {
|
int Database::getUserID(std::string login) {
|
||||||
std::string q = "SELECT AccountID FROM Accounts WHERE Login = :login";
|
// generates prep statement
|
||||||
const char* query = q.c_str();
|
sqlite3pp::query qry(db, "SELECT AccountID FROM Accounts WHERE Login = :login");
|
||||||
sqlite3pp::query qry(db, query);
|
// binds the username to the login param
|
||||||
qry.bind(":login", login, sqlite3pp::nocopy);
|
qry.bind(":login", login, sqlite3pp::nocopy);
|
||||||
|
|
||||||
|
// executes the query
|
||||||
sqlite3pp::query::iterator i = qry.begin();
|
sqlite3pp::query::iterator i = qry.begin();
|
||||||
|
|
||||||
|
// grabs the first result of the query
|
||||||
int result;
|
int result;
|
||||||
std::tie(result) = (*i).get_columns<int>(0);
|
std::tie(result) = (*i).get_columns<int>(0);
|
||||||
|
|
||||||
|
// returns the result
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::getUserSlotsNum(int AccountId) {
|
int Database::getUserSlotsNum(int AccountId) {
|
||||||
std::string q = "SELECT COUNT(PlayerID) FROM Players WHERE AccountID = :ID";
|
// generates the prepared statement
|
||||||
const char* query = q.c_str();
|
sqlite3pp::query qry(db, "SELECT COUNT(PlayerID) FROM Players WHERE AccountID = :ID");
|
||||||
sqlite3pp::query qry(db, query);
|
|
||||||
|
// binds the ID to the param
|
||||||
qry.bind(":ID", AccountId);
|
qry.bind(":ID", AccountId);
|
||||||
|
|
||||||
|
// executes
|
||||||
sqlite3pp::query::iterator i = qry.begin();
|
sqlite3pp::query::iterator i = qry.begin();
|
||||||
|
|
||||||
|
// grabs the first result
|
||||||
int result;
|
int result;
|
||||||
std::tie(result) = (*i).get_columns<int>(0);
|
std::tie(result) = (*i).get_columns<int>(0);
|
||||||
|
|
||||||
|
// returns the result
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::isNameFree(std::string First, std::string Second) {
|
bool Database::isNameFree(std::string First, std::string Second) {
|
||||||
std::string q = "SELECT COUNT(PlayerID) FROM Players WHERE FirstName = :First COLLATE nocase AND LastName = :Second COLLATE nocase";
|
// generates the prepared statement
|
||||||
const char* query = q.c_str();
|
sqlite3pp::query qry(db, "SELECT COUNT(PlayerID) FROM Players WHERE FirstName = :First COLLATE nocase AND LastName = :Second COLLATE nocase");
|
||||||
sqlite3pp::query qry(db, query);
|
|
||||||
|
// binds the params
|
||||||
qry.bind(":First", First, sqlite3pp::nocopy);
|
qry.bind(":First", First, sqlite3pp::nocopy);
|
||||||
qry.bind(":Second", Second, sqlite3pp::nocopy);
|
qry.bind(":Second", Second, sqlite3pp::nocopy);
|
||||||
|
|
||||||
|
// executes the query
|
||||||
sqlite3pp::query::iterator i = qry.begin();
|
sqlite3pp::query::iterator i = qry.begin();
|
||||||
|
|
||||||
|
// grabs the result
|
||||||
int result;
|
int result;
|
||||||
std::tie(result) = (*i).get_columns<int>(0);
|
std::tie(result) = (*i).get_columns<int>(0);
|
||||||
|
|
||||||
|
// if no results return, the the username is unused
|
||||||
return (result == 0);
|
return (result == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID) {
|
void Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID) {
|
||||||
std::string charData = CharacterToJson(save);
|
// generate the command
|
||||||
sqlite3pp::command cmd(db, "INSERT INTO Players (AccountID, Slot, FirstName, LastName, CharData) VALUES (:AccountID, :Slot, :FirstName, :LastName, :CharData)");
|
sqlite3pp::command cmd(db, "INSERT INTO Players (AccountID, Slot, FirstName, LastName, CharData) VALUES (:AccountID, :Slot, :FirstName, :LastName, :CharData)");
|
||||||
|
|
||||||
|
// generate character data
|
||||||
|
std::string charData = CharacterToJson(save);
|
||||||
std::string first = U16toU8(save->szFirstName);
|
std::string first = U16toU8(save->szFirstName);
|
||||||
std::string last = U16toU8(save->szLastName);
|
std::string last = U16toU8(save->szLastName);
|
||||||
|
|
||||||
|
// bind to command
|
||||||
cmd.bind(":AccountID", AccountID);
|
cmd.bind(":AccountID", AccountID);
|
||||||
cmd.bind(":Slot", save->iSlotNum);
|
cmd.bind(":Slot", save->iSlotNum);
|
||||||
cmd.bind(":CharData", charData, sqlite3pp::nocopy);
|
cmd.bind(":CharData", charData, sqlite3pp::nocopy);
|
||||||
cmd.bind(":FirstName", first, sqlite3pp::nocopy);
|
cmd.bind(":FirstName", first, sqlite3pp::nocopy);
|
||||||
cmd.bind(":LastName", last, sqlite3pp::nocopy);
|
cmd.bind(":LastName", last, sqlite3pp::nocopy);
|
||||||
|
|
||||||
|
// run
|
||||||
cmd.execute();
|
cmd.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character) {
|
void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character) {
|
||||||
|
sqlite3pp::command cmd(db, "UPDATE Players SET CharData = :data WHERE PlayerID = :id");
|
||||||
|
|
||||||
|
// grab the data to add to the command
|
||||||
int id = character->PCStyle.iPC_UID;
|
int id = character->PCStyle.iPC_UID;
|
||||||
std::string charData = CharacterToJson(character);
|
std::string charData = CharacterToJson(character);
|
||||||
sqlite3pp::command cmd(db, "UPDATE Players SET CharData = :data WHERE PlayerID = :id");
|
|
||||||
|
// bind to the command & execute
|
||||||
cmd.bind(":data", charData, sqlite3pp::nocopy);
|
cmd.bind(":data", charData, sqlite3pp::nocopy);
|
||||||
cmd.bind(":id", id);
|
cmd.bind(":id", id);
|
||||||
cmd.execute();
|
cmd.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::finishTutorial(int PlayerID) {
|
void Database::finishTutorial(int PlayerID) {
|
||||||
std::string json;
|
sqlite3pp::query qry(db, "SELECT CharData FROM Players WHERE PlayerID = :ID");
|
||||||
std::string q = "SELECT CharData FROM Players WHERE PlayerID = :ID";
|
|
||||||
const char* query = q.c_str();
|
// bind to the query and execute
|
||||||
sqlite3pp::query qry(db, query);
|
|
||||||
qry.bind(":ID", PlayerID);
|
qry.bind(":ID", PlayerID);
|
||||||
sqlite3pp::query::iterator i = qry.begin();
|
sqlite3pp::query::iterator i = qry.begin();
|
||||||
|
|
||||||
|
// grab the player json from the database
|
||||||
|
std::string json;
|
||||||
std::tie(json) = (*i).get_columns<std::string>(0);
|
std::tie(json) = (*i).get_columns<std::string>(0);
|
||||||
|
|
||||||
|
// parse the json into a Player
|
||||||
Player player = JsonToPlayer(json, PlayerID);
|
Player player = JsonToPlayer(json, PlayerID);
|
||||||
|
|
||||||
|
// set the tutorial flag & equip lightning gun
|
||||||
player.PCStyle2.iTutorialFlag = 1;
|
player.PCStyle2.iTutorialFlag = 1;
|
||||||
//equip lightning gun
|
|
||||||
player.Equip[0].iID = 328;
|
player.Equip[0].iID = 328;
|
||||||
json = PlayerToJson(player);
|
json = PlayerToJson(player);
|
||||||
|
|
||||||
|
// update the database
|
||||||
sqlite3pp::command cmd(db, "UPDATE Players SET CharData = :data WHERE PlayerID = :id");
|
sqlite3pp::command cmd(db, "UPDATE Players SET CharData = :data WHERE PlayerID = :id");
|
||||||
cmd.bind(":data", json, sqlite3pp::nocopy);
|
cmd.bind(":data", json, sqlite3pp::nocopy);
|
||||||
cmd.bind(":id", PlayerID);
|
cmd.bind(":id", PlayerID);
|
||||||
@ -148,61 +206,81 @@ void Database::finishTutorial(int PlayerID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Database::getCharacterID(int AccountID, int slot) {
|
int Database::getCharacterID(int AccountID, int slot) {
|
||||||
std::string q = "SELECT PlayerID FROM Players WHERE AccountID = :ID AND Slot = :Slot";
|
// make the query
|
||||||
const char* query = q.c_str();
|
sqlite3pp::query qry(db, "SELECT PlayerID FROM Players WHERE AccountID = :ID AND Slot = :Slot");
|
||||||
sqlite3pp::query qry(db, query);
|
|
||||||
|
// bind the params & execute
|
||||||
qry.bind(":ID", AccountID);
|
qry.bind(":ID", AccountID);
|
||||||
qry.bind(":Slot", slot);
|
qry.bind(":Slot", slot);
|
||||||
sqlite3pp::query::iterator i = qry.begin();
|
sqlite3pp::query::iterator i = qry.begin();
|
||||||
|
|
||||||
|
// grab the result
|
||||||
int result;
|
int result;
|
||||||
std::tie(result) = (*i).get_columns<int>(0);
|
std::tie(result) = (*i).get_columns<int>(0);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::deleteCharacter(int characterID, int accountID) {
|
int Database::deleteCharacter(int characterID, int accountID) {
|
||||||
//checking if requested player exist and is bound to the account
|
// checking if requested player exist and is bound to the account
|
||||||
std::string q = "SELECT COUNT(AccountID) FROM Players WHERE AccountID = :AccID AND PlayerID = :PID";
|
|
||||||
const char* query = q.c_str();
|
sqlite3pp::query qry(db, "SELECT COUNT(AccountID) FROM Players WHERE AccountID = :AccID AND PlayerID = :PID");
|
||||||
sqlite3pp::query qry(db, query);
|
|
||||||
qry.bind(":AccID", accountID);
|
qry.bind(":AccID", accountID);
|
||||||
qry.bind(":PID", characterID);
|
qry.bind(":PID", characterID);
|
||||||
sqlite3pp::query::iterator i = qry.begin();
|
sqlite3pp::query::iterator i = qry.begin();
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
std::tie(result) = (*i).get_columns<int>(0);
|
std::tie(result) = (*i).get_columns<int>(0);
|
||||||
|
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
//get player character slot
|
// get player character slot
|
||||||
q = "SELECT Slot FROM Players WHERE PlayerID = :PID";
|
sqlite3pp::query qry(db, "SELECT Slot FROM Players WHERE PlayerID = :PID");
|
||||||
query = q.c_str();
|
|
||||||
sqlite3pp::query qry(db, query);
|
// bind & execute
|
||||||
qry.bind(":PID", characterID);
|
qry.bind(":PID", characterID);
|
||||||
sqlite3pp::query::iterator i = qry.begin();
|
sqlite3pp::query::iterator i = qry.begin();
|
||||||
|
|
||||||
|
// grab the slot to return
|
||||||
int slot;
|
int slot;
|
||||||
std::tie(slot) = (*i).get_columns<int>(0);
|
std::tie(slot) = (*i).get_columns<int>(0);
|
||||||
//delete
|
|
||||||
|
// actually delete the record
|
||||||
sqlite3pp::command cmd(db, "DELETE FROM Players WHERE PlayerID = :ID");
|
sqlite3pp::command cmd(db, "DELETE FROM Players WHERE PlayerID = :ID");
|
||||||
cmd.bind(":ID", characterID);
|
cmd.bind(":ID", characterID);
|
||||||
cmd.execute();
|
cmd.execute();
|
||||||
|
|
||||||
|
// finally, return the grabbed slot
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
else return -1;
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list <Player> Database::getCharacters(int userID) {
|
// TODO: this should really be std::vector, but for the sake of compatibility with PRs, I'll change this after merging
|
||||||
std::list<Player> Result = std::list<Player>();
|
std::list<Player> Database::getCharacters(int userID) {
|
||||||
std::string q = "SELECT * FROM Players WHERE AccountID = :ID";
|
std::list<Player> result = std::list<Player>();
|
||||||
const char* query = q.c_str();
|
|
||||||
sqlite3pp::query qry(db, query);
|
sqlite3pp::query qry(db, "SELECT * FROM Players WHERE AccountID = :ID");
|
||||||
|
|
||||||
qry.bind(":ID", userID);
|
qry.bind(":ID", userID);
|
||||||
|
|
||||||
|
// for each character owned by the account,
|
||||||
for (sqlite3pp::query::iterator i = qry.begin(); i != qry.end(); ++i) {
|
for (sqlite3pp::query::iterator i = qry.begin(); i != qry.end(); ++i) {
|
||||||
|
// grab the data
|
||||||
int ID, AccountID, slot;
|
int ID, AccountID, slot;
|
||||||
char const* charData, * first, * second;
|
char const* charData, * first, * second;
|
||||||
std::tie(ID, AccountID, slot, first, second, charData) =
|
std::tie(ID, AccountID, slot, first, second, charData) =
|
||||||
(*i).get_columns<int, int, int, char const*, char const*, char const*>(0, 1, 2, 3, 4, 5);
|
(*i).get_columns<int, int, int, char const*, char const*, char const*>(0, 1, 2, 3, 4, 5);
|
||||||
|
|
||||||
|
// convert to player
|
||||||
Player toadd = JsonToPlayer(charData, ID);
|
Player toadd = JsonToPlayer(charData, ID);
|
||||||
toadd.slot = slot;
|
toadd.slot = slot;
|
||||||
Result.push_back(toadd);
|
|
||||||
|
// add it to the results
|
||||||
|
result.push_back(toadd);
|
||||||
}
|
}
|
||||||
return Result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Database::CharacterToJson(sP_CL2LS_REQ_SAVE_CHAR_NAME* save) {
|
std::string Database::CharacterToJson(sP_CL2LS_REQ_SAVE_CHAR_NAME* save) {
|
||||||
@ -241,7 +319,7 @@ std::string Database::PlayerToJson(Player player) {
|
|||||||
nlohmann::json json = {
|
nlohmann::json json = {
|
||||||
{"Level",1},
|
{"Level",1},
|
||||||
//to check
|
//to check
|
||||||
{"HP",100},
|
{"HP",1000},
|
||||||
{"NameCheck", 1},
|
{"NameCheck", 1},
|
||||||
{"FirstName",U16toU8(player.PCStyle.szFirstName)},
|
{"FirstName",U16toU8(player.PCStyle.szFirstName)},
|
||||||
{"LastName",U16toU8(player.PCStyle.szLastName)},
|
{"LastName",U16toU8(player.PCStyle.szLastName)},
|
||||||
|
Loading…
Reference in New Issue
Block a user