コード例 #1
0
            private unsafe void Thread_Start()
            {
                string path = Engine.FileManager.BasePath(string.Format("Data/QuickLoad/Anim{0}.mul", this.m_Index));
                string str2 = Engine.FileManager.ResolveMUL(string.Format("Anim{0}.mul", (this.m_Index == 1) ? "" : this.m_Index.ToString()));
                string str3 = Engine.FileManager.ResolveMUL(string.Format("Anim{0}.idx", (this.m_Index == 1) ? "" : this.m_Index.ToString()));

                if (!File.Exists(str2) || !File.Exists(str3))
                {
                    if (this.m_Index == 1)
                    {
                        this.m_Owner.m_Index = new Entry3D[0];
                        this.m_Owner.m_Count = 0;
                    }
                    else if (this.m_Index == 2)
                    {
                        this.m_Owner.m_Index2 = new Entry3D[0];
                        this.m_Owner.m_Count2 = 0;
                    }
                    else if (this.m_Index == 3)
                    {
                        this.m_Owner.m_Index3 = new Entry3D[0];
                        this.m_Owner.m_Count3 = 0;
                    }
                    else
                    {
                        this.m_Owner.m_Index4 = new Entry3D[0];
                        this.m_Owner.m_Count4 = 0;
                    }
                }
                else
                {
                    if (File.Exists(path))
                    {
                        using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
                        {
                            if (stream.Length >= 0x15L)
                            {
                                BinaryReader reader = new BinaryReader(stream);
                                if (reader.ReadBoolean())
                                {
                                    DateTime timeStamp = Engine.GetTimeStamp(str2);
                                    DateTime time2     = Engine.GetTimeStamp(str3);
                                    DateTime time3     = DateTime.FromFileTime(reader.ReadInt64());
                                    DateTime time4     = DateTime.FromFileTime(reader.ReadInt64());
                                    if ((timeStamp == time3) && (time2 == time4))
                                    {
                                        int num = reader.ReadInt32();
                                        if (reader.BaseStream.Length >= (0x15 + (num * 12)))
                                        {
                                            Entry3D[] entrydArray = new Entry3D[num];
                                            entrydArray = new Entry3D[num];
                                            fixed(Entry3D *entrydRef = entrydArray)
                                            {
                                                Engine.NativeRead((FileStream)reader.BaseStream, (void *)entrydRef, num * 12);
                                            }

                                            if (this.m_Index == 1)
                                            {
                                                this.m_Owner.m_Index = entrydArray;
                                                this.m_Owner.m_Count = num;
                                            }
                                            else if (this.m_Index == 2)
                                            {
                                                this.m_Owner.m_Index2 = entrydArray;
                                                this.m_Owner.m_Count2 = num;
                                            }
                                            else if (this.m_Index == 3)
                                            {
                                                this.m_Owner.m_Index3 = entrydArray;
                                                this.m_Owner.m_Count3 = num;
                                            }
                                            else
                                            {
                                                this.m_Owner.m_Index4 = entrydArray;
                                                this.m_Owner.m_Count4 = num;
                                            }
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    using (FileStream stream2 = new FileStream(str3, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        int       num2         = (int)(stream2.Length / 12L);
                        Entry3D[] entrydArray2 = new Entry3D[num2];
                        fixed(Entry3D *entrydRef2 = entrydArray2)
                        {
                            Engine.NativeRead(stream2, (void *)entrydRef2, num2 * 12);
                            using (FileStream stream3 = new FileStream(str2, FileMode.Open, FileAccess.Read, FileShare.Read))
                            {
                                BinaryReader reader2    = new BinaryReader(stream3);
                                Entry3D *    entrydPtr  = entrydRef2;
                                Entry3D *    entrydPtr2 = entrydRef2 + num2;
                                while (entrydPtr < entrydPtr2)
                                {
                                    if (entrydPtr->m_Lookup >= 0)
                                    {
                                        reader2.BaseStream.Seek((long)(entrydPtr->m_Lookup + 0x200), SeekOrigin.Begin);
                                        int num3 = reader2.ReadInt32() & 0xff;
                                        int num4 = 0;
                                        int num5 = -10000;
                                        while (num4 < num3)
                                        {
                                            reader2.BaseStream.Seek((long)((entrydPtr->m_Lookup + 0x204) + (num4 << 2)), SeekOrigin.Begin);
                                            reader2.BaseStream.Seek((long)((entrydPtr->m_Lookup + 0x202) + reader2.ReadInt32()), SeekOrigin.Begin);
                                            int num6 = reader2.ReadInt16();
                                            int num7 = reader2.ReadInt32() >> 0x10;
                                            if ((num7 + num6) > num5)
                                            {
                                                num5 = num7 + num6;
                                            }
                                            num4++;
                                        }
                                        entrydPtr->m_Extra = num3 | (num5 << 8);
                                    }
                                    entrydPtr++;
                                }
                            }
                            using (FileStream stream4 = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
                            {
                                BinaryWriter writer = new BinaryWriter(stream4);
                                writer.Write(false);
                                writer.Write(Engine.GetTimeStamp(str2).ToFileTime());
                                writer.Write(Engine.GetTimeStamp(str3).ToFileTime());
                                writer.Write(num2);
                                Engine.NativeWrite((FileStream)writer.BaseStream, (void *)entrydRef2, num2 * 12);
                                writer.Seek(0, SeekOrigin.Begin);
                                writer.Write(true);
                            }
                        }

                        if (this.m_Index == 1)
                        {
                            this.m_Owner.m_Index = entrydArray2;
                            this.m_Owner.m_Count = num2;
                        }
                        else if (this.m_Index == 2)
                        {
                            this.m_Owner.m_Index2 = entrydArray2;
                            this.m_Owner.m_Count2 = num2;
                        }
                        else if (this.m_Index == 3)
                        {
                            this.m_Owner.m_Index3 = entrydArray2;
                            this.m_Owner.m_Count3 = num2;
                        }
                        else
                        {
                            this.m_Owner.m_Index4 = entrydArray2;
                            this.m_Owner.m_Count4 = num2;
                        }
                    }
                }
            }