From 891f1639548827837216a068dde2524fca9d5d88 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 12 May 2021 20:19:45 +0200 Subject: [PATCH] ray:: fixed crashes when rmap is destroyed while in use --- raycaster.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/raycaster.cpp b/raycaster.cpp index 55cb3d92..f9e9a4f5 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -1676,9 +1676,11 @@ struct raycast_map { }; unique_ptr rmap; +bool reset_rmap = false; EX void reset_raycaster() { - our_raycaster = nullptr; rmap = nullptr; + our_raycaster = nullptr; + reset_rmap = true; rots::saved_matrices_ray = {}; } @@ -1851,6 +1853,8 @@ EX void cast() { if(o->uFogColor != -1) glUniform4f(o->uFogColor, cols[0], cols[1], cols[2], cols[3]); + if(reset_rmap) rmap = nullptr, reset_rmap = false; + if(!rmap) rmap = (unique_ptr) new raycast_map; if(rmap->need_to_create(cs)) {