Can anyone tell me
why this crashes my program? It's suppose to make it so order has all the elements in the t vector situated by (y + height).
Edit: crashes on the lines with "insert" in them.
void createDrawOrder(vector<Thing*> t, vector<int> *order) {
int min = t[0]->y + t[0]->height;
int max = t[0]->y + t[0]->height;
vector<int>::iterator it;
it = order->begin();
order->push_back(0);
for (int i = 1; i < (int) t.size(); i++) {
if ((t[i]->y + t[i]->height) < min) {
min = (t[i]->y + t[i]->height);
order->insert(it, i);
}
else if((t[i]->y + t[i]->height) >= min && (t[i]->y + t[i]->height) < max){
int tempsize = (int) order->size();
for (int j = 0; j < tempsize; j++){
if((t[i]->y + t[i]->height) <= (t[(*order)[j]]->y + t[(*order)[j]]->height)){
order->insert(it + j, i);
}
}
}
else if ((t[i]->y + t[i]->height) >= max) {
max = (t[i]->y + t[i]->height);
order->push_back(i);
}
}
}//end method max