mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 20:51:29 +00:00
GetAccountIDByChar converted to StringFormat
This commit is contained in:
parent
fa3d8c9720
commit
85895d01eb
@ -660,21 +660,19 @@ the name "name" or zero if no character with that name was found
|
|||||||
Zero will also be returned if there is a database error.
|
Zero will also be returned if there is a database error.
|
||||||
*/
|
*/
|
||||||
uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
|
uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
|
||||||
char *query = nullptr;
|
std::string query = StringFormat("SELECT account_id, id FROM character_ WHERE name='%s'", charname);
|
||||||
|
|
||||||
auto results = QueryDatabase(query, MakeAnyLenString(&query, "SELECT account_id, id FROM character_ WHERE name='%s'", charname));
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
{
|
{
|
||||||
std::cerr << "Error in GetAccountIDByChar query '" << query << "' " << results.ErrorMessage() << std::endl;
|
std::cerr << "Error in GetAccountIDByChar query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||||
safe_delete_array(query);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete_array(query);
|
if (results.RowCount() != 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (results.RowCount() == 1)
|
|
||||||
{
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
|
|
||||||
uint32 accountId = atoi(row[0]);
|
uint32 accountId = atoi(row[0]);
|
||||||
@ -683,9 +681,6 @@ uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
|
|||||||
*oCharID = atoi(row[1]);
|
*oCharID = atoi(row[1]);
|
||||||
|
|
||||||
return accountId;
|
return accountId;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve account_id for a given char_id
|
// Retrieve account_id for a given char_id
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user