ReadBoolean() public method

public ReadBoolean ( ) : bool
return bool
        private static void Shutdown( NetState state, PacketReader pvSrc )
        {
            bool restart = pvSrc.ReadBoolean();
            bool save = pvSrc.ReadBoolean();

            Console.WriteLine( "RemoteAdmin: shutting down server (Restart: {0}) (Save: {1}) [{2}]", restart, save, DateTime.Now );

            if ( save && !AutoRestart.Restarting )
                Misc.AutoSave.Save();

            Core.Kill( restart );
        }
        private static void WorldBroadcast( NetState state, PacketReader pvSrc )
        {
            string message = pvSrc.ReadUTF8String();
            int hue = pvSrc.ReadInt16();
            bool ascii = pvSrc.ReadBoolean();

            World.Broadcast(hue, ascii, message);

            state.Send( new MessageBoxMessage( "Your message has been broadcasted.", "Message Broadcasted" ) );
        }
		private static void UpdateAccount( NetState state, PacketReader pvSrc )
		{
			string username = pvSrc.ReadString();
			string pass = pvSrc.ReadString();

			Account a = Accounts.GetAccount( username );

			if ( a == null )
				a = Accounts.AddAccount( username, pass );
			else if ( pass != "(hidden)" )
				a.SetPassword( pass );

			if ( a != state.Account )
			{
				a.AccessLevel = (AccessLevel)pvSrc.ReadByte();
				a.Banned = pvSrc.ReadBoolean();
			}
			else
			{
				pvSrc.ReadInt16();//skip both
				state.Send( new MessageBoxMessage( "Warning: When editing your own account, account status and accesslevel cannot be changed.", "Editing Own Account" ) );
			}

			ArrayList list = new ArrayList();
			ushort length = pvSrc.ReadUInt16();
			bool invalid = false;
			for (int i=0;i<length;i++)
			{
				string add = pvSrc.ReadString();
				if ( Utility.IsValidIP( add ) )
					list.Add( add );
				else
					invalid = true;
			}

			if ( list.Count > 0 )
				a.IPRestrictions = (string[])list.ToArray( typeof( string ) );
			else
				a.IPRestrictions = new string[0];

			if ( invalid )
				state.Send( new MessageBoxMessage( "Warning: one or more of the IP Restrictions you specified was not valid.", "Invalid IP Restriction" ) );
			state.Send( new MessageBoxMessage( "Account updated successfully.", "Account Updated" ) );
		}
		public static void GodModeRequest( NetState state, PacketReader pvSrc )
		{
			if ( VerifyGC( state ) )
			{
				state.Send( new GodModeReply( pvSrc.ReadBoolean() ) );
			}
		}
		public static void PartyMessage_SetCanLoot( NetState state, PacketReader pvSrc )
		{
			if ( PartyCommands.Handler != null )
				PartyCommands.Handler.OnSetCanLoot( state.Mobile, pvSrc.ReadBoolean() );
		}
		public static void QuestArrow( NetState state, PacketReader pvSrc )
		{
			bool rightClick = pvSrc.ReadBoolean();
			Mobile from = state.Mobile;

			if ( from != null && from.QuestArrow != null )
				from.QuestArrow.OnClick( rightClick );
		}
		public static void SetWarMode( NetState state, PacketReader pvSrc )
		{
			state.Mobile.DelayChangeWarmode( pvSrc.ReadBoolean() );
		}
Example #8
0
        private static void UpdateAccount(NetState state, PacketReader pvSrc)
        { 
            if (state.Account.AccessLevel < AccessLevel.Administrator)
            {
                state.Send(new MessageBoxMessage("You do not have permission to edit accounts.", "Account Access Exception"));
                return;
            }

            string username = pvSrc.ReadString();
            string pass = pvSrc.ReadString();

            Account a = Accounts.GetAccount(username) as Account;

            if (a != null && !CanAccessAccount(state.Account, a))
            {
                state.Send(new MessageBoxMessage("You cannot edit an account with an access level greater than or equal to your own.", "Account Access Exception"));
            }
            else
            {
                bool CreatedAccount = false;
                bool UpdatedPass = false;
                bool oldbanned = a == null ? false : a.Banned;
                AccessLevel oldAcessLevel = a == null ? 0 : a.AccessLevel;

                if (a == null)
                {
                    a = new Account(username, pass);
                    CreatedAccount = true;
                }
                else if (pass != "(hidden)")
                {
                    a.SetPassword(pass);
                    UpdatedPass = true;
                }

                if (a != state.Account)
                {
                    AccessLevel newAccessLevel = (AccessLevel)pvSrc.ReadByte();
                    if (a.AccessLevel != newAccessLevel)
                    {
                        if (newAccessLevel >= state.Account.AccessLevel)
                            state.Send(new MessageBoxMessage("Warning: You may not set an access level greater than or equal to your own.", "Account Access Level update denied."));
                        else
                            a.AccessLevel = newAccessLevel;
                    }
                    bool newBanned = pvSrc.ReadBoolean();
                    if (newBanned != a.Banned)
                    {
                        oldbanned = a.Banned;
                        a.Banned = newBanned;
                        a.Comments.Add(new AccountComment(state.Account.Username, newBanned ? "Banned via Remote Admin" : "Unbanned via Remote Admin"));
                    }
                }
                else
                {
                    pvSrc.ReadInt16();//skip both
                    state.Send(new MessageBoxMessage("Warning: When editing your own account, Account Status and Access Level cannot be changed.", "Editing Own Account"));
                }

                ArrayList list = new ArrayList();
                ushort length = pvSrc.ReadUInt16();
                bool invalid = false;
                for (int i = 0; i < length; i++)
                {
                    string add = pvSrc.ReadString();
                    if (Utility.IsValidIP(add))
                        list.Add(add);
                    else
                        invalid = true;
                }

                if (list.Count > 0)
                    a.IPRestrictions = (string[])list.ToArray(typeof(string));
                else
                    a.IPRestrictions = new string[0];

                if (invalid)
                    state.Send(new MessageBoxMessage("Warning: one or more of the IP Restrictions you specified was not valid.", "Invalid IP Restriction"));

                if (CreatedAccount)
                    RemoteAdminLogging.WriteLine(state, "Created account {0} with Access Level {1}", a.Username, a.AccessLevel);
                else
                {
                    string changes = string.Empty;
                    if (UpdatedPass)
                        changes += " Password Changed.";
                    if (oldAcessLevel != a.AccessLevel)
                        changes = string.Format("{0} Access level changed from {1} to {2}.", changes, oldAcessLevel, a.AccessLevel);
                    if (oldbanned != a.Banned)
                        changes += a.Banned ? " Banned." : " Unbanned.";
                    RemoteAdminLogging.WriteLine(state, "Updated account {0}:{1}", a.Username, changes);
                }

                state.Send(new MessageBoxMessage("Account updated successfully.", "Account Updated"));
            }
        }
		public static void StringQueryResponse( NetState state, PacketReader pvSrc )
		{
			int serial = pvSrc.ReadInt32();
			pvSrc.ReadUInt16(); // unknown
			bool ok = pvSrc.ReadBoolean();
			int length = pvSrc.ReadUInt16();
			string str = null;
			if ( length > 0 )
				str = pvSrc.ReadString(length - 1);

			StringQueryCollection stringqueries = state.StringQueries;

			for ( int i = 0; i < stringqueries.Count; ++i )
			{
				StringQuery stringquery = stringqueries[i];

				if ( stringquery.Serial == serial )
				{
					stringquery.OnResponse( state, ok, str );

					state.RemoveStringQuery( i );
					return;
				}
			}
		}
		public static void MoveTile( MahjongGame game, NetState state, PacketReader pvSrc )
		{
			if ( game == null || !game.Players.IsInGamePlayer( state.Mobile ) )
				return;

			int number = pvSrc.ReadByte();

			if ( number < 0 || number >= game.Tiles.Length )
				return;

			pvSrc.ReadByte(); // Current direction

			MahjongPieceDirection direction = GetDirection( pvSrc.ReadByte() );

			pvSrc.ReadByte();

			bool flip = pvSrc.ReadBoolean();

			pvSrc.ReadInt16(); // Current Y
			pvSrc.ReadInt16(); // Current X

			pvSrc.ReadByte();

			int y = pvSrc.ReadInt16();
			int x = pvSrc.ReadInt16();

			pvSrc.ReadByte();

			game.Tiles[number].Move( new Point2D( x, y ), direction, flip, game.Players.GetPlayerIndex( state.Mobile ) );
		}
		public static void TogglePublicHand( MahjongGame game, NetState state, PacketReader pvSrc )
		{
			if ( game == null || !game.Players.IsInGamePlayer( state.Mobile ) )
				return;

			pvSrc.ReadInt16();
			pvSrc.ReadByte();

			bool publicHand = pvSrc.ReadBoolean();

			game.Players.SetPublic( game.Players.GetPlayerIndex( state.Mobile ), publicHand );
		}
        public static void CreateCharacter( NetState state, PacketReader pvSrc )
        {
            int unk1 = pvSrc.ReadInt32();
            int unk2 = pvSrc.ReadInt32();
            int unk3 = pvSrc.ReadByte();
            string name = pvSrc.ReadString( 30 );

            pvSrc.Seek( 2, SeekOrigin.Current );
            int flags = pvSrc.ReadInt32();
            pvSrc.Seek( 8, SeekOrigin.Current );
            int prof = pvSrc.ReadByte();
            pvSrc.Seek( 15, SeekOrigin.Current );

            bool female = pvSrc.ReadBoolean();
            int str = pvSrc.ReadByte();
            int dex = pvSrc.ReadByte();
            int intl= pvSrc.ReadByte();
            int is1 = pvSrc.ReadByte();
            int vs1 = pvSrc.ReadByte();
            int is2 = pvSrc.ReadByte();
            int vs2 = pvSrc.ReadByte();
            int is3 = pvSrc.ReadByte();
            int vs3 = pvSrc.ReadByte();
            int hue = pvSrc.ReadUInt16();
            int hairVal = pvSrc.ReadInt16();
            int hairHue = pvSrc.ReadInt16();
            int hairValf= pvSrc.ReadInt16();
            int hairHuef= pvSrc.ReadInt16();
            pvSrc.ReadByte();
            int cityIndex = pvSrc.ReadByte();
            int charSlot = pvSrc.ReadInt32();
            int clientIP = pvSrc.ReadInt32();
            int shirtHue = pvSrc.ReadInt16();
            int pantsHue = pvSrc.ReadInt16();

            CityInfo[] info = state.CityInfo;
            IAccount a = state.Account;

            if ( info == null || a == null || cityIndex < 0 || cityIndex >= info.Length )
            {
                Console.WriteLine( cityIndex );
                Console.WriteLine( info.Length );
                state.Dispose();
            }
            else
            {
                // Check if anyone is using this account
                for ( int i = 0; i < a.Length; ++i )
                {
                    Mobile check = a[i];

                    if ( check != null && check.Map != Map.Internal )
                    {
                        Console.WriteLine( "Login: {0}: Account in use", state );
                        state.Send( new PopupMessage( PMMessage.CharInWorld ) );
                        return;
                    }
                }

                state.Flags = flags;

                CharacterCreatedEventArgs args = new CharacterCreatedEventArgs(
                    state, a,
                    name, female, hue,
                    str, dex, intl,
                    info[cityIndex],
                    new SkillNameValue[3]
                    {
                        new SkillNameValue( (SkillName)is1, vs1 ),
                        new SkillNameValue( (SkillName)is2, vs2 ),
                        new SkillNameValue( (SkillName)is3, vs3 ),
                    },
                    shirtHue, pantsHue,
                    hairVal, hairHue,
                    hairValf, hairHuef,
                    prof );

                state.BlockAllPackets = true;

                EventSink.InvokeCharacterCreated( args );

                Mobile m = args.Mobile;

                if ( m != null )
                {
                    state.Mobile = m;
                    m.NetState = state;

                    state.BlockAllPackets = false;
                    DoLogin( state, m );
                }
                else
                {
                    state.BlockAllPackets = false;
                    state.Dispose();
                }
            }
        }
Example #13
0
 public void SetWarMode( GameClient state, PacketReader pvSrc )
 {
     state.Mobile.DelayChangeWarmode( pvSrc.ReadBoolean() );
 }
Example #14
0
        public void QuestArrow( GameClient state, PacketReader pvSrc )
        {
            Mobile from = state.Mobile;

            bool rightClick = pvSrc.ReadBoolean();

            if ( from.QuestArrow != null )
                from.QuestArrow.OnClick( rightClick );
        }
Example #15
0
 public void GodModeRequest( GameClient state, PacketReader pvSrc )
 {
     if ( VerifyGC( state ) )
         state.Send( new GodModeReply( pvSrc.ReadBoolean() ) );
 }