Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Bug Reports

Development::Bug Reports Post detailed bug reports and what you would like to see next in the emu here.

Reply
 
Thread Tools Display Modes
  #1  
Old 12-26-2006, 02:01 PM
Aerewen
Hill Giant
 
Join Date: Dec 2006
Posts: 110
Default Merchants not keeping items...

I'm still looking into the code for this merchant issue where they don't keep items sold to them regardless of the variable setting...

can't seem to find anything on it at all.

someone had said that when items were sold to an npc they simply got added to the npc's loot table and then that loot table was added to the item list when browsed...

i dont see any references in the source code to the merchantlist_temp table that exists, nor do i ever see any rows inserted into it...

i thought this table was here specificly for saving items sold to merchants, but it seems like the table isnt even used...
Reply With Quote
  #2  
Old 12-26-2006, 02:22 PM
Aerewen
Hill Giant
 
Join Date: Dec 2006
Posts: 110
Default

think i found the problem:

Code:
From: zone.cpp
==============================
void Zone::LoadTempMerchantData(){
	LogFile->write(EQEMuLog::Status, "Loading Temporary Merchant Lists...");

	char* query = 0;
	uint32_breakdown workpt;
	workpt.b4() = DBA_b4_Zone;
	workpt.w2_3() = 0;
	workpt.b1() = DBA_b1_Zone_MerchantListsTemp;
	DBAsyncWork* dbaw = new DBAsyncWork(&database, &MTdbafq, workpt, DBAsync::Read);
	dbaw->AddQuery(1, &query, MakeAnyLenString(&query, 
		"select ml.npcid,ml.slot,ml.itemid,ml.charges from "
		"merchantlist_temp ml, npc_types nt, spawnentry se, "
		"spawn2 s2 where nt.id=ml.npcid and nt.id=se.npcid and "
		"se.spawngroupid=s2.spawngroupid and s2.zone='%s' "
		"group by ml.npcid,slot order by npcid,slot asc", GetShortName()));
	if (!(pQueuedMerchantsWorkID = dbasync->AddWork(&dbaw))) {
		safe_delete(dbaw);
		LogFile->write(EQEMuLog::Error, "dbasync->AddWork() failed adding merchant list query");
		return;
	}
the zone loads the temp merchant list from the database when the zone is started.

and the zone stores the temporary items like this:
Code:
From: zone.h
======================
map<uint32,std::list<TempMerchantList> > tmpmerchanttable;
which gets the list when the zone is started, but is not updated with the new items from the function below...

however... when an item is sold to the merchant it is added to the database...
Code:
From: zonedb.cpp
===========================
void ZoneDatabase::SaveMerchantTemp(int32 npcid, int32 slot, int32 item, int32 charges){
	char errbuf[MYSQL_ERRMSG_SIZE];
    char *query = 0;

	if (!RunQuery(query, MakeAnyLenString(&query, "replace into merchantlist_temp (npcid,slot,itemid,charges) values(%d,%d,%d,%d)", npcid, slot, item, charges), errbuf)) {
		cerr << "Error in SaveMerchantTemp query '" << query << "' " << errbuf << endl;
	}
	safe_delete_array(query);	
}
so it seems the temporary lists are being stored in a list variable in each instance of zone.exe, but the selling of an item to a merchant is being stored in the database only... i intend to do some database testing to see if in-fact rows are being inserted into the database when items are sold. i would attempt to manually insert items into the temp list... but the problem is that everything is cleared from it when the zone boots, and since my theory is that the items are loaded at zone boot... well lol there's no way to check it.

i'll be honest... i can mostly read and understand c++ but i'll be damned if i can write it very well... think of me as someone who took intro to french in high school... who is now trying to edit a french novel lol

i can look through and find the problems, but i've not the slightest idea how to correct the grammatical errors in it :p

Last edited by Aerewen; 12-26-2006 at 10:36 PM..
Reply With Quote
  #3  
Old 12-27-2006, 05:41 AM
John Adams
Demi-God
 
Join Date: Jul 2006
Posts: 1,552
Default

Quote:
Originally Posted by Aerewen
but the problem is that everything is cleared from it when the zone boots, and since my theory is that the items are loaded at zone boot... well lol there's no way to check it.
Have you tried making the merchants zone Static, so when you leave, it does not shut down? Maybe that'll help preserve the state of the merchant when you are testing.


edit: Verified bug. Just tested this with a merchant I stuck in the guild hall. You are correct. I sold it a vial of dye, closed the window, reopened, and the vial was gone. Zoned out (dynamic zone) and back in, no sold items on merchant.

However, the item IS in the merchantlist_temp table for this NPCid, slot, and item # (32557)

Last edited by John Adams; 12-27-2006 at 01:57 PM..
Reply With Quote
  #4  
Old 12-27-2006, 10:47 AM
Aerewen
Hill Giant
 
Join Date: Dec 2006
Posts: 110
Default

yes i have just tested it myself and exactly what i said is what is happening.

When the world boots up it clears the entire merchantlist_temp table. Then loads the merchantlists from the merchantlist table and sets them into an array in the zone.exe file.

When items are sold to the vendor they are inserted into the merchantlist_temp table, but not into the array.

I posted the sections of code where the problem comes from, now if someone else could do us all a favor and fix it... lol cuz i've about exhausted my knowledge of c++ in just finding the issue :p
Reply With Quote
  #5  
Old 12-28-2006, 08:30 PM
Aerewen
Hill Giant
 
Join Date: Dec 2006
Posts: 110
Default

After looking at this code i think we have a slightly larger problem on our hands...

The merchantlist information is being stored in an array... which means that presently, whenever a player accesses a merchant, that data comes out of the array and has nothing to do with the database. So we actually don't need to change anything with the way merchants handle items sold to them, instead what needs to happen is that the zone should only load the items in the merchantlist table at startup since they don't change. Then we need to modify the code for the function when a player accesses that merchant, and have it load the values from the merchantlist_temp table into the file...

where this causes a problem is what happens when 2 players access the same merchant at the same time. if a merchant had 1 discordant scoriae on it... and 2 players accessed the merchant at the same time, they could both buy that item since the temp list would only be loaded at the time of browsing... thus creating a method of item duplication.
Reply With Quote
  #6  
Old 12-29-2006, 02:03 AM
John Adams
Demi-God
 
Join Date: Jul 2006
Posts: 1,552
Default

I'm back at work! /argue on! j/k

If I can get on Live tonight, I will sell something to a vendor, and have 2 PCs open the same vendor and see what happens if they both try and buy the item. Something in the back of my mind tells me the merchant inventory list is dynamically updated live... but I could be dreaming.
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 09:58 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