Exemplo n.º 1
0
        private static void OnChangeOwnersRequest(ref ChangeOwnershipsMsg msg, MyNetworkClient sender)
        {
            MyCubeBlock block = null;
            int         c     = 0;

            while (c < msg.Requests.Count)
            {
                var request = msg.Requests[c];
                if (MyEntities.TryGetEntityById <MyCubeBlock>(request.BlockId, out block))
                {
                    if (Sync.IsServer && ((block.IDModule.Owner == 0) || block.IDModule.Owner == msg.RequestingPlayer || (request.Owner == 0)))
                    {
                        c++;
                    }
                    else
                    {
                        System.Diagnostics.Debug.Fail("Invalid ownership change request!");
                        msg.Requests.RemoveAtFast(c);
                    }
                }
                else
                {
                    c++;
                }
            }

            if (msg.Requests.Count > 0)
            {
                OnChangeOwners(ref msg, sender);
                Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success);
            }
        }
Exemplo n.º 2
0
 private static void OnChangeOwners(ref ChangeOwnershipsMsg msg, MyNetworkClient sender)
 {
     foreach (var request in msg.Requests)
     {
         MyCubeBlock block = null;
         if (MyEntities.TryGetEntityById <MyCubeBlock>(request.BlockId, out block))
         {
             block.ChangeOwner(request.Owner, msg.ShareMode);
         }
     }
 }
Exemplo n.º 3
0
        public static void ChangeOwnersRequest(MyOwnershipShareModeEnum shareMode, List <MySingleOwnershipRequest> requests, long requestingPlayer)
        {
            System.Diagnostics.Debug.Assert((int)shareMode >= 0);

            var msg = new ChangeOwnershipsMsg();

            msg.RequestingPlayer = requestingPlayer;
            msg.ShareMode        = shareMode;

            msg.Requests = requests;

            Sync.Layer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
        }
Exemplo n.º 4
0
 private static void OnChangeOwners(ref ChangeOwnershipsMsg msg, MyNetworkClient sender)
 {
     foreach (var request in msg.Requests)
     {
         MyCubeBlock block = null;
         if (MyEntities.TryGetEntityById<MyCubeBlock>(request.BlockId, out block))
         {
             block.ChangeOwner(request.Owner, msg.ShareMode);
         }
     }
 }
Exemplo n.º 5
0
        private static void OnChangeOwnersRequest(ref ChangeOwnershipsMsg msg, MyNetworkClient sender)
        {
            MyCubeBlock block = null;
            int c = 0;

            while (c < msg.Requests.Count)
            {
                var request = msg.Requests[c];
                if (MyEntities.TryGetEntityById<MyCubeBlock>(request.BlockId, out block))
                {
                    if (Sync.IsServer && ((block.IDModule.Owner == 0) || block.IDModule.Owner == msg.RequestingPlayer || (request.Owner == 0)))
                    {
                        c++;
                    }
                    else
                    {
                        System.Diagnostics.Debug.Fail("Invalid ownership change request!");
                        msg.Requests.RemoveAtFast(c);
                    }
                }
                else 
                {
                    c++;
                }
            }

            if (msg.Requests.Count > 0)
            {
                OnChangeOwners(ref msg, sender);
                Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success);
            }
        }
Exemplo n.º 6
0
        public static void ChangeOwnersRequest(MyOwnershipShareModeEnum shareMode, List<MySingleOwnershipRequest> requests, long requestingPlayer)
        {
            System.Diagnostics.Debug.Assert((int)shareMode >= 0);

            var msg = new ChangeOwnershipsMsg();
            msg.RequestingPlayer = requestingPlayer;
            msg.ShareMode = shareMode;

            msg.Requests = requests;

            Sync.Layer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
        }
Exemplo n.º 7
0
        public static void ChangeOwnersRequest(MyOwnershipShareModeEnum shareMode, List<MySingleOwnershipRequest> requests)
        {
            System.Diagnostics.Debug.Assert((int)shareMode >= 0);

            var msg = new ChangeOwnershipsMsg();
            msg.RequestingPlayer = MySession.LocalPlayerId; // CH: This is (probably) set only via GUI. If you intend to change this, you'll need playerId
            msg.ShareMode = shareMode;

            msg.Requests = requests;

            Sync.Layer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
        }