예제 #1
0
        private void WriteList(TdfBaseType type, ArrayList list)
        {
            foreach (Object obj in list)
            {
                switch (type)
                {
                case TdfBaseType.Integer:
                    WriteInteger((ulong)obj);
                    break;

                case TdfBaseType.String:
                    WriteString((string)obj);
                    break;

                case TdfBaseType.Struct:
                    WriteStruct((List <Tdf>)obj);
                    break;

                case TdfBaseType.TDF_TYPE_BLAZE_OBJECT_ID:
                    WriteTdfVector3((TdfVector3)obj);
                    break;

                default:
                    Log.Warn(string.Format("Unknown list type: {0}.", type));
                    break;
                }
            }
        }
예제 #2
0
        public TdfMap(string label, TdfBaseType keyType, TdfBaseType valueType, Dictionary<object, object> map)
        {
            this.Label = label;
            this.Type = TdfBaseType.Map;

            this.KeyType = keyType;
            this.ValueType = valueType;

            this.Map = map;
        }
예제 #3
0
        public TdfList(string label, TdfBaseType listType, ArrayList list, bool stub = false)
        {
            this.Label = label;
            this.Type  = TdfBaseType.List;

            this.ListType = listType;
            this.List     = list;

            this.Stub = stub;
        }
예제 #4
0
        public TdfMap(string label, TdfBaseType keyType, TdfBaseType valueType, Dictionary <object, object> map)
        {
            this.Label = label;
            this.Type  = TdfBaseType.Map;

            this.KeyType   = keyType;
            this.ValueType = valueType;

            this.Map = map;
        }
예제 #5
0
        public TdfList(string label, TdfBaseType listType, ArrayList list, bool stub = false)
        {
            this.Label = label;
            this.Type = TdfBaseType.List;

            this.ListType = listType;
            this.List = list;

            this.Stub = stub;
        }
예제 #6
0
        public TdfMap(string label, TdfBaseType type1, TdfBaseType type2, Dictionary <object, object> map)
        {
            this.label = label;
            this.type  = TdfBaseType.TDF_TYPE_MAP;

            this.type1 = type1;
            this.type2 = type2;

            this.map = map;
        }
예제 #7
0
        public TdfList(string label, TdfBaseType listType, ArrayList list, bool stub = false)
        {
            this.label = label;
            this.type  = TdfBaseType.TDF_TYPE_LIST;

            this.listType = listType;
            this.list     = list;

            this.stub = stub;
        }
예제 #8
0
        private Tdf ReadTdf()
        {
            Tdf tdf = null;

            string      label = ReadLabel();
            TdfBaseType type  = (TdfBaseType)_stream.ReadByte();

            switch (type)
            {
            case TdfBaseType.TDF_TYPE_INTEGER:
                tdf = DecodeTdfInteger(label);
                break;

            case TdfBaseType.TDF_TYPE_STRING:
                tdf = DecodeTdfString(label);
                break;

            case TdfBaseType.TDF_TYPE_BINARY:
                tdf = DecodeTdfBlob(label);
                break;

            case TdfBaseType.TDF_TYPE_STRUCT:
                tdf = DecodeTdfStruct(label);
                break;

            case TdfBaseType.TDF_TYPE_LIST:
                tdf = DecodeTdfList(label);
                break;

            case TdfBaseType.TDF_TYPE_MAP:
                tdf = DecodeTdfMap(label);
                break;

            case TdfBaseType.TDF_TYPE_UNION:
                tdf = DecodeTdfUnion(label);
                break;

            case TdfBaseType.TDF_TYPE_BLAZE_OBJECT_TYPE:
                tdf = DecodeTdfVector2(label);
                break;

            case TdfBaseType.TDF_TYPE_BLAZE_OBJECT_ID:
                tdf = DecodeTdfVector3(label);
                break;

            default:
                Log.Warn(string.Format("Unknown Tdf type: {0}.", type));
                break;
            }

            return(tdf);
        }
예제 #9
0
        private TdfMap DecodeTdfMap(string label)
        {
            // read list types
            TdfBaseType listType1 = (TdfBaseType)_stream.ReadByte();
            TdfBaseType listType2 = (TdfBaseType)_stream.ReadByte();

            // read list size
            int listSize = _stream.ReadByte();

            TdfMap map = new TdfMap(label, listType1, listType2, new Dictionary <object, object>());

            // read list
            Func <TdfBaseType, Object> readListItem = (type) =>
            {
                Object item = null;

                switch (type)
                {
                case TdfBaseType.TDF_TYPE_INTEGER:
                    item = DecodeInteger();
                    break;

                case TdfBaseType.TDF_TYPE_STRING:
                    item = DecodeString();
                    break;

                case TdfBaseType.TDF_TYPE_STRUCT:
                    item = DecodeStruct();
                    break;

                default:
                    Log.Warn(string.Format("Unknown list item type: {0}.", type));
                    break;
                }

                return(item);
            };

            for (int i = 0; i < listSize; i++)
            {
                Object key   = readListItem(listType1);
                Object value = readListItem(listType2);

                if (key != null | value != null)
                {
                    map.map.Add(key, value);
                }
            }

            return(map);
        }
예제 #10
0
        private ArrayList DecodeList(TdfBaseType listType, int listSize)
        {
            ArrayList list = new ArrayList();

            // weird Tdf check #1: HNET, for instance.
            if (_data[_stream.Position] == 0x02 && listType == TdfBaseType.TDF_TYPE_STRUCT)
            {
                _stream.Seek(1, SeekOrigin.Current);

                // also hack, should be 'read until 0x00' or something
                list.Add(ReadTdf());
                list.Add(ReadTdf());

                _stream.ReadByte();
            }
            else
            {
                for (int i = 0; i < listSize; i++)
                {
                    switch (listType)
                    {
                    case TdfBaseType.TDF_TYPE_INTEGER:
                        list.Add(DecodeInteger());
                        break;

                    case TdfBaseType.TDF_TYPE_STRING:
                        list.Add(DecodeString());
                        break;

                    case TdfBaseType.TDF_TYPE_STRUCT:
                        list.Add(DecodeStruct());
                        break;

                    default:
                        break;
                    }
                }
            }

            return(list);
        }
예제 #11
0
        public TdfMap(string label, TdfBaseType type1, TdfBaseType type2, Dictionary<object, object> map)
        {
            this.label = label;
            this.type = TdfBaseType.TDF_TYPE_MAP;

            this.type1 = type1;
            this.type2 = type2;

            this.map = map;
        }
예제 #12
0
        public TdfList(string label, TdfBaseType listType, ArrayList list, bool stub = false)
        {
            this.label = label;
            this.type = TdfBaseType.TDF_TYPE_LIST;

            this.listType = listType;
            this.list = list;

            this.stub = stub;
        }
예제 #13
0
        private void WriteList(TdfBaseType type, ArrayList list)
        {
            foreach (Object obj in list)
            {
                switch (type)
                {
                    case TdfBaseType.Integer:
                        WriteInteger((ulong)obj);
                        break;

                    case TdfBaseType.String:
                        WriteString((string)obj);
                        break;

                    case TdfBaseType.Struct:
                        WriteStruct((List<Tdf>)obj);
                        break;

                    case TdfBaseType.TDF_TYPE_BLAZE_OBJECT_ID:
                        WriteTdfVector3((TdfVector3)obj);
                        break;

                    default:
                        Log.Warn(string.Format("Unknown list type: {0}.", type));
                        break;
                }
            }
        }
예제 #14
0
        private ArrayList DecodeList(TdfBaseType listType, int listSize)
        {
            var list = new ArrayList();

            // weird Tdf check #1: HNET, for example.
            if (_data[_stream.Position] == 0x02 && listType == TdfBaseType.Struct)
            {
                _stream.Seek(1, SeekOrigin.Current);

                // also hack, should be 'read until 0x00' or something
                list.Add(ReadTdf());
                list.Add(ReadTdf());

                _stream.ReadByte();
            }
            else
            {
                for (int i = 0; i < listSize; i++)
                {
                    switch (listType)
                    {
                        case TdfBaseType.Integer:
                            list.Add(DecodeInteger());
                            break;

                        case TdfBaseType.String:
                            list.Add(DecodeString());
                            break;

                        case TdfBaseType.Struct:
                            list.Add(DecodeStruct());
                            break;

                        default:
                            break;
                    }
                }
            }

            return list;
        }