From 82ec1a07c79b1c96688464609d043d6ce23685b1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 6 Apr 2023 15:29:33 +0200 Subject: a --- editor/draw.cpp | 10 ++++++---- editor/update.cpp | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'editor') diff --git a/editor/draw.cpp b/editor/draw.cpp index 6d07f871..285299b6 100644 --- a/editor/draw.cpp +++ b/editor/draw.cpp @@ -80,9 +80,10 @@ void app::draw_collision_boxes() for (int16_t x = minx; x <= maxx; x++) { const chunk_coords pos{x, y}; - auto& c = world[pos]; - if (c.empty()) + auto* c_ = world.at(pos); + if (!c_) continue; + auto& c = *c_; c.ensure_passability(); const with_shifted_camera_offset o{shader, pos, {minx, miny}, {maxx, maxy}}; if (floormat_main::check_chunk_visible(shader.camera_offset(), sz)) @@ -116,9 +117,10 @@ void app::draw_collision_boxes() for (int16_t x = minx; x <= maxx; x++) { const chunk_coords c_pos{x, y}; - auto& c = world[c_pos]; - if (c.empty()) + auto* c_ = world.at(c_pos); + if (!c_) continue; + auto& c = *c_; c.ensure_passability(); const with_shifted_camera_offset o{shader, c_pos, {minx, miny}, {maxx, maxy}}; if (floormat_main::check_chunk_visible(shader.camera_offset(), sz)) diff --git a/editor/update.cpp b/editor/update.cpp index 069399c7..eb4029dc 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -185,7 +185,10 @@ void app::update_world(float dt) for (int16_t y = miny; y <= maxy; y++) for (int16_t x = minx; x <= maxx; x++) { - auto& c = world[chunk_coords{x, y}]; + auto* c_ = world.at(chunk_coords{x, y}); + if (!c_) + continue; + auto& c = *c_; const auto& es = c.entities(); start: const auto size = es.size(); for (auto i = size-1; i != (size_t)-1; i--) -- cgit v1.2.3