public void RequestRealmlist() { PacketOut packet = new PacketOut(LogonServerOpCode.REALM_LIST); packet.Write(0x00); Send(packet); // Most tricky code ever. It's so because retail server sends a lot of data in this packet... byte[] temp = pLoop.OnReceive(3); PacketIn p1 = new PacketIn(temp, true); byte[] temp2 = pLoop.OnReceive(p1.ReadUInt16()); byte[] temp3 = new byte[temp.Length + temp2.Length]; temp.CopyTo(temp3, 0); temp2.CopyTo(temp3, temp.Length); p1 = new PacketIn(temp3, false); HandlePacket(p1); }
/* [PacketHandlerAtribute(WorldServerOpCode.SMSG_COMPRESSED_UPDATE_OBJECT)] public void HandleCompressedObjectUpdate(PacketIn packet) { try { Int32 size = packet.ReadInt32(); byte[] decomped = mClient.Shared.Compression.Decompress(size, packet.ReadRemaining()); packet = new PacketIn(decomped, 1); HandleObjectUpdate(packet); } catch(Exception ex) { Log.WriteLine(LogType.Error, "{1} \n {0}", ex.StackTrace, ex.Message); } } [PacketHandlerAtribute(WorldServerOpCode.SMSG_UPDATE_OBJECT)] public void HandleObjectUpdate(PacketIn packet) { UInt32 UpdateBlocks = packet.ReadUInt32(); for(int allBlocks = 0; allBlocks < UpdateBlocks; allBlocks++) { UpdateType type = (UpdateType)packet.ReadByte(); WoWGuid updateGuid; uint updateId; uint fCount; switch(type) { case UpdateType.Values: Object getObject; updateGuid = new WoWGuid(packet.ReadUInt64()); if (objectMgr.objectExists(updateGuid)) { getObject = objectMgr.getObject(updateGuid); } else { getObject = new Object(updateGuid); objectMgr.addObject(getObject); } Log.WriteLine(LogType.Normal, "Handling Fields Update for object: {0}", getObject.Guid.ToString()); HandleUpdateObjectFieldBlock(packet, getObject); objectMgr.updateObject(getObject); break; case UpdateType.Create: case UpdateType.CreateSelf: updateGuid = new WoWGuid(packet.ReadUInt64()); updateId = packet.ReadByte(); fCount = GeUpdateFieldsCount(updateId); if (objectMgr.objectExists(updateGuid)) objectMgr.delObject(updateGuid); Object newObject = new Object(updateGuid); newObject.Fields = new UInt32[2000]; objectMgr.addObject(newObject); HandleUpdateMovementBlock(packet, newObject); HandleUpdateObjectFieldBlock(packet, newObject); objectMgr.updateObject(newObject); Log.WriteLine(LogType.Normal, "Handling Creation of object: {0}", newObject.Guid.ToString()); break; case UpdateType.OutOfRange: fCount = packet.ReadByte(); for (int j = 0; j < fCount; j++) { WoWGuid guid = new WoWGuid(packet.ReadUInt64()); Log.WriteLine(LogType.Normal, "Handling delete for object: {0}", guid.ToString()); if (objectMgr.objectExists(guid)) objectMgr.delObject(guid); } break; } } } */ public void HandleUpdateMovementBlock(PacketIn packet, Object newObject) { UInt16 flags = packet.ReadUInt16(); if((flags & 0x20) >= 1) { UInt32 flags2 = packet.ReadUInt32(); UInt16 unk1 = packet.ReadUInt16(); UInt32 unk2 = packet.ReadUInt32(); newObject.Position = new Coordinate(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat()); if ((flags2 & 0x200) >= 1) { packet.ReadBytes(21); //transporter } if (((flags2 & 0x2200000) >= 1) || ((unk1 & 0x20) >= 1)) { packet.ReadBytes(4); // pitch } packet.ReadBytes(4); //lastfalltime if ((flags2 & 0x1000) >= 1) { packet.ReadBytes(16); // skip 4 floats } if ((flags2 & 0x4000000) >= 1) { packet.ReadBytes(4); // skip 1 float } packet.ReadBytes(32); // all of speeds if ((flags2 & 0x8000000) >= 1) //spline ;/ { UInt32 splineFlags = packet.ReadUInt32(); if ((splineFlags & 0x00020000) >= 1) { packet.ReadBytes(4); // skip 1 float } else { if ((splineFlags & 0x00010000) >= 1) { packet.ReadBytes(4); // skip 1 float } else if ((splineFlags & 0x00008000) >= 1) { packet.ReadBytes(12); // skip 3 float } } packet.ReadBytes(28); // skip 8 float UInt32 splineCount = packet.ReadUInt32(); for (UInt32 j = 0; j < splineCount; j++) { packet.ReadBytes(12); // skip 3 float } packet.ReadBytes(13); } } else if ((flags & 0x100) >= 1) { packet.ReadBytes(40); } else if ((flags & 0x40) >= 1) { newObject.Position = new Coordinate(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat()); } if ((flags & 0x8) >= 1) { packet.ReadBytes(4); } if ((flags & 0x10) >= 1) { packet.ReadBytes(4); } if ((flags & 0x04) >= 1) { packet.ReadBytes(8); } if ((flags & 0x2) >= 1) { packet.ReadBytes(4); } if ((flags & 0x80) >= 1) { packet.ReadBytes(8); } if ((flags & 0x200) >= 1) { packet.ReadBytes(8); } }
public void HandleRealmlist(PacketIn packetIn) { //packetIn.ReadByte(); UInt16 Length = packetIn.ReadUInt16(); UInt32 Request = packetIn.ReadUInt32(); int realmscount = packetIn.ReadInt16(); //Console.Write(packetIn.ToHex()); Log.WriteLine(LogType.Success, "Got information about {0} realms.", realmscount); Realm[] realms = new Realm[realmscount]; try { for (int i = 0; i < realmscount; i++) { realms[i].Type = packetIn.ReadByte(); realms[i].Color = packetIn.ReadByte(); packetIn.ReadByte(); // unk realms[i].Name = packetIn.ReadString(); realms[i].Address = packetIn.ReadString(); realms[i].Population = packetIn.ReadFloat(); realms[i].NumChars = packetIn.ReadByte(); realms[i].Language = packetIn.ReadByte(); packetIn.ReadByte(); } Realmlist = realms; mCore.Event(new Event(EventType.EVENT_REALMLIST, "", new object[] { Realmlist })); } catch (Exception ex) { Log.WriteLine(LogType.Error, "Exception Occured"); Log.WriteLine(LogType.Error, "Message: {0}", ex.Message); Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace); Disconnect(); } }