From 8b4362ece7853077847f780e24caca31b53aa614 Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 27 Jan 2022 21:18:01 +0100 Subject: [PATCH] Disable navmesh disk cache when db is failed to open --- components/detournavigator/navigator.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/detournavigator/navigator.cpp b/components/detournavigator/navigator.cpp index cf3c4ba5b3..5b9341523c 100644 --- a/components/detournavigator/navigator.cpp +++ b/components/detournavigator/navigator.cpp @@ -3,6 +3,8 @@ #include "navigatorstub.hpp" #include "recastglobalallocator.hpp" +#include + namespace DetourNavigator { std::unique_ptr makeNavigator(const Settings& settings, const std::string& userDataPath) @@ -11,7 +13,16 @@ namespace DetourNavigator std::unique_ptr db; if (settings.mEnableNavMeshDiskCache) - db = std::make_unique(userDataPath + "/navmesh.db"); + { + try + { + db = std::make_unique(userDataPath + "/navmesh.db"); + } + catch (const std::exception& e) + { + Log(Debug::Error) << e.what() << ", navigation mesh disk cache will be disabled"; + } + } return std::make_unique(settings, std::move(db)); }