mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
IsBotNameValid converted to QueryDatabase
This commit is contained in:
parent
118c2a9db9
commit
9eb3907d45
36
zone/bot.cpp
36
zone/bot.cpp
@ -2339,35 +2339,29 @@ bool Bot::IsValidName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::IsBotNameAvailable(std::string* errorMessage) {
|
bool Bot::IsBotNameAvailable(std::string* errorMessage) {
|
||||||
bool Result = false;
|
|
||||||
|
|
||||||
if(this->GetCleanName()) {
|
if(!this->GetCleanName())
|
||||||
char* Query = 0;
|
return false;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT COUNT(id) FROM vwBotCharacterMobs WHERE name LIKE '%s'", this->GetCleanName()), TempErrorMessageBuffer, &DatasetResult)) {
|
std::string query = StringFormat("SELECT COUNT(id) FROM vwBotCharacterMobs "
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
"WHERE name LIKE '%s'", this->GetCleanName());
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
if(!results.Success()) {
|
||||||
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
uint32 ExistingNameCount = 0;
|
|
||||||
|
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
uint32 existingNameCount = 0;
|
||||||
ExistingNameCount = atoi(DataRow[0]);
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
existingNameCount = atoi(row[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ExistingNameCount == 0)
|
if(existingNameCount != 0)
|
||||||
Result = true;
|
return false;
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
safe_delete(Query);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::Save() {
|
bool Bot::Save() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user