Your check seems to first check the Bot names... if there is no bot name... it sets
Result = True
Then it checks players .. if the player DOES exist it doesn't set the result back to false.
Code:
bool Bot::IsBotNameAvailable(std::string* errorMessage) {
bool Result = false;
bool ResultBot = false;
bool ResultPlayer = false;
if(this->GetCleanName()) {
char* Query = 0;
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)) {
*errorMessage = std::string(TempErrorMessageBuffer);
}
else {
uint32 ExistingNameCount = 0;
while(DataRow = mysql_fetch_row(DatasetResult)) {
ExistingNameCount = atoi(DataRow[0]);
break;
}
if(ExistingNameCount == 0)
ResultBot = true;
mysql_free_result(DatasetResult);
}
safe_delete(Query);
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT COUNT(id) FROM character_ WHERE name LIKE '%s'", this->GetCleanName()), TempErrorMessageBuffer, &DatasetResult)) {
*errorMessage = std::string(TempErrorMessageBuffer);
}
else {
uint32 ExistingNameCountPlayer = 0;
while(DataRow = mysql_fetch_row(DatasetResult)) {
ExistingNameCountPlayer = atoi(DataRow[0]);
break;
}
if(ExistingNameCountPlayer == 0)
ResultPlayer = true;
mysql_free_result(DatasetResult);
}
safe_delete(Query);
if(ResultPlayer == true && ResultBot == true) {
Result = true;
}
}
return Result;
}
I do not have a bots compile to test this on... but this might be a fix? Not 100% on that one just yet