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;
|
||||
|
||||
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);
|
||||
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)
|
||||
{
|
||||
if (db.count<DbPlayer>(where(c(&DbPlayer::AccountID) == AccountID))<4) {
|
||||
DbPlayer create = {};
|
||||
//save packet data
|
||||
create.FirstName = U16toU8(save->szFirstName);
|
||||
@ -141,24 +142,28 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
||||
else
|
||||
create.NameCheck = 0;
|
||||
//create default body character
|
||||
create.Body= 0;
|
||||
create.Class= 0;
|
||||
create.EyeColor= 1;
|
||||
create.FaceStyle= 1;
|
||||
create.Gender= 1;
|
||||
create.HP= 1000;
|
||||
create.HairColor= 1;
|
||||
create.Body = 0;
|
||||
create.Class = 0;
|
||||
create.EyeColor = 1;
|
||||
create.FaceStyle = 1;
|
||||
create.Gender = 1;
|
||||
create.HP = 1000;
|
||||
create.HairColor = 1;
|
||||
create.HairStyle = 1;
|
||||
create.Height= 0;
|
||||
create.Level= 1;
|
||||
create.SkinColor= 1;
|
||||
create.isGM = settings::GM;
|
||||
create.Height = 0;
|
||||
create.Level = 1;
|
||||
create.SkinColor = 1;
|
||||
create.isGM = false;
|
||||
create.x_coordinates = settings::SPAWN_X;
|
||||
create.y_coordinates= settings::SPAWN_Y;
|
||||
create.z_coordinates= settings::SPAWN_Z;
|
||||
create.y_coordinates = settings::SPAWN_Y;
|
||||
create.z_coordinates = settings::SPAWN_Z;
|
||||
create.angle = settings::SPAWN_ANGLE;
|
||||
create.QuestFlag = std::vector<char>();
|
||||
return db.insert(create);
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
|
||||
@ -229,10 +234,10 @@ void Database::finishTutorial(int PlayerID)
|
||||
db.update(playerToDb(finish));
|
||||
}
|
||||
|
||||
int Database::deleteCharacter(int characterID)
|
||||
int Database::deleteCharacter(int characterID, int userID)
|
||||
{
|
||||
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;
|
||||
db.remove<DbPlayer>(find.front().PlayerID);
|
||||
db.remove_all<Inventory>(where(c(&Inventory::playerId) == characterID));
|
||||
|
@ -83,7 +83,7 @@ namespace Database {
|
||||
//called after tutorial
|
||||
void finishTutorial(int PlayerID);
|
||||
//returns slot number
|
||||
int deleteCharacter(int characterID);
|
||||
int deleteCharacter(int characterID, int userID);
|
||||
std::vector <Player> getCharacters(int userID);
|
||||
//accepting/declining custom name
|
||||
enum class CUSTOMNAME {
|
||||
|
Loading…
Reference in New Issue
Block a user