private static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum<ObjectType>("Object Type", TypeCode.Byte, index); packet.WriteLine("Pos: " + packet.Position); packet.ResetBitReader(); var moves = ReadMovementUpdateBlock548(ref packet, guid, index); packet.WriteLine("Pos: " + packet.Position); packet.ResetBitReader(); var updates = CoreParsers.UpdateHandler.ReadValuesUpdateBlock(ref packet, objType, index, true); WoWObject obj; switch (objType) { case ObjectType.Unit: obj = new Unit(); break; case ObjectType.GameObject: obj = new GameObject(); break; case ObjectType.Item: obj = new Item(); break; case ObjectType.Player: obj = new Player(); break; default: obj = new WoWObject(); break; } obj.Type = objType; obj.Movement = moves; obj.UpdateFields = updates; obj.Map = map; obj.Area = CoreParsers.WorldStateHandler.CurrentAreaId; obj.PhaseMask = (uint)CoreParsers.MovementHandler.CurrentPhaseMask; // If this is the second time we see the same object (same guid, // same position) update its phasemask if (Storage.Objects.ContainsKey(guid)) { var existObj = Storage.Objects[guid].Item1; CoreParsers.UpdateHandler.ProcessExistingObject(ref existObj, obj, guid); // can't do "ref Storage.Objects[guid].Item1 directly } else Storage.Objects.Add(guid, obj, packet.TimeSpan); if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject)) packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN"); }
private static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum<ObjectType>("Object Type", TypeCode.Byte, index); var moves = ReadMovementUpdateBlock(ref packet, guid, index); var updates = ReadValuesUpdateBlock(ref packet, objType, index); var obj = new WoWObject {Type = objType, Movement = moves, UpdateFields = updates, Map = map, Area = WorldStateHandler.CurrentAreaId, PhaseMask = (uint) MovementHandler.CurrentPhaseMask}; if (guid.HasEntry() && guid.GetObjectType() == ObjectType.Unit) { List<string> lines = new List<string>(); lines.Add("UpdateType: Values"); foreach (var data in updates) lines.Add("Block Value " + UpdateFields.GetUpdateFieldName(data.Key, "UnitField") + ": " + data.Value.Int32Value + "/" + data.Value.SingleValue); if (packet.SniffFileInfo.Stuffing.upObjPackets.ContainsKey(guid)) packet.SniffFileInfo.Stuffing.upObjPackets[guid].upObjPackets.Enqueue(new UpdateObjectPacket(packet.Time, packet.Number, lines)); else packet.SniffFileInfo.Stuffing.upObjPackets.TryAdd(guid, new UpdateObjectPackets(new UpdateObjectPacket(packet.Time, packet.Number, lines))); } packet.SniffFileInfo.Stuffing.Objects.TryAdd(guid, obj); if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject)) packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN"); }
private static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum<ObjectType>("Object Type", TypeCode.Byte, index); var moves = ReadMovementUpdateBlock(ref packet, guid, index); var updates = ReadValuesUpdateBlock(ref packet, objType, index); WoWObject obj; switch (objType) { case ObjectType.Unit: obj = new Unit(); break; case ObjectType.GameObject: obj = new GameObject(); break; case ObjectType.Item: obj = new Item(); break; case ObjectType.Player: obj = new Player(); break; default: obj = new WoWObject(); break; } obj.Type = objType; obj.Movement = moves; obj.UpdateFields = updates; obj.Map = map; obj.Area = WorldStateHandler.CurrentAreaId; obj.PhaseMask = (uint) MovementHandler.CurrentPhaseMask; Storage.Objects.TryAdd(guid, obj); if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject)) packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN"); }
private static void ProcessExistingObject(ref WoWObject obj, WoWObject newObj, Guid guid) { obj.PhaseMask |= newObj.PhaseMask; if (guid.GetHighType() == HighGuidType.Unit) // skip if not an unit { if (!obj.Movement.HasWpsOrRandMov) if (obj.Movement.Position != newObj.Movement.Position) { UpdateField uf; if (obj.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(UnitField.UNIT_FIELD_FLAGS), out uf)) if ((uf.UInt32Value & (uint) UnitFlags.IsInCombat) == 0) // movement could be because of aggro so ignore that obj.Movement.HasWpsOrRandMov = true; } } }
private static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum<ObjectType>("Object Type", TypeCode.Byte, index); var moves = ReadMovementUpdateBlock(ref packet, guid, index); var updates = ReadValuesUpdateBlock(ref packet, objType, index); var obj = new WoWObject {Type = objType, Movement = moves, UpdateFields = updates, Map = map, Area = WorldStateHandler.CurrentAreaId, PhaseMask = (uint) MovementHandler.CurrentPhaseMask}; packet.SniffFileInfo.Stuffing.Objects.TryAdd(guid, obj); if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject)) packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN"); }
private static bool GetTransportMap(WoWObject @object, out int mapId) { mapId = -1; WoWObject transport; if (!Storage.Objects.TryGetValue(@object.Movement.TransportGuid, out transport)) return false; UpdateField entry; if (!transport.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(ObjectField.OBJECT_FIELD_ENTRY), out entry)) return false; if (SQLConnector.Enabled) { var transportTemplates = SQLDatabase.GetDict<uint, GameObjectTemplate>(new List<uint> { entry.UInt32Value }); if (transportTemplates.IsEmpty()) return false; mapId = transportTemplates[entry.UInt32Value].Item1.Data[6]; } return true; }
public static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum<ObjectType>("Object Type", TypeCode.Byte, index); var moves = ReadMovementUpdateBlock(ref packet, guid, index); var updates = ReadValuesUpdateBlock(ref packet, objType, index); var obj = new WoWObject {Type = objType, Movement = moves, UpdateFields = updates, Map = map}; Stuffing.Objects.TryAdd(guid, obj); HandleUpdateFieldChangedValues(guid, objType, updates, moves, true); }
private static bool GetTransportMap(WoWObject @object, out int mapId) { mapId = -1; WoWObject transport; if (!Storage.Objects.TryGetValue(@object.Movement.TransportGuid, out transport)) return false; UpdateField entry; if (transport.UpdateFields == null || !transport.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(ObjectField.OBJECT_FIELD_ENTRY), out entry)) return false; if (SQLConnector.Enabled) { var transportTemplates = SQLDatabase.Get(new RowList<GameObjectTemplate> { new GameObjectTemplate { Entry = entry.UInt32Value } }); if (transportTemplates.Count == 0) return false; mapId = transportTemplates.First().Data.Data[6].GetValueOrDefault(); } return true; }
private static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum<ObjectType>("Object Type", TypeCode.Byte, index); var moves = ReadMovementUpdateBlock(ref packet, guid, index); var updates = ReadValuesUpdateBlock(ref packet, objType, index); switch (objType) { case ObjectType.Unit: var unit = new Unit {Type = objType, Movement = moves, UpdateFields = updates, Map = map, Area = WorldStateHandler.CurrentAreaId, PhaseMask = (uint) MovementHandler.CurrentPhaseMask}; packet.SniffFileInfo.Storage.Objects.TryAdd(guid, unit); break; case ObjectType.GameObject: var go = new GameObject {Type = objType, Movement = moves, UpdateFields = updates, Map = map, Area = WorldStateHandler.CurrentAreaId, PhaseMask = (uint) MovementHandler.CurrentPhaseMask}; packet.SniffFileInfo.Storage.Objects.TryAdd(guid, go); break; case ObjectType.Item: var item = new Item {Type = objType, Movement = moves, UpdateFields = updates, Map = map, Area = WorldStateHandler.CurrentAreaId, PhaseMask = (uint) MovementHandler.CurrentPhaseMask}; packet.SniffFileInfo.Storage.Objects.TryAdd(guid, item); break; case ObjectType.Player: var player = new Player {Type = objType, Movement = moves, UpdateFields = updates, Map = map, Area = WorldStateHandler.CurrentAreaId, PhaseMask = (uint) MovementHandler.CurrentPhaseMask}; packet.SniffFileInfo.Storage.Objects.TryAdd(guid, player); break; default: var obj = new WoWObject {Type = objType, Movement = moves, UpdateFields = updates, Map = map, Area = WorldStateHandler.CurrentAreaId, PhaseMask = (uint) MovementHandler.CurrentPhaseMask}; packet.SniffFileInfo.Storage.Objects.TryAdd(guid, obj); break; } if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject)) packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN"); }