Ejemplo n.º 1
0
        /// <summary>Detect map type.</summary>
        /// <param name="rules">The rules.ini file to be used.</param>
        /// <returns>The engine to be used to render this map.</returns>
        public static EngineType DetectEngineType(MapFile mf)
        {
            var vfsTS = new VFS();
            var vfsFS = new VFS();
            var vfsRA2 = new VFS();
            var vfsYR = new VFS();

            if (Directory.Exists(VFS.TSInstallDir)) {
                vfsTS.LoadMixes(VFS.TSInstallDir, EngineType.TiberianSun);
                vfsFS.LoadMixes(VFS.TSInstallDir, EngineType.Firestorm);
            }

            if (Directory.Exists(VFS.RA2InstallDir)) {
                vfsRA2.LoadMixes(VFS.RA2InstallDir, EngineType.RedAlert2);
                vfsYR.LoadMixes(VFS.RA2InstallDir, EngineType.YurisRevenge);
            }

            IniFile rulesTS = vfsTS.OpenFile<IniFile>("rules.ini");
            IniFile rulesFS = vfsFS.OpenFile<IniFile>("rules.ini");
            if (rulesFS != null)
                rulesFS.MergeWith(vfsFS.OpenFile<IniFile>("firestrm.ini"));

            IniFile rulesRA2 = vfsRA2.OpenFile<IniFile>("rules.ini");
            IniFile rulesYR = vfsYR.OpenFile<IniFile>("rulesmd.ini");

            TheaterType theater = Theater.TheaterTypeFromString(mf.ReadString("Map", "Theater"));
            TheaterSettings thsTS = ModConfig.DefaultsTS.GetTheater(theater);
            TheaterSettings thsFS = ModConfig.DefaultsFS.GetTheater(theater);
            TheaterSettings thsRA2 = ModConfig.DefaultsRA2.GetTheater(theater);
            TheaterSettings thsYR = ModConfig.DefaultsYR.GetTheater(theater);

            if (thsTS != null)
                foreach (var f in thsTS.Mixes)
                    vfsTS.AddItem(f);

            if (thsFS != null)
                foreach (var f in thsFS.Mixes)
                    vfsFS.AddItem(f);

            if (thsRA2 != null)
                foreach (var f in thsRA2.Mixes)
                    vfsRA2.AddItem(f);

            if (thsYR != null)
                foreach (var f in thsYR.Mixes)
                    vfsYR.AddItem(f);

            var ret = DetectEngineFromRules(mf, rulesTS, rulesFS, rulesRA2, rulesYR, thsTS, thsFS, thsRA2, thsYR, vfsTS, vfsFS, vfsRA2, vfsYR);
            Logger.Debug("Engine type detected as {0}", ret);
            return ret;
        }
Ejemplo n.º 2
0
        /// <summary>Detect map type.</summary>
        /// <param name="rules">The rules.ini file to be used.</param>
        /// <returns>The engine to be used to render this map.</returns>
        public static EngineType DetectEngineType(MapFile mf)
        {
            var vfsTS  = new VFS();
            var vfsFS  = new VFS();
            var vfsRA2 = new VFS();
            var vfsYR  = new VFS();

            if (Directory.Exists(VFS.TSInstallDir))
            {
                vfsTS.LoadMixes(VFS.TSInstallDir, EngineType.TiberianSun);
                vfsFS.LoadMixes(VFS.TSInstallDir, EngineType.Firestorm);
            }

            if (Directory.Exists(VFS.RA2InstallDir))
            {
                vfsRA2.LoadMixes(VFS.RA2InstallDir, EngineType.RedAlert2);
                vfsYR.LoadMixes(VFS.RA2InstallDir, EngineType.YurisRevenge);
            }

            IniFile rulesTS = vfsTS.OpenFile <IniFile>("rules.ini");
            IniFile rulesFS = vfsFS.OpenFile <IniFile>("rules.ini");

            if (rulesFS != null)
            {
                rulesFS.MergeWith(vfsFS.OpenFile <IniFile>("firestrm.ini"));
            }

            IniFile rulesRA2 = vfsRA2.OpenFile <IniFile>("rules.ini");
            IniFile rulesYR  = vfsYR.OpenFile <IniFile>("rulesmd.ini");

            TheaterType     theater = Theater.TheaterTypeFromString(mf.ReadString("Map", "Theater"));
            TheaterSettings thsTS   = ModConfig.DefaultsTS.GetTheater(theater);
            TheaterSettings thsFS   = ModConfig.DefaultsFS.GetTheater(theater);
            TheaterSettings thsRA2  = ModConfig.DefaultsRA2.GetTheater(theater);
            TheaterSettings thsYR   = ModConfig.DefaultsYR.GetTheater(theater);

            if (thsTS != null)
            {
                foreach (var f in thsTS.Mixes)
                {
                    vfsTS.AddItem(f);
                }
            }

            if (thsFS != null)
            {
                foreach (var f in thsFS.Mixes)
                {
                    vfsFS.AddItem(f);
                }
            }

            if (thsRA2 != null)
            {
                foreach (var f in thsRA2.Mixes)
                {
                    vfsRA2.AddItem(f);
                }
            }

            if (thsYR != null)
            {
                foreach (var f in thsYR.Mixes)
                {
                    vfsYR.AddItem(f);
                }
            }

            var ret = DetectEngineFromRules(mf, rulesTS, rulesFS, rulesRA2, rulesYR, thsTS, thsFS, thsRA2, thsYR, vfsTS, vfsFS, vfsRA2, vfsYR);

            Logger.Debug("Engine type detected as {0}", ret);
            return(ret);
        }