File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,8 @@ void Eluna::CreateBindStores()
177177
178178void Eluna::DestroyBindStores ()
179179{
180- bindingMaps.clear ();
180+ for (auto & binding : bindingMaps)
181+ binding.reset ();
181182}
182183
183184void Eluna::RunScripts ()
Original file line number Diff line number Diff line change @@ -182,12 +182,13 @@ class ELUNA_GAME_API Eluna
182182 // Map from map ID -> Lua table ref
183183 std::unordered_map<uint32, int > continentDataRefs;
184184
185- std::unordered_map <std::underlying_type_t <Hooks::RegisterTypes >, std::unique_ptr<BaseBindingMap> > bindingMaps;
185+ std::array <std::unique_ptr<BaseBindingMap >, Hooks::REGTYPE_COUNT > bindingMaps;
186186
187187 template <typename T>
188188 void CreateBinding (Hooks::RegisterTypes type)
189189 {
190- bindingMaps[std::underlying_type_t <Hooks::RegisterTypes>(type)] = std::make_unique<BindingMap<T>>(L);
190+ auto index = static_cast <std::underlying_type_t <Hooks::RegisterTypes>>(type);
191+ bindingMaps[index] = std::make_unique<BindingMap<T>>(L);
191192 }
192193
193194 void OpenLua ();
@@ -363,9 +364,14 @@ class ELUNA_GAME_API Eluna
363364 template <typename T>
364365 BindingMap<T>* GetBinding (std::underlying_type_t <Hooks::RegisterTypes> type)
365366 {
366- auto it = bindingMaps.find (type);
367- if (it == bindingMaps.end ()) return nullptr ;
368- return dynamic_cast <BindingMap<T>*>(it->second .get ());
367+ if (type >= Hooks::REGTYPE_COUNT)
368+ return nullptr ;
369+
370+ auto & binding = bindingMaps[type];
371+ if (!binding)
372+ return nullptr ;
373+
374+ return dynamic_cast <BindingMap<T>*>(binding.get ());
369375 }
370376
371377 template <typename T>
You can’t perform that action at this time.
0 commit comments