private static void OnHuedEffect(PacketReader p, PacketHandlerEventArgs args) { byte type = p.ReadByte(); Serial src = p.ReadUInt32(); Serial dest = p.ReadUInt32(); ItemID itemID = p.ReadUInt16(); p.Seek(10, SeekOrigin.Current); byte speed = p.ReadByte(); byte count = p.ReadByte(); p.ReadUInt32(); uint hue = p.ReadUInt32(); uint mode = p.ReadUInt32(); Handle(huedEffect, args, type, src, dest, itemID, speed, count, hue, mode); }
public void ReadPacket(PacketReader reader) { FailureReason = (LoginFailureReason)reader.ReadInt32(); var fingerprintJson = reader.ReadString(); if (fingerprintJson != null) Fingerprint = new Fingerprint(fingerprintJson); HostName = reader.ReadString(); AssetsRootUrl = reader.ReadString(); iTunesUrl = reader.ReadString(); Unknown1 = reader.ReadString(); RemainingTime = reader.ReadInt32(); Unknown2 = reader.ReadByte(); CompressedFingerprintJson = reader.ReadByteArray(); Unknown3 = reader.ReadString(); Unknown4 = reader.ReadString(); }
/// <summary> /// The read. /// </summary> /// <param name="client"> /// </param> /// <param name="packet"> /// </param> public static void Read(Client client, byte[] packet) { // TODO: Fix this mess. ushort data_length = BitConverter.ToUInt16(new[] { packet[3], packet[2] }, 0); byte[] sender_ID = BitConverter.GetBytes(client.Character.characterId); Array.Reverse(sender_ID); MemoryStream m_stream = new MemoryStream(); m_stream.Write(packet, 0, 9); m_stream.Write(sender_ID, 0, 4); m_stream.Write(packet, 9, packet.Length - 9); m_stream.Capacity = (int)m_stream.Length; byte[] message = m_stream.GetBuffer(); byte[] new_length = BitConverter.GetBytes(message.Length - 4); message[2] = new_length[1]; message[3] = new_length[0]; m_stream.Close(); m_stream.Dispose(); foreach (Client m_client in client.Server.Clients) { if (!m_client.KnownClients.Contains(client.Character.characterId)) { byte[] pname = PlayerName.New(client, client.Character.characterId); m_client.Send(pname); m_client.KnownClients.Add(client.Character.characterId); } m_client.Send(message); } PacketReader reader = new PacketReader(ref packet); reader.ReadUInt16(); reader.ReadUInt16(); reader.ReadUInt16(); reader.ReadUInt16(); reader.ReadByte(); string text = reader.ReadString(); string channelName = ChatChannels.GetChannel(packet).Name; ChatLogger.WriteString(channelName, text, client.Character.characterName); }
private static void EquipmentUpdate( PacketReader p ) { Serial serial = p.ReadUInt32(); Item i = World.FindItem( serial ); if ( i == null ) { World.AddItem( i=new Item( serial ) ); Item.UpdateContainers(); } if ( World.Player != null && World.Player.Holding == i ) World.Player.Holding = null; ushort iid = p.ReadUInt16(); i.ItemID = (ushort)(iid + p.ReadSByte()); // signed, itemID offset i.Layer = p.ReadByte(); Serial ser = p.ReadUInt32();// cont must be set after hue (for counters) i.Hue = p.ReadUInt16(); i.Container = ser; }
void read_invoke_res(PacketReader r, out ValueImpl v, out ValueImpl exc, out ValueImpl out_this, out ValueImpl[] out_args) { int resflags = r.ReadByte (); v = null; exc = null; out_this = null; out_args = null; if (resflags == 0) { exc = r.ReadValue (); } else { v = r.ReadValue (); if ((resflags & 2) != 0) out_this = r.ReadValue (); if ((resflags & 4) != 0) { int nargs = r.ReadInt (); out_args = new ValueImpl [nargs]; for (int i = 0; i < nargs; ++i) out_args [i] = r.ReadValue (); } } }
private static void ExtendedPacket( PacketReader p, PacketHandlerEventArgs args ) { ushort type = p.ReadUInt16(); switch ( type ) { case 0x04: // close gump { // int serial, int tid if ( World.Player != null ) World.Player.HasGump = false; break; } case 0x06: // party messages { OnPartyMessage( p, args ); break; } case 0x08: // map change { if ( World.Player != null ) World.Player.Map = p.ReadByte(); break; } case 0x14: // context menu { p.ReadInt16(); // 0x01 UOEntity ent = null; Serial ser = p.ReadUInt32(); if ( ser.IsMobile ) ent = World.FindMobile( ser ); else if ( ser.IsItem ) ent = World.FindItem( ser ); if ( ent != null ) { byte count = p.ReadByte(); try { ent.ContextMenu.Clear(); for(int i=0;i<count;i++) { ushort idx = p.ReadUInt16(); ushort num = p.ReadUInt16(); ushort flags = p.ReadUInt16(); ushort color = 0; if ( (flags&0x02) != 0 ) color = p.ReadUInt16(); ent.ContextMenu.Add( idx, num ); } } catch { } } break; } case 0x18: // map patches { if ( World.Player != null ) { int count = p.ReadInt32() * 2; try { World.Player.MapPatches = new int[count]; for(int i=0;i<count;i++) World.Player.MapPatches[i] = p.ReadInt32(); } catch { } } break; } case 0x19: // stat locks { if ( p.ReadByte() == 0x02 ) { Mobile m = World.FindMobile( p.ReadUInt32() ); if ( World.Player == m && m != null ) { p.ReadByte();// 0? byte locks = p.ReadByte(); World.Player.StrLock = (LockType)((locks>>4) & 3); World.Player.DexLock = (LockType)((locks>>2) & 3); World.Player.IntLock = (LockType)(locks & 3); } } break; } case 0x1D: // Custom House "General Info" { Item i = World.FindItem( p.ReadUInt32() ); if ( i != null ) i.HouseRevision = p.ReadInt32(); break; } } }
private static void DropRequest( PacketReader p, PacketHandlerEventArgs args ) { Serial iser = p.ReadUInt32(); int x = p.ReadInt16(); int y = p.ReadInt16(); int z = p.ReadSByte(); if ( Engine.UsePostKRPackets ) /* grid num */p.ReadByte(); Point3D newPos = new Point3D( x, y, z ); Serial dser = p.ReadUInt32(); if ( Macros.MacroManager.AcceptActions ) MacroManager.Action( new DropAction( dser, newPos ) ); Item i = World.FindItem( iser ); if ( i == null ) return; Item dest = World.FindItem( dser ); if ( dest != null && dest.IsContainer && World.Player != null && ( dest.IsChildOf( World.Player.Backpack ) || dest.IsChildOf( World.Player.Quiver ) ) ) i.IsNew = true; if ( Config.GetBool( "QueueActions" ) ) args.Block = DragDropManager.Drop( i, dser, newPos ); }
private static void ClientTextCommand( PacketReader p, PacketHandlerEventArgs args ) { int type = p.ReadByte(); string command = p.ReadString(); switch ( type ) { case 0x24: // Use skill { int skillIndex; try{ skillIndex = Convert.ToInt32( command.Split( ' ' )[0] ); } catch{ break; } if ( World.Player != null ) World.Player.LastSkill = skillIndex; if ( Macros.MacroManager.AcceptActions ) MacroManager.Action( new UseSkillAction( skillIndex ) ); if ( skillIndex == (int)SkillName.Stealth && !World.Player.Visible ) StealthSteps.Hide(); break; } case 0x27: // Cast spell from book { try { string[] split = command.Split( ' ' ); if ( split.Length > 0 ) { ushort spellID = Convert.ToUInt16( split[0] ); Serial serial = Convert.ToUInt32( split.Length > 1 ? Utility.ToInt32( split[1], -1 ) : -1 ); Spell s = Spell.Get( spellID ); if ( s != null ) { s.OnCast( p ); args.Block = true; if ( Macros.MacroManager.AcceptActions ) MacroManager.Action( new BookCastSpellAction( s, serial ) ); } } } catch { } break; } case 0x56: // Cast spell from macro { try { ushort spellID = Convert.ToUInt16( command ); Spell s = Spell.Get( spellID ); if ( s != null ) { s.OnCast( p ); args.Block = true; if ( Macros.MacroManager.AcceptActions ) MacroManager.Action( new MacroCastSpellAction( s ) ); } } catch { } break; } } }
private static void ChangeSeason( PacketReader p, PacketHandlerEventArgs args ) { if ( World.Player != null ) World.Player.Season = p.ReadByte(); }
private static void Skills( PacketReader p, PacketHandlerEventArgs args ) { if ( World.Player == null || World.Player.Skills == null || Engine.MainWindow == null ) return; byte type = p.ReadByte(); switch ( type ) { case 0x02://list (with caps, 3.0.8 and up) { int i; while ( (i = p.ReadUInt16()) > 0 ) { if ( i>0 && i <= Skill.Count ) { Skill skill = World.Player.Skills[i-1]; if ( skill == null ) continue; skill.FixedValue = p.ReadUInt16(); skill.FixedBase = p.ReadUInt16(); skill.Lock = (LockType)p.ReadByte(); skill.FixedCap = p.ReadUInt16(); if ( !World.Player.SkillsSent ) skill.Delta = 0; ClientCommunication.PostSkillUpdate( i-1, skill.FixedBase ); } else { p.Seek( 7, SeekOrigin.Current ); } } World.Player.SkillsSent = true; Engine.MainWindow.RedrawSkills(); break; } case 0x00: // list (without caps, older clients) { int i; while ( (i = p.ReadUInt16()) > 0 ) { if ( i>0 && i <= Skill.Count ) { Skill skill = World.Player.Skills[i-1]; if ( skill == null ) continue; skill.FixedValue = p.ReadUInt16(); skill.FixedBase = p.ReadUInt16(); skill.Lock = (LockType)p.ReadByte(); skill.FixedCap = 100;//p.ReadUInt16(); if ( !World.Player.SkillsSent ) skill.Delta = 0; ClientCommunication.PostSkillUpdate( i-1, skill.FixedBase ); } else { p.Seek( 5, SeekOrigin.Current ); } } World.Player.SkillsSent = true; Engine.MainWindow.RedrawSkills(); break; } case 0xDF: //change (with cap, new clients) { int i = p.ReadUInt16(); if ( i >= 0 && i < Skill.Count ) { Skill skill = World.Player.Skills[i]; if ( skill == null ) break; ushort old = skill.FixedBase; skill.FixedValue = p.ReadUInt16(); skill.FixedBase = p.ReadUInt16(); skill.Lock = (LockType)p.ReadByte(); skill.FixedCap = p.ReadUInt16(); Engine.MainWindow.UpdateSkill( skill ); if ( Config.GetBool( "DisplaySkillChanges" ) && skill.FixedBase != old ) World.Player.SendMessage( MsgLevel.Force, LocString.SkillChanged, (SkillName)i, skill.Delta > 0 ? "+" : "", skill.Delta, skill.Value, skill.FixedBase - old > 0 ? "+" : "", ((double)( skill.FixedBase - old )) / 10.0 ); ClientCommunication.PostSkillUpdate( i, skill.FixedBase ); } break; } case 0xFF: //change (without cap, older clients) { int i = p.ReadUInt16(); if ( i >= 0 && i < Skill.Count ) { Skill skill = World.Player.Skills[i]; if ( skill == null ) break; ushort old = skill.FixedBase; skill.FixedValue = p.ReadUInt16(); skill.FixedBase = p.ReadUInt16(); skill.Lock = (LockType)p.ReadByte(); skill.FixedCap = 100; Engine.MainWindow.UpdateSkill( skill ); if ( Config.GetBool( "DisplaySkillChanges" ) && skill.FixedBase != old ) World.Player.SendMessage( MsgLevel.Force, LocString.SkillChanged, (SkillName)i, skill.Delta > 0 ? "+" : "", skill.Delta, skill.Value, ((double)( skill.FixedBase - old )) / 10.0, skill.FixedBase - old > 0 ? "+" : "" ); ClientCommunication.PostSkillUpdate( i, skill.FixedBase ); } break; } } }
private static void MovementDemand( PacketReader p, PacketHandlerEventArgs args ) { if ( PacketPlayer.Playing ) ClientCommunication.ForceSendToClient( new MobileUpdate( World.Player ) ); World.Player.ProcessMove( (Direction)p.ReadByte() ); }
private static void MovementAck( PacketReader p, PacketHandlerEventArgs args ) { if ( World.Player != null ) { byte oldNoto = World.Player.Notoriety; byte seq = p.ReadByte(); World.Player.Notoriety = p.ReadByte(); if ( WalkAction.IsMacroWalk( seq ) ) args.Block = true; args.Block |= !World.Player.MoveAck( seq ); if ( oldNoto != World.Player.Notoriety && Config.GetBool( "ShowNotoHue" ) ) ClientCommunication.RequestTitlebarUpdate(); } }
private static void MobileStatus( PacketReader p, PacketHandlerEventArgs args ) { Serial serial = p.ReadUInt32(); Mobile m = World.FindMobile( serial ); if ( m == null ) World.AddMobile( m = new Mobile( serial ) ); m.Name = p.ReadString( 30 ); m.Hits = p.ReadUInt16(); m.HitsMax = p.ReadUInt16(); p.ReadBoolean();//CanBeRenamed byte type = p.ReadByte(); if ( m == World.Player && type != 0x00 ) { PlayerData player = (PlayerData)m; player.Female = p.ReadBoolean(); int oStr = player.Str, oDex = player.Dex, oInt = player.Int; player.Str = p.ReadUInt16(); player.Dex = p.ReadUInt16(); player.Int = p.ReadUInt16(); if ( player.Str != oStr && oStr != 0 && Config.GetBool( "DisplaySkillChanges" ) ) World.Player.SendMessage( MsgLevel.Force, LocString.StrChanged, player.Str - oStr > 0 ? "+" : "", player.Str - oStr, player.Str ); if ( player.Dex != oDex && oDex != 0 && Config.GetBool( "DisplaySkillChanges" ) ) World.Player.SendMessage( MsgLevel.Force, LocString.DexChanged, player.Dex - oDex > 0 ? "+" : "", player.Dex - oDex, player.Dex ); if ( player.Int != oInt && oInt != 0 && Config.GetBool( "DisplaySkillChanges" ) ) World.Player.SendMessage( MsgLevel.Force, LocString.IntChanged, player.Int - oInt > 0 ? "+" : "", player.Int - oInt, player.Int ); player.Stam = p.ReadUInt16(); player.StamMax = p.ReadUInt16(); player.Mana = p.ReadUInt16(); player.ManaMax = p.ReadUInt16(); player.Gold = p.ReadUInt32(); player.AR = p.ReadUInt16(); // ar / physical resist player.Weight = p.ReadUInt16(); if ( type >= 0x03 ) { if ( type > 0x04 ) { player.MaxWeight = p.ReadUInt16(); p.ReadByte(); // race? } player.StatCap = p.ReadUInt16(); if ( type > 0x03 ) { player.Followers = p.ReadByte(); player.FollowersMax = p.ReadByte(); player.FireResistance = p.ReadInt16(); player.ColdResistance = p.ReadInt16(); player.PoisonResistance = p.ReadInt16(); player.EnergyResistance = p.ReadInt16(); player.Luck = p.ReadInt16(); player.DamageMin = p.ReadUInt16(); player.DamageMax = p.ReadUInt16(); player.Tithe = p.ReadInt32(); } } ClientCommunication.RequestTitlebarUpdate(); ClientCommunication.PostHitsUpdate(); ClientCommunication.PostStamUpdate(); ClientCommunication.PostManaUpdate(); Engine.MainWindow.UpdateTitle(); // update player name } }
private static void LoginConfirm( PacketReader p, PacketHandlerEventArgs args ) { World.Items.Clear(); World.Mobiles.Clear(); UseNewStatus = false; Serial serial = p.ReadUInt32(); PlayerData m = new PlayerData( serial ); m.Name = World.OrigPlayerName; Mobile test = World.FindMobile( serial ); if ( test != null ) test.Remove(); World.AddMobile( World.Player = m ); Config.LoadProfileFor( World.Player ); PlayerData.ExternalZ = false; p.ReadUInt32(); // always 0? m.Body = p.ReadUInt16(); m.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadInt16() ); m.Direction = (Direction)p.ReadByte(); m.Resync(); //ClientCommunication.SendToServer( new SkillsQuery( m ) ); //ClientCommunication.SendToServer( new StatusQuery( m ) ); ClientCommunication.RequestTitlebarUpdate(); ClientCommunication.PostLogin( (int)serial.Value ); Engine.MainWindow.UpdateTitle(); // update player name & shard name /* //the rest of the packet: (total length: 37) m_Stream.Write( (byte) 0 ); m_Stream.Write( (int) -1 ); m_Stream.Write( (short) 0 ); m_Stream.Write( (short) 0 ); m_Stream.Write( (short) (map==null?6144:map.Width) ); m_Stream.Write( (short) (map==null?4096:map.Height) ); Stream.Fill(); */ ClientCommunication.BeginCalibratePosition(); }
private static void LiftReject( PacketReader p, PacketHandlerEventArgs args ) { /* if ( ActionQueue.FilterLiftReject() ) args.Block = true; */ int reason = p.ReadByte(); if ( !DragDropManager.LiftReject() ) args.Block = true; //MacroManager.PlayError( MacroError.LiftRej ); }
private static void ServerList( PacketReader p, PacketHandlerEventArgs args ) { p.ReadByte(); //unknown ushort numServers = p.ReadUInt16(); for ( int i = 0; i < numServers; ++i ) { ushort num = p.ReadUInt16(); World.Servers[num] = p.ReadString( 32 ); p.ReadByte(); // full % p.ReadSByte(); // time zone p.ReadUInt32(); // ip } }
private static void SetSkillLock( PacketReader p, PacketHandlerEventArgs args ) { int i = p.ReadUInt16(); if ( i >= 0 && i < Skill.Count ) { Skill skill = World.Player.Skills[i]; skill.Lock = (LockType)p.ReadByte(); Engine.MainWindow.UpdateSkill( skill ); } }
private static void MovementRej( PacketReader p, PacketHandlerEventArgs args ) { if ( World.Player != null ) { byte seq = p.ReadByte(); int x = p.ReadUInt16(); int y = p.ReadUInt16(); Direction dir = (Direction)p.ReadByte(); sbyte z = p.ReadSByte(); if ( WalkAction.IsMacroWalk( seq ) ) args.Block = true; World.Player.MoveRej( seq, dir, new Point3D( x, y, z ) ); } }
private static void WorldItem( PacketReader p, PacketHandlerEventArgs args ) { Item item; uint serial = p.ReadUInt32(); item = World.FindItem( serial&0x7FFFFFFF ); bool isNew = false; if ( item == null ) { World.AddItem( item=new Item( serial&0x7FFFFFFF ) ); isNew = true; } else { item.CancelRemove(); } if ( !DragDropManager.EndHolding( serial ) ) return; item.Container = null; Counter.Uncount( item ); ushort itemID = p.ReadUInt16(); item.ItemID = (ushort)(itemID&0x7FFF); if ( (serial & 0x80000000) != 0 ) item.Amount = p.ReadUInt16(); else item.Amount = 1; if ( (itemID & 0x8000) != 0 ) item.ItemID = (ushort)(item.ItemID + p.ReadSByte()); ushort x = p.ReadUInt16(); ushort y = p.ReadUInt16(); if ( (x & 0x8000) != 0 ) item.Direction = p.ReadByte(); else item.Direction = 0; short z = p.ReadSByte(); item.Position = new Point3D( x&0x7FFF, y&0x3FFF, z ); if ( ( y & 0x8000 ) != 0 ) item.Hue = p.ReadUInt16(); else item.Hue = 0; byte flags = 0; if ( ( y & 0x4000 ) != 0 ) flags = p.ReadByte(); item.ProcessPacketFlags( flags ); if ( isNew && World.Player != null ) { if ( item.ItemID == 0x2006 )// corpse itemid = 0x2006 { if ( Config.GetBool( "ShowCorpseNames" ) ) ClientCommunication.SendToServer( new SingleClick( item ) ); if ( Config.GetBool( "AutoOpenCorpses" ) && Utility.InRange( item.Position, World.Player.Position, Config.GetInt( "CorpseRange" ) ) && World.Player != null && World.Player.Visible ) PlayerData.DoubleClick( item ) ; } else if ( item.IsMulti ) { ClientCommunication.PostAddMulti( item.ItemID, item.Position ); } else { ScavengerAgent s = ScavengerAgent.Instance; int dist = Utility.Distance( item.GetWorldPosition(), World.Player.Position ); if ( !World.Player.IsGhost && World.Player.Visible && dist <= 2 && s.Enabled && item.Movable ) s.Scavenge( item ); } } Item.UpdateContainers(); }
private static void MovementRequest( PacketReader p, PacketHandlerEventArgs args ) { if ( World.Player != null ) { Direction dir = (Direction)p.ReadByte(); byte seq = p.ReadByte(); World.Player.MoveReq( dir, seq ); WalkAction.LastWalkTime = DateTime.Now; if ( MacroManager.AcceptActions ) MacroManager.Action( new WalkAction( dir ) ); } }
private static void ClientEncodedPacket( PacketReader p, PacketHandlerEventArgs args ) { Serial serial = p.ReadUInt32(); ushort packetID = p.ReadUInt16(); switch ( packetID ) { case 0x19: // set ability { int ability = 0; if ( p.ReadByte() == 0 ) ability = p.ReadInt32(); if ( ability >= 0 && ability < (int)AOSAbility.Invalid && Macros.MacroManager.AcceptActions ) MacroManager.Action( new SetAbilityAction( (AOSAbility)ability ) ); break; } } }
private static void NewMobileStatus( PacketReader p, PacketHandlerEventArgs args ) { Mobile m = World.FindMobile( (Serial)p.ReadUInt32() ); if ( m == null ) return; UseNewStatus = true; // 00 01 p.ReadUInt16(); // 00 01 Poison // 00 02 Yellow Health Bar ushort id = p.ReadUInt16(); // 00 Off // 01 On // For Poison: Poison Level + 1 byte flag = p.ReadByte(); if ( id == 1 ) { bool wasPoisoned = m.Poisoned; m.Poisoned = ( flag != 0 ); if ( m == World.Player && wasPoisoned != m.Poisoned ) ClientCommunication.RequestTitlebarUpdate(); } }
private static void CustomHouseInfo( PacketReader p, PacketHandlerEventArgs args ) { p.ReadByte(); // compression p.ReadByte(); // Unknown Item i = World.FindItem( p.ReadUInt32() ); if ( i != null ) { i.HouseRevision = p.ReadInt32(); i.HousePacket = p.CopyBytes( 0, p.Length ); } }
private static void OnPartyMessage( PacketReader p, PacketHandlerEventArgs args ) { switch ( p.ReadByte() ) { case 0x01: // List { m_Party.Clear(); int count = p.ReadByte(); for(int i=0;i<count;i++) { Serial s = p.ReadUInt32(); if ( World.Player == null || s != World.Player.Serial ) m_Party.Add( s ); } break; } case 0x02: // Remove Member/Re-list { m_Party.Clear(); int count = p.ReadByte(); Serial remSerial = p.ReadUInt32(); // the serial of who was removed if ( World.Player != null ) { Mobile rem = World.FindMobile( remSerial ); if ( rem != null && !Utility.InRange( World.Player.Position, rem.Position, World.Player.VisRange ) ) rem.Remove(); } for(int i=0;i<count;i++) { Serial s = p.ReadUInt32(); if ( World.Player == null || s != World.Player.Serial ) m_Party.Add( s ); } break; } case 0x03: // text message case 0x04: // 3 = private, 4 = public { //Serial from = p.ReadUInt32(); //string text = p.ReadUnicodeStringSafe(); break; } case 0x07: // party invite { //Serial leader = p.ReadUInt32(); PartyLeader = p.ReadUInt32(); if ( m_PartyDeclineTimer == null ) m_PartyDeclineTimer = Timer.DelayedCallback( TimeSpan.FromSeconds( 10.0 ), new TimerCallback( PartyAutoDecline ) ); m_PartyDeclineTimer.Start(); break; } } if (Engine.MainWindow.MapWindow != null) Engine.MainWindow.MapWindow.UpdateMap(); }
private static void EquipRequest( PacketReader p, PacketHandlerEventArgs args ) { Serial iser = p.ReadUInt32(); // item being dropped serial Layer layer = (Layer)p.ReadByte(); Serial mser = p.ReadUInt32(); Item item = World.FindItem( iser ); if ( MacroManager.AcceptActions ) { if ( layer == Layer.Invalid || layer > Layer.LastValid ) { if ( item != null ) { layer = item.Layer; if ( layer == Layer.Invalid || layer > Layer.LastValid ) layer = (Layer)item.ItemID.ItemData.Quality; } } if ( layer > Layer.Invalid && layer <= Layer.LastUserValid ) MacroManager.Action( new DropAction( mser, Point3D.Zero, layer ) ); } if ( item == null ) return; Mobile m = World.FindMobile( mser ); if ( m == null ) return; if ( Config.GetBool( "QueueActions" ) ) args.Block = DragDropManager.Drop( item, m, layer ); }
private static void PingResponse( PacketReader p, PacketHandlerEventArgs args ) { if ( Ping.Response( p.ReadByte() ) ) args.Block = true; }
CattrInfo[] ReadCattrs(PacketReader r) { CattrInfo[] res = new CattrInfo [r.ReadInt ()]; for (int i = 0; i < res.Length; ++i) { CattrInfo info = new CattrInfo (); info.ctor_id = r.ReadId (); info.ctor_args = new ValueImpl [r.ReadInt ()]; for (int j = 0; j < info.ctor_args.Length; ++j) { info.ctor_args [j] = r.ReadValue (); } info.named_args = new CattrNamedArgInfo [r.ReadInt ()]; for (int j = 0; j < info.named_args.Length; ++j) { CattrNamedArgInfo arg = new CattrNamedArgInfo (); int arg_type = r.ReadByte (); arg.is_property = arg_type == 0x54; arg.id = r.ReadId (); arg.value = r.ReadValue (); info.named_args [j] = arg; } res [i] = info; } return res; }
private static void RunUOProtocolExtention(PacketReader p, PacketHandlerEventArgs args) { args.Block = true; switch (p.ReadByte()) { case 1: // Custom Party information { Serial serial; PacketHandlers.SpecialPartyReceived++; while ((serial = p.ReadUInt32()) > 0) { Mobile mobile = World.FindMobile(serial); short x = p.ReadInt16(); short y = p.ReadInt16(); byte map = p.ReadByte(); if (mobile == null) { World.AddMobile( mobile = new Mobile(serial) ); mobile.Visible = false; } if ( mobile.Name == null || mobile.Name.Length <= 0 ) mobile.Name = "(Not Seen)"; if ( !m_Party.Contains( serial ) ) m_Party.Add( serial ); if ( map == World.Player.Map ) mobile.Position = new Point3D(x, y, mobile.Position.Z); else mobile.Position = Point3D.Zero; } if (Engine.MainWindow.MapWindow != null) Engine.MainWindow.MapWindow.UpdateMap(); break; } case 0xFE: // Begin Handshake/Features Negotiation { ulong features = p.ReadRawUInt64(); if ( ClientCommunication.HandleNegotiate( features ) != 0 ) { ClientCommunication.SendToServer( new RazorNegotiateResponse() ); Engine.MainWindow.UpdateControlLocks(); } break; } } }
bool ReceivePacket() { byte[] packet = ReadPacket (); if (packet.Length == 0) { return false; } if (IsReplyPacket (packet)) { int id = GetPacketId (packet); ReplyCallback cb = null; lock (reply_packets_monitor) { reply_cbs.TryGetValue (id, out cb); if (cb == null) { reply_packets [id] = packet; Monitor.PulseAll (reply_packets_monitor); } else { int c = reply_cb_counts [id]; c --; if (c == 0) { reply_cbs.Remove (id); reply_cb_counts.Remove (id); } } } if (cb != null) cb.Invoke (id, packet); } else { PacketReader r = new PacketReader (packet); if (r.CommandSet == CommandSet.EVENT && r.Command == (int)CmdEvent.COMPOSITE) { int spolicy = r.ReadByte (); int nevents = r.ReadInt (); SuspendPolicy suspend_policy = decode_suspend_policy (spolicy); EventInfo[] events = new EventInfo [nevents]; for (int i = 0; i < nevents; ++i) { EventKind kind = (EventKind)r.ReadByte (); int req_id = r.ReadInt (); EventType etype = (EventType)kind; long thread_id = r.ReadId (); if (kind == EventKind.VM_START) { events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id }; //EventHandler.VMStart (req_id, thread_id, null); } else if (kind == EventKind.VM_DEATH) { int exit_code = 0; if (Version.AtLeast (2, 27)) exit_code = r.ReadInt (); //EventHandler.VMDeath (req_id, 0, null); events [i] = new EventInfo (etype, req_id) { ExitCode = exit_code }; } else if (kind == EventKind.THREAD_START) { events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = thread_id }; //EventHandler.ThreadStart (req_id, thread_id, thread_id); } else if (kind == EventKind.THREAD_DEATH) { events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = thread_id }; //EventHandler.ThreadDeath (req_id, thread_id, thread_id); } else if (kind == EventKind.ASSEMBLY_LOAD) { long id = r.ReadId (); events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id }; //EventHandler.AssemblyLoad (req_id, thread_id, id); } else if (kind == EventKind.ASSEMBLY_UNLOAD) { long id = r.ReadId (); events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id }; //EventHandler.AssemblyUnload (req_id, thread_id, id); } else if (kind == EventKind.TYPE_LOAD) { long id = r.ReadId (); events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id }; //EventHandler.TypeLoad (req_id, thread_id, id); } else if (kind == EventKind.METHOD_ENTRY) { long id = r.ReadId (); events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id }; //EventHandler.MethodEntry (req_id, thread_id, id); } else if (kind == EventKind.METHOD_EXIT) { long id = r.ReadId (); events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id }; //EventHandler.MethodExit (req_id, thread_id, id); } else if (kind == EventKind.BREAKPOINT) { long id = r.ReadId (); long loc = r.ReadLong (); events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id, Location = loc }; //EventHandler.Breakpoint (req_id, thread_id, id, loc); } else if (kind == EventKind.STEP) { long id = r.ReadId (); long loc = r.ReadLong (); events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id, Location = loc }; //EventHandler.Step (req_id, thread_id, id, loc); } else if (kind == EventKind.EXCEPTION) { long id = r.ReadId (); long loc = 0; // FIXME events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id, Location = loc }; //EventHandler.Exception (req_id, thread_id, id, loc); } else if (kind == EventKind.APPDOMAIN_CREATE) { long id = r.ReadId (); events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id }; //EventHandler.AppDomainCreate (req_id, thread_id, id); } else if (kind == EventKind.APPDOMAIN_UNLOAD) { long id = r.ReadId (); events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id }; //EventHandler.AppDomainUnload (req_id, thread_id, id); } else if (kind == EventKind.USER_BREAK) { long id = 0; long loc = 0; events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Id = id, Location = loc }; //EventHandler.Exception (req_id, thread_id, id, loc); } else if (kind == EventKind.USER_LOG) { int level = r.ReadInt (); string category = r.ReadString (); string message = r.ReadString (); events [i] = new EventInfo (etype, req_id) { ThreadId = thread_id, Level = level, Category = category, Message = message }; //EventHandler.Exception (req_id, thread_id, id, loc); } else if (kind == EventKind.KEEPALIVE) { events [i] = new EventInfo (etype, req_id) { }; } else { throw new NotImplementedException ("Unknown event kind: " + kind); } } EventHandler.Events (suspend_policy, events); } } return true; }
private static void SAWorldItem(PacketReader p, PacketHandlerEventArgs args) { /* New World Item Packet PacketID: 0xF3 PacketLen: 24 Format: BYTE - 0xF3 packetId WORD - 0x01 BYTE - ArtDataID: 0x00 if the item uses art from TileData table, 0x02 if the item uses art from MultiData table) DWORD - item Serial WORD - item ID BYTE - item direction (same as old) WORD - amount WORD - amount WORD - X WORD - Y SBYTE - Z BYTE - item light WORD - item Hue BYTE - item flags (same as old packet) */ // Post-7.0.9.0 /* New World Item Packet PacketID: 0xF3 PacketLen: 26 Format: BYTE - 0xF3 packetId WORD - 0x01 BYTE - ArtDataID: 0x00 if the item uses art from TileData table, 0x02 if the item uses art from MultiData table) DWORD - item Serial WORD - item ID BYTE - item direction (same as old) WORD - amount WORD - amount WORD - X WORD - Y SBYTE - Z BYTE - item light WORD - item Hue BYTE - item flags (same as old packet) WORD ??? */ ushort _unk1 = p.ReadUInt16(); byte _artDataID = p.ReadByte(); Item item; uint serial = p.ReadUInt32(); item = World.FindItem(serial); bool isNew = false; if (item == null) { World.AddItem(item = new Item(serial)); isNew = true; } else { item.CancelRemove(); } if (!DragDropManager.EndHolding(serial)) return; item.Container = null; Counter.Uncount(item); ushort itemID = p.ReadUInt16(); item.ItemID = (ushort)( _artDataID == 0x02 ? itemID | 0x4000 : itemID ); item.Direction = p.ReadByte(); ushort _amount = p.ReadUInt16(); item.Amount = _amount = p.ReadUInt16(); ushort x = p.ReadUInt16(); ushort y = p.ReadUInt16(); short z = p.ReadSByte(); item.Position = new Point3D(x, y, z); byte _light = p.ReadByte(); item.Hue = p.ReadUInt16(); byte flags = p.ReadByte(); item.ProcessPacketFlags(flags); if (Engine.UsePostHSChanges) { p.ReadUInt16(); } if (isNew && World.Player != null) { if (item.ItemID == 0x2006)// corpse itemid = 0x2006 { if (Config.GetBool("ShowCorpseNames")) ClientCommunication.SendToServer(new SingleClick(item)); if (Config.GetBool("AutoOpenCorpses") && Utility.InRange(item.Position, World.Player.Position, Config.GetInt("CorpseRange")) && World.Player != null && World.Player.Visible) PlayerData.DoubleClick(item); } else if (item.IsMulti) { ClientCommunication.PostAddMulti(item.ItemID, item.Position); } else { ScavengerAgent s = ScavengerAgent.Instance; int dist = Utility.Distance(item.GetWorldPosition(), World.Player.Position); if (!World.Player.IsGhost && World.Player.Visible && dist <= 2 && s.Enabled && item.Movable) s.Scavenge(item); } } Item.UpdateContainers(); }