void GameFactory::DestroyAll() noexcept { BaseList copy; cs.Operate([©]() { copy = move(instances); index.clear(); typecount.clear(); delrefs.clear(); }); for (const auto& instance : copy) { Base* reference = static_cast<Base*>(instance.first->StartSession()); reference->freecontents(); #ifdef VAULTMP_DEBUG debug.print("Base ", std::dec, instance.first->GetNetworkID(), " (type: ", typeid(*(instance.first)).name(), ") to be destructed (", instance.first.get(), ")"); #endif reference->Finalize(); } Lockable::Reset(); }