예제 #1
0
        private void loadFromStream(Stream input)
        {
            this.magic = MadScience.StreamHelpers.ReadStringASCII(input, 4);
            MadScience.StreamHelpers.ReadValueU32(input); // Always zero
            this.blockSize = MadScience.StreamHelpers.ReadValueU32(input);

            this.entries.Clear();

            uint entryCount = MadScience.StreamHelpers.ReadValueU32(input);

            for (int i = 0; i < entryCount; i++)
            {
                MTNFEntry entry = new MTNFEntry();
                entry.fieldTypeHash = MadScience.StreamHelpers.ReadValueU32(input);
                entry.dataType      = MadScience.StreamHelpers.ReadValueU32(input);
                entry.dataCount     = MadScience.StreamHelpers.ReadValueU32(input);
                entry.offset        = MadScience.StreamHelpers.ReadValueU32(input);
                entries.Add(entry);
            }
            for (int i = 0; i < entryCount; i++)
            {
                switch (entries[i].dataType)
                {
                case 1:
                    for (int j = 0; j < entries[i].dataCount; j++)
                    {
                        entries[i].floats.Add(MadScience.StreamHelpers.ReadValueF32(input));
                    }
                    break;

                case 2:
                case 4:
                    for (int j = 0; j < entries[i].dataCount; j++)
                    {
                        entries[i].dwords.Add(MadScience.StreamHelpers.ReadValueU32(input));
                    }
                    break;
                }
            }
        }
        private void loadFromStream(Stream input)
        {
            this.magic = MadScience.StreamHelpers.ReadStringASCII(input, 4);
            MadScience.StreamHelpers.ReadValueU32(input); // Always zero
            this.blockSize = MadScience.StreamHelpers.ReadValueU32(input);

            this.entries.Clear();

            uint entryCount = MadScience.StreamHelpers.ReadValueU32(input);
            for (int i = 0; i < entryCount; i++)
            {
                MTNFEntry entry = new MTNFEntry();
                entry.fieldTypeHash = MadScience.StreamHelpers.ReadValueU32(input);
                entry.dataType = MadScience.StreamHelpers.ReadValueU32(input);
                entry.dataCount = MadScience.StreamHelpers.ReadValueU32(input);
                entry.offset = MadScience.StreamHelpers.ReadValueU32(input);
                entries.Add(entry);
            }
            for (int i = 0; i < entryCount; i++)
            {
                switch (entries[i].dataType)
                {
                    case 1:
                        for (int j = 0; j < entries[i].dataCount; j++)
                        {
                            entries[i].floats.Add(MadScience.StreamHelpers.ReadValueF32(input));
                        }
                        break;
                    case 2:
                    case 4:
                        for (int j = 0; j < entries[i].dataCount; j++)
                        {
                            entries[i].dwords.Add(MadScience.StreamHelpers.ReadValueU32(input));
                        }
                        break;
                }
            }
        }