diff --git a/source/lib/res/h_mgr.cpp b/source/lib/res/h_mgr.cpp index 6733363c1f..a4ca771e26 100755 --- a/source/lib/res/h_mgr.cpp +++ b/source/lib/res/h_mgr.cpp @@ -716,6 +716,15 @@ Handle h_find(H_Type type, uintptr_t key) } +int h_allow_free(Handle h, H_Type type) +{ + HDATA* hd = h_data(h, type); + if(!hd) + return ERR_INVALID_HANDLE; + hd->keep_open = 0; + return 0; +} + int res_cur_scope; diff --git a/source/lib/res/h_mgr.h b/source/lib/res/h_mgr.h index fda547a892..cba2df28e2 100755 --- a/source/lib/res/h_mgr.h +++ b/source/lib/res/h_mgr.h @@ -201,7 +201,10 @@ extern int h_reload(const char* fn); extern int res_cur_scope; - +// disable caching and allow the handle to actually be freed when refcount +// is at 0. used when cached resources must be closed before exit, +// e.g. sounds when reinitializing OpenAL (due to changed settings). +extern int h_allow_free(Handle h, H_Type type); extern void h_mgr_shutdown();