Exemplo n.º 1
0
 public void PrintDuplicationWarnings()
 {
     foreach (string warn in m_dupeWarnings)
     {
         CTDebug.Warn(warn);
     }
     m_dupeWarnings.Clear();
 }
Exemplo n.º 2
0
 public void Load(string path)
 {
     if (File.Exists(path))
     {
         string[] input = File.ReadAllLines(path);
         for (int i = 0; i < input.Length; ++i)
         {
             if (input[i][0] == '!')
             {
                 Group = input[i].Substring(1);
             }
             else if (input[i][0] == '@')
             {
                 switch (input[i].Substring(1).ToLowerInvariant())
                 {
                 case "minify":
                     Minify = true;
                     break;
                 }
             }
             else
             {
                 try
                 {
                     ColumnInfo readInfo = ColumnInfo.Parse(input[i]);
                     int        colIndex = this.FindIndex((ColumnInfo checkColumn) => { return(checkColumn.Name == readInfo.Name); });
                     if (colIndex >= 0 && this[colIndex].Name == readInfo.Name)
                     {
                         this[colIndex] = readInfo;
                     }
                     else
                     {
                         CTDebug.Warn("Could not find column {0}", readInfo.Name);
                     }
                 }
                 catch (FormatException e)
                 {
                     CTDebug.Error(e.ToString());
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        public void Read(string filename)
        {
            BinaryReader reader = new BinaryReader(File.OpenRead(filename));

            m_header = reader.ReadMdbFileHeader();
            for (int i = 0; i < m_header.NumPackets; ++i)
            {
                m_packetHeaders.Add(reader.ReadMdbPacketHeader());
            }
            for (int i = 0; i < m_header.NumPackets; ++i)
            {
                if (reader.BaseStream.Position != m_packetHeaders[i].Offset)
                {
                    CTDebug.Warn("At position {0}, expecting {1}", reader.BaseStream.Position, m_packetHeaders[i].Offset);
                    reader.BaseStream.Seek(m_packetHeaders[i].Offset, SeekOrigin.Begin);
                }
                m_packets.Add(reader.ReadMdbPacket());
            }
        }
Exemplo n.º 4
0
        public static void Run(string[] args)
        {
            string inDir = "in", outDir = "out";

            //Console.WriteLine("Please enter the input directory");
            //inDir = Console.ReadLine();
            //Console.WriteLine("Please enter the output directory");
            //outDir = Console.ReadLine();

            foreach (string path in Directory.EnumerateFiles(inDir))
            {
                string fileName = path.Split('\\').Last();
                if (path.ToLowerInvariant().EndsWith(".mdb"))
                {
                    string[] nameParts = fileName.Split('.')[0].Split('_');
                    string   newName;
                    int      number;
                    if (nameParts.Length != 3)
                    {
                        Cloaktower.CTDebug.Warn("Encountered bad filename: {0}", fileName);
                        File.Copy(path, Path.Combine(outDir, fileName), true);
                        continue;
                    }
                    else
                    {
                        number       = int.Parse(nameParts[2].Substring(4, 2)) + 30;
                        nameParts[2] = nameParts[2].Substring(0, 4) + (number).ToString();
                        newName      = string.Join("_", nameParts);
                    }
                    MdbDocument doc = new Cloaktower.MDB.MdbDocument(path);
                    doc.Read(path);

                    string filePrefix = fileName.Split('.')[0];
                    foreach (MdbPacket packet in doc.GetPackets())
                    {
                        if (packet is NamedMdbPacket)
                        {
                            NamedMdbPacket named = (NamedMdbPacket)packet;
                            if (named.Signature == "SKIN")
                            {
                                string[] split = named.Name.Contents.Split('_');
                                split[2] = split[2].Substring(0, split[2].Length - 2) + (number).ToString();
                                string newInternalName = named.Name.Contents.Substring(0, named.Name.Contents.Length - 2) + (number).ToString();
                                CTDebug.Info("Renaming {0} to {1}", named.Name.Contents, newInternalName);
                                named.Name.Contents = newInternalName;
                                if (split[2].Substring(0, 4) == "Head" && split.Length == 3)
                                {
                                    newName = newInternalName;
                                }
                            }
                            else if (named.Signature == "RIGD")
                            {
                                CTDebug.Warn("Found a RIGD in {0}", fileName);
                            }
                        }
                    }
                    doc.Write(Path.Combine(outDir, newName + ".mdb"));
                }
                else
                {
                    File.Copy(path, Path.Combine(outDir, fileName), true);
                }
            }
        }
Exemplo n.º 5
0
        public static MdbPacket ReadMdbPacket(this BinaryReader reader)
        {
            string    Signature     = reader.ReadAscii(4);
            UInt32    Size          = reader.ReadUInt32();
            MdbPacket ret           = null;
            long      debugCheckPos = reader.BaseStream.Position;

            switch (Signature)
            {
            case "RIGD":
                ret = reader.ReadMdbPacket_RIGD(Size);
                break;

            case "SKIN":
                ret = reader.ReadMdbPacket_SKIN(Size);
                break;

            case "COL2":
            case "COL3":
                ret = reader.ReadMdbPacket_COLN(Size);
                break;

            case "COLS":
                ret = reader.ReadMdbPacket_COLS(Size);
                break;

            case "WALK":
                ret = reader.ReadMdbPacket_WALK(Size);
                break;

            case "HOOK":
                ret = reader.ReadMdbPacket_HOOK(Size);
                break;

            case "TRRN":
                ret = reader.ReadMdbPacket_TRRN(Size);
                break;

            case "HELM":
                ret = reader.ReadMdbPacket_HELM(Size);
                break;

            case "HAIR":
                ret = reader.ReadMdbPacket_HAIR(Size);
                break;

            default:
                CTDebug.Error("Unrecognized object format: {0}", Signature);
                break;
            }

            long diff = reader.BaseStream.Position - debugCheckPos;

            if (diff != Size)
            {
                CTDebug.Warn("Invalid size of MDB Packet.");
            }
            ret.Size      = Size;
            ret.Signature = Signature;

            return(ret);
        }