Skip to content

Commit

Permalink
Fix crash when loading level due to modified list in range-base for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
kavika13 committed Aug 5, 2024
1 parent 4d17bd2 commit 4329204
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Source/Main/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4429,7 +4429,11 @@ void Engine::Draw() {
{ // Perform per-frame calculations (like character shadows or LOD)
PROFILER_GPU_ZONE(g_profiler_ctx, "Pre-draw frame");
float predraw_time = game_timer.GetRenderTime();
for (auto obj : scenegraph_->objects_) {
// Using an index based for-loop because new items get added inside the angelscript PreDraw function
for (int i = 0; i < scenegraph_->objects_.size(); ++i) {
// TODO: Handle removing an object in angelscript inside PreDraw function? Should all deletes from script be a queued delete?
// May have to modify scripts to make that work right.
Object* obj = scenegraph_->objects_[i];
if (!obj->parent) {
obj->PreDrawFrame(predraw_time);
}
Expand Down

0 comments on commit 4329204

Please sign in to comment.