Ejemplo 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();
}
#include "Object.h"

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

#ifdef VAULTMP_DEBUG
Debug* Object::debug;
#endif

#ifdef VAULTMP_DEBUG
void Object::SetDebugHandler(Debug* debug)
{
	Object::debug = debug;

	if (debug)
		debug->Print("Attached debug handler to Object class", true);
}
#endif

Object::Object(unsigned int refID, unsigned int baseID) : Reference(refID, baseID)
{
	vector<unsigned char> data = API::RetrieveAllAxis();

	for (unsigned char _data : data)
	{
		object_Game_Pos.insert(pair<unsigned char, Value<double> >(_data, Value<double>()));
		object_Network_Pos.insert(pair<unsigned char, Value<double> >(_data, Value<double>()));
		object_Angle.insert(pair<unsigned char, Value<double> >(_data, Value<double>()));
	}
}

Object::Object(const pDefault* packet) : Object(PacketFactory::ExtractReference(packet), PacketFactory::ExtractBase(packet))