mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-17 22:12:24 +00:00
GetBotItemsCount converted to QueryDatabase
This commit is contained in:
parent
cd1b45f0d6
commit
390dcc9a88
32
zone/bot.cpp
32
zone/bot.cpp
@ -4279,30 +4279,22 @@ uint32 Bot::GetBotItemBySlot(uint32 slotID) {
|
||||
|
||||
// Returns the number of inventory records the bot has in the database.
|
||||
uint32 Bot::GetBotItemsCount(std::string *errorMessage) {
|
||||
uint32 Result = 0;
|
||||
|
||||
if(this->GetBotID() > 0) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char* query = 0;
|
||||
MYSQL_RES* DatasetResult;
|
||||
MYSQL_ROW DataRow;
|
||||
if(this->GetBotID() == 0)
|
||||
return 0;
|
||||
|
||||
if(database.RunQuery(query, MakeAnyLenString(&query, "SELECT COUNT(*) FROM botinventory WHERE botid=%i", this->GetBotID()), errbuf, &DatasetResult)) {
|
||||
if(mysql_num_rows(DatasetResult) == 1) {
|
||||
DataRow = mysql_fetch_row(DatasetResult);
|
||||
if(DataRow)
|
||||
Result = atoi(DataRow[0]);
|
||||
}
|
||||
std::string query = StringFormat("SELECT COUNT(*) FROM botinventory WHERE botid = %i", this->GetBotID());
|
||||
auto results = database.QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
*errorMessage = std::string(results.ErrorMessage());
|
||||
return 0;
|
||||
}
|
||||
|
||||
mysql_free_result(DatasetResult);
|
||||
}
|
||||
else
|
||||
*errorMessage = std::string(errbuf);
|
||||
if(results.RowCount() != 1)
|
||||
return 0;
|
||||
|
||||
safe_delete_array(query);
|
||||
}
|
||||
|
||||
return Result;
|
||||
auto row = results.begin();
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
bool Bot::MesmerizeTarget(Mob* target) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user