public static void GameobjectQueryResponse(Packet packet) { GameObject go = new GameObject(); var entry = packet.ReadEntryKey("Entry"); go.Entry = entry.Key; if (entry.Value) { return; } go.Type = packet.ReadEnum <GameObjectType>("Type"); go.DisplayID = packet.ReadInt32("Display ID"); for (var i = 0; i < 4; i++) { go.Name[i] = packet.ReadCString("Name " + i); } go.IconName = packet.ReadCString("Icon Name"); go.CastCaption = packet.ReadCString("Cast Caption"); go.UnkString = packet.ReadCString("Unk String"); for (var i = 0; i < 32; i++) { go.Data[i] = packet.ReadInt32("Data " + i); } go.Size = packet.ReadSingle("Size"); for (var i = 0; i < 6; i++) { go.QuestItems[i] = packet.ReadInt32("Quest Item " + i); } go.Exp = packet.ReadInt32("Expansion ID"); GameObjectStorage.GetSingleton().Add(go); }
private static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; CmdLine = new CommandLine(args); string file; string loader; string nodump; string nohex; string tosql; string skiplarge; bool _toSQL = false; try { file = CmdLine.GetValue("-file"); loader = CmdLine.GetValue("-loader"); nodump = CmdLine.GetValue("-nodump"); nohex = CmdLine.GetValue("-nohex"); tosql = CmdLine.GetValue("-tosql"); skiplarge = CmdLine.GetValue("-skiplarge"); if (tosql.Equals(bool.TrueString, StringComparison.InvariantCultureIgnoreCase)) { _toSQL = true; } } catch (IndexOutOfRangeException) { PrintUsage("All command line options require an argument."); return; } try { var packets = Reader.Read(loader, file); if (packets == null) { PrintUsage("Could not open file " + file + " for reading."); return; } if (packets.Count() > 0) { var fullPath = Utilities.GetPathFromFullPath(file); Handler.InitializeLogFile(Path.Combine(fullPath, file + ".txt"), nodump, nohex, skiplarge); foreach (var packet in packets) { Handler.Parse(packet); } Handler.WriteToFile(); } } catch (Exception ex) { Console.WriteLine(ex.GetType()); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } Console.ResetColor(); if (_toSQL) { var fullPath = Utilities.GetPathFromFullPath(file); QuestStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_questcache.sql")); CreatureStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_creaturecache.sql")); GameObjectStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_gameobjectcache.sql")); CreatureTemplateUpdateStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_creaturecacheupdates.sql")); CreatureSpawnStorage css = CreatureSpawnStorage.GetSingleton(); GameObjectSpawnStorage gss = GameObjectSpawnStorage.GetSingleton(); Dictionary <int, Dictionary <Guid, WowObject> > dict = ObjectHandler.Objects; foreach (int map in dict.Keys) { Dictionary <Guid, WowObject> objectsInMap = dict[map]; foreach (Guid guid in objectsInMap.Keys) { WowObject obj = objectsInMap[guid]; if (obj.Type == ObjectType.Unit) { CreatureSpawn spawn = new CreatureSpawn(); spawn.Entry = guid.GetEntry(); spawn.Map = map; spawn.X = obj.Position.X; spawn.Y = obj.Position.Y; spawn.Z = obj.Position.Z; spawn.O = obj.Movement.Orientation; css.Add(spawn); } else if (obj.Type == ObjectType.GameObject) { GameObjectSpawn spawn = new GameObjectSpawn(); spawn.Entry = guid.GetEntry(); spawn.Map = map; spawn.X = obj.Position.X; spawn.Y = obj.Position.Y; spawn.Z = obj.Position.Z; spawn.O = obj.Movement.Orientation; gss.Add(spawn); } } } css.Output(Path.Combine(fullPath, file + "_creaturesniffedspawns.sql")); gss.Output(Path.Combine(fullPath, file + "_gameobjectsniffedspawns.sql")); } }