//////////////////////////////////////////////////////////////////////////////
//
// AVP_PlayerObjective_LocationMarker.cpp
//
// Created by AJK 25/02/2009
//
// Copyright (c) 2009 Rebellion. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////

// Core
#include "Core/Asura.h"

// Header
#include "Entity/ObjectiveSystem/PlayerObjective/AVP_ServerEntity_LocationMarker.h"

// Asura
#include "ChunkSystem/Asura_Chunk_Stream.h"

// AVP
#include "Entity/AVP_Entity_Classification.h"

	  
Asura_Hashed_List<AVP_ServerEntity_LocationMarker> AVP_ServerEntity_LocationMarker::s_xList(2);

AVP_ServerEntity_LocationMarker::AVP_ServerEntity_LocationMarker( const Asura_Guid uGuid )
: PARENT(uGuid)
, m_uPlayerObjectiveGuid ( ASURA_GUID_UNREGISTERED )
{
	Classification = AVP_ENTITYCLASS_LOCATIONMARKER;

	SetNeverUpdateClient();

	s_xList.AddToList(this);
}

AVP_ServerEntity_LocationMarker::~AVP_ServerEntity_LocationMarker(void)
{
	s_xList.RemoveFromList(this);
}

void AVP_ServerEntity_LocationMarker::WriteToChunkStream(Asura_Chunk_Stream& xStream) const
{
	//Version
	xStream << CURRENT_CHUNK_VERSION;

	//Parent
	PARENT::WriteToChunkStream(xStream);

	xStream << m_uPlayerObjectiveGuid;
	xStream << m_xPosition;
}

void AVP_ServerEntity_LocationMarker::ReadFromChunkStream(Asura_Chunk_Stream& xStream)
{
	//Version
	u_int uVersion;
	xStream	>> uVersion;

	//Parent
	PARENT::ReadFromChunkStream(xStream);

	if (uVersion == CURRENT_CHUNK_VERSION)
	{
		xStream >> m_uPlayerObjectiveGuid; 
		xStream >> m_xPosition; 
	}

	SetNeverUpdates(true);
}