View Single Post
  #13  
Old 02-20-2013, 10:41 AM
zippzipp
Fire Beetle
 
Join Date: Dec 2012
Posts: 14
Default

Zam

I just confirmed it. Replace your existing Bot::IsBotNameAvailable function with this one. Sorry about the issue before. The problem before was a bug in the code and also the diff i posted. I wish I could update the code in the main post but wont let me.

Code:
bool Bot::IsBotNameAvailable(std::string* errorMessage) {
	bool Result1 = false;
	bool Result2 = 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)
				Result1 = true;

			mysql_free_result(DatasetResult);



			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 ExistingNameCount = 0;

				while(DataRow = mysql_fetch_row(DatasetResult)) {
					ExistingNameCount = atoi(DataRow[0]);
					break;
				}

				if(ExistingNameCount == 0)
					Result2 = true;

				mysql_free_result(DatasetResult);

			}
		}
		safe_delete(Query);
	}

	if(Result1 && Result2)
		return true;
	else
		return false;
}
Reply With Quote