Ejemplo n.º 1
0
        public static bool ExtractSingleWmo(uint fileId)
        {
            // Copy files from archive
            string fileName = $"File{fileId:X8}.xxx";

            if (File.Exists(Program.wmoDirectory + fileName))
            {
                return(true);
            }

            bool file_ok = true;

            Console.WriteLine($"Extracting {fileName}");
            WMORoot froot = new WMORoot();

            if (!froot.open(fileId))
            {
                Console.WriteLine("Couldn't open RootWmo!!!");
                return(true);
            }

            using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(Program.wmoDirectory + fileName, FileMode.Create, FileAccess.Write)))
            {
                froot.ConvertToVMAPRootWmo(binaryWriter);
                int Wmo_nVertices = 0;
                //printf("root has %d groups\n", froot->nGroups);
                for (int i = 0; i < froot.groupFileDataIDs.Count; ++i)
                {
                    WMOGroup fgroup = new WMOGroup();
                    if (!fgroup.open(froot.groupFileDataIDs[i]))
                    {
                        Console.WriteLine($"Could not open all Group file for: {fileId.ToString()}");
                        file_ok = false;
                        break;
                    }

                    Wmo_nVertices += fgroup.ConvertToVMAPGroupWmo(binaryWriter, froot, false);// preciseVectorData);
                }

                binaryWriter.Seek(8, SeekOrigin.Begin); // store the correct no of vertices
                binaryWriter.Write(Wmo_nVertices);

                // Delete the extracted file in the case of an error
                if (!file_ok)
                {
                    File.Delete(Program.wmoDirectory + fileName);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static bool ExtractSingleWmo(string fileName)
        {
            // Copy files from archive
            string plainName = fileName.GetPlainName();

            if (File.Exists(Program.WmoDirectory + plainName))
            {
                return(true);
            }

            int p = 0;
            // Select root wmo files
            int index = plainName.IndexOf('_');

            if (index != -1)
            {
                string rchr = plainName.Substring(index);
                if (rchr != null)
                {
                    for (int i = 0; i < 4; ++i)
                    {
                        char m = rchr[i];
                        if (char.IsDigit(m))
                        {
                            p++;
                        }
                    }
                }
            }

            if (p == 3)
            {
                return(true);
            }

            bool file_ok = true;

            Console.WriteLine($"Extracting {fileName}");
            WMORoot froot = new WMORoot();

            if (!froot.open(fileName))
            {
                Console.WriteLine("Couldn't open RootWmo!!!");
                return(true);
            }

            using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(Program.WmoDirectory + plainName, FileMode.Create, FileAccess.Write)))
            {
                froot.ConvertToVMAPRootWmo(binaryWriter);

                WmoDoodads[plainName] = froot.DoodadData;
                WMODoodadData doodads       = WmoDoodads[plainName];
                int           Wmo_nVertices = 0;
                for (int i = 0; i < froot.groupFileDataIDs.Count; ++i)
                {
                    WMOGroup fgroup = new WMOGroup();
                    if (!fgroup.open(froot.groupFileDataIDs[i], froot))
                    {
                        Console.WriteLine($"Could not open all Group file for: {plainName}");
                        file_ok = false;
                        break;
                    }

                    Wmo_nVertices += fgroup.ConvertToVMAPGroupWmo(binaryWriter, false);
                    foreach (ushort groupReference in fgroup.DoodadReferences)
                    {
                        if (groupReference >= doodads.Spawns.Count)
                        {
                            continue;
                        }

                        uint doodadNameIndex = doodads.Spawns[groupReference].NameIndex;
                        if (!froot.ValidDoodadNames.Contains(doodadNameIndex))
                        {
                            continue;
                        }

                        doodads.References.Add(groupReference);
                    }
                }

                binaryWriter.Seek(8, SeekOrigin.Begin); // store the correct no of vertices
                binaryWriter.Write(Wmo_nVertices);

                // Delete the extracted file in the case of an error
                if (!file_ok)
                {
                    File.Delete(Program.WmoDirectory + fileName);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        public static bool ExtractSingleWmo(string fileName)
        {
            // Copy files from archive
            string plainName = fileName.GetPlainName();

            if (File.Exists(Program.wmoDirectory + plainName))
            {
                return(true);
            }

            int p = 0;
            // Select root wmo files
            int index = plainName.IndexOf('_');

            if (index != -1)
            {
                string rchr = plainName.Substring(index);
                if (rchr != null)
                {
                    for (int i = 0; i < 4; ++i)
                    {
                        char m = rchr[i];
                        if (char.IsDigit(m))
                        {
                            p++;
                        }
                    }
                }
            }

            if (p == 3)
            {
                return(true);
            }

            bool file_ok = true;

            Console.WriteLine($"Extracting {fileName}");
            WMORoot froot = new WMORoot();

            if (!froot.open(fileName))
            {
                Console.WriteLine("Couldn't open RootWmo!!!");
                return(true);
            }

            using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(Program.wmoDirectory + plainName, FileMode.Create, FileAccess.Write)))
            {
                froot.ConvertToVMAPRootWmo(binaryWriter);
                int Wmo_nVertices = 0;
                //printf("root has %d groups\n", froot->nGroups);
                for (int i = 0; i < froot.groupFileDataIDs.Count; ++i)
                {
                    WMOGroup fgroup = new WMOGroup();
                    if (!fgroup.open(froot.groupFileDataIDs[i]))
                    {
                        Console.WriteLine($"Could not open all Group file for: {plainName}");
                        file_ok = false;
                        break;
                    }

                    Wmo_nVertices += fgroup.ConvertToVMAPGroupWmo(binaryWriter, froot, false);// preciseVectorData);
                }

                binaryWriter.Seek(8, SeekOrigin.Begin); // store the correct no of vertices
                binaryWriter.Write(Wmo_nVertices);

                // Delete the extracted file in the case of an error
                if (!file_ok)
                {
                    File.Delete(Program.wmoDirectory + fileName);
                }
            }

            return(true);
        }