deleteing player deletes inventory and nanos, minor tweaks to settings

This commit is contained in:
kamilprzyb 2020-09-08 22:41:02 +02:00 committed by dongresource
parent 2fd7a8c6fc
commit 1d9a7139a8
3 changed files with 20 additions and 26 deletions

View File

@ -44,9 +44,9 @@ auto db = make_storage("database.db",
make_column("HP", &Database::DbPlayer::HP), make_column("HP", &Database::DbPlayer::HP),
make_column("HairColor", &Database::DbPlayer::HairColor), make_column("HairColor", &Database::DbPlayer::HairColor),
make_column("HairStyle", &Database::DbPlayer::HairStyle), make_column("HairStyle", &Database::DbPlayer::HairStyle),
make_column("Height", &Database::DbPlayer::Height), make_column("Height", &Database::DbPlayer::Height),
make_column("NameCheck", &Database::DbPlayer::NameCheck), make_column("NameCheck", &Database::DbPlayer::NameCheck),
make_column("SkinColor", &Database::DbPlayer::SkinColor), make_column("SkinColor", &Database::DbPlayer::SkinColor),
make_column("isGM", &Database::DbPlayer::isGM), make_column("isGM", &Database::DbPlayer::isGM),
make_column("FusionMatter", &Database::DbPlayer::FusionMatter), make_column("FusionMatter", &Database::DbPlayer::FusionMatter),
make_column("Taros", &Database::DbPlayer::Taros), make_column("Taros", &Database::DbPlayer::Taros),
@ -119,7 +119,7 @@ bool Database::isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck)
(db.get_all<DbPlayer> (db.get_all<DbPlayer>
(where((c(&DbPlayer::FirstName) == First) (where((c(&DbPlayer::FirstName) == First)
and (c(&DbPlayer::LastName) == Last))) and (c(&DbPlayer::LastName) == Last)))
.empty()); .empty());
} }
int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID) 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.Height= 0;
create.Level= 1; create.Level= 1;
create.SkinColor= 1; create.SkinColor= 1;
create.isGM = false; create.isGM = settings::GM;
//commented and disabled for now
//if (U16toU8(save->szFirstName) == settings::GMPASS) {
// create.isGM = true;
//}
create.FusionMatter= 0;
create.Taros= 0;
create.PCState = 0;
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;
create.angle = 0; create.angle = settings::SPAWN_ANGLE;
return db.insert(create); return db.insert(create);
} }
@ -237,6 +229,9 @@ int Database::deleteCharacter(int characterID)
db.get_all<DbPlayer>(where(c(&DbPlayer::PlayerID) == characterID)); db.get_all<DbPlayer>(where(c(&DbPlayer::PlayerID) == characterID));
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<Nano>(where(c(&Nano::playerId) == characterID));
return slot; return slot;
} }
@ -418,8 +413,10 @@ void Database::updateNanos(Player player) {
where(c(&Nano::playerId) == player.iID) where(c(&Nano::playerId) == player.iID)
); );
//insert //insert
int i = 1; for (int i=1; i < SIZEOF_NANO_BANK_SLOT; i++)
while ((i<SIZEOF_NANO_BANK_SLOT)&&(player.Nanos[i]).iID!=0){ {
if ((player.Nanos[i]).iID == 0)
continue;
Nano toAdd = {}; Nano toAdd = {};
sNano* next = &player.Nanos[i]; sNano* next = &player.Nanos[i];
toAdd.playerId = player.iID; toAdd.playerId = player.iID;
@ -427,7 +424,6 @@ void Database::updateNanos(Player player) {
toAdd.iSkillID = next->iSkillID; toAdd.iSkillID = next->iSkillID;
toAdd.iStamina = next->iStamina; toAdd.iStamina = next->iStamina;
db.insert(toAdd); db.insert(toAdd);
i++;
} }
db.commit(); db.commit();
} }

View File

@ -6,7 +6,6 @@
int settings::VERBOSITY = 1; int settings::VERBOSITY = 1;
int settings::LOGINPORT = 8001; int settings::LOGINPORT = 8001;
bool settings::LOGINRANDCHARACTERS = false;
bool settings::APPROVEALLNAMES = true; bool settings::APPROVEALLNAMES = true;
int settings::SHARDPORT = 8002; int settings::SHARDPORT = 8002;
@ -14,11 +13,11 @@ std::string settings::SHARDSERVERIP = "127.0.0.1";
int settings::PLAYERDISTANCE = 20000; int settings::PLAYERDISTANCE = 20000;
int settings::NPCDISTANCE = 16000; int settings::NPCDISTANCE = 16000;
// default spawn point is city hall // default spawn point is Sector V (future)
int settings::SPAWN_X = 179213; int settings::SPAWN_X = 632032;
int settings::SPAWN_Y = 268451; int settings::SPAWN_Y = 187177;
int settings::SPAWN_Z = -4210; int settings::SPAWN_Z = -5500;
std::string settings::GMPASS = "pass"; int settings::SPAWN_ANGLE = 130;
std::string settings::NPCJSON = "data/NPCs.json"; std::string settings::NPCJSON = "data/NPCs.json";
std::string settings::XDTJSON = "data/xdt.json"; std::string settings::XDTJSON = "data/xdt.json";
std::string settings::MOBJSON = "data/mobs.json"; std::string settings::MOBJSON = "data/mobs.json";
@ -40,7 +39,6 @@ void settings::init() {
APPROVEALLNAMES = reader.GetBoolean("", "acceptallcustomnames", APPROVEALLNAMES); APPROVEALLNAMES = reader.GetBoolean("", "acceptallcustomnames", APPROVEALLNAMES);
VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY); VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY);
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT); LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
LOGINRANDCHARACTERS = reader.GetBoolean("login", "randomcharacters", LOGINRANDCHARACTERS);
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT); SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1"); SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1");
PLAYERDISTANCE = reader.GetInteger("shard", "playerdistance", PLAYERDISTANCE); PLAYERDISTANCE = reader.GetInteger("shard", "playerdistance", PLAYERDISTANCE);
@ -48,7 +46,7 @@ void settings::init() {
SPAWN_X = reader.GetInteger("shard", "spawnx", SPAWN_X); SPAWN_X = reader.GetInteger("shard", "spawnx", SPAWN_X);
SPAWN_Y = reader.GetInteger("shard", "spawny", SPAWN_Y); SPAWN_Y = reader.GetInteger("shard", "spawny", SPAWN_Y);
SPAWN_Z = reader.GetInteger("shard", "spawnz", SPAWN_Z); 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); NPCJSON = reader.Get("shard", "npcdata", NPCJSON);
XDTJSON = reader.Get("shard", "xdtdata", XDTJSON); XDTJSON = reader.Get("shard", "xdtdata", XDTJSON);
MOBJSON = reader.Get("shard", "mobdata", MOBJSON); MOBJSON = reader.Get("shard", "mobdata", MOBJSON);

View File

@ -12,11 +12,11 @@ namespace settings {
extern int SPAWN_X; extern int SPAWN_X;
extern int SPAWN_Y; extern int SPAWN_Y;
extern int SPAWN_Z; extern int SPAWN_Z;
extern int SPAWN_ANGLE;
extern std::string MOTDSTRING; extern std::string MOTDSTRING;
extern std::string NPCJSON; extern std::string NPCJSON;
extern std::string XDTJSON; extern std::string XDTJSON;
extern std::string MOBJSON; extern std::string MOBJSON;
extern std::string GMPASS;
extern bool GM; extern bool GM;
void init(); void init();