//===========================================================================//
// File:	NetWeapon.hpp											
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 01/06/2000  JSE  Inital coding
//---------------------------------------------------------------------------//
// Copyright (C) 1998, Microsoft Corp.										 //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//




#pragma once

#include "NetConstants.hpp"

//#include "Mech.hpp"

namespace MechWarrior4 
{


	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//

	typedef void
		(*DecodeFunction)(
			Entity *entity, 
			MemoryStream *memory_stream, 
			Time till,
			Scalar packet_latency,
			int connection,
			int debug_level,
			int bandwidth,
			Scalar rate
		);

	typedef void
		(*SkipFunction)(
			MemoryStream *memory_stream,
			int size,
			Time till,
			int connection,
			int debug_level,
			int bandwidth
		);

	typedef void
		(*EncodeFunction)(
			Entity *entity,
			DynamicMemoryStream *memory_stream,
			int connection,
			int debug_level,
			int bandwidth
		);

	typedef int
		(*SizeFunction)(
			Entity *entity
		);

	typedef int
		(*MaxSizeFunction)(
			Entity *entity,
			int debug_level,
			int bandwidth
		);

	typedef bool
		(*MaintainActiveFlagFunction)(
			Entity *entity,
			Point3D cull_location
		);


	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//


#define UPDATE_ENTRY(c) \
	UpdateEntry((DecodeFunction)c::Decode, (SkipFunction)c::Skip, (EncodeFunction)c::Encode, (SizeFunction)c::SizeFunction, (MaxSizeFunction)c::MaxSize, (MaintainActiveFlagFunction)c::MaintainActiveFlagFunction, c::GetUpdateEntryType(), c::GetUpdateEntryCount())



	struct UpdateEntry 
	{
	public:
	
		UpdateEntry(DecodeFunction dec_func, SkipFunction skip_func, EncodeFunction enc_func, SizeFunction size_func, MaxSizeFunction max_func, MaintainActiveFlagFunction active_func, int update_id, int entry_count)
		{
			Check_Pointer(dec_func);
			Check_Pointer(skip_func);
			Check_Pointer(enc_func);

			m_decode = dec_func;
			m_skip = skip_func;
			m_encode = enc_func;
			m_size = size_func;
			m_maxSize = max_func;
			m_maintainActiveFlag = active_func;

			m_updateID = update_id;
			m_entryCount = entry_count;

		}

		DecodeFunction m_decode;
		SkipFunction m_skip;
		EncodeFunction m_encode;
		SizeFunction m_size;
		MaxSizeFunction m_maxSize;
		MaintainActiveFlagFunction m_maintainActiveFlag;

		int m_updateID;
		int m_entryCount;

		int GetEntryCount()
		{
			return m_entryCount;
		}

		int GetUpdateID()
		{
			return m_updateID;
		}

	};

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	//

	class UpdateManager
	{
	public:
		enum {
			BaseUpdateID = -1,
			MechPositionUpdateID = 0,
			MechAnimationUpdateID, //1
			MechMovemntUpdateID, //2
			MechExternalDamageUpdateID, //3
			MechFirstPersonPositionUpdateID, //4
			MechFirstPersonControlUpdateID, //5
			WeaponCommandID, //6
			MissionObjectiveUpdateID, //7
			MechInternalDamageUpdateID, //8
			MechInternalHeatUpdateID, //9
			SubsystemUpdateID,//10
			FlushUpdateID,//11
			SearchLightUpdateID,//12
			InternalAMSAmmoUpdateID,//13
			ExternalAMSAmmoUpdateID,//14
			NearBuildingExternalDamageUpdateID,//15
			SecondaryBuildingExternalDamageUpdateID,//16
			FarBuildingExternalDamageUpdateID,//17
			ExternalJumpJetUpdateID,//18
			InternalJumpJetUpdateID,//19
			VehicleDamageUpdateID,//20
			AirMovementUpdateID,//21
			GroundMovementUpdateID,//22
			TurretMovementUpdateID,//23
			TorsoMovementUpdateID,//24
			NavPointUpdateID,//25
			FlagUpdateID,//26
			TimeUpdateID,//27
			SecurityQueryID,//28
			SecurityResponseID,//29
			PingUpdateID,//30
			UpdateCount
		};

		static UpdateEntry
			UpdateEntries[];

		static int GetUpdateCount(){return UpdateCount;};
		static int GetUpdateEntryCount(int type);
	};
};