View Single Post
  #1  
Old 02-16-2013, 06:39 PM
zippzipp
Fire Beetle
 
Join Date: Dec 2012
Posts: 14
Default Fix for #bot create when same named PC exists

Hello all. I found that when you create a bot that has the same name as an existing player it bugs both the player and the bot out like crazy. I added a check against the character_ table in the database to make sure a player does not already exist with the target name.

Code:
Index: bot.cpp
===================================================================
--- bot.cpp	(revision 2506)
+++ bot.cpp	(working copy)
@@ -2370,6 +2370,26 @@
 				Result = 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)
+					Result = true;
+
+				mysql_free_result(DatasetResult);
+
+			}
 		}
 
 		safe_delete(Query);
Reply With Quote