mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
CheckStatus converted to StringFormat
This commit is contained in:
parent
d943183994
commit
ddcaf855fe
@ -246,42 +246,37 @@ void Database::LoginIP(uint32 AccountID, const char* LoginIP)
|
|||||||
|
|
||||||
int16 Database::CheckStatus(uint32 account_id)
|
int16 Database::CheckStatus(uint32 account_id)
|
||||||
{
|
{
|
||||||
char *query = nullptr;
|
std::string query = StringFormat("SELECT `status`, UNIX_TIMESTAMP(`suspendeduntil`) as `suspendeduntil`, UNIX_TIMESTAMP() as `current`"
|
||||||
|
" FROM `account` WHERE `id` = %i", account_id);
|
||||||
|
|
||||||
auto results = QueryDatabase(query, MakeAnyLenString(&query, "SELECT `status`, UNIX_TIMESTAMP(`suspendeduntil`) as `suspendeduntil`, UNIX_TIMESTAMP() as `current`"
|
auto results = QueryDatabase(query);
|
||||||
" FROM `account` WHERE `id` = %i", account_id));
|
|
||||||
|
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
{
|
{
|
||||||
std::cerr << "Error in CheckStatus query '" << query << "' " << results.ErrorMessage() << std::endl;
|
std::cerr << "Error in CheckStatus query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||||
safe_delete_array(query);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete_array(query);
|
if (results.RowCount() != 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
|
||||||
if (results.RowCount() == 1)
|
int16 status = atoi(row[0]);
|
||||||
{
|
|
||||||
auto row = results.begin();
|
|
||||||
|
|
||||||
int16 status = atoi(row[0]);
|
int32 suspendeduntil = 0;
|
||||||
|
|
||||||
int32 suspendeduntil = 0;
|
// MariaDB initalizes with NULL if unix_timestamp() is out of range
|
||||||
|
if (row[1] != nullptr) {
|
||||||
// MariaDB initalizes with NULL if unix_timestamp() is out of range
|
suspendeduntil = atoi(row[1]);
|
||||||
if (row[1] != nullptr) {
|
|
||||||
suspendeduntil = atoi(row[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 current = atoi(row[2]);
|
|
||||||
|
|
||||||
if(suspendeduntil > current)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
int32 current = atoi(row[2]);
|
||||||
|
|
||||||
|
if(suspendeduntil > current)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Database::CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id) {
|
uint32 Database::CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user