1
General / Re: RenderWindow::draw() crashes program when iterating over an entity list
« on: October 12, 2016, 09:49:51 am »
Thank you very much for all the tips and two cents! I was really up against a brick wall with this one, and never thought that would've been the problem.
So I was somewhat able to create a workaround with the solution: Create the Entities when loading each level (phase == 0), and then destroy anyone that dies.
+1 to both (If this forums has reps, that is )
So I was somewhat able to create a workaround with the solution: Create the Entities when loading each level (phase == 0), and then destroy anyone that dies.
...
if (phase == 0) {
Entity * tmp_ent = nullptr;
tmp_ent = new Entity {
...
};
ents.push_back(tmp_ent);
phase = 1;
}
...
for (Entity *rem : to_remove) {
ents.erase(std::remove(ents.begin(), ents.end(), rem), ents.end());
delete rem;
}
...
}
if (phase == 0) {
Entity * tmp_ent = nullptr;
tmp_ent = new Entity {
...
};
ents.push_back(tmp_ent);
phase = 1;
}
...
for (Entity *rem : to_remove) {
ents.erase(std::remove(ents.begin(), ents.end(), rem), ents.end());
delete rem;
}
...
}
+1 to both (If this forums has reps, that is )