GetBotOwnerCharacterID converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-09-03 18:24:30 -07:00
parent 2429980fd5
commit 081192d29e

View File

@ -4935,29 +4935,22 @@ uint32 Bot::CreatedBotCount(uint32 botOwnerCharacterID, std::string* errorMessag
} }
uint32 Bot::GetBotOwnerCharacterID(uint32 botID, std::string* errorMessage) { uint32 Bot::GetBotOwnerCharacterID(uint32 botID, std::string* errorMessage) {
uint32 Result = 0;
if(botID > 0) { if(botID == 0)
char ErrBuf[MYSQL_ERRMSG_SIZE]; return 0;
char* Query = 0;
MYSQL_RES* DatasetResult;
MYSQL_ROW DataRow;
if(database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT BotOwnerCharacterID FROM bots WHERE BotID = %u", botID), ErrBuf, &DatasetResult)) { std::string query = StringFormat("SELECT BotOwnerCharacterID FROM bots WHERE BotID = %u", botID);
if(mysql_num_rows(DatasetResult) == 1) { auto results = database.QueryDatabase(query);
if(DataRow = mysql_fetch_row(DatasetResult)) if (results.Success()) {
Result = atoi(DataRow[0]); *errorMessage = std::string(results.ErrorMessage());
} return 0;
}
mysql_free_result(DatasetResult); if (results.RowCount() != 1)
} return 0;
else
*errorMessage = std::string(ErrBuf);
safe_delete_array(Query); auto row = results.begin();
} return atoi(row[0]);
return Result;
} }
void Bot::LevelBotWithClient(Client* client, uint8 level, bool sendlvlapp) { void Bot::LevelBotWithClient(Client* client, uint8 level, bool sendlvlapp) {