Beispiel #1
0
        public void Parse(int adt_name, Dictionary <uint, List <Toolbox.IngameObject> > IG_Obj)
        {
            if ((adt_name > 0) && cs.FileExists(adt_name))
            {
                //Console.WriteLine("parsing " + adt_name + " : " +x + " / " + y);
                using (Stream stream = cs.OpenFile(adt_name))
                {
                    using (BinaryReader reader = new BinaryReader(stream))
                    {
                        while (reader.BaseStream.Position != reader.BaseStream.Length)
                        {
                            var magic = reader.ReadUInt32();
                            var size  = reader.ReadUInt32();
                            var pos   = reader.BaseStream.Position;

                            if (magic == Toolbox.mk("MFBO"))
                            {
                                plane_max.a    = new short[3];
                                plane_max.a[0] = reader.ReadInt16();
                                plane_max.a[1] = reader.ReadInt16();
                                plane_max.a[2] = reader.ReadInt16();
                                plane_max.b    = new short[3];
                                plane_max.b[0] = reader.ReadInt16();
                                plane_max.b[1] = reader.ReadInt16();
                                plane_max.b[2] = reader.ReadInt16();
                                plane_max.c    = new short[3];
                                plane_max.c[0] = reader.ReadInt16();
                                plane_max.c[1] = reader.ReadInt16();
                                plane_max.c[2] = reader.ReadInt16();

                                plane_min.a    = new short[3];
                                plane_min.a[0] = reader.ReadInt16();
                                plane_min.a[1] = reader.ReadInt16();
                                plane_min.a[2] = reader.ReadInt16();
                                plane_min.b    = new short[3];
                                plane_min.b[0] = reader.ReadInt16();
                                plane_min.b[1] = reader.ReadInt16();
                                plane_min.b[2] = reader.ReadInt16();
                                plane_min.c    = new short[3];
                                plane_min.c[0] = reader.ReadInt16();
                                plane_min.c[1] = reader.ReadInt16();
                                plane_min.c[2] = reader.ReadInt16();
                            }
                            if (magic == Toolbox.mk("MCNK"))
                            {
                                var flags          = reader.ReadUInt32();
                                var sub_x          = reader.ReadUInt32();
                                var sub_y          = reader.ReadUInt32();
                                var nLayers        = reader.ReadUInt32();
                                var nDoodadRefs    = reader.ReadUInt32();
                                var holes_high_res = reader.ReadUInt64();
                                var ofsLayer       = reader.ReadUInt32();
                                var ofsRefs        = reader.ReadUInt32();
                                var ofsAlpha       = reader.ReadUInt32();
                                var sizeAlpha      = reader.ReadUInt32();
                                var ofsShadow      = reader.ReadUInt32();
                                var sizeShadow     = reader.ReadUInt32();
                                var areaid         = reader.ReadUInt32();
                                impasses[sub_x, sub_y] = -1;
                                if (areaid == 0)
                                {
                                    unknown[sub_x, sub_y] = 1;
                                }
                                else
                                {
                                    Toolbox.CsvArea csvdefault = CsvAreas.Find(e => e.ID == (int)areaid);
                                    Toolbox.Area    area       = new Toolbox.Area();
                                    area.x     = x;
                                    area.y     = y;
                                    area.sub_x = sub_x;
                                    area.sub_y = sub_y;
                                    area.ID    = (int)areaid;
                                    if (csvdefault != null)
                                    {
                                        area.ZoneName      = csvdefault.ZoneName;
                                        area.AreaName_lang = csvdefault.AreaName_lang;
                                        area.ContinentID   = csvdefault.ContinentID;
                                    }
                                    areas.Add(area);
                                }
                                if ((flags & 2) == 2)
                                {
                                    impasses[sub_x, sub_y] = 1;
                                }
                            }

                            if (magic == Toolbox.mk("MWMO")) // wmo filenames
                            {
                                char c;
                                int  i = (int)size;
                                while (i > 0)
                                {
                                    StringBuilder sb = new StringBuilder();
                                    while ((c = Convert.ToChar(reader.ReadByte())) != '\0')
                                    {
                                        sb.Append(c);
                                        i--;
                                    }
                                    i--;
                                    if (!filenameswmo.Contains(sb.ToString()))
                                    {
                                        filenameswmo.Add(sb.ToString());
                                    }
                                }
                            }
                            if (magic == Toolbox.mk("MMDX")) // m2 filenames
                            {
                                char c;
                                int  i = (int)size;
                                while (i > 0)
                                {
                                    StringBuilder sb = new StringBuilder();
                                    while ((c = Convert.ToChar(reader.ReadByte())) != '\0')
                                    {
                                        sb.Append(c);
                                        i--;
                                    }
                                    i--;
                                    if (!filenamesm2.Contains(sb.ToString()))
                                    {
                                        filenamesm2.Add(sb.ToString());
                                    }
                                }
                            }

                            if (magic == Toolbox.mk("MMID")) // m2 offset names
                            {
                                while (reader.BaseStream.Position < pos + size)
                                {
                                    mmid.Add(reader.ReadUInt32());
                                }
                            }
                            if (magic == Toolbox.mk("MWID")) // wmo offset names
                            {
                                while (reader.BaseStream.Position < pos + size)
                                {
                                    mwid.Add(reader.ReadUInt32());
                                }
                            }

                            if (magic == Toolbox.mk("MODF")) // placement WMO
                            {
                                while (reader.BaseStream.Position < pos + size)
                                {
                                    objects.Add(Toolbox.MakeObject(reader, 0, listfile, x, y, mwid, filenameswmo, filelist, IG_Obj));
                                }
                            }
                            if (magic == Toolbox.mk("MDDF")) // placement m2
                            {
                                while (reader.BaseStream.Position < pos + size)
                                {
                                    objects.Add(Toolbox.MakeObject(reader, 1, listfile, x, y, mmid, filenamesm2, filelist, IG_Obj));
                                }
                            }

                            reader.BaseStream.Position = pos + size;
                        }
                    }
                }
                adt_claims_tile = true;
            }
        }
Beispiel #2
0
        public void ParseWdt(Dictionary <uint, List <Toolbox.IngameObject> > IG_Obj)
        {
            //Console.WriteLine("Parsing wdt " + wdt_id);
            if (cs.FileExists(wdt_id))
            {
                using (Stream stream = cs.OpenFile(wdt_id))
                {
                    using (BinaryReader reader = new BinaryReader(stream))
                    {
                        while (reader.BaseStream.Position != reader.BaseStream.Length)
                        {
                            var magic = reader.ReadUInt32();
                            var size  = reader.ReadUInt32();
                            var pos   = reader.BaseStream.Position;

                            if (magic == Toolbox.mk("MPHD"))
                            {
                                var flags = reader.ReadUInt32();
                                if ((flags & 1) == 1)
                                {
                                    wmo_only = true;
                                }
                            }
                            if (magic == Toolbox.mk("MAIN"))
                            {
                                for (int x = 0; x < 64; ++x)
                                {
                                    for (int y = 0; y < 64; ++y)
                                    {
                                        wdt_claimed_tiles[y, x] = (reader.ReadUInt32() & 1) == 1;
                                        all_claimed_tiles[y, x] = wdt_claimed_tiles[y, x];
                                        var asyncid = reader.ReadUInt32();
                                    }
                                }
                            }

                            if (magic == Toolbox.mk("MWMO")) // wmo filenames
                            {
                                char c;
                                int  i = (int)size;
                                while (i > 0)
                                {
                                    StringBuilder sb = new StringBuilder();
                                    while ((c = Convert.ToChar(reader.ReadByte())) != '\0')
                                    {
                                        sb.Append(c);
                                        i--;
                                    }
                                    i--;
                                    if (!filenameswmo.Contains(sb.ToString()))
                                    {
                                        filenameswmo.Add(sb.ToString());
                                    }
                                }
                            }

                            if (magic == Toolbox.mk("MODF"))
                            {
                                wmo = Toolbox.MakeObject(reader, 2, listfile, 1, 1, null, filenameswmo, filelist, IG_Obj);
                            }

                            if (magic == Toolbox.mk("MAID"))
                            {
                                for (int i = 0; i < 64; i++)
                                {
                                    for (int j = 0; j < 64; j++)
                                    {
                                        maid_chunk.root[i, j]    = reader.ReadUInt32();
                                        maid_chunk.obj0[i, j]    = reader.ReadUInt32();
                                        maid_chunk.obj1[i, j]    = reader.ReadUInt32();
                                        maid_chunk.tex0[i, j]    = reader.ReadUInt32();
                                        maid_chunk.loadadt[i, j] = reader.ReadUInt32();
                                        maid_chunk.mapt[i, j]    = reader.ReadUInt32();
                                        maid_chunk.maptn[i, j]   = reader.ReadUInt32();
                                        maid_chunk.minit[i, j]   = reader.ReadUInt32();
                                    }
                                }
                            }
                            reader.BaseStream.Position = pos + size;
                        }
                    }
                }
            }
            else
            {
                //Console.WriteLine("Wdt not found : " + wdt_id);
            }
        }
Beispiel #3
0
        public void Parse(int adt_name, Dictionary <uint, List <Toolbox.IngameObject> > IG_Obj)
        {
            if ((adt_name > 0) && cs.FileExists(adt_name))
            {
                using (Stream stream = cs.OpenFile(adt_name))
                {
                    using (BinaryReader reader = new BinaryReader(stream))
                    {
                        while (reader.BaseStream.Position != reader.BaseStream.Length)
                        {
                            var magic = reader.ReadUInt32();
                            var size  = reader.ReadUInt32();
                            var pos   = reader.BaseStream.Position;

                            if (magic == Toolbox.mk("MWMO")) // wmo filenames
                            {
                                char c;
                                int  i = (int)size;
                                while (i > 0)
                                {
                                    StringBuilder sb = new StringBuilder();
                                    while ((c = Convert.ToChar(reader.ReadByte())) != '\0')
                                    {
                                        sb.Append(c);
                                        i--;
                                    }
                                    i--;
                                    if (!filenameswmo.Contains(sb.ToString()))
                                    {
                                        filenameswmo.Add(sb.ToString());
                                    }
                                }
                            }
                            if (magic == Toolbox.mk("MMDX")) // m2 filenames
                            {
                                char c;
                                int  i = (int)size;
                                while (i > 0)
                                {
                                    StringBuilder sb = new StringBuilder();
                                    while ((c = Convert.ToChar(reader.ReadByte())) != '\0')
                                    {
                                        sb.Append(c);
                                        i--;
                                    }
                                    i--;
                                    if (!filenamesm2.Contains(sb.ToString()))
                                    {
                                        filenamesm2.Add(sb.ToString());
                                    }
                                }
                            }

                            if (magic == Toolbox.mk("MMID")) // m2 offset names
                            {
                                while (reader.BaseStream.Position < pos + size)
                                {
                                    mmid.Add(reader.ReadUInt32());
                                }
                            }
                            if (magic == Toolbox.mk("MWID")) // wmo offset names
                            {
                                while (reader.BaseStream.Position < pos + size)
                                {
                                    mwid.Add(reader.ReadUInt32());
                                }
                            }


                            if (magic == Toolbox.mk("MODF")) // placement WMO
                            {
                                while (reader.BaseStream.Position < pos + size)
                                {
                                    objects.Add(Toolbox.MakeObject(reader, 0, listfile, x, y, mwid, filenameswmo, filelist, IG_Obj));
                                }
                            }
                            if (magic == Toolbox.mk("MDDF")) // placement m2
                            {
                                while (reader.BaseStream.Position < pos + size)
                                {
                                    objects.Add(Toolbox.MakeObject(reader, 1, listfile, x, y, mmid, filenamesm2, filelist, IG_Obj));
                                }
                            }

                            reader.BaseStream.Position = pos + size;
                        }
                    }
                }
                obj_claims_tile = true;
            }
        }