View Single Post
  #4  
Old 05-22-2007, 05:49 AM
Darkonig
Hill Giant
 
Join Date: Dec 2006
Posts: 102
Default

Code:
858c792
< bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint8 tradeskill, 
---
> bool ZoneDatabase::GetTradeRecipe(const ItemInst* container, uint8 c_type, uint32 some_id, 
872,881c806,813
< 	//use the world item type as type if we have a world item
< 	//otherwise use the item's ID... this make the assumption that
< 	//no tradeskill containers will have an item ID which is
< 	//below the highest ID of objects, which is currently 0x30
< 	uint32 type = c_type;
< 	
< 	//dunno why I have to cast this up to call GetItem
< 	const Item_Struct *istruct = ((const ItemInst *) container)->GetItem();
< 	if(c_type == 0 && istruct) {
< 		type = istruct->ID;
---
> 	// make where clause segment for container(s)
> 	char containers[30];
> 	if (some_id == 0) {
> 		// world combiner so no item number
> 		snprintf(containers,29, "= %u", c_type);
> 	} else {
> 		// container in inventory
> 		snprintf(containers,29, "in (%u,%u)", c_type, some_id);
913,916d844
< 	//add in the container.
< 	count++;
< 	sum += type;
< 	
920,922c848,850
< 	"  OR ( tre.item_id=%u AND tre.iscontainer=1 )"
< 	" GROUP BY tre.recipe_id HAVING sum(tre.componentcount+tre.iscontainer) = %u"
< 	"  AND sum(tre.item_id * (tre.componentcount+tre.iscontainer)) = %u", buf2, type, count, sum);
---
> 	"  OR ( tre.item_id %s AND tre.iscontainer=1 )"
> 	" GROUP BY tre.recipe_id HAVING sum(tre.componentcount) = %u"
> 	"  AND sum(tre.item_id * tre.componentcount) = %u", buf2, containers, count, sum);
925c853
< 		LogFile->write(EQEMuLog::Error, "Error in GetTradeRecept search, query: %s", query);
---
> 		LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe search, query: %s", query);
927c855
< 		LogFile->write(EQEMuLog::Error, "Error in GetTradeRecept search, error: %s", errbuf);
---
> 		LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe search, error: %s", errbuf);
956,959c884,886
< 		" WHERE tre.recipe_id IN (%s) "
< 		"       AND (tre.iscontainer=0 OR tre.item_id=%u) "
< 		" GROUP BY tre.recipe_id HAVING sum(tre.componentcount+tre.iscontainer) = %u"
< 		" AND sum(tre.item_id * (tre.componentcount+tre.iscontainer)) = %u", buf2, type, count, sum);
---
> 		" WHERE tre.recipe_id IN (%s)"
> 		" GROUP BY tre.recipe_id HAVING sum(tre.componentcount) = %u"
> 		"  AND sum(tre.item_id * tre.componentcount) = %u", buf2, count, sum);
962c889
< 			LogFile->write(EQEMuLog::Error, "Error in GetTradeRecept, re-query: %s", query);
---
> 			LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, re-query: %s", query);
964c891
< 			LogFile->write(EQEMuLog::Error, "Error in GetTradeRecept, error: %s", errbuf);
---
> 			LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, error: %s", errbuf);
1018c945
< 	return(GetTradeRecipe(recipe_id, c_type, tradeskill, spec));
---
> 	return(GetTradeRecipe(recipe_id, c_type, some_id, spec));
1023c950
< bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint8 tradeskill, 
---
> bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id, 
1034,1036c961,976
< 	qlen = MakeAnyLenString(&query, "SELECT tr.skillneeded, tr.trivial, tr.nofail, tr.replace_container"
< 	" FROM tradeskill_recipe AS tr"
< 	" WHERE tr.id = %lu AND tr.tradeskill = %u", recipe_id, tradeskill);
---
> 	// make where clause segment for container(s)
> 	char containers[30];
> 	if (some_id == 0) {
> 		// world combiner so no item number
> 		snprintf(containers,29, "= %u", c_type);
> 	} else {
> 		// container in inventory
> 		snprintf(containers,29, "in (%u,%u)", c_type, some_id);
> 	}
> 	
> 	qlen = MakeAnyLenString(&query, "SELECT tr.id, tr.tradeskill, tr.skillneeded,"
> 	" tr.trivial, tr.nofail, tr.replace_container"
> 	" FROM tradeskill_recipe AS tr inner join tradeskill_recipe_entries as tre"
> 	" ON tr.id = tre.recipe_id"
> 	" WHERE tr.id = %lu AND tre.item_id %s"
> 	" GROUP BY tr.id", recipe_id, containers);
1039c979
< 		LogFile->write(EQEMuLog::Error, "Error in GetTradeRecept, query: %s", query);
---
> 		LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, query: %s", query);
1041c981
< 		LogFile->write(EQEMuLog::Error, "Error in GetTradeRecept, error: %s", errbuf);
---
> 		LogFile->write(EQEMuLog::Error, "Error in GetTradeRecipe, error: %s", errbuf);
1053,1056c993,997
< 	spec->skill_needed		= (sint16)atoi(row[0]);
< 	spec->trivial			= (uint16)atoi(row[1]);
< 	spec->nofail			= atoi(row[2]) ? true : false;
< 	spec->replace_container	= atoi(row[3]) ? true : false;
---
> 	spec->tradeskill			= (SkillType)atoi(row[1]);
> 	spec->skill_needed		= (sint16)atoi(row[2]);
> 	spec->trivial			= (uint16)atoi(row[3]);
> 	spec->nofail			= atoi(row[4]) ? true : false;
> 	spec->replace_container	= atoi(row[5]) ? true : false;
Reply With Quote