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

@ -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<DbPlayer>(where(c(&DbPlayer::PlayerID) == characterID));
int slot = find.front().slot;
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;
}
@ -418,8 +413,10 @@ void Database::updateNanos(Player player) {
where(c(&Nano::playerId) == player.iID)
);
//insert
int i = 1;
while ((i<SIZEOF_NANO_BANK_SLOT)&&(player.Nanos[i]).iID!=0){
for (int i=1; i < SIZEOF_NANO_BANK_SLOT; i++)
{
if ((player.Nanos[i]).iID == 0)
continue;
Nano toAdd = {};
sNano* next = &player.Nanos[i];
toAdd.playerId = player.iID;
@ -427,7 +424,6 @@ void Database::updateNanos(Player player) {
toAdd.iSkillID = next->iSkillID;
toAdd.iStamina = next->iStamina;
db.insert(toAdd);
i++;
}
db.commit();
}

View File

@ -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);

View File

@ -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();