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); } }
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); } } }
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); }
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); } } }
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); } }
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); }
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); }