mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 11:31:30 +00:00
Update TaskGoalListManager::GetListByID to std algos
This commit is contained in:
parent
e3dfb2f19d
commit
6399710c1d
@ -3172,9 +3172,7 @@ bool TaskGoalListManager::LoadLists()
|
|||||||
TaskGoalLists[listIndex].Max = entry;
|
TaskGoalLists[listIndex].Max = entry;
|
||||||
|
|
||||||
TaskGoalLists[listIndex].GoalItemEntries[entryIndex] = entry;
|
TaskGoalLists[listIndex].GoalItemEntries[entryIndex] = entry;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -3184,24 +3182,13 @@ bool TaskGoalListManager::LoadLists()
|
|||||||
int TaskGoalListManager::GetListByID(int ListID) {
|
int TaskGoalListManager::GetListByID(int ListID) {
|
||||||
|
|
||||||
// Find the list with the specified ListID and return the index
|
// Find the list with the specified ListID and return the index
|
||||||
|
auto it = std::find_if(TaskGoalLists.begin(), TaskGoalLists.end(),
|
||||||
|
[ListID](const TaskGoalList_Struct &t) { return t.ListID == ListID; });
|
||||||
|
|
||||||
int FirstEntry = 0;
|
if (it == TaskGoalLists.end())
|
||||||
int LastEntry = NumberOfLists - 1;
|
|
||||||
|
|
||||||
while(FirstEntry <= LastEntry) {
|
|
||||||
int MiddleEntry = (FirstEntry + LastEntry) / 2;
|
|
||||||
|
|
||||||
if(ListID > TaskGoalLists[MiddleEntry].ListID)
|
|
||||||
FirstEntry = MiddleEntry + 1;
|
|
||||||
else if(ListID < TaskGoalLists[MiddleEntry].ListID)
|
|
||||||
LastEntry = MiddleEntry - 1;
|
|
||||||
else
|
|
||||||
return MiddleEntry;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
return std::distance(TaskGoalLists.begin(), it);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TaskGoalListManager::GetFirstEntry(int ListID) {
|
int TaskGoalListManager::GetFirstEntry(int ListID) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user