From 1d9a7139a88dfe5ace5a2759253cc950dbb500bc Mon Sep 17 00:00:00 2001 From: kamilprzyb Date: Tue, 8 Sep 2020 22:41:02 +0200 Subject: [PATCH] deleteing player deletes inventory and nanos, minor tweaks to settings --- src/Database.cpp | 30 +++++++++++++----------------- src/settings.cpp | 14 ++++++-------- src/settings.hpp | 2 +- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/Database.cpp b/src/Database.cpp index 77f082a..6f6e520 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -44,9 +44,9 @@ auto db = make_storage("database.db", make_column("HP", &Database::DbPlayer::HP), make_column("HairColor", &Database::DbPlayer::HairColor), make_column("HairStyle", &Database::DbPlayer::HairStyle), - make_column("Height", &Database::DbPlayer::Height), - make_column("NameCheck", &Database::DbPlayer::NameCheck), - make_column("SkinColor", &Database::DbPlayer::SkinColor), + make_column("Height", &Database::DbPlayer::Height), + make_column("NameCheck", &Database::DbPlayer::NameCheck), + make_column("SkinColor", &Database::DbPlayer::SkinColor), make_column("isGM", &Database::DbPlayer::isGM), make_column("FusionMatter", &Database::DbPlayer::FusionMatter), make_column("Taros", &Database::DbPlayer::Taros), @@ -119,7 +119,7 @@ bool Database::isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck) (db.get_all (where((c(&DbPlayer::FirstName) == First) and (c(&DbPlayer::LastName) == Last))) - .empty()); + .empty()); } int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID) @@ -151,19 +151,11 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID) create.Height= 0; create.Level= 1; create.SkinColor= 1; - create.isGM = false; - //commented and disabled for now - //if (U16toU8(save->szFirstName) == settings::GMPASS) { - // create.isGM = true; - //} - - create.FusionMatter= 0; - create.Taros= 0; - create.PCState = 0; + create.isGM = settings::GM; create.x_coordinates = settings::SPAWN_X; create.y_coordinates= settings::SPAWN_Y; create.z_coordinates= settings::SPAWN_Z; - create.angle = 0; + create.angle = settings::SPAWN_ANGLE; return db.insert(create); } @@ -237,6 +229,9 @@ int Database::deleteCharacter(int characterID) db.get_all(where(c(&DbPlayer::PlayerID) == characterID)); int slot = find.front().slot; db.remove(find.front().PlayerID); + db.remove_all(where(c(&Inventory::playerId) == characterID)); + db.remove_all(where(c(&Nano::playerId) == characterID)); + return slot; } @@ -418,8 +413,10 @@ void Database::updateNanos(Player player) { where(c(&Nano::playerId) == player.iID) ); //insert - int i = 1; - while ((iiSkillID; toAdd.iStamina = next->iStamina; db.insert(toAdd); - i++; } db.commit(); } diff --git a/src/settings.cpp b/src/settings.cpp index d2c7314..f6cd64b 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -6,7 +6,6 @@ int settings::VERBOSITY = 1; int settings::LOGINPORT = 8001; -bool settings::LOGINRANDCHARACTERS = false; bool settings::APPROVEALLNAMES = true; int settings::SHARDPORT = 8002; @@ -14,11 +13,11 @@ std::string settings::SHARDSERVERIP = "127.0.0.1"; int settings::PLAYERDISTANCE = 20000; int settings::NPCDISTANCE = 16000; -// default spawn point is city hall -int settings::SPAWN_X = 179213; -int settings::SPAWN_Y = 268451; -int settings::SPAWN_Z = -4210; -std::string settings::GMPASS = "pass"; +// default spawn point is Sector V (future) +int settings::SPAWN_X = 632032; +int settings::SPAWN_Y = 187177; +int settings::SPAWN_Z = -5500; +int settings::SPAWN_ANGLE = 130; std::string settings::NPCJSON = "data/NPCs.json"; std::string settings::XDTJSON = "data/xdt.json"; std::string settings::MOBJSON = "data/mobs.json"; @@ -40,7 +39,6 @@ void settings::init() { APPROVEALLNAMES = reader.GetBoolean("", "acceptallcustomnames", APPROVEALLNAMES); VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY); LOGINPORT = reader.GetInteger("login", "port", LOGINPORT); - LOGINRANDCHARACTERS = reader.GetBoolean("login", "randomcharacters", LOGINRANDCHARACTERS); SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT); SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1"); PLAYERDISTANCE = reader.GetInteger("shard", "playerdistance", PLAYERDISTANCE); @@ -48,7 +46,7 @@ void settings::init() { SPAWN_X = reader.GetInteger("shard", "spawnx", SPAWN_X); SPAWN_Y = reader.GetInteger("shard", "spawny", SPAWN_Y); SPAWN_Z = reader.GetInteger("shard", "spawnz", SPAWN_Z); - GMPASS = reader.Get("login", "pass", GMPASS); + SPAWN_ANGLE = reader.GetInteger("shard", "spawnangle", SPAWN_ANGLE); NPCJSON = reader.Get("shard", "npcdata", NPCJSON); XDTJSON = reader.Get("shard", "xdtdata", XDTJSON); MOBJSON = reader.Get("shard", "mobdata", MOBJSON); diff --git a/src/settings.hpp b/src/settings.hpp index 67c7431..de8121b 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -12,11 +12,11 @@ namespace settings { extern int SPAWN_X; extern int SPAWN_Y; extern int SPAWN_Z; + extern int SPAWN_ANGLE; extern std::string MOTDSTRING; extern std::string NPCJSON; extern std::string XDTJSON; extern std::string MOBJSON; - extern std::string GMPASS; extern bool GM; void init();