Esempio n. 1
0
        public static void InitKeys()
        {
            if (!Flags.SkipKeys)
            {
                Logger.Info("Core", "Checking ResourceKeys");

                foreach (var key in TrackedFiles[0x90])
                {
                    if (!ValidKey(key))
                    {
                        continue;
                    }

                    var resourceKey = GetInstance <STUResourceKey>(key);
                    if (resourceKey == null || resourceKey.GetKeyID() == 0 || Client.ConfigHandler.Keyring.Keys.ContainsKey(resourceKey.GetReverseKeyID()))
                    {
                        continue;
                    }
                    Client.ConfigHandler.Keyring.AddKey(resourceKey.GetReverseKeyID(), resourceKey.m_key);
                    Logger.Info("Core", $"Added ResourceKey {resourceKey.GetKeyIDString()}, Value: {resourceKey.GetKeyValueString()}");
                }
            }
        }
Esempio n. 2
0
        private static void Main()
        {
            InitTankSettings();

            HookConsole();

            var tools = GetTools();

        #if DEBUG
            FlagParser.CheckCollisions(typeof(ToolFlags), (flag, duplicate) => {
                Logger.Error("Flag", $"The flag \"{flag}\" from {duplicate} is a duplicate!");
            });
        #endif

            FlagParser.LoadArgs();

            Logger.Info("Core", $"{Assembly.GetExecutingAssembly().GetName().Name} v{Util.GetVersion(typeof(Program).Assembly)}");

            Logger.Info("Core", $"CommandLine: [{string.Join(", ", FlagParser.AppArgs.Select(x => $"\"{x}\""))}]");

            Flags = FlagParser.Parse <ToolFlags>(full => PrintHelp(full, tools));
            if (Flags == null)
            {
                return;
            }

            Logger.Info("Core", $"CommandLineFile: {FlagParser.ArgFilePath}");

            if (Flags.SaveArgs)
            {
                FlagParser.AppArgs = FlagParser.AppArgs.Where(x => !x.StartsWith("--arg")).ToArray();
                FlagParser.SaveArgs(Flags.OverwatchDirectory);
            }
            else if (Flags.ResetArgs || Flags.DeleteArgs)
            {
                FlagParser.ResetArgs();

                if (Flags.DeleteArgs)
                {
                    FlagParser.DeleteArgs();
                }

                Logger.Info("Core", $"CommandLineNew: [{string.Join(", ", FlagParser.AppArgs.Select(x => $"\"{x}\""))}]");
                Flags = FlagParser.Parse <ToolFlags>(full => PrintHelp(full, tools));
                if (Flags == null)
                {
                    return;
                }
            }

            if (string.IsNullOrWhiteSpace(Flags.OverwatchDirectory) || string.IsNullOrWhiteSpace(Flags.Mode) || Flags.Help)
            {
                PrintHelp(false, tools);
                return;
            }

            ITool         targetTool           = null;
            ICLIFlags     targetToolFlags      = null;
            ToolAttribute targetToolAttributes = null;

            #region Tool Activation

            foreach (var type in tools)
            {
                var attribute = type.GetCustomAttribute <ToolAttribute>();

                if (!string.Equals(attribute.Keyword, Flags.Mode, StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }
                targetTool           = Activator.CreateInstance(type) as ITool;
                targetToolAttributes = attribute;

                if (attribute.CustomFlags != null)
                {
                    var flags = attribute.CustomFlags;
                    if (typeof(ICLIFlags).IsAssignableFrom(flags))
                    {
                        targetToolFlags = typeof(FlagParser).GetMethod(nameof(FlagParser.Parse), new Type[] { })
                                          ?.MakeGenericMethod(flags)
                                          .Invoke(null, null) as ICLIFlags;
                    }
                }

                break;
            }

            if (targetToolFlags == null && targetTool != null)
            {
                return;
            }

            if (targetTool == null)
            {
                FlagParser.Help <ToolFlags>(false, new Dictionary <string, string>());
                PrintHelp(false, tools);
                return;
            }

            #endregion

            if (!targetToolAttributes.UtilNoArchiveNeeded)
            {
                try {
                    InitStorage(Flags.Online);
                } catch {
                    Logger.Log24Bit(ConsoleSwatch.XTermColor.OrangeRed, true, Console.Error, "CASC",
                                    "=================\nError initializing CASC!\n" +
                                    "Please Scan & Repair your game, launch it for a minute, and try the tools again before reporting a bug!\n" +
                                    "========================");
                    throw;
                }

                //foreach (KeyValuePair<ushort, HashSet<ulong>> type in TrackedFiles.OrderBy(x => x.Key)) {
                //    //Console.Out.WriteLine($"Found type: {type.Key:X4} ({type.Value.Count} files)");
                //    Console.Out.WriteLine($"Found type: {type.Key:X4}");
                //}

                InitKeys();
                InitMisc();
            }

            var stopwatch = new Stopwatch();
            Logger.Info("Core", "Tooling...");
            stopwatch.Start();
            targetTool.Parse(targetToolFlags);
            stopwatch.Stop();

            Logger.Success("Core", $"Execution finished in {stopwatch.Elapsed} seconds");

            ShutdownMisc();
        }
Esempio n. 3
0
        public static void InitStorage(bool online = false)   // turnin offline off again, can cause perf issues with bundle hack
        // Attempt to load language via registry, if they were already provided via flags then this won't do anything
        {
            if (!Flags.NoLanguageRegistry)
            {
                TryFetchLocaleFromRegistry();
            }

            Logger.Info("CASC", $"Text Language: {Flags.Language} | Speech Language: {Flags.SpeechLanguage}");

            var args = new ClientCreateArgs {
                SpeechLanguage = Flags.SpeechLanguage,
                TextLanguage   = Flags.Language,
                HandlerArgs    = new ClientCreateArgs_Tank {
                    CacheAPM = Flags.UseCache, ManifestRegion = Flags.RCN ? ProductHandler_Tank.REGION_CN : ProductHandler_Tank.REGION_DEV
                },
                Online = online
            };

            LoadHelper.PreLoad();
            Client = new ClientHandler(Flags.OverwatchDirectory, args);
            LoadHelper.PostLoad(Client);

            if (args.TextLanguage != "enUS")
            {
                Logger.Warn("Core", "Reminder! When extracting data in other languages, the names of the heroes/skins/etc must be in the language you have chosen.");
            }

            if (Client.AgentProduct.ProductCode != "pro")
            {
                Logger.Warn("Core", $"The branch \"{Client.AgentProduct.ProductCode}\" is not supported!. This might result in failure to load. Proceed with caution.");
            }

            var clientLanguages = Client.AgentProduct.Settings.Languages.Select(x => x.Language).ToArray();

            if (!clientLanguages.Contains(args.TextLanguage))
            {
                Logger.Warn("Core", "Battle.Net Agent reports that text language {0} is not installed.", args.TextLanguage);
            }
            else if (!clientLanguages.Contains(args.SpeechLanguage))
            {
                Logger.Warn("Core", "Battle.Net Agent reports that speech language {0} is not installed.", args.SpeechLanguage);
            }

            TankHandler = Client.ProductHandler as ProductHandler_Tank;
            if (TankHandler == null)
            {
                Logger.Error("Core", $"Not a valid Overwatch installation (detected product: {Client.Product})");
                return;
            }

            BuildVersion = uint.Parse(Client.InstallationInfo.Values["Version"].Split('.').Last());
            if (BuildVersion < 39028)
            {
                Logger.Error("Core", "DataTool doesn't support Overwatch versions below 1.14. Please use OverTool.");
            }
            else if (BuildVersion < ProductHandler_Tank.VERSION_152_PTR)
            {
                Logger.Error("Core", "This version of DataTool doesn't support versions of Overwatch below 1.52. Please downgrade DataTool.");
            }

            InitTrackedFiles();
        }