Inheritance: System.EventArgs
Exemple #1
0
        private static void EventSink_DeleteCharacter(DeleteRequestEventArgs e)
        {
            NetState state = e.State;
            int index = e.Index;
            Account acct = state.Account as Account;

            if (acct != null && index >= 0 && index < acct.Length)
            {
                Mobile m = acct[index];
                if (m != null && m.Player)
                {
                    m_ReservedNames.Remove(m.Name.ToLower());
                }
            }
        }
Exemple #2
0
        private static void EventSink_DeleteCharacter(DeleteRequestEventArgs e)
        {
            NetState state = e.State;
            int      index = e.Index;
            Account  acct  = state.Account as Account;

            if (acct != null && index >= 0 && index < acct.Length)
            {
                Mobile m = acct[index];
                if (m != null && m.Player)
                {
                    m_ReservedNames.Remove(m.Name.ToLower());
                }
            }
        }
Exemple #3
0
 public static void InvokeDeleteRequest( DeleteRequestEventArgs e )
 {
     if ( DeleteRequest != null )
         DeleteRequest( e );
 }
		private static void EventSink_DeleteRequest( DeleteRequestEventArgs e )
		{
			NetState state = e.State;
			int index = e.Index;

			Account acct = state.Account as Account;

			if ( acct == null )
			{
				state.Dispose();
			}
			else if ( index < 0 || index >= acct.Length )
			{
				state.Send( new DeleteResult( DeleteResultType.BadRequest ) );
				state.Send( new CharacterListUpdate( acct ) );
			}
			else
			{
				Mobile m = acct[index];

				if ( m == null )
				{
					state.Send( new DeleteResult( DeleteResultType.CharNotExist ) );
					state.Send( new CharacterListUpdate( acct ) );
				}
				else if ( m.NetState != null )
				{
					state.Send( new DeleteResult( DeleteResultType.CharBeingPlayed ) );
					state.Send( new CharacterListUpdate( acct ) );
				}
				else if ( RestrictDeletion && DateTime.Now < (m.CreationTime + DeleteDelay) )
				{
					state.Send( new DeleteResult( DeleteResultType.CharTooYoung ) );
					state.Send( new CharacterListUpdate( acct ) );
				}
				else if ( m.AccessLevel == AccessLevel.Player && Region.Find( m.LogoutLocation, m.LogoutMap ).GetRegion( typeof( Jail ) ) != null )	//Don't need to check current location, if netstate is null, they're logged out
				{
					state.Send( new DeleteResult( DeleteResultType.BadRequest ) );
					state.Send( new CharacterListUpdate( acct ) );
				}
				else
				{
					Console.WriteLine( "Client: {0}: Deleting character {1} (0x{2:X})", state, index, m.Serial.Value );

					acct.Comments.Add( new AccountComment( "System", String.Format( "Character #{0} {1} deleted by {2}", index + 1, m, state ) ) );

					m.Delete();
					state.Send( new CharacterListUpdate( acct ) );
				}
			}
		}
		private static void EventSink_DeleteRequest( DeleteRequestEventArgs e )
		{
			NetState state = e.State;
			int index = e.Index;

			Account acct = state.Account as Account;

			if ( acct == null )
			{
				state.Dispose();
			}
			else if ( index < 0 || index >= acct.Length )
			{
				state.Send( new DeleteResult( DeleteResultType.BadRequest ) );
				state.Send( new CharacterListUpdate( acct ) );
			}
			else
			{
				Mobile m = acct[index];

				if ( m == null )
				{
					state.Send( new DeleteResult( DeleteResultType.CharNotExist ) );
					state.Send( new CharacterListUpdate( acct ) );
				}
				else if ( m.NetState != null )
				{
					state.Send( new DeleteResult( DeleteResultType.CharBeingPlayed ) );
					state.Send( new CharacterListUpdate( acct ) );
				}
				else if ( RestrictDeletion && DateTime.Now < (m.CreationTime + DeleteDelay) )
				{
					state.Send( new DeleteResult( DeleteResultType.CharTooYoung ) );
					state.Send( new CharacterListUpdate( acct ) );
				}
				else
				{
					Console.WriteLine( "Client: {0}: Deleting character {1} (0x{2:X})", state, index, m.Serial.Value );

					acct.Comments.Add( new AccountComment( "System", String.Format( "Character #{0} {1} deleted by {2}", index+1, m, state ) ) );

					m.Delete();
					state.Send( new CharacterListUpdate( acct ) );
				}
			}
		}
Exemple #6
0
		public static void InvokeDeleteRequest(DeleteRequestEventArgs e)
		{
			if (DeleteRequest != null)
			{
				foreach (DeleteRequestEventHandler currentDelegate in DeleteRequest.GetInvocationList())
				{
					try
					{
						currentDelegate.Invoke(e);
					}
					catch (Exception ex)
					{
						// Log an exception
						EventSink.InvokeLogException(new LogExceptionEventArgs(ex));
					}
				}
			}
		}
Exemple #7
0
 public static void InvokeDeleteRequest(DeleteRequestEventArgs e)
 {
     DeleteRequest?.Invoke(e);
 }
		private static void EventSink_DeleteRequest(DeleteRequestEventArgs e)
		{
			NetState state = e.State;
			int index = e.Index;

			Account acct = state.Account as Account;

			if (acct == null)
			{
				state.Dispose();
			}
			else if (index < 0 || index >= 5)
			{
				state.Send(new DeleteResult(DeleteResultType.BadRequest));
				state.Send(new CharacterListUpdate(acct));
			}
			else
			{
				Mobile m = acct[index];

				if (m == null)
				{
					state.Send(new DeleteResult(DeleteResultType.CharNotExist));
					state.Send(new CharacterListUpdate(acct));
				}
				else if (m.NetState != null)
				{
					state.Send(new DeleteResult(DeleteResultType.CharBeingPlayed));
					state.Send(new CharacterListUpdate(acct));
				}
				else if (RestrictDeletion && DateTime.Now < (m.CreationTime + DeleteDelay))
				{
					state.Send(new DeleteResult(DeleteResultType.CharTooYoung));
					state.Send(new CharacterListUpdate(acct));
				}
				else
				{
					bool bDelete = true;

					if (m is Server.Mobiles.PlayerMobile)
					{
						Server.Mobiles.PlayerMobile pm = (Server.Mobiles.PlayerMobile)m;
						System.Collections.ArrayList houses = Multis.BaseHouse.GetHouses(pm);
						if (houses.Count > 0)
						{
							if (acct.Count > 1)
							{
								Mobile newOwner = null;
								//find a non-deleted, non-null character on the account
								for (int i = 0; i < acct.Count; i++)
								{
									if (index != i)
									{
										if (acct[i] != null)
										{
											if (!acct[i].Deleted)
											{
												newOwner = acct[i];
											}
										}
									}
								}

								if (newOwner == null) //sanity check, should never happen
								{
									System.Console.WriteLine("Sanity check failed: newOwner == null!");
									bDelete = false;
									state.Send(new DeleteResult(DeleteResultType.BadRequest));
								}
								else
								{
									for (int i = 0; i < houses.Count; ++i)
									{
										if (houses[i] is Server.Multis.BaseHouse)
										{
											Server.Multis.BaseHouse house = (Server.Multis.BaseHouse)houses[i];
											if (house != null)
											{
												if (house.Owner == m) //another sanity check - house.Owner should always be m at this point!
												{
													//swap to new owner
													house.Owner = newOwner;
												}
											}
										}
									}
								}
							}
							else
							{
								//If account only has one character, then refuse to delete the houseowner
								bDelete = false;
								state.Send(new DeleteResult(DeleteResultType.BadRequest));
							}
						}
					}

					if (bDelete)
					{
						Console.WriteLine("Client: {0}: Deleting character {1} (name:{3}) (0x{2:X})", state, index, m.Serial.Value, m.Name);
						m.Delete();
					}

					state.Send(new CharacterListUpdate(acct));
				}
			}
		}