Exemplo n.º 1
0
        void FillList()
        {
            uint val1, val2, val3, val4, val5;
            string cur = String.Empty, old = String.Empty;

            gr.BaseStream.Position = FIELDS_INFO_START;

            do
            {
                val1 = gr.ReadUInt32();
                if (val1 == 0)
                    val1 = gr.ReadUInt32();
                val2 = gr.ReadUInt32();
                val3 = gr.ReadUInt32();
                val4 = gr.ReadUInt32();
                val5 = gr.ReadUInt32();

                long oldpos = gr.BaseStream.Position;
                gr.BaseStream.Position = val1 - FIELDS_NAMES_OFFSET;

                try
                {
                    cur = gr.ReadStringNull();
                }
                catch(EndOfStreamException exc)
                {
                    break;
                }

                gr.BaseStream.Position = oldpos;

                string info = String.Format("Size: {0}, Type: {1}, Flags: {2}", val3, (UpdateFieldType)val4, (UpdatafieldFlags)val5);

                UpdateField uf = new UpdateField(cur, val2, val3, info);
                list.Add(uf);

                //if (!old.Equals("CORPSE_FIELD_PAD") && cur.Equals("CORPSE_FIELD_PAD"))
                //    break;

                old = cur;
            } while (true);
        }
Exemplo n.º 2
0
        void DumpToFile()
        {
            StreamWriter sw = new StreamWriter("UpdateFields.h");

            sw.WriteLine("/*");
            sw.WriteLine(" * Copyright (C) 2005-2010 MaNGOS <http://www.mangosproject.org/>");
            sw.WriteLine(" *");
            sw.WriteLine(" * This program is free software; you can redistribute it and/or modify");
            sw.WriteLine(" * it under the terms of the GNU General Public License as published by");
            sw.WriteLine(" * the Free Software Foundation; either version 2 of the License, or");
            sw.WriteLine(" * (at your option) any later version.");
            sw.WriteLine(" *");
            sw.WriteLine(" * This program is distributed in the hope that it will be useful,");
            sw.WriteLine(" * but WITHOUT ANY WARRANTY; without even the implied warranty of");
            sw.WriteLine(" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the");
            sw.WriteLine(" * GNU General Public License for more details.");
            sw.WriteLine(" *");
            sw.WriteLine(" * You should have received a copy of the GNU General Public License");
            sw.WriteLine(" * along with this program; if not, write to the Free Software");
            sw.WriteLine(" * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA");
            sw.WriteLine(" */");
            sw.WriteLine();
            sw.WriteLine("#ifndef _UPDATEFIELDS_AUTO_H");
            sw.WriteLine("#define _UPDATEFIELDS_AUTO_H");
            sw.WriteLine();
            sw.WriteLine("// Auto generated for version {0}", WOW_VERSION);
            sw.WriteLine();
            sw.WriteLine("enum EObjectFields");
            sw.WriteLine("{");

            string delta = String.Empty;

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

                if (uf.Pos == 0)
                {
                    if (i > 1)
                    {
                        long last_end = list[i - 1].Pos + list[i - 1].Total;

                        WriteFormat(sw, list[i - 1].Name, delta, last_end.ToString("X4"), "", true);

                        if (!list[i - 1].Name.Contains("UNIT"))
                        {
                            sw.WriteLine("};");
                            sw.WriteLine();
                        }
                        else
                        {
                            sw.WriteLine();
                        }

                        switch (list[i].Name)
                        {
                        case "ITEM_FIELD_OWNER":
                            sw.WriteLine("enum EItemFields");
                            sw.WriteLine("{");
                            break;

                        case "CONTAINER_FIELD_NUM_SLOTS":
                            sw.WriteLine("enum EContainerFields");
                            sw.WriteLine("{");
                            break;

                        case "UNIT_FIELD_CHARM":
                            sw.WriteLine("enum EUnitFields");
                            sw.WriteLine("{");
                            break;

                        case "OBJECT_FIELD_CREATED_BY":
                            sw.WriteLine("enum EGameObjectFields");
                            sw.WriteLine("{");
                            break;

                        case "DYNAMICOBJECT_CASTER":
                            sw.WriteLine("enum EDynamicObjectFields");
                            sw.WriteLine("{");
                            break;

                        case "CORPSE_FIELD_OWNER":
                            sw.WriteLine("enum ECorpseFields");
                            sw.WriteLine("{");
                            break;
                        }
                    }
                }

                delta = String.Empty;
                if (i > 5)
                {
                    delta = "OBJECT_END";
                }
                if (list[i].Name.StartsWith("CONTAINER"))
                {
                    delta = "ITEM_END";
                }
                if (list[i].Name.StartsWith("PLAYER"))
                {
                    delta = "UNIT_END";
                }

                WriteFormat(sw, list[i].Name, delta, (list[i].Pos).ToString("X4"), list[i].Descr, false);

                if (list[i].Total > 2)
                {
                    for (long k = 1; k < list[i].Total; ++k)
                    {
                        WriteFormat(sw, list[i].Name + "_" + k.ToString(), delta, (list[i].Pos + k).ToString("X4"), list[i].Descr, false);
                    }
                }
            }
            WriteFormat(sw, list[list.Count - 1].Name, delta, (list[list.Count - 1].Pos + 1).ToString("X4"), "", true);
            sw.WriteLine("};");
            sw.WriteLine("#endif");

            sw.Flush();
            sw.Close();
        }
Exemplo n.º 3
0
        void FillList()
        {
            uint val1, val2, size, type, flags;
            string cur = String.Empty, old = String.Empty;

            gr.BaseStream.Position = FIELDS_INFO_START;

            do
            {
                val1 = gr.ReadUInt32();
                if (val1 == 0)
                    val1 = gr.ReadUInt32();
                val2 = gr.ReadUInt32();
                size = gr.ReadUInt32();
                type = gr.ReadUInt32();
                flags = gr.ReadUInt32();

                long oldpos = gr.BaseStream.Position;
                gr.BaseStream.Position = val1 - FIELDS_NAMES_OFFSET;
                cur = gr.ReadStringNull();
                gr.BaseStream.Position = oldpos;

                string info = String.Format("Size: {0}, Type: {1}, Flags: {2}", size, (UpdateFieldType)type, (UpdatafieldFlags)flags);

                UpdateField uf = new UpdateField(cur, val2, size, info);
                list.Add(uf);

                if (!old.Equals("CORPSE_FIELD_PAD") && cur.Equals("CORPSE_FIELD_PAD"))
                    break;

                old = cur;
            } while (true);
        }