Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Bots

Development::Bots Forum for bots.

Reply
 
Thread Tools Display Modes
  #1  
Old 02-16-2013, 02:50 AM
zippzipp
Fire Beetle
 
Join Date: Dec 2012
Posts: 14
Default Fix for #bot delete failing on bots with pets

It seems #bot delete fails if the bot has pets because the BotDelete function in bots.cpp does not delete the foreign keys relationships related to BotPets, BotPetBuffs, and BotPetInventories.

I fixed this:

Code:
Index: bot.cpp
===================================================================
--- bot.cpp	(revision 2506)
+++ bot.cpp	(working copy)
@@ -4249,6 +4250,8 @@
 	if(this->GetBotID() > 0) {
 		char* Query = 0;
 		char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
+		MYSQL_RES* DatasetResult;
+		MYSQL_ROW DataRow;
 
 		// TODO: These queries need to be ran together as a transaction.. ie, if one or more fail then they all will fail to commit to the database.
 
@@ -4258,6 +4261,31 @@
 		else
 			TempCounter++;
 
+		uint32 pet_id;
+		if(database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT BotPetsId FROM botpets WHERE BotId = '%u'", this->GetBotID()), TempErrorMessageBuffer, &DatasetResult)) {
+			while(DataRow = mysql_fetch_row(DatasetResult)) {
+				pet_id= atoi(DataRow[0]);
+			}
+		}
+
+		if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM botpetinventory WHERE BotPetsId = '%u'", pet_id), TempErrorMessageBuffer)) {
+			*errorMessage = std::string(TempErrorMessageBuffer);
+		}
+		else
+			TempCounter++;
+
+		if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM botpetbuffs WHERE BotPetsId = '%u'", pet_id), TempErrorMessageBuffer)) {
+			*errorMessage = std::string(TempErrorMessageBuffer);
+		}
+		else
+			TempCounter++;
+
+		if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM botpets WHERE BotId = '%u'", this->GetBotID()), TempErrorMessageBuffer)) {
+			*errorMessage = std::string(TempErrorMessageBuffer);
+		}
+		else
+			TempCounter++;
+
 		if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM botbuffs WHERE botid = '%u'", this->GetBotID()), TempErrorMessageBuffer)) {
 			*errorMessage = std::string(TempErrorMessageBuffer);
 		}
@@ -4276,7 +4304,7 @@
 		else
 			TempCounter++;
 
-		if(TempCounter == 4)
+		if(TempCounter == 7)
 			Result = true;
 	}
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:32 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3