Ejemplo n.º 1
0
        public CAttribute(EndianBinaryReaderEx reader, CPSSGFile file, CNode node)
        {
            this.file  = file;
            ParentNode = node;

            id   = reader.ReadInt32();
            size = reader.ReadInt32();
            if (size == 4)
            {
                data = reader.ReadBytes(size);
                return;
            }
            else if (size > 4)
            {
                int strlen = reader.ReadInt32();
                if (size - 4 == strlen)
                {
                    data = reader.ReadPSSGString(strlen);
                    return;
                }
                else
                {
                    reader.Seek(-4, System.IO.SeekOrigin.Current);
                }
            }
            data = reader.ReadBytes(size);
        }
Ejemplo n.º 2
0
        public CPSSGFile(System.IO.Stream fileStream)
        {
            using (EndianBinaryReaderEx reader = new EndianBinaryReaderEx(new BigEndianBitConverter(), fileStream)) {
                magic = reader.ReadPSSGString(4);
                if (magic != "PSSG")
                {
                    throw new Exception("This is not a PSSG file!");
                }
                int size = reader.ReadInt32();
                int attributeInfoCount = reader.ReadInt32();
                int nodeInfoCount      = reader.ReadInt32();

                attributeInfo = new CAttributeInfo[attributeInfoCount];
                nodeInfo      = new CNodeInfo[nodeInfoCount];

                for (int i = 0; i < nodeInfoCount; i++)
                {
                    nodeInfo[i] = new CNodeInfo(reader, this);
                }
                long positionAfterInfo = reader.BaseStream.Position;

                rootNode = new CNode(reader, this, null, true);
                if (reader.BaseStream.Position < reader.BaseStream.Length)
                {
                    reader.BaseStream.Position = positionAfterInfo;
                    rootNode = new CNode(reader, this, null, false);
                    if (reader.BaseStream.Position < reader.BaseStream.Length)
                    {
                        throw new Exception("This file is improperly saved and not supported by this version of the PSSG editor." + Environment.NewLine + Environment.NewLine +
                                            "Get an older version of the program if you wish to take out its contents, but, put it back together using this program and a non-modded version of the pssg file.");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public CNodeInfo(EndianBinaryReaderEx reader, CPSSGFile file)
        {
            attributeInfo = new SortedDictionary <int, CAttributeInfo>();

            id   = reader.ReadInt32();
            name = reader.ReadPSSGString();
            int            attributeInfoCount = reader.ReadInt32();
            CAttributeInfo ai;

            for (int i = 0; i < attributeInfoCount; i++)
            {
                ai = new CAttributeInfo(reader);
                attributeInfo.Add(ai.id, ai);

                file.attributeInfo[ai.id - 1] = ai;
            }
        }
Ejemplo n.º 4
0
        public CAttribute(EndianBinaryReaderEx reader, CPSSGFile file, CNode node)
        {
            this.file = file;
            ParentNode = node;

            id = reader.ReadInt32();
            size = reader.ReadInt32();
            if (size == 4) {
                data = reader.ReadBytes(size);
                return;
            } else if (size > 4) {
                int strlen = reader.ReadInt32();
                if (size - 4 == strlen) {
                    data = reader.ReadPSSGString(strlen);
                    return;
                } else {
                    reader.Seek(-4, System.IO.SeekOrigin.Current);
                }
            }
            data = reader.ReadBytes(size);
        }
Ejemplo n.º 5
0
 public CAttributeInfo(EndianBinaryReaderEx reader)
 {
     id   = reader.ReadInt32();
     name = reader.ReadPSSGString();
 }
Ejemplo n.º 6
0
        public CPSSGFile(System.IO.Stream fileStream)
        {
            using (EndianBinaryReaderEx reader = new EndianBinaryReaderEx(new BigEndianBitConverter(), fileStream)) {
                magic = reader.ReadPSSGString(4);
                if (magic != "PSSG") {
                    throw new Exception("This is not a PSSG file!");
                }
                int size = reader.ReadInt32();
                int attributeInfoCount = reader.ReadInt32();
                int nodeInfoCount = reader.ReadInt32();

                attributeInfo = new CAttributeInfo[attributeInfoCount];
                nodeInfo = new CNodeInfo[nodeInfoCount];

                for (int i = 0; i < nodeInfoCount; i++) {
                    nodeInfo[i] = new CNodeInfo(reader, this);
                }
                long positionAfterInfo = reader.BaseStream.Position;

                rootNode = new CNode(reader, this, null, true);
                if (reader.BaseStream.Position < reader.BaseStream.Length) {
                    reader.BaseStream.Position = positionAfterInfo;
                    rootNode = new CNode(reader, this, null, false);
                    if (reader.BaseStream.Position < reader.BaseStream.Length) {
                        throw new Exception("This file is improperly saved and not supported by this version of the PSSG editor." + Environment.NewLine + Environment.NewLine +
                            "Get an older version of the program if you wish to take out its contents, but, put it back together using this program and a non-modded version of the pssg file.");
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public CNodeInfo(EndianBinaryReaderEx reader, CPSSGFile file)
        {
            attributeInfo = new SortedDictionary<int, CAttributeInfo>();

            id = reader.ReadInt32();
            name = reader.ReadPSSGString();
            int attributeInfoCount = reader.ReadInt32();
            CAttributeInfo ai;
            for (int i = 0; i < attributeInfoCount; i++) {
                ai = new CAttributeInfo(reader);
                attributeInfo.Add(ai.id, ai);

                file.attributeInfo[ai.id - 1] = ai;
            }
        }
Ejemplo n.º 8
0
 public CAttributeInfo(EndianBinaryReaderEx reader)
 {
     id = reader.ReadInt32();
     name = reader.ReadPSSGString();
 }