View Single Post
  #11  
Old 07-23-2011, 05:23 PM
lerxst2112
Demi-God
 
Join Date: Aug 2010
Posts: 1,743
Default

Two small tweaks to this.

The color is unsigned in the database so I changed the query to write it as such.

The check for the proper parameters was after all of the parsing where it should have been before it.

Code:
Index: trunk/EQEmuServer/zone/bot.cpp
===================================================================
--- trunk/EQEmuServer/zone/bot.cpp	(revision 1981)
+++ trunk/EQEmuServer/zone/bot.cpp	(working copy)
@@ -10142,13 +10142,15 @@
 	//bot armor colors
 	if(!strcasecmp(sep->arg[1], "armorcolor")) {
 		if(c->GetTarget() && c->GetTarget()->IsBot() && (c->GetTarget()->CastToBot()->GetBotOwner() == c)) {
+
+			if(sep->arg[2][0] == '\0' || sep->arg[3][0] == '\0' || sep->arg[4][0] == '\0' || sep->arg[5][0] == '\0') {
+				c->Message(0, "Usage: #bot armorcolor [slot] [red] [green] [blue] - use #bot help armorcolor for info");
+				return;
+			}
+
 			uint32 botid = c->GetTarget()->CastToBot()->GetBotID();
 			std::string errorMessage;
 			char* Query = 0;
-			//if(sep->argnum < 6) {
-			//	c->Message(0, "Usage: #bot armorcolor [slot] [red] [green] [blue] - use #bot help armorcolor for info");
-			//	return;
-			//}
 
 			int setslot = atoi(sep->arg[2]);
 			uint8 red = atoi(sep->arg[3]);
@@ -10156,22 +10158,14 @@
 			uint8 blue = atoi(sep->arg[5]);
 			uint32 setcolor = (red << 16) | (green << 8) | blue;
 
-			if(sep->arg[2][0] == '\0' || sep->arg[3][0] == '\0' || sep->arg[4][0] == '\0' || sep->arg[5][0] == '\0') {
-				c->Message(0, "Usage: #bot armorcolor [slot] [red] [green] [blue] - use #bot help armorcolor for info");
-				return;
+			if(database.RunQuery(Query, MakeAnyLenString(&Query, "UPDATE botinventory SET color = %u WHERE slotID = %i AND botID = %u",setcolor, setslot, botid))){
+				int slotmaterial = Inventory::CalcMaterialFromSlot(setslot);
+				c->GetTarget()->CastToBot()->SendWearChange(slotmaterial);
 			}
-			else{
-				if(database.RunQuery(Query, MakeAnyLenString(&Query, "UPDATE botinventory SET color = %i WHERE slotID = %i AND botID = %u",setcolor, setslot, botid))){
-					int slotmaterial = Inventory::CalcMaterialFromSlot(setslot);
-					c->GetTarget()->CastToBot()->SendWearChange(slotmaterial);
-				}
-			}
-			
 		}
 		else {
 			c->Message(15, "You must target a bot you own to do this.");
 		}
-
 		return;
 	}
 	// Help for coloring bot armor
Reply With Quote