void HandlePong(PacketIn packet) { UInt32 Server_Seq = packet.ReadUInt32(); if (Server_Seq == Ping_Seq) { Ping_Res_Time = MM_GetTime(); Latency = Ping_Res_Time - Ping_Req_Time; Ping_Seq += 1; Log.WriteLine(LogType.Debug, "Got nice pong. We love server;)"); } else Log.WriteLine(LogType.Error, "Server pong'd bad sequence! Ours: {0} Theirs: {1}", Ping_Seq, Server_Seq); }
public void Handle_NameQuery(PacketIn packet) { WoWGuid guid = new WoWGuid(packet.ReadUInt64()); string name = packet.ReadString(); packet.ReadByte(); Race Race = (Race)packet.ReadUInt32(); Gender Gender = (Gender)packet.ReadUInt32(); Classname Class = (Classname)packet.ReadUInt32(); if (objectMgr.objectExists(guid)) // Update existing Object { Object obj = objectMgr.getObject(guid); obj.Name = name; objectMgr.updateObject(obj); } else // Create new Object -- FIXME: Add to new 'names only' list? { Object obj = new Object(guid); obj.Name = name; objectMgr.addObject(obj); /* Process chat message if we looked them up now */ for (int i = 0; i < ChatQueued.Count; i++) { ChatQueue message = (ChatQueue)ChatQueued[i]; if (message.GUID.GetOldGuid() == guid.GetOldGuid()) { Log.WriteLine(LogType.Chat, "[{1}] {0}", message.Message, name); ChatQueued.Remove(message); } } } }
public void HandleUpdateObjectFieldBlock(PacketIn packet, Object newObject) { uint lenght = packet.ReadByte(); UpdateMask UpdateMask = new UpdateMask(); UpdateMask.SetCount((ushort)(lenght)); UpdateMask.SetMask(packet.ReadBytes((int)lenght * 4), (ushort)lenght); UInt32[] Fields = new UInt32[UpdateMask.GetCount()]; for (int i = 0; i < UpdateMask.GetCount(); i++) { if (!UpdateMask.GetBit((ushort)i)) { UInt32 val = packet.ReadUInt32(); newObject.SetField(i, val); Log.WriteLine(LogType.Normal, "Update Field: {0} = {1}", (UpdateFields)i, val); } } }
public void Handle_CreatureQuery(PacketIn packet) { Entry entry = new Entry(); entry.entry = packet.ReadUInt32(); entry.name = packet.ReadString(); entry.blarg = packet.ReadBytes(3); entry.subname = packet.ReadString(); entry.flags = packet.ReadUInt32(); entry.subtype = packet.ReadUInt32(); entry.family = packet.ReadUInt32(); entry.rank = packet.ReadUInt32(); foreach (Object obj in objectMgr.getObjectArray()) { if (obj.Fields != null) { if (obj.Fields[(int)UpdateFields.OBJECT_FIELD_ENTRY] == entry.entry) { obj.Name = entry.name; objectMgr.updateObject(obj); } } } }
/* [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(); } }
public void HandleCharEnum(PacketIn packet) { byte count = packet.ReadByte(); Character[] characterList = new Character[count]; for (int i = 0; i < count; i++) { characterList[i].GUID = packet.ReadUInt64(); characterList[i].Name = packet.ReadString(); characterList[i].Race = packet.ReadByte(); characterList[i].Class = packet.ReadByte(); packet.ReadByte(); packet.ReadUInt32(); packet.ReadByte(); packet.ReadByte(); packet.ReadUInt32(); characterList[i].MapID = packet.ReadUInt32(); packet.ReadFloat(); packet.ReadFloat(); packet.ReadFloat(); packet.ReadUInt32(); packet.ReadUInt32(); packet.ReadByte(); packet.ReadUInt32(); packet.ReadUInt32(); packet.ReadUInt32(); packet.ReadBytes(9 * 20); } Log.WriteLine(LogType.Success, "Received info about {0} characters", count); Charlist = characterList; mCore.Event(new Event(EventType.EVENT_CHARLIST, "", new object[] { Charlist })); PingLoop(); }
public void HandleAuthChallange(PacketIn packet) { packet.ReadUInt32(); ServerSeed = packet.ReadUInt32(); ClientSeed = (UInt32)0; DoAuthSession(); }
public void HandleChat(PacketIn packet) { try { string channel = null; UInt64 guid = 0; WoWGuid fguid = null, fguid2 = null; string username = null; byte Type = packet.ReadByte(); UInt32 Language = packet.ReadUInt32(); guid = packet.ReadUInt64(); fguid = new WoWGuid(guid); packet.ReadInt32(); if ((ChatMsg)Type == ChatMsg.Channel) { channel = packet.ReadString(); } if (Type == 47) return; fguid2 = new WoWGuid(packet.ReadUInt64()); UInt32 Length = packet.ReadUInt32(); string Message = Encoding.Default.GetString(packet.ReadBytes((int)Length)); //Message = Regex.Replace(Message, @"\|H[a-zA-z0-9:].|h", ""); // Why do i should need spells and quest linked? ;> Message = Regex.Replace(Message, @"\|[rc]{1}[a-zA-z0-9]{0,8}", ""); // Colorfull chat message also isn't the most important thing. byte afk = 0; if (fguid.GetOldGuid() == 0) { username = "******"; } else { if (objectMgr.objectExists(fguid)) username = objectMgr.getObject(fguid).Name; } if (username == null) { ChatQueue que = new ChatQueue(); que.GUID = fguid; que.Type = Type; que.Language = Language; if ((ChatMsg)Type == ChatMsg.Channel) que.Channel = channel; que.Length = Length; que.Message = Message; que.AFK = afk; ChatQueued.Add(que); QueryName(guid); return; } object[] param = new object[] { (ChatMsg)Type, channel, username, Message }; mCore.Event(new Event(EventType.EVENT_CHAT_MSG, "0", param)); //Log.WriteLine(LogType.Chat, "[{1}] {0}", Message, username); } 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); } }