public void CalculateHashes(List <GameMode> gameModes)
        {
            fh = new FileHashes
            {
                GameOptionsHash = Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + ProgramConstants.BASE_RESOURCE_PATH + "GameOptions.ini"),
                ClientDXHash    = Utilities.CalculateSHA1ForFile(ProgramConstants.GetBaseResourcePath() + "clientdx.exe"),
                ClientXNAHash   = Utilities.CalculateSHA1ForFile(ProgramConstants.GetBaseResourcePath() + "clientxna.exe"),
                ClientOGLHash   = Utilities.CalculateSHA1ForFile(ProgramConstants.GetBaseResourcePath() + "clientogl.exe"),
                MainExeHash     = Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + ClientConfiguration.Instance.GetGameExecutableName()),
                LauncherExeHash = Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + ClientConfiguration.Instance.GetGameLauncherExecutableName),
                MPMapsHash      = Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + ClientConfiguration.Instance.MPMapsIniPath),
                INIHashes       = string.Empty
            };

            foreach (string filePath in fileNamesToCheck)
            {
                fh.INIHashes = AddToStringIfFileExists(fh.INIHashes, filePath);
                Logger.Log("Hash for " + filePath + ": " +
                           Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + filePath));
            }

            #if !YR
            if (Directory.Exists(ProgramConstants.GamePath + "INI\\Map Code"))
            {
                foreach (GameMode gameMode in gameModes)
                {
                    fh.INIHashes = AddToStringIfFileExists(fh.INIHashes, "INI\\Map Code\\" + gameMode.Name + ".ini");
                    Logger.Log("Hash for INI\\Map Code\\" + gameMode.Name + ".ini :" +
                               Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + "INI\\Map Code\\" + gameMode.Name + ".ini"));
                }
            }
            #endif

            if (Directory.Exists(ProgramConstants.GamePath + "INI\\Game Options"))
            {
                List <string> files = Directory.GetFiles(
                    ProgramConstants.GamePath + "INI\\Game Options",
                    "*", SearchOption.AllDirectories).ToList();

                files.Sort();

                foreach (string fileName in files)
                {
                    fh.INIHashes = fh.INIHashes + Utilities.CalculateSHA1ForFile(fileName);
                    Logger.Log("Hash for " + fileName + ": " +
                               Utilities.CalculateSHA1ForFile(fileName));
                }
            }

            fh.INIHashes = Utilities.CalculateSHA1ForString(fh.INIHashes);
        }
Пример #2
0
        public string GetCompleteHash()
        {
            string str = fh.GameOptionsHash;

            str = str + fh.ClientDXHash;
            str = str + fh.ClientXNAHash;
            str = str + fh.MainExeHash;
            str = str + fh.INIHashes;
            str = str + fh.MPMapsHash;

            Logger.Log("Complete hash: " + Utilities.CalculateSHA1ForString(str));

            return(Utilities.CalculateSHA1ForString(str));
        }
        public string GetCompleteHash()
        {
            string str = fh.GameOptionsHash;
            str += fh.ClientDXHash;
            str += fh.ClientXNAHash;
            str += fh.ClientOGLHash;
            str += fh.GameExeHash;
            str += fh.LauncherExeHash;
            str += fh.INIHashes;
            str += fh.MPMapsHash;
            str += fh.FHCConfigHash;

            Logger.Log("Complete hash: " + Utilities.CalculateSHA1ForString(str));

            return Utilities.CalculateSHA1ForString(str);
        }
Пример #4
0
        public void CalculateHashes(List <GameMode> gameModes)
        {
            fh = new FileHashes
            {
                GameOptionsHash = Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + ProgramConstants.BASE_RESOURCE_PATH + "GameOptions.ini"),
                ClientDXHash    = Utilities.CalculateSHA1ForFile(ProgramConstants.GetBaseResourcePath() + "clientdx.exe"),
                ClientXNAHash   = Utilities.CalculateSHA1ForFile(ProgramConstants.GetBaseResourcePath() + "clientxna.exe"),
                ClientOGLHash   = Utilities.CalculateSHA1ForFile(ProgramConstants.GetBaseResourcePath() + "clientogl.exe"),
                GameExeHash     = calculateGameExeHash ?
                                  Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + ClientConfiguration.Instance.GetGameExecutableName()) : string.Empty,
                LauncherExeHash = Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + ClientConfiguration.Instance.GameLauncherExecutableName),
                MPMapsHash      = Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + ClientConfiguration.Instance.MPMapsIniPath),
                FHCConfigHash   = Utilities.CalculateSHA1ForFile(ProgramConstants.BASE_RESOURCE_PATH + CONFIGNAME),
                INIHashes       = string.Empty
            };

            Logger.Log("Hash for " + ProgramConstants.BASE_RESOURCE_PATH + CONFIGNAME + ": " + fh.FHCConfigHash);
            Logger.Log("Hash for " + ProgramConstants.BASE_RESOURCE_PATH + "GameOptions.ini: " + fh.GameOptionsHash);
            Logger.Log("Hash for " + ProgramConstants.BASE_RESOURCE_PATH + "clientdx.exe: " + fh.ClientDXHash);
            Logger.Log("Hash for " + ProgramConstants.BASE_RESOURCE_PATH + "clientxna.exe: " + fh.ClientXNAHash);
            Logger.Log("Hash for " + ProgramConstants.BASE_RESOURCE_PATH + "clientogl.exe: " + fh.ClientOGLHash);
            Logger.Log("Hash for " + ClientConfiguration.Instance.MPMapsIniPath + ": " + fh.MPMapsHash);
            if (calculateGameExeHash)
            {
                Logger.Log("Hash for " + ClientConfiguration.Instance.GetGameExecutableName() + ": " + fh.GameExeHash);
            }
            if (!string.IsNullOrEmpty(ClientConfiguration.Instance.GameLauncherExecutableName))
            {
                Logger.Log("Hash for " + ClientConfiguration.Instance.GameLauncherExecutableName + ": " + fh.LauncherExeHash);
            }

            foreach (string filePath in fileNamesToCheck)
            {
                fh.INIHashes = AddToStringIfFileExists(fh.INIHashes, filePath);
                Logger.Log("Hash for " + filePath + ": " +
                           Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + filePath));
            }

            string[] iniPaths = new string[]
            {
#if !YR
                ProgramConstants.GamePath + "INI/Map Code",
#endif
                ProgramConstants.GamePath + "INI/Game Options"
            };

            foreach (string path in iniPaths)
            {
                if (!string.IsNullOrEmpty(path) && Directory.Exists(path))
                {
                    List <string> files = Directory.GetFiles(path, "*", SearchOption.AllDirectories).
                                          Select(s => s.Replace(ProgramConstants.GamePath, "").Replace("\\", "/")).ToList();

                    files.Sort();

                    foreach (string filename in files)
                    {
                        string sha1 = Utilities.CalculateSHA1ForFile(ProgramConstants.GamePath + filename);
                        fh.INIHashes += sha1;
                        Logger.Log("Hash for " + filename + ": " + sha1);
                    }
                }
            }

            fh.INIHashes = Utilities.CalculateSHA1ForString(fh.INIHashes);
        }