mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
Sanity checks for creating and deleting characters.
Co-authored-by: kamilprzyb <kamilprzybspam@wp.pl>
This commit is contained in:
parent
c7189a5cef
commit
38d5998a6e
@ -268,7 +268,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
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);
|
int operationResult = Database::deleteCharacter(del->iPC_UID, loginSessions[sock].userID);
|
||||||
|
|
||||||
INITSTRUCT(sP_LS2CL_REP_CHAR_DELETE_SUCC, resp);
|
INITSTRUCT(sP_LS2CL_REP_CHAR_DELETE_SUCC, resp);
|
||||||
resp.iSlotNum = operationResult;
|
resp.iSlotNum = operationResult;
|
||||||
|
@ -125,6 +125,7 @@ bool Database::isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck)
|
|||||||
|
|
||||||
int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
||||||
{
|
{
|
||||||
|
if (db.count<DbPlayer>(where(c(&DbPlayer::AccountID) == AccountID))<4) {
|
||||||
DbPlayer create = {};
|
DbPlayer create = {};
|
||||||
//save packet data
|
//save packet data
|
||||||
create.FirstName = U16toU8(save->szFirstName);
|
create.FirstName = U16toU8(save->szFirstName);
|
||||||
@ -152,7 +153,7 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
|||||||
create.Height = 0;
|
create.Height = 0;
|
||||||
create.Level = 1;
|
create.Level = 1;
|
||||||
create.SkinColor = 1;
|
create.SkinColor = 1;
|
||||||
create.isGM = settings::GM;
|
create.isGM = false;
|
||||||
create.x_coordinates = settings::SPAWN_X;
|
create.x_coordinates = settings::SPAWN_X;
|
||||||
create.y_coordinates = settings::SPAWN_Y;
|
create.y_coordinates = settings::SPAWN_Y;
|
||||||
create.z_coordinates = settings::SPAWN_Z;
|
create.z_coordinates = settings::SPAWN_Z;
|
||||||
@ -160,6 +161,10 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
|||||||
create.QuestFlag = std::vector<char>();
|
create.QuestFlag = std::vector<char>();
|
||||||
return db.insert(create);
|
return db.insert(create);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
|
void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
|
||||||
{
|
{
|
||||||
@ -229,10 +234,10 @@ void Database::finishTutorial(int PlayerID)
|
|||||||
db.update(playerToDb(finish));
|
db.update(playerToDb(finish));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::deleteCharacter(int characterID)
|
int Database::deleteCharacter(int characterID, int userID)
|
||||||
{
|
{
|
||||||
auto find =
|
auto find =
|
||||||
db.get_all<DbPlayer>(where(c(&DbPlayer::PlayerID) == characterID));
|
db.get_all<DbPlayer>(where(c(&DbPlayer::PlayerID) == characterID and c(&DbPlayer::AccountID)==userID));
|
||||||
int slot = find.front().slot;
|
int slot = find.front().slot;
|
||||||
db.remove<DbPlayer>(find.front().PlayerID);
|
db.remove<DbPlayer>(find.front().PlayerID);
|
||||||
db.remove_all<Inventory>(where(c(&Inventory::playerId) == characterID));
|
db.remove_all<Inventory>(where(c(&Inventory::playerId) == characterID));
|
||||||
|
@ -83,7 +83,7 @@ namespace Database {
|
|||||||
//called after tutorial
|
//called after tutorial
|
||||||
void finishTutorial(int PlayerID);
|
void finishTutorial(int PlayerID);
|
||||||
//returns slot number
|
//returns slot number
|
||||||
int deleteCharacter(int characterID);
|
int deleteCharacter(int characterID, int userID);
|
||||||
std::vector <Player> getCharacters(int userID);
|
std::vector <Player> getCharacters(int userID);
|
||||||
//accepting/declining custom name
|
//accepting/declining custom name
|
||||||
enum class CUSTOMNAME {
|
enum class CUSTOMNAME {
|
||||||
|
Loading…
Reference in New Issue
Block a user