Jump to content

[Patch] Ordered list for vendors


Guest Siegels

Recommended Posts

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';

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

(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';

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

×
×
  • 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