Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 

Thread Tools
Display Modes

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 10:11 PM.


 

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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3