コード例 #1
0
        public static InstallationDirStatus Validate(string path)
        {
            if (!Directory.Exists(path))
            {
                return(CreateInvalid("The directory does not exist."));
            }

            foreach (var requiredFile in RequiredFiles)
            {
                var fullPath = Path.Combine(path, requiredFile);
                if (!File.Exists(fullPath))
                {
                    return(CreateInvalid("Required file " + requiredFile + " is missing."));
                }
            }

            var dllPath    = Path.Combine(path, "temple.dll");
            var dllVersion = TempleDllVersion.Identify(dllPath);

            if (!dllVersion.Supported)
            {
                return(CreateInvalid("Unsupported temple.dll Version found: "
                                     + dllVersion.Description));
            }


            // It's a Co8 DLL, check if the required script file exists
            if (dllVersion.Co8)
            {
                var co8Init = Path.Combine(path, "data", "scr", "_co8init.py");
                if (!File.Exists(co8Init))
                {
                    return(CreateInvalid("A Co8 temple.dll is being used without the required Co8 data files."));
                }
                if (App._iniViewModel.NeedsCo8Defaults)
                {
                    App._iniViewModel.NumberOfPcs       = NumberOfPcsType.Flexible;
                    App._iniViewModel.MaxLevel          = 30;
                    App._iniViewModel.MetamagicStacking = true; // this is true ever since Moebius patch...
                }
            }

            var result = new InstallationDirStatus {
                Valid = true, Status = dllVersion.Description, IsCo8 = dllVersion.Co8, ModuleNames = new List <string>()
            };
            DirectoryInfo di = new DirectoryInfo(Path.Combine(path, "modules"));

            FileInfo[] rgFiles = di.GetFiles("*.dat", SearchOption.TopDirectoryOnly);

            foreach (FileInfo datFile in rgFiles)
            {
                if (datFile.Name.EndsWith("_core.dat", System.StringComparison.OrdinalIgnoreCase))  // ignore MODULENAME_core.dat
                {
                    continue;
                }
                result.ModuleNames.Add(datFile.Name.Split('.')[0]);
            }
            return(result);
        }
コード例 #2
0
        public static InstallationDirStatus Validate(string path)
        {
            if (!Directory.Exists(path))
            {
                return(CreateInvalid("The directory does not exist."));
            }

            foreach (var requiredFile in RequiredFiles)
            {
                var fullPath = Path.Combine(path, requiredFile);
                if (!File.Exists(fullPath))
                {
                    return(CreateInvalid("Required file " + requiredFile + " is missing."));
                }
            }

            var dllPath    = Path.Combine(path, "temple.dll");
            var dllVersion = TempleDllVersion.Identify(dllPath);

            if (!dllVersion.Supported)
            {
                return(CreateInvalid("Unsupported temple.dll Version found: "
                                     + dllVersion.Description));
            }


            // It's a Co8 DLL, check if the required script file exists
            if (dllVersion.Co8)
            {
                var co8Init = Path.Combine(path, "data", "scr", "_co8init.py");
                if (!File.Exists(co8Init))
                {
                    return(CreateInvalid("A Co8 temple.dll is being used without the required Co8 data files."));
                }
                if (App._iniViewModel.NeedsCo8Defaults)
                {
                    App._iniViewModel.NumberOfPcs = NumberOfPcsType.Flexible;
                    App._iniViewModel.MaxLevel    = 30;
                }
            }

            return(new InstallationDirStatus {
                Valid = true, Status = dllVersion.Description, IsCo8 = dllVersion.Co8
            });
        }
コード例 #3
0
        public static TempleDllVersion Identify(string dllPath)
        {
            // Slurp the file into memory
            var dllData = File.ReadAllBytes(dllPath);

            var result = new TempleDllVersion();

            if (CheckSignature(dllData, VanillaDllSignature.Patch3Signature.Offset,
                               VanillaDllSignature.Patch3Signature.Pattern))
            {
                result.VanillaVersion = VanillaDllVersion.Patch3;
                // No known mods of patch 3
                return(result);
            }

            if (!CheckSignature(dllData, VanillaDllSignature.Patch2Signature.Offset,
                                VanillaDllSignature.Patch2Signature.Pattern))
            {
                // Unknown version
                result.VanillaVersion = VanillaDllVersion.Unknown;
                return(result);
            }

            // Anything Patch2 should be supported, really
            result.Supported = true;

            if (IsCo8SavehookPresent(dllData))
            {
                result.Co8 = true;
            }

            if (CheckSignature(dllData, 0x15c0, new byte[]
            {
                0xE8, 0xFB, 0xA1, 0x0F, 0x00
            }))
            {
                result.MoebiusFixes = true;
            }

            return(result);
        }