Core/Gossip: Use algorithms from std::ranges namespace in gossip menu code

Port From (https://github.com/TrinityCore/TrinityCore/commit/a562f4fafade619ec1289d6f54e14fc28dc010d8)
This commit is contained in:
Hondacrx
2025-08-18 15:58:44 -04:00
parent 5b6c783823
commit 70ad92f838
+5 -12
View File
@@ -35,15 +35,12 @@ namespace Game.Misc
orderIndex = (int)(itr.OrderIndex + 1); orderIndex = (int)(itr.OrderIndex + 1);
} }
if (!_menuItems.Empty()) foreach (var (_, _menuItem) in _menuItems)
{ {
foreach (var pair in _menuItems) if (_menuItem.OrderIndex > orderIndex)
{
if (pair.Value.OrderIndex > orderIndex)
break; break;
orderIndex = (int)pair.Value.OrderIndex + 1; orderIndex = (int)_menuItem.OrderIndex + 1;
}
} }
} }
@@ -714,13 +711,9 @@ namespace Game.Misc
_questMenuItems.Add(questMenuItem); _questMenuItems.Add(questMenuItem);
} }
bool HasItem(uint questId) public bool HasItem(uint questId)
{ {
foreach (var item in _questMenuItems) return _questMenuItems.Any(p => p.QuestId == questId);
if (item.QuestId == questId)
return true;
return false;
} }
public void ClearMenu() public void ClearMenu()