-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add sorting feature and related conf #174
Conversation
src/transmog_scripts.cpp
Outdated
|
||
if (sConfigMgr->GetOption<bool>("Transmogrification.EnableSortByQualityAndName", true)) { | ||
const std::string acore_world_name = sConfigMgr->GetOption<std::string>("Transmogrification.AcoreWorldName", "acore_world"); | ||
query = "SELECT custom_unlocked_appearances.account_id, custom_unlocked_appearances.item_template_id, " + acore_world_name + ".item_template.name, " + acore_world_name + ".item_template.Quality FROM custom_unlocked_appearances INNER JOIN " + acore_world_name + ".item_template ON custom_unlocked_appearances.item_template_id=" + acore_world_name + ".item_template.entry ORDER BY " + acore_world_name + ".item_template.Quality DESC, " + acore_world_name + ".item_template.name ASC;"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query will perform very badly with this cross-db join
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, I do not know how to improve it
would be better to convert it into a left join?
Couldn't you just sort the generated vector of allowed items instead? Sure you sort multiple times but it's a cheap sort on such a small collection and wouldn't be nearly as messy. something like this (you can and should probably make the name comparison better) bool CmpTmog (Item* i1, Item* i2)
{
const ItemTemplate* i1t = i1->GetTemplate();
const ItemTemplate* i2t = i2->GetTemplate();
return i1t->Name1[0] > i2t->Name1[0] || i1t->Quality > i2t->Quality;
}
sort(allowedItems.begin(), allowedItems.end(), CmpTmog); |
in fact I would advise mildly reworking this to use string::compare for the name comparisons. |
I will try that, thank you! |
I restored the code as it was before and added that |
if I remove |
Yeah you might have to tweak the conditions for the comparison to be a bit more intelligent, I just kinda slapped an example together from what I remembered about C++ sorting |
Way much better, good job! 👍 |
thanks you both! |
closes #133
I tested it in-game with few items