;BitStreams are wrapped. If you need them, add the functions here!

;-------------------------;
;MESSAGE TYPES
;-------------------------;


	;//
	;// RESERVED TYPES - DO Not CHANGE THESE
	;// All types from RakPeer
	;//
	;/// These types are never returned To the user.
	;/// Ping from a connected system.  Update timestamps (internal use only)
	Const ID_INTERNAL_PING = 0  
	;/// Ping from an unconnected system.  Reply but do Not update timestamps. (internal use only)
	Const ID_PING = 1
	;/// Ping from an unconnected system.  Only reply If we have open connections. Do Not update timestamps. (internal use only)
	Const ID_PING_OPEN_CONNECTIONS = 2
	;/// Pong from a connected system.  Update timestamps (internal use only)
	Const ID_CONNECTED_PONG = 3
	;/// Asking For a New connection (internal use only)
	Const ID_CONNECTION_REQUEST = 4
	;/// Connecting To a secured server/peer (internal use only)
	Const ID_SECURED_CONNECTION_RESPONSE = 5
	;/// Connecting To a secured server/peer (internal use only)
	Const ID_SECURED_CONNECTION_CONFIRMATION = 6
	;/// Packet that tells us the packet contains an integer ID To name mapping For the remote system (internal use only)
	Const ID_RPC_MAPPING = 7
	;/// A reliable packet To detect lost connections (internal use only)
	Const ID_DETECT_LOST_CONNECTIONS = 8
	;/// Offline message so we know when To reset And start a New connection (internal use only)
	Const ID_OPEN_CONNECTION_REQUEST = 9
	;/// Offline message response so we know when To reset And start a New connection (internal use only)
	Const ID_OPEN_CONNECTION_REPLY = 10
	;/// Remote procedure call (internal use only)
	Const ID_RPC = 11
	;/// Remote procedure call reply =  For RPCs that Return Data (internal use only)
	Const ID_RPC_REPLY = 12
	;/// RakPeer - Same as ID_ADVERTISE_SYSTEM, but intended For internal use rather than being passed To the user. Second Byte indicates Type. Used currently For NAT punchthrough For receiver port advertisement. See ID_NAT_ADVERTISE_RECIPIENT_PORT
	Const ID_OUT_OF_BAND_INTERNAL = 13


	;//
	;// USER TYPES - DO Not CHANGE THESE
	;//

	;/// RakPeer - In a client/server environment =  our connection request To the server has been accepted.
	Const ID_CONNECTION_REQUEST_ACCEPTED = 14
	;/// RakPeer - Sent To the player when a connection request cannot be completed due To inability To connect.
	Const ID_CONNECTION_ATTEMPT_FAILED = 15
	;/// RakPeer - Sent a connect request To a system we are currently connected To.
	Const ID_ALREADY_CONNECTED = 16
	;/// RakPeer - A remote system has successfully connected.
	Const ID_NEW_INCOMING_CONNECTION = 17
	;/// RakPeer - The system we attempted To connect To is Not accepting New connections.
	Const ID_NO_FREE_INCOMING_CONNECTIONS = 18
	;/// RakPeer - The system specified in Packet::systemAddress has disconnected from us.  For the client =  this would mean the server has shutdown.
	Const ID_DISCONNECTION_NOTIFICATION = 19
	;/// RakPeer - Reliable packets cannot be delivered To the system specified in Packet::systemAddress.  The connection To that system has been closed.
	Const ID_CONNECTION_LOST = 20
	;/// RakPeer - We preset an RSA Public key which does Not match what the system we connected To is using.
	Const ID_RSA_PUBLIC_KEY_MISMATCH = 21
	;/// RakPeer - We are banned from the system we attempted To connect To.
	Const ID_CONNECTION_BANNED = 22
	;/// RakPeer - The remote system is using a password And has refused our connection because we did Not set the correct password.
	Const ID_INVALID_PASSWORD = 23
	;/// RakPeer - A packet has been tampered with in transit.  The sender is contained in Packet::systemAddress.
	Const ID_MODIFIED_PACKET = 24
	;/// RakPeer - The four bytes following this Byte represent an unsigned Int which is automatically modified by the difference in system times between the sender And the recipient. Requires that you call SetOccasionalPing.
	Const ID_TIMESTAMP = 25
    ;/// RakPeer - Pong from an unconnected system.  First Byte is Const ID_PONG =  second SizeOf(RakNetTime) bytes is the ping =  following bytes is system specific enumeration Data.
	Const ID_PONG = 26
	;/// RakPeer - Inform a remote system of our IP/Port =  plus some offline Data
	Const ID_ADVERTISE_SYSTEM = 27
	;/// ConnectionGraph plugin - In a client/server environment =  a client other than ourselves has disconnected gracefully.  Packet::systemAddress is modified To reflect the systemAddress of this client.
	Const ID_REMOTE_DISCONNECTION_NOTIFICATION = 28
	;/// ConnectionGraph plugin - In a client/server environment =  a client other than ourselves has been forcefully dropped. Packet::systemAddress is modified To reflect the systemAddress of this client.
	Const ID_REMOTE_CONNECTION_LOST = 29
	;/// ConnectionGraph plugin - In a client/server environment =  a client other than ourselves has connected.  Packet::systemAddress is modified To reflect the systemAddress of this client.
	Const ID_REMOTE_NEW_INCOMING_CONNECTION = 30
	;// RakPeer - Downloading a large message. Format is Const ID_DOWNLOAD_PROGRESS (MessageID) =  partCount (unsigned Int) =  partTotal (unsigned Int) =  partLength (unsigned Int) =  First part Data (length <= MAX_MTU_SIZE)
	Const ID_DOWNLOAD_PROGRESS = 31

	;/// FileListTransfer plugin - Setup Data
	Const ID_FILE_LIST_TRANSFER_HEADER = 32
	;/// FileListTransfer plugin - A file
	Const ID_FILE_LIST_TRANSFER_FILE = 33

	;/// DirectoryDeltaTransfer plugin - Request from a remote system For a download of a directory
	Const ID_DDT_DOWNLOAD_REQUEST = 34
	
	;/// RakNetTransport plugin - Transport provider message =  used For remote console
	Const ID_TRANSPORT_STRING = 35

	;/// ReplicaManager plugin - Create an Object
	Const ID_REPLICA_MANAGER_CONSTRUCTION = 36
	;/// ReplicaManager plugin - Destroy an Object
	Const ID_REPLICA_MANAGER_DESTRUCTION = 37
	;/// ReplicaManager plugin - Changed scope of an Object
	Const ID_REPLICA_MANAGER_SCOPE_CHANGE = 38
	;/// ReplicaManager plugin - Serialized Data of an Object
	Const ID_REPLICA_MANAGER_SERIALIZE = 39
	;/// ReplicaManager plugin - New connection, about To send all world objects
	Const ID_REPLICA_MANAGER_DOWNLOAD_STARTED = 40
	;/// ReplicaManager plugin - Finished downloading all serialized objects
	Const ID_REPLICA_MANAGER_DOWNLOAD_COMPLETE = 41

	;/// ConnectionGraph plugin - Request the connection graph from another system
	Const ID_CONNECTION_GRAPH_REQUEST = 42
	;/// ConnectionGraph plugin - Reply To a connection graph download request
	Const ID_CONNECTION_GRAPH_REPLY = 43
	;/// ConnectionGraph plugin - Update edges / nodes For a system with a connection graph
	Const ID_CONNECTION_GRAPH_UPDATE = 44
	;/// ConnectionGraph plugin - Add a New connection To a connection graph
	Const ID_CONNECTION_GRAPH_NEW_CONNECTION = 45
	;/// ConnectionGraph plugin - Remove a connection from a connection graph - connection was abruptly lost
	Const ID_CONNECTION_GRAPH_CONNECTION_LOST = 46
	;/// ConnectionGraph plugin - Remove a connection from a connection graph - connection was gracefully lost
	Const ID_CONNECTION_GRAPH_DISCONNECTION_NOTIFICATION = 47

	;/// Router plugin - route a message through another system
	Const ID_ROUTE_AND_MULTICAST = 48

	;/// RakVoice plugin - Open a communication channel
	Const ID_RAKVOICE_OPEN_CHANNEL_REQUEST = 49
	;/// RakVoice plugin - Communication channel accepted
	Const ID_RAKVOICE_OPEN_CHANNEL_REPLY = 50
	;/// RakVoice plugin - Close a communication channel
	Const ID_RAKVOICE_CLOSE_CHANNEL = 51
	;/// RakVoice plugin - Voice Data
	Const ID_RAKVOICE_DATA = 52

	;/// Autopatcher plugin - Get a list of files that have changed since a certain date
	Const ID_AUTOPATCHER_GET_CHANGELIST_SINCE_DATE = 53
	;/// Autopatcher plugin - A list of files To create
	Const ID_AUTOPATCHER_CREATION_LIST = 54
	;/// Autopatcher plugin - A list of files To Delete
	Const ID_AUTOPATCHER_DELETION_LIST = 55
	;/// Autopatcher plugin - A list of files To get patches For
	Const ID_AUTOPATCHER_GET_PATCH = 56
	;/// Autopatcher plugin - A list of patches For a list of files
	Const ID_AUTOPATCHER_PATCH_LIST = 57
	;/// Autopatcher plugin - Returned To the user: An error from the database repository For the autopatcher.
	Const ID_AUTOPATCHER_REPOSITORY_FATAL_ERROR = 58
	;/// Autopatcher plugin - Finished getting all files from the autopatcher
	Const ID_AUTOPATCHER_FINISHED_INTERNAL = 59
	Const ID_AUTOPATCHER_FINISHED = 60
	;/// Autopatcher plugin - Returned To the user: You must restart the application To finish patching.
	Const ID_AUTOPATCHER_RESTART_APPLICATION = 61

	;/// NATPunchthrough plugin - Intermediary got a request To help punch through a nat
	Const ID_NAT_PUNCHTHROUGH_REQUEST = 62
	;/// NATPunchthrough plugin - Intermediary cannot complete the request because the target system is Not connected
	Const ID_NAT_TARGET_NOT_CONNECTED = 63
	;/// NATPunchthrough plugin - While attempting To connect =  we lost the connection To the target system
	Const ID_NAT_TARGET_CONNECTION_LOST = 64
	;/// NATPunchthrough plugin - Internal message To connect at a certain time
	Const ID_NAT_CONNECT_AT_TIME = 65
	;/// NATPunchthrough plugin - Internal message To send a message (To punch through the nat) at a certain time
	Const ID_NAT_SEND_OFFLINE_MESSAGE_AT_TIME = 66
	;/// NATPunchthrough plugin - The facilitator is already attempting this connection
	Const ID_NAT_IN_PROGRESS = 67


	;/// LightweightDatabase plugin - Query
	Const ID_DATABASE_QUERY_REQUEST = 68
	;/// LightweightDatabase plugin - Update
	Const ID_DATABASE_UPDATE_ROW = 69
	;/// LightweightDatabase plugin - Remove
	Const ID_DATABASE_REMOVE_ROW = 70
	;/// LightweightDatabase plugin - A serialized table.  Bytes 1+ contain the table.  Pass To TableSerializer::DeserializeTable
	Const ID_DATABASE_QUERY_REPLY = 71
	;/// LightweightDatabase plugin - Specified table Not found
	Const ID_DATABASE_UNKNOWN_TABLE = 72
	;/// LightweightDatabase plugin - Incorrect password
	Const ID_DATABASE_INCORRECT_PASSWORD = 73
	
	;/// ReadyEvent plugin - Set the ready state For a particular system
	Const ID_READY_EVENT_SET = 74
	;/// ReadyEvent plugin - Unset the ready state For a particular system
	Const ID_READY_EVENT_UNSET = 75
	;/// All systems are in state ID_READY_EVENT_SET
	Const ID_READY_EVENT_ALL_SET = 76
	;/// ReadyEvent plugin - Request of ready event state - used For pulling Data when newly connecting
	Const ID_READY_EVENT_QUERY = 77

	;/// Lobby packets. Second Byte indicates Type.
	Const ID_LOBBY_GENERAL = 78

	;/// Auto RPC procedure call
	Const ID_AUTO_RPC_CALL = 79

	;/// Auto RPC functionName To index mapping
	Const ID_AUTO_RPC_REMOTE_INDEX = 80

	;/// Auto RPC error code
	;/// See AutoRPC.h For codes, stored in packet->Data[1]
	Const ID_RPC_REMOTE_ERROR = 81

	
	;// For the user To use.  Start your First enumeration at this value.
	Const ID_USER_PACKET_ENUM = 82



;-------------------------;
;MESSAGE PRIORITIES
;-------------------------;
Const	HIGH_PRIORITY= 1
Const	MEDIUM_PRIORITY= 2
Const	LOW_PRIORITY= 3

;-------------------------;
;MESSAGE RELIABILITY
;-------------------------;
Const UNRELIABLE= 0
Const UNRELIABLE_SEQUENCED= 1
Const RELIABLE= 2
Const RELIABLE_ORDERED= 3
Const RELIABLE_SEQUENCED= 4

;-------------------------;
;UNASSIGNED PLAYER ID
;-------------------------;
UNASSIGNED_SYSTEM_ADDRESS= RN_GetUNASSIGNED_SYSTEM_ADDRESS()
UNASSIGNED_NETWORK_ID= RN_GetUNASSIGNED_NETWORK_ID()

Function RN_GetPacketIdentifier%(packet%)
	local msg$ = RN_PacketGetData(packet)
	;Return Asc(msg[0..1])
	Return Asc(msg)
End Function