Beispiel #1
0
 public bool LoadGP(UInt32 ID, ref IffGrandPrixData GrandPrix)
 {
     if (!FGPData.TryGetValue(ID, out GrandPrix))
     {
         return(false);
     }
     return(true);
 }
Beispiel #2
0
        //Constructor
        public GrandPrixDataCollection()
        {
            MemoryStream     Buffer;
            IffGrandPrixData GrandPrix;

            FGPData = new Dictionary <uint, IffGrandPrixData>();

            PangyaBinaryReader Reader = null;

            using (var zip = ZipFile.OpenRead("data/pangya_gb.iff"))                          //ler o arquivo de base
            {
                var FileZip = zip.Entries.FirstOrDefault(c => c.Name == "GrandPrixData.iff"); //verifica se existe o arquivo

                if (FileZip == null)
                {
                    PangyaAPI.WriteConsole.WriteLine(" data\\GrandPrixData.iff is not loaded");
                    return;
                }
                else
                {
                    Buffer = new MemoryStream();
                    FileZip.Open().CopyTo(Buffer);
                }
            }

            try
            {
                Reader = new PangyaBinaryReader(Buffer);
                if (new string(Reader.ReadChars(2)) == "PK")
                {
                    throw new Exception("The given IFF file is a ZIP file, please unpack it before attempting to parse it");
                }

                Reader.Seek(0, 0);

                Reader.ReadUInt16(out ushort recordCount);
                long recordLength = ((Reader.GetSize() - 8L) / (recordCount));
                Reader.ReadUInt16(out BindingID);
                Reader.ReadUInt32(out Version);

                for (int i = 0; i < recordCount; i++)
                {
                    GrandPrix = new IffGrandPrixData();

                    GrandPrix = (IffGrandPrixData)Reader.Read(GrandPrix);


                    FGPData.Add(GrandPrix.TypeID, GrandPrix);
                }
            }
            finally
            {
                Reader.Dispose();
                Buffer.Dispose();
            }
        }
Beispiel #3
0
        public bool IsGPExist(UInt32 TypeId)
        {
            IffGrandPrixData GP = new IffGrandPrixData();

            if (!LoadGP(TypeId, ref GP))
            {
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        public IffGrandPrixData GetGP(UInt32 TypeId)
        {
            IffGrandPrixData GP = new IffGrandPrixData();

            if (!LoadGP(TypeId, ref GP))
            {
                return(GP);
            }
            return(GP);
        }