Пример #1
0
        /// <summary>
        /// Formats a ServerToClientMessage with logout message data.
        /// </summary>
        /// <param name="mpr">Player record of the player logging out.</param>
        /// <param name="turnNumber">Current turn number.</param>
        /// <param name="wm"></param>
        public static void CreateCharacterLogoutMessage(MasterPlayerRecord mpr, int turnNumber, ServerToClientMessage wm)
        {
            if (wm.Sender == null)
                throw (new Exception("Character has null sender, this will crash the MessageSender!"));

            if (mpr.State != ClientState.InWorld)
                wm.MessageType = mpr.LogoutCharacterGranted ? MessageType.S2C_PlayerLoggedOut : MessageType.S2C_LogoutDenied;
            else
                wm.MessageType = mpr.LogoutCharacterGranted ? MessageType.S2C_CharacterLoggedOut : MessageType.S2C_LogoutDenied;

            wm.Code = (int)PlayerAction.RemoveEntity;
            wm.Data = mpr.LogoutCharacterGranted ? "Logout OK" : "Logout denied";
            wm.TurnNumber = turnNumber;
            wm.Buffer = BitConverter.GetBytes(mpr.CharacterId);
            wm.DeliveryChannel = 0;
            wm.DeliveryMethod = NetDeliveryMethod.ReliableUnordered;
        }
Пример #2
0
 /// <summary>
 /// Adds a MPR to the table.
 /// </summary>
 /// <param name="mpr"></param>
 public void Add(MasterPlayerRecord mpr)
 {
     rwls.EnterWriteLock();
     try
     {
         AsteriaData.LinkedNode<MasterPlayerRecord> node = list.Add(mpr);
         epMap.Add(mpr.Sender.RemoteEndpoint, node);
         if (mpr.AccountId > 0)
             aIdMap.Add(mpr.AccountId, node);
         if (mpr.CharacterId > 0)
             cIdMap.Add(mpr.CharacterId, node);
     }
     finally
     {
         rwls.ExitWriteLock();
     }
 }