Example #1
0
        public virtual void setQbFormat(QbItemType type)
        {
            if (_qbFormatSet)
                return;

            #region switch
            switch (type)
            {
                case QbItemType.SectionArray:
                case QbItemType.SectionFloatsX2:
                case QbItemType.SectionFloatsX3:
                case QbItemType.SectionString:
                case QbItemType.SectionStringW:
                case QbItemType.SectionStruct:
                case QbItemType.SectionScript:
                    //Complex section type:
                    //  ItemId, FileId, Pointer, Reserved
                    _qbFormat = QbFormat.SectionPointer;
                    break;

                case QbItemType.SectionInteger:
                case QbItemType.SectionFloat:
                case QbItemType.SectionQbKey:
                case QbItemType.SectionQbKeyString:
                case QbItemType.SectionStringPointer:
                case QbItemType.SectionQbKeyStringQs: //GH:GH
                    //Simple section type:
                    //  ItemId, FileId, Value, Reserved
                    _qbFormat = QbFormat.SectionValue;
                    break;

                case QbItemType.StructItemArray:
                case QbItemType.StructItemFloatsX2:
                case QbItemType.StructItemFloatsX3:
                case QbItemType.StructItemString:
                case QbItemType.StructItemStringW:
                case QbItemType.StructItemStruct:
                    //Complex struct type:
                    //  ItemId, Pointer, NextItemPointer
                    _qbFormat = QbFormat.StructItemPointer;
                    break;

                case QbItemType.StructItemQbKeyString:
                case QbItemType.StructItemStringPointer:
                case QbItemType.StructItemQbKeyStringQs:
                case QbItemType.StructItemQbKey:
                case QbItemType.StructItemInteger:
                case QbItemType.StructItemFloat:
                    //Simple struct type:
                    //  ItemId, Value (4 byte), NextItemPointer
                    _qbFormat = QbFormat.StructItemValue;
                    break;

                case QbItemType.ArrayArray:
                case QbItemType.ArrayString:
                case QbItemType.ArrayStringW:
                case QbItemType.ArrayStruct:
                case QbItemType.ArrayFloatsX2:
                case QbItemType.ArrayFloatsX3:
                    //Complex array type:
                    //  ItemCount, Pointer, Pointers -  (if length is 1 then pointer points to first item and Pointers are abscent)
                    _qbFormat = QbFormat.ArrayPointer;
                    break;

                case QbItemType.ArrayQbKey:
                case QbItemType.ArrayInteger:
                case QbItemType.ArrayFloat:
                case QbItemType.ArrayQbKeyString:
                case QbItemType.ArrayStringPointer: //GH:GH
                case QbItemType.ArrayQbKeyStringQs: //GH:GH
                    //Simple array type:
                    //  ItemCount, Pointer, Pointers -  (if length is 1 then pointer points to first item and Pointers are abscent)
                    _qbFormat = QbFormat.ArrayValue;
                    break;

                case QbItemType.StructHeader: //when struct array item
                    _qbFormat = QbFormat.StructHeader;
                    break;

                case QbItemType.Floats:
                    _qbFormat = QbFormat.Floats;
                    break;

                case QbItemType.Unknown:
                    _qbFormat = QbFormat.Unknown;
                    break;

                default:
                    break;
            }
            #endregion

            _qbFormatSet = true;
        }
Example #2
0
        private static QbItemBase createQbItemType(QbFile qbFile, QbItemType type, QbFormat qbFormat, bool hasQbFormat)
        {
            QbItemBase qib = null;

            if (qbFile.PakFormat.GetQbItemValue(type, qbFile) == 0xFFFFFFFF)
                throw new ApplicationException(string.Format("'{0}' data value not known for {1}", type.ToString(), qbFile.PakFormat.FriendlyName));

            switch (type)
            {
                //case QbItemType.Unknown:
                //    break;

                case QbItemType.SectionString:
                case QbItemType.SectionStringW:
                case QbItemType.ArrayString:
                case QbItemType.ArrayStringW:
                case QbItemType.StructItemString:
                case QbItemType.StructItemStringW:
                    qib = new QbItemString(qbFile);
                    break;
                case QbItemType.SectionArray:
                case QbItemType.ArrayArray:
                case QbItemType.StructItemArray:
                    qib = new QbItemArray(qbFile);
                    break;
                case QbItemType.SectionStruct:
                case QbItemType.StructItemStruct:
                case QbItemType.StructHeader:
                    qib = new QbItemStruct(qbFile);
                    break;
                case QbItemType.SectionScript:
                    qib = new QbItemScript(qbFile);
                    break;
                case QbItemType.SectionFloat:
                case QbItemType.ArrayFloat:
                case QbItemType.StructItemFloat:
                    qib = new QbItemFloat(qbFile);
                    break;
                case QbItemType.SectionFloatsX2:
                case QbItemType.SectionFloatsX3:
                case QbItemType.ArrayFloatsX2:
                case QbItemType.ArrayFloatsX3:
                case QbItemType.StructItemFloatsX2:
                case QbItemType.StructItemFloatsX3:
                    qib = new QbItemFloatsArray(qbFile);
                    break;
                case QbItemType.SectionInteger:
                case QbItemType.SectionStringPointer:
                case QbItemType.ArrayInteger:
                case QbItemType.ArrayStringPointer: //GH:GH
                case QbItemType.StructItemStringPointer:
                case QbItemType.StructItemInteger:
                    qib = new QbItemInteger(qbFile);
                    break;
                case QbItemType.SectionQbKey:
                case QbItemType.SectionQbKeyString:
                case QbItemType.SectionQbKeyStringQs: //GH:GH
                case QbItemType.ArrayQbKey:
                case QbItemType.ArrayQbKeyString:
                case QbItemType.ArrayQbKeyStringQs: //GH:GH
                case QbItemType.StructItemQbKey:
                case QbItemType.StructItemQbKeyString:
                case QbItemType.StructItemQbKeyStringQs:
                    qib = new QbItemQbKey(qbFile);
                    break;
                case QbItemType.Floats:
                    qib = new QbItemFloats(qbFile);
                    break;
                case QbItemType.ArrayStruct:
                    qib = new QbItemStructArray(qbFile);
                    break;

                default:
                    throw new ApplicationException(string.Format("'{0}' is not recognised by CreateQbItemType.", type.ToString()));
            }
            if (qib != null)
                qib.Create(type);

            return qib;
        }
Example #3
0
        private static QbItemBase createQbItemType(QbFile qbFile, QbItemType type, QbFormat qbFormat, bool hasQbFormat)
        {
            QbItemBase qib = null;

            if (qbFile.PakFormat.GetQbItemValue(type, qbFile) == 0xFFFFFFFF)
            {
                throw new ApplicationException(string.Format("'{0}' data value not known for {1}", type.ToString(), qbFile.PakFormat.FriendlyName));
            }

            switch (type)
            {
            //case QbItemType.Unknown:
            //    break;

            case QbItemType.SectionString:
            case QbItemType.SectionStringW:
            case QbItemType.ArrayString:
            case QbItemType.ArrayStringW:
            case QbItemType.StructItemString:
            case QbItemType.StructItemStringW:
                qib = new QbItemString(qbFile);
                break;

            case QbItemType.SectionArray:
            case QbItemType.ArrayArray:
            case QbItemType.StructItemArray:
                qib = new QbItemArray(qbFile);
                break;

            case QbItemType.SectionStruct:
            case QbItemType.StructItemStruct:
            case QbItemType.StructHeader:
                qib = new QbItemStruct(qbFile);
                break;

            case QbItemType.SectionScript:
                qib = new QbItemScript(qbFile);
                break;

            case QbItemType.SectionFloat:
            case QbItemType.ArrayFloat:
            case QbItemType.StructItemFloat:
                qib = new QbItemFloat(qbFile);
                break;

            case QbItemType.SectionFloatsX2:
            case QbItemType.SectionFloatsX3:
            case QbItemType.ArrayFloatsX2:
            case QbItemType.ArrayFloatsX3:
            case QbItemType.StructItemFloatsX2:
            case QbItemType.StructItemFloatsX3:
                qib = new QbItemFloatsArray(qbFile);
                break;

            case QbItemType.SectionInteger:
            case QbItemType.SectionStringPointer:
            case QbItemType.ArrayInteger:
            case QbItemType.ArrayStringPointer:     //GH:GH
            case QbItemType.StructItemStringPointer:
            case QbItemType.StructItemInteger:
                qib = new QbItemInteger(qbFile);
                break;

            case QbItemType.SectionQbKey:
            case QbItemType.SectionQbKeyString:
            case QbItemType.SectionQbKeyStringQs:     //GH:GH
            case QbItemType.ArrayQbKey:
            case QbItemType.ArrayQbKeyString:
            case QbItemType.ArrayQbKeyStringQs:     //GH:GH
            case QbItemType.StructItemQbKey:
            case QbItemType.StructItemQbKeyString:
            case QbItemType.StructItemQbKeyStringQs:
                qib = new QbItemQbKey(qbFile);
                break;

            case QbItemType.Floats:
                qib = new QbItemFloats(qbFile);
                break;

            case QbItemType.ArrayStruct:
                qib = new QbItemStructArray(qbFile);
                break;

            default:
                throw new ApplicationException(string.Format("'{0}' is not recognised by CreateQbItemType.", type.ToString()));
            }
            if (qib != null)
            {
                qib.Create(type);
            }

            return(qib);
        }
Example #4
0
 public static QbItemBase CreateQbItemType(QbFile qbFile, QbItemType type, QbFormat qbFormat)
 {
     return createQbItemType(qbFile, type, qbFormat, true);
 }
Example #5
0
 public static QbItemBase CreateQbItemType(QbFile qbFile, QbItemType type, QbFormat qbFormat)
 {
     return(createQbItemType(qbFile, type, qbFormat, true));
 }