View Single Post
  #2  
Old 06-19-2011, 08:54 AM
Leere
Sarnak
 
Join Date: Sep 2008
Location: Home
Posts: 31
Default

Another try to get the diff to post without the tab to space conversion. Sorry about any inconvenience.

Code:
Index: client_packet.cpp
===================================================================
--- client_packet.cpp	(revision 1944)
+++ client_packet.cpp	(working copy)
@@ -2228,7 +2228,7 @@
 	//^Item Name,Item ID,Cost in Points,Theme (0=none),0,1,races bit map,classes bitmap
 	EQApplicationPacket* outapp = new EQApplicationPacket(OP_AdventureMerchantResponse,ss.str().size()+2);
 	outapp->pBuffer[0] = count;
-	strn0cpy((char*)&outapp->pBuffer[1],ss.str().c_str(),ss.str().size());
+	strn0cpy((char*)&outapp->pBuffer[1],ss.str().c_str(),ss.str().size()+1);
 	FastQueuePacket(&outapp);
 }
sql based duplicate elimination
Code:
Index: zone.cpp
===================================================================
--- zone.cpp	(revision 1944)
+++ zone.cpp	(working copy)
@@ -578,7 +578,7 @@
 		"from merchantlist ml, npc_types nt, spawnentry se, spawn2 s2 "
 		"where nt.merchant_id=ml.merchantid and nt.id=se.npcid "
 		"and se.spawngroupid=s2.spawngroupid and s2.zone='%s' and s2.version=%u "
-		//"group by ml.merchantid,slot order by merchantid,slot asc"		//this made the query use a temp table/filesort (very slow)... so we handle unsorted data on our end.
+		"group by ml.merchantid, ml.slot"
 		, GetShortName(), GetInstanceVersion()));
 	if (!(pQueuedMerchantsWorkID = dbasync->AddWork(&dbaw))) {
 		safe_delete(dbaw);
code based duplicate search
Code:
Index: zone.cpp
===================================================================
--- zone.cpp	(revision 1944)
+++ zone.cpp	(working copy)
@@ -544,6 +544,8 @@
 void Zone::LoadMerchantData_result(MYSQL_RES* result) {
 	MYSQL_ROW row;
 	std::map<uint32,std::list<MerchantList> >::iterator cur;
+	std::list<MerchantList>::iterator dupes;
+	bool found;
 	int32 npcid = 0;
 	while((row = mysql_fetch_row(result))) {
 		MerchantList ml;
@@ -559,7 +561,17 @@
 		}
 		ml.slot = atoul(row[1]);
 		ml.item = atoul(row[2]);
-		cur->second.push_back(ml);
+		// Need to check for duplicate entries since we get the merchantlist
+		// repeated for every npc in the zone that uses it.
+		found = false;
+		for (dupes = cur->second.begin(); dupes != cur->second.end() && !found; dupes++) {
+			MerchantList mertemp = *dupes;
+			if (mertemp.slot == ml.slot && mertemp.item == ml.item) {
+				found = true;
+			}
+		}
+		if (!found)
+			cur->second.push_back(ml);
 	}
 	//mysql_free_result(result);
 //	LogFile->write(EQEMuLog::Status, "Finished Loading Merchant Lists...");
Reply With Quote