mrDIMAS / StationIapetus

3rd person shooter in the very early development phase
GNU General Public License v3.0
292 stars 28 forks source link

Crash when shooting grenades #8

Open martin-t opened 2 years ago

martin-t commented 2 years ago

I throw a grenade, shoot it with the default gun and after a short while (when it's supposed to explode?) the game crashes.

thread 'main' panicked at 'Attempt to borrow destroyed object at [Idx: 819; Gen: 1] handle.', /home/martin/dev/rust/rg3d/rg3d-core/src/pool.rs:504:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:457:5
   2: <rg3d_core::pool::Pool<T> as core::ops::index::IndexMut<rg3d_core::pool::Handle<T>>>::index_mut
   3: <alloc::vec::Vec<T> as rg3d_core::VecExtensions<T>>::retain_mut
   4: station_iapetus::level::BaseLevel::update
   5: station_iapetus::Game::update
   6: station_iapetus::Game::run::{{closure}}
   7: winit::platform_impl::platform::x11::EventLoop<T>::run
   8: winit::platform_impl::platform::EventLoop<T>::run
   9: winit::event_loop::EventLoop<T>::run
  10: station_iapetus::Game::run
  11: station_iapetus::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
LordCocoNut commented 2 years ago

I did a little investigation, and I think this might be caused by the decals system. Will try to fix it and possibly do pull request.

LordCocoNut commented 2 years ago

Ok, since im beginner to rust and I dont know the inner processes of Iapeteus or Engine so i wont be able to fix it, but i think the problem is caused at line 1208 in /src/level/mod.rs, where is being handled parent to add bullet decal to. I think cause of that there is being decal created for grenade and after cleaning up from projectile.rs there remains decal reference for it, which causes error.

Dont know if there should be a mechanism to clear decals in clean_up methods before the node is being destroyed.