Exemplo n.º 1
0
void GameFactory::DestroyAllInstances()
{
	cs.StartSession();

	for (const auto& instance : instances)
	{
		if (instance.second & ALL_CONTAINERS)
			reinterpret_cast<Container*>(instance.first.get())->container.clear();

#ifdef VAULTMP_DEBUG
		if (debug)
			debug->PrintFormat("Reference %08X with base %08X and NetworkID %llu (type: %s) to be destructed (%08X)", true, instance.first->GetReference(), instance.first->GetBase(), instance.first->GetNetworkID(), typeid(*(instance.first)).name(), instance.first.get());
#endif

		Reference* reference = reinterpret_cast<Reference*>(instance.first->StartSession());

		reference->Finalize();
	}

	instances.clear();
	typecount.clear();

	cs.EndSession();

	// Cleanup classes

	Object::param_Axis = RawParameter(vector<string>());
	Actor::param_ActorValues = RawParameter(vector<string>());

	Lockable::Reset();
}
void GameFactory::DestroyAllInstances()
{
	cs.StartSession();

	for (pair<Reference* const, unsigned char>& instance : instances)
	{
		if (instance.second & ALL_CONTAINERS)
			reinterpret_cast<Container*>(instance.first)->container.clear();

#ifdef VAULTMP_DEBUG

		if (debug)
			debug->PrintFormat("Reference %08X with base %08X and NetworkID %lld (type: %s) to be destructed (%08X)", true, instance.first->GetReference(), instance.first->GetBase(), instance.first->GetNetworkID(), typeid(*(instance.first)).name(), instance.first);

#endif

		Reference* reference = reinterpret_cast<Reference*>(instance.first->StartSession());

		if (reference)
		{
			reference->Finalize();
			delete reference; // this throws
		}
	}

	instances.clear();
	typecount.clear();

	cs.EndSession();

	// Cleanup classes

	Object::param_Axis = RawParameter(vector<string>());

	Container::Items = NULL;

#ifdef VAULTSERVER
	delete Actor::dbActors;
	delete Actor::dbCreatures;
#endif

	Actor::param_ActorValues = RawParameter(vector<string>());

	Lockable::Reset();
}