Multiple login account support initial, needs a ton of work but can login and create account

This commit is contained in:
KimLS
2017-11-14 21:42:14 -08:00
parent da163be8db
commit 6b70faf141
18 changed files with 198 additions and 359 deletions
+1
View File
@@ -1405,6 +1405,7 @@ private:
uint32 WID;
uint32 account_id;
char account_name[30];
char loginserver[64];
uint32 lsaccountid;
char lskey[30];
int16 admin;
+8 -7
View File
@@ -1283,16 +1283,17 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
database.LoadCharacterFactionValues(cid, factionvalues);
/* Load Character Account Data: Temp until I move */
query = StringFormat("SELECT `status`, `name`, `lsaccount_id`, `gmspeed`, `revoked`, `hideme`, `time_creation` FROM `account` WHERE `id` = %u", this->AccountID());
query = StringFormat("SELECT `status`, `name`, `ls_id`, `lsaccount_id`, `gmspeed`, `revoked`, `hideme`, `time_creation` FROM `account` WHERE `id` = %u", this->AccountID());
auto results = database.QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
admin = atoi(row[0]);
strncpy(account_name, row[1], 30);
lsaccountid = atoi(row[2]);
gmspeed = atoi(row[3]);
revoked = atoi(row[4]);
gm_hide_me = atoi(row[5]);
account_creation = atoul(row[6]);
strn0cpy(account_name, row[1], sizeof(account_name));
strn0cpy(loginserver, row[2], sizeof(loginserver));
lsaccountid = atoi(row[3]);
gmspeed = atoi(row[4]);
revoked = atoi(row[5]);
gm_hide_me = atoi(row[6]);
account_creation = atoul(row[7]);
}
/* Load Character Data */
+59 -56
View File
@@ -1957,31 +1957,33 @@ void command_shutdown(Client *c, const Seperator *sep)
void command_delacct(Client *c, const Seperator *sep)
{
if(sep->arg[1][0] == 0)
c->Message(0, "Format: #delacct accountname");
else
if (database.DeleteAccount(sep->arg[1]))
c->Message(0, "The account was deleted.");
else
c->Message(0, "Unable to delete account.");
//TODO: REIMPLEMENT
// if(sep->arg[1][0] == 0)
// c->Message(0, "Format: #delacct accountname");
// else
// if (database.DeleteAccount(sep->arg[1]))
// c->Message(0, "The account was deleted.");
// else
// c->Message(0, "Unable to delete account.");
}
void command_setpass(Client *c, const Seperator *sep)
{
if(sep->argnum != 2)
c->Message(0, "Format: #setpass accountname password");
else {
int16 tmpstatus = 0;
uint32 tmpid = database.GetAccountIDByName(sep->arg[1], &tmpstatus);
if (!tmpid)
c->Message(0, "Error: Account not found");
else if (tmpstatus > c->Admin())
c->Message(0, "Cannot change password: Account's status is higher than yours");
else if (database.SetLocalPassword(tmpid, sep->arg[2]))
c->Message(0, "Password changed.");
else
c->Message(0, "Error changing password.");
}
//TODO: REIMPLEMENT
//if(sep->argnum != 2)
// c->Message(0, "Format: #setpass accountname password");
//else {
// int16 tmpstatus = 0;
// uint32 tmpid = database.GetAccountIDByName(sep->arg[1], &tmpstatus);
// if (!tmpid)
// c->Message(0, "Error: Account not found");
// else if (tmpstatus > c->Admin())
// c->Message(0, "Cannot change password: Account's status is higher than yours");
// else if (database.SetLocalPassword(tmpid, sep->arg[2]))
// c->Message(0, "Password changed.");
// else
// c->Message(0, "Error changing password.");
//}
}
void command_setlsinfo(Client *c, const Seperator *sep)
@@ -4414,41 +4416,42 @@ void command_uptime(Client *c, const Seperator *sep)
void command_flag(Client *c, const Seperator *sep)
{
if(sep->arg[2][0] == 0) {
if (!c->GetTarget() || (c->GetTarget() && c->GetTarget() == c)) {
c->UpdateAdmin();
c->Message(0, "Refreshed your admin flag from DB.");
} else if (c->GetTarget() && c->GetTarget() != c && c->GetTarget()->IsClient()) {
c->GetTarget()->CastToClient()->UpdateAdmin();
c->Message(0, "%s's admin flag has been refreshed.", c->GetTarget()->GetName());
c->GetTarget()->Message(0, "%s refreshed your admin flag.", c->GetName());
}
}
else if (!sep->IsNumber(1) || atoi(sep->arg[1]) < -2 || atoi(sep->arg[1]) > 255 || strlen(sep->arg[2]) == 0)
c->Message(0, "Usage: #flag [status] [acctname]");
else if (c->Admin() < commandChangeFlags) {
//this check makes banning players by less than this level
//impossible, but i'll leave it in anyways
c->Message(0, "You may only refresh your own flag, doing so now.");
c->UpdateAdmin();
}
else {
if (atoi(sep->arg[1]) > c->Admin())
c->Message(0, "You cannot set people's status to higher than your own");
else if (atoi(sep->arg[1]) < 0 && c->Admin() < commandBanPlayers)
c->Message(0, "You have too low of status to suspend/ban");
else if (!database.SetAccountStatus(sep->argplus[2], atoi(sep->arg[1])))
c->Message(0, "Unable to set GM Flag.");
else {
c->Message(0, "Set GM Flag on account.");
auto pack = new ServerPacket(ServerOP_FlagUpdate, 6);
*((uint32*) pack->pBuffer) = database.GetAccountIDByName(sep->argplus[2]);
*((int16*) &pack->pBuffer[4]) = atoi(sep->arg[1]);
worldserver.SendPacket(pack);
delete pack;
}
}
//TODO: REIMPLEMENT
// if(sep->arg[2][0] == 0) {
// if (!c->GetTarget() || (c->GetTarget() && c->GetTarget() == c)) {
// c->UpdateAdmin();
// c->Message(0, "Refreshed your admin flag from DB.");
// } else if (c->GetTarget() && c->GetTarget() != c && c->GetTarget()->IsClient()) {
// c->GetTarget()->CastToClient()->UpdateAdmin();
// c->Message(0, "%s's admin flag has been refreshed.", c->GetTarget()->GetName());
// c->GetTarget()->Message(0, "%s refreshed your admin flag.", c->GetName());
// }
// }
// else if (!sep->IsNumber(1) || atoi(sep->arg[1]) < -2 || atoi(sep->arg[1]) > 255 || strlen(sep->arg[2]) == 0)
// c->Message(0, "Usage: #flag [status] [acctname]");
//
// else if (c->Admin() < commandChangeFlags) {
////this check makes banning players by less than this level
////impossible, but i'll leave it in anyways
// c->Message(0, "You may only refresh your own flag, doing so now.");
// c->UpdateAdmin();
// }
// else {
// if (atoi(sep->arg[1]) > c->Admin())
// c->Message(0, "You cannot set people's status to higher than your own");
// else if (atoi(sep->arg[1]) < 0 && c->Admin() < commandBanPlayers)
// c->Message(0, "You have too low of status to suspend/ban");
// else if (!database.SetAccountStatus(sep->argplus[2], atoi(sep->arg[1])))
// c->Message(0, "Unable to set GM Flag.");
// else {
// c->Message(0, "Set GM Flag on account.");
// auto pack = new ServerPacket(ServerOP_FlagUpdate, 6);
// *((uint32*) pack->pBuffer) = database.GetAccountIDByName(sep->argplus[2]);
// *((int16*) &pack->pBuffer[4]) = atoi(sep->arg[1]);
// worldserver.SendPacket(pack);
// delete pack;
// }
// }
}
void command_time(Client *c, const Seperator *sep)