コード例 #1
0
 private void WhenClassTableIsLoaded()
 {
     _classTable = ClassTable.ReadClassTable(_loadedClassTablePath);
 }
コード例 #2
0
        public FileInfo FindThreeDeeCockpitFile(int vehicleACD)
        {
            if (vehicleACD == -1)
            {
                return(FindThreeDeeCockpitFileUsingOldMethod());
            }

            var file = string.Empty;

            try
            {
                var exePath = _bmsRunningExecutableLocator.BMSExePath;
                if (exePath == null)
                {
                    return(null);
                }

                exePath += Path.DirectorySeparatorChar;
                var bmsBaseDirectory  = new DirectoryInfo(exePath).Parent.Parent.FullName + Path.DirectorySeparatorChar;
                var currentTheaterTdf = _currentTheaterDotTdfLoader.GetCurrentTheaterDotTdf(bmsBaseDirectory);
                var dataDir           = Path.Combine(bmsBaseDirectory, "data");

                var artDir            = Path.Combine(dataDir, currentTheaterTdf != null ? currentTheaterTdf.artDir ?? "art" : "art");
                var mainCkptArtFolder = Path.Combine(artDir, "ckptart");
                if (!Directory.Exists(mainCkptArtFolder))
                {
                    mainCkptArtFolder = Path.Combine(dataDir, @"art\ckptart");
                }

                var objectDir = Path.Combine(dataDir, currentTheaterTdf != null ? currentTheaterTdf.objectDir ?? @"terrdata\objects" : @"terrdata\objects");
                if (!Directory.Exists(objectDir))
                {
                    objectDir = Path.Combine(dataDir, @"terrdata\objects");
                }
                var classTable       = ClassTable.ReadClassTable(Path.Combine(objectDir, "FALCON4.CT"));
                var vehicleDataTable = new VcdFile(Path.Combine(objectDir, "FALCON4.VCD")).VehicleDataTable;
                var vehicleClass     = classTable.FirstOrDefault(
                    x => x.dataType == (byte)Data_Types.DTYPE_VEHICLE &&
                    x.vuClassData.classInfo_[(int)VuClassHierarchy.VU_DOMAIN] == (byte)Classtable_Domains.DOMAIN_AIR &&
                    x.vuClassData.classInfo_[(int)VuClassHierarchy.VU_TYPE] == (byte)Classtable_Types.TYPE_AIRPLANE &&
                    x.vehicleDataIndex == vehicleACD)
                ;

                var vehicleData = vehicleDataTable[vehicleClass.dataPtr];
                var vehicleName = Encoding.ASCII.GetString(vehicleData.Name).TrimAtNull().Replace("*", "");
                var vehicleNCTR = Encoding.ASCII.GetString(vehicleData.NCTR).TrimAtNull().Replace("*", "");
                var visType     = vehicleClass.visType[0];

                const string threeDeeCockpitDatFile = "3dckpit.dat";
                if (visType == (short)Vis_Types.VIS_F16C)
                {
                    file = Path.Combine(mainCkptArtFolder, threeDeeCockpitDatFile);
                }
                else
                {
                    file = Path.Combine(mainCkptArtFolder, visType.ToString(), threeDeeCockpitDatFile);
                    if (!FileExists(file))
                    {
                        file = Path.Combine(mainCkptArtFolder, vehicleName, threeDeeCockpitDatFile);
                        if (!FileExists(file))
                        {
                            file = Path.Combine(mainCkptArtFolder, vehicleNCTR, threeDeeCockpitDatFile);
                            if (!FileExists(file))
                            {
                                file = Path.Combine(mainCkptArtFolder, threeDeeCockpitDatFile);
                            }
                        }
                    }
                }
            }
            catch (Exception e) { _log.Error(e.Message, e); }

            var fi = !string.IsNullOrEmpty(file) ? new FileInfo(file) : null;

            return(FileExists(file) ? fi : FindThreeDeeCockpitFileUsingOldMethod());
        }