mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
Remove TaskGoalList_Struct::Size since it's not needed
This commit is contained in:
parent
6399710c1d
commit
c3e007597e
@ -3133,7 +3133,7 @@ bool TaskGoalListManager::LoadLists()
|
|||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
int listID = atoi(row[0]);
|
int listID = atoi(row[0]);
|
||||||
int listSize = atoi(row[1]);
|
int listSize = atoi(row[1]);
|
||||||
TaskGoalLists.push_back({listID, listSize, 0, 0});
|
TaskGoalLists.push_back({listID, 0, 0});
|
||||||
|
|
||||||
TaskGoalLists[listIndex].GoalItemEntries.reserve(listSize);
|
TaskGoalLists[listIndex].GoalItemEntries.reserve(listSize);
|
||||||
|
|
||||||
@ -3143,23 +3143,16 @@ bool TaskGoalListManager::LoadLists()
|
|||||||
for (int listIndex = 0; listIndex < NumberOfLists; listIndex++) {
|
for (int listIndex = 0; listIndex < NumberOfLists; listIndex++) {
|
||||||
|
|
||||||
int listID = TaskGoalLists[listIndex].ListID;
|
int listID = TaskGoalLists[listIndex].ListID;
|
||||||
unsigned int size = TaskGoalLists[listIndex].Size;
|
auto size = TaskGoalLists[listIndex].GoalItemEntries.capacity(); // this was only done for manual memory management, shouldn't need to do this
|
||||||
query = StringFormat("SELECT `entry` from `goallists` "
|
query = StringFormat("SELECT `entry` from `goallists` "
|
||||||
"WHERE `listid` = %i "
|
"WHERE `listid` = %i "
|
||||||
"ORDER BY `entry` ASC LIMIT %i",
|
"ORDER BY `entry` ASC LIMIT %i",
|
||||||
listID, size);
|
listID, size);
|
||||||
results = database.QueryDatabase(query);
|
results = database.QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
TaskGoalLists[listIndex].Size = 0;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should only happen if a row is deleted in between us retrieving the counts
|
|
||||||
// at the start of this method and getting to here. It should not be possible for
|
|
||||||
// an INSERT to cause a problem, as the SELECT is used with a LIMIT
|
|
||||||
if (results.RowCount() < size)
|
|
||||||
TaskGoalLists[listIndex].Size = results.RowCount();
|
|
||||||
|
|
||||||
int entryIndex = 0;
|
int entryIndex = 0;
|
||||||
for (auto row = results.begin(); row != results.end(); ++row, ++entryIndex) {
|
for (auto row = results.begin(); row != results.end(); ++row, ++entryIndex) {
|
||||||
|
|
||||||
@ -3197,7 +3190,7 @@ int TaskGoalListManager::GetFirstEntry(int ListID) {
|
|||||||
|
|
||||||
if((ListIndex < 0) || (ListIndex >= NumberOfLists)) return -1;
|
if((ListIndex < 0) || (ListIndex >= NumberOfLists)) return -1;
|
||||||
|
|
||||||
if(TaskGoalLists[ListIndex].Size == 0) return -1;
|
if(TaskGoalLists[ListIndex].GoalItemEntries.empty()) return -1;
|
||||||
|
|
||||||
return TaskGoalLists[ListIndex].GoalItemEntries[0];
|
return TaskGoalLists[ListIndex].GoalItemEntries[0];
|
||||||
}
|
}
|
||||||
@ -3210,45 +3203,35 @@ std::vector<int> TaskGoalListManager::GetListContents(int ListID) {
|
|||||||
|
|
||||||
if((ListIndex < 0) || (ListIndex >= NumberOfLists)) return ListContents;
|
if((ListIndex < 0) || (ListIndex >= NumberOfLists)) return ListContents;
|
||||||
|
|
||||||
for(int i=0; i<TaskGoalLists[ListIndex].Size; i++)
|
ListContents = TaskGoalLists[ListIndex].GoalItemEntries;
|
||||||
ListContents.push_back(TaskGoalLists[ListIndex].GoalItemEntries[i]);
|
|
||||||
|
|
||||||
return ListContents;
|
return ListContents;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TaskGoalListManager::IsInList(int ListID, int Entry)
|
||||||
|
{
|
||||||
bool TaskGoalListManager::IsInList(int ListID, int Entry) {
|
|
||||||
|
|
||||||
Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i)", ListID, Entry);
|
Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i)", ListID, Entry);
|
||||||
|
|
||||||
int ListIndex = GetListByID(ListID);
|
int ListIndex = GetListByID(ListID);
|
||||||
|
|
||||||
if((ListIndex<0) || (ListIndex >= NumberOfLists)) return false;
|
if ((ListIndex < 0) || (ListIndex >= NumberOfLists))
|
||||||
|
return false;
|
||||||
|
|
||||||
if((Entry < TaskGoalLists[ListIndex].Min) || (Entry > TaskGoalLists[ListIndex].Max))
|
if ((Entry < TaskGoalLists[ListIndex].Min) || (Entry > TaskGoalLists[ListIndex].Max))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int FirstEntry = 0;
|
int FirstEntry = 0;
|
||||||
int LastEntry = TaskGoalLists[ListIndex].Size - 1;
|
auto &task = TaskGoalLists[ListIndex];
|
||||||
|
|
||||||
while(FirstEntry <= LastEntry) {
|
auto it = std::find(task.GoalItemEntries.begin(), task.GoalItemEntries.end(), Entry);
|
||||||
int MiddleEntry = (FirstEntry + LastEntry) / 2;
|
|
||||||
|
|
||||||
if(Entry > TaskGoalLists[ListIndex].GoalItemEntries[MiddleEntry])
|
if (it == task.GoalItemEntries.end())
|
||||||
FirstEntry = MiddleEntry + 1;
|
return false;
|
||||||
else if(Entry < TaskGoalLists[ListIndex].GoalItemEntries[MiddleEntry])
|
|
||||||
LastEntry = MiddleEntry - 1;
|
|
||||||
else {
|
|
||||||
Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i) returning true", ListIndex, Entry);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i) returning true", ListIndex,
|
||||||
|
Entry);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskProximityManager::TaskProximityManager() {
|
TaskProximityManager::TaskProximityManager() {
|
||||||
|
|||||||
@ -53,7 +53,6 @@ namespace EQEmu
|
|||||||
|
|
||||||
struct TaskGoalList_Struct {
|
struct TaskGoalList_Struct {
|
||||||
int ListID;
|
int ListID;
|
||||||
int Size;
|
|
||||||
int Min, Max;
|
int Min, Max;
|
||||||
std::vector<int> GoalItemEntries;
|
std::vector<int> GoalItemEntries;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user