Ejemplo n.º 1
0
        public static bool Read(RAFFileListEntry file, ref InibinFile data, Logger logger)
        {
            bool result = true;

            logger.Event("Reading inibin: " + file.FileName);

            try
            {
                // Get the data from the archive
                MemoryStream myInput = new MemoryStream( file.GetContent() );
                result = ReadCharacterInibin(myInput, ref data, logger);

                int end = file.FileName.LastIndexOf("/");
                String directory = file.FileName.Substring(0, end);
                String archive = file.RAFArchive.RAFFilePath;
                archive = archive.Replace("\\", "/");
                end = archive.LastIndexOf("/");
                archive = archive.Substring(0, end);

                data.directory = new DirectoryInfo(archive + "/" + directory);
                myInput.Close();
            }
            catch(Exception e)
            {
                logger.Error("Unable to open memory stream: " + file.FileName);
                logger.Error(e.Message);
                result = false;
            }

            return result;
        }
Ejemplo n.º 2
0
        public static bool Read(RAFFileListEntry file, ref InibinFile data, Logger logger)
        {
            bool result = true;

            logger.Event("Reading inibin: " + file.FileName);

            try
            {
                // Get the data from the archive
                MemoryStream myInput = new MemoryStream(file.GetContent());
                result = ReadCharacterInibin(myInput, ref data, logger);

                int    end       = file.FileName.LastIndexOf("/");
                String directory = file.FileName.Substring(0, end);
                String archive   = file.RAFArchive.RAFFilePath;
                archive = archive.Replace("\\", "/");
                end     = archive.LastIndexOf("/");
                archive = archive.Substring(0, end);

                data.directory = new DirectoryInfo(archive + "/" + directory);
                myInput.Close();
            }
            catch (Exception e)
            {
                logger.Error("Unable to open memory stream: " + file.FileName);
                logger.Error(e.Message);
                result = false;
            }

            return(result);
        }
Ejemplo n.º 3
0
        private static bool ReadCharacterInibin(MemoryStream stream, ref InibinFile file, Logger logger)
        {
            bool result = true;

            file = new InibinFile();

            stream.Seek( 0, SeekOrigin.Begin );

            // Header Info
            int version = stream.ReadByte();

            #if VERBOSE
            DebugOut("version", version);
            #endif

            int fileLen = (int) stream.Length;
            #if VERBOSE
            DebugOut("file length", fileLen);
            #endif

            int oldLen = (int)ReadShort(ref stream);
            #if VERBOSE
            DebugOut("old style length", oldLen);
            #endif

            int oldStyleOffset = fileLen - oldLen;
            #if VERBOSE
            DebugOut("old style offset", oldStyleOffset);
            #endif

            int format = (int) ReadShort(ref stream);
            #if VERBOSE
            DebugOut("format", format);
            #endif

            if ((format & 0x0001) == 0)
            {
            #if VERBOSE
                DebugOut("No U32 segment", "skipping");
            #endif
            }
            else
            {
                // Reads values based on the hash keys.
            #if VERBOSE
                DebugOut("U32 properties start position", stream.Position);
            #endif
                long[] keys = ReadSegmentKeys( ref stream );
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        long val = (long)ReadInt32(ref stream);
            #if VERBOSE
                        DebugOut("U32 prop(" + key + ")", val);
            #endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // float values
            if ((format & 0x0002) == 0)
            {
            #if VERBOSE
                DebugOut("No float segment", "skipping");
            #endif
            }
            else
            {
            #if VERBOSE
                DebugOut("Float properties start position", stream.Position);
            #endif
                long[] keys = ReadSegmentKeys( ref stream );
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        float val = ReadFloat(ref stream);
            #if VERBOSE
                        DebugOut("float prop(" + key + ")", val);
            #endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // U8 values
            if ((format & 0x0004) == 0)
            {
            #if VERBOSE
                DebugOut("No U8/10 segment", "skipping");
            #endif
            }
            else
            {
            #if VERBOSE
                DebugOut("U8/10 properties start position", stream.Position);
            #endif
                long[] keys = ReadSegmentKeys( ref stream );
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        float val = stream.ReadByte() * 0.1F;
            #if VERBOSE
                        DebugOut("U8/10 prop(" + key + ")", val);
            #endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // U16 values
            if ((format & 0x0008) == 0)
            {
            #if VERBOSE
                DebugOut("No U16 segment", "skipping");
            #endif
            }
            else
            {
            #if VERBOSE
                DebugOut("U16 properties start position", stream.Position);
            #endif
                long[] keys = ReadSegmentKeys( ref stream );
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        int val = (int)ReadShort(ref stream);
            #if VERBOSE
                        DebugOut("U16 prop(" + key + ")", val);
            #endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // U8 values
            if ((format & 0x0010) == 0)
            {
            #if VERBOSE
                DebugOut("No U8 segment", "skipping");
            #endif
            }
            else
            {
            #if VERBOSE
                DebugOut("U8 properties start position", stream.Position);
            #endif
                long[] keys = ReadSegmentKeys( ref stream );
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        int val = 0xff & stream.ReadByte();
            #if VERBOSE
                        DebugOut("U8 prop(" + key + ")", val);
            #endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // Boolean flags - single bit, ignoring
            if ((format & 0x0020) == 0)
            {
            #if VERBOSE
                DebugOut("No boolean segment", "skipping");
            #endif
            }
            else
            {
            #if VERBOSE
                DebugOut("Boolean flags start position", stream.Position);
            #endif
                long[] booleanKeys = ReadSegmentKeys(ref stream);
                if (booleanKeys != null)
                {
            #if VERBOSE
                    DebugOut("Boolean keys found", booleanKeys.Length);
            #endif
                    int index = 0;
                    for (int i = 0; i < 1 + ((booleanKeys.Length - 1) / 8); ++i)
                    {
                        int bits = stream.ReadByte();
                        for (int b = 0; b < 8; ++b)
                        {
                            long key = booleanKeys[index];
                            int val = 0x1 & bits;
            #if VERBOSE
                            DebugOut("Boolean prop(" + key + ")", val);
            #endif

                            file.AddProperty(key, val);

                            bits = bits >> 1;
                            if (++index == booleanKeys.Length)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            // 4-byte color values or something?
            if ((format & 0x0400) == 0)
            {
            #if VERBOSE
                DebugOut("No 4-byte color segment", "skipping");
            #endif
            }
            else
            {
            #if VERBOSE
                DebugOut("Color? properties start position", stream.Position);
            #endif
                long[] keys = ReadSegmentKeys( ref stream );
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        long val = (long)ReadInt32(ref stream);
            #if VERBOSE
                        DebugOut("U32 color prop(" + key + ")", val);
            #endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // Newer section.
            // I don't know what exactly these values represent.
            // I think it's related to champions with the new rage mechanic.
            // I'm just using it to increment the stream.
            // So, when I get to the part to read in strings, the pointer is at the
            // correct location.
            if ((format & 0x0080) == 0)
            {
            #if VERBOSE
                DebugOut("No offsets segment", "skipping");
            #endif
            }
            else
            {
            #if VERBOSE
                DebugOut("Rage values start position", stream.Position);
            #endif
                long[] rageKeys = ReadSegmentKeys(ref stream);
                if (rageKeys != null)
                {
            #if VERBOSE
                    DebugOut("Rage keys found", rageKeys.Length);
            #endif
                    foreach (long key in rageKeys)
                    {
                        float val1 = ReadFloat(ref stream);
                        float val2 = ReadFloat(ref stream);
                        float val3 = ReadFloat(ref stream);
            #if VERBOSE
                        DebugOut("Rage prop 1(" + key + ")", val1);
                        DebugOut("Rage prop 2(" + key + ")", val2);
                        DebugOut("Rage prop 3(" + key + ")", val3);
            #endif
                        // If you actually need these values, figure out what 12 byte
                        // structure they represent and add that property.
                        // It's probably a Vector3.
                        // file.AddProperty(key, MyRageKeyStructure);
                    }
                }
            }

            // Old-style offsets to strings
            if ((format & 0x1000) == 0)
            {
            #if VERBOSE
                DebugOut("No offsets segment", "skipping");
            #endif
            }
            else
            {
            #if VERBOSE
                DebugOut("Old style data position", stream.Position);
            #endif
                int lastOffset = -1;
                long[] keys = ReadSegmentKeys( ref stream );

                //
                // New method to read the newer .inibins.
                // Why determine the offset by reading in data from the file header
                // when we can just compute it here?  This seems to fix the problem
                // with newer .inibins.  I'm not sure what the value in the header
                // is used for though.
                //

                if (keys != null)
                {
                    oldStyleOffset = (int)stream.Position + keys.Length * 2;

                    foreach (long key in keys)
                    {
                        int offset = (int)ReadShort(ref stream);
            #if VERBOSE
                        DebugOut("String offset(" + key + ")", offset);
            #endif
                        String val = ReadNullTerminatedString(ref stream,
                            oldStyleOffset + offset);
            #if VERBOSE
                        DebugOut("String prop(" + key + ")", val);
            #endif

                        file.AddProperty(key, val);

                        lastOffset = offset;
                    }
                }
            }

            #if VERBOSE
            // Debuging Code
            //Debug.WriteLine("Skin #1 Name: " + file.properties[(long) InibinHashID.SKIN_ONE_NAME]);
            Debug.WriteLine("Skin #1 SKN: " + file.properties[(long) InibinHashID.SKIN_ONE_SKN]);
            Debug.WriteLine("Skin #1 SKL: " + file.properties[(long) InibinHashID.SKIN_ONE_SKL]);
            Debug.WriteLine("Skin #1 DDS: " + file.properties[(long) InibinHashID.SKIN_ONE_TEXTURE]);

            Debug.WriteLine("Skin #2 Name: " + file.properties[(long) InibinHashID.SKIN_TWO_NAME]);
            Debug.WriteLine("Skin #2 SKN: " + file.properties[(long) InibinHashID.SKIN_TWO_SKN]);
            Debug.WriteLine("Skin #2 SKL: " + file.properties[(long) InibinHashID.SKIN_TWO_SKL]);
            Debug.WriteLine("Skin #2 DDS: " + file.properties[(long) InibinHashID.SKIN_TWO_TEXTURE]);

            Debug.WriteLine("Skin #3 Name: " + file.properties[(long) InibinHashID.SKIN_THREE_NAME]);
            Debug.WriteLine("Skin #3 SKN: " + file.properties[(long) InibinHashID.SKIN_THREE_SKN]);
            Debug.WriteLine("Skin #3 SKL: " + file.properties[(long) InibinHashID.SKIN_THREE_SKL]);
            Debug.WriteLine("Skin #3 DDS: " + file.properties[(long) InibinHashID.SKIN_THREE_TEXTURE]);

            Debug.WriteLine("Skin #4 Name: " + file.properties[(long) InibinHashID.SKIN_FOUR_NAME]);
            Debug.WriteLine("Skin #4 SKN: " + file.properties[(long) InibinHashID.SKIN_FOUR_SKN]);
            Debug.WriteLine("Skin #4 SKL: " + file.properties[(long) InibinHashID.SKIN_FOUR_SKL]);
            Debug.WriteLine("Skin #4 DDS: " + file.properties[(long) InibinHashID.SKIN_FOUR_TEXTURE]);

            Debug.WriteLine("Skin #5 Name: " + file.properties[(long) InibinHashID.SKIN_FIVE_NAME]);
            Debug.WriteLine("Skin #5 SKN: " + file.properties[(long) InibinHashID.SKIN_FIVE_SKN]);
            Debug.WriteLine("Skin #5 SKL: " + file.properties[(long) InibinHashID.SKIN_FIVE_SKL]);
            Debug.WriteLine("Skin #5 DDS: " + file.properties[(long) InibinHashID.SKIN_FIVE_TEXTURE]);

            Debug.WriteLine("Skin #6 Name: " + file.properties[(long) InibinHashID.SKIN_SIX_NAME]);
            Debug.WriteLine("Skin #6 SKN: " + file.properties[(long) InibinHashID.SKIN_SIX_SKN]);
            Debug.WriteLine("Skin #6 SKL: " + file.properties[(long) InibinHashID.SKIN_SIX_SKL]);
            Debug.WriteLine("Skin #6 DDS: " + file.properties[(long) InibinHashID.SKIN_SIX_TEXTURE]);

            Debug.WriteLine("Skin #7 Name: " + file.properties[(long)InibinHashID.SKIN_SEVEN_NAME]);
            Debug.WriteLine("Skin #7 SKN: " + file.properties[(long)InibinHashID.SKIN_SEVEN_SKN]);
            Debug.WriteLine("Skin #7 SKL: " + file.properties[(long)InibinHashID.SKIN_SEVEN_SKL]);
            Debug.WriteLine("Skin #7 DDS: " + file.properties[(long)InibinHashID.SKIN_SEVEN_TEXTURE]);

            Debug.WriteLine("Skin #8 Name: " + file.properties[(long)InibinHashID.SKIN_EIGHT_NAME]);
            Debug.WriteLine("Skin #8 SKN: " + file.properties[(long)InibinHashID.SKIN_EIGHT_SKN]);
            Debug.WriteLine("Skin #8 SKL: " + file.properties[(long)InibinHashID.SKIN_EIGHT_SKL]);
            Debug.WriteLine("Skin #8 DDS: " + file.properties[(long)InibinHashID.SKIN_EIGHT_TEXTURE]);
            #endif

            logger.Event("Version: " + version);

            //if (file.properties.ContainsKey((long)InibinHashID.SKIN_ONE_NAME))
                //logger.LogEvent("Skin #1 Name: " + file.properties[(long) InibinHashID.SKIN_ONE_NAME]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_ONE_SKN))
                logger.Event("Skin #1 SKN: " + file.properties[(long)InibinHashID.SKIN_ONE_SKN]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_ONE_SKL))
                logger.Event("Skin #1 SKL: " + file.properties[(long)InibinHashID.SKIN_ONE_SKL]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_ONE_TEXTURE))
                logger.Event("Skin #1 DDS: " + file.properties[(long)InibinHashID.SKIN_ONE_TEXTURE]);

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_TWO_NAME))
                logger.Event("Skin #2 Name: " + file.properties[(long)InibinHashID.SKIN_TWO_NAME]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_TWO_SKN))
                logger.Event("Skin #2 SKN: " + file.properties[(long)InibinHashID.SKIN_TWO_SKN]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_TWO_SKL))
                logger.Event("Skin #2 SKL: " + file.properties[(long)InibinHashID.SKIN_TWO_SKL]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_TWO_TEXTURE))
                logger.Event("Skin #2 DDS: " + file.properties[(long)InibinHashID.SKIN_TWO_TEXTURE]);

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_THREE_NAME))
                logger.Event("Skin #3 Name: " + file.properties[(long)InibinHashID.SKIN_THREE_NAME]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_THREE_SKN))
                logger.Event("Skin #3 SKN: " + file.properties[(long)InibinHashID.SKIN_THREE_SKN]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_THREE_SKL))
                logger.Event("Skin #3 SKL: " + file.properties[(long)InibinHashID.SKIN_THREE_SKL]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_THREE_TEXTURE))
                logger.Event("Skin #3 DDS: " + file.properties[(long)InibinHashID.SKIN_THREE_TEXTURE]);

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FOUR_NAME))
                logger.Event("Skin #4 Name: " + file.properties[(long)InibinHashID.SKIN_FOUR_NAME]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FOUR_SKN))
                logger.Event("Skin #4 SKN: " + file.properties[(long)InibinHashID.SKIN_FOUR_SKN]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FOUR_SKL))
                logger.Event("Skin #4 SKL: " + file.properties[(long)InibinHashID.SKIN_FOUR_SKL]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FOUR_TEXTURE))
                logger.Event("Skin #4 DDS: " + file.properties[(long)InibinHashID.SKIN_FOUR_TEXTURE]);

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FIVE_NAME))
                logger.Event("Skin #5 Name: " + file.properties[(long)InibinHashID.SKIN_FIVE_NAME]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FIVE_SKN))
                logger.Event("Skin #5 SKN: " + file.properties[(long)InibinHashID.SKIN_FIVE_SKN]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FIVE_SKL))
                logger.Event("Skin #5 SKL: " + file.properties[(long)InibinHashID.SKIN_FIVE_SKL]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FIVE_TEXTURE))
                logger.Event("Skin #5 DDS: " + file.properties[(long)InibinHashID.SKIN_FIVE_TEXTURE]);

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SIX_NAME))
                logger.Event("Skin #6 Name: " + file.properties[(long)InibinHashID.SKIN_SIX_NAME]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SIX_SKN))
                logger.Event("Skin #6 SKN: " + file.properties[(long)InibinHashID.SKIN_SIX_SKN]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SIX_SKL))
                logger.Event("Skin #6 SKL: " + file.properties[(long)InibinHashID.SKIN_SIX_SKL]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SIX_TEXTURE))
                logger.Event("Skin #6 DDS: " + file.properties[(long)InibinHashID.SKIN_SIX_TEXTURE]);

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SEVEN_NAME))
                logger.Event("Skin #7 Name: " + file.properties[(long)InibinHashID.SKIN_SEVEN_NAME]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SEVEN_SKN))
                logger.Event("Skin #7 SKN: " + file.properties[(long)InibinHashID.SKIN_SEVEN_SKN]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SEVEN_SKL))
                logger.Event("Skin #7 SKL: " + file.properties[(long)InibinHashID.SKIN_SEVEN_SKL]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SEVEN_TEXTURE))
                logger.Event("Skin #7 DDS: " + file.properties[(long)InibinHashID.SKIN_SEVEN_TEXTURE]);

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_EIGHT_NAME))
                logger.Event("Skin #8 Name: " + file.properties[(long)InibinHashID.SKIN_EIGHT_NAME]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_EIGHT_SKN))
                logger.Event("Skin #8 SKN: " + file.properties[(long)InibinHashID.SKIN_EIGHT_SKN]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_EIGHT_SKL))
                logger.Event("Skin #8 SKL: " + file.properties[(long)InibinHashID.SKIN_EIGHT_SKL]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_EIGHT_TEXTURE))
                logger.Event("Skin #8 DDS: " + file.properties[(long)InibinHashID.SKIN_EIGHT_TEXTURE]);

            return result;
        }
Ejemplo n.º 4
0
        private static bool ReadCharacterInibin(MemoryStream stream, ref InibinFile file, Logger logger)
        {
            bool result = true;

            file = new InibinFile();

            stream.Seek(0, SeekOrigin.Begin);

            // Header Info
            int version = stream.ReadByte();

#if VERBOSE
            DebugOut("version", version);
#endif

            int fileLen = (int)stream.Length;
#if VERBOSE
            DebugOut("file length", fileLen);
#endif

            int oldLen = (int)ReadShort(ref stream);
#if VERBOSE
            DebugOut("old style length", oldLen);
#endif

            int oldStyleOffset = fileLen - oldLen;
#if VERBOSE
            DebugOut("old style offset", oldStyleOffset);
#endif

            int format = (int)ReadShort(ref stream);
#if VERBOSE
            DebugOut("format", format);
#endif

            if ((format & 0x0001) == 0)
            {
#if VERBOSE
                DebugOut("No U32 segment", "skipping");
#endif
            }
            else
            {
                // Reads values based on the hash keys.
#if VERBOSE
                DebugOut("U32 properties start position", stream.Position);
#endif
                long[] keys = ReadSegmentKeys(ref stream);
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        long val = (long)ReadInt32(ref stream);
#if VERBOSE
                        DebugOut("U32 prop(" + key + ")", val);
#endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // float values
            if ((format & 0x0002) == 0)
            {
#if VERBOSE
                DebugOut("No float segment", "skipping");
#endif
            }
            else
            {
#if VERBOSE
                DebugOut("Float properties start position", stream.Position);
#endif
                long[] keys = ReadSegmentKeys(ref stream);
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        float val = ReadFloat(ref stream);
#if VERBOSE
                        DebugOut("float prop(" + key + ")", val);
#endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // U8 values
            if ((format & 0x0004) == 0)
            {
#if VERBOSE
                DebugOut("No U8/10 segment", "skipping");
#endif
            }
            else
            {
#if VERBOSE
                DebugOut("U8/10 properties start position", stream.Position);
#endif
                long[] keys = ReadSegmentKeys(ref stream);
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        float val = stream.ReadByte() * 0.1F;
#if VERBOSE
                        DebugOut("U8/10 prop(" + key + ")", val);
#endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // U16 values
            if ((format & 0x0008) == 0)
            {
#if VERBOSE
                DebugOut("No U16 segment", "skipping");
#endif
            }
            else
            {
#if VERBOSE
                DebugOut("U16 properties start position", stream.Position);
#endif
                long[] keys = ReadSegmentKeys(ref stream);
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        int val = (int)ReadShort(ref stream);
#if VERBOSE
                        DebugOut("U16 prop(" + key + ")", val);
#endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // U8 values
            if ((format & 0x0010) == 0)
            {
#if VERBOSE
                DebugOut("No U8 segment", "skipping");
#endif
            }
            else
            {
#if VERBOSE
                DebugOut("U8 properties start position", stream.Position);
#endif
                long[] keys = ReadSegmentKeys(ref stream);
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        int val = 0xff & stream.ReadByte();
#if VERBOSE
                        DebugOut("U8 prop(" + key + ")", val);
#endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // Boolean flags - single bit, ignoring
            if ((format & 0x0020) == 0)
            {
#if VERBOSE
                DebugOut("No boolean segment", "skipping");
#endif
            }
            else
            {
#if VERBOSE
                DebugOut("Boolean flags start position", stream.Position);
#endif
                long[] booleanKeys = ReadSegmentKeys(ref stream);
                if (booleanKeys != null)
                {
#if VERBOSE
                    DebugOut("Boolean keys found", booleanKeys.Length);
#endif
                    int index = 0;
                    for (int i = 0; i < 1 + ((booleanKeys.Length - 1) / 8); ++i)
                    {
                        int bits = stream.ReadByte();
                        for (int b = 0; b < 8; ++b)
                        {
                            long key = booleanKeys[index];
                            int  val = 0x1 & bits;
#if VERBOSE
                            DebugOut("Boolean prop(" + key + ")", val);
#endif

                            file.AddProperty(key, val);

                            bits = bits >> 1;
                            if (++index == booleanKeys.Length)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            // 4-byte color values or something?
            if ((format & 0x0400) == 0)
            {
#if VERBOSE
                DebugOut("No 4-byte color segment", "skipping");
#endif
            }
            else
            {
#if VERBOSE
                DebugOut("Color? properties start position", stream.Position);
#endif
                long[] keys = ReadSegmentKeys(ref stream);
                if (keys != null)
                {
                    foreach (long key in keys)
                    {
                        long val = (long)ReadInt32(ref stream);
#if VERBOSE
                        DebugOut("U32 color prop(" + key + ")", val);
#endif

                        file.AddProperty(key, val);
                    }
                }
            }

            // Newer section.
            // I don't know what exactly these values represent.
            // I think it's related to champions with the new rage mechanic.
            // I'm just using it to increment the stream.
            // So, when I get to the part to read in strings, the pointer is at the
            // correct location.
            if ((format & 0x0080) == 0)
            {
#if VERBOSE
                DebugOut("No offsets segment", "skipping");
#endif
            }
            else
            {
#if VERBOSE
                DebugOut("Rage values start position", stream.Position);
#endif
                long[] rageKeys = ReadSegmentKeys(ref stream);
                if (rageKeys != null)
                {
#if VERBOSE
                    DebugOut("Rage keys found", rageKeys.Length);
#endif
                    foreach (long key in rageKeys)
                    {
                        float val1 = ReadFloat(ref stream);
                        float val2 = ReadFloat(ref stream);
                        float val3 = ReadFloat(ref stream);
#if VERBOSE
                        DebugOut("Rage prop 1(" + key + ")", val1);
                        DebugOut("Rage prop 2(" + key + ")", val2);
                        DebugOut("Rage prop 3(" + key + ")", val3);
#endif
                        // If you actually need these values, figure out what 12 byte
                        // structure they represent and add that property.
                        // It's probably a Vector3.
                        // file.AddProperty(key, MyRageKeyStructure);
                    }
                }
            }

            // Old-style offsets to strings
            if ((format & 0x1000) == 0)
            {
#if VERBOSE
                DebugOut("No offsets segment", "skipping");
#endif
            }
            else
            {
#if VERBOSE
                DebugOut("Old style data position", stream.Position);
#endif
                int    lastOffset = -1;
                long[] keys       = ReadSegmentKeys(ref stream);

                //
                // New method to read the newer .inibins.
                // Why determine the offset by reading in data from the file header
                // when we can just compute it here?  This seems to fix the problem
                // with newer .inibins.  I'm not sure what the value in the header
                // is used for though.
                //

                if (keys != null)
                {
                    oldStyleOffset = (int)stream.Position + keys.Length * 2;

                    foreach (long key in keys)
                    {
                        int offset = (int)ReadShort(ref stream);
#if VERBOSE
                        DebugOut("String offset(" + key + ")", offset);
#endif
                        String val = ReadNullTerminatedString(ref stream,
                                                              oldStyleOffset + offset);
#if VERBOSE
                        DebugOut("String prop(" + key + ")", val);
#endif

                        file.AddProperty(key, val);

                        lastOffset = offset;
                    }
                }
            }

#if VERBOSE
            // Debuging Code
            //Debug.WriteLine("Skin #1 Name: " + file.properties[(long) InibinHashID.SKIN_ONE_NAME]);
            Debug.WriteLine("Skin #1 SKN: " + file.properties[(long)InibinHashID.SKIN_ONE_SKN]);
            Debug.WriteLine("Skin #1 SKL: " + file.properties[(long)InibinHashID.SKIN_ONE_SKL]);
            Debug.WriteLine("Skin #1 DDS: " + file.properties[(long)InibinHashID.SKIN_ONE_TEXTURE]);

            Debug.WriteLine("Skin #2 Name: " + file.properties[(long)InibinHashID.SKIN_TWO_NAME]);
            Debug.WriteLine("Skin #2 SKN: " + file.properties[(long)InibinHashID.SKIN_TWO_SKN]);
            Debug.WriteLine("Skin #2 SKL: " + file.properties[(long)InibinHashID.SKIN_TWO_SKL]);
            Debug.WriteLine("Skin #2 DDS: " + file.properties[(long)InibinHashID.SKIN_TWO_TEXTURE]);

            Debug.WriteLine("Skin #3 Name: " + file.properties[(long)InibinHashID.SKIN_THREE_NAME]);
            Debug.WriteLine("Skin #3 SKN: " + file.properties[(long)InibinHashID.SKIN_THREE_SKN]);
            Debug.WriteLine("Skin #3 SKL: " + file.properties[(long)InibinHashID.SKIN_THREE_SKL]);
            Debug.WriteLine("Skin #3 DDS: " + file.properties[(long)InibinHashID.SKIN_THREE_TEXTURE]);

            Debug.WriteLine("Skin #4 Name: " + file.properties[(long)InibinHashID.SKIN_FOUR_NAME]);
            Debug.WriteLine("Skin #4 SKN: " + file.properties[(long)InibinHashID.SKIN_FOUR_SKN]);
            Debug.WriteLine("Skin #4 SKL: " + file.properties[(long)InibinHashID.SKIN_FOUR_SKL]);
            Debug.WriteLine("Skin #4 DDS: " + file.properties[(long)InibinHashID.SKIN_FOUR_TEXTURE]);

            Debug.WriteLine("Skin #5 Name: " + file.properties[(long)InibinHashID.SKIN_FIVE_NAME]);
            Debug.WriteLine("Skin #5 SKN: " + file.properties[(long)InibinHashID.SKIN_FIVE_SKN]);
            Debug.WriteLine("Skin #5 SKL: " + file.properties[(long)InibinHashID.SKIN_FIVE_SKL]);
            Debug.WriteLine("Skin #5 DDS: " + file.properties[(long)InibinHashID.SKIN_FIVE_TEXTURE]);

            Debug.WriteLine("Skin #6 Name: " + file.properties[(long)InibinHashID.SKIN_SIX_NAME]);
            Debug.WriteLine("Skin #6 SKN: " + file.properties[(long)InibinHashID.SKIN_SIX_SKN]);
            Debug.WriteLine("Skin #6 SKL: " + file.properties[(long)InibinHashID.SKIN_SIX_SKL]);
            Debug.WriteLine("Skin #6 DDS: " + file.properties[(long)InibinHashID.SKIN_SIX_TEXTURE]);

            Debug.WriteLine("Skin #7 Name: " + file.properties[(long)InibinHashID.SKIN_SEVEN_NAME]);
            Debug.WriteLine("Skin #7 SKN: " + file.properties[(long)InibinHashID.SKIN_SEVEN_SKN]);
            Debug.WriteLine("Skin #7 SKL: " + file.properties[(long)InibinHashID.SKIN_SEVEN_SKL]);
            Debug.WriteLine("Skin #7 DDS: " + file.properties[(long)InibinHashID.SKIN_SEVEN_TEXTURE]);

            Debug.WriteLine("Skin #8 Name: " + file.properties[(long)InibinHashID.SKIN_EIGHT_NAME]);
            Debug.WriteLine("Skin #8 SKN: " + file.properties[(long)InibinHashID.SKIN_EIGHT_SKN]);
            Debug.WriteLine("Skin #8 SKL: " + file.properties[(long)InibinHashID.SKIN_EIGHT_SKL]);
            Debug.WriteLine("Skin #8 DDS: " + file.properties[(long)InibinHashID.SKIN_EIGHT_TEXTURE]);
#endif

            logger.Event("Version: " + version);

            //if (file.properties.ContainsKey((long)InibinHashID.SKIN_ONE_NAME))
            //logger.LogEvent("Skin #1 Name: " + file.properties[(long) InibinHashID.SKIN_ONE_NAME]);
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_ONE_SKN))
            {
                logger.Event("Skin #1 SKN: " + file.properties[(long)InibinHashID.SKIN_ONE_SKN]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_ONE_SKL))
            {
                logger.Event("Skin #1 SKL: " + file.properties[(long)InibinHashID.SKIN_ONE_SKL]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_ONE_TEXTURE))
            {
                logger.Event("Skin #1 DDS: " + file.properties[(long)InibinHashID.SKIN_ONE_TEXTURE]);
            }

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_TWO_NAME))
            {
                logger.Event("Skin #2 Name: " + file.properties[(long)InibinHashID.SKIN_TWO_NAME]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_TWO_SKN))
            {
                logger.Event("Skin #2 SKN: " + file.properties[(long)InibinHashID.SKIN_TWO_SKN]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_TWO_SKL))
            {
                logger.Event("Skin #2 SKL: " + file.properties[(long)InibinHashID.SKIN_TWO_SKL]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_TWO_TEXTURE))
            {
                logger.Event("Skin #2 DDS: " + file.properties[(long)InibinHashID.SKIN_TWO_TEXTURE]);
            }

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_THREE_NAME))
            {
                logger.Event("Skin #3 Name: " + file.properties[(long)InibinHashID.SKIN_THREE_NAME]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_THREE_SKN))
            {
                logger.Event("Skin #3 SKN: " + file.properties[(long)InibinHashID.SKIN_THREE_SKN]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_THREE_SKL))
            {
                logger.Event("Skin #3 SKL: " + file.properties[(long)InibinHashID.SKIN_THREE_SKL]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_THREE_TEXTURE))
            {
                logger.Event("Skin #3 DDS: " + file.properties[(long)InibinHashID.SKIN_THREE_TEXTURE]);
            }

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FOUR_NAME))
            {
                logger.Event("Skin #4 Name: " + file.properties[(long)InibinHashID.SKIN_FOUR_NAME]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FOUR_SKN))
            {
                logger.Event("Skin #4 SKN: " + file.properties[(long)InibinHashID.SKIN_FOUR_SKN]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FOUR_SKL))
            {
                logger.Event("Skin #4 SKL: " + file.properties[(long)InibinHashID.SKIN_FOUR_SKL]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FOUR_TEXTURE))
            {
                logger.Event("Skin #4 DDS: " + file.properties[(long)InibinHashID.SKIN_FOUR_TEXTURE]);
            }

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FIVE_NAME))
            {
                logger.Event("Skin #5 Name: " + file.properties[(long)InibinHashID.SKIN_FIVE_NAME]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FIVE_SKN))
            {
                logger.Event("Skin #5 SKN: " + file.properties[(long)InibinHashID.SKIN_FIVE_SKN]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FIVE_SKL))
            {
                logger.Event("Skin #5 SKL: " + file.properties[(long)InibinHashID.SKIN_FIVE_SKL]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_FIVE_TEXTURE))
            {
                logger.Event("Skin #5 DDS: " + file.properties[(long)InibinHashID.SKIN_FIVE_TEXTURE]);
            }

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SIX_NAME))
            {
                logger.Event("Skin #6 Name: " + file.properties[(long)InibinHashID.SKIN_SIX_NAME]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SIX_SKN))
            {
                logger.Event("Skin #6 SKN: " + file.properties[(long)InibinHashID.SKIN_SIX_SKN]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SIX_SKL))
            {
                logger.Event("Skin #6 SKL: " + file.properties[(long)InibinHashID.SKIN_SIX_SKL]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SIX_TEXTURE))
            {
                logger.Event("Skin #6 DDS: " + file.properties[(long)InibinHashID.SKIN_SIX_TEXTURE]);
            }

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SEVEN_NAME))
            {
                logger.Event("Skin #7 Name: " + file.properties[(long)InibinHashID.SKIN_SEVEN_NAME]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SEVEN_SKN))
            {
                logger.Event("Skin #7 SKN: " + file.properties[(long)InibinHashID.SKIN_SEVEN_SKN]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SEVEN_SKL))
            {
                logger.Event("Skin #7 SKL: " + file.properties[(long)InibinHashID.SKIN_SEVEN_SKL]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_SEVEN_TEXTURE))
            {
                logger.Event("Skin #7 DDS: " + file.properties[(long)InibinHashID.SKIN_SEVEN_TEXTURE]);
            }

            if (file.properties.ContainsKey((long)InibinHashID.SKIN_EIGHT_NAME))
            {
                logger.Event("Skin #8 Name: " + file.properties[(long)InibinHashID.SKIN_EIGHT_NAME]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_EIGHT_SKN))
            {
                logger.Event("Skin #8 SKN: " + file.properties[(long)InibinHashID.SKIN_EIGHT_SKN]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_EIGHT_SKL))
            {
                logger.Event("Skin #8 SKL: " + file.properties[(long)InibinHashID.SKIN_EIGHT_SKL]);
            }
            if (file.properties.ContainsKey((long)InibinHashID.SKIN_EIGHT_TEXTURE))
            {
                logger.Event("Skin #8 DDS: " + file.properties[(long)InibinHashID.SKIN_EIGHT_TEXTURE]);
            }

            return(result);
        }
Ejemplo n.º 5
0
        private void GenerateModelDefinitions(Logger logger)
        {
            foreach (RAFFileListEntry f in inibins)
            {
                InibinFile iniFile = new InibinFile();
                bool readResult = InibinReader.Read(f, ref iniFile, logger);

                if (readResult == true)
                {
                    // Add the models from this .inibin file
                    List<ModelDefinition> modelDefs = iniFile.GetModelStrings();
                    for (int j = 0; j < modelDefs.Count; ++j)
                    {
                        // Name the model after the parent directory
                        // of the .inibin plus the name from the .inibin.
                        // Some things overlap without both.

                        string path = f.FileName;
                        string[] splitPath = path.Split('/');

                        string directoryName = splitPath[splitPath.Length - 2];
                        if (directoryName.Contains("Base") == true ||
                            directoryName.Contains("Skin") == true)
                        {
                            // The directory structure for this case will be something like
                            // "*/ChampionName/Skins/Base/".
                            // We just want the "ChampionName".
                            directoryName = splitPath[splitPath.Length - 4];
                        }

                        // Sometimes the name from the .inibin file is "".
                        // So, just name it after the directory
                        String name = modelDefs[j].name;
                        if (name == "")
                        {
                            name = directoryName + "/" + directoryName;
                        }
                        else
                        {
                            name = directoryName + "/" + name;
                        }

                        try
                        {
                            LOLModel model;
                            bool storeResult = StoreModel(modelDefs[j], out model, logger);

                            if (storeResult == true)
                            {
                                // Try to store animations for model as well
                                storeResult = StoreAnimations(ref model, logger);
                            }

                            if (storeResult == true)
                            {
                                if (models.ContainsKey(name) == false)
                                {
                                    logger.Event("Adding model definition: " + name);
                                    models.Add(name, model);
                                }
                                else
                                {
                                    logger.Warning("Duplicate model definition: " + name);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            logger.Error("Unable to store model definition: " + name);
                            logger.Error(e.Message);
                        }
                    }
                }
            }
        }