public void AddEntityAndPointsToValue(AnalysisEntity analysisEntity, PointsToAbstractValue value)
        {
            Debug.Assert(PointsToAnalysisKind == PointsToAnalysisKind.Complete || !analysisEntity.IsChildOrInstanceMemberNeedingCompletePointsToAnalysis());

            AllEntities.Add(analysisEntity);
            AddTrackedPointsToValue(value);
        }
Ejemplo n.º 2
0
        public void Load(string oplfile)
        {
            Name = Path.GetFileNameWithoutExtension(oplfile).ToLowerInvariant();

            var  lines  = File.ReadAllLines(oplfile);
            bool ininst = false;
            bool incars = false;

            foreach (var line in lines)
            {
                string tline = line.Trim();
                if (string.IsNullOrEmpty(tline))
                {
                    continue;                              //blank line
                }
                if (tline.StartsWith("#"))
                {
                    continue;                        //commented out
                }
                if (tline.StartsWith("version"))
                {
                    continue;
                }
                if (tline.StartsWith("inst"))
                {
                    ininst = true; continue;
                }                                                          //start of instances
                if (tline.StartsWith("cars"))
                {
                    incars = true; continue;
                }                                                          //start of car gens
                if (tline.StartsWith("end") && (ininst || incars))
                {
                    ininst = false;
                    incars = false;
                    continue;
                }
                if (ininst)
                {
                    Entity ent = new Entity(tline);
                    AllEntities.Add(ent);
                }
                if (incars)
                {
                    CarGen cgen = new CarGen(tline);
                    CarGenerators.Add(cgen);
                }
            }

            //ProcessEntities();
        }
Ejemplo n.º 3
0
        private static void ScanFiles()
        {
            var parsers = new List <Action <BinaryReader, string> >();

            if (_checkAll || _checkTim)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var timParser = new TIMParser((tmdEntity, fp) =>
                    {
                        AllTextures.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Texture {tmdEntity.Width}x{tmdEntity.Height} {tmdEntity.Bpp}bpp");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for TIM at file {0}", fileTitle);
                    timParser.LookForTim(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkCroc)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var crocModelReader = new CrocModelReader((tmdEntity, fp) =>
                    {
                        AllEntities.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Model with {tmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for Croc at file {0}", fileTitle);
                    crocModelReader.LookForCrocModel(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkBff)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var crocModelReader = new BFFModelReader((tmdEntity, fp) =>
                    {
                        AllEntities.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Model with {tmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for BFF at file {0}", fileTitle);
                    crocModelReader.LookForBFF(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkPsx)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var psxParser = new PSXParser((tmdEntity, fp) =>
                    {
                        AllEntities.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Model with {tmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for PSX at file {0}", fileTitle);
                    psxParser.LookForPSX(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkTmd)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var tmdParser = new TMDParser((tmdEntity, fp) =>
                    {
                        AllEntities.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Model with {tmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for TMD at file {0}", fileTitle);
                    tmdParser.LookForTmd(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkVdf)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var vdfParser = new VDFParser((vdfEntity, fp) =>
                    {
                        AllAnimations.Add(vdfEntity);
                        UpdateProgress(fp, $"Found Animation with {vdfEntity.ObjectCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for VDF at file {0}", fileTitle);
                    vdfParser.LookForVDF(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkAn)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var anParser = new ANParser((vdfEntity, fp) =>
                    {
                        AllAnimations.Add(vdfEntity);
                        UpdateProgress(fp, $"Found Animation with {vdfEntity.ObjectCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for AN at file {0}", fileTitle);
                    anParser.LookForAN(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkPmd)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var pmdParser = new PMDParser((pmdEntity, fp) =>
                    {
                        AllEntities.Add(pmdEntity);
                        UpdateProgress(fp, $"Found Model with {pmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for PMD at file {0}", fileTitle);
                    pmdParser.LookForPMD(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkTod)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var todParser = new TODParser((todEntity, fp) =>
                    {
                        AllAnimations.Add(todEntity);
                        UpdateProgress(fp, $"Found Animation with {todEntity.ObjectCount} objects and {todEntity.FrameCount} frames");
                        PreviewForm.ReloadItems();
                    });
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for TOD at file {0}", fileTitle);
                    todParser.LookForTOD(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkHmd)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var hmdParser = new HMDParser((hmdEntity, fp) =>
                    {
                        AllEntities.Add(hmdEntity);
                        UpdateProgress(fp, $"Found Model with {hmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    }, (hmdAnimation, fp) =>
                    {
                        AllAnimations.Add(hmdAnimation);
                        UpdateProgress(fp, $"Found Animation with {hmdAnimation.ObjectCount} objects and {hmdAnimation.FrameCount} frames");
                        PreviewForm.ReloadItems();
                    }, delegate(Texture texture, long fp)
                    {
                        AllTextures.Add(texture);
                        UpdateProgress(fp, $"Found Texture {texture.Width}x{texture.Height} {texture.Bpp}bpp");
                        PreviewForm.ReloadItems();
                    }
                                                  );
                    //Program.Logger.WriteLine("");
                    Program.Logger.WriteLine("Scanning for HMD at file {0}", fileTitle);
                    hmdParser.LookForHMDEntities(binaryReader, fileTitle);
                });
            }

            if (File.Exists(_path))
            {
                Parallel.ForEach(parsers, parser =>
                {
                    using (var fs = File.Open(_path, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        ProcessFile(fs, _path, parser);
                    }
                });
            }
            else
            {
                ProcessFiles(_path, Filter, parsers);
            }
        }
Ejemplo n.º 4
0
 protected Entity()
 {
     IsDeleted = false;
     AllEntities.Add(this);
 }
Ejemplo n.º 5
0
        public void Load(string iplfile)
        {
            Name = Path.GetFileNameWithoutExtension(iplfile).ToLowerInvariant();

            var  lines  = File.ReadAllLines(iplfile);
            bool ininst = false;
            bool incars = false;

            foreach (var line in lines)
            {
                string tline = line.Trim();
                if (string.IsNullOrEmpty(tline))
                {
                    continue;                              //blank line
                }
                if (tline.StartsWith("#"))
                {
                    continue;                        //commented out
                }
                //if (tline.StartsWith("version")) continue;
                if (tline.StartsWith("inst"))
                {
                    ininst = true; continue;
                }                                                          //start of instances
                if (tline.StartsWith("cars"))
                {
                    incars = true; continue;
                }                                                          //start of car gens
                if (tline.StartsWith("end") && (ininst || incars))
                {
                    ininst = false;
                    incars = false;
                    continue;
                }
                if (ininst)
                {
                    Entity ent = new Entity(tline);
                    AllEntities.Add(ent);
                    if (ent.Name.StartsWith("slod"))
                    {
                        SlodEntities.Add(ent);
                    }
                    else if (ent.Name.StartsWith("lod"))
                    {
                        LodEntities.Add(ent);
                    }
                    else
                    {
                        if (ent.ParentIndex < 0)
                        {
                            OEntities.Add(ent);
                        }
                        else
                        {
                            HdEntities.Add(ent);
                        }
                    }
                }
                if (incars)
                {
                    CarGen cgen = new CarGen(tline);
                    CarGenerators.Add(cgen);
                }
            }

            AllLodEntities.Clear();
            AllLodEntities.AddRange(SlodEntities);
            AllLodEntities.AddRange(LodEntities);

            AllHdEntities.Clear();
            AllHdEntities.AddRange(HdEntities);
            AllHdEntities.AddRange(OEntities);


            for (int i = 0; i < AllLodEntities.Count; i++)
            {
                AllLodEntities[i].NewIndex = i;
            }
            for (int i = 0; i < AllHdEntities.Count; i++)
            {
                AllHdEntities[i].NewIndex = i;
            }
        }
Ejemplo n.º 6
0
 protected internal virtual void Initialize()
 {
     AllEntities.Add(this);
 }
Ejemplo n.º 7
0
 public void AddEntityAndPointsToValue(AnalysisEntity analysisEntity, PointsToAbstractValue value)
 {
     AllEntities.Add(analysisEntity);
     AddTrackedPointsToValue(value);
 }
Ejemplo n.º 8
0
        private static void ScanFiles()
        {
            var parsers = new List <Action <BinaryReader, string> >();

            if (_checkAll || _checkTim)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var timParser = new TIMParser((tmdEntity, fp) =>
                    {
                        AllTextures.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Texture {tmdEntity.Width}x{tmdEntity.Height} {tmdEntity.Bpp}bpp");
                        PreviewForm.ReloadItems();
                    });
                    Logger.WriteLine("");
                    Logger.WriteLine("Scanning for TIM Images at file {0}", fileTitle);
                    timParser.LookForTim(binaryReader, fileTitle);
                });
            }

            if (_checkTimAlt)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var timParser = new TIMParserOld((tmdEntity, fp) =>
                    {
                        AllTextures.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Texture {tmdEntity.Width}x{tmdEntity.Height} {tmdEntity.Bpp}bpp");
                        PreviewForm.ReloadItems();
                    });
                    Logger.WriteLine("");
                    Logger.WriteLine("Scanning for TIM Images (alt) at file {0}", fileTitle);
                    timParser.LookForTim(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkTmd)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var tmdParser = new TMDParser((tmdEntity, fp) =>
                    {
                        AllEntities.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Model with {tmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    Logger.WriteLine("");
                    Logger.WriteLine("Scanning for TMD Models at file {0}", fileTitle);
                    tmdParser.LookForTmd(binaryReader, fileTitle);
                });
            }

            if (_checkTmdAlt)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var tmdParser = new TMDParserAlternative((tmdEntity, fp) =>
                    {
                        AllEntities.Add(tmdEntity);
                        UpdateProgress(fp, $"Found Model with {tmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    Logger.WriteLine("");
                    Logger.WriteLine("Scanning for TMD Models (alt) at file {0}", fileTitle);
                    tmdParser.LookForTmd(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkPmd)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var pmdParser = new PMDParser((pmdEntity, fp) =>
                    {
                        AllEntities.Add(pmdEntity);
                        UpdateProgress(fp, $"Found Model with {pmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    Logger.WriteLine("");
                    Logger.WriteLine("Scanning for PMD Models at file {0}", fileTitle);
                    pmdParser.LookForPMD(binaryReader, fileTitle);
                });
            }

            if (_checkAll || _checkTod)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var todParser = new TODParser((todEntity, fp) =>
                    {
                        AllAnimations.Add(todEntity);
                        UpdateProgress(fp, $"Found Animation with {todEntity.ObjectCount} objects and {todEntity.FrameCount} frames");
                        PreviewForm.ReloadItems();
                    });
                    Logger.WriteLine("");
                    Logger.WriteLine("Scanning for TOD Animations at file {0}", fileTitle);
                    todParser.LookForTOD(binaryReader, fileTitle);
                });
            }

            if (_checkHmdModels)
            {
                parsers.Add((binaryReader, fileTitle) =>
                {
                    var hmdParser = new HMDParser((hmdEntity, fp) =>
                    {
                        AllEntities.Add(hmdEntity);
                        UpdateProgress(fp, $"Found Model with {hmdEntity.ChildCount} objects");
                        PreviewForm.ReloadItems();
                    });
                    Logger.WriteLine("");
                    Logger.WriteLine("Scanning for HMD Models at file {0}", fileTitle);
                    hmdParser.LookForHMDEntities(binaryReader, fileTitle);
                });
            }

            if (_path.ToLowerInvariant().EndsWith(".iso"))
            {
                using (var isoStream = File.Open(_path, FileMode.Open))
                {
                    var cdReader = new CDReader(isoStream, true);
                    var files    = cdReader.GetFiles("", _filter ?? "*.*", SearchOption.AllDirectories);
                    foreach (var file in files)
                    {
                        if (file.ToLowerInvariant().Contains(".str;"))
                        {
                            continue;
                        }
                        var fileInfo = cdReader.GetFileInfo(file);
                        if (fileInfo.Exists)
                        {
                            foreach (var parser in parsers)
                            {
                                using (var stream = fileInfo.OpenRead())
                                {
                                    ProcessFile(stream, file, parser);
                                }
                            }
                        }
                    }
                }
            }
            else if (File.Exists(_path))
            {
                Parallel.ForEach(parsers, parser =>
                {
                    using (var fs = File.Open(_path, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        ProcessFile(fs, _path, parser);
                    }
                });
            }
            else
            {
                ProcessFiles(_path, _filter, parsers);
            }
        }