Jump to content

[Patch] Ordered list for vendors


Recommended Posts

Posted

Hi,

I use mangos since 3 years now, and I always noticed that vendors have the items sorted randomly.

So, what does it mean ?

On off, you can see ie for a poison vendor: Mortal poison, Mortal poison II, Mortal poison III, Mortal poison IV ... etc. All sorted.

In mangos ... =D We have not "Order by" in the sql request, so we can see Mortal poison II, Instant poison IV, Mortal poison IX ... etc. (this is an exemple, i don't remember how it is with UDB )

So i made this patch which allow custom order in vendors lists.

This is not really "usefull" but i am always bored about search a specific poison, or other item (ie emblems of conquest, item sets must be at the end of the list) in those lists, and i think ordored ones could be fine.

Tested on my local server, you can choose order while adding items, or with a new command : .npc moveitem <itemid/link> [<int>] (if not given, sortOrder = 0)

(slot 0 is first and default slot)

Here is the updated patch without nester query (need test) : [DOWNLOAD LINK][PASTEBIN LINK]

Apply this to your database if you want to have correct text when using command:

INSERT INTO `mangos_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) VALUES
(10000, 'Item ''%i'' ''%s'' moved in vendor list to place %i', NULL, 'Equipement ''%i'' ''%s'' déplacé dans la liste du vendeur à la place %i.', NULL, NULL, NULL, NULL, NULL, NULL);

And this ... if you want this patch to work =D

ALTER  TABLE  `npc_vendor`  ADD  `sortOrder` TINYINT( 3  )  UNSIGNED NOT  NULL DEFAULT  '0';

Posted

Sounds like a great idea to me, Siegels! This would make shopping from vendors a lot less confusing.

I hope this will make into the "Under Review" section for consideration, so long as it's not considered too "hacky" as the devs like to say.

I'd love to see what other works you'll have to offer in the near future.

Posted
I hope this will make into the "Under Review" section for consideration, so long as it's not considered too "hacky" as the devs like to say.

I don't know what have to be in "Core Modifications" or "Under revision ..." so I posted here =D

Posted

You posted in the right place, Siegels. If your offering meets certain standards, such as following the programming guidelines and adding features that reproduce retail functions, it may become a candidate for review. Once that occurs, if you're willing to follow the advice of the MaNGOS team for improvements to your code, it just might become an official part of the server core code. :)

Keep up the good work!

Posted

Simple, does it's job, but I notced there is a nester query in there:

UPDATE npc_vendor SET sortOrder = sortOrder - 1 WHERE sortOrder > (SELECT sortOrder FROM npc_vendor WHERE entry='%u' AND item='%u' LIMIT 1) AND entry = '%u'

I'm not sure if mangos allows these. I could be wrong.

Posted
Simple, does it's job, but I notced there is a nester query in there:

UPDATE npc_vendor SET sortOrder = sortOrder - 1 WHERE sortOrder > (SELECT sortOrder FROM npc_vendor WHERE entry='%u' AND item='%u' LIMIT 1) AND entry = '%u'

I'm not sure if mangos allows these. I could be wrong.

This is perfectly handled. Why shouldn't it be ? It's just advanced SQL, good and advanced SQL.

Posted
This is perfectly handled. Why shouldn't it be ? It's just advanced SQL, good and advanced SQL.

Nester queries are usually much slower than joins. I will do some performance checks and get back to you if I create a faster query.

Posted

(Up)

Oh i see, I didn't know that we can use join in an update query xD

Like this ?:

UPDATE npc_vendor list, npc_vendor item SET list.sortOrder = list.sortOrder - 1 WHERE list.sortOrder > item.sortOrder AND item.entry='%u' AND item.entry=list.entry and item.item = '%u';

Posted

Nester query or not, I still like this patch and would love to add it to my server.

Siegels, if you do change the SQL queries to use JOINs instead of a nested loop, will you also provide a query so I may update my database by safely removing the nested query and replacing it with the JOIN, if you do need to modify your SQL? That is the only reason I have not already added your patch.

I had encountered some issues with the old Dual Spec patch SQL queries that were difficult to fix and it has left me wary of having similar troubles with other patchs' SQL files.

Posted

There is only 1 nester query witch can be replaced with a JOIN query without doing any change in your database. SQL patch in first .patch file is correct with or without modification but, yes, join is faster than nester. I will (test and) provide a new patch when I would turn into ubuntu (I'm actually over windows (bwah...) and don't have any developement stuff).

Posted

Updated first post. Added new patch.

Now when moving an item in a vendor list, position of other items is checked before moving.

Query replacement for nester query modified.

Posted

No, he does not need to do this. The Pastebin link shows a file uploaded May 1, 2010. Same goes for Filebeam.

These are the most current versions of his patch. Download and enjoy. :)

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use