Thread: Network.Flags
View Single Post
Old 03-04-2006, 09:20 AM   #1 (permalink)
jaynigs
Forum Expert
 
jaynigs's Avatar
 
Join Date: Mar 2003
Location: England
Age: 35
Posts: 986
Default Network.Flags

Ive been trying for the last 2 hours to change the supported features within the core dependant on the client expansion.. The problem i face is that the Network.Flags are not set until the player logs in with a character, so i cannot seem to test if the player uses Mondains Legacy etc at server login...


i have Highlighted in bold where the Netstate flags are set.


PacketHandlers.cs
Code:
	public static void PlayCharacter( NetState state, PacketReader pvSrc )
		{
			pvSrc.ReadInt32(); // 0xEDEDEDED

			string name = pvSrc.ReadString( 30 );

			pvSrc.Seek( 2, SeekOrigin.Current );
			int flags = pvSrc.ReadInt32();
			pvSrc.Seek( 24, SeekOrigin.Current );

			int charSlot = pvSrc.ReadInt32();
			int clientIP = pvSrc.ReadInt32();

			IAccount a = state.Account;

			if ( a == null || charSlot < 0 || charSlot >= a.Length )
			{
				state.Dispose();
			}
			else
			{
				Mobile m = a[charSlot];

				// 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 && check != m )
					{
						Console.WriteLine( "Login: {0}: Account in use", state );
						state.Send( new PopupMessage( PMMessage.CharInWorld ) );
						return;
					}
				}

				if ( m == null )
				{
					state.Dispose();
				}
				else
				{
					if ( m.NetState != null )
						m.NetState.Dispose();

					NetState.ProcessDisposedQueue();

					state.BlockAllPackets = true;

					state.Flags = flags;


and this is where i need them..


PacketHandlers.cs
Code:
		public static void GameLogin( NetState state, PacketReader pvSrc )
		{
			if ( state.SentFirstPacket )
			{
				state.Dispose();
				return;
			}

			state.SentFirstPacket = true;

			int authID = pvSrc.ReadInt32();

			if ( !IsValidAuthID( authID ) )
			{
				Console.WriteLine( "Login: {0}: Invalid client detected, disconnecting", state );
				state.Dispose();
				return;
			}
			else if ( state.m_AuthID != 0 && authID != state.m_AuthID )
			{
				Console.WriteLine( "Login: {0}: Invalid client detected, disconnecting", state );
				state.Dispose();
				return;
			}
			else if ( state.m_AuthID == 0 && authID != state.m_Seed )
			{
				Console.WriteLine( "Login: {0}: Invalid client detected, disconnecting", state );
				state.Dispose();
				return;
			}

			string username = pvSrc.ReadString( 30 );
			string password = pvSrc.ReadString( 30 );


			int flags = pvSrc.ReadInt32();


			GameLoginEventArgs e = new GameLoginEventArgs( state, username, password );

			EventSink.InvokeGameLogin( e );

			if ( e.Accepted )
			{
				state.CityInfo = e.CityInfo;
				state.CompressionEnabled = true;


				if ( Core.AOS )
					state.Send( SupportedFeatures.Instantiate( state.Account, flags ) );

				state.Send( new CharacterList( state.Account, state.CityInfo ) );
			}
			else
			{
				state.Dispose();
			}
		}

Since Ea/Osi use this ability, there must be some packet info i could use to set the Netstate.Flags earlier. Or, another way to detect the expansion type from ClientVersion info?

Thanks for reading

jay
jaynigs is offline   Reply With Quote