Switch TaskGoalList_Struct::GoalItemEntries to std::vector

This commit is contained in:
Michael Cook (mackal) 2018-06-11 21:58:11 -04:00
parent 4fec8a2b75
commit e3dfb2f19d
2 changed files with 6 additions and 16 deletions

View File

@ -3097,28 +3097,18 @@ void ClientTaskState::ProcessTaskProximities(Client *c, float X, float Y, float
} }
} }
TaskGoalListManager::TaskGoalListManager() { TaskGoalListManager::TaskGoalListManager()
{
NumberOfLists = 0; NumberOfLists = 0;
} }
TaskGoalListManager::~TaskGoalListManager() { TaskGoalListManager::~TaskGoalListManager() {}
for(int i=0; i< NumberOfLists; i++) {
safe_delete_array(TaskGoalLists[i].GoalItemEntries);
}
}
bool TaskGoalListManager::LoadLists() bool TaskGoalListManager::LoadLists()
{ {
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskGoalListManager::LoadLists Called"); Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskGoalListManager::LoadLists Called");
for (int i = 0; i < NumberOfLists; i++)
safe_delete_array(TaskGoalLists[i].GoalItemEntries);
TaskGoalLists.clear(); TaskGoalLists.clear();
const char *ERR_MYSQLERROR = "Error in TaskGoalListManager::LoadLists: %s %s"; const char *ERR_MYSQLERROR = "Error in TaskGoalListManager::LoadLists: %s %s";
@ -3143,9 +3133,9 @@ 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, nullptr}); TaskGoalLists.push_back({listID, listSize, 0, 0});
TaskGoalLists[listIndex].GoalItemEntries = new int[listSize]; TaskGoalLists[listIndex].GoalItemEntries.reserve(listSize);
listIndex++; listIndex++;
} }

View File

@ -55,7 +55,7 @@ struct TaskGoalList_Struct {
int ListID; int ListID;
int Size; int Size;
int Min, Max; int Min, Max;
int *GoalItemEntries; std::vector<int> GoalItemEntries;
}; };
// This is used for handling lists, loading them from the database, searching them. // This is used for handling lists, loading them from the database, searching them.