Skip to content

Commit

Permalink
editor: now use bptr<object>::destroy()
Browse files Browse the repository at this point in the history
  • Loading branch information
sthalik committed Aug 9, 2024
1 parent d2917b6 commit 1bbdbb8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion editor/imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void app::do_popup_menu()
{
const auto [id, target] = _popup_target;
auto& w = M->world();
const auto eʹ = w.find_object(id);
auto eʹ = w.find_object(id);

if (target == popup_target_type::none || !eʹ)
{
Expand Down Expand Up @@ -394,6 +394,7 @@ void app::do_popup_menu()
e.chunk().remove_object(e.index());
e.destroy_script_post();
e.gone = true;
eʹ.destroy();
}
}
else
Expand Down
10 changes: 6 additions & 4 deletions editor/scenery-editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ void scenery_editor::place_tile(world& w, global_coords pos, const scenery_& s,
while (auto id = a.get_object_colliding_with_cursor())
{
for (auto i = 0uz; i < sz; i++)
if (const auto eʹ = es[i]; eʹ->id == id)
if (auto eʹ = es[i]; eʹ->id == id)
{
eʹ->destroy_script_pre(eʹ, script_destroy_reason::kill);
auto& e = *eʹ;
e.destroy_script_pre(eʹ, script_destroy_reason::kill);
c.remove_object(i);
eʹ->destroy_script_post();
eʹ->gone = true;
e.destroy_script_post();
e.gone = true;
eʹ.destroy();
goto start;
}
break;
Expand Down
12 changes: 7 additions & 5 deletions editor/vobj-editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ void vobj_editor::place_tile(world& w, global_coords pos, const vobj_* x, struct
{
for (auto i = (int)(es.size()-1); i >= 0; i--)
{
const auto eʹ = es[i];
if (eʹ->id == id && eʹ->is_virtual())
auto eʹ = es[i];
auto& e = *eʹ;
if (e.id == id && eʹ->is_virtual())
{
eʹ->destroy_script_pre(eʹ, script_destroy_reason::kill);
e.destroy_script_pre(eʹ, script_destroy_reason::kill);
c.remove_object((unsigned)i);
eʹ->destroy_script_post();
eʹ->gone = true;
e.destroy_script_post();
e.gone = true;
eʹ.destroy();
goto start;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ void chunk::remove_object(size_t i)

}
arrayRemove(_objects, i);
//eʹ.destroy();
}

ArrayView<const bptr<object>> chunk::objects() const
Expand Down

0 comments on commit 1bbdbb8

Please sign in to comment.