mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-01 05:02:25 +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.
|
// Returns the number of inventory records the bot has in the database.
|
||||||
uint32 Bot::GetBotItemsCount(std::string *errorMessage) {
|
uint32 Bot::GetBotItemsCount(std::string *errorMessage) {
|
||||||
uint32 Result = 0;
|
|
||||||
|
|
||||||
if(this->GetBotID() > 0) {
|
if(this->GetBotID() == 0)
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
return 0;
|
||||||
char* query = 0;
|
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
|
|
||||||
if(database.RunQuery(query, MakeAnyLenString(&query, "SELECT COUNT(*) FROM botinventory WHERE botid=%i", this->GetBotID()), errbuf, &DatasetResult)) {
|
std::string query = StringFormat("SELECT COUNT(*) FROM botinventory WHERE botid = %i", this->GetBotID());
|
||||||
if(mysql_num_rows(DatasetResult) == 1) {
|
auto results = database.QueryDatabase(query);
|
||||||
DataRow = mysql_fetch_row(DatasetResult);
|
if(!results.Success()) {
|
||||||
if(DataRow)
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
Result = atoi(DataRow[0]);
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::MesmerizeTarget(Mob* target) {
|
bool Bot::MesmerizeTarget(Mob* target) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user