//
// Asura_Message.h
//
// Created by Kevin Lea - 27/06/2001 16:23:49
// 
// Copyright (C) 2001 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef __ASURA_MESSAGE_H__
#define __ASURA_MESSAGE_H__

#include "Core/Asura_Maths.h"
#include "Debugging/Asura_Assert.h"
#include "Network/Asura_Guid.h"
#include "Network/Asura_Network.h"

// forward declarations
class Asura_NetMsg;

// enums
enum ASURA_MSG_ID
{
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//RAR - Message IDs up to this point in the enumeration may be saved out to asura files,
	//so it is important that the values of existing ones remain unaltered.
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////

	ASURA_MSG_INVALID						            = 0,
	ASURA_MSG_INITIALISE					            = 1,

	ASURA_MSG_DESTRUCT                                  = 2,
	ASURA_MSG_ACTIVATE                                  = 3,
	ASURA_MSG_DEACTIVATE                                = 4,
	ASURA_MSG_TRIGGER						            = 5,

	ASURA_MSG_SPLITTER_ACTIVATEOUTPUT		            = 6,
	ASURA_MSG_SPLITTER_DEACTIVATEOUTPUT		            = 7,

	ASURA_MSG_CHANGE_ANIMATION				            = 8,
	ASURA_MSG_GLASS_SMASH					            = 9,

	ASURA_MSG_UNTRIGGER						            = 10,

	ASURA_MSG_LOCK							            = 11,
	ASURA_MSG_UNLOCK						            = 12,
	ASURA_MSG_LIFTCALL						            = 13,

	ASURA_MSG_RESET							            = 14,

	ASURA_MSG_SWITCHON						            = 15,
	ASURA_MSG_SWITCHOFF						            = 16,

	ASURA_MSG_TEMPLATE_TRIGGERINPUT			            = 17,
	ASURA_MSG_TEMPLATE_TRIGGEROUTPUT		            = 18,

	ASURA_MSG_ACTIVATECUTSCENEWITHTIME		            = 19,

	ASURA_MSG_LOGICTRIGGER_INPUTON			            = 20,
	ASURA_MSG_LOGICTRIGGER_INPUTOFF			            = 21,

	ASURA_MSG_CUTSCENE_ENABLEEVENT			            = 22,
	ASURA_MSG_CUTSCENE_DISABLEEVENT			            = 23,

	ASURA_MSG_TIMELINETRIGGER_ENABLEMESSAGE	            = 24,
	ASURA_MSG_TIMELINETRIGGER_DISABLEMESSAGE            = 25,

	ASURA_MSG_TEXTUREANIMATION				            = 26,

	ASURA_MSG_HIDE							            = 27,
	ASURA_MSG_UNHIDE						            = 28,

	ASURA_MSG_COLLISIONSON                              = 29,
	ASURA_MSG_COLLISIONSOFF					            = 30,

	ASURA_MSG_METAMUSIC_ACTIVATEZONE                    = 31,   //Used with meta music zones
	ASURA_MSG_METAMUSIC_DEACTIVATEZONE		            = 32,

	ASURA_MSG_SET_FSFX						            = 33,	// JGP - set full screen effect

	ASURA_MSG_AUDIO_REVERB                              = 34,   // SD - set active audio reverb. Parameter : GUID of audio reverb
	ASURA_MSG_AUDIO_EVENT                               = 35,   // SD - set an audio event. Parameters : GUID of audio event + matrix (position / orientation).
	ASURA_MSG_AUDIO_MIXINGGROUP				            = 36,	// SD - change mixing group parameters. Parameters : GUID of audio mixing, new gain (float), new pitch (float), recursive (bool)
	ASURA_MSG_AUDIO_AMBIENCE				            = 37,	// SD - change ambience 

	ASURA_MSG_SET_DESTRUCTIBLE				            = 38,   // for telling physical objects whether they are destructible or not

	ASURA_MSG_SET_FSFX_NEW                              = 39,   // JGP - set full screen effect (new message)
	ASURA_MSG_SOUND_MIXER_PRESET			            = 40,

	ASURA_MSG_AXON_CREATE_GOAL                          = 41,
	ASURA_MSG_AXON_SET_PAUSED                           = 42,

	ASURA_MSG_SETTIMER                                  = 43,   //RAR 15/09/2006 - Used by time/timeline triggers to set the current timer
	ASURA_MSG_TIMETRIGGER_SETTRIGGERTIME                = 44,   //RAR 15/09/2006 - Used by time trigger
	ASURA_MSG_TIMELINETRIGGER_SETTRIGGERTIME            = 45,   //RAR 15/09/2006 - Used by timeline trigger
	ASURA_MSG_PAUSETIMER                                = 46,   //RAR 18/09/2006 For time/timeline triggers
	ASURA_MSG_UNPAUSETIMER					            = 47,	//RAR 18/09/2006 For time/timeline triggers

	ASURA_MSG_COUNTEDTRIGGER_SETCOUNTER                 = 48,   
	ASURA_MSG_COUNTEDTRIGGER_ENABLEMESSAGE              = 49,   
	ASURA_MSG_COUNTEDTRIGGER_DISABLEMESSAGE             = 50,   
	ASURA_MSG_COUNTEDTRIGGER_SETTRIGGERCOUNT            = 51,

	ASURA_MSG_PROXY_ACTIVATE                            = 52,
	ASURA_MSG_PROXY_DEACTIVATE                          = 53,
	ASURA_MSG_PROXY_ADDTARGET                           = 54,
	ASURA_MSG_PROXY_REMOVETARGET                        = 55,
	ASURA_MSG_PROXY_SETTARGET				            = 56,

	ASURA_MSG_AXON_GAMESCENE_LEAVE_GAMESCENE_AI         = 57,	// no longer used as of 01/11/2008
	ASURA_MSG_AXON_GS2_PATHFIND_TO_NODE					= 58,
	ASURA_MSG_AXON_GAMESCENE_NEVER_STOP_AT_NODE         = 59,	// no longer used as of 01/11/2008
	ASURA_MSG_AXON_GAMESCENE_LEAVE_NODE_IF_THERE        = 60,	// no longer used as of 01/11/2008
	ASURA_MSG_AXON_GS2_ANIM_SEQUENCE_DATA               = 61,
	ASURA_MSG_AXON_GAMESCENE_TELEPORT_TO_NODE           = 62,	// no longer used as of 01/11/2008
	ASURA_MSG_UNUSED_1									= 63,	// no longer used as of 01/11/2008
    ASURA_MSG_UNUSED_2                                  = 64,	// no longer used as of 01/11/2008
    ASURA_MSG_UNUSED_3                                  = 65,	// no longer used as of 01/11/2008

	ASURA_MSG_AXON_GS2_DONT_STOP_AT_NODE				= 66,
	ASURA_MSG_AXON_GS2_SET_NODE_PARAMS					= 67,

	ASURA_MSG_LIFT_START								= 68,
	ASURA_MSG_LIFT_STOP									= 69,
	ASURA_MSG_LIFT_REVERSE								= 70,
	ASURA_MSG_LIFT_SETFLAGS								= 71,
	ASURA_MSG_LIFT_NODE_SETFLAGS						= 72,

	ASURA_MSG_DIALOGUE_FROMINSTANCE						= 73,	//Used more as a special code in the static messages. It shouldn't actually be sent as such
	ASURA_MSG_DIALOGUE_PLAYLINE							= 74,	//Plays a single dialogue line
	ASURA_MSG_DIALOGUE_PLAYLINEONENTITY					= 75,	//Plays a single dialogue line using the target as the guid to play it from

	ASURA_MSG_UNUSED_0									= 76,	// no longer used as of 01/11/2008

	ASURA_MSG_GUIMENU_ACTIVATE							= 77,	// allows a designer to setup a trigger that activates a menu

	ASURA_MSG_AXON_GAMESCENE_LEAVE_NODE			        = 78,   // no longer used as of 01/11/2008
	ASURA_MSG_AXON_GAMESCENE_ATTRACT_TO_NODE			= 79,   // no longer used as of 01/11/2008

	ASURA_MSG_DIALOGUE_CANCELSUBTITLE					= 80,	//Cancels the currently displayed dialogue system subtitle

	ASURA_MSG_AXON_GAMESCENE_ALWAYS_STOP_AT_NODE        = 81,	// no longer used as of 01/11/2008

	ASURA_MSG_LIFT_GOTO_NODE							= 82,

	ASURA_MSGID_TELEPORT_ENTITY							= 83,	// Teleports a specific entity.

	ASURA_MSG_CUTSCENE_SETCAMERA						= 84,	// Switches camera on an active cutscene

	ASURA_MSG_DYNAMICLIGHT_FADE							= 85,	// Fade control for DynamicLight entities

	ASURA_MSG_COUNTEDTRIGGER_ADDCOUNTER		            = 86,	// Adds (or subtracts) from a counted trigger's counter.

	ASURA_MSG_TIMETRIGGER_ADDTIME						= 87,	// Adds (or subtracts) from a time trigger's remaining time

	ASURA_MSG_CHANGE_CONSOLEVAR							= 88,	// Modify the value of a console variable.

	ASURA_MSG_AXON_GAMESCENE_ACTOR_ATTRACT_TO_NODE		= 89,	// no longer used as of 01/11/2008

	ASURA_MSG_SOUND_MIXER_PRESET_QUEUE					= 90,
	ASURA_MSG_SOUND_MIXER_PRESET_UNQUEUE				= 91,

	ASURA_MSG_SOUND_SET_REVERB							= 92,

	ASURA_MSG_AXON_GAMESCENE_SET_ATTRACTOR_FLAGS		= 93,   // no longer used as of 01/11/2008

	ASURA_MSG_PLAY_PFX_ON_ENTITY						= 94,	// Play a pfx on an entity

	ASURA_MSG_OBJECTIVE_READY							= 95,
	ASURA_MSG_OBJECTIVE_COMPLETE						= 96,
	ASURA_MSG_OBJECTIVE_FAIL							= 97,
	ASURA_MSG_OBJECTIVE_SKIP							= 98,

	ASURA_MSG_AXON_GS2_TAKE_LINK						= 99,	// Actor should take this link if it happens upon it whilst traversing gamescene.
	ASURA_MSG_AXON_GS2_LEAVE_NODE						= 100,	// Forces an actor to leave a node.
	ASURA_MSG_AXON_GS2_EXIT_GAMESCENE					= 101,	// Forces an actor to exit gamescene.
	ASURA_MSG_AXON_GS2_SET_LINK_WEIGHT					= 102,	// Sets the weight by which a link will be chosen from a node.
	ASURA_MSG_AXON_GS2_ANIM_CHANGE						= 103,	// Changes the animation of an actor on gamescene.

	ASURA_MSG_RESTORE_HEALTH							= 104,  // Restores the health of an entity to its max value

	ASURA_MSG_AXON_GS2_TELEPORT_TO_NODE					= 105,	// Teleports an actor on gamescene to a gamescene node.

	ASURA_MSG_CONTAINER_CHANGE_STATE					= 106,	// Change state of a container entity (input slot 0).

	ASURA_MSG_DYNAMIC_MUSIC_TRIGGER						= 107,	// Activate a dynamic music trigger

	ASURA_MSG_DIALOGUE_CONTROLLER_TOGGLE_LINE			= 108,	// Activate or Deactivate a line of dialogue
	ASURA_MSG_DIALOGUE_CONTROLLER_INTERRUPT				= 109,	// Interrupt playback of a dialogue event

	ASURA_MSG_CONTAINER_CHANGE_STATE_EXTENDED			= 110,	// Change state of a container entity (any input slot).

	ASURA_MSG_FMV_CONTROLLER_PLAY						= 111,	// Start playing an FMV
	ASURA_MSG_FMV_CONTROLLER_PAUSE						= 112,	// Pause FMV playback

	ASURA_MSG_TIMETRIGGER_ADDTOTRIGGERTIME				= 113,   //RAR 09/01/2009 - Used by time trigger

	ASURA_MSG_SPLITTER_TRIGGEROUTPUT		            = 114, //Trigger a single output from a splitter block
	
	ASURA_MSG_DIALOGUE_CONTROLLER_TRIGGER_LINE			= 115,	// Trigger a single line from a dialogue controller

	ASURA_MSG_APPLY_LINEAR_FORCE						= 116, 
	ASURA_MSG_APPLY_RADIAL_FORCE						= 117,

	

	//////////////////////////////////////////////////////////////////////////////////////////
	// (MH - 20.10.2006) Please add new messages to the list in Asura_Network::GetMsgIDDesc()
	// NY - 15 November 2006 - and Tools_Message_Editing.cpp (s_axMessageList)
	//////////////////////////////////////////////////////////////////////////////////////////

	ASURA_MSG_END_OF_STATIC_MESSAGES,

	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//RAR - Message IDs up to this point in the enumeration may be saved out to asura files,
	//so it is important that the values of existing ones remain unaltered.
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////


	ASURA_MSG_CLIENTUPDATE,
	ASURA_MSG_CLIENTCREATE,
#ifdef ASURA_ALLOW_INACTIVE_CLIENT_ENTITIES
	ASURA_MSG_CLIENTCREATEINACTIVE,
#endif //#ifdef ASURA_ALLOW_INACTIVE_CLIENT_ENTITIES
	ASURA_MSG_PACKEDMESSAGES,
	ASURA_MSG_NETMSGUPDATE,
	ASURA_MSG_CLIENT_REQUESTCREATEMSG,

	ASURA_MSG_VALIDCLIENTGUID,

	ASURA_MSG_PLAYERCONNECTED,
	ASURA_MSG_PLAYERDISCONNECTED,

	ASURA_MSG_CUTSCENECONTROLLER_REQ_PROFILE_CUTSCENE,
	ASURA_MSG_CUTSCENECONTROLLER_PROFILE_CUTSCENE,

	ASURA_MSG_CUTSCENECONTROLLER_ACTIVATE,
	ASURA_MSG_CUTSCENECONTROLLER_CLIENTUPDATE,
	ASURA_MSG_CUTSCENECONTROLLER_UPDATEEVENTSTATE,

#ifdef ASURA_SUPPORT_SERVERCUTSCENES	// the Gunfighter-style cutscenes with entities
	ASURA_MSG_SERVERCUTSCENEACTOR_CLIENTUPDATE_STANDARD,
	ASURA_MSG_SERVERCUTSCENEACTOR_CLIENTUPDATE_PRIMARYANIMATION,
	ASURA_MSG_SERVERCUTSCENEACTOR_CLIENTUPDATE_SECONDARYANIMATION,
	ASURA_MSG_SERVERCUTSCENEACTOR_CLIENTUPDATE_PRIMARYANIMATION_TOPOS,
	ASURA_MSG_SERVERCUTSCENEACTOR_CLIENTUPDATE_SECONDARYANIMATION_TOPOS,
	ASURA_MSG_SERVERCUTSCENEACTOR_CLIENTUPDATE_ADDATTACHMENTSHAPE,
	ASURA_MSG_SERVERCUTSCENEACTOR_CLIENTUPDATE_ADDATTACHMENTHIERARCHY,
	ASURA_MSG_SERVERCUTSCENEACTOR_CLIENTUPDATE_ADDATTACHMENTACTOR,
	ASURA_MSG_SERVERCUTSCENEACTOR_CLIENTUPDATE_ADDATTACHMENTENTITY,
	ASURA_MSG_SERVERCUTSCENEACTOR_CLIENTUPDATE_REMOVEATTACHMENT,
	ASURA_MSG_SERVERCUTSCENEACTORSHAPE_CLIENTUPDATE_STANDARD,
#endif // #ifdef ASURA_SUPPORT_SERVERCUTSCENES


	ASURA_MSG_HIDEFORCUTSCENE, //For hiding/unhiding objects that are associated with cutscene actors

	ASURA_MSG_GLASS_APPLYDECAL,
	ASURA_MSG_GLASS_SMASHWITHPOSITION,
	ASURA_MSG_GLASS_CLIENTUPDATE,

	ASURA_MSG_CREATE_BEAM,

	ASURA_MSG_MUSICSYSTEM_PLAY,

	ASURA_MSG_METAMUSIC_PLAY,
	ASURA_MSG_METAMUSIC_CHANGESTATE,
	ASURA_MSG_METAMUSIC_RESTARTLASTTRACK,

	ASURA_MSG_EXPLOSION_CREATE,

	ASURA_MSG_PLAYER_MULTIPLECOMMANDS,
	ASURA_MSG_PLAYER_POSITIONVALIDATED,
	ASURA_MSG_PLAYER_POSITIONCORRECTED,

#ifdef ASURA_SUPPORT_COMMAND_CONSOLE_REMOTE
	ASURA_MSG_COMMANDCONSOLE_REMOTE_NONCE_REQ,
	ASURA_MSG_COMMANDCONSOLE_REMOTE_NONCE,
	ASURA_MSG_COMMANDCONSOLE_REMOTE_EXEC_CMD,
	ASURA_MSG_COMMANDCONSOLE_REMOTE_EXEC_CMD_RESULT,
#endif // #ifdef ASURA_SUPPORT_COMMAND_CONSOLE_REMOTE

#ifdef ASURA_SUPPORT_MULTIPLAYER_COMMS
	ASURA_MSG_MULTIPLAYERCOMMS_TALK,
	ASURA_MSG_MULTIPLAYERCOMMS_TEAMTALK,
	ASURA_MSG_MULTIPLAYERCOMMS_TELL,
#endif // #ifdef ASURA_SUPPORT_MULTIPLAYER_COMMS

	// These two messages are hopefully temporary, and are only needed as long as look at triggers are only able to get camera data on the client
	ASURA_MSG_LOOKATTRIGGER_CLIENTCOUNTCHANGE,

	// voice data message should be handled (data gets forwarded to clients) on dedicated servers 
	// even if the server build doesn't support voice.
	ASURA_MSG_VOICEDATA,

	//Used by dialogue playback system to tell server a piece of dialogue has finished
	ASURA_MSG_NOTIFYFINISHED,

	//Message sent by the environmental texture anim controllers to update
	//the client machines
	ASURA_MSG_ENVTEXTUREANIMATION,

	// Standard skip cutscene message. In the first default version, this is sent from whoever skipped to every other machine in the game, so needs no forwarding on.
	// However, since all it does is skip playing cutscenes on the receiving machine it should be easy enough for other projects to reuse this and adjust who it's sent to if different behaviour is required.
	ASURA_MSG_SKIP_CUTSCENES,

	// message sent by dialogue trigger to cause some dialogue to play.
	ASURA_MSG_DIALOGUE_TRIGGER,

	// Messages for link/unlinking entities...
	ASURA_MSG_LINK_TO_PARENT,
	ASURA_MSG_LINK_TO_PARENT_WITH_PHYSICS,
	ASURA_MSG_LINK_TO_PARENT_BONE_RELATIVE,
	ASURA_MSG_LINK_TO_PARENT_STICKY,
	ASURA_MSG_UNLINK_FROM_PARENT,
	

	// Messages for the teleport system...
	ASURA_MSGID_TELEPORT,				// Teleports a client-entity to the specified location.
	ASURA_MSGID_BEGIN_PLAYER_TELEPORT,	// Begins teleportation of all player-related entities.

	//Messages for the Moves system
	ASURA_MSG_MOVE_START,
	ASURA_MSG_MOVE_ABORT,
	ASURA_MSG_MOVE_FINISHED, // Renamed from ASURA_MSG_MOVE_FINISH to make it clearer that this is just intended to report the finishing of a move, not to actively finish a move (unlike the previous two messages, which directly start or abort a move respectively).
	ASURA_MSG_MOVECHAINCOMPLETE, // Slightly different to the above, this is only sent when no moves are playing any more, instead of after each move in a chain.

	//Attractors (Env hooks)
	ASURA_MSG_ATTRACTOR_FLAGS,

	//Play sound event (for lifts)
	ASURA_MSG_PLAYSOUNDEVENT,

	//streaming background sound system
	ASURA_MSG_STREAMINGBACKGROUNDSOUND_FLAGS,
	
#ifdef ASURA_USE_AXON
	ASURA_MSG_AXON_GS2_ATTRACTOR_PULSE,
	ASURA_MSG_AXON_GS2_ATTRACTOR_CANCEL,
#endif

	ASURA_MSG_CONTAINER_CHANGE_HEALTH,
	ASURA_MSG_CONTAINER_CLIENTUPDATE_EXTENDED1,
	ASURA_MSG_CONTAINER_CLIENTUPDATE_EXTENDED,

	ASURA_MSG_DIALOGUE_PLAYLINE_CONTROLLER,
	ASURA_MSG_DIALOGUE_STOPLINE_CONTROLLER,

	ASURA_MSG_COLLISIONFX_CLIENTUPDATE,
	ASURA_MSG_COLLISIONFX_CLIENTCREATEDECAL,

	//////////////////////////////////////////////////////////////////////////////////////////
	// (MH - 20.10.2006) Please add new messages to the list in Asura_Network::GetMsgIDDesc()
	//////////////////////////////////////////////////////////////////////////////////////////

	ASURA_MSG_END_OF_ENGINE_MESSAGES,	// used to shift project range into consecutive range for better packing.
	
	// note that using platform-specific messages will break the packing mentioned above.
	// If this is a problem, the platform messages could be put in the independent list.
	ASURA_MSG_PLATFORM_SPECIFIC = 0x4000,//start of asura platform specific messages

	ASURA_MSG_PROJECT_SPECIFIC = 0x8000,//start of project specific messages

	// using these message IDs will also break the packing mentioned above.
	ASURA_MSG_TRANSPORT_LAYER = 0xF000,// start of transport layer messages e.g. connection request, enum host request, etc.

};

/// Kevin Lea - 06/12/2001 12:41:17 - Asura_Message
/// Originally I'd planned Asura_Message to be a simple
/// base class with other messages derived from it -
/// this breaks down when you send things across networks
/// and realise that memorywise it's just easier to 
/// have a simply allocated data block; a deconstructor
/// can't do much with an object that hasn't actually
/// been through a constructor... 
class Asura_Message
{
	friend class Asura_Network;
	friend class Asura_MessageHeader;
	friend class Tools_Entity_Simulation;

public:

	Asura_Message() {}

	template<class T>
	void GetData( T ** pptData)
	{
		Asura_Assert(m_bAllocatedOwnData, "returning non-const ptr to data we don't own");
		Asura_Assert(GetDataSize() == sizeof(T), "incorrect data size");
		*pptData = reinterpret_cast<T*>(m_pData);
	}

	template<class T>
	void GetData( T const ** pptData) const
	{
		Asura_Assert(GetDataSize() == sizeof(T), "incorrect data size");
		*pptData = reinterpret_cast<const T*>(m_pData);
	}

	const void* GetData(void) const
	{
		return m_pData;
	}
	
	void* GetData(void) 
	{
		Asura_Assert(m_bAllocatedOwnData, "returning non-const ptr to data we don't own");
		return m_pData;
	}
	
    // (MH - 19.10.2002) added this for checking message format hasn't changed.
    u_int GetDataSize(void) const
    {
        return m_uDataSize;
    }

    void SetMsgID( u_short usMsgID )
    {
        m_usMsgID = usMsgID;
    }
	u_short GetMsgID(void) const
	{
		return m_usMsgID;
	}

    void SetEntityClassification(u_short usEntityClassification)
	{
		m_usEntityClassification = usEntityClassification;
	}
	u_short GetEntityClassification(void) const
	{
		return m_usEntityClassification;
	}

	void UseGuaranteedDelivery(void)
	{
		m_bGuaranteed = true;
	}
	
	bool IsUsingGuaranteedDelivery(void) const
	{
		return m_bGuaranteed;
	}

	// AW - 31/01/03 - A note about forwarded messages:
	// The idea behind this is that sometimes you want entities to forward
	// messages to other entities. However, if those entities then send the
	// message back again, you can end up sending messages recursively. By
	// marking messages as forwarded it is easy to find out if this message
	// has already been forwarded. This was implemented for door groups.
	void SetAsForwarded(void)
	{
		m_bIsForwarded = true;
	}
	bool IsForwarded() const
	{
		return m_bIsForwarded;
	}

	float GetSentTime() const
	{
		return SentTime;
	}

	void SetFromGuid(Asura_Guid uGuid)
	{
		From = uGuid;
	}

	Asura_Guid GetFromGuid() const
	{
		return From;
	}

	void SetToGuid(Asura_Guid uGuid)
	{
		To = uGuid;
	}

	Asura_Guid GetToGuid() const
	{
		return To;
	}

	Asura_Guid		To;
	Asura_Guid		From;

	// (MH - 25.11.2003) SentTime should no longer be set by calling code.
	// It is set by Asura_Network::Send(). 
	// DeliveryTime is not used so there is no need to set it.
	float			SentTime;
	float			DeliveryTime;

private:
	Asura_Message( const Asura_Message& );
	Asura_Message& operator=( const Asura_Message& );

	unsigned short	m_usMsgID;
    unsigned short	m_usEntityClassification;
	unsigned int	m_uDataSize;
	void*			m_pData;

	union
	{
		struct
		{
			unsigned m_bGuaranteed:1,
					m_bIsForwarded:1,
					m_bAllocatedOwnData:1;
		};
		unsigned m_uFlags;
	};

};

#ifdef ASURA_NETMSG_PACK_ALL_DATA
class Asura_Message_Registration
{
public:

	// static member functions
	static const Asura_NetMsg* RegisterNetMsg(u_short usMsgID, u_short usEntityClassification);
};
#endif

// (MH - 05.01.2004) Asura_Message_Header is now called Asura_MessageHeader, 
// and is defined in Asura_MessageHeader.h, as it is only used by the external 
// networking stuff.

/// Kevin Lea - 18/12/2001 17:04:55 - data fields for some generic messages

class Asura_MsgData_ValidClientGuid
{
public:
	Asura_Guid Guid;

#ifdef ASURA_NETMSG_PACK_ALL_DATA
	void RegisterFields(Asura_NetMsg* pxNetMsg) const;
	static u_char GetNumFields() { return 1; }
#endif
};

class Asura_MsgData_PlayerConnected
{
public:
	Asura_Guid PlayerGuid;

#ifdef ASURA_NETMSG_PACK_ALL_DATA
	void RegisterFields(Asura_NetMsg* pxNetMsg) const;
	static u_char GetNumFields() { return 1; }
#endif
};

class Asura_MsgData_PlayerDisconnected
{
public:
	Asura_Guid PlayerGuid;
	ASURA_NETWORK_DISCONNECT_REASON m_eReason;

#ifdef ASURA_NETMSG_PACK_ALL_DATA
	void RegisterFields(Asura_NetMsg* pxNetMsg) const;
	static u_char GetNumFields() { return 2; }
#endif
};

class Asura_MsgData_PlaySoundEvent
{
public:
	Asura_Hash_ID m_uSoundEventHash;
};

class Asura_MsgData_LiftCall
{
public:
	void Initialise()
	{
		uStopNumber = 0;
	}
	unsigned uStopNumber;
};

class Asura_Message_ActivateCutsceneWithTime
{
public:
	void Initialise()
	{
		m_fStartTime = 0.0f;
	}
	float m_fStartTime;
};

class Asura_MsgData_PlayerPositionCorrection
{
public:
	Asura_Vector_3 m_xPosition;
	Asura_Vector_3 m_xLinImpulse;
	u_short m_bIsInContactWithFloor:1;
	u_short m_usPad:15;
	u_short m_usUpdateID;
};

#endif//__ASURA_MESSAGE_H__
