Esempio n. 1
0
        public static void LoadUpdateFields(uint build)
        {
            ClearUpdateFields();

            var file = String.Format(Application.StartupPath + "\\" + "updatefields\\{0}.dat", build);
            var type = FieldType.FIELD_TYPE_NONE;
            var sr = new StreamReader(file);
            while (sr.Peek() >= 0)
            {
                if (type == FieldType.FIELD_TYPE_END)
                {
                    OBJECT_END = Convert.ToUInt32(sr.ReadLine());
                    ITEM_END = Convert.ToUInt32(sr.ReadLine());
                    CONTAINER_END = Convert.ToUInt32(sr.ReadLine());
                    UNIT_END = Convert.ToUInt32(sr.ReadLine());
                    PLAYER_END = Convert.ToUInt32(sr.ReadLine());
                    GO_END = Convert.ToUInt32(sr.ReadLine());
                    DO_END = Convert.ToUInt32(sr.ReadLine());
                    CORPSE_END = Convert.ToUInt32(sr.ReadLine());
                    type = FieldType.FIELD_TYPE_NONE;
                    continue;
                }

                var curline = sr.ReadLine();

                if (curline.StartsWith("#") || curline.StartsWith("/")) // skip commentary lines
                    continue;

                if (curline.Length == 0)    // empty line
                    continue;

                if (curline.StartsWith(":"))    // label lines
                {
                    if (curline.Contains("ends"))
                        type = FieldType.FIELD_TYPE_END;
                    if (curline.Contains("item"))
                        type = FieldType.FIELD_TYPE_ITEM;
                    if (curline.Contains("unit+player"))
                        type = FieldType.FIELD_TYPE_UNIT;
                    else if (curline.Contains("gameobject"))
                        type = FieldType.FIELD_TYPE_GO;
                    else if (curline.Contains("dynamicobject"))
                        type = FieldType.FIELD_TYPE_DO;
                    else if (curline.Contains("corpse"))
                        type = FieldType.FIELD_TYPE_CORPSE;

                    continue;
                }

                var arr = curline.Split('	');

                if (arr.Length < 3)
                    continue;

                var id = Convert.ToInt32(arr[0]);
                var name = arr[1];
                var type1 = Convert.ToUInt32(arr[2]);
                //uint format = Convert.ToUInt32(arr[3]);
                const uint format = 0;

                var uf = new UpdateField(id, name, type1, format, 0);
                switch (type)
                {
                    case FieldType.FIELD_TYPE_END:
                        break;
                    case FieldType.FIELD_TYPE_ITEM:
                        item_uf.Add(id, uf);
                        break;
                    case FieldType.FIELD_TYPE_UNIT:
                        unit_uf.Add(id, uf);
                        break;
                    case FieldType.FIELD_TYPE_GO:
                        go_uf.Add(id, uf);
                        break;
                    case FieldType.FIELD_TYPE_DO:
                        do_uf.Add(id, uf);
                        break;
                    case FieldType.FIELD_TYPE_CORPSE:
                        corpse_uf.Add(id, uf);
                        break;
                }
            }

            CheckIntegrity();
        }
Esempio n. 2
0
        public static void LoadUpdateFields(uint build)
        {
            ClearUpdateFields();

            var file = String.Format(Application.StartupPath + "\\" + "updatefields\\{0}.dat", build);
            var type = FieldType.FIELD_TYPE_NONE;
            var sr   = new StreamReader(file);

            while (sr.Peek() >= 0)
            {
                if (type == FieldType.FIELD_TYPE_END)
                {
                    OBJECT_END    = Convert.ToUInt32(sr.ReadLine());
                    ITEM_END      = Convert.ToUInt32(sr.ReadLine());
                    CONTAINER_END = Convert.ToUInt32(sr.ReadLine());
                    UNIT_END      = Convert.ToUInt32(sr.ReadLine());
                    PLAYER_END    = Convert.ToUInt32(sr.ReadLine());
                    GO_END        = Convert.ToUInt32(sr.ReadLine());
                    DO_END        = Convert.ToUInt32(sr.ReadLine());
                    CORPSE_END    = Convert.ToUInt32(sr.ReadLine());
                    type          = FieldType.FIELD_TYPE_NONE;
                    continue;
                }

                var curline = sr.ReadLine();

                if (curline.StartsWith("#") || curline.StartsWith("/")) // skip commentary lines
                {
                    continue;
                }

                if (curline.Length == 0)    // empty line
                {
                    continue;
                }

                if (curline.StartsWith(":"))    // label lines
                {
                    if (curline.Contains("ends"))
                    {
                        type = FieldType.FIELD_TYPE_END;
                    }
                    if (curline.Contains("item"))
                    {
                        type = FieldType.FIELD_TYPE_ITEM;
                    }
                    if (curline.Contains("unit+player"))
                    {
                        type = FieldType.FIELD_TYPE_UNIT;
                    }
                    else if (curline.Contains("gameobject"))
                    {
                        type = FieldType.FIELD_TYPE_GO;
                    }
                    else if (curline.Contains("dynamicobject"))
                    {
                        type = FieldType.FIELD_TYPE_DO;
                    }
                    else if (curline.Contains("corpse"))
                    {
                        type = FieldType.FIELD_TYPE_CORPSE;
                    }

                    continue;
                }

                var arr = curline.Split('	');

                if (arr.Length < 3)
                {
                    continue;
                }

                var id    = Convert.ToInt32(arr[0]);
                var name  = arr[1];
                var type1 = Convert.ToUInt32(arr[2]);
                //uint format = Convert.ToUInt32(arr[3]);
                const uint format = 0;

                var uf = new UpdateField(id, name, type1, format, 0);
                switch (type)
                {
                case FieldType.FIELD_TYPE_END:
                    break;

                case FieldType.FIELD_TYPE_ITEM:
                    item_uf.Add(id, uf);
                    break;

                case FieldType.FIELD_TYPE_UNIT:
                    unit_uf.Add(id, uf);
                    break;

                case FieldType.FIELD_TYPE_GO:
                    go_uf.Add(id, uf);
                    break;

                case FieldType.FIELD_TYPE_DO:
                    do_uf.Add(id, uf);
                    break;

                case FieldType.FIELD_TYPE_CORPSE:
                    corpse_uf.Add(id, uf);
                    break;
                }
            }

            CheckIntegrity();
        }