mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-20 17:31:30 +00:00
Use lambdas in sort functions (for zone at least)
This commit is contained in:
parent
811872c17f
commit
8522542ae2
@ -4644,13 +4644,6 @@ const char* Merc::GetRandomName(){
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Compare_Merc_Spells(MercSpell i, MercSpell j);
|
|
||||||
|
|
||||||
bool Compare_Merc_Spells(MercSpell i, MercSpell j)
|
|
||||||
{
|
|
||||||
return(i.slot > j.slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Merc::LoadMercSpells() {
|
bool Merc::LoadMercSpells() {
|
||||||
// loads mercs spells into list
|
// loads mercs spells into list
|
||||||
merc_spells.clear();
|
merc_spells.clear();
|
||||||
@ -4683,7 +4676,9 @@ bool Merc::LoadMercSpells() {
|
|||||||
AddProcToWeapon(mercSpellEntryItr->spellid, true, mercSpellEntryItr->proc_chance);
|
AddProcToWeapon(mercSpellEntryItr->spellid, true, mercSpellEntryItr->proc_chance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::sort(merc_spells.begin(), merc_spells.end(), Compare_Merc_Spells);
|
std::sort(merc_spells.begin(), merc_spells.end(), [](const MercSpell& a, const MercSpell& b) {
|
||||||
|
return a.slot > b.slot;
|
||||||
|
});
|
||||||
|
|
||||||
if (merc_spells.size() == 0)
|
if (merc_spells.size() == 0)
|
||||||
AIautocastspell_timer->Disable();
|
AIautocastspell_timer->Disable();
|
||||||
|
|||||||
@ -2334,7 +2334,6 @@ create table npc_spells_entries (
|
|||||||
|
|
||||||
bool IsSpellInList(DBnpcspells_Struct* spell_list, int16 iSpellID);
|
bool IsSpellInList(DBnpcspells_Struct* spell_list, int16 iSpellID);
|
||||||
bool IsSpellEffectInList(DBnpcspellseffects_Struct* spelleffect_list, uint16 iSpellEffectID, int32 base, int32 limit, int32 max);
|
bool IsSpellEffectInList(DBnpcspellseffects_Struct* spelleffect_list, uint16 iSpellEffectID, int32 base, int32 limit, int32 max);
|
||||||
bool Compare_AI_Spells(AISpells_Struct i, AISpells_Struct j);
|
|
||||||
|
|
||||||
bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) {
|
bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) {
|
||||||
// ok, this function should load the list, and the parent list then shove them into the struct and sort
|
// ok, this function should load the list, and the parent list then shove them into the struct and sort
|
||||||
@ -2459,7 +2458,9 @@ bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) {
|
|||||||
spell_list->entries[i].resist_adjust);
|
spell_list->entries[i].resist_adjust);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::sort(AIspells.begin(), AIspells.end(), Compare_AI_Spells);
|
std::sort(AIspells.begin(), AIspells.end(), [](const AISpells_Struct& a, const AISpells_Struct& b) {
|
||||||
|
return a.priority > b.priority;
|
||||||
|
});
|
||||||
|
|
||||||
if (IsValidSpell(attack_proc_spell))
|
if (IsValidSpell(attack_proc_spell))
|
||||||
AddProcToWeapon(attack_proc_spell, true, proc_chance);
|
AddProcToWeapon(attack_proc_spell, true, proc_chance);
|
||||||
@ -2599,11 +2600,6 @@ bool IsSpellInList(DBnpcspells_Struct* spell_list, int16 iSpellID) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Compare_AI_Spells(AISpells_Struct i, AISpells_Struct j)
|
|
||||||
{
|
|
||||||
return(i.priority > j.priority);
|
|
||||||
}
|
|
||||||
|
|
||||||
// adds a spell to the list, taking into account priority and resorting list as needed.
|
// adds a spell to the list, taking into account priority and resorting list as needed.
|
||||||
void NPC::AddSpellToNPCList(int16 iPriority, int16 iSpellID, uint16 iType,
|
void NPC::AddSpellToNPCList(int16 iPriority, int16 iSpellID, uint16 iType,
|
||||||
int16 iManaCost, int32 iRecastDelay, int16 iResistAdjust)
|
int16 iManaCost, int32 iRecastDelay, int16 iResistAdjust)
|
||||||
|
|||||||
@ -345,10 +345,10 @@ bool CheckLOSBetweenPoints(Map::Vertex start, Map::Vertex end) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SortPathNodesByDistance(PathNodeSortStruct n1, PathNodeSortStruct n2)
|
auto path_compare = [](const PathNodeSortStruct& a, const PathNodeSortStruct& b)
|
||||||
{
|
{
|
||||||
return n1.Distance < n2.Distance;
|
return a.Distance < b.Distance;
|
||||||
}
|
};
|
||||||
|
|
||||||
std::deque<int> PathManager::FindRoute(Map::Vertex Start, Map::Vertex End)
|
std::deque<int> PathManager::FindRoute(Map::Vertex Start, Map::Vertex End)
|
||||||
{
|
{
|
||||||
@ -382,7 +382,7 @@ std::deque<int> PathManager::FindRoute(Map::Vertex Start, Map::Vertex End)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(SortedByDistance.begin(), SortedByDistance.end(), SortPathNodesByDistance);
|
std::sort(SortedByDistance.begin(), SortedByDistance.end(), path_compare);
|
||||||
|
|
||||||
for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator)
|
for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator)
|
||||||
{
|
{
|
||||||
@ -420,7 +420,7 @@ std::deque<int> PathManager::FindRoute(Map::Vertex Start, Map::Vertex End)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(SortedByDistance.begin(), SortedByDistance.end(), SortPathNodesByDistance);
|
std::sort(SortedByDistance.begin(), SortedByDistance.end(), path_compare);
|
||||||
|
|
||||||
for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator)
|
for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator)
|
||||||
{
|
{
|
||||||
@ -1120,7 +1120,7 @@ int PathManager::FindNearestPathNode(Map::Vertex Position)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(SortedByDistance.begin(), SortedByDistance.end(), SortPathNodesByDistance);
|
std::sort(SortedByDistance.begin(), SortedByDistance.end(), path_compare);
|
||||||
|
|
||||||
for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator)
|
for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -391,7 +391,9 @@ void NPC::GetClosestWaypoint(std::list<wplist> &wp_list, int count, float m_x, f
|
|||||||
w_dist.index = i;
|
w_dist.index = i;
|
||||||
distances.push_back(w_dist);
|
distances.push_back(w_dist);
|
||||||
}
|
}
|
||||||
distances.sort(wp_distance_pred);
|
distances.sort([](const wp_distance& a, const wp_distance& b) {
|
||||||
|
return a.dist < b.dist;
|
||||||
|
});
|
||||||
|
|
||||||
std::list<wp_distance>::iterator iter = distances.begin();
|
std::list<wp_distance>::iterator iter = distances.begin();
|
||||||
for(int i = 0; i < count; ++i)
|
for(int i = 0; i < count; ++i)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user