void Server_ReceiveChangeMainControlledUnit( RemoteEntityWorld sender,
ReceiveDataReader reader)
{
//not safe. client can send networkUIN of any unit from any place.
//check to ensure that other players can not send messages to another player
if( !Server_CheckRemoteEntityWorldAssociatedWithThisIntellect( sender ) )
return;
uint unitNetworkUIN = reader.ReadVariableUInt32();
if( !reader.Complete() )
return;
Unit unit = Entities.Instance.GetByNetworkUIN( unitNetworkUIN ) as Unit;
//unit is not exists
if( unit == null )
return;
ServerOrSingle_ChangeMainControlledUnit( unit );
}