mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-11 11:12:25 +00:00
GetBotIDByBotName converted to QueryDatabase
This commit is contained in:
parent
390dcc9a88
commit
8312a8cf3b
36
zone/bot.cpp
36
zone/bot.cpp
@ -4487,35 +4487,19 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bot::GetBotIDByBotName(std::string botName) {
|
uint32 Bot::GetBotIDByBotName(std::string botName) {
|
||||||
uint32 Result = 0;
|
if(botName.empty())
|
||||||
|
return 0;
|
||||||
|
|
||||||
if(!botName.empty()) {
|
std::string query = StringFormat("SELECT BotID FROM bots WHERE Name = '%s'", botName.c_str());
|
||||||
char* Query = 0;
|
auto results = database.QueryDatabase(query);
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
if(!results.Success())
|
||||||
MYSQL_RES* DatasetResult;
|
return 0;
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
std::string errorMessage;
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT BotID FROM bots WHERE Name = '%s'", botName.c_str()), TempErrorMessageBuffer, &DatasetResult)) {
|
if (results.RowCount() == 0)
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
return 0;
|
||||||
}
|
|
||||||
else {
|
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
|
||||||
Result = atoi(DataRow[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
auto row = results.begin();
|
||||||
}
|
return atoi(row[0]);
|
||||||
|
|
||||||
safe_delete_array(Query);
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
// TODO: Log this error to zone error log
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bot* Bot::LoadBot(uint32 botID, std::string* errorMessage) {
|
Bot* Bot::LoadBot(uint32 botID, std::string* errorMessage) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user