public StringList(string language)
        {
            this.m_Language = language;
            this.m_Table    = new Hashtable();
            string filePath = Client.GetFilePath(string.Format("cliloc.{0}", (object)language));

            if (filePath == null)
            {
                this.m_Entries = new StringEntry[0];
            }
            else
            {
                ArrayList arrayList = new ArrayList();
                using (BinaryReader binaryReader = new BinaryReader((Stream) new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)))
                {
                    binaryReader.ReadInt32();
                    int num1 = (int)binaryReader.ReadInt16();
                    while (binaryReader.PeekChar() != -1)
                    {
                        int number = binaryReader.ReadInt32();
                        int num2   = (int)binaryReader.ReadByte();
                        int count  = (int)binaryReader.ReadInt16();
                        if (count > StringList.m_Buffer.Length)
                        {
                            StringList.m_Buffer = new byte[count + 1023 & -1024];
                        }
                        binaryReader.Read(StringList.m_Buffer, 0, count);
                        string @string = Encoding.UTF8.GetString(StringList.m_Buffer, 0, count);
                        arrayList.Add((object)new StringEntry(number, @string));
                        this.m_Table[(object)number] = (object)@string;
                    }
                }
                this.m_Entries = (StringEntry[])arrayList.ToArray(typeof(StringEntry));
            }
        }
Example #2
0
        public TileMatrixPatch(TileMatrix matrix, int index)
        {
            object[] objArray = new object[] { index };
            string   filePath = Client.GetFilePath("mapdiff{0}.mul", objArray);

            objArray = new object[] { index };
            string str = Client.GetFilePath("mapdiffl{0}.mul", objArray);

            if (filePath != null && str != null)
            {
                this.m_LandBlocks = this.PatchLand(matrix, filePath, str);
            }
            objArray = new object[] { index };
            string filePath1 = Client.GetFilePath("stadiff{0}.mul", objArray);

            objArray = new object[] { index };
            string str1 = Client.GetFilePath("stadiffl{0}.mul", objArray);

            objArray = new object[] { index };
            string filePath2 = Client.GetFilePath("stadiffi{0}.mul", objArray);

            if (filePath1 != null && str1 != null && filePath2 != null)
            {
                this.m_StaticBlocks = this.PatchStatics(matrix, filePath1, str1, filePath2);
            }
        }
Example #3
0
        private static unsafe SkillCategory[] LoadCategories()
        {
            SkillCategory[] list = new SkillCategory[0];

            string grpPath = Client.GetFilePath("skillgrp.mul");

            if (grpPath == null)
            {
                return(new SkillCategory[0]);
            }
            else
            {
                List <SkillCategory> toAdd = new List <SkillCategory>();

                using (FileStream stream = new FileStream(grpPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin = new BinaryReader(stream);

                    byte[] START = new byte[4];                     //File Start Offset

                    bin.Read(START, 0, 4);

                    int index = 0;

                    long
                        x = stream.Length,
                        y = 0;


                    while (y < x)                     //Position < Length
                    {
                        string name      = ParseName(stream);
                        long   fileIndex = stream.Position - name.Length;

                        if (name.Length > 0)
                        {
                            toAdd.Add(new SkillCategory(new SkillCategoryData(fileIndex, index, name)));

                            y = stream.Position;

                            ++index;
                        }
                    }
                }

                if (toAdd.Count > 0)
                {
                    list = new SkillCategory[toAdd.Count];

                    for (int i = 0; i < toAdd.Count; i++)
                    {
                        list[i] = toAdd[i];
                    }

                    toAdd.Clear();
                }
            }

            return(list);
        }
Example #4
0
        static Sounds()
        {
            m_Index  = new BinaryReader(new FileStream(Client.GetFilePath("soundidx.mul"), FileMode.Open));
            m_Stream = new FileStream(Client.GetFilePath("sound.mul"), FileMode.Open);
            Regex reg = new Regex(@"(\d{1,3}) \x7B(\d{1,3})\x7D (\d{1,3})", RegexOptions.Compiled);

            m_Translations = new Dictionary <int, int>();

            string line;

            using (StreamReader reader = new StreamReader(Client.GetFilePath("Sound.def")))
            {
                while ((line = reader.ReadLine()) != null)
                {
                    if (((line = line.Trim()).Length != 0) && !line.StartsWith("#"))
                    {
                        Match match = reg.Match(line);

                        if (match.Success)
                        {
                            m_Translations.Add(int.Parse(match.Groups[1].Value), int.Parse(match.Groups[2].Value));
                        }
                    }
                }
            }
        }
Example #5
0
        static Hues()
        {
            string filePath = Client.GetFilePath("hues.mul");
            int    num      = 0;

            Hues.m_List = new Hue[3000];
            if (filePath != null)
            {
                using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader binaryReader = new BinaryReader(fileStream);
                    int          length       = (int)fileStream.Length / 708;
                    if (length > 375)
                    {
                        length = 375;
                    }
                    for (int i = 0; i < length; i++)
                    {
                        binaryReader.ReadInt32();
                        int num1 = 0;
                        while (num1 < 8)
                        {
                            Hues.m_List[num] = new Hue(num, binaryReader);
                            num1++;
                            num++;
                        }
                    }
                }
            }
            while (num < 3000)
            {
                Hues.m_List[num] = new Hue(num);
                num++;
            }
        }
Example #6
0
        public StringList(string language)
        {
            this.m_Language = language;
            this.m_Table    = new Hashtable();
            string filePath = Client.GetFilePath(string.Format("cliloc.{0}", language));

            if (filePath == null)
            {
                this.m_Entries = new StringEntry[0];
                return;
            }
            ArrayList arrayLists = new ArrayList();

            using (BinaryReader binaryReader = new BinaryReader(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
                binaryReader.ReadInt32();
                binaryReader.ReadInt16();
                while (binaryReader.PeekChar() != -1)
                {
                    int num = binaryReader.ReadInt32();
                    binaryReader.ReadByte();
                    int num1 = binaryReader.ReadInt16();
                    if (num1 > (int)StringList.m_Buffer.Length)
                    {
                        StringList.m_Buffer = new byte[num1 + 1023 & -1024];
                    }
                    binaryReader.Read(StringList.m_Buffer, 0, num1);
                    string str = Encoding.UTF8.GetString(StringList.m_Buffer, 0, num1);
                    arrayLists.Add(new StringEntry(num, str));
                    this.m_Table[num] = str;
                }
            }
            this.m_Entries = (StringEntry[])arrayLists.ToArray(typeof(StringEntry));
        }
Example #7
0
        static Verdata()
        {
            string path = Client.GetFilePath("verdata.mul");

            if (path == null)
            {
                m_Patches = new Entry5D[0];
                m_Stream  = Stream.Null;
            }
            else
            {
                m_Stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                BinaryReader bin = new BinaryReader(m_Stream);

                m_Patches = new Entry5D[bin.ReadInt32()];

                for (int i = 0; i < m_Patches.Length; ++i)
                {
                    m_Patches[i].file   = bin.ReadInt32();
                    m_Patches[i].index  = bin.ReadInt32();
                    m_Patches[i].lookup = bin.ReadInt32();
                    m_Patches[i].length = bin.ReadInt32();
                    m_Patches[i].extra  = bin.ReadInt32();
                }
            }
        }
Example #8
0
        public StringList(string language)
        {
            m_Language = language;
            m_Table    = new Hashtable();
            m_EntTable = new Hashtable();

            string path = Client.GetFilePath(String.Format("cliloc.{0}", language));

            if (path == null || !File.Exists(path))
            {
                Console.WriteLine("Error! Unable to open {0}!", path);
                m_Entries = new StringEntry[0];
                return;
            }

            ArrayList list = new ArrayList();

            using (BinaryReader bin = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8))
            {
                bin.ReadInt32();
                bin.ReadInt16();

                try
                {
                    while (true)
                    {
                        int number = bin.ReadInt32();
                        bin.ReadByte();
                        int length = bin.ReadInt16();

                        if (length > m_Buffer.Length)
                        {
                            m_Buffer = new byte[(length + 1023) & ~1023];
                        }

                        bin.Read(m_Buffer, 0, length);

                        try
                        {
                            StringEntry ent;
                            string      text = Encoding.UTF8.GetString(m_Buffer, 0, length);

                            ent = new StringEntry(number, text);
                            list.Add(ent);
                            m_EntTable[number] = ent;
                            m_Table[number]    = text;
                        }
                        catch
                        {
                        }
                    }
                }
                catch (System.IO.EndOfStreamException)
                {
                    // end of file.  stupid C#.
                }
            }

            m_Entries = (StringEntry[])list.ToArray(typeof(StringEntry));
        }
Example #9
0
        public TileMatrixPatch(TileMatrix matrix, int index)
        {
            try
            {
                string mapDataPath  = Client.GetFilePath("mapdiff{0}.mul", index);
                string mapIndexPath = Client.GetFilePath("mapdiffl{0}.mul", index);

                if (mapDataPath != null && mapIndexPath != null)
                {
                    m_LandBlocks = PatchLand(matrix, mapDataPath, mapIndexPath);
                }

                string staDataPath   = Client.GetFilePath("stadiff{0}.mul", index);
                string staIndexPath  = Client.GetFilePath("stadiffl{0}.mul", index);
                string staLookupPath = Client.GetFilePath("stadiffi{0}.mul", index);

                if (staDataPath != null && staIndexPath != null && staLookupPath != null)
                {
                    m_StaticBlocks = PatchStatics(matrix, staDataPath, staIndexPath, staLookupPath);
                }
            }
            catch
            {
            }
        }
Example #10
0
        static Hues()
        {
            string filePath = Client.GetFilePath("hues.mul");
            int    index1   = 0;

            Hues.m_List = new Hue[3000];
            if (filePath != null)
            {
                using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin  = new BinaryReader((Stream)fileStream);
                    int          num1 = (int)fileStream.Length / 708;
                    if (num1 > 375)
                    {
                        num1 = 375;
                    }
                    for (int index2 = 0; index2 < num1; ++index2)
                    {
                        bin.ReadInt32();
                        int num2 = 0;
                        while (num2 < 8)
                        {
                            Hues.m_List[index1] = new Hue(index1, bin);
                            ++num2;
                            ++index1;
                        }
                    }
                }
            }
            for (; index1 < 3000; ++index1)
            {
                Hues.m_List[index1] = new Hue(index1);
            }
        }
Example #11
0
 public static void Init()
 {
     streamArray[0] = new FileStream(Client.GetFilePath("unifont.mul"), FileMode.Open, FileAccess.Read);
     streamArray[1] = new FileStream(Client.GetFilePath("unifont1.mul"), FileMode.Open, FileAccess.Read);
     streamArray[2] = new FileStream(Client.GetFilePath("unifont2.mul"), FileMode.Open, FileAccess.Read);
     readerArray[0] = new BinaryReader(streamArray[0]);
     readerArray[1] = new BinaryReader(streamArray[1]);
     readerArray[2] = new BinaryReader(streamArray[2]);
 }
Example #12
0
        public TileMatrix(int fileIndex, int mapID, int width, int height)
        {
            m_Width       = width;
            m_Height      = height;
            m_BlockWidth  = width >> 3;
            m_BlockHeight = height >> 3;

            if (fileIndex != 0x7F)
            {
                string mapPath = Client.GetFilePath("map{0}.mul", fileIndex);

                if (mapPath != null && File.Exists(mapPath))
                {
                    m_Map = new FileStream(mapPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                }

                string indexPath = Client.GetFilePath("staidx{0}.mul", fileIndex);

                if (indexPath != null && File.Exists(indexPath))
                {
                    m_Index       = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    m_IndexReader = new BinaryReader(m_Index);
                }

                string staticsPath = Client.GetFilePath("statics{0}.mul", fileIndex);

                if (staticsPath != null && File.Exists(staticsPath))
                {
                    m_Statics = new FileStream(staticsPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                }
            }

            m_EmptyStaticBlock = new HuedTile[8][][];

            for (int i = 0; i < 8; ++i)
            {
                m_EmptyStaticBlock[i] = new HuedTile[8][];

                for (int j = 0; j < 8; ++j)
                {
                    m_EmptyStaticBlock[i][j] = new HuedTile[0];
                }
            }

            m_InvalidLandBlock = new Tile[196];

            m_LandTiles   = new Tile[m_BlockWidth][][];
            m_StaticTiles = new HuedTile[m_BlockWidth][][][][];

            m_Patch = new TileMatrixPatch(this, mapID);

            /*for ( int i = 0; i < m_BlockWidth; ++i )
             * {
             *      m_LandTiles[i] = new Tile[m_BlockHeight][];
             *      m_StaticTiles[i] = new Tile[m_BlockHeight][][][];
             * }*/
        }
Example #13
0
        static TileData()
        {
            string filePath = Client.GetFilePath("tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin = new BinaryReader(fs);

                    m_LandData = new LandData[0x4000];

                    for (int i = 0; i < 0x4000; ++i)
                    {
                        if ((i & 0x1F) == 0)
                        {
                            bin.ReadInt32();                             // header
                        }

                        TileFlag flags = (TileFlag)bin.ReadInt32();
                        bin.ReadInt16();                         // skip 2 bytes -- textureID

                        m_LandData[i] = new LandData(ReadNameString(bin), flags);
                    }

                    m_ItemData    = new ItemData[0x4000];
                    m_HeightTable = new int[0x4000];

                    for (int i = 0; i < 0x4000; ++i)
                    {
                        if ((i & 0x1F) == 0)
                        {
                            bin.ReadInt32();                             // header
                        }
                        TileFlag flags   = (TileFlag)bin.ReadInt32();
                        int      weight  = bin.ReadByte();
                        int      quality = bin.ReadByte();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int quantity = bin.ReadByte();
                        int anim     = bin.ReadInt16();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int value  = bin.ReadByte();
                        int height = bin.ReadByte();

                        m_ItemData[i]    = new ItemData(ReadNameString(bin), flags, weight, quality, quantity, value, height, anim);
                        m_HeightTable[i] = height;
                    }
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }
Example #14
0
        private static unsafe void LoadColors()
        {
            Map.m_Colors = new short[32768];
            string filePath = Client.GetFilePath("radarcol.mul");

            if (filePath == null)
                return;

            fixed(short *numPtr = &Map.m_Colors[0])
            {
                using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    Map._lread(fileStream.Handle, (void *)numPtr, 65536);
            }
        }
Example #15
0
        static ASCIIText()
        {
            string path = Client.GetFilePath("fonts.mul");

            if (path != null)
            {
                using (BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open)))
                {
                    for (int i = 0; i < 10; ++i)
                    {
                        Fonts[i] = new ASCIIFont();

                        byte header = reader.ReadByte();

                        for (int k = 0; k < 224; ++k)
                        {
                            byte width  = reader.ReadByte();
                            byte height = reader.ReadByte();
                            reader.ReadByte();                             // delimeter?

                            if (width > 0 && height > 0)
                            {
                                if (height > Fonts[i].Height && k < 96)
                                {
                                    Fonts[i].Height = height;
                                }

                                Bitmap bmp = new Bitmap(width, height);

                                for (int y = 0; y < height; ++y)
                                {
                                    for (int x = 0; x < width; ++x)
                                    {
                                        short pixel = (short)(reader.ReadByte() | (reader.ReadByte() << 8));

                                        if (pixel != 0)
                                        {
                                            bmp.SetPixel(x, y, Color.FromArgb((pixel & 0x7C00) >> 7, (pixel & 0x3E0) >> 2, (pixel & 0x1F) << 3));
                                        }
                                    }
                                }

                                Fonts[i].Characters[k] = bmp;
                            }
                        }
                    }
                }
            }
        }
Example #16
0
        static BodyTable()
        {
            m_Entries = new Dictionary <int, BodyTableEntry>();

            string filePath = Client.GetFilePath("body.def");

            if (filePath == null)
            {
                return;
            }

            StreamReader def = new StreamReader(filePath);

            string line;

            while ((line = def.ReadLine()) != null)
            {
                if ((line = line.Trim()).Length == 0 || line.StartsWith("#"))
                {
                    continue;
                }

                try
                {
                    int index1 = line.IndexOf(" {");
                    int index2 = line.IndexOf("} ");

                    string param1 = line.Substring(0, index1);
                    string param2 = line.Substring(index1 + 2, index2 - index1 - 2);
                    string param3 = line.Substring(index2 + 2);

                    int indexOf = param2.IndexOf(',');

                    if (indexOf > -1)
                    {
                        param2 = param2.Substring(0, indexOf).Trim();
                    }

                    int iParam1 = Convert.ToInt32(param1);
                    int iParam2 = Convert.ToInt32(param2);
                    int iParam3 = Convert.ToInt32(param3);

                    m_Entries[iParam1] = new BodyTableEntry(iParam2, iParam1, iParam3);
                }
                catch
                {
                }
            }
        }
Example #17
0
        /*public unsafe void GetImage( int x, int y, int width, int height, Bitmap bmp )
         * {
         *      if ( m_Colors == null )
         *              LoadColors();
         *
         *      TileMatrix matrix = Tiles;
         *
         *      BitmapData bd = bmp.LockBits( new Rectangle( 0, 0, width<<3, height<<3 ), ImageLockMode.WriteOnly, PixelFormat.Format16bppRgb555 );
         *
         *      int scanDelta = bd.Stride >> 1;
         *
         *      short *pvDest = (short *)bd.Scan0;
         *
         *      fixed ( short *pColors = m_Colors )
         *      {
         *              fixed ( int *pHeight = TileData.HeightTable )
         *              {
         *                      for ( int i = 0; i < width; ++i )
         *                      {
         *                              pvDest = ((short *)bd.Scan0) + (i << 3);
         *
         *                              for ( int j = 0; j < height; ++j )
         *                              {
         *                                      Tile[] tiles = matrix.GetLandBlock( x + i, y + j );
         *                                      HuedTile[][][] statics = matrix.GetStaticBlock( x + i, y + j );
         *
         *                                      for ( int k = 0, v = 0; k < 8; ++k, v += 8 )
         *                                      {
         *                                              for ( int p = 0; p < 8; ++p )
         *                                              {
         *                                                      int highTop = -255;
         *                                                      int highZ = -255;
         *                                                      int highID = 0;
         *                                                      int highHue = 0;
         *                                                      int z, top;
         *
         *                                                      HuedTile[] curStatics = statics[p][k];
         *
         *                                                      if ( curStatics.Length > 0 )
         *                                                      {
         *                                                              fixed ( HuedTile *phtStatics = curStatics )
         *                                                              {
         *                                                                      HuedTile *pStatics = phtStatics;
         *                                                                      HuedTile *pStaticsEnd = pStatics + curStatics.Length;
         *
         *                                                                      while ( pStatics < pStaticsEnd )
         *                                                                      {
         *                                                                              z = pStatics->m_Z;
         *                                                                              top = z + pHeight[pStatics->m_ID & 0x3FFF];
         *
         *                                                                              if ( top > highTop || (z > highZ && top >= highTop) )
         *                                                                              {
         *                                                                                      highTop = top;
         *                                                                                      highZ = z;
         *                                                                                      highID = pStatics->m_ID;
         *                                                                                      highHue = pStatics->m_Hue;
         *                                                                              }
         *
         ++pStatics;
         *                                                                      }
         *                                                              }
         *                                                      }
         *
         *                                                      top = tiles[v + p].Z;
         *
         *                                                      if ( top > highTop )
         *                                                      {
         *                                                              highID = tiles[v + p].ID;
         *                                                              highHue = 0;
         *                                                      }
         *
         *                                                      if ( highHue == 0 )
         *                                                              pvDest[p] = pColors[highID];
         *                                                      else
         *                                                              pvDest[p] = Hues.GetHue( highHue - 1 ).Colors[(pColors[highID] >> 10) & 0x1F];
         *                                              }
         *
         *                                              pvDest += scanDelta;
         *                                      }
         *                              }
         *                      }
         *              }
         *      }
         *
         *      bmp.UnlockBits(bd);
         * }*/

        private unsafe static void LoadColors()
        {
            m_Colors = new short[0x8000];

            string path = Client.GetFilePath("radarcol.mul");

            if (path == null)
                return;

            fixed(short *pColors = m_Colors)
            {
                using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
                    NativeMethods._lread(fs.SafeFileHandle, pColors, 0x10000);
            }
        }
        static TileData()
        {
            TileData.m_StringBuffer = new byte[20];
            string filePath = Client.GetFilePath("tiledata.mul");

            if (filePath == null)
            {
                throw new FileNotFoundException();
            }
            using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryReader binaryReader = new BinaryReader(fileStream);
                TileData.m_LandData = new LandData[16384];
                for (int i = 0; i < 16384; i++)
                {
                    if ((i & 31) == 0)
                    {
                        binaryReader.ReadInt32();
                    }
                    TileFlag tileFlag = (TileFlag)binaryReader.ReadInt32();
                    binaryReader.ReadInt16();
                    TileData.m_LandData[i] = new LandData(TileData.ReadNameString(binaryReader), tileFlag);
                }
                TileData.m_ItemData    = new ItemData[16384];
                TileData.m_HeightTable = new int[16384];
                for (int j = 0; j < 16384; j++)
                {
                    if ((j & 31) == 0)
                    {
                        binaryReader.ReadInt32();
                    }
                    TileFlag tileFlag1 = (TileFlag)binaryReader.ReadInt32();
                    int      num       = binaryReader.ReadByte();
                    int      num1      = binaryReader.ReadByte();
                    binaryReader.ReadInt16();
                    binaryReader.ReadByte();
                    int num2 = binaryReader.ReadByte();
                    int num3 = binaryReader.ReadInt16();
                    binaryReader.ReadInt16();
                    binaryReader.ReadByte();
                    int num4 = binaryReader.ReadByte();
                    int num5 = binaryReader.ReadByte();
                    TileData.m_ItemData[j]    = new ItemData(TileData.ReadNameString(binaryReader), tileFlag1, num, num1, num2, num4, num5, num3);
                    TileData.m_HeightTable[j] = num5;
                }
            }
        }
Example #19
0
        static TileData()
        {
            string filePath = Client.GetFilePath("tiledata.mul");

            if (filePath == null)
            {
                throw new FileNotFoundException();
            }
            using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryReader bin = new BinaryReader((Stream)fileStream);
                TileData.m_LandData = new LandData[16384];
                for (int index = 0; index < 16384; ++index)
                {
                    if ((index & 31) == 0)
                    {
                        bin.ReadInt32();
                    }
                    TileFlag flags = (TileFlag)bin.ReadInt32();
                    int      num   = (int)bin.ReadInt16();
                    TileData.m_LandData[index] = new LandData(TileData.ReadNameString(bin), flags);
                }
                TileData.m_ItemData    = new ItemData[16384];
                TileData.m_HeightTable = new int[16384];
                for (int index = 0; index < 16384; ++index)
                {
                    if ((index & 31) == 0)
                    {
                        bin.ReadInt32();
                    }
                    TileFlag flags    = (TileFlag)bin.ReadInt32();
                    int      weight   = (int)bin.ReadByte();
                    int      quality  = (int)bin.ReadByte();
                    int      num1     = (int)bin.ReadInt16();
                    int      num2     = (int)bin.ReadByte();
                    int      quantity = (int)bin.ReadByte();
                    int      anim     = (int)bin.ReadInt16();
                    int      num3     = (int)bin.ReadInt16();
                    int      num4     = (int)bin.ReadByte();
                    int      num5     = (int)bin.ReadByte();
                    int      height   = (int)bin.ReadByte();
                    TileData.m_ItemData[index]    = new ItemData(TileData.ReadNameString(bin), flags, weight, quality, quantity, num5, height, anim);
                    TileData.m_HeightTable[index] = height;
                }
            }
        }
Example #20
0
        public FileIndex(string idxFile, string mulFile, int length, int file)
        {
            m_Index = new Entry3D[length];

            m_IndexPath = Client.GetFilePath(idxFile);
            m_MulPath   = Client.GetFilePath(mulFile);

            if (m_IndexPath != null && m_MulPath != null)
            {
                using (FileStream index = new FileStream(m_IndexPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin = new BinaryReader(index);
                    m_Stream = new FileStream(m_MulPath, FileMode.Open, FileAccess.Read, FileShare.Read);

                    int count = (int)(index.Length / 12);

                    for (int i = 0; i < count && i < length; ++i)
                    {
                        m_Index[i].lookup = bin.ReadInt32();
                        m_Index[i].length = bin.ReadInt32();
                        m_Index[i].extra  = bin.ReadInt32();
                    }

                    for (int i = count; i < length; ++i)
                    {
                        m_Index[i].lookup = -1;
                        m_Index[i].length = -1;
                        m_Index[i].extra  = -1;
                    }
                }
            }

            Entry5D[] patches = Verdata.Patches;

            for (int i = 0; i < patches.Length; ++i)
            {
                Entry5D patch = patches[i];

                if (patch.file == file && patch.index >= 0 && patch.index < length)
                {
                    m_Index[patch.index].lookup = patch.lookup;
                    m_Index[patch.index].length = patch.length | (1 << 31);
                    m_Index[patch.index].extra  = patch.extra;
                }
            }
        }
Example #21
0
        static BodyTable()
        {
            BodyTable.m_Entries = new Hashtable();
            string filePath = Client.GetFilePath("body.def");

            if (filePath == null)
            {
                return;
            }
            StreamReader streamReader = new StreamReader(filePath);

            while (true)
            {
                string str  = streamReader.ReadLine();
                string str1 = str;
                if (str == null)
                {
                    break;
                }
                string str2 = str1.Trim();
                str1 = str2;
                if (str2.Length != 0 && !str1.StartsWith("#"))
                {
                    try
                    {
                        int    num  = str1.IndexOf(" {");
                        int    num1 = str1.IndexOf("} ");
                        string str3 = str1.Substring(0, num);
                        string str4 = str1.Substring(num + 2, num1 - num - 2);
                        string str5 = str1.Substring(num1 + 2);
                        int    num2 = str4.IndexOf(',');
                        if (num2 > -1)
                        {
                            str4 = str4.Substring(0, num2).Trim();
                        }
                        int bodyTableEntry = Convert.ToInt32(str3);
                        int num3           = Convert.ToInt32(str4);
                        int num4           = Convert.ToInt32(str5);
                        BodyTable.m_Entries[bodyTableEntry] = new BodyTableEntry(num3, bodyTableEntry, num4);
                    }
                    catch
                    {
                    }
                }
            }
        }
Example #22
0
        public TileMatrixPatch(TileMatrix matrix, int index)
        {
            string filePath1 = Client.GetFilePath("mapdiff{0}.mul", (object)index);
            string filePath2 = Client.GetFilePath("mapdiffl{0}.mul", (object)index);

            if (filePath1 != null && filePath2 != null)
            {
                this.m_LandBlocks = this.PatchLand(matrix, filePath1, filePath2);
            }
            string filePath3 = Client.GetFilePath("stadiff{0}.mul", (object)index);
            string filePath4 = Client.GetFilePath("stadiffl{0}.mul", (object)index);
            string filePath5 = Client.GetFilePath("stadiffi{0}.mul", (object)index);

            if (filePath3 == null || filePath4 == null || filePath5 == null)
            {
                return;
            }
            this.m_StaticBlocks = this.PatchStatics(matrix, filePath3, filePath4, filePath5);
        }
        static BodyTable()
        {
            string filePath = Client.GetFilePath("body.def");

            if (filePath == null)
            {
                return;
            }
            StreamReader streamReader = new StreamReader(filePath);
            string       str1;

            while ((str1 = streamReader.ReadLine()) != null)
            {
                string str2;
                if ((str2 = str1.Trim()).Length != 0)
                {
                    if (!str2.StartsWith("#"))
                    {
                        try
                        {
                            int    length1 = str2.IndexOf(" {");
                            int    num     = str2.IndexOf("} ");
                            string str3    = str2.Substring(0, length1);
                            string str4    = str2.Substring(length1 + 2, num - length1 - 2);
                            string str5    = str2.Substring(num + 2);
                            int    length2 = str4.IndexOf(',');
                            if (length2 > -1)
                            {
                                str4 = str4.Substring(0, length2).Trim();
                            }
                            int newID  = Convert.ToInt32(str3);
                            int oldID  = Convert.ToInt32(str4);
                            int newHue = Convert.ToInt32(str5);
                            BodyTable.m_Entries[(object)newID] = (object)new BodyTableEntry(oldID, newID, newHue);
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
 public TileMatrix(int fileIndex, int mapID, int width, int height)
 {
     this.m_Width       = width;
     this.m_Height      = height;
     this.m_BlockWidth  = width >> 3;
     this.m_BlockHeight = height >> 3;
     if (fileIndex != 127)
     {
         object[] objArray = new object[] { fileIndex };
         string   filePath = Client.GetFilePath("map{0}.mul", objArray);
         if (filePath != null)
         {
             this.m_Map = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
         }
         objArray = new object[] { fileIndex };
         string str = Client.GetFilePath("staidx{0}.mul", objArray);
         if (str != null)
         {
             this.m_Index       = new FileStream(str, FileMode.Open, FileAccess.Read, FileShare.Read);
             this.m_IndexReader = new BinaryReader(this.m_Index);
         }
         objArray = new object[] { fileIndex };
         string filePath1 = Client.GetFilePath("statics{0}.mul", objArray);
         if (filePath1 != null)
         {
             this.m_Statics = new FileStream(filePath1, FileMode.Open, FileAccess.Read, FileShare.Read);
         }
     }
     this.m_EmptyStaticBlock = new HuedTile[8][][];
     for (int i = 0; i < 8; i++)
     {
         this.m_EmptyStaticBlock[i] = new HuedTile[8][];
         for (int j = 0; j < 8; j++)
         {
             this.m_EmptyStaticBlock[i][j] = new HuedTile[0];
         }
     }
     this.m_InvalidLandBlock = new Tile[196];
     this.m_LandTiles        = new Tile[this.m_BlockWidth][][];
     this.m_StaticTiles      = new HuedTile[this.m_BlockWidth][][][][];
     this.m_Patch            = new TileMatrixPatch(this, mapID);
 }
Example #25
0
        public static void SetMaxHeight()
        {
            string filePath = Client.GetFilePath("tiledata.mul");

            if (filePath != null && File.Exists(filePath))
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    BinaryWriter bin = new BinaryWriter(fs);

                    for (int i = 0; i < 0x4000; ++i)
                    {
                    }
                }
            }
            else
            {
                //throw new FileNotFoundException();
            }
        }
Example #26
0
        public StringList(string language)
        {
            this.language = language;
            table         = new Dictionary <int, string>();

            string path = Client.GetFilePath(String.Format("cliloc.{0}", language));

            if (path == null)
            {
                entries = new StringEntry[0];
                return;
            }

            List <StringEntry> list = new List <StringEntry>();

            using (BinaryReader bin = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.Unicode))
            {
                bin.ReadInt32();
                bin.ReadInt16();

                while (bin.BaseStream.Position != bin.BaseStream.Length)
                {
                    int number = bin.ReadInt32();
                    bin.ReadByte();
                    int length = bin.ReadInt16();

                    if (length > buffer.Length)
                    {
                        buffer = new byte[(length + 1023) & ~1023];
                    }

                    bin.Read(buffer, 0, length);
                    string text = Encoding.UTF8.GetString(buffer, 0, length);

                    list.Add(new StringEntry(number, text));
                    table[number] = text;
                }
            }

            entries = (StringEntry[])list.ToArray();
        }
Example #27
0
        public StringList(string language)
        {
            m_Language = language;
            m_Table    = new Hashtable();

            string path = Client.GetFilePath(String.Format("cliloc.{0}", language));

            if (path == null)
            {
                m_Entries = new StringEntry[0];
                return;
            }

            ArrayList list = new ArrayList();

            using (BinaryReader bin = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
                bin.ReadInt32();
                bin.ReadInt16();

                while (bin.BaseStream.Length != bin.BaseStream.Position)
                {
                    int number = bin.ReadInt32();
                    bin.ReadByte();
                    int length = bin.ReadInt16();

                    if (length > m_Buffer.Length)
                    {
                        m_Buffer = new byte[(length + 1023) & ~1023];
                    }

                    bin.Read(m_Buffer, 0, length);
                    string text = Encoding.UTF8.GetString(m_Buffer, 0, length);

                    list.Add(new StringEntry(number, text));
                    m_Table[number] = text;
                }
            }

            m_Entries = (StringEntry[])list.ToArray(typeof(StringEntry));
        }
 public TileMatrix(int fileIndex, int mapID, int width, int height)
 {
     this.m_Width       = width;
     this.m_Height      = height;
     this.m_BlockWidth  = width >> 3;
     this.m_BlockHeight = height >> 3;
     if (fileIndex != (int)sbyte.MaxValue)
     {
         string filePath1 = Client.GetFilePath("map{0}.mul", (object)fileIndex);
         if (filePath1 != null)
         {
             this.m_Map = new FileStream(filePath1, FileMode.Open, FileAccess.Read, FileShare.Read);
         }
         string filePath2 = Client.GetFilePath("staidx{0}.mul", (object)fileIndex);
         if (filePath2 != null)
         {
             this.m_Index       = new FileStream(filePath2, FileMode.Open, FileAccess.Read, FileShare.Read);
             this.m_IndexReader = new BinaryReader((Stream)this.m_Index);
         }
         string filePath3 = Client.GetFilePath("statics{0}.mul", (object)fileIndex);
         if (filePath3 != null)
         {
             this.m_Statics = new FileStream(filePath3, FileMode.Open, FileAccess.Read, FileShare.Read);
         }
     }
     this.m_EmptyStaticBlock = new HuedTile[8][][];
     for (int index1 = 0; index1 < 8; ++index1)
     {
         this.m_EmptyStaticBlock[index1] = new HuedTile[8][];
         for (int index2 = 0; index2 < 8; ++index2)
         {
             this.m_EmptyStaticBlock[index1][index2] = new HuedTile[0];
         }
     }
     this.m_InvalidLandBlock = new Tile[196];
     this.m_LandTiles        = new Tile[this.m_BlockWidth][][];
     this.m_StaticTiles      = new HuedTile[this.m_BlockWidth][][][][];
     this.m_Patch            = new TileMatrixPatch(this, mapID);
 }
Example #29
0
        public FileIndex(string idxFile, string mulFile, int length, int file)
        {
            this.m_Index = new Entry3D[length];
            string filePath = Client.GetFilePath(idxFile);
            string str      = Client.GetFilePath(mulFile);

            if (filePath != null && str != null)
            {
                using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader binaryReader = new BinaryReader(fileStream);
                    this.m_Stream = new FileStream(str, FileMode.Open, FileAccess.Read, FileShare.Read);
                    int num = (int)(fileStream.Length / (long)12);
                    for (int i = 0; i < num && i < length; i++)
                    {
                        this.m_Index[i].lookup = binaryReader.ReadInt32();
                        this.m_Index[i].length = binaryReader.ReadInt32();
                        this.m_Index[i].extra  = binaryReader.ReadInt32();
                    }
                    for (int j = num; j < length; j++)
                    {
                        this.m_Index[j].lookup = -1;
                        this.m_Index[j].length = -1;
                        this.m_Index[j].extra  = -1;
                    }
                }
            }
            Entry5D[] patches = Verdata.Patches;
            for (int k = 0; k < (int)patches.Length; k++)
            {
                Entry5D entry5D = patches[k];
                if (entry5D.file == file && entry5D.index >= 0 && entry5D.index < length)
                {
                    this.m_Index[entry5D.index].lookup = entry5D.lookup;
                    this.m_Index[entry5D.index].length = entry5D.length | -2147483648;
                    this.m_Index[entry5D.index].extra  = entry5D.extra;
                }
            }
        }
Example #30
0
        static Verdata()
        {
            string filePath = Client.GetFilePath("verdata.mul");

            if (filePath == null)
            {
                Verdata.m_Patches = new Entry5D[0];
                Verdata.m_Stream  = System.IO.Stream.Null;
                return;
            }
            Verdata.m_Stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
            BinaryReader binaryReader = new BinaryReader(Verdata.m_Stream);

            Verdata.m_Patches = new Entry5D[binaryReader.ReadInt32()];
            for (int i = 0; i < (int)Verdata.m_Patches.Length; i++)
            {
                Verdata.m_Patches[i].file   = binaryReader.ReadInt32();
                Verdata.m_Patches[i].index  = binaryReader.ReadInt32();
                Verdata.m_Patches[i].lookup = binaryReader.ReadInt32();
                Verdata.m_Patches[i].length = binaryReader.ReadInt32();
                Verdata.m_Patches[i].extra  = binaryReader.ReadInt32();
            }
        }