Exemplo n.º 1
0
        public bool LoadFromFile(string path)
        {
            PatchUOFileReader reader = new PatchUOFileReader(File.OpenRead(path));

            if( !reader.IsValidFile )
            {
                reader.Close();
                return false;
            }
            else
            {
                int ver = reader.ReadInt32();
                switch( ver )
                {
                    case 0:
                    {
                        _patches = reader.ReadPatches();
                        break;
                    }
                }
                reader.Close();
                return true;
            }
        }
Exemplo n.º 2
0
        public bool LoadFromFile(string path)
        {
            PatchUOFileReader reader = new PatchUOFileReader(File.OpenRead(path));

            if (!reader.IsValidFile)
            {
                reader.Close();
                return(false);
            }
            else
            {
                int ver = reader.ReadInt32();
                switch (ver)
                {
                case 0:
                {
                    _patches = reader.ReadPatches();
                    break;
                }
                }
                reader.Close();
                return(true);
            }
        }
Exemplo n.º 3
0
        internal void Import(string path)
        {
            PatchReader reader = new PatchReader(File.OpenRead(path));
            string ext = Path.GetExtension(path);

            if( ext == ".uop" )
            {
                if( reader.ReadInt32() != PatchReader.UOPHeader )
                {
                    MessageBox.Show("Invalid UOP file, Aborting", "Invalid File");
                    return;
                }

                int count = reader.ReadInt32();
                reader.ReadInt32();//UNKNOWN FIELD

                for( int i = 0; i < count; i++ )
                {
                    Patch p = reader.ReadUOPPatch();

                    if( IsValid(p.FileID) && !ContainsPatch(p) )
                        _patches.Add(p);
                }
            }
            else if ( ext == ".muo" )
            {
                if( reader.ReadInt32() != PatchReader.MUOHeader )
                {
                    MessageBox.Show("Invalid MUO file, Aborting", "Invalid File");
                    return;
                }

                string[] data = reader.ReadMUOHeaderData();
                int count = reader.ReadInt32();

                for( int i = 0; i < count; i++ )
                {
                    Patch p = reader.ReadMUOPatch();

                    if( IsValid(p.FileID) && !ContainsPatch(p) )
                        _patches.Add(p);
                }
            }
            else if( ext == ".puo" )
            {
                if( reader.ReadInt32() != PatchReader.UOPHeader )
                {
                    MessageBox.Show("Invalid UOP file, Aborting", "Invalid File");
                    return;
                }
                reader.Close();

                PatchUOFileReader puoReader = new PatchUOFileReader(File.OpenRead(path));

                List<Patch> patches = puoReader.ReadPatches();
                for( int i = 0; i < patches.Count; i++ )
                {
                    Patch p = patches[i];

                    if( IsValid(p.FileID) && !ContainsPatch(p) )
                        _patches.Add(p);
                }

                puoReader.Close();
            }
            else if( ext == ".mul" )
            {
                try
                {
                    int count = reader.ReadInt32();

                    for( int i = 0; i < count; i++ )
                    {
                        Patch p = reader.ReadVerdataPatch();

                        if( IsValid(p.FileID) && !ContainsPatch(p) )
                            _patches.Add(p);
                    }
                }
                catch
                {
                    MessageBox.Show("Invalid or corrupt verdata file.", "Error");
                }
            }
            else
                MessageBox.Show("That file extension is invalid.", "Not Supported");

            if( reader != null )
                reader.Close();
        }
Exemplo n.º 4
0
        internal void Import(string path)
        {
            PatchReader reader = new PatchReader(File.OpenRead(path));
            string      ext    = Path.GetExtension(path);

            if (ext == ".uop")
            {
                if (reader.ReadInt32() != PatchReader.UOPHeader)
                {
                    MessageBox.Show("Invalid UOP file, Aborting", "Invalid File");
                    return;
                }

                int count = reader.ReadInt32();
                reader.ReadInt32();                //UNKNOWN FIELD

                for (int i = 0; i < count; i++)
                {
                    Patch p = reader.ReadUOPPatch();

                    if (IsValid(p.FileID) && !ContainsPatch(p))
                    {
                        _patches.Add(p);
                    }
                }
            }
            else if (ext == ".muo")
            {
                if (reader.ReadInt32() != PatchReader.MUOHeader)
                {
                    MessageBox.Show("Invalid MUO file, Aborting", "Invalid File");
                    return;
                }

                string[] data  = reader.ReadMUOHeaderData();
                int      count = reader.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    Patch p = reader.ReadMUOPatch();

                    if (IsValid(p.FileID) && !ContainsPatch(p))
                    {
                        _patches.Add(p);
                    }
                }
            }
            else if (ext == ".puo")
            {
                if (reader.ReadInt32() != PatchReader.UOPHeader)
                {
                    MessageBox.Show("Invalid UOP file, Aborting", "Invalid File");
                    return;
                }
                reader.Close();

                PatchUOFileReader puoReader = new PatchUOFileReader(File.OpenRead(path));

                List <Patch> patches = puoReader.ReadPatches();
                for (int i = 0; i < patches.Count; i++)
                {
                    Patch p = patches[i];

                    if (IsValid(p.FileID) && !ContainsPatch(p))
                    {
                        _patches.Add(p);
                    }
                }

                puoReader.Close();
            }
            else if (ext == ".mul")
            {
                try
                {
                    int count = reader.ReadInt32();

                    for (int i = 0; i < count; i++)
                    {
                        Patch p = reader.ReadVerdataPatch();

                        if (IsValid(p.FileID) && !ContainsPatch(p))
                        {
                            _patches.Add(p);
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Invalid or corrupt verdata file.", "Error");
                }
            }
            else
            {
                MessageBox.Show("That file extension is invalid.", "Not Supported");
            }

            if (reader != null)
            {
                reader.Close();
            }
        }