#include "assets.h"
#include "Windows.h"

#include <QIODevice>

Assets::Assets(QObject *parent)
    : QObject(parent)  {

}

Assets::~Assets() {

}



QVector<Glyph> Assets::Load_GlyphArray(QDataStream *aStream, int count)
{
    QVector<Glyph> result;
    for (int i = 0; i < count; i++) {
        Glyph glyph;

        *aStream
                >> glyph.letter
                >> glyph.x0
                >> glyph.y0
                >> glyph.dx
                >> glyph.pixelWidth
                >> glyph.pixelHeight
                >> glyph.s0
                >> glyph.t0
                >> glyph.s1
                >> glyph.t1;

        result << glyph;
    }
    return result;
}


// ?Load_GfxLightRegionAxisArray@@YAX_NH@Z at 0x822a49a0
QVector<GfxLightRegionAxis> Assets::Load_GfxLightRegionAxisArray(QDataStream *aStream, int count)
{
    QVector<GfxLightRegionAxis> result;
    for (int i = 0; i < count; i++) {
        GfxLightRegionAxis gfxLightRegionAxis;

        *aStream
                >> gfxLightRegionAxis.dir[0]
                >> gfxLightRegionAxis.dir[1]
                >> gfxLightRegionAxis.dir[2]
                >> gfxLightRegionAxis.midPoint
                >> gfxLightRegionAxis.halfSize;

        result << gfxLightRegionAxis;
    }
    return result;
}


// ?Load_GfxDrawSurfArray@@YAX_NH@Z at 0x822a49c0
QVector<GfxDrawSurf> Assets::Load_GfxDrawSurfArray(QDataStream *aStream, int count)
{
    QVector<GfxDrawSurf> result;
    for (int i = 0; i < count; i++) {
        GfxDrawSurf gfxDrawSurf;

        *aStream
                >> gfxDrawSurf.packed;

        result << gfxDrawSurf;
    }
    return result;
}


// ?Load_GfxSceneDynBrushArray@@YAX_NH@Z at 0x822a49d8
QVector<GfxSceneDynBrush> Assets::Load_GfxSceneDynBrushArray(QDataStream *aStream, int count)
{
    QVector<GfxSceneDynBrush> result;
    for (int i = 0; i < count; i++) {
        GfxSceneDynBrush gfxSceneDynBrush;

        *aStream
                >> gfxSceneDynBrush.info.surfId
                >> gfxSceneDynBrush.dynEntId;

        result << gfxSceneDynBrush;
    }
    return result;
}


// ?Load_GfxSceneDynModelArray@@YAX_NH@Z at 0x822a49f0
QVector<GfxSceneDynModel> Assets::Load_GfxSceneDynModelArray(QDataStream *aStream, int count)
{
    QVector<GfxSceneDynModel> result;
    for (int i = 0; i < count; i++) {
        GfxSceneDynModel gfxSceneDynModel;

        *aStream
                >> gfxSceneDynModel.info.lod
                >> gfxSceneDynModel.info.surfId
                >> gfxSceneDynModel.dynEntId;

        result << gfxSceneDynModel;
    }
    return result;
}


// ?Load_GfxStreamingAabbTreeArray@@YAX_NH@Z at 0x822a4a10
QVector<GfxStreamingAabbTree> Assets::Load_GfxStreamingAabbTreeArray(QDataStream *aStream, int count)
{
    QVector<GfxStreamingAabbTree> result;
    for (int i = 0; i < count; i++) {
        GfxStreamingAabbTree gfxStreamingAabbTree;

        *aStream
                >> gfxStreamingAabbTree.firstItem
                >> gfxStreamingAabbTree.itemCount
                >> gfxStreamingAabbTree.firstChild
                >> gfxStreamingAabbTree.childCount
                >> gfxStreamingAabbTree.mins[0]
                >> gfxStreamingAabbTree.mins[1]
                >> gfxStreamingAabbTree.mins[2]
                >> gfxStreamingAabbTree.maxs[0]
                >> gfxStreamingAabbTree.maxs[1]
                >> gfxStreamingAabbTree.maxs[2];

        result << gfxStreamingAabbTree;
    }
    return result;
}

GfxLightGridColors Assets::Load_GfxLightGridColors(QDataStream *aStream)
{
    GfxLightGridColors result;

    for (int j = 0; j < 56; j++) {
        *aStream
                >> result.rgb[j][0]
                >> result.rgb[j][1]
                >> result.rgb[j][2];
    }
    return result;
}

// ?Load_GfxLightGridColorsArray@@YAX_NH@Z at 0x822a4a28
QVector<GfxLightGridColors> Assets::Load_GfxLightGridColorsArray(QDataStream *aStream, int count)
{
    QVector<GfxLightGridColors> result;
    for (int i = 0; i < count; i++) {
        result << Load_GfxLightGridColors(aStream);
    }
    return result;
}


// ?Load_GfxLightGridEntryArray@@YAX_NH@Z at 0x822a4a40
QVector<GfxLightGridEntry> Assets::Load_GfxLightGridEntryArray(QDataStream *aStream, int count)
{
    QVector<GfxLightGridEntry> result;
    for (int i = 0; i < count; i++) {
        GfxLightGridEntry gfxLightGridEntry;

        for (int j = 0; j < 56; j++) {
            *aStream
                    >> gfxLightGridEntry.colorsIndex
                    >> gfxLightGridEntry.primaryLightIndex
                    >> gfxLightGridEntry.needsTrace;
        }

        result << gfxLightGridEntry;
    }
    return result;
}


// ?Load_GfxCullGroupArray@@YAX_NH@Z at 0x822a4a58
QVector<GfxCullGroup> Assets::Load_GfxCullGroupArray(QDataStream *aStream, int count)
{
    QVector<GfxCullGroup> result;
    for (int i = 0; i < count; i++) {
        GfxCullGroup gfxCullGroup;

        for (int j = 0; j < 56; j++) {
            *aStream
                    >> gfxCullGroup.mins[0]
                    >> gfxCullGroup.mins[1]
                    >> gfxCullGroup.mins[2]
                    >> gfxCullGroup.maxs[0]
                    >> gfxCullGroup.maxs[1]
                    >> gfxCullGroup.maxs[2]
                    >> gfxCullGroup.surfaceCount
                    >> gfxCullGroup.startSurfIndex;
        }

        result << gfxCullGroup;
    }
    return result;
}

typedef unsigned __int16 StaticModelIndex;

// ?Load_StaticModelIndexArray@@YAX_NH@Z at 0x822a4a70
QVector<StaticModelIndex> Assets::Load_StaticModelIndexArray(QDataStream *aStream, int count)
{
    QVector<StaticModelIndex> result;
    for (int i = 0; i < count; i++) {
        StaticModelIndex staticModelIndex;

        *aStream >> staticModelIndex;

        result << staticModelIndex;
    }
    return result;
}


// ?Load_GfxStaticModelInstArray@@YAX_NH@Z at 0x822a4a88
QVector<GfxStaticModelInst> Assets::Load_GfxStaticModelInstArray(QDataStream *aStream, int count)
{
    QVector<GfxStaticModelInst> result;
    for (int i = 0; i < count; i++) {
        GfxStaticModelInst gfxStaticModelInst;

        *aStream
                >> gfxStaticModelInst.mins[0]
                >> gfxStaticModelInst.mins[1]
                >> gfxStaticModelInst.mins[2]
                >> gfxStaticModelInst.maxs[0]
                >> gfxStaticModelInst.maxs[1]
                >> gfxStaticModelInst.maxs[2]
                >> gfxStaticModelInst.groundLighting.array[0]
                >> gfxStaticModelInst.groundLighting.array[1]
                >> gfxStaticModelInst.groundLighting.array[2]
                >> gfxStaticModelInst.groundLighting.array[3];

        result << gfxStaticModelInst;
    }
    return result;
}

// ?Load_ItemKeyHandler@@YAX_N@Z at 0x822a5f68
XItemKeyHandler Assets::Load_ItemKeyHandler(QDataStream *aStream)
{
    XItemKeyHandler result;

    *aStream
            >> result.key
            >> result.actionPtr
            >> result.nextPtr;

    if (result.actionPtr == -1) {
        result.action = Load_XStringCustom(aStream);
    }

    while (result.nextPtr == -1) {
        *aStream
                >> result.next->key
                >> result.next->actionPtr
                >> result.next->nextPtr;
    }
    return result;
}

typedef XItemKeyHandler ItemKeyHandlerNext;

// ?Load_ItemKeyHandlerNext@@YAX_N@Z at 0x822a4aa0
XItemKeyHandler Assets::Load_ItemKeyHandlerNext(QDataStream *aStream)
{
    return Load_ItemKeyHandler(aStream);
}

// ?Load_EditFieldDef@@YAX_N@Z at 0x822a4af0
XEditFieldDef Assets::Load_EditFieldDef(QDataStream *aStream)
{
    XEditFieldDef result;

    *aStream
            >> result.minVal
            >> result.maxVal
            >> result.defVal
            >> result.range
            >> result.maxChars
            >> result.maxCharsGotoNext
            >> result.maxPaintChars
            >> result.paintOffset;

    return result;
}

// ?Load_Operator@@YAX_N@Z at 0x822a4b08
OperationEnum Assets::Load_Operator(QDataStream *aStream)
{
    OperationEnum result;

    *aStream >> result;

    return result;
}

// ?Load_LeafBrushArray@@YAX_NH@Z at 0x822a4b20
QVector<quint16> Assets::Load_LeafBrushArray(QDataStream *aStream, int count)
{
    QVector<quint16> result;

    for (int i = 0; i < count; i++) {
        quint16 leafBrush;

        *aStream >> leafBrush;

        result << leafBrush;
    }
    return result;
}


CLeaf Assets::Load_CLeaf(QDataStream *aStream)
{
    CLeaf result;

    *aStream
            >> result.firstCollAabbIndex
            >> result.collAabbCount
            >> result.brushContents
            >> result.terrainContents
            >> result.mins[0]
            >> result.mins[1]
            >> result.mins[2]
            >> result.maxs[0]
            >> result.maxs[1]
            >> result.maxs[2]
            >> result.leafBrushNode
            >> result.cluster;


    return result;
}

// ?Load_CModelArray@@YAX_NH@Z at 0x822a4b38
QVector<CModel> Assets::Load_CModelArray(QDataStream *aStream, int count)
{
    QVector<CModel> result;

    for (int i = 0; i < count; i++) {
        CModel cmodel;

        *aStream
                >> cmodel.mins[0]
                >> cmodel.mins[1]
                >> cmodel.mins[2]
                >> cmodel.maxs[0]
                >> cmodel.maxs[1]
                >> cmodel.maxs[2]
                >> cmodel.radius;

        cmodel.leaf = Load_CLeaf(aStream);

        result << cmodel;
    }

    return result;
}


// ?Load_CollisionAabbTreeArray@@YAX_NH@Z at 0x822a4b58
QVector<CollisionAabbTree> Assets::Load_CollisionAabbTreeArray(QDataStream *aStream, int count)
{
    QVector<CollisionAabbTree> result;

    for (int i = 0; i < count; i++) {
        CollisionAabbTree collisionAabbTree;

        *aStream
                >> collisionAabbTree.origin[0]
                >> collisionAabbTree.origin[1]
                >> collisionAabbTree.origin[2]
                >> collisionAabbTree.halfSize[0]
                >> collisionAabbTree.halfSize[1]
                >> collisionAabbTree.halfSize[2]
                >> collisionAabbTree.materialIndex
                >> collisionAabbTree.childCount
                >> collisionAabbTree.u.firstChildIndex
                >> collisionAabbTree.u.partitionIndex;

        result << collisionAabbTree;
    }

    return result;
}

// ?Load_CollisionBorder@@YAX_N@Z at 0x822a4b88
CollisionBorder Assets::Load_CollisionBorder(QDataStream *aStream)
{
    CollisionBorder result;

    *aStream
            >> result.distEq[0]
            >> result.distEq[1]
            >> result.distEq[2]
            >> result.zBase
            >> result.zSlope
            >> result.start
            >> result.length;

    return result;
}

// ?Load_CollisionBorderArray@@YAX_NH@Z at 0x822a4b70
QVector<CollisionBorder> Assets::Load_CollisionBorderArray(QDataStream *aStream, int count)
{
    QVector<CollisionBorder> result;

    for (int i = 0; i < count; i++) {
        result << Load_CollisionBorder(aStream);
    }

    return result;
}

// ?Load_cLeafBrushNodeChildren_t@@YAX_N@Z at 0x822a4ba0
CLeafBrushNodeChildren Assets::Load_cLeafBrushNodeChildren_t(QDataStream *aStream)
{
    CLeafBrushNodeChildren result;

    *aStream
            >> result.dist
            >> result.range
            >> result.childOffset[0]
            >> result.childOffset[1];

    return result;
}


// ?Load_cLeaf_tArray@@YAX_NH@Z at 0x822a4c30
QVector<CLeaf> Assets::Load_cLeaf_tArray(QDataStream *aStream, int count)
{
    QVector<CLeaf> result;

    for (int i = 0; i < count; i++) {
        result << Load_CLeaf(aStream);
    }

    return result;
}


// ?Load_DynEntityClientArray@@YAX_NH@Z at 0x822a4c48
QVector<DynEntityClient> Assets::Load_DynEntityClientArray(QDataStream *aStream, int count)
{
    QVector<DynEntityClient> result;

    for (int i = 0; i < count; i++) {
        DynEntityClient dynEntityClient;

        *aStream
                >> dynEntityClient.physObjId
                >> dynEntityClient.flags
                >> dynEntityClient.lightingHandle
                >> dynEntityClient.health;

        result << dynEntityClient;
    }

    return result;
}


// ?Load_DynEntityPoseArray@@YAX_NH@Z at 0x822a4c68
QVector<DynEntityPose> Assets::Load_DynEntityPoseArray(QDataStream *aStream, int count)
{
    QVector<DynEntityPose> result;

    for (int i = 0; i < count; i++) {
        DynEntityPose dynEntityPose;

        *aStream
                >> dynEntityPose.pose.quat[0]
                >> dynEntityPose.pose.quat[1]
                >> dynEntityPose.pose.quat[2]
                >> dynEntityPose.pose.quat[3]
                >> dynEntityPose.pose.origin[0]
                >> dynEntityPose.pose.origin[1]
                >> dynEntityPose.pose.origin[2]
                >> dynEntityPose.radius;

        result << dynEntityPose;
    }

    return result;
}


// ?Load_DynEntityCollArray@@YAX_NH@Z at 0x822a4c80
QVector<DynEntityColl> Assets::Load_DynEntityCollArray(QDataStream *aStream, int count)
{
    QVector<DynEntityColl> result;

    for (int i = 0; i < count; i++) {
        DynEntityColl dynEntityColl;

        *aStream
                >> dynEntityColl.sector
                >> dynEntityColl.nextEntInSector
                >> dynEntityColl.linkMins[0]
                >> dynEntityColl.linkMins[1]
                >> dynEntityColl.linkMaxs[0]
                >> dynEntityColl.linkMaxs[1];

        result << dynEntityColl;
    }

    return result;
}


// ?Load_FxTrailVertexArray@@YAX_NH@Z at 0x822a4ca0
QVector<FxTrailVertex> Assets::Load_FxTrailVertexArray(QDataStream *aStream, int count)
{
    QVector<FxTrailVertex> result;

    for (int i = 0; i < count; i++) {
        FxTrailVertex fxTrailVertex;

        *aStream
                >> fxTrailVertex.pos[0]
                >> fxTrailVertex.pos[1]
                >> fxTrailVertex.normal[0]
                >> fxTrailVertex.normal[1]
                >> fxTrailVertex.texCoord;

        result << fxTrailVertex;
    }

    return result;
}


// ?Load_FxElemVelStateSampleArray@@YAX_NH@Z at 0x822a4cc0
QVector<FxElemVelStateSample> Assets::Load_FxElemVelStateSampleArray(QDataStream *aStream, int count)
{
    QVector<FxElemVelStateSample> result;

    for (int i = 0; i < count; i++) {
        FxElemVelStateSample fxElemVelStateSample;

        *aStream
                >> fxElemVelStateSample.local.velocity.base[0]
                >> fxElemVelStateSample.local.velocity.base[1]
                >> fxElemVelStateSample.local.velocity.base[2]
                >> fxElemVelStateSample.local.velocity.amplitude[0]
                >> fxElemVelStateSample.local.velocity.amplitude[1]
                >> fxElemVelStateSample.local.velocity.amplitude[2]
                >> fxElemVelStateSample.local.totalDelta.base[0]
                >> fxElemVelStateSample.local.totalDelta.base[1]
                >> fxElemVelStateSample.local.totalDelta.base[2]
                >> fxElemVelStateSample.local.totalDelta.amplitude[0]
                >> fxElemVelStateSample.local.totalDelta.amplitude[1]
                >> fxElemVelStateSample.local.totalDelta.amplitude[2]
                >> fxElemVelStateSample.world.velocity.base[0]
                >> fxElemVelStateSample.world.velocity.base[1]
                >> fxElemVelStateSample.world.velocity.base[2]
                >> fxElemVelStateSample.world.velocity.amplitude[0]
                >> fxElemVelStateSample.world.velocity.amplitude[1]
                >> fxElemVelStateSample.world.velocity.amplitude[2]
                >> fxElemVelStateSample.world.totalDelta.base[0]
                >> fxElemVelStateSample.world.totalDelta.base[1]
                >> fxElemVelStateSample.world.totalDelta.base[2]
                >> fxElemVelStateSample.world.totalDelta.amplitude[0]
                >> fxElemVelStateSample.world.totalDelta.amplitude[1]
                >> fxElemVelStateSample.world.totalDelta.amplitude[2];

        result << fxElemVelStateSample;
    }

    return result;
}

// ?Load_FxElemVisStateSampleArray@@YAX_NH@Z at 0x822a4ce0
QVector<FxElemVisStateSample> Assets::Load_FxElemVisStateSampleArray(QDataStream *aStream, int count)
{
    QVector<FxElemVisStateSample> result;

    for (int i = 0; i < count; i++) {
        FxElemVisStateSample fxElemVisStateSample;

        *aStream
                >> fxElemVisStateSample.base.color[0]
                >> fxElemVisStateSample.base.color[1]
                >> fxElemVisStateSample.base.color[2]
                >> fxElemVisStateSample.base.color[3]
                >> fxElemVisStateSample.base.rotationDelta
                >> fxElemVisStateSample.base.rotationTotal
                >> fxElemVisStateSample.base.size[0]
                >> fxElemVisStateSample.base.size[1]
                >> fxElemVisStateSample.base.scale;

        result << fxElemVisStateSample;
    }

    return result;
}


// ?Load_pathbasenode_tArray@@YAX_NH@Z at 0x822a4d60
QVector<PathBaseNode> Assets::Load_pathbasenode_tArray(QDataStream *aStream, int count)
{
    QVector<PathBaseNode> result;

    for (int i = 0; i < count; i++) {
        PathBaseNode pathbasenode;

        *aStream
                >> pathbasenode.vOrigin[0]
                >> pathbasenode.vOrigin[1]
                >> pathbasenode.vOrigin[2]
                >> pathbasenode.type;

        result << pathbasenode;
    }

    return result;
}

typedef PathLink pathlink_t;

// ?Load_pathlink_tArray@@YAX_NH@Z at 0x822a4d78
QVector<pathlink_t> Assets::Load_pathlink_tArray(QDataStream *aStream, int count)
{
    QVector<pathlink_t> result;

    for (int i = 0; i < count; i++) {
        pathlink_t pathlink;

        *aStream
                >> pathlink.fDist
                >> pathlink.nodeNum
                >> pathlink.disconnectCount
                >> pathlink.negotiationLink
                >> pathlink.ubBadPlaceCount[0]
                >> pathlink.ubBadPlaceCount[1]
                >> pathlink.ubBadPlaceCount[2]
                >> pathlink.ubBadPlaceCount[3];

        result << pathlink;
    }

    return result;
}


// ?Load_XModelHighMipBoundsArray@@YAX_NH@Z at 0x822a4d98
QVector<XModelHighMipBounds> Assets::Load_XModelHighMipBoundsArray(QDataStream *aStream, int count)
{
    QVector<XModelHighMipBounds> result;

    for (int i = 0; i < count; i++) {
        XModelHighMipBounds xModelHighMipBounds;

        *aStream
                >> xModelHighMipBounds.mins[0]
                >> xModelHighMipBounds.mins[1]
                >> xModelHighMipBounds.mins[2]
                >> xModelHighMipBounds.maxs[0]
                >> xModelHighMipBounds.maxs[1]
                >> xModelHighMipBounds.maxs[2];

        result << xModelHighMipBounds;
    }

    return result;
}

typedef XModelCollSurf XModelCollSurf;

// ?Load_XModelCollSurf@@YAX_N@Z at 0x822a4db8
XModelCollSurf Assets::Load_XModelCollSurf(QDataStream *aStream)
{
    XModelCollSurf result;

    *aStream
            >> result.mins[0]
            >> result.mins[1]
            >> result.maxs[2]
            >> result.maxs[0]
            >> result.maxs[1]
            >> result.maxs[2]
            >> result.boneIdx
            >> result.contents
            >> result.surfFlags;

    return result;
}

typedef unsigned __int8 cbrushedge_t;

// ?Load_cbrushedge_t@@YAX_N@Z at 0x822a4de8
cbrushedge_t Assets::Load_cbrushedge_t(QDataStream *aStream)
{
    cbrushedge_t result;

    *aStream >> result;

    return result;
}

// ?Load_cbrushedge_tArray@@YAX_NH@Z at 0x822a4dd0
QVector<cbrushedge_t> Assets::Load_cbrushedge_tArray(QDataStream *aStream, size_t count)
{
    QVector<cbrushedge_t> result;

    for (int i = 0; i < count; i++) {
        result << Load_cbrushedge_t(aStream);
    }

    return result;
}

typedef CPlane cplane_t;

// ?Load_cplane_t@@YAX_N@Z at 0x822a4e20
cplane_t Assets::Load_cplane_t(QDataStream *aStream)
{
    cplane_t result;

    *aStream
            >> result.normal[0]
            >> result.normal[1]
            >> result.normal[2]
            >> result.dist
            >> result.type
            >> result.signbits
            >> result.pad[0]
            >> result.pad[1];

    return result;
}

// ?Load_cplane_t@@YAX_N@Z at 0x822a4e20
CPlane Assets::Load_CPlane(QDataStream *aStream)
{
    CPlane result;

    *aStream
            >> result.normal[0]
            >> result.normal[1]
            >> result.normal[2]
            >> result.dist
            >> result.type
            >> result.signbits
            >> result.pad[0]
            >> result.pad[1];

    return result;
}


// ?Load_cplane_tArray@@YAX_NH@Z at 0x822a4e00
QVector<cplane_t> Assets::Load_cplane_tArray(QDataStream *aStream, int count)
{
    QVector<cplane_t> result;

    for (int i = 0; i < count; i++) {
        result << Load_cplane_t(aStream);
    }

    return result;
}


// ?Load_MaterialConstantDefArray@@YAX_NH@Z at 0x822a4e38
QVector<MaterialConstantDef> Assets::Load_MaterialConstantDefArray(QDataStream *aStream, int count)
{
    QVector<MaterialConstantDef> result;

    for (int i = 0; i < count; i++) {
        MaterialConstantDef materialConstantDef;

        *aStream >> materialConstantDef.nameHash;

        for (int j = 0; j < 12; j++) {
            *aStream >> materialConstantDef.name[j];
        }

        for (int j = 0; j < 4; j++) {
            *aStream >> materialConstantDef.literal[j];
        }

        *aStream
                >> materialConstantDef.literal[0]
                >> materialConstantDef.literal[1]
                >> materialConstantDef.literal[2]
                >> materialConstantDef.literal[3];

        result << materialConstantDef;
    }

    return result;
}


// ?Load_GfxStateBitsArray@@YAX_NH@Z at 0x822a4e50
QVector<GfxStateBits> Assets::Load_GfxStateBitsArray(QDataStream *aStream, int count)
{
    QVector<GfxStateBits> result;

    for (int i = 0; i < count; i++) {
        GfxStateBits gfxStateBits;

        *aStream
                >> gfxStateBits.loadBits[0]
                >> gfxStateBits.loadBits[1];

        result << gfxStateBits;
    }

    return result;
}


// ?Load_MaterialArgumentCodeConst@@YAX_N@Z at 0x822a4e68
MaterialArgumentCodeConst Assets::Load_MaterialArgumentCodeConst(QDataStream *aStream)
{
    MaterialArgumentCodeConst result;

    *aStream
            >> result.index
            >> result.firstRow
            >> result.rowCount;

    return result;
}


// ?Load_MaterialVertexDeclaration@@YAX_N@Z at 0x822a4e80
MaterialVertexDeclaration Assets::Load_MaterialVertexDeclaration(QDataStream *aStream)
{
    MaterialVertexDeclaration result;

    *aStream
            >> result.streamCount
            >> result.hasOptionalSource;

    for (int i = 0; i < 16; i++) {

        *aStream >> result.routing.data[i].source;
        *aStream >> result.routing.data[i].dest;
    }

    for (int i = 0; i < 15; i++) {
        quint32 declPtr;
        *aStream >> declPtr;
        &result.routing.decl[i] = declPtr;
    }

    return result;
}

// ?Load_byteShaderArray@@YAX_NH@Z at 0x822a4e98
QVector<quint8> Assets::Load_byteShaderArray(QDataStream *aStream, size_t count)
{
    QVector<quint8> result;

    for (int i = 0; i < count; i++) {
        quint8 byteShader_;

        *aStream >> byteShader_;

        result << byteShader_;
    }

    return result;
}

typedef unsigned __int8 byte4;

// ?Load_byte4Array@@YAX_NH@Z at 0x822a4eb0
QVector<byte4> Assets::Load_byte4Array(QDataStream *aStream, size_t count)
{
    QVector<byte4> result;

    for (int i = 0; i < count; i++) {
        byte4 byte4_;

        *aStream >> byte4_;

        result << byte4_;
    }

    return result;
}

typedef GfxTexture GfxRawTexture;

// ?Load_GfxRawTextureArray@@YAX_NH@Z at 0x822a4ec8
QVector<GfxRawTexture> Assets::Load_GfxRawTextureArray(QDataStream *aStream, int count)
{
    QVector<GfxRawTexture> result;

    for (int i = 0; i < count; i++) {
        GfxRawTexture gfxRawTexture;

        *aStream
                >> gfxRawTexture.basemapPtr
                >> gfxRawTexture.mapPtr
                >> gfxRawTexture.volmapPtr
                >> gfxRawTexture.cubemapPtr
                >> gfxRawTexture.loadDefPtr;

        result << gfxRawTexture;
    }

    return result;
}


// ?Load_IDirect3DCubeTexture9@@YAX_N@Z at 0x822a4ee0
D3DCubeTexture Assets::Load_IDirect3DCubeTexture9(QDataStream *aStream)
{
    D3DCubeTexture result;

    *aStream
            >> result.MipFlush
            >> result.Format
            >> result.Common
            >> result.ReferenceCount
            >> result.Fence
            >> result.ReadFence
            >> result.Identifier
            >> result.BaseFlush;

    for (int i = 0; i < 16; i++) {

        *aStream >> result.routing.data[i].source;
        *aStream >> result.routing.data[i].dest;
    }

    for (int i = 0; i < 15; i++) {
        quint32 declPtr;
        *aStream >> declPtr;
        &result.routing.decl[i] = declPtr;
    }

    return result;
}


// ?Load_IDirect3DVolumeTexture9@@YAX_N@Z at 0x822a4ef8
D3DVolumeTexture Assets::Load_IDirect3DVolumeTexture9(QDataStream *aStream)
{
    D3DVolumeTexture result;

    *aStream
            >> result.MipFlush
            >> result.Format
            >> result.Common
            >> result.ReferenceCount
            >> result.Fence
            >> result.ReadFence
            >> result.Identifier
            >> result.BaseFlush;

    for (int i = 0; i < 16; i++) {

        *aStream >> result.routing.data[i].source;
        *aStream >> result.routing.data[i].dest;
    }

    for (int i = 0; i < 15; i++) {
        quint32 declPtr;
        *aStream >> declPtr;
        &result.routing.decl[i] = declPtr;
    }

    return result;
}


// ?Load_IDirect3DTexture9@@YAX_N@Z at 0x822a4f10
D3DTexture Assets::Load_IDirect3DTexture9(QDataStream *aStream)
{
    D3DTexture result;

    *aStream
            >> result.MipFlush
            >> result.Format;

    return result;
}

// ?Load_r_index16_tArray@@YAX_NH@Z at 0x822a4f28
QVector<quint16> Assets::Load_r_index16_tArray(QDataStream *aStream, int count)
{
    QVector<quint16> result;

    for (int i = 0; i < count; i++) {
        quint16 r_index16;

        *aStream >> r_index16;

        result << r_index16;
    }

    return result;
}

// ?Load_r_index_tArray@@YAX_NH@Z at 0x822a4f40
QVector<quint16> Assets::Load_r_index_tArray(QDataStream *aStream, int count)
{
    QVector<quint16> result;

    for (int i = 0; i < count; i++) {
        quint16 r_index;

        *aStream >> r_index;

        result << r_index;
    }

    return result;
}

// ?Load_GfxIndexBuffer@@YAX_N@Z at 0x822a4f58
D3DIndexBuffer Assets::Load_GfxIndexBuffer(QDataStream *aStream)
{
    D3DIndexBuffer result;

    *aStream
            >> result.Address
            >> result.Size
            >> result.Common
            >> result.ReferenceCount
            >> result.Fence
            >> result.ReadFence
            >> result.Identifier
            >> result.BaseFlush;

    return result;
}

// ?Load_XBlendInfoArray@@YAX_NH@Z at 0x822a4f70
QVector<quint16> Assets::Load_XBlendInfoArray(QDataStream *aStream, int count)
{
    QVector<quint16> result;

    for (int i = 0; i < count; i++) {
        quint16 xBlendInfo;

        *aStream >> xBlendInfo;

        result << xBlendInfo;
    }

    return result;
}

typedef D3DVertexBuffer GfxVertexBuffer;

// ?Load_GfxVertexBuffer@@YAX_N@Z at 0x822a4f88
GfxVertexBuffer Assets::Load_GfxVertexBuffer(QDataStream *aStream)
{
    GfxVertexBuffer result;

    *aStream
            >> result.Format.request.Type
            >> result.Format.request.BaseAddress
            >> result.Format.request.Endian
            >> result.Format.request.Size
            >> result.Format.request.AddressClamp
            >> result.Format.request.
            >> result.Format.request.RequestSize
            >> result.Format.request.ClampDisable
            >> result.Format.dword[0]
            >> result.Format.dword[1]
            >> result.Common
            >> result.ReferenceCount
            >> result.Fence
            >> result.ReadFence
            >> result.Identifier
            >> result.BaseFlush;

    return result;
}


// ?Load_XSurfaceCollisionNodeArray@@YAX_NH@Z at 0x822a4fa0
QVector<XSurfaceCollisionNode> Assets::Load_XSurfaceCollisionNodeArray(QDataStream *aStream, int count)
{
    QVector<XSurfaceCollisionNode> result;

    for (int i = 0; i < count; i++) {
        XSurfaceCollisionNode xSurfaceCollisionNode;

        *aStream
                >> xSurfaceCollisionNode.aabb.mins[0]
                >> xSurfaceCollisionNode.aabb.mins[1]
                >> xSurfaceCollisionNode.aabb.mins[2]
                >> xSurfaceCollisionNode.aabb.maxs[0]
                >> xSurfaceCollisionNode.aabb.maxs[1]
                >> xSurfaceCollisionNode.aabb.maxs[2]
                >> xSurfaceCollisionNode.childBeginIndex
                >> xSurfaceCollisionNode.childCount;

        result << xSurfaceCollisionNode;
    }

    return result;
}

// ?Load_XSurfaceCollisionLeafArray@@YAX_NH@Z at 0x822a4fb8
QVector<XSurfaceCollisionLeaf> Assets::Load_XSurfaceCollisionLeafArray(QDataStream *aStream, int count)
{
    QVector<XSurfaceCollisionLeaf> result;

    for (int i = 0; i < count; i++) {
        XSurfaceCollisionLeaf xSurfaceCollisionLeaf;

        *aStream >> xSurfaceCollisionLeaf.triangleBeginIndex;

        result << xSurfaceCollisionLeaf;
    }

    return result;
}


// ?Load_GfxBrushModelArray@@YAX_NH@Z at 0x822a4fd0
QVector<GfxBrushModel> Assets::Load_GfxBrushModelArray(QDataStream *aStream, int count)
{
    QVector<GfxBrushModel> result;

    for (int i = 0; i < count; i++) {
        GfxBrushModel gfxBrushModel;

        *aStream
                >> gfxBrushModel.writable.mins[0]
                >> gfxBrushModel.writable.mins[1]
                >> gfxBrushModel.writable.mins[2]
                >> gfxBrushModel.writable.maxs[0]
                >> gfxBrushModel.writable.maxs[1]
                >> gfxBrushModel.writable.maxs[2]
                >> gfxBrushModel.bounds[0][0]
                >> gfxBrushModel.bounds[0][1]
                >> gfxBrushModel.bounds[0][2]
                >> gfxBrushModel.bounds[1][0]
                >> gfxBrushModel.bounds[1][1]
                >> gfxBrushModel.bounds[1][2]
                >> gfxBrushModel.surfaceCount
                >> gfxBrushModel.startSurfIndex;

        result << gfxBrushModel;
    }

    return result;
}

typedef GfxPackedVertex GfxPackedVertex0;

// ?Load_GfxPackedVertex0Array@@YAX_NH@Z at 0x822a4fe8
QVector<GfxPackedVertex0> Assets::Load_GfxPackedVertex0Array(QDataStream *aStream, int count)
{
    QVector<GfxPackedVertex0> result;

    for (int i = 0; i < count; i++) {
        GfxPackedVertex0 gfxPackedVertex0;

        *aStream
                >> gfxPackedVertex0.xyz[0]
                >> gfxPackedVertex0.xyz[1]
                >> gfxPackedVertex0.xyz[2]
                >> gfxPackedVertex0.binormalSign
                >> gfxPackedVertex0.color.array[0]
                >> gfxPackedVertex0.color.array[1]
                >> gfxPackedVertex0.color.array[2]
                >> gfxPackedVertex0.color.array[3]
                >> gfxPackedVertex0.texCoord.packed
                >> gfxPackedVertex0.normal.packed
                >> gfxPackedVertex0.tangent.packed;

        result << gfxPackedVertex0;
    }

    return result;
}

typedef GfxWorldVertex GfxWorldVertex0;

// ?Load_GfxWorldVertex0Array@@YAX_NH@Z at 0x822a5000
void Assets::Load_GfxWorldVertex0Array(QDataStream *aStream, int count)
{
    QVector<GfxWorldVertex0> result;

    for (int i = 0; i < count; i++) {
        GfxWorldVertex0 gfxWorldVertex0;

        *aStream
                >> gfxWorldVertex0.xyz[0]
                >> gfxWorldVertex0.xyz[1]
                >> gfxWorldVertex0.xyz[2]
                >> gfxWorldVertex0.binormalSign
                >> gfxWorldVertex0.color.array[0]
                >> gfxWorldVertex0.color.array[1]
                >> gfxWorldVertex0.color.array[2]
                >> gfxWorldVertex0.color.array[3]
                >> gfxWorldVertex0.texCoord[0]
                >> gfxWorldVertex0.texCoord[1]
                >> gfxWorldVertex0.lmapCoord[0]
                >> gfxWorldVertex0.lmapCoord[1]
                >> gfxWorldVertex0.normal.packed
                >> gfxWorldVertex0.tangent.packed;

        result << gfxPackedVertex0;
    }

    return result;
}


// ?Load_XAUDIOCHANNELMAPENTRYArray@@YAX_NH@Z at 0x822a5018
QVector<XAUDIOCHANNELMAPENTRY> Assets::Load_XAUDIOCHANNELMAPENTRYArray(QDataStream *aStream, int count)
{
    QVector<XAUDIOCHANNELMAPENTRY> result;

    for (int i = 0; i < count; i++) {
        XAUDIOCHANNELMAPENTRY xAUDIOCHANNELMAPENTRY;

        *aStream
                >> xAUDIOCHANNELMAPENTRY.InputChannel
                >> xAUDIOCHANNELMAPENTRY.OutputChannel
                >> xAUDIOCHANNELMAPENTRY.Volume;

        result << xAUDIOCHANNELMAPENTRY;
    }

    return result;
}


// ?Load_StreamFileNamePacked@@YAX_N@Z at 0x822a5030
StreamFileNamePacked Assets::Load_StreamFileNamePacked(QDataStream *aStream)
{
    StreamFileNamePacked result;

    *aStream
            >> result.offset
            >> result.length;

    return result;
}


// ?Load_XaReverbSettingsArray@@YAX_NH@Z at 0x822a5048
QVector<XAudioReverbSettings> Assets::Load_XaReverbSettingsArray(QDataStream *aStream, int count)
{
    QVector<XAudioReverbSettings> result;

    for (int i = 0; i < count; i++) {
        XAudioReverbSettings xaReverbSettings;

        *aStream
                >> xaReverbSettings.presetOverridden
                >> xaReverbSettings.reverbSettings.ReflectionsDelay
                >> xaReverbSettings.reverbSettings.ReverbDelay
                >> xaReverbSettings.reverbSettings.RearDelay
                >> xaReverbSettings.reverbSettings.PositionLeft
                >> xaReverbSettings.reverbSettings.PositionRight
                >> xaReverbSettings.reverbSettings.PositionMatrixLeft
                >> xaReverbSettings.reverbSettings.PositionMatrixRight
                >> xaReverbSettings.reverbSettings.EarlyDiffusion
                >> xaReverbSettings.reverbSettings.LateDiffusion
                >> xaReverbSettings.reverbSettings.LowEQGain
                >> xaReverbSettings.reverbSettings.LowEQCutoff
                >> xaReverbSettings.reverbSettings.HighEQGain
                >> xaReverbSettings.reverbSettings.HighEQCutoff
                >> xaReverbSettings.reverbSettings.RoomFilterFreq
                >> xaReverbSettings.reverbSettings.RoomFilterMain
                >> xaReverbSettings.reverbSettings.RoomFilterHF
                >> xaReverbSettings.reverbSettings.ReflectionsGain
                >> xaReverbSettings.reverbSettings.ReverbGain
                >> xaReverbSettings.reverbSettings.DecayTime
                >> xaReverbSettings.reverbSettings.Density
                >> xaReverbSettings.reverbSettings.RoomSize;

        result << xaReverbSettings;
    }

    return result;
}

typedef char char2048;

// ?Load_char2048Array@@YAX_NH@Z at 0x822a5060
QVector<char2048> Assets::Load_char2048Array(QDataStream *aStream, size_t count)
{
    QVector<char2048> result;

    for (int i = 0; i < count; i++) {
        char2048 char2048_;

        *aStream >> char2048_;

        result << char2048_;
    }

    return result;
}


// ?Load_DObjAnimMatArray@@YAX_NH@Z at 0x822a5078
QVector<DObjAnimMat> Assets::Load_DObjAnimMatArray(QDataStream *aStream, int count)
{
    QVector<DObjAnimMat> result;

    for (int i = 0; i < count; i++) {
        DObjAnimMat dObjAnimMat;

        *aStream
                >> dObjAnimMat.quat[0]
                >> dObjAnimMat.quat[1]
                >> dObjAnimMat.quat[2]
                >> dObjAnimMat.quat[3]
                >> dObjAnimMat.trans[0]
                >> dObjAnimMat.trans[1]
                >> dObjAnimMat.trans[2]
                >> dObjAnimMat.transWeight;

        result << dObjAnimMat;
    }

    return result;
}


// ?Load_XBoneInfoArray@@YAX_NH@Z at 0x822a5090
QVector<XBoneInfo> Assets::Load_XBoneInfoArray(QDataStream *aStream, int count)
{
    QVector<XBoneInfo> result;

    for (int i = 0; i < count; i++) {
        XBoneInfo xBoneInfo;

        *aStream
                >> xBoneInfo.bounds[0][0]
                >> xBoneInfo.bounds[0][1]
                >> xBoneInfo.bounds[0][2]
                >> xBoneInfo.bounds[1][0]
                >> xBoneInfo.bounds[1][1]
                >> xBoneInfo.bounds[1][2]
                >> xBoneInfo.offset[0]
                >> xBoneInfo.offset[1]
                >> xBoneInfo.offset[2]
                >> xBoneInfo.radiusSquared;

        result << xBoneInfo;
    }

    return result;
}

typedef unsigned __int16 UShortVec[3];

// ?Load_UShortVecArray@@YAX_NH@Z at 0x822a50b0
QVector<UShortVec> Assets::Load_UShortVecArray(QDataStream *aStream, int count)
{
    QVector<UShortVec> result;

    for (int i = 0; i < count; i++) {
        UShortVec uShortVec;

        *aStream
                >> uShortVec[0]
                >> uShortVec[1]
                >> uShortVec[2];

        result << uShortVec;
    }

    return result;
}

typedef unsigned __int8 ByteVec[3];

// ?Load_ByteVecArray@@YAX_NH@Z at 0x822a50d0
QVector<ByteVec> Assets::Load_ByteVecArray(QDataStream *aStream, int count)
{
    QVector<ByteVec> result;

    for (int i = 0; i < count; i++) {
        ByteVec byteVec;

        *aStream
                >> byteVec[0]
                >> byteVec[1]
                >> byteVec[2];

        result << byteVec;
    }

    return result;
}


// ?Load_dmaterial_tArray@@YAX_NH@Z at 0x822a50f0
QVector<dmaterial_t> Assets::Load_dmaterial_tArray(QDataStream *aStream, int count)
{
    QVector<dmaterial_t> result;

    for (int i = 0; i < count; i++) {
        dmaterial_t dmaterial;

        for (int j = 0; j < 64; j++) {
            *aStream >> dmaterial.material[j];
        }

        *aStream
                >> dmaterial.surfaceFlags
                >> dmaterial.contentFlags;

        result << dmaterial;
    }

    return result;
}


// ?Load_XString@@YAX_N@Z at 0x822a5110
void Assets::Load_XString(QDataStream *aStream)
{
    const char *v3; // r11

    qint32 stringPtr;
    *aStream >> stringPtr;

    if (stringPtr)
    {
        if (stringPtr == -1)
        {
            //Load_XStringCustom(v1);
        }
        else
        {
            // Resolve pointer to g_streamBlocks contents
            //*varXString = (const char *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                    + (((unsigned int)(stringPtr - 1) >> 26) & 0x38)))[(stringPtr - 1) & 0x1FFFFFFF];
        }
    }
}

// See if this actually needs to be const char
//typedef const char ConstChar;
typedef QChar ConstChar;

// ?Load_ConstCharArray@@YAX_NH@Z at 0x822a51b0
QVector<ConstChar> Assets::Load_ConstCharArray(QDataStream *aStream, size_t count)
{
    QVector<ConstChar> result;

    for (int i = 0; i < count; i++) {
        ConstChar constChar;

        *aStream >> constChar;

        result << constChar;
    }

    return result;
}

typedef unsigned __int16 ScriptString;

// ?Load_ScriptString@@YAX_N@Z at 0x822a51c8
ScriptString Assets::Load_ScriptString(QDataStream *aStream)
{
    ScriptString result;

    *aStream >> result;

    return result;

    // Might need to resolve contents to the value in varXAssetList?
    //*varScriptString = (unsigned __int16)*(const char **)((char *)varXAssetList->stringList.strings
    //                                                      + __ROL4__(*varScriptString, 2));
}

typedef unsigned __int16 UnsignedShort;

// ?Load_UnsignedShortArray@@YAX_NH@Z at 0x822a5220
QVector<UnsignedShort> Assets::Load_UnsignedShortArray(QDataStream *aStream, int count)
{
    QVector<UnsignedShort> result;

    for (int i = 0; i < count; i++) {
        UnsignedShort unsignedShort;

        *aStream >> unsignedShort;

        result << unsignedShort;
    }

    return result;
}

struct XQuat2 {
    __int16 u[2];
};

// ?Load_XQuat2@@YAX_N@Z at 0x822a5250
XQuat2 Assets::Load_XQuat2(QDataStream *aStream)
{
    XQuat2 xQuat2;

    *aStream
            >> xQuat2.u[0]
            >> xQuat2.u[1];

    return xQuat2;
}

// ?Load_XQuat2Array@@YAX_NH@Z at 0x822a5238
QVector<XQuat2> Assets::Load_XQuat2Array(QDataStream *aStream, int count)
{
    QVector<XQuat2> result;

    for (int i = 0; i < count; i++) {
        result << Load_XQuat2(aStream);
    }

    return result;
}


// ?Load_ushortArray@@YAX_NH@Z at 0x822a5268
QVector<ushort> Assets::Load_ushortArray(QDataStream *aStream, int count)
{
    QVector<ushort> result;

    for (int i = 0; i < count; i++) {
        ushort ushort_;

        *aStream >> ushort_;

        result << ushort_;
    }

    return result;
}


// ?Load_shortArray@@YAX_NH@Z at 0x822a5280
QVector<short> Assets::Load_shortArray(QDataStream *aStream, int count)
{
    QVector<short> result;

    for (int i = 0; i < count; i++) {
        short short_;

        *aStream >> short_;

        result << short_;
    }

    return result;
}

struct vec3_t {
    float v[3];
};

// ?Load_vec3_t@@YAX_N@Z at 0x822a52b8
vec3_t Assets::Load_vec3_t(QDataStream *aStream)
{
    vec3_t result;

    *aStream
            >> result.v[0]
            >> result.v[1]
            >> result.v[2];

    return result;
}

// ?Load_vec3_tArray@@YAX_NH@Z at 0x822a5298
QVector<vec3_t> Assets::Load_vec3_tArray(QDataStream *aStream, int count)
{
    QVector<vec3_t> result;

    for (int i = 0; i < count; i++) {
        result << Load_vec3_t(aStream);
    }

    return result;
}

struct vec2_t {
    float v[2];
};

// ?Load_vec2_tArray@@YAX_NH@Z at 0x822a52d0
QVector<vec2_t> Assets::Load_vec2_tArray(QDataStream *aStream, int count)
{
    QVector<vec2_t> result;

    for (int i = 0; i < count; i++) {
        vec2_t vec2;

        *aStream
                >> vec2.v[0]
                >> vec2.v[1];

        result << vec2;
    }

    return result;
}

typedef unsigned __int8 raw_byte16;

// ?Load_raw_byte16Array@@YAX_NH@Z at 0x822a52e8
QVector<raw_byte16> Assets::Load_raw_byte16Array(QDataStream *aStream, size_t count)
{
    QVector<raw_byte16> result;

    for (int i = 0; i < count; i++) {
        raw_byte16 raw_byte16_;

        *aStream >> raw_byte16_;

        result << raw_byte16_;
    }

    return result;
}

typedef unsigned __int8 raw_byte;

// ?Load_raw_byteArray@@YAX_NH@Z at 0x822a5300
QVector<raw_byte> Assets::Load_raw_byteArray(QDataStream *aStream, size_t count)
{
    QVector<raw_byte> result;

    for (int i = 0; i < count; i++) {
        raw_byte raw_byte_;

        *aStream >> raw_byte_;

        result << raw_byte_;
    }

    return result;
}

typedef unsigned int raw_uint128;

// ?Load_raw_uint128Array@@YAX_NH@Z at 0x822a5318
QVector<raw_uint128> Assets::Load_raw_uint128Array(QDataStream *aStream, int count)
{
    QVector<raw_uint128> result;

    for (int i = 0; i < count; i++) {
        raw_uint128 raw_uint128_;

        *aStream >> raw_uint128_;

        result << raw_uint128_;
    }

    return result;
}

typedef unsigned int raw_uint;

// ?Load_raw_uintArray@@YAX_NH@Z at 0x822a5330
QVector<raw_uint> Assets::Load_raw_uintArray(QDataStream *aStream, int count)
{
    QVector<raw_uint> result;

    for (int i = 0; i < count; i++) {
        raw_uint raw_uint_;

        *aStream >> raw_uint_;

        result << raw_uint_;
    }

    return result;
}


// ?Load_float@@YAX_N@Z at 0x822a5360
float Assets::Load_float(QDataStream *aStream)
{
    float result;

    *aStream >> result;

    return result;
}


// ?Load_floatArray@@YAX_NH@Z at 0x822a5348
QVector<float> Assets::Load_floatArray(QDataStream *aStream, int count)
{
    QVector<float> result;

    for (int i = 0; i < count; i++) {
        result << Load_float(aStream);
    }

    return result;
}


// ?Load_uint@@YAX_N@Z at 0x822a5390
uint Assets::Load_uint(QDataStream *aStream)
{
    uint result;

    *aStream >> result;

    return result;
}


// ?Load_uintArray@@YAX_NH@Z at 0x822a5378
QVector<uint> Assets::Load_uintArray(QDataStream *aStream, int count)
{
    QVector<uint> result;

    for (int i = 0; i < count; i++) {
        result << Load_uint(aStream);
    }

    return result;
}


// ?Load_DWORDArray@@YAX_NH@Z at 0x822a53a8
QVector<DWORD> Assets::Load_DWORDArray(QDataStream *aStream, int count)
{
    QVector<DWORD> result;

    for (int i = 0; i < count; i++) {
        DWORD DWORD_;

        *aStream >> DWORD_;

        result << DWORD_;
    }

    return result;
}

typedef unsigned __int8 byte4096;

// ?Load_byte4096Array@@YAX_NH@Z at 0x822a53c0
QVector<byte4096> Assets::Load_byte4096Array(QDataStream *aStream, size_t count)
{
    QVector<byte4096> result;

    for (int i = 0; i < count; i++) {
        byte4096 byte4096_;

        *aStream >> byte4096_;

        result << byte4096_;
    }

    return result;
}


// ?Load_int@@YAX_N@Z at 0x822a53f0
int Assets::Load_int(QDataStream *aStream)
{
    int result;

    *aStream >> result;

    return result;
}


// ?Load_intArray@@YAX_NH@Z at 0x822a53d8
QVector<int> Assets::Load_intArray(QDataStream *aStream, int count)
{
    QVector<int> result;

    for (int i = 0; i < count; i++) {
        result << Load_int(aStream);
    }

    return result;
}


// ?Load_char@@YAX_N@Z at 0x822a5420
char Assets::Load_char(QDataStream *aStream)
{
    char result;

    *aStream >> result;

    return result;
}


// ?Load_charArray@@YAX_NH@Z at 0x822a5408
QVector<char> Assets::Load_charArray(QDataStream *aStream, size_t count)
{
    QVector<char> result;

    for (int i = 0; i < count; i++) {
        result << Load_char(aStream);
    }

    return result;
}


// ?Load_byteArray@@YAX_NH@Z at 0x822a5438
QVector<byte> Assets::Load_byteArray(QDataStream *aStream, size_t count)
{
    QVector<byte> result;

    for (int i = 0; i < count; i++) {
        byte byte_;

        *aStream >> byte_;

        result << byte_;
    }

    return result;
}


// ?Load_GfxWorldDpvsPlanes@@YAX_N@Z at 0x822a5450
GfxWorldDpvsPlanes Assets::Load_GfxWorldDpvsPlanes(QDataStream *aStream, GfxWorld aGfxWorld)
{
    GfxWorldDpvsPlanes result;
    *aStream
            >> result.cellCount
            >> result.planesPtr
            >> result.nodesPtr
            >> result.sceneEntCellBitsPtr;

    if (result.planesPtr)
    {
        if (result.planesPtr == -1)
        {
            for (int i = 0; i < aGfxWorld.planeCount; i++) {
                gfxWorldDpvsPlanes.planes << Load_cplane_t(aStream);
            }
        }
        else
        {
            // Resolve to content in g_streamBlocks
            //varGfxWorldDpvsPlanes->planes = (cplane_s *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                    + (((unsigned int)&varGfxWorldDpvsPlanes->planes[-1].pad[1] >> 26) & 0x38)))[(int)&varGfxWorldDpvsPlanes->planes[-1].pad[1] & 0x1FFFFFFF];
        }
    }
    if (result.nodesPtr)
    {
        for (int i = 0; i < aGfxWorld.nodeCount; i++) {
            ushort ushort_;

            *aStream >> ushort_;

            result.nodes << ushort_;
        }
    }
    if (result.sceneEntCellBitsPtr)
    {
        for (int i = 0; i < (result.cellCount << 10); i++) {
            unsigned int uint_;

            *aStream >> uint_;

            result.sceneEntCellBits << uint_;
        }
    }
    return result;
}


// ?Load_GfxWorldDpvsDynamic@@YAX_N@Z at 0x822a5580
GfxWorldDpvsDynamic Assets::Load_GfxWorldDpvsDynamic(QDataStream *aStream, GfxWorld aGfxWorld)
{
    GfxWorldDpvsDynamic result;
    *aStream
            >> result.dynEntClientWordCount[0]
            >> result.dynEntClientWordCount[1]
            >> result.dynEntClientCount[0]
            >> result.dynEntClientCount[1]
            >> result.dynEntCellBitsPtrs[0]
            >> result.dynEntCellBitsPtrs[1]
            >> result.dynEntVisDataPtrs[0][0]
            >> result.dynEntVisDataPtrs[0][1]
            >> result.dynEntVisDataPtrs[0][2]
            >> result.dynEntVisDataPtrs[1][0]
            >> result.dynEntVisDataPtrs[1][1]
            >> result.dynEntVisDataPtrs[1][2];


    if (result.dynEntCellBitsPtrs[0])
    {
        //for (int i = 0; i < aGfxWorld.dpvsPlanes.cellCount * gfxWorldDpvsDynamic.dynEntClientWordCount[0]; i++) {
        *aStream >> result.dynEntCellBits[0];
        //}
    }
    if (result.dynEntCellBitsPtrs[1])
    {
        //for (int i = 0; i < aGfxWorld.dpvsPlanes.cellCount * gfxWorldDpvsDynamic.dynEntClientWordCount[0]; i++) {
        *aStream >> result.dynEntCellBits[1];
        //}
    }
    if (result.dynEntVisDataPtrs[0][0])
    {
        //for (int i = 0; i < gfxWorldDpvsDynamic.dynEntClientWordCount[0]; i++) {
        *aStream >> result.dynEntVisData[0][0];
        //}
    }
    if (result.dynEntVisDataPtrs[1][0])
    {
        //for (int i = 0; i < gfxWorldDpvsDynamic.dynEntClientWordCount[1]; i++) {
        *aStream >> result.dynEntVisData[1][0];
        //}
    }
    if (result.dynEntVisDataPtrs[0][1])
    {
        //for (int i = 0; i < gfxWorldDpvsDynamic.dynEntClientWordCount[0]; i++) {
        *aStream >> result.dynEntVisData[0][1];
        //}
    }
    if (result.dynEntVisDataPtrs[1][1])
    {
        //for (int i = 0; i < gfxWorldDpvsDynamic.dynEntClientWordCount[1]; i++) {
        *aStream >> result.dynEntVisData[1][1];
        //}
    }
    if (result.dynEntVisDataPtrs[0][2])
    {
        //for (int i = 0; i < gfxWorldDpvsDynamic.dynEntClientWordCount[0]; i++) {
        *aStream >> result.dynEntVisData[0][2];
        //}
    }
    if (result.dynEntVisDataPtrs[1][2])
    {
        //for (int i = 0; i < gfxWorldDpvsDynamic.dynEntClientWordCount[1]; i++) {
        *aStream >> result.dynEntVisData[1][2];
        //}
    }
    return result;
}


// ?Load_GfxLightRegionHull@@YAX_N@Z at 0x822a57d0
GfxLightRegionHull Assets::Load_GfxLightRegionHull(QDataStream *aStream)
{
    unsigned int axisCount; // r11
    unsigned __int8 *v2; // r4

    GfxLightRegionHull result;
    *aStream
            >> result.kdopMidPoint[0]
            >> result.kdopMidPoint[1]
            >> result.kdopMidPoint[2]
            >> result.kdopMidPoint[3]
            >> result.kdopMidPoint[4]
            >> result.kdopMidPoint[5]
            >> result.kdopMidPoint[6]
            >> result.kdopMidPoint[7]
            >> result.kdopMidPoint[8]
            >> result.kdopHalfSize[0]
            >> result.kdopHalfSize[1]
            >> result.kdopHalfSize[2]
            >> result.kdopHalfSize[3]
            >> result.kdopHalfSize[4]
            >> result.kdopHalfSize[5]
            >> result.kdopHalfSize[6]
            >> result.kdopHalfSize[7]
            >> result.kdopHalfSize[8]
            >> result.axisCount
            >> result.axisPtr;

    if (result.axisPtr)
    {
        for (int i = 0; i < result.axisCount; i++) {
            GfxLightRegionAxis axis;

            *aStream
                    >> axis.dir[0]
                    >> axis.dir[1]
                    >> axis.dir[2]
                    >> axis.midPoint
                    >> axis.halfSize;

            result.axis << axis;
        }
    }
    return result;
}

unsigned __int16 __ROL4__(unsigned __int16 value, unsigned __int16 bits) {
    // Ensure that the rotation is within bounds
    bits = bits % 32; // In case someone passes a value greater than 31

    return (value << bits) | (value >> (8 - bits));
}

// ?Load_GfxShadowGeometry@@YAX_N@Z at 0x822a5850
GfxShadowGeometry Assets::Load_GfxShadowGeometry(QDataStream *aStream)
{
    GfxShadowGeometry result;
    *aStream
            >> result.surfaceCount
            >> result.smodelCount
            >> result.sortedSurfIndexPtr
            >> result.smodelIndexPtr;

    if (result.sortedSurfIndexPtr)
    {
        for (int i = 0; i < __ROL4__(result.surfaceCount, 1); i++) {
            unsigned __int16 surfIndex;

            *aStream >> surfIndex;

            result.sortedSurfIndex << surfIndex;
        }
    }
    if (result.smodelIndexPtr)
    {
        for (int i = 0; i < __ROL4__(result.smodelCount, 1); i++) {
            unsigned __int16 smodelIndex;

            *aStream >> smodelIndex;

            result.smodelIndex << smodelIndex;
        }
    }
    return result;
}


// ?Load_GfxWorldStreamInfo@@YAX_N@Z at 0x822a58f0
GfxWorldStreamInfo Assets::Load_GfxWorldStreamInfo(QDataStream *aStream)
{
    GfxWorldStreamInfo result;
    *aStream
            >> result.aabbTreeCount
            >> result.aabbTreesPtr
            >> result.leafRefCount
            >> result.leafRefsPtr;

    if (result.aabbTreesPtr)
    {
        for (int i = 0; i < result.aabbTreeCount; i++) {
            GfxStreamingAabbTree aabbTree;

            *aStream
                    >> aabbTree.firstItem
                    >> aabbTree.itemCount
                    >> aabbTree.firstChild
                    >> aabbTree.childCount
                    >> aabbTree.mins[0]
                    >> aabbTree.mins[1]
                    >> aabbTree.mins[2]
                    >> aabbTree.maxs[0]
                    >> aabbTree.maxs[1]
                    >> aabbTree.maxs[2];

            result.aabbTrees << aabbTree;
        }
    }
    if (result.leafRefsPtr)
    {
        for (int i = 0; i < result.leafRefCount; i++) {
            int leafRef;

            *aStream >> leafRef;

            result.leafRefs << leafRef;
        }
    }
    return result;
}


// ?Load_GfxLightGrid@@YAX_N@Z at 0x822a59b0
GfxLightGrid Assets::Load_GfxLightGrid(QDataStream *aStream)
{
    GfxLightGrid result;

    *aStream
            >> result.hasLightRegions
            >> result.sunPrimaryLightIndex
            >> result.mins[0]
            >> result.mins[1]
            >> result.mins[2]
            >> result.maxs[0]
            >> result.maxs[1]
            >> result.maxs[2]
            >> result.rowAxis
            >> result.colAxis
            >> result.rowDataStartPtr
            >> result.rawRowDataSize
            >> result.rawRowDataPtr
            >> result.entryCount
            >> result.entriesPtr
            >> result.colorCount
            >> result.colorsPtr;

    if (result.rowDataStartPtr)
    {
        for (int i = 0; i < (result.maxs[result.rowAxis] - result.mins[result.rowAxis] + 1); i++) {
            unsigned __int16 rowDataStart;

            *aStream >> rowDataStart;

            result.rowDataStart << rowDataStart;
        }
    }
    if (result.rawRowDataPtr)
    {
        for (int i = 0; i < result.rawRowDataSize; i++) {
            unsigned __int16 rawRowData;

            *aStream >> rawRowData;

            result.rawRowData << rawRowData;
        }
    }
    if (result.entriesPtr)
    {
        for (int i = 0; i < result.entryCount; i++) {
            GfxLightGridEntry entry;

            *aStream
                    >> entry.colorsIndex
                    >> entry.primaryLightIndex
                    >> entry.needsTrace;

            result.entries << entry;
        }
    }
    if (result.colorsPtr)
    {
        for (int i = 0; i < result.colorCount; i++) {
            result.colors << Load_GfxLightGridColors(aStream);
        }
    }
}


// ?Load_GfxWorldVertexLayerData@@YAX_N@Z at 0x822a5af8
GfxWorldVertexLayerData Assets::Load_GfxWorldVertexLayerData(QDataStream *aStream, GfxWorld aGfxWorld)
{
    GfxWorldVertexLayerData result;

    *aStream
            >> result.dataPtr
            >> result.layerVb.Format.__s0.Type
            >> result.layerVb.Format.__s0.BaseAddress
            >> result.layerVb.Format.__s0.Endian
            >> result.layerVb.Format.__s0.Size
            >> result.layerVb.Format.__s0.AddressClamp
            //>> result.layerVb.Format.__s0.: 1;
            >> result.layerVb.Format.__s0.RequestSize
            >> result.layerVb.Format.__s0.ClampDisable
            >> result.layerVb.Format.dword[0]
            >> result.layerVb.Format.dword[1]
            >> result.layerVb.Common
            >> result.layerVb.ReferenceCount
            >> result.layerVb.Fence
            >> result.layerVb.ReadFence
            >> result.layerVb.Identifier
            >> result.layerVb.BaseFlush;

    if (result.dataPtr)
    {
        for (int i = 0; i < aGfxWorld.vertexLayerDataSize; i++) {
            unsigned __int8 dataPart;

            *aStream >> dataPart;

            result.data << dataPart;
        }
    }
    aStream->skipRawData(0x20);
    return result;
}


// ?Load_GfxWorldVertexData@@YAX_N@Z at 0x822a5bd0
GfxWorldVertexData Assets::Load_GfxWorldVertexData(QDataStream *aStream, GfxWorld aGfxWorld)
{
    GfxWorldVertexData *v1; // r11
    GfxWorldVertex *v2; // r4
    unsigned int vertexCount; // r11
    D3DVertexBuffer *p_worldVb; // r31
    GfxWorldVertex *vertices; // r30

    GfxWorldVertexData result;
    *aStream
            >> result.verticesPtr
            >> result.worldVb.Format.__s0.Type
            >> result.worldVb.Format.__s0.BaseAddress
            >> result.worldVb.Format.__s0.Endian
            >> result.worldVb.Format.__s0.Size
            >> result.worldVb.Format.__s0.AddressClamp
            //>> result.worldVb.Format.__s0.: 1;
            >> result.worldVb.Format.__s0.RequestSize
            >> result.worldVb.Format.__s0.ClampDisable
            >> result.worldVb.Format.dword[0]
            >> result.worldVb.Format.dword[1]
            >> result.worldVb.Common
            >> result.worldVb.ReferenceCount
            >> result.worldVb.Fence
            >> result.worldVb.ReadFence
            >> result.worldVb.Identifier
            >> result.worldVb.BaseFlush;

    if (result.verticesPtr)
    {
        for (int i = 0; i < aGfxWorld.vertexCount; i++) {
            GfxWorldVertex gfxWorldVertex;

            *aStream
                    >> gfxWorldVertex.xyz[0]
                    >> gfxWorldVertex.xyz[1]
                    >> gfxWorldVertex.xyz[2]
                    >> gfxWorldVertex.binormalSign
                    >> gfxWorldVertex.color.array[0]
                    >> gfxWorldVertex.color.array[1]
                    >> gfxWorldVertex.color.array[2]
                    >> gfxWorldVertex.color.array[3]
                    >> gfxWorldVertex.texCoord[0]
                    >> gfxWorldVertex.texCoord[1]
                    >> gfxWorldVertex.lmapCoord[0]
                    >> gfxWorldVertex.lmapCoord[1]
                    >> gfxWorldVertex.normal.packed
                    >> gfxWorldVertex.tangent.packed;

            result.vertices << gfxWorldVertex;
        }
    }
    return result;
}


// ?Load_GfxAabbTree@@YAX_N@Z at 0x822a5da8
GfxAabbTree Assets::Load_GfxAabbTree(QDataStream *aStream)
{
    unsigned __int16 *smodelIndexes; // r10
    size_t v2; // r5
    unsigned __int8 *v3; // r4

    GfxAabbTree result;
    *aStream
            >> result.mins[0]
            >> result.mins[1]
            >> result.mins[2]
            >> result.maxs[0]
            >> result.maxs[1]
            >> result.maxs[2]
            >> result.childCount
            >> result.surfaceCount
            >> result.startSurfIndex
            >> result.smodelIndexCount
            >> result.smodelIndexesPtr
            >> result.childrenOffset;

    if (result.smodelIndexesPtr)
    {
        if (result.smodelIndexesPtr == -1)
        {
            for (int i = 0; i < result.smodelIndexCount; i++) {
                unsigned __int16 smodelIndex;

                *aStream >> smodelIndex;

                result.smodelIndexes << smodelIndex;
            }
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //varGfxAabbTree->smodelIndexes = (unsigned __int16 *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                            + ((((unsigned int)varGfxAabbTree->smodelIndexes
            //                                                                                 - 1) >> 26) & 0x38)))[((int)varGfxAabbTree->smodelIndexes - 1) & 0x1FFFFFFF];
        }
    }
    return result;
}


// ?Load_GfxAabbTreeArray@@YAX_NH@Z at 0x822a75f0
QVector<GfxAabbTree> Assets::Load_GfxAabbTreeArray(QDataStream *aStream, int count)
{
    QVector<GfxAabbTree> result;

    for (int i = 0; i < count; i++) {
        result << Load_GfxAabbTree(aStream);
    }

    return result;
}


// ?Load_GfxCell@@YAX_N@Z at 0x822a8af0
GfxCell Assets::Load_GfxCell(QDataStream *aStream)
{
    GfxCell result;

    *aStream
            >> result.mins[0]
            >> result.mins[1]
            >> result.mins[2]
            >> result.maxs[0]
            >> result.maxs[1]
            >> result.maxs[2]
            >> result.aabbTreeCount
            >> result.aabbTreePtr
            >> result.portalCount
            >> result.portalsPtr
            >> result.cullGroupCount
            >> result.cullGroupsPtr
            >> result.reflectionProbeCount
            >> result.reflectionProbesPtr;

    if (result.aabbTreePtr)
    {
        result.aabbTree = Load_GfxAabbTreeArray(aStream, result.aabbTreeCount);
    }
    if (result.portalsPtr)
    {
        result.portals = Load_GfxPortalArray(1, result.portalCount);
    }
    if (result.cullGroupsPtr)
    {
        v4 = 4 * v1->cullGroupCount;
        v5 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v5;
        varint = (int *)v5;
        v1->cullGroups = (int *)v5;
        Load_Stream(1, v5, v4);
        v1 = varGfxCell;
    }
    if (result.reflectionProbesPtr)
    {
        v6 = g_streamPos;
        reflectionProbeCount = v1->reflectionProbeCount;
        varbyte = g_streamPos;
        v1->reflectionProbes = g_streamPos;
        Load_Stream(1, v6, reflectionProbeCount);
    }
}


// ?Load_GfxPortal@@YAX_N@Z at 0x822a5cb8
GfxPortal Assets::Load_GfxPortal(QDataStream *aStream)
{
    GfxPortal *v1; // r11
    GfxCell *cell; // r10
    int vertexCount; // r10
    unsigned __int8 *v4; // r4

    GfxPortal result;
    *aStream
            >> result.writable.isQueued
            >> result.writable.isAncestor
            >> result.writable.recursionDepth
            >> result.writable.hullPointCount
            >> result.writable.hullPointPtrs[0]
            >> result.writable.hullPointPtrs[1]
            >> result.writable.queuedParentPtr
            >> result.plane.coeffs[0]
            >> result.plane.coeffs[1]
            >> result.plane.coeffs[2]
            >> result.plane.coeffs[3]
            >> result.plane.side[0]
            >> result.plane.side[1]
            >> result.plane.side[2]
            >> result.plane.pad
            >> result.cellPtr
            >> result.verticesPtr
            >> result.vertexCount
            >> result.hullAxis[0][0]
            >> result.hullAxis[0][1]
            >> result.hullAxis[0][2]
            >> result.hullAxis[1][0]
            >> result.hullAxis[1][1]
            >> result.hullAxis[1][2];

    if (result.cellPtr)
    {
        if (result.cellPtr == -1)
        {
            result.cell = Load_GfxCell(aStream);
        }
        else
        {
            // Resolve contents to g_streamBlocks
            //varGfxPortal->cell = (GfxCell *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                        + ((((unsigned int)&varGfxPortal->cell[-1].reflectionProbes
            //                                                             + 3) >> 26) & 0x38)))[((int)&varGfxPortal->cell[-1].reflectionProbes
            //                                                                                    + 3) & 0x1FFFFFFF];
        }
    }
    if (result.verticesPtr)
    {
        for (int i = 0; i < vertexCount + __ROL4__(vertexCount, 1); i++) {
            float vertex;

            *aStream >> vertex;

            result.vertices[i] = vertex;
        }
    }

    return result;
}

// ?Load_GfxPortalArray@@YAX_NH@Z at 0x822a7598
QVector<GfxPortal> Assets::Load_GfxPortalArray(QDataStream *aStream, int count)
{
    QVector<GfxPortal> result;

    for (int i = 0; i < count; i++) {
        result << Load_GfxPortal(aStream);
    }

    return result;
}

QString Assets::Load_XStringCustom(QDataStream *aStream) {
    QString result;

    char stringChar;

    *aStream >> stringChar;
    while (stringChar != '\0') {
        result += stringChar;

        *aStream >> stringChar;
    }

    return result;
}

QString Assets::Load_XString(QDataStream *aStream)
{
    QString result;

    qint32 stringPtr;
    *aStream >> stringPtr;

    if (stringPtr == -1) {
        result = Load_XStringCustom(aStream);
    } else {
        // Resolve to contents in g_streamBlocks
        //*varXString = (const char *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
        //                                                        + (((unsigned int)(v2 - 1) >> 26) & 0x38)))[(v2 - 1) & 0x1FFFFFFF];
    }

    return result;
}

// ?Load_RawFile@@YAX_N@Z at 0x822a5e60
RawFile Assets::Load_RawFile(QDataStream *aStream)
{
    RawFile result;

    *aStream
            >> result.namePtr
            >> result.len
            >> result.bufferPtr;

    result.name = Load_XString(aStream);
    if (result.bufferPtr)
    {
        QByteArray buffer(result.len + 1, Qt::Uninitialized);
        aStream->readRawData(buffer.data(), result.len + 1);
        result.buffer = QString::fromUtf8(buffer);
    }

    return result
}


// ?Load_LocalizeEntry@@YAX_N@Z at 0x822a5ef0
XLocalizeEntry Assets::Load_LocalizeEntry(QDataStream *aStream)
{
    XLocalizeEntry result;

    *aStream
            >> result.valuePtr
            >> result.namePtr;

    if (result.valuePtr == -1) {
        result.value = Load_XStringCustom(aStream);
    }
    if (result.namePtr == -1) {
        result.name = Load_XStringCustom(aStream);
    }

    return result;
}


// ?Load_operandInternalDataUnion@@YAX_N@Z at 0x822a6058
void Assets::Load_operandInternalDataUnion(QDataStream *aStream)
{
    XOperand *varOperand = new XOperand;
    QString varXString;
    if ( varOperand->dataType == VAL_STRING )
    {
        varXString = (const char **)varoperandInternalDataUnion;
        Load_XString(0);
    }
}


// ?Load_ComPrimaryLight@@YAX_N@Z at 0x822a6098
XComPrimaryLight Assets::Load_ComPrimaryLight(QDataStream *aStream)
{
    XComPrimaryLight result;

    *aStream
            >> result.type
            >> result.canUseShadowMap
            >> result.exponent
            >> result.unused
            >> result.color[0]
            >> result.color[1]
            >> result.color[2]
            >> result.dir[0]
            >> result.dir[1]
            >> result.dir[2]
            >> result.origin[0]
            >> result.origin[1]
            >> result.origin[2]
            >> result.radius
            >> result.cosHalfFovOuter
            >> result.cosHalfFovInner
            >> result.cosHalfFovExpanded
            >> result.rotationLimit
            >> result.translationLimit
            >> result.defNamePtr;

    if (result.defNamePtr == -1) {
        result.defName = Load_XStringCustom(aStream);
    }

    return result;
}


// ?Load_CollisionPartition@@YAX_N@Z at 0x822a60e8
CollisionPartition Assets::Load_CollisionPartition(QDataStream *aStream)
{
    CollisionPartition result;

    *aStream
            >> result.triCount
            >> result.borderCount
            >> result.firstTri
            >> result.bordersPtr;

    if (result.bordersPtr)
    {
        if (result.bordersPtr == -1)
        {
            result.borders = Load_CollisionBorder(aStream);
        }
        else
        {
            // Resolve contents from g_streamBlock
            //varCollisionPartition->borders = (CollisionBorder *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                            + ((((unsigned int)&varCollisionPartition->borders[-1].length
            //                                                                                 + 3) >> 26) & 0x38)))[((int)&varCollisionPartition->borders[-1].length + 3) & 0x1FFFFFFF];
        }
    }

    return result;
}

CLeafBrushNodeLeaf Assets::Load_CLeafBrushNodeLeaf(QDataStream *aStream, int leafBrushCount)
{
    CLeafBrushNodeLeaf result;

    *aStream >> result.brushesPtr;

    if (result.brushesPtr) {
        if (result.brushesPtr == -1)
        {
            for (int i = 0; i < leafBrushCount; i++) {
                unsigned int brush;

                *aStream >> brush;

                result.brushes << brush;
            }
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //varcLeafBrushNodeLeaf_t->brushes = (unsigned __int16 *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                             + ((((unsigned int)varcLeafBrushNodeLeaf_t->brushes
            //                                                                                - 1) >> 26) & 0x38)))[((int)varcLeafBrushNodeLeaf_t->brushes - 1) & 0x1FFFFFFF];
        }
    }
    return result;
}

// ?Load_CLeafBrushNodeData@@YAX_N@Z at 0x822a61a0
CLeafBrushNodeData Assets::Load_CLeafBrushNodeData(QDataStream *aStream, int aNodeCount)
{
    CLeafBrushNodeData result;

    if (aNodeCount > 0)
    {
        result = Load_CLeafBrushNodeLeaf(aStream, aNodeCount);
    }

    return result;
}


// ?Load_MapEnts@@YAX_N@Z at 0x822a6278
MapEnts Assets::Load_MapEnts(QDataStream *aStream)
{
    MapEnts results;

    *aStream
            >> results.namePtr
            >> results.entityStringPtr
            >> results.numEntityChars;

    if (results.namePtr == -1) {
        results.name = Assets::Load_XString(aStream);
    }

    if (results.entityStringPtr)
    {
        QByteArray entityData(results.numEntityChars, Qt::Uninitialized);

        aStream->readRawData(entityData.data(), results.numEntityChars);

        results.entityString = QString::fromUtf8(entityData);
    }

    return results;
}


// ?Load_FxTrailDef@@YAX_N@Z at 0x822a6308
FxTrailDef Assets::Load_FxTrailDef(QDataStream *aStream)
{
    FxTrailDef result;

    *aStream
            >> result.scrollTimeMsec
            >> result.repeatDist
            >> result.splitDist
            >> result.vertCount
            >> result.vertsPtr
            >> result.indCount
            >> result.indsPtr;


    if (result.vertsPtr)
    {
        for (int i = 0; i < result.vertCount; i++) {
            FxTrailVertex fxTrailVertex;

            *aStream
                    >> fxTrailVertex.pos[0]
                    >> fxTrailVertex.pos[1]
                    >> fxTrailVertex.normal[0]
                    >> fxTrailVertex.normal[1]
                    >> fxTrailVertex.texCoord;

            result.verts << fxTrailVertex;
        }
    }
    if (result.indsPtr)
    {
        for (int i = 0; i < result.indCount; i++) {
            ushort ind;

            *aStream >> ind;

            result.inds << ind;
        }
    }

    return result;
}


// ?Load_FxEffectDefRef@@YAX_N@Z at 0x822a63d0
FxEffectDefRef Assets::Load_FxEffectDefRef(QDataStream *aStream)
{
    FxEffectDefRef result;
    *aStream >> result.namePtr;
    if (result.namePtr == -1) {
        Load_XStringCustom(aStream);
    }

    //if ( varFxEffectDefRef->handle )
    //    v2->handle = (const FxEffectDef *)DB_FindXAssetHeader(
    //                (XAssetHeader *)0x1A,
    //                (XAssetType)varFxEffectDefRef->handle,
    //                v1);
    return result;
}


// ?Load_GameWorldMp@@YAX_N@Z at 0x822a6430
GameWorldMp Assets::Load_GameWorldMp(QDataStream *aStream)
{
    GameWorldMp result;

    *aStream >> result.namePtr;

    if (result.namePtr == -1) {
        result.name = Load_XStringCustom(aStream);
    }

    return result;
}


// ?LoadPathNodeTreeArray@@YAX_NH@Z at 0x822a6488
QVector<PathNodeTree> Assets::LoadPathNodeTreeArray(QDataStream *aStream, int count)
{
    QVector<PathNodeTree> result;

    for (int i = 0; i < count; i++) {
        PathNodeTree pathnode_tree;

        *aStream
                >> pathnode_tree.axis
                >> pathnode_tree.dist
                >> pathnode_tree.infoPtr;

        if (pathnode_tree.infoPtr)
        {
            if (pathnode_tree.infoPtr == -1 )
            {
                Load_PathNodeTree(1);
            }
            else
            {
                // Resolve contents from g_streamBlocks
                //*varpathnode_tree_ptr = (pathnode_tree_t *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                //                                                                   + (((unsigned int)(v4 - 1) >> 26) & 0x38)))[(v4 - 1) & 0x1FFFFFFF];
            }
        }

        result << pathnode_tree;
    }
    return result;
}


// ?Load_PathNodeTreeNodes@@YAX_N@Z at 0x822a6540
PathNodeTreeNodes Assets::Load_PathNodeTreeNodes(QDataStream *aStream)
{
    PathNodeTreeNodes result;

    *aStream >> result.nodeCount;

    for (int i = 0; i < result.nodeCount; i++) {
        quint16 node;
        *aStream >> node;
        result.nodes << node;
    }
    return result;
}


// ?Load_PathNodeConstant@@YAX_N@Z at 0x822a65b8
PathNodeConstant Assets::Load_PathNodeConstant(QDataStream *aStream)
{
    PathNodeConstant result;

    *aStream
            >> result.type
            >> result.spawnflags
            >> result.targetname
            >> result.script_linkName
            >> result.script_noteworthy
            >> result.target
            >> result.animscript
            >> result.animscriptfunc
            >> result.vOrigin[0]
            >> result.vOrigin[1]
            >> result.vOrigin[2]
            >> result.fAngle
            >> result.forward[0]
            >> result.forward[1]
            >> result.fRadius
            >> result.minUseDistSq
            >> result.wOverlapNode[0]
            >> result.wOverlapNode[1]
            >> result.wChainId
            >> result.wChainDepth
            >> result.wChainParent
            >> result.totalLinkCount
            >> result.wChainId
            >> result.LinksPtr;

    // idfk what this does
    // Load_Stream(0, varpathnode_constant_t, 0x44u);
    // varScriptString = &varpathnode_constant_t->targetname;
    // Load_Stream(0, &varpathnode_constant_t->targetname, 2u);
    // *varScriptString = (unsigned __int16)*(const char **)((char *)varXAssetList->stringList.strings
    //                                                       + __ROL4__(*varScriptString, 2));
    // varScriptString = &varpathnode_constant_t->script_linkName;
    // Load_Stream(0, &varpathnode_constant_t->script_linkName, 2u);
    // *varScriptString = (unsigned __int16)*(const char **)((char *)varXAssetList->stringList.strings
    //                                                       + __ROL4__(*varScriptString, 2));
    // varScriptString = &varpathnode_constant_t->script_noteworthy;
    // Load_Stream(0, &varpathnode_constant_t->script_noteworthy, 2u);
    // *varScriptString = (unsigned __int16)*(const char **)((char *)varXAssetList->stringList.strings
    //                                                       + __ROL4__(*varScriptString, 2));
    // varScriptString = &varpathnode_constant_t->target;
    // Load_Stream(0, &varpathnode_constant_t->target, 2u);
    // *varScriptString = (unsigned __int16)*(const char **)((char *)varXAssetList->stringList.strings
    //                                                       + __ROL4__(*varScriptString, 2));
    // varScriptString = &varpathnode_constant_t->animscript;
    // Load_Stream(0, &varpathnode_constant_t->animscript, 2u);
    // v1 = varpathnode_constant_t;
    // *varScriptString = (unsigned __int16)*(const char **)((char *)varXAssetList->stringList.strings
    //                                                       + __ROL4__(*varScriptString, 2));
    // if (result.LinksPtr)
    // {
    //     totalLinkCount = v1->totalLinkCount;
    //     v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
    //     v1->Links = (PathLink *)v3;
    //     g_streamPos = v3;
    //     varpathlink_t = (pathlink_s *)v3;
    //     Load_Stream(1, v3, 4 * (totalLinkCount + __ROL4__(totalLinkCount, 1)));
    // }
}


// ?Load_XModelCollSurfArray@@YAX_NH@Z at 0x822a6780
QVector<XModelCollSurf> Assets::Load_XModelCollSurfArray(QDataStream *aStream, int count)
{
    QVector<XModelCollSurf> result;

    for (int i = 0; i < count; i++) {
        XModelCollSurf xModelCollSurf_s;

        *aStream
                >> xModelCollSurf_s.mins[0]
                >> xModelCollSurf_s.mins[1]
                >> xModelCollSurf_s.mins[2]
                >> xModelCollSurf_s.maxs[0]
                >> xModelCollSurf_s.maxs[1]
                >> xModelCollSurf_s.maxs[2]
                >> xModelCollSurf_s.boneIdx
                >> xModelCollSurf_s.contents
                >> xModelCollSurf_s.surfFlags;

        result << xModelCollSurf_s;
    }
    return result;
}


// ?Load_PhysPreset@@YAX_N@Z at 0x822a6850
PhysPreset Assets::Load_PhysPreset(QDataStream *aStream)
{
    PhysPreset result;

    *aStream
            >> result.namePtr
            >> result.type
            >> result.mass
            >> result.bounce
            >> result.friction
            >> result.bulletForceScale
            >> result.explosiveForceScale
            >> result.sndAliasPrefixPtr
            >> result.piecesSpreadFraction
            >> result.piecesUpwardVelocity
            >> result.tempDefaultToCylinder;

    if (result.namePtr == -1) {
        result.name = Load_XStringCustom(aStream);
    }
    if (result.sndAliasPrefixPtr == -1) {
        result.sndAliasPrefix = Load_XStringCustom(aStream);
    }

    return result;
}


// ?Load_MaterialArgumentDef@@YAX_N@Z at 0x822a68c8
MaterialArgumentDef Assets::Load_MaterialArgumentDef(QDataStream *aStream, MaterialShaderArgument aArgument)
{
    MaterialArgumentDef result;

    if (aArgument.type == 1 || aArgument.type == 7)
    {
        if (aArgument.u.codeSampler)
        {
            if (aArgument.u.codeSampler == -1)
            {
                //varMaterialArgumentDef->codeSampler = (unsigned int)v3;
                //varfloat = (float *)v3;
                //Load_Stream(1, v3, 0x10u);
            }
            else
            {
                // Resolve contents from g_streamBlocks
                //varMaterialArgumentDef->codeSampler = (unsigned int)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                //                                                                            + (((codeSampler - 1) >> 26) & 0x38)))[(codeSampler - 1) & 0x1FFFFFFF];
            }
        }
    }
    return result;
}


// ?Load_GfxPixelShaderLoadDef@@YAX_N@Z at 0x822a6950
GfxPixelShaderLoadDef Assets::Load_GfxPixelShaderLoadDef(QDataStream *aStream)
{
    GfxPixelShaderLoadDef result;

    *aStream
            >> result.cachedPartPtr
            >> result.physicalPartPtr
            >> result.cachedPartSize
            >> result.physicalPartSize;

    if (result.physicalPartPtr)
    {
        for (int i = 0; i < result.physicalPartSize; i++) {
            unsigned __int8 physicalPart;

            *aStream >> physicalPart;

            result.physicalPart << physicalPart;
        }
    }
    if (result.cachedPartPtr)
    {
        for (int i = 0; i < result.cachedPartSize; i++) {
            unsigned __int8 cachedPart;

            *aStream >> cachedPart;

            result.cachedPart << cachedPart;
        }
    }

    return result;
}


// ?Load_GfxVertexShaderLoadDef@@YAX_N@Z at 0x822a69f8
GfxVertexShaderLoadDef Assets::Load_GfxVertexShaderLoadDef(QDataStream *aStream)
{
    GfxVertexShaderLoadDef result;

    *aStream
            >> result.cachedPartPtr
            >> result.physicalPartPtr
            >> result.cachedPartSize
            >> result.physicalPartSize;

    if (result.physicalPartPtr)
    {
        for (int i = 0; i < result.physicalPartSize; i++) {
            unsigned __int8 physicalPart;

            *aStream >> physicalPart;

            result.physicalPart << physicalPart;
        }
    }
    if (result.cachedPartPtr)
    {
        for (int i = 0; i < result.cachedPartSize; i++) {
            unsigned __int8 cachedPart;

            *aStream >> cachedPart;

            result.cachedPart << cachedPart;
        }
    }
    return result;
}


// ?Load_GfxImagePixels@@YAX_N@Z at 0x822a6aa0
QVector<quint8> Assets::Load_GfxImagePixels(QDataStream *aStream, GfxImage aGfxImage)
{
    QVector<quint8> result;

    if (aGfxImage.pixelsPtr)
    {
        aStream->skipRawData(aGfxImage.cardMemory.platform[0]);
    }

    return result;
}


// ?Load_GfxTexture@@YAX_N@Z at 0x822a6b28
GfxTexture Assets::Load_GfxTexture(QDataStream *aStream, GfxTexture aGfxTexture, GfxImageLoadDef aGfxImageLoadDef)
{
    unsigned __int8 *v1; // r4
    D3DBaseTexture *basemap; // r11
    unsigned __int8 *v3; // r4
    unsigned __int8 *v4; // r4

    if ((aGfxImageLoadDef.flags & 4) != 0)
    {
        if (aGfxTexture.basemap)
        {
            v1 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v1;
            varGfxTexture->basemap = (D3DBaseTexture *)v1;
            varIDirect3DCubeTexture9 = (D3DCubeTexture *)v1;
            Load_Stream(1, v1, 0x34u);
        }
    }
    else
    {
        basemap = aGfxTexture.basemap;
        if ( (aGfxImageLoadDef.flags & 8) != 0 )
        {
            if ( basemap )
            {
                v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
                g_streamPos = v3;
                aGfxTexture.basemap = (D3DBaseTexture *)v3;
                varIDirect3DVolumeTexture9 = (D3DVolumeTexture *)v3;
                Load_Stream(1, v3, 0x34u);
            }
        }
        else if ( basemap )
        {
            v4 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v4;
            aGfxTexture.basemap = (D3DBaseTexture *)v4;
            varIDirect3DTexture9 = (D3DTexture *)v4;
            Load_Stream(1, v4, 0x34u);
        }
    }
}


// ?Load_XSurfaceVertexInfo@@YAX_N@Z at 0x822a6c08
XSurfaceVertexInfo Assets::Load_XSurfaceVertexInfo(QDataStream *aStream)
{
    unsigned __int16 *vertsBlend; // r10
    int v2; // r10
    int v3; // r9
    int v4; // r8
    int v5; // r6
    unsigned __int8 *v6; // r4

    XSurfaceVertexInfo result;

    *aStream
            >> result.vertCount[0]
            >> result.vertCount[1]
            >> result.vertCount[2]
            >> result.vertCount[3]
            >> result.vertsBlendPtr;

    if (result.vertsBlendPtr)
    {
        if (result.vertsBlendPtr == -1)
        {
            aStream->skipRawData(2 * (7 * result.vertCount[3] + 5 * result.vertCount[2] + 3 * result.vertCount[1] + result.vertCount[0]));
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //varXSurfaceVertexInfo->vertsBlend = (unsigned __int16 *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                                + ((((unsigned int)varXSurfaceVertexInfo->vertsBlend
            //                                                                                     - 1) >> 26) & 0x38)))[((int)varXSurfaceVertexInfo->vertsBlend - 1) & 0x1FFFFFFF];
        }
    }
}


// ?Load_XSurfaceCollisionTree@@YAX_N@Z at 0x822a6d00
XSurfaceCollisionTree Assets::Load_XSurfaceCollisionTree(QDataStream *aStream)
{
    XSurfaceCollisionTree result;

    *aStream
            >> result.trans[0]
            >> result.trans[1]
            >> result.trans[2]
            >> result.scale[0]
            >> result.scale[1]
            >> result.scale[2]
            >> result.nodeCount
            >> result.leafCount;

    for (int i = 0; i < result.nodeCount; i++) {
        XSurfaceCollisionNode collisionNode;

        *aStream
                >> collisionNode.aabb.mins[0]
                >> collisionNode.aabb.mins[1]
                >> collisionNode.aabb.mins[2]
                >> collisionNode.aabb.maxs[0]
                >> collisionNode.aabb.maxs[1]
                >> collisionNode.aabb.maxs[2]
                >> collisionNode.childBeginIndex
                >> collisionNode.childCount;

        result.nodes << collisionNode;
    }
    for (int i = 0; i < result.leafCount; i++) {
        XSurfaceCollisionLeaf collisionLeaf;

        *aStream >> collisionLeaf.triangleBeginIndex;

        result.leafs << collisionLeaf;
    }
    return result;
}


// ?Load_MaterialInfo@@YAX_N@Z at 0x822a6dc0
MaterialInfo Assets::Load_MaterialInfo(QDataStream *aStream)
{
    MaterialInfo result;

    *aStream
            >> result.namePtr
            >> result.gameFlags
            >> result.sortKey
            >> result.textureAtlasRowCount
            >> result.textureAtlasColumnCount
            >> result.drawSurf.objectId
            >> result.drawSurf.reflectionProbeIndex
            >> result.drawSurf.customIndex
            >> result.drawSurf.materialSortedIndex
            >> result.drawSurf.prepass
            >> result.drawSurf.primaryLightIndex
            >> result.drawSurf.surfType
            >> result.drawSurf.primarySortKey
            >> result.drawSurf.unused
            >> result.surfaceTypeBits;

    result.name = Load_XStringCustom(aStream);

    return result;
}


// ?Load_XAUDIOCHANNELMAP@@YAX_N@Z at 0x822a6e10
XAUDIOCHANNELMAP Assets::Load_XAUDIOCHANNELMAP(QDataStream *aStream)
{
    XAUDIOCHANNELMAP result;

    *aStream
            >> result.EntryCount
            >> result.paEntriesPtr;

    if (result.paEntriesPtr)
    {
        for (int i = 0; i < result.EntryCount; i++) {
            XAUDIOCHANNELMAPENTRY entry;

            *aStream
                    >> entry.InputChannel
                    >> entry.OutputChannel
                    >> entry.Volume;

            result.paEntries << entry;
        }
    }
    return result;
}


// ?Load_SndCurve@@YAX_N@Z at 0x822a6e88
SndCurve Assets::Load_SndCurve(QDataStream *aStream)
{
    SndCurve result;

    *aStream
            >> result.filenamePtr
            >> result.knotCount;

    for (int i = 0; i < 8; i++) {
        *aStream
                >> result.knots[i][0]
                >> result.knots[i][1];
    }

    if (result.filenamePtr == -1) {
        result.filename = Load_XStringCustom(aStream);
    }
    return result;
}


// ?Load_StreamFileNameRaw@@YAX_N@Z at 0x822a6ee0
StreamFileNameRaw Assets::Load_StreamFileNameRaw(QDataStream *aStream)
{
    StreamFileNameRaw result;

    *aStream
            >> result.dirPtr
            >> result.namePtr;

    if (result.dirPtr == -1) {
        result.dir = Load_XStringCustom(aStream);
    }
    if (result.namePtr == -1) {
        result.name = Load_XStringCustom(aStream);
    }

    return result;
}


// ?Load_SndDriverGlobals@@YAX_N@Z at 0x822a6f48
XSoundDriverGlobals Assets::Load_SndDriverGlobals(QDataStream *aStream)
{
    XSoundDriverGlobals result;

    *aStream
            >> result.reverbSettingsPtr
            >> result.namePtr;

    if (result.reverbSettingsPtr)
    {
        XAudioReverbSettings xaReverbSettings;

        *aStream
                >> xaReverbSettings.presetOverridden
                >> xaReverbSettings.reverbSettings.ReflectionsDelay
                >> xaReverbSettings.reverbSettings.ReverbDelay
                >> xaReverbSettings.reverbSettings.RearDelay
                >> xaReverbSettings.reverbSettings.PositionLeft
                >> xaReverbSettings.reverbSettings.PositionRight
                >> xaReverbSettings.reverbSettings.PositionMatrixLeft
                >> xaReverbSettings.reverbSettings.PositionMatrixRight
                >> xaReverbSettings.reverbSettings.EarlyDiffusion
                >> xaReverbSettings.reverbSettings.LateDiffusion
                >> xaReverbSettings.reverbSettings.LowEQGain
                >> xaReverbSettings.reverbSettings.LowEQCutoff
                >> xaReverbSettings.reverbSettings.HighEQGain
                >> xaReverbSettings.reverbSettings.HighEQCutoff
                >> xaReverbSettings.reverbSettings.RoomFilterFreq
                >> xaReverbSettings.reverbSettings.RoomFilterMain
                >> xaReverbSettings.reverbSettings.RoomFilterHF
                >> xaReverbSettings.reverbSettings.ReflectionsGain
                >> xaReverbSettings.reverbSettings.ReverbGain
                >> xaReverbSettings.reverbSettings.DecayTime
                >> xaReverbSettings.reverbSettings.Density
                >> xaReverbSettings.reverbSettings.RoomSize;

        result.reverbSettings = xaReverbSettings;
    }
    if (result.namePtr == -1) {
        result.name = Load_XStringCustom(aStream);
    }
}


// ?Load_XaSeekTable@@YAX_N@Z at 0x822a6fe0
XaSeekTable Assets::Load_XaSeekTable(QDataStream *aStream)
{
    XaSeekTable result;

    *aStream
            >> result.size
            >> result.dataPtr;

    if (result.dataPtr)
    {
        for (int i = 0; i < result.size; i++) {
            unsigned int data;

            *aStream >> data;

            result.data << data;
        }
    }
}


// ?Load_XAUDIOPACKET_ALIGNED@@YAX_N@Z at 0x822a7058
XAUDIOPACKET_ALIGNED Assets::Load_XAUDIOPACKET_ALIGNED(QDataStream *aStream)
{
    XAUDIOPACKET_ALIGNED result;

    *aStream
            >> result.pBufferPtr
            >> result.BufferSize
            >> result.LoopCount;

    for (int i = 0; i < 6; i++) {
        *aStream
                >> result.XMALoop[i].LoopStart
                >> result.XMALoop[i].LoopEnd
                >> result.XMALoop[i].LoopSubframeEnd
                >> result.XMALoop[i].LoopSubframeSkip;
    }

    *aStream >> result.pContextPtr;

    if (result.pBufferPtr)
    {
        for (int i = 0; i < result.BufferSize; i++) {
            char bufferChar;

            *aStream >> bufferChar;

            result.pBuffer << bufferChar;
        }
    }
    if (result.pContextPtr)
    {
        *aStream >> result.pContext;
    }
}


// ?Load_XAnimNotifyInfo@@YAX_N@Z at 0x822a70f8
XAnimNotifyInfo Assets::Load_XAnimNotifyInfo(QDataStream *aStream)
{
    XAnimNotifyInfo result;

    *aStream
            >> result.name
            >> result.time;

    // Fill out parsing
    aStream->skipRawData(2);

    return result;
}


// ?Load_XAnimDynamicFrames@@YAX_N@Z at 0x822a7168
XAnimDynamicFrames Assets::Load_XAnimDynamicFrames(QDataStream *aStream,
                                                   XAnimPartTrans aXAnimPartTrans,
                                                   XAnimDynamicIndices aXAnimDynamicIndices,
                                                   XAnimDynamicFrames aXAnimDynamicFrames)
{
    XAnimDynamicFrames result;

    if (aXAnimPartTrans.smallTrans)
    {
        if (aXAnimDynamicIndices._1[0]) // Check this should be [0]
        {
            int readSize = aXAnimPartTrans.size + 1;
            if (aXAnimPartTrans.size == 0)
                readSize = 0;
            // Fill out parsing
            aStream->skipRawData(3 * readSize);
        }
    }
    else if (aXAnimDynamicFrames._1)
    {
        int readSize = aXAnimPartTrans.size + 1;
        if (aXAnimPartTrans.size == 0)
            readSize = 0;
        // Fill out parsing
        aStream->skipRawData(6 * readSize);
    }

    return result;
}


// ?Load_XAnimDynamicIndicesTrans@@YAX_N@Z at 0x822a7228
XAnimDynamicIndices Assets::Load_XAnimDynamicIndicesTrans(QDataStream *aStream,
                                                          XAnimParts aXAnimParts,
                                                          XAnimPartTrans aXAnimPartTrans)
{
    if (aXAnimParts.numframes >= 0x100u)
    {
        // Fill out parsing
        aStream->skipRawData(2 * (aXAnimPartTrans.size + 1));
    }
    else
    {
        // Fill out parsing
        aStream->skipRawData(aXAnimPartTrans.size + 1);
    }
}


// ?Load_XAnimDynamicIndicesDeltaQuat@@YAX_N@Z at 0x822a7278
XAnimDynamicIndices Assets::Load_XAnimDynamicIndicesDeltaQuat(QDataStream *aStream,
                                                              XAnimDeltaPartQuat aXAnimDeltaPartQuat,
                                                              XAnimParts aXAnimParts)
{
    XAnimDynamicIndices result;

    if (aXAnimParts.numframes >= 0x100u)
    {
        // Fill out parsing
        aStream->skipRawData(2 * (aXAnimDeltaPartQuat.size + 1));
    }
    else
    {
        // Fill out parsing
        aStream->skipRawData(aXAnimDeltaPartQuat.size + 1);
    }

    return result;
}


// ?Load_XAnimIndices@@YAX_N@Z at 0x822a72c8
XAnimIndices Assets::Load_XAnimIndices(QDataStream *aStream,
                                       XAnimParts aXAnimParts,
                                       XAnimIndices aXAnimIndices)
{
    XAnimIndices result;

    if (aXAnimParts.numframes >= 0x100u)
    {
        if (aXAnimIndices._1)
        {
            // Fill out parsing
            aStream->skipRawData(2 * aXAnimParts.indexCount);
        }
    }
    else if (aXAnimIndices._1)
    {
        // Fill out parsing
        aStream->skipRawData(aXAnimParts.indexCount);
    }
    return result;
}


// ?Load_XStringArray@@YAX_NH@Z at 0x822a73b8
QStringList Assets::Load_XStringArray(QDataStream *aStream, int count)
{
    QStringList result;

    for (int i = 0; i < count; i++) {
        result << Load_XString(aStream);
    }

    return result;
}


// ?Load_ScriptStringArray@@YAX_NH@Z at 0x822a7460
QVector<ScriptString> Assets::Load_ScriptStringArray(QDataStream *aStream, int count)
{
    QVector<ScriptString> result;

    for (int i = 0; i < count; i++) {
        result << Load_ScriptString(aStream);
    }

    return result;
}


// ?Load_GfxLightRegionHullArray@@YAX_NH@Z at 0x822a74d8
QVector<GfxLightRegionHull> Assets::Load_GfxLightRegionHullArray(QDataStream *aStream, int count)
{
    QVector<GfxLightRegionHull> result;

    for (int i = 0; i < count; i++) {
        result << Load_GfxLightRegionHull(aStream);
    }

    return result;
}


// ?Load_GfxShadowGeometryArray@@YAX_NH@Z at 0x822a7538
QVector<GfxShadowGeometry> Assets::Load_GfxShadowGeometryArray(QDataStream *aStream, int count)
{
    QVector<GfxShadowGeometry> result;

    for (int i = 0; i < count; i++) {
        result << Load_GfxShadowGeometry(aStream);
    }

    return result;
}


// ?Load_StringTable@@YAX_N@Z at 0x822a7650
StringTable Assets::Load_StringTable(QDataStream *aStream)
{
    StringTable result;

    *aStream
            >> result.namePtr
            >> result.columnCount
            >> result.rowCount
            >> result.valuesPtr;

    if (result.namePtr == -1) {
        result.name = Load_XStringCustom(aStream);
    }
    if (result.valuesPtr)
    {
        result.values = Load_XStringArray(aStream, result.rowCount * result.columnCount);
    }

    return result;
}


// ?Load_RawFilePtr@@YAX_N@Z at 0x822a76e8
RawFile Assets::Load_RawFilePtr(QDataStream *aStream)
{
    RawFile result;
    qint32 rawFilePtr;

    *aStream >> rawFilePtr;

    if (rawFilePtr)
    {
        if (rawFilePtr != -1 && rawFilePtr != -2)
        {
            // Resolve contents from g_streamBlocks
            //*varRawFilePtr = *(RawFile **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                      + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            //DB_PopStreamPos();
            return result;
        }
        result = Load_RawFile(aStream);
    }
    return result;
}


// ?Load_LocalizeEntryPtr@@YAX_N@Z at 0x822a77d0
XLocalizeEntry Assets::Load_LocalizeEntryPtr(QDataStream *aStream)
{
    XLocalizeEntry result;
    qint32 localizeEntryPtr;

    *aStream >> localizeEntryPtr;

    if (localizeEntryPtr)
    {
        if (localizeEntryPtr != -1 && localizeEntryPtr != -2)
        {
            //*varLocalizeEntryPtr = *(LocalizeEntry **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                  + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            //DB_PopStreamPos();
            return result;
        }
        result = Load_LocalizeEntry(aStream);
    }
    return result;
}

// ?Load_MultiDef@@YAX_N@Z at 0x822a78b8
XMultiDef Assets::Load_MultiDef(QDataStream *aStream)
{
    XMultiDef result;

    for (int i = 0; i < 32; i++) {
        *aStream >> result.dvarListPtrs[i];
    }
    for (int i = 0; i < 32; i++) {
        *aStream >> result.dvarStrPtrs[i];
    }
    for (int i = 0; i < 32; i++) {
        *aStream >> result.dvarValue[i];
    }

    *aStream
            >> result.count
            >> result.strDef;

    for (int i = 0; i < 32; i++) {
        if (result.dvarListPtrs[i] == -1) {
            result.dvarList << Load_XStringCustom(aStream);
        }
    }
    for (int i = 0; i < 32; i++) {
        if (result.dvarStrPtrs[i] == -1) {
            result.dvarStr << Load_XStringCustom(aStream);
        }
    }

    return result;
}


// ?Load_Operand@@YAX_N@Z at 0x822a7958
XOperand Assets::Load_Operand(QDataStream *aStream)
{
    XOperand result;

    *aStream >> result.dataType;

    if (result.dataType == VAL_STRING)
    {
        result.stringVal = Load_XString(aStream);
    }
    else if (result.dataType == VAL_FLOAT)
    {
        *aStream >> result.floatVal;
    }
    else if (result.dataType == VAL_INT)
    {
        *aStream >> result.intVal;
    }

    return result;
}


// ?Load_ComPrimaryLightArray@@YAX_NH@Z at 0x822a79d0
QVector<XComPrimaryLight> Assets::Load_ComPrimaryLightArray(QDataStream *aStream, int count)
{
    QVector<XComPrimaryLight> result;

    for (int i = 0; i < count; i++) {
        XComPrimaryLight comPrimaryLight;

        *aStream
                >> comPrimaryLight.type
                >> comPrimaryLight.canUseShadowMap
                >> comPrimaryLight.exponent
                >> comPrimaryLight.unused
                >> comPrimaryLight.color[0]
                >> comPrimaryLight.color[1]
                >> comPrimaryLight.color[2]
                >> comPrimaryLight.dir[0]
                >> comPrimaryLight.dir[1]
                >> comPrimaryLight.dir[2]
                >> comPrimaryLight.origin[0]
                >> comPrimaryLight.origin[1]
                >> comPrimaryLight.origin[2]
                >> comPrimaryLight.radius
                >> comPrimaryLight.cosHalfFovOuter
                >> comPrimaryLight.cosHalfFovInner
                >> comPrimaryLight.cosHalfFovExpanded
                >> comPrimaryLight.rotationLimit
                >> comPrimaryLight.translationLimit
                >> comPrimaryLight.defNamePtr;

        result << comPrimaryLight;
    }
    return result;
}


CBrushSide Assets::Load_cbrushside_t(QDataStream *aStream)
{
    CBrushSide result;

    *aStream
            >> result.planePtr
            >> result.materialNum
            >> result.firstAdjacentSideOffset
            >> result.edgeCount;

    if (result.planePtr == -1) {
        result.plane = Load_CPlane(aStream);
    }

    return result;
}


// ?Load_CBrush@@YAX_N@Z at 0x822a7a48
CBrush Assets::Load_CBrush(QDataStream *aStream)
{
    CBrush result;

    *aStream
            >> result.mins[0]
            >> result.mins[1]
            >> result.mins[2]
            >> result.contents
            >> result.maxs[0]
            >> result.maxs[1]
            >> result.maxs[2]
            >> result.numsides
            >> result.sidesPtr
            >> result.axialMaterialNum[0][0]
            >> result.axialMaterialNum[0][1]
            >> result.axialMaterialNum[0][2]
            >> result.axialMaterialNum[1][0]
            >> result.axialMaterialNum[1][1]
            >> result.axialMaterialNum[1][2]
            >> result.baseAdjacentSidePtr
            >> result.firstAdjacentSideOffsets[0][0]
            >> result.firstAdjacentSideOffsets[0][1]
            >> result.firstAdjacentSideOffsets[0][2]
            >> result.firstAdjacentSideOffsets[1][0]
            >> result.firstAdjacentSideOffsets[1][1]
            >> result.firstAdjacentSideOffsets[1][2]
            >> result.edgeCount[0][0]
            >> result.edgeCount[0][1]
            >> result.edgeCount[0][2]
            >> result.edgeCount[1][0]
            >> result.edgeCount[1][1]
            >> result.edgeCount[1][2];

    if (result.sidesPtr)
    {
        if (result.sidesPtr == -1)
        {
            for (int i = 0; i < result.numsides; i++) {
                result.sides << Load_cbrushside_t(aStream);
            }
        }
        else
        {
            // Resolve from g_streamBlocks
            //varcbrush_t->sides = (cbrushside_t *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                             + (((unsigned int)(&varcbrush_t->sides[-1].edgeCount + 1) >> 26) & 0x38)))[(int)(&varcbrush_t->sides[-1].edgeCount + 1) & 0x1FFFFFFF];
        }
    }
    if (result.baseAdjacentSidePtr)
    {
        if (result.baseAdjacentSidePtr == -1)
        {
            *aStream >> result.baseAdjacentSide;
        }
        else
        {
            // Resolve from g_streamBlocks
            //v1->baseAdjacentSide = &(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                               + (((unsigned int)(v1->baseAdjacentSide - 1) >> 26) & 0x38)))[(int)(v1->baseAdjacentSide - 1) & 0x1FFFFFFF];
        }
    }

    return result;
}


// ?Load_CollisionPartitionArray@@YAX_NH@Z at 0x822a7b50
QVector<CollisionPartition> Assets::Load_CollisionPartitionArray(QDataStream *aStream, int count)
{
    QVector<CollisionPartition> result;

    for (int i = 0; i < count; i++) {
        result << Load_CollisionPartition(aStream);
    }

    return result;
}


// ?Load_CLeafBrushNode@@YAX_N@Z at 0x822a7bb0
CLeafBrushNode Assets::Load_CLeafBrushNode(QDataStream *aStream)
{
    CLeafBrushNode result;

    *aStream
            >> result.axis
            >> result.leafBrushCount
            >> result.contents
            >> result.data;

    result.data = Load_CLeafBrushNodeData(aStream);

    return result;
}


// ?Load_cNode_tArray@@YAX_NH@Z at 0x822a7c00
QVector<cNode_t> Assets::Load_cNode_tArray(QDataStream *aStream, int count)
{
    QVector<cNode_t> result;


    for (int i = 0; i < count; i++) {
        cNode_t cNode;

        *aStream
                >> cNode.planePtr
                >> cNode.children[0]
                >> cNode.children[1];

        if (cNode.planePtr)
        {
            if (cNode.planePtr == -1)
            {
                cNode.plane = Assets::Load_CPlane(aStream);
            }
            else
            {
                // Resolve contents from g_streamBlocks
                //varcNode_t->plane = (cplane_s *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                //                                                        + (((unsigned int)&plane[-1].pad[1] >> 26) & 0x38)))[(unsigned int)&plane[-1].pad[1] & 0x1FFFFFFF];
            }
        }

        result << cNode;
    }

    return result;
}


// ?Load_MapEntsPtr@@YAX_N@Z at 0x822a7cc8
void Assets::Load_MapEntsPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    MapEnts **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varMapEntsPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varMapEntsPtr;
    if ( *varMapEntsPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varMapEntsPtr = *(MapEnts **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                  + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varMapEntsPtr = (MapEnts *)v3;
        varMapEnts = (MapEnts *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_MapEnts(1);
        v5 = varMapEntsPtr;
        *v5 = (MapEnts *)DB_AddXAsset((XAssetHeader *)0x10, (XAssetHeader *)*varMapEntsPtr, v6);
        if ( inserted )
            *inserted = *varMapEntsPtr;
    }
    DB_PopStreamPos();
}


// ?Load_GameWorldMpPtr@@YAX_N@Z at 0x822a7db0
void Assets::Load_GameWorldMpPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    GameWorldMp **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varGameWorldMpPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varGameWorldMpPtr;
    if ( *varGameWorldMpPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varGameWorldMpPtr = *(GameWorldMp **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                          + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varGameWorldMpPtr = (GameWorldMp *)v3;
        varGameWorldMp = (GameWorldMp *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_GameWorldMp(1);
        v5 = varGameWorldMpPtr;
        *v5 = (GameWorldMp *)DB_AddXAsset((XAssetHeader *)0xF, (XAssetHeader *)*varGameWorldMpPtr, v6);
        if ( inserted )
            *inserted = *varGameWorldMpPtr;
    }
    DB_PopStreamPos();
}


// ?Load_pathnode_tree_info_t@@YAX_N@Z at 0x822a7e98
void Assets::Load_pathnode_tree_info_t(QDataStream *aStream)
{
    if ( varpathnode_tree_t->axis < 0 )
    {
        varpathnode_tree_nodes_t = (PathNodeTreeNodes *)varpathnode_tree_info_t;
        Load_PathNodeTreeNodes(0);
    }
    else
    {
        varpathnode_tree_ptr = (pathnode_tree_t **)varpathnode_tree_info_t;
        LoadPathNodeTreeArray(0, 2);
    }
}


// ?Load_pathnode_t@@YAX_N@Z at 0x822a7ed8
void Assets::Load_pathnode_t(QDataStream *aStream)
{
    Load_Stream(0, varpathnode_t, 0x80u);
    varpathnode_constant_t = &varpathnode_t->constant;
    Load_PathNodeConstant(0);
}


// ?Load_cbrushside_tArray@@YAX_NH@Z at 0x822a7f28
void Assets::Load_cbrushside_tArray(QDataStream *aStream, int count)
{
    int v2; // r31
    CBrushSide *v3; // r30
    CPlane *plane; // r11
    unsigned __int8 *v5; // r4

    v2 = count;
    Load_Stream(1, varcbrushside_t, 12 * count);
    v3 = varcbrushside_t;
    if ( v2 > 0 )
    {
        do
        {
            varcbrushside_t = v3;
            Load_Stream(0, v3, 0xCu);
            plane = varcbrushside_t->plane;
            if ( varcbrushside_t->plane )
            {
                if ( plane == (CPlane *)-1 )
                {
                    v5 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
                    g_streamPos = v5;
                    varcplane_t = (cplane_s *)v5;
                    varcbrushside_t->plane = (cplane_s *)v5;
                    Load_Stream(1, v5, 0x14u);
                }
                else
                {
                    varcbrushside_t->plane = (cplane_s *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                 + (((unsigned int)&plane[-1].pad[1] >> 26) & 0x38)))[(unsigned int)&plane[-1].pad[1] & 0x1FFFFFFF];
                }
            }
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_PhysPresetPtr@@YAX_N@Z at 0x822a7ff8
void Assets::Load_PhysPresetPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    PhysPreset **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varPhysPresetPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varPhysPresetPtr;
    if ( *varPhysPresetPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varPhysPresetPtr = *(PhysPreset **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                        + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varPhysPresetPtr = (PhysPreset *)v3;
        varPhysPreset = (PhysPreset *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_PhysPreset(1);
        v5 = varPhysPresetPtr;
        *v5 = (PhysPreset *)DB_AddXAsset((XAssetHeader *)1, (XAssetHeader *)*varPhysPresetPtr, v6);
        if ( inserted )
            *inserted = *varPhysPresetPtr;
    }
    DB_PopStreamPos();
}


// ?Load_MaterialShaderArgument@@YAX_N@Z at 0x822a80e0
MaterialShaderArgument Assets::Load_MaterialShaderArgument(QDataStream *aStream)
{
    MaterialShaderArgument result;

    *aStream
            >> result.type
            >> result.dest;

    result.u = Assets::Load_MaterialArgumentDef(aStream, result);
}


// ?Load_MaterialPixelShaderProgram@@YAX_N@Z at 0x822a8130
MaterialPixelShaderProgram Assets::Load_MaterialPixelShaderProgram(QDataStream *aStream)
{
    MaterialPixelShaderProgram result;

    *aStream >> result.psPtr;

    result.loadDef = Load_GfxPixelShaderLoadDef(aStream);

    if ( varMaterialPixelShader->prog.loadDef.physicalPartSize )
    {
        ps = varMaterialPixelShader->prog.ps;
        HIDWORD(v2) = varMaterialPixelShader->prog.loadDef.physicalPart;
        LODWORD(v2) = 0;
        *(_QWORD *)&ps->Common = v2;
        *(_QWORD *)&ps->Fence = v2;
        *(_QWORD *)&ps->Identifier = v2;
        *(_QWORD *)&ps[1].Common = v2;
        *(_QWORD *)&ps[1].Fence = v2;
        ps->Common = 7;
        ps->ReferenceCount = 1;
        ps->BaseFlush = -65536;
        ps[1].Common = HIDWORD(v2);
    }
    else
    {
        varMaterialPixelShader->prog.ps = 0;
    }

    return result;
}


// ?Load_MaterialVertexShaderProgram@@YAX_N@Z at 0x822a81e8
void Assets::Load_MaterialVertexShaderProgram(QDataStream *aStream)
{
    Load_Stream(0, varMaterialVertexShaderProgram, 0xCu);
    varGfxVertexShaderLoadDef = (GfxVertexShaderLoadDef *)varMaterialVertexShaderProgram;
    Load_GfxVertexShaderLoadDef(0);
    XGRegisterVertexShader(
                varMaterialVertexShader->prog.vs,
                (unsigned int)varMaterialVertexShader->prog.loadDef.physicalPart);
}


// ?Load_GfxImageLoadDef@@YAX_N@Z at 0x822a8248
GfxImageLoadDef Assets::Load_GfxImageLoadDef(QDataStream *aStream)
{
    GfxImageLoadDef result;

    *aStream
            >> result.levelCount
            >> result.flags
            >> result.dimensions[0]
            >> result.dimensions[1]
            >> result.dimensions[2]
            >> result.format;

    result.texture = Assets::Load_GfxTexture(aStream);

    return result;
}

typedef GfxTexture GfxTextureLoad;

// ?Load_GfxTextureLoad@@YAX_N@Z at 0x822a82a8
GfxTextureLoad Assets::Load_GfxTextureLoad(QDataStream *aStream)
{
    GfxTextureLoad result;

    *aStream >> result.basemapPtr;

    if (result.basemapPtr)
    {
        if (result.basemapPtr == -1 || result.basemapPtr == -2)
        {
            result.loadDef = Assets::Load_GfxImageLoadDef(aStream);
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //varGfxTextureLoad->basemap = *(D3DBaseTexture **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                         + ((((unsigned int)&basemap[-1].Format.dword[5]
            //                                                                              + 3) >> 26) & 0x38)))[((unsigned int)&basemap[-1].Format.dword[5] + 3) & 0x1FFFFFFF];
        }
    }

    return result;
}


// ?Load_XRigidVertList@@YAX_N@Z at 0x822a83a0
XRigidVertList Assets::Load_XRigidVertList(QDataStream *aStream)
{
    XRigidVertList result;

    *aStream
            >> result.boneOffset
            >> result.vertCount
            >> result.triOffset
            >> result.triCount
            >> result.collisionTreePtr;

    if (result.collisionTreePtr)
    {
        if (result.collisionTreePtr == -1)
        {
            result.collisionTree = Assets::Load_XSurfaceCollisionTree(aStream);
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //varXRigidVertList->collisionTree = (XSurfaceCollisionTree *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                                    + ((((unsigned int)&varXRigidVertList->collisionTree[-1].leafs
            //                                                                                         + 3) >> 26) & 0x38)))[((int)&varXRigidVertList->collisionTree[-1].leafs + 3) & 0x1FFFFFFF];
        }
    }
}


// ?Load_snd_alias_list_name@@YAX_N@Z at 0x822a8450
void Assets::Load_snd_alias_list_name(QDataStream *aStream)
{
    Load_Stream(0, varsnd_alias_list_name, 4u);
    Load_SndAliasCustom(varsnd_alias_list_name);
}


// ?Load_XAUDIOCHANNELMAPArray@@YAX_NH@Z at 0x822a8490
QVector<XAUDIOCHANNELMAP> Assets::Load_XAUDIOCHANNELMAPArray(QDataStream *aStream, int count)
{
    QVector<XAUDIOCHANNELMAP> result;

    for (int i = 0; i < count; i++) {
        result << Assets::Load_XAUDIOCHANNELMAP(aStream);
    }

    return result;
}


// ?Load_SndCurvePtr@@YAX_N@Z at 0x822a8528
SndCurve Assets::Load_SndCurvePtr(QDataStream *aStream)
{
    SndCurve result;
    qint32 sndCurvePtr;

    *aStream >> sndCurvePtr;

    if (sndCurvePtr)
    {
        if (sndCurvePtr == -1 || sndCurvePtr == -2)
        {
            result = Assets::Load_SndCurve(aStream);
        }
        else {
            // Resolve contents from g_streamBlocks
            //*varSndCurvePtr = *(SndCurve **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                        + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
        }
    }
    return result;
}


// ?Load_StreamFileInfo@@YAX_N@Z at 0x822a8610
void Assets::Load_StreamFileInfo(QDataStream *aStream)
{
    if ( !varStreamFileName->fileIndex )
    {
        varStreamFileNameRaw = &varStreamFileInfo->raw;
        Load_StreamFileNameRaw(0);
    }
}


// ?Load_SndDriverGlobalsPtr@@YAX_N@Z at 0x822a8640
void Assets::Load_SndDriverGlobalsPtr(QDataStream *aStream)
{
    XSoundDriverGlobals result;
    qint32 sndDriverGlobalsPtr;

    *aStream >> sndDriverGlobalsPtr;

    if (sndDriverGlobalsPtr)
    {
        if (sndDriverGlobalsPtr == -1 || sndDriverGlobalsPtr == -2)
        {
            result = Assets::Load_SndDriverGlobals(aStream);
        }
        else
        {
            // Resolve contents for g_streamBlocks
            //*varSndDriverGlobalsPtr = *(SndDriverGlobals **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                        + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
        }
    }
}


// ?Load_XaSound@@YAX_N@Z at 0x822a8728
XaSound Assets::Load_XaSound(QDataStream *aStream)
{
    XaSound result;

    *aStream
            >> result.packet.pBufferPtr
            >> result.packet.BufferSize
            >> result.packet.LoopCount;

    for (int i = 0; i < 6; i++) {
        *aStream
                >> result.packet.XMALoop[i].LoopStart
                >> result.packet.XMALoop[i].LoopEnd
                >> result.packet.XMALoop[i].LoopSubframeEnd
                >> result.packet.XMALoop[i].LoopSubframeSkip;
    }
    *aStream
            >> result.packet.pContextPtr
            >> result.packet.pContext
            >> result.format.SampleType
            >> result.format.___u1.NumStreams
            >> result.format.___u1.ChannelCount;

    for (int i = 0; i < 6; i++) {
        *aStream
                >> result.format.___u2.Stream[i].SampleRate
                >> result.format.___u2.Stream[i].ChannelCount
                >> result.format.___u2.Stream[i].DecodeBufferSize;
    }
    *aStream
            >> result.packet.pContextPtr
            >> result.xaIwXmaDataInfo.totalMsec
            >> result.seekTable.size
            >> result.seekTable.dataPtr;

    result.packet = Assets::Load_XAUDIOPACKET_ALIGNED(aStream);
    result.seekTable = Assets::Load_XaSeekTable(aStream);

    return result;
}


// ?Load_XAnimNotifyInfoArray@@YAX_NH@Z at 0x822a8790
QVector<XAnimNotifyInfo> Assets::Load_XAnimNotifyInfoArray(QDataStream *aStream, int count)
{
    QVector<XAnimNotifyInfo> result;

    for (int i = 0; i < count; i++) {
        XAnimNotifyInfo xAnimNotifyInfo;

        *aStream
                >> xAnimNotifyInfo.name
                >> xAnimNotifyInfo.time;

        result << xAnimNotifyInfo;
    }
    return result;
}

// ?Load_XAnimPartTransFrames@@YAX_N@Z at 0x822a8828
void Assets::Load_XAnimPartTransFrames(QDataStream *aStream)
{
    unsigned int numframes; // r9
    int size; // r11
    size_t v3; // r5

    Load_Stream(1, varXAnimPartTransFrames, 0x1Cu);
    numframes = varXAnimParts->numframes;
    varXAnimDynamicIndicesTrans = &varXAnimPartTransFrames->indices;
    size = varXAnimPartTrans->size;
    if ( numframes >= 0x100 )
    {
        v3 = 2 * (size + 1);
        varUnsignedShort = varXAnimPartTransFrames->indices._2;
    }
    else
    {
        v3 = size + 1;
        varbyte = varXAnimPartTransFrames->indices._1;
    }
    Load_Stream(1, &varXAnimPartTransFrames->indices, v3);
    varXAnimDynamicFrames = &varXAnimPartTransFrames->frames;
    Load_XAnimDynamicFrames(0);
}


// ?Load_XAnimDeltaPartQuatDataFrames@@YAX_N@Z at 0x822a88d0
void Assets::Load_XAnimDeltaPartQuatDataFrames(QDataStream *aStream)
{
    unsigned int numframes; // r9
    int size; // r11
    size_t v3; // r5
    unsigned __int8 *v4; // r4
    int v5; // r11
    bool v6; // cr58
    int v7; // r11

    Load_Stream(1, varXAnimDeltaPartQuatDataFrames, 4u);
    numframes = varXAnimParts->numframes;
    varXAnimDynamicIndicesDeltaQuat = &varXAnimDeltaPartQuatDataFrames->indices;
    size = varXAnimDeltaPartQuat->size;
    if ( numframes >= 0x100 )
    {
        v3 = 2 * (size + 1);
        varUnsignedShort = varXAnimDeltaPartQuatDataFrames->indices._2;
    }
    else
    {
        v3 = size + 1;
        varbyte = varXAnimDeltaPartQuatDataFrames->indices._1;
    }
    Load_Stream(1, &varXAnimDeltaPartQuatDataFrames->indices, v3);
    if ( varXAnimDeltaPartQuatDataFrames->frames )
    {
        v4 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v4;
        varXAnimDeltaPartQuatDataFrames->frames = (__int16 (*)[2])v4;
        varXQuat2 = (__int16 (*)[2])v4;
        v5 = varXAnimDeltaPartQuat->size;
        v6 = v5 == 0;
        v7 = v5 + 1;
        if ( v6 )
            v7 = 0;
        Load_Stream(1, v4, 4 * v7);
    }
}


// ?Load_TempStringArray@@YAX_NH@Z at 0x822a89c0
void Assets::Load_TempStringArray(QDataStream *aStream, int count)
{
    int v2; // r31
    const char **v3; // r30
    const char **v4; // r3
    int v5; // r11

    v2 = count;
    Load_Stream(1, varTempString, 4 * count);
    v3 = varTempString;
    if ( v2 > 0 )
    {
        do
        {
            varTempString = v3;
            Load_Stream(0, v3, 4u);
            v4 = varTempString;
            v5 = (int)*varTempString;
            if ( *varTempString )
            {
                if ( v5 == -1 )
                {
                    varConstChar = (const char *)g_streamPos;
                    *varTempString = (const char *)g_streamPos;
                    Load_TempStringCustom(v4);
                }
                else
                {
                    *varTempString = (const char *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                           + (((unsigned int)(v5 - 1) >> 26) & 0x38)))[(v5 - 1) & 0x1FFFFFFF];
                }
            }
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_GfxLightRegion@@YAX_N@Z at 0x822a8a78
GfxLightRegion Assets::Load_GfxLightRegion(QDataStream *aStream)
{
    GfxLightRegion result;

    *aStream
            >> result.hullCount
            >> result.hullsPtr;

    if (result.hullsPtr)
    {
        result.hulls << Assets::Load_GfxLightRegionHullArray(aStream, result.hullCount);
    }

    return result;
}


// ?Load_StringTablePtr@@YAX_N@Z at 0x822a8c10
StringTable Assets::Load_StringTablePtr(QDataStream *aStream)
{
    StringTable result;
    qint32 stringTablePtr;

    *aStream >> stringTablePtr;

    if (stringTablePtr)
    {
        if (stringTablePtr == -1)
        {
            result = Assets::Load_StringTable(aStream);
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //*varStringTablePtr = (StringTable *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                            + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
        }
    }
}


// ?Load_entryInternalData@@YAX_N@Z at 0x822a8d00
void Assets::Load_entryInternalData(QDataStream *aStream)
{
    if ( varexpressionEntry->type )
    {
        varOperand = (Operand *)varentryInternalData;
        Load_Operand(0);
    }
}


// ?Load_ComWorld@@YAX_N@Z at 0x822a8d30
ComWorld Assets::Load_ComWorld(QDataStream *aStream)
{
    ComWorld result;

    *aStream
            >> result.namePtr
            >> result.isInUse
            >> result.primaryLightCount
            >> result.primaryLightsPtr;

    if (result.namePtr) {
        result.name = Assets::Load_XStringCustom(aStream);
    }
    if (result.primaryLightsPtr)
    {
        result.primaryLights << Assets::Load_ComPrimaryLightArray(aStream, result.primaryLightCount);
    }
}


// ?Load_cbrush_tArray@@YAX_NH@Z at 0x822a8dc8
QVector<CBrush> Assets::Load_cbrush_tArray(QDataStream *aStream, int count)
{
    QVector<CBrush> result;

    for (int i = 0; i < count; i++) {
        result << Assets::Load_CBrush(aStream);
    }

    return result;
}


// ?Load_cLeafBrushNode_tArray@@YAX_NH@Z at 0x822a8e28
QVector<cLeafBrushNode_t> Assets::Load_cLeafBrushNode_tArray(QDataStream *aStream, int count)
{
    QVector<cLeafBrushNode_t> result;

    for (int i = 0; i < count; i++) {
        cLeafBrushNode_t cLeafBrushNode = Assets::Load_CLeafBrushNode(aStream);
        Assets::Load_CLeafBrushNode(aStream);
        if (cLeafBrushNode.leafBrushCount > 0) {
            if (cLeafBrushNode.data.leaf.brushesPtr) {
                cLeafBrushNode.data = Assets::Load_CLeafBrushNodeLeaf(count);
            }
        }

        result << cLeafBrushNode;
    }

    return result;
}


// ?Load_PathNodeTree@@YAX_N@Z at 0x822a8ed8
PathNodeTree Assets::Load_PathNodeTree(QDataStream *aStream)
{
    PathNodeTree result;

    *aStream
            >> result.axis
            >> result.dist
            >> result.infoPtr;

    if (result.axis < 0)
    {
        varpathnode_tree_nodes_t = (PathNodeTreeNodes *)&varpathnode_tree_t->u;
        Load_PathNodeTreeNodes(0);
    }
    else
    {
        varpathnode_tree_ptr = varpathnode_tree_t->u.child;
        LoadPathNodeTreeArray(0, 2);
    }
}


// ?Load_pathnode_tArray@@YAX_NH@Z at 0x822a8f60
void Assets::Load_pathnode_tArray(QDataStream *aStream, int count)
{
    int v2; // r30
    pathnode_t *v3; // r31

    v2 = count;
    Load_Stream(1, varpathnode_t, count << 7);
    v3 = varpathnode_t;
    if ( v2 > 0 )
    {
        do
        {
            varpathnode_t = v3;
            Load_Stream(0, v3, 0x80u);
            varpathnode_constant_t = &varpathnode_t->constant;
            Load_PathNodeConstant(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_BrushWrapper@@YAX_N@Z at 0x822a8fd0
BrushWrapper Assets::Load_BrushWrapper(QDataStream *aStream)
{
    BrushWrapper result;

    *aStream
            >> result.mins[0]
            >> result.mins[1]
            >> result.mins[2]
            >> result.contents
            >> result.maxs[0]
            >> result.maxs[1]
            >> result.maxs[2]
            >> result.numsides
            >> result.sidesPtr
            >> result.axialMaterialNum[0][0]
            >> result.axialMaterialNum[0][1]
            >> result.axialMaterialNum[0][2]
            >> result.axialMaterialNum[1][0]
            >> result.axialMaterialNum[1][1]
            >> result.axialMaterialNum[1][2]
            >> result.baseAdjacentSidePtr
            >> result.firstAdjacentSideOffsets[0][0]
            >> result.firstAdjacentSideOffsets[0][1]
            >> result.firstAdjacentSideOffsets[0][2]
            >> result.firstAdjacentSideOffsets[1][0]
            >> result.firstAdjacentSideOffsets[1][1]
            >> result.firstAdjacentSideOffsets[1][2]
            >> result.edgeCount[0][0]
            >> result.edgeCount[0][1]
            >> result.edgeCount[0][2]
            >> result.edgeCount[1][0]
            >> result.edgeCount[1][1]
            >> result.edgeCount[1][2]
            >> result.totalEdgeCount
            >> result.planesPtr;

    if (result.sidesPtr)
    {
        result.sides = Assets::Load_cbrushside_tArray(aStream, result.numsides);
    }
    if (result.baseAdjacentSidePtr)
    {
        result.baseAdjacentSide = Assets::Load_cbrushedge_t(aStream);
    }
    if (result.planesPtr)
    {
        if (result.planesPtr == -1)
        {
            for (int i = 0; i < result.numsides; i++) {
                result.planes << Assets::Load_CPlane(aStream);
            }
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //v1->planes = (cplane_s *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                 + (((unsigned int)&v1->planes[-1].pad[1] >> 26) & 0x38)))[(int)&v1->planes[-1].pad[1] & 0x1FFFFFFF];
        }
    }
}


// ?Load_MaterialShaderArgumentArray@@YAX_NH@Z at 0x822a90f0
void Assets::Load_MaterialShaderArgumentArray(QDataStream *aStream, int count)
{
    int v2; // r30
    MaterialShaderArgument *v3; // r31

    v2 = count;
    Load_Stream(1, varMaterialShaderArgument, 8 * count);
    v3 = varMaterialShaderArgument;
    if ( v2 > 0 )
    {
        do
        {
            varMaterialShaderArgument = v3;
            Load_Stream(0, v3, 8u);
            varMaterialArgumentDef = &varMaterialShaderArgument->u;
            Load_MaterialArgumentDef(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_MaterialPixelShader@@YAX_N@Z at 0x822a9168
MaterialPixelShader Assets::Load_MaterialPixelShader(QDataStream *aStream)
{
    MaterialPixelShader result;
    Load_Stream(1, varMaterialPixelShader, 0x10u);
    DB_PushStreamPos(4u);
    varXString = &varMaterialPixelShader->name;
    Load_XString(0);
    varMaterialPixelShaderProgram = &varMaterialPixelShader->prog;
    Load_MaterialPixelShaderProgram(0);

    return result;
}


// ?Load_MaterialVertexShader@@YAX_N@Z at 0x822a91d8
void Assets::Load_MaterialVertexShader(QDataStream *aStream)
{
    Load_Stream(1, varMaterialVertexShader, 0x10u);
    varXString = &varMaterialVertexShader->name;
    Load_XString(0);
    varMaterialVertexShaderProgram = &varMaterialVertexShader->prog;
    Load_MaterialVertexShaderProgram(0);
}


// ?Load_GfxImage@@YAX_N@Z at 0x822a9240
GfxImage Assets::Load_GfxImage(QDataStream *aStream)
{
    GfxImage result;

    *aStream
            >> result.mapType
            //>> result.texture.map
            >> result.semantic
            >> result.cardMemory
            >> result.width
            >> result.height
            >> result.depth
            >> result.category
            >> result.delayLoadPixels
            >> result.pixelsPtr
            >> result.baseSize
            >> result.streamSlot
            >> result.streaming
            >> result.namePtr;

    if (result.namePtr == -1) {
        result.name = Assets::Load_XStringCustom(aStream);
    }
    if (result.pixelsPtr) {
        result.pixels = Assets::Load_GfxImagePixels(aStream);
    }

    result.texture = Assets::Load_GfxTextureLoad(aStream);

    *aStream >> result.texture

            varGfxTextureLoad = &varGfxImage->texture;
    Load_GfxTextureLoad(0);
    return result;
}


// ?Load_XRigidVertListArray@@YAX_NH@Z at 0x822a92d0
void Assets::Load_XRigidVertListArray(QDataStream *aStream, int count)
{
    int v2; // r31
    XRigidVertList *v3; // r30

    v2 = count;
    Load_Stream(1, varXRigidVertList, 12 * count);
    v3 = varXRigidVertList;
    if ( v2 > 0 )
    {
        do
        {
            varXRigidVertList = v3;
            Load_XRigidVertList(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_snd_alias_list_nameArray@@YAX_NH@Z at 0x822a9330
void Assets::Load_snd_alias_list_nameArray(QDataStream *aStream, int count)
{
    SoundAliasList **v2; // r31
    int v3; // r30

    Load_Stream(1, varsnd_alias_list_name, 0x74u);
    v2 = varsnd_alias_list_name;
    v3 = 29;
    do
    {
        varsnd_alias_list_name = v2;
        Load_Stream(0, v2, 4u);
        Load_SndAliasCustom(varsnd_alias_list_name);
        --v3;
        ++v2;
    }
    while ( v3 );
}


// ?Load_SpeakerMapChannel@@YAX_N@Z at 0x822a9390
void Assets::Load_SpeakerMapChannel(QDataStream *aStream)
{
    Load_Stream(0, varSpeakerMapChannel, 0x10u);
    varXAUDIOCHANNELMAP = (XAUDIOCHANNELMAP *)varSpeakerMapChannel;
    Load_XAUDIOCHANNELMAPArray(0, 2);
}


// ?Load_LoadedSound@@YAX_N@Z at 0x822a93e0
void Assets::Load_LoadedSound(QDataStream *aStream)
{
    Load_Stream(1, varLoadedSound, 0xA0u);
    DB_PushStreamPos(4u);
    varXString = &varLoadedSound->name;
    Load_XString(0);
    varXaSound = &varLoadedSound->sound;
    Load_XaSound(0);
    DB_PopStreamPos();
}


// ?Load_StreamFileName@@YAX_N@Z at 0x822a9450
void Assets::Load_StreamFileName(QDataStream *aStream)
{
    unsigned int fileIndex; // r9

    Load_Stream(0, varStreamFileName, 0xCu);
    fileIndex = varStreamFileName->fileIndex;
    varStreamFileInfo = &varStreamFileName->info;
    if ( !fileIndex )
    {
        varStreamFileNameRaw = &varStreamFileName->info.raw;
        Load_StreamFileNameRaw(0);
    }
}


// ?Load_XAnimPartTransData@@YAX_N@Z at 0x822a94b8
void Assets::Load_XAnimPartTransData(QDataStream *aStream)
{
    if ( varXAnimPartTrans->size )
    {
        varXAnimPartTransFrames = &varXAnimPartTransData->frames;
        Load_XAnimPartTransFrames(1);
    }
    else
    {
        varvec3_t = (float (*)[3])varXAnimPartTransData;
        Load_Stream(1, varXAnimPartTransData, 0xCu);
    }
}


// ?Load_XAnimDeltaPartQuatData@@YAX_N@Z at 0x822a94f8
void Assets::Load_XAnimDeltaPartQuatData(QDataStream *aStream)
{
    if ( varXAnimDeltaPartQuat->size )
    {
        varXAnimDeltaPartQuatDataFrames = &varXAnimDeltaPartQuatData->frames;
        Load_XAnimDeltaPartQuatDataFrames(1);
    }
    else
    {
        varXQuat2 = (__int16 (*)[2])varXAnimDeltaPartQuatData;
        Load_Stream(1, varXAnimDeltaPartQuatData, 4u);
    }
}


// ?Load_ScriptStringList@@YAX_N@Z at 0x822a9538
void Assets::Load_ScriptStringList(QDataStream *aStream)
{
    int count; // r4
    unsigned __int8 *v2; // r11

    Load_Stream(0, varScriptStringList, 8u);
    DB_PushStreamPos(4u);
    if ( varScriptStringList->strings )
    {
        count = varScriptStringList->count;
        v2 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v2;
        varScriptStringList->strings = (const char **)v2;
        varTempString = (const char **)v2;
        Load_TempStringArray(1, count);
    }
    DB_PopStreamPos();
}


// ?Load_GfxLightRegionArray@@YAX_NH@Z at 0x822a95b8
void Assets::Load_GfxLightRegionArray(QDataStream *aStream, int count)
{
    int v2; // r31
    GfxLightRegion *v3; // r29
    unsigned int hullCount; // r4

    v2 = count;
    Load_Stream(1, varGfxLightRegion, 8 * count);
    v3 = varGfxLightRegion;
    if ( v2 > 0 )
    {
        do
        {
            varGfxLightRegion = v3;
            Load_Stream(0, v3, 8u);
            if ( varGfxLightRegion->hulls )
            {
                hullCount = varGfxLightRegion->hullCount;
                g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
                varGfxLightRegionHull = (GfxLightRegionHull *)g_streamPos;
                varGfxLightRegion->hulls = (GfxLightRegionHull *)g_streamPos;
                Load_GfxLightRegionHullArray(1, hullCount);
            }
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_GfxCellArray@@YAX_NH@Z at 0x822a9650
void Assets::Load_GfxCellArray(QDataStream *aStream, int count)
{
    int v2; // r31
    GfxCell *v3; // r30

    v2 = count;
    Load_Stream(1, varGfxCell, 56 * count);
    v3 = varGfxCell;
    if ( v2 > 0 )
    {
        do
        {
            varGfxCell = v3;
            Load_GfxCell(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_expressionEntry@@YAX_N@Z at 0x822a96a8
void Assets::Load_expressionEntry(QDataStream *aStream)
{
    int type; // r9

    Load_Stream(1, varexpressionEntry, 0xCu);
    type = varexpressionEntry->type;
    varentryInternalData = &varexpressionEntry->data;
    if ( type )
    {
        varOperand = (Operand *)&varexpressionEntry->data;
        Load_Operand(0);
    }
}


// ?Load_ComWorldPtr@@YAX_N@Z at 0x822a9710
void Assets::Load_ComWorldPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    ComWorld **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varComWorldPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varComWorldPtr;
    if ( *varComWorldPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varComWorldPtr = *(ComWorld **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                    + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varComWorldPtr = (ComWorld *)v3;
        varComWorld = (ComWorld *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_ComWorld(1);
        v5 = varComWorldPtr;
        *v5 = (ComWorld *)DB_AddXAsset((XAssetHeader *)0xD, (XAssetHeader *)*varComWorldPtr, v6);
        if ( inserted )
            *inserted = *varComWorldPtr;
    }
    DB_PopStreamPos();
}


// ?Load_pathnode_tree_tArray@@YAX_NH@Z at 0x822a97f8
void Assets::Load_pathnode_tree_tArray(QDataStream *aStream, int count)
{
    int v2; // r31
    PathNodeTree *v3; // r30

    v2 = count;
    Load_Stream(1, varpathnode_tree_t, 16 * count);
    v3 = varpathnode_tree_t;
    if ( v2 > 0 )
    {
        do
        {
            varpathnode_tree_t = v3;
            Load_PathNodeTree(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_MaterialPixelShaderPtr@@YAX_N@Z at 0x822a98b0
void Assets::Load_MaterialPixelShaderPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    MaterialPixelShader **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varMaterialPixelShaderPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varMaterialPixelShaderPtr;
    if ( *varMaterialPixelShaderPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varMaterialPixelShaderPtr = *(MaterialPixelShader **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                          + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varMaterialPixelShaderPtr = (MaterialPixelShader *)v3;
        varMaterialPixelShader = (MaterialPixelShader *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_MaterialPixelShader(1);
        v5 = varMaterialPixelShaderPtr;
        *v5 = (MaterialPixelShader *)DB_AddXAsset((XAssetHeader *)5, (XAssetHeader *)*varMaterialPixelShaderPtr, v6);
        if ( inserted )
            *inserted = *varMaterialPixelShaderPtr;
    }
    DB_PopStreamPos();
}


// ?Load_GfxImagePtr@@YAX_N@Z at 0x822a9a40
void Assets::Load_GfxImagePtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r31

    Load_Stream(0, varGfxImagePtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varGfxImagePtr;
    if ( *varGfxImagePtr )
    {
        if ( v1 == -1 || v1 == -2 )
        {
            v2 = v1 == -2;
            v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v3;
            *varGfxImagePtr = (GfxImage *)v3;
            varGfxImage = (GfxImage *)v3;
            if ( v2 )
                inserted = DB_InsertPointer();
            else
                inserted = 0;
            Load_GfxImage(1);
            Load_GfxImageAsset(varGfxImagePtr);
            if ( inserted )
                *inserted = *varGfxImagePtr;
        }
        else
        {
            *varGfxImagePtr = *(GfxImage **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                    + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
        }
    }
    DB_PopStreamPos();
}


// ?Load_XSurface@@YAX_N@Z at 0x822a9b30
void Assets::Load_XSurface(QDataStream *aStream)
{
    XSurface *v1; // r11
    GfxPackedVertex *verts0; // r10
    size_t v3; // r5
    unsigned __int8 *v4; // r4
    XSurface *v5; // r11
    D3DVertexBuffer *p_vb0; // r28
    GfxPackedVertex *v7; // r30
    XRigidVertList *vertList; // r10
    int vertListCount; // r4
    unsigned __int16 *triIndices; // r10
    int triCount; // r10
    unsigned __int8 *v12; // r4
    D3DIndexBuffer *p_indexBuffer; // r31
    unsigned __int16 *v14; // r30

    Load_Stream(0, varXSurface, 0x74u);
    varXSurfaceVertexInfo = &varXSurface->vertInfo;
    Load_XSurfaceVertexInfo(0);
    v1 = varXSurface;
    verts0 = varXSurface->verts0;
    if ( verts0 )
    {
        if ( verts0 == (GfxPackedVertex *)-1 )
        {
            v3 = __ROL4__(varXSurface->vertCount, 5);
            v4 = (unsigned __int8 *)((unsigned int)(g_streamPos + 15) & 0xFFFFFFF0);
            g_streamPos = v4;
            varGfxPackedVertex0 = (GfxPackedVertex *)v4;
            varXSurface->verts0 = (GfxPackedVertex *)v4;
            Load_Stream(1, v4, v3);
            v1 = varXSurface;
        }
        else
        {
            varXSurface->verts0 = (GfxPackedVertex *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                             + ((((unsigned int)&varXSurface->verts0[-1].tangent.packed
                                                                                  + 3) >> 26) & 0x38)))[((int)&varXSurface->verts0[-1].tangent.packed
                                                                                                         + 3) & 0x1FFFFFFF];
        }
    }
    varGfxVertexBuffer = &v1->vb0;
    Load_Stream(0, &v1->vb0, 0x20u);
    v5 = varXSurface;
    p_vb0 = &varXSurface->vb0;
    v7 = varXSurface->verts0;
    if ( v7 )
    {
        XGSetVertexBufferHeader(__ROL4__(varXSurface->vertCount, 5), 0, 0, 0, p_vb0);
        XGOffsetResourceAddress(p_vb0, v7);
        v5 = varXSurface;
    }
    vertList = v5->vertList;
    if ( vertList )
    {
        if ( vertList == (XRigidVertList *)-1 )
        {
            vertListCount = v5->vertListCount;
            g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            varXRigidVertList = (XRigidVertList *)g_streamPos;
            v5->vertList = (XRigidVertList *)g_streamPos;
            Load_XRigidVertListArray(1, vertListCount);
            v5 = varXSurface;
        }
        else
        {
            v5->vertList = (XRigidVertList *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                     + ((((unsigned int)&v5->vertList[-1].collisionTree + 3) >> 26) & 0x38)))[((int)&v5->vertList[-1].collisionTree + 3) & 0x1FFFFFFF];
        }
    }
    triIndices = v5->triIndices;
    if ( triIndices )
    {
        if ( triIndices == (unsigned __int16 *)-1 )
        {
            triCount = v5->triCount;
            v12 = (unsigned __int8 *)((unsigned int)(g_streamPos + 15) & 0xFFFFFFF0);
            v5->triIndices = (unsigned __int16 *)v12;
            g_streamPos = v12;
            varr_index16_t = (unsigned __int16 *)v12;
            Load_Stream(1, v12, 2 * (triCount + __ROL4__(triCount, 1)));
            v5 = varXSurface;
        }
        else
        {
            v5->triIndices = (unsigned __int16 *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                         + ((((unsigned int)v5->triIndices - 1) >> 26) & 0x38)))[((int)v5->triIndices - 1) & 0x1FFFFFFF];
        }
    }
    varGfxIndexBuffer = &v5->indexBuffer;
    Load_Stream(0, &v5->indexBuffer, 0x20u);
    p_indexBuffer = &varXSurface->indexBuffer;
    v14 = varXSurface->triIndices;
    XGSetIndexBufferHeader(
                2 * (varXSurface->triCount + __ROL4__(varXSurface->triCount, 1)),
                0,
                D3DFMT_INDEX16,
                0,
                0,
                &varXSurface->indexBuffer);
    XGOffsetResourceAddress(p_indexBuffer, v14);
}


// ?Load_SpeakerMapChannelArray@@YAX_NH@Z at 0x822a9d68
void Assets::Load_SpeakerMapChannelArray(QDataStream *aStream, int count)
{
    XAUDIOCHANNELMAP *v2; // r31
    int v3; // r30

    Load_Stream(0, varSpeakerMapChannel, 0x20u);
    v2 = (XAUDIOCHANNELMAP *)varSpeakerMapChannel;
    v3 = 2;
    do
    {
        varSpeakerMapChannel = (XAUDIOCHANNELMAP (*)[2])v2;
        Load_Stream(0, v2, 0x10u);
        varXAUDIOCHANNELMAP = (XAUDIOCHANNELMAP *)varSpeakerMapChannel;
        Load_XAUDIOCHANNELMAPArray(0, 2);
        --v3;
        v2 += 2;
    }
    while ( v3 );
}


// ?Load_StreamedSound@@YAX_N@Z at 0x822a9dd8
void Assets::Load_StreamedSound(QDataStream *aStream)
{
    Load_Stream(0, varStreamedSound, 0xCu);
    varStreamFileName = &varStreamedSound->filename;
    Load_StreamFileName(0);
}


// ?Load_LoadedSoundPtr@@YAX_N@Z at 0x822a9e28
void Assets::Load_LoadedSoundPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    LoadedSound **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varLoadedSoundPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varLoadedSoundPtr;
    if ( *varLoadedSoundPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varLoadedSoundPtr = *(LoadedSound **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                          + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varLoadedSoundPtr = (LoadedSound *)v3;
        varLoadedSound = (LoadedSound *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_LoadedSound(1);
        v5 = varLoadedSoundPtr;
        *v5 = (LoadedSound *)DB_AddXAsset((XAssetHeader *)0xA, (XAssetHeader *)*varLoadedSoundPtr, v6);
        if ( inserted )
            *inserted = *varLoadedSoundPtr;
    }
    DB_PopStreamPos();
}


// ?Load_XAnimPartTrans@@YAX_N@Z at 0x822a9f10
void Assets::Load_XAnimPartTrans(QDataStream *aStream)
{
    int size; // r9

    Load_Stream(1, varXAnimPartTrans, 4u);
    size = varXAnimPartTrans->size;
    varXAnimPartTransData = &varXAnimPartTrans->u;
    if ( size )
    {
        varXAnimPartTransFrames = &varXAnimPartTrans->u.frames;
        Load_XAnimPartTransFrames(1);
    }
    else
    {
        varvec3_t = (float (*)[3])&varXAnimPartTrans->u;
        Load_Stream(1, &varXAnimPartTrans->u, 0xCu);
    }
}


// ?Load_XAnimDeltaPartQuat@@YAX_N@Z at 0x822a9f98
void Assets::Load_XAnimDeltaPartQuat(QDataStream *aStream)
{
    int size; // r9

    Load_Stream(1, varXAnimDeltaPartQuat, 4u);
    size = varXAnimDeltaPartQuat->size;
    varXAnimDeltaPartQuatData = &varXAnimDeltaPartQuat->u;
    if ( size )
    {
        varXAnimDeltaPartQuatDataFrames = &varXAnimDeltaPartQuat->u.frames;
        Load_XAnimDeltaPartQuatDataFrames(1);
    }
    else
    {
        varXQuat2 = (__int16 (*)[2])&varXAnimDeltaPartQuat->u;
        Load_Stream(1, &varXAnimDeltaPartQuat->u, 4u);
    }
}


// ?Load_GfxReflectionProbe@@YAX_N@Z at 0x822aa020
void Assets::Load_GfxReflectionProbe(QDataStream *aStream)
{
    Load_Stream(0, varGfxReflectionProbe, 0x10u);
    varGfxImagePtr = &varGfxReflectionProbe->reflectionImage;
    Load_GfxImagePtr(0);
}


// ?Load_PathData@@YAX_N@Z at 0x822aa0a0
void Assets::Load_PathData(QDataStream *aStream)
{
    PathData *v1; // r31
    unsigned int nodeCount; // r4
    bool v3; // r3
    size_t v4; // r5
    unsigned __int8 *v5; // r4
    size_t v6; // r5
    unsigned __int8 *v7; // r4
    size_t v8; // r5
    unsigned __int8 *v9; // r4
    unsigned __int8 *v10; // r4
    size_t visBytes; // r5
    int nodeTreeCount; // r4

    Load_Stream(0, varPathData, 0x28u);
    v1 = varPathData;
    if ( varPathData->nodes )
    {
        nodeCount = varPathData->nodeCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varpathnode_t = (pathnode_t *)g_streamPos;
        varPathData->nodes = (pathnode_t *)g_streamPos;
        Load_pathnode_tArray(1, nodeCount);
        v1 = varPathData;
    }
    DB_PushStreamPos(1u);
    if ( v1->basenodes )
    {
        v4 = 16 * v1->nodeCount;
        v5 = (unsigned __int8 *)((unsigned int)(g_streamPos + 15) & 0xFFFFFFF0);
        g_streamPos = v5;
        varpathbasenode_t = (pathbasenode_t *)v5;
        v1->basenodes = (PathBaseNode *)v5;
        Load_Stream(v3, v5, v4);
        v1 = varPathData;
    }
    DB_PopStreamPos();
    if ( v1->chainNodeForNode )
    {
        v6 = 2 * v1->nodeCount;
        v7 = (unsigned __int8 *)((unsigned int)(g_streamPos + 1) & 0xFFFFFFFE);
        g_streamPos = v7;
        varUnsignedShort = (unsigned __int16 *)v7;
        v1->chainNodeForNode = (unsigned __int16 *)v7;
        Load_Stream(1, v7, v6);
        v1 = varPathData;
    }
    if ( v1->nodeForChainNode )
    {
        v8 = 2 * v1->nodeCount;
        v9 = (unsigned __int8 *)((unsigned int)(g_streamPos + 1) & 0xFFFFFFFE);
        g_streamPos = v9;
        varUnsignedShort = (unsigned __int16 *)v9;
        v1->nodeForChainNode = (unsigned __int16 *)v9;
        Load_Stream(1, v9, v8);
        v1 = varPathData;
    }
    if ( v1->pathVis )
    {
        v10 = g_streamPos;
        visBytes = v1->visBytes;
        varbyte = g_streamPos;
        v1->pathVis = g_streamPos;
        Load_Stream(1, v10, visBytes);
        v1 = varPathData;
    }
    if ( v1->nodeTree )
    {
        nodeTreeCount = v1->nodeTreeCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varpathnode_tree_t = (pathnode_tree_t *)g_streamPos;
        v1->nodeTree = (pathnode_tree_t *)g_streamPos;
        Load_pathnode_tree_tArray(1, nodeTreeCount);
    }
}


// ?Load_PhysGeomInfoArray@@YAX_NH@Z at 0x822aa228
void Assets::Load_PhysGeomInfoArray(QDataStream *aStream, int count)
{
    int v2; // r31
    PhysGeomInfo *v3; // r30
    BrushWrapper *brush; // r11

    v2 = count;
    Load_Stream(1, varPhysGeomInfo, 68 * count);
    v3 = varPhysGeomInfo;
    if ( v2 > 0 )
    {
        do
        {
            varPhysGeomInfo = v3;
            Load_Stream(0, v3, 0x44u);
            brush = varPhysGeomInfo->brush;
            if ( varPhysGeomInfo->brush )
            {
                if ( brush == (BrushWrapper *)-1 )
                {
                    g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
                    varBrushWrapper = (BrushWrapper *)g_streamPos;
                    varPhysGeomInfo->brush = (BrushWrapper *)g_streamPos;
                    Load_BrushWrapper(1);
                }
                else
                {
                    varPhysGeomInfo->brush = (BrushWrapper *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                     + ((((unsigned int)&brush[-1].planes + 3) >> 26) & 0x38)))[((unsigned int)&brush[-1].planes + 3) & 0x1FFFFFFF];
                }
            }
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_GfxLightmapArray@@YAX_N@Z at 0x822aa2e8
void Assets::Load_GfxLightmapArray(QDataStream *aStream)
{
    Load_Stream(0, varGfxLightmapArray, 8u);
    varGfxImagePtr = &varGfxLightmapArray->primary;
    Load_GfxImagePtr(0);
    varGfxImagePtr = &varGfxLightmapArray->secondary;
    Load_GfxImagePtr(0);
}


// ?Load_GfxLightImage@@YAX_N@Z at 0x822aa350
void Assets::Load_GfxLightImage(QDataStream *aStream)
{
    Load_Stream(0, varGfxLightImage, 8u);
    varGfxImagePtr = &varGfxLightImage->image;
    Load_GfxImagePtr(0);
}


// ?Load_MaterialVertexShaderPtrArray@@YAX_NH@Z at 0x822aa3a0
void Assets::Load_MaterialVertexShaderPtrArray(QDataStream *aStream, int count)
{
    MaterialVertexShader **v2; // r31
    int v3; // r29
    bool v4; // r3

    Load_Stream(0, varMaterialVertexShaderPtr, 0x3Cu);
    v2 = varMaterialVertexShaderPtr;
    v3 = 15;
    do
    {
        varMaterialVertexShaderPtr = v2;
        Load_Stream(0, v2, 4u);
        if ( *varMaterialVertexShaderPtr )
            Load_MaterialVertexShaderPtr(v4);
        --v3;
        ++v2;
    }
    while ( v3 );
}


// ?Load_water_t@@YAX_N@Z at 0x822aa408
void Assets::Load_water_t(QDataStream *aStream)
{
    water_t *v1; // r11
    int N; // r9
    int M; // r8
    unsigned __int8 *v4; // r4
    int v5; // r9
    int v6; // r8
    unsigned __int8 *v7; // r4
    int v8; // r9
    int v9; // r8
    unsigned __int8 *v10; // r4

    Load_Stream(1, varwater_t, 0x48u);
    v1 = varwater_t;
    if ( varwater_t->H0X )
    {
        N = varwater_t->N;
        M = varwater_t->M;
        v4 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v4;
        varwater_t->H0X = (float *)v4;
        varfloat = (float *)v4;
        Load_Stream(1, v4, 4 * N * M);
        v1 = varwater_t;
    }
    if ( v1->H0Y )
    {
        v5 = v1->N;
        v6 = v1->M;
        v7 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v7;
        v1->H0Y = (float *)v7;
        varfloat = (float *)v7;
        Load_Stream(1, v7, 4 * v5 * v6);
        v1 = varwater_t;
    }
    if ( v1->wTerm )
    {
        v8 = v1->N;
        v9 = v1->M;
        v10 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v10;
        v1->wTerm = (float *)v10;
        varfloat = (float *)v10;
        Load_Stream(1, v10, 4 * v8 * v9);
        v1 = varwater_t;
    }
    varGfxImagePtr = &v1->image;
    Load_GfxImagePtr(0);
}


// ?Load_XSurfaceArray@@YAX_NH@Z at 0x822aa510
void Assets::Load_XSurfaceArray(QDataStream *aStream, int count)
{
    int v2; // r31
    XSurface *v3; // r30

    v2 = count;
    Load_Stream(1, varXSurface, 116 * count);
    v3 = varXSurface;
    if ( v2 > 0 )
    {
        do
        {
            varXSurface = v3;
            Load_XSurface(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_SpeakerMap@@YAX_N@Z at 0x822aa568
void Assets::Load_SpeakerMap(QDataStream *aStream)
{
    Load_Stream(1, varSpeakerMap, 0x28u);
    varXString = &varSpeakerMap->name;
    Load_XString(0);
    varSpeakerMapChannel = varSpeakerMap->channelMaps;
    Load_SpeakerMapChannelArray(0, 2);
}


// ?Load_SoundFileRef@@YAX_N@Z at 0x822aa5d8
void Assets::Load_SoundFileRef(QDataStream *aStream)
{
    if ( varSoundFile->type == 1 )
    {
        varLoadedSoundPtr = &varSoundFileRef->loadSnd;
        Load_LoadedSoundPtr(0);
    }
    else
    {
        varStreamedSound = (StreamedSound *)varSoundFileRef;
        Load_Stream(0, varSoundFileRef, 0xCu);
        varStreamFileName = &varStreamedSound->filename;
        Load_StreamFileName(0);
    }
}


// ?Load_XAnimDeltaPart@@YAX_N@Z at 0x822aa668
void Assets::Load_XAnimDeltaPart(QDataStream *aStream)
{
    XAnimDeltaPart *v1; // r11

    Load_Stream(1, varXAnimDeltaPart, 8u);
    v1 = varXAnimDeltaPart;
    if ( varXAnimDeltaPart->trans )
    {
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varXAnimPartTrans = (XAnimPartTrans *)g_streamPos;
        varXAnimDeltaPart->trans = (XAnimPartTrans *)g_streamPos;
        Load_XAnimPartTrans(1);
        v1 = varXAnimDeltaPart;
    }
    if ( v1->quat )
    {
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varXAnimDeltaPartQuat = (XAnimDeltaPartQuat *)g_streamPos;
        v1->quat = (XAnimDeltaPartQuat *)g_streamPos;
        Load_XAnimDeltaPartQuat(1);
    }
}


// ?Load_GfxReflectionProbeArray@@YAX_NH@Z at 0x822aa718
void Assets::Load_GfxReflectionProbeArray(QDataStream *aStream, int count)
{
    int v2; // r30
    GfxReflectionProbe *v3; // r31

    v2 = count;
    Load_Stream(1, varGfxReflectionProbe, 16 * count);
    v3 = varGfxReflectionProbe;
    if ( v2 > 0 )
    {
        do
        {
            varGfxReflectionProbe = v3;
            Load_Stream(0, v3, 0x10u);
            varGfxImagePtr = &varGfxReflectionProbe->reflectionImage;
            Load_GfxImagePtr(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_expressionEntry_ptrArray@@YAX_NH@Z at 0x822aa790
void Assets::Load_expressionEntry_ptrArray(QDataStream *aStream, int count)
{
    XExpressionEntry **v3; // r28
    int v4; // r26
    unsigned __int8 *v5; // r4
    int type; // r10

    Load_Stream(1, varexpressionEntry_ptr, 4 * count);
    v3 = varexpressionEntry_ptr;
    if ( count > 0 )
    {
        v4 = count;
        do
        {
            varexpressionEntry_ptr = v3;
            Load_Stream(0, v3, 4u);
            if ( *varexpressionEntry_ptr )
            {
                v5 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
                g_streamPos = v5;
                varexpressionEntry = (expressionEntry *)v5;
                *varexpressionEntry_ptr = (expressionEntry *)v5;
                Load_Stream(1, v5, 0xCu);
                type = varexpressionEntry->type;
                varentryInternalData = &varexpressionEntry->data;
                if ( type )
                {
                    varOperand = (Operand *)&varexpressionEntry->data;
                    Load_Operand(0);
                }
            }
            --v4;
            ++v3;
        }
        while ( v4 );
    }
}


// ?Load_GameWorldSp@@YAX_N@Z at 0x822aa858
void Assets::Load_GameWorldSp(QDataStream *aStream)
{
    Load_Stream(1, varGameWorldSp, 0x2Cu);
    DB_PushStreamPos(4u);
    varXString = &varGameWorldSp->name;
    Load_XString(0);
    varPathData = &varGameWorldSp->path;
    Load_PathData(0);
    DB_PopStreamPos();
}


// ?Load_PhysGeomList@@YAX_N@Z at 0x822aa8c8
void Assets::Load_PhysGeomList(QDataStream *aStream)
{
    unsigned int count; // r4
    unsigned __int8 *v2; // r11

    Load_Stream(1, varPhysGeomList, 0x2Cu);
    if ( varPhysGeomList->geoms )
    {
        count = varPhysGeomList->count;
        v2 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v2;
        varPhysGeomList->geoms = (PhysGeomInfo *)v2;
        varPhysGeomInfo = (PhysGeomInfo *)v2;
        Load_PhysGeomInfoArray(1, count);
    }
}


// ?Load_GfxLightmapArrayArray@@YAX_NH@Z at 0x822aa940
void Assets::Load_GfxLightmapArrayArray(QDataStream *aStream, int count)
{
    int v2; // r29
    GfxLightmapArray *v3; // r31

    v2 = count;
    Load_Stream(1, varGfxLightmapArray, 8 * count);
    v3 = varGfxLightmapArray;
    if ( v2 > 0 )
    {
        do
        {
            varGfxLightmapArray = v3;
            Load_Stream(0, v3, 8u);
            varGfxImagePtr = &varGfxLightmapArray->primary;
            Load_GfxImagePtr(0);
            varGfxImagePtr = &varGfxLightmapArray->secondary;
            Load_GfxImagePtr(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_GfxLightDef@@YAX_N@Z at 0x822aa9c8
void Assets::Load_GfxLightDef(QDataStream *aStream)
{
    Load_Stream(1, varGfxLightDef, 0x10u);
    DB_PushStreamPos(4u);
    varXString = &varGfxLightDef->name;
    Load_XString(0);
    varGfxLightImage = &varGfxLightDef->attenuation;
    Load_Stream(0, &varGfxLightDef->attenuation, 8u);
    varGfxImagePtr = &varGfxLightImage->image;
    Load_GfxImagePtr(0);
    DB_PopStreamPos();
}


// ?Load_MaterialTextureDefInfo@@YAX_N@Z at 0x822aaa50
void Assets::Load_MaterialTextureDefInfo(QDataStream *aStream)
{
    GfxImage *image; // r11
    unsigned __int8 *v2; // r11

    if ( varMaterialTextureDef->semantic == 11 )
    {
        image = varMaterialTextureDefInfo->image;
        if ( varMaterialTextureDefInfo->image )
        {
            if ( image == (GfxImage *)-1 )
            {
                v2 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
                g_streamPos = v2;
                varMaterialTextureDefInfo->image = (GfxImage *)v2;
                varwater_t = (water_t *)v2;
                Load_water_t(1);
            }
            else
            {
                varMaterialTextureDefInfo->image = (GfxImage *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                       + ((((unsigned int)&image[-1].name + 3) >> 26) & 0x38)))[((unsigned int)&image[-1].name + 3) & 0x1FFFFFFF];
            }
        }
    }
    else
    {
        varGfxImagePtr = &varMaterialTextureDefInfo->image;
        Load_GfxImagePtr(0);
    }
}


// ?Load_MaterialPass@@YAX_N@Z at 0x822aaae0
void Assets::Load_MaterialPass(QDataStream *aStream)
{
    MaterialPass *v1; // r11
    MaterialVertexDeclaration *vertexDecl; // r10
    MaterialVertexDeclaration *v3; // r4
    MaterialPass *v4; // r11
    MaterialVertexShader *vertexShader; // r10
    int v6; // r4

    Load_Stream(0, varMaterialPass, 0x54u);
    v1 = varMaterialPass;
    vertexDecl = varMaterialPass->vertexDecl;
    if ( varMaterialPass->vertexDecl )
    {
        if ( vertexDecl == (MaterialVertexDeclaration *)-1 )
        {
            v3 = (MaterialVertexDeclaration *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = &v3->streamCount;
            varMaterialVertexDeclaration = v3;
            varMaterialPass->vertexDecl = v3;
            Load_Stream(1, v3, 0x40u);
            Load_BuildVertexDecl(&varMaterialPass->vertexDecl);
            v1 = varMaterialPass;
        }
        else
        {
            varMaterialPass->vertexDecl = (MaterialVertexDeclaration *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                               + ((((unsigned int)&vertexDecl[-1].routing.decl[14]
                                                                                                    + 3) >> 26) & 0x38)))[((unsigned int)&vertexDecl[-1].routing.decl[14] + 3) & 0x1FFFFFFF];
        }
    }
    varMaterialVertexShaderPtr = v1->vertexShaderArray;
    Load_MaterialVertexShaderPtrArray(0, 15);
    v4 = varMaterialPass;
    vertexShader = varMaterialPass->vertexShader;
    if ( vertexShader )
    {
        if ( vertexShader == (MaterialVertexShader *)-1 )
        {
            g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            varMaterialVertexShader = (MaterialVertexShader *)g_streamPos;
            varMaterialPass->vertexShader = (MaterialVertexShader *)g_streamPos;
            Load_MaterialVertexShader(1);
            v4 = varMaterialPass;
        }
        else
        {
            varMaterialPass->vertexShader = (MaterialVertexShader *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                            + ((((unsigned int)&varMaterialPass->vertexShader[-1].prog.loadDef.physicalPartSize
                                                                                                 + 1) >> 26) & 0x38)))[((int)&varMaterialPass->vertexShader[-1].prog.loadDef.physicalPartSize + 1) & 0x1FFFFFFF];
        }
    }
    varMaterialPixelShaderPtr = &v4->pixelShader;
    Load_MaterialPixelShaderPtr(0);
    if ( varMaterialPass->args )
    {
        v6 = varMaterialPass->stableArgCount + varMaterialPass->perObjArgCount + varMaterialPass->perPrimArgCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varMaterialShaderArgument = (MaterialShaderArgument *)g_streamPos;
        varMaterialPass->args = (MaterialShaderArgument *)g_streamPos;
        Load_MaterialShaderArgumentArray(1, v6);
    }
}


// ?Load_SoundFile@@YAX_N@Z at 0x822aac58
void Assets::Load_SoundFile(QDataStream *aStream)
{
    Load_Stream(1, varSoundFile, 0x10u);
    varSoundFileRef = &varSoundFile->u;
    Load_SoundFileRef(0);
}


// ?Load_XAnimParts@@YAX_N@Z at 0x822aaca8
void Assets::Load_XAnimParts(QDataStream *aStream)
{
    XAnimParts *v1; // r11
    int v2; // r4
    int notifyCount; // r4
    unsigned __int8 *v4; // r4
    size_t dataByteCount; // r5
    size_t v6; // r5
    unsigned __int8 *v7; // r4
    size_t v8; // r5
    unsigned __int8 *v9; // r4
    size_t v10; // r5
    unsigned __int8 *v11; // r4
    unsigned __int8 *v12; // r4
    size_t randomDataByteCount; // r5
    size_t v14; // r5
    unsigned __int8 *v15; // r4

    Load_Stream(1, varXAnimParts, 0x5Cu);         // 92
    DB_PushStreamPos(4u);
    varXString = &varXAnimParts->name;
    Load_XString(0);
    v1 = varXAnimParts;
    if ( varXAnimParts->names )
    {
        v2 = varXAnimParts->boneCount[11];
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 1) & 0xFFFFFFFE);
        varScriptString = (unsigned __int16 *)g_streamPos;
        varXAnimParts->names = (unsigned __int16 *)g_streamPos;
        Load_ScriptStringArray(1, v2);
        v1 = varXAnimParts;
    }
    if ( v1->notify )
    {
        notifyCount = v1->notifyCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varXAnimNotifyInfo = (XAnimNotifyInfo *)g_streamPos;
        v1->notify = (XAnimNotifyInfo *)g_streamPos;
        Load_XAnimNotifyInfoArray(1, notifyCount);
        v1 = varXAnimParts;
    }
    if ( v1->deltaPart )
    {
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varXAnimDeltaPart = (XAnimDeltaPart *)g_streamPos;
        v1->deltaPart = (XAnimDeltaPart *)g_streamPos;
        Load_XAnimDeltaPart(1);
        v1 = varXAnimParts;
    }
    if ( v1->dataByte )
    {
        v4 = g_streamPos;
        dataByteCount = v1->dataByteCount;
        varbyte = g_streamPos;
        v1->dataByte = g_streamPos;
        Load_Stream(1, v4, dataByteCount);
        v1 = varXAnimParts;
    }
    if ( v1->dataShort )
    {
        v6 = __ROL4__(v1->dataShortCount, 1);
        v7 = (unsigned __int8 *)((unsigned int)(g_streamPos + 1) & 0xFFFFFFFE);
        g_streamPos = v7;
        varshort = (__int16 *)v7;
        v1->dataShort = (__int16 *)v7;
        Load_Stream(1, v7, v6);
        v1 = varXAnimParts;
    }
    if ( v1->dataInt )
    {
        v8 = __ROL4__(v1->dataIntCount, 2);
        v9 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v9;
        varint = (int *)v9;
        v1->dataInt = (int *)v9;
        Load_Stream(1, v9, v8);
        v1 = varXAnimParts;
    }
    if ( v1->randomDataShort )
    {
        v10 = 2 * v1->randomDataShortCount;
        v11 = (unsigned __int8 *)((unsigned int)(g_streamPos + 1) & 0xFFFFFFFE);
        g_streamPos = v11;
        varshort = (__int16 *)v11;
        v1->randomDataShort = (__int16 *)v11;
        Load_Stream(1, v11, v10);
        v1 = varXAnimParts;
    }
    if ( v1->randomDataByte )
    {
        v12 = g_streamPos;
        randomDataByteCount = v1->randomDataByteCount;
        varbyte = g_streamPos;
        v1->randomDataByte = g_streamPos;
        Load_Stream(1, v12, randomDataByteCount);
        v1 = varXAnimParts;
    }
    if ( v1->randomDataInt )
    {
        v14 = __ROL4__(v1->randomDataIntCount, 2);
        v15 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v15;
        varint = (int *)v15;
        v1->randomDataInt = (int *)v15;
        Load_Stream(1, v15, v14);
        v1 = varXAnimParts;
    }
    varXAnimIndices = &v1->indices;
    Load_XAnimIndices(0);
    DB_PopStreamPos();
}


// ?Load_statement@@YAX_N@Z at 0x822aaef8
void Assets::Load_statement(QDataStream *aStream)
{
    int numEntries; // r4
    unsigned __int8 *v2; // r11

    Load_Stream(0, varstatement, 8u);
    if ( varstatement->entries )
    {
        numEntries = varstatement->numEntries;
        v2 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v2;
        varstatement->entries = (expressionEntry **)v2;
        varexpressionEntry_ptr = (expressionEntry **)v2;
        Load_expressionEntry_ptrArray(1, numEntries);
    }
}


// ?Load_GameWorldSpPtr@@YAX_N@Z at 0x822aaf70
void Assets::Load_GameWorldSpPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    GameWorldSp **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varGameWorldSpPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varGameWorldSpPtr;
    if ( *varGameWorldSpPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varGameWorldSpPtr = *(GameWorldSp **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                          + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varGameWorldSpPtr = (GameWorldSp *)v3;
        varGameWorldSp = (GameWorldSp *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_GameWorldSp(1);
        v5 = varGameWorldSpPtr;
        *v5 = (GameWorldSp *)DB_AddXAsset((XAssetHeader *)0xE, (XAssetHeader *)*varGameWorldSpPtr, v6);
        if ( inserted )
            *inserted = *varGameWorldSpPtr;
    }
    DB_PopStreamPos();
}


// ?Load_GfxLightDefPtr@@YAX_N@Z at 0x822ab058
void Assets::Load_GfxLightDefPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    XGfxLightDef **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varGfxLightDefPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varGfxLightDefPtr;
    if ( *varGfxLightDefPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varGfxLightDefPtr = *(GfxLightDef **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                          + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varGfxLightDefPtr = (GfxLightDef *)v3;
        varGfxLightDef = (GfxLightDef *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_GfxLightDef(1);
        v5 = varGfxLightDefPtr;
        *v5 = (GfxLightDef *)DB_AddXAsset((XAssetHeader *)0x12, (XAssetHeader *)*varGfxLightDefPtr, v6);
        if ( inserted )
            *inserted = *varGfxLightDefPtr;
    }
    DB_PopStreamPos();
}


// ?Load_MaterialTextureDef@@YAX_N@Z at 0x822ab140
void Assets::Load_MaterialTextureDef(QDataStream *aStream)
{
    Load_Stream(0, varMaterialTextureDef, 0xCu);
    varMaterialTextureDefInfo = &varMaterialTextureDef->u;
    Load_MaterialTextureDefInfo(0);
}


// ?Load_MaterialPassArray@@YAX_NH@Z at 0x822ab190
void Assets::Load_MaterialPassArray(QDataStream *aStream, int count)
{
    int v2; // r31
    MaterialPass *v3; // r30

    v2 = count;
    Load_Stream(1, varMaterialPass, 84 * count);
    v3 = varMaterialPass;
    if ( v2 > 0 )
    {
        do
        {
            varMaterialPass = v3;
            Load_MaterialPass(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_snd_alias_t@@YAX_N@Z at 0x822ab1e8
void Assets::Load_snd_alias_t(QDataStream *aStream)
{
    snd_alias_t *v1; // r11
    SoundFile *soundFile; // r10
    SpeakerMap *speakerMap; // r10

    Load_Stream(0, varsnd_alias_t, 0x5Cu);
    varXString = &varsnd_alias_t->aliasName;
    Load_XString(0);
    varXString = &varsnd_alias_t->subtitle;
    Load_XString(0);
    varXString = &varsnd_alias_t->secondaryAliasName;
    Load_XString(0);
    varXString = &varsnd_alias_t->chainAliasName;
    Load_XString(0);
    v1 = varsnd_alias_t;
    soundFile = varsnd_alias_t->soundFile;
    if ( soundFile )
    {
        if ( soundFile == (SoundFile *)-1 )
        {
            g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            varSoundFile = (SoundFile *)g_streamPos;
            varsnd_alias_t->soundFile = (SoundFile *)g_streamPos;
            Load_SoundFile(1);
            v1 = varsnd_alias_t;
        }
        else
        {
            varsnd_alias_t->soundFile = (SoundFile *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                             + ((((unsigned int)&varsnd_alias_t->soundFile[-1].u.streamSnd.filename.info.packed.length
                                                                                  + 3) >> 26) & 0x38)))[((int)&varsnd_alias_t->soundFile[-1].u.streamSnd.filename.info.packed.length
                                                                                                         + 3) & 0x1FFFFFFF];
        }
    }
    varSndCurvePtr = &v1->volumeFalloffCurve;
    Load_SndCurvePtr(0);
    speakerMap = varsnd_alias_t->speakerMap;
    if ( speakerMap )
    {
        if ( speakerMap == (SpeakerMap *)-1 )
        {
            g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            varSpeakerMap = (SpeakerMap *)g_streamPos;
            varsnd_alias_t->speakerMap = (SpeakerMap *)g_streamPos;
            Load_SpeakerMap(1);
        }
        else
        {
            varsnd_alias_t->speakerMap = (SpeakerMap *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                               + ((((unsigned int)&varsnd_alias_t->speakerMap[-1].channelMaps[1][1].paEntries
                                                                                    + 3) >> 26) & 0x38)))[((int)&varsnd_alias_t->speakerMap[-1].channelMaps[1][1].paEntries
                                                                                                           + 3) & 0x1FFFFFFF];
        }
    }
}


// ?Load_XAnimPartsPtr@@YAX_N@Z at 0x822ab348
void Assets::Load_XAnimPartsPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    XAnimParts **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varXAnimPartsPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varXAnimPartsPtr;
    if ( *varXAnimPartsPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varXAnimPartsPtr = *(XAnimParts **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                        + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varXAnimPartsPtr = (XAnimParts *)v3;
        varXAnimParts = (XAnimParts *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_XAnimParts(1);
        v5 = varXAnimPartsPtr;
        *v5 = (XAnimParts *)DB_AddXAsset((XAssetHeader *)2, (XAssetHeader *)*varXAnimPartsPtr, v6);
        if ( inserted )
            *inserted = *varXAnimPartsPtr;
    }
    DB_PopStreamPos();
}


// ?Load_GfxLight@@YAX_N@Z at 0x822ab430
void Assets::Load_GfxLight(QDataStream *aStream)
{
    Load_Stream(1, varGfxLight, 0x40u);
    varGfxLightDefPtr = &varGfxLight->def;
    Load_GfxLightDefPtr(0);
}


// ?Load_MaterialTextureDefArray@@YAX_NH@Z at 0x822ab480
void Assets::Load_MaterialTextureDefArray(QDataStream *aStream, int count)
{
    int v2; // r30
    MaterialTextureDef *v3; // r31

    v2 = count;
    Load_Stream(1, varMaterialTextureDef, 12 * count);
    v3 = varMaterialTextureDef;
    if ( v2 > 0 )
    {
        do
        {
            varMaterialTextureDef = v3;
            Load_Stream(0, v3, 0xCu);
            varMaterialTextureDefInfo = &varMaterialTextureDef->u;
            Load_MaterialTextureDefInfo(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_MaterialTechnique@@YAX_N@Z at 0x822ab500
void Assets::Load_MaterialTechnique(QDataStream *aStream)
{
    int passCount; // r4

    Load_Stream(1, varMaterialTechnique, 8u);
    passCount = varMaterialTechnique->passCount;
    varMaterialPass = varMaterialTechnique->passArray;
    Load_MaterialPassArray(1, passCount);
    varXString = &varMaterialTechnique->name;
    Load_XString(0);
}


// ?Load_snd_alias_tArray@@YAX_NH@Z at 0x822ab568
void Assets::Load_snd_alias_tArray(QDataStream *aStream, int count)
{
    int v2; // r31
    snd_alias_t *v3; // r30

    v2 = count;
    Load_Stream(1, varsnd_alias_t, 92 * count);
    v3 = varsnd_alias_t;
    if ( v2 > 0 )
    {
        do
        {
            varsnd_alias_t = v3;
            Load_snd_alias_t(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_snd_alias_list_t@@YAX_N@Z at 0x822ab620
void Assets::Load_snd_alias_list_t(QDataStream *aStream)
{
    snd_alias_t *head; // r10
    int count; // r4
    unsigned __int8 *v3; // r10

    Load_Stream(1, varsnd_alias_list_t, 0xCu);
    DB_PushStreamPos(4u);
    varXString = &varsnd_alias_list_t->aliasName;
    Load_XString(0);
    head = varsnd_alias_list_t->head;
    if ( head )
    {
        if ( head == (snd_alias_t *)-1 )
        {
            count = varsnd_alias_list_t->count;
            v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v3;
            varsnd_alias_list_t->head = (snd_alias_t *)v3;
            varsnd_alias_t = (snd_alias_t *)v3;
            Load_snd_alias_tArray(1, count);
        }
        else
        {
            varsnd_alias_list_t->head = (snd_alias_t *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                               + ((((unsigned int)&varsnd_alias_list_t->head[-1].speakerMap
                                                                                    + 3) >> 26) & 0x38)))[((int)&varsnd_alias_list_t->head[-1].speakerMap
                                                                                                           + 3) & 0x1FFFFFFF];
        }
    }
    DB_PopStreamPos();
}


// ?Load_MaterialTechniquePtrArray@@YAX_NH@Z at 0x822ab6e8
void Assets::Load_MaterialTechniquePtrArray(QDataStream *aStream, int count)
{
    MaterialTechnique **v2; // r31
    int v3; // r26
    int v4; // r11

    Load_Stream(0, varMaterialTechniquePtr, 0x68u);
    v2 = varMaterialTechniquePtr;
    v3 = 26;
    do
    {
        varMaterialTechniquePtr = v2;
        Load_Stream(0, v2, 4u);
        v4 = (int)*varMaterialTechniquePtr;
        if ( *varMaterialTechniquePtr )
        {
            if ( v4 == -1 )
            {
                g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
                varMaterialTechnique = (MaterialTechnique *)g_streamPos;
                *varMaterialTechniquePtr = (MaterialTechnique *)g_streamPos;
                Load_MaterialTechnique(1);
            }
            else
            {
                *varMaterialTechniquePtr = (MaterialTechnique *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                        + (((unsigned int)(v4 - 1) >> 26) & 0x38)))[(v4 - 1) & 0x1FFFFFFF];
            }
        }
        --v3;
        ++v2;
    }
    while ( v3 );
}


// ?Load_snd_alias_list_ptr@@YAX_N@Z at 0x822ab7a0
void Assets::Load_snd_alias_list_ptr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    SoundAliasList **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varsnd_alias_list_ptr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varsnd_alias_list_ptr;
    if ( *varsnd_alias_list_ptr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varsnd_alias_list_ptr = *(snd_alias_list_t **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                   + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varsnd_alias_list_ptr = (snd_alias_list_t *)v3;
        varsnd_alias_list_t = (snd_alias_list_t *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_snd_alias_list_t(1);
        v5 = varsnd_alias_list_ptr;
        *v5 = (snd_alias_list_t *)DB_AddXAsset((XAssetHeader *)8, (XAssetHeader *)*varsnd_alias_list_ptr, v6);
        if ( inserted )
            *inserted = *varsnd_alias_list_ptr;
    }
    DB_PopStreamPos();
}


// ?Load_MaterialTechniqueSet@@YAX_N@Z at 0x822ab888
void Assets::Load_MaterialTechniqueSet(QDataStream *aStream)
{
    Load_Stream(1, varMaterialTechniqueSet, 116);
    DB_PushStreamPos(4u);
    varXString = &varMaterialTechniqueSet->name;
    Load_XString(0);
    varMaterialTechniquePtr = varMaterialTechniqueSet->techniques;
    Load_MaterialTechniquePtrArray(0, 26);
    DB_PopStreamPos();
}


// ?Load_MaterialTechniqueSetPtr@@YAX_N@Z at 0x822ab900
void Assets::Load_MaterialTechniqueSetPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    MaterialTechniqueSet **v5; // r31
    XAssetHeader *v6; // r5
    XAssetHeader *v7; // r3

    Load_Stream(0, varMaterialTechniqueSetPtr, 4);
    DB_PushStreamPos(0);
    v1 = (int)*varMaterialTechniqueSetPtr;
    if ( *varMaterialTechniqueSetPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varMaterialTechniqueSetPtr = *(MaterialTechniqueSet **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                            + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varMaterialTechniqueSetPtr = (MaterialTechniqueSet *)v3;
        varMaterialTechniqueSet = (MaterialTechniqueSet *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_MaterialTechniqueSet(1);
        v5 = varMaterialTechniqueSetPtr;
        v7 = DB_AddXAsset((XAssetHeader *)6, (XAssetType)*varMaterialTechniqueSetPtr, v6);
        *v5 = (MaterialTechniqueSet *)v7;
        v7[2].xmodelPieces = (XModelPieces *)v7;
        if ( inserted )
            *inserted = *varMaterialTechniqueSetPtr;
    }
    DB_PopStreamPos();
}


// ?Load_Material@@YAX_N@Z at 0x822ab9f0
void Assets::Load_Material(QDataStream *aStream)
{
    Material *v1; // r11
    MaterialTextureDef *textureTable; // r10
    int textureCount; // r4
    MaterialConstantDef *constantTable; // r10
    size_t v5; // r5
    unsigned __int8 *v6; // r4
    GfxStateBits *stateBitsTable; // r10
    size_t v8; // r5
    unsigned __int8 *v9; // r4

    Load_Stream(1, varMaterial, 0x48u);
    DB_PushStreamPos(4u);
    varMaterialInfo = &varMaterial->info;
    Load_Stream(0, varMaterial, 0x18u);
    varXString = &varMaterialInfo->name;
    Load_XString(0);
    varMaterialTechniqueSetPtr = &varMaterial->techniqueSet;
    Load_MaterialTechniqueSetPtr(0);
    v1 = varMaterial;
    textureTable = varMaterial->textureTable;
    if ( textureTable )
    {
        if ( textureTable == (MaterialTextureDef *)-1 )
        {
            textureCount = varMaterial->textureCount;
            g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            varMaterialTextureDef = (MaterialTextureDef *)g_streamPos;
            varMaterial->textureTable = (MaterialTextureDef *)g_streamPos;
            Load_MaterialTextureDefArray(1, textureCount);
            v1 = varMaterial;
        }
        else
        {
            varMaterial->textureTable = (MaterialTextureDef *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                      + ((((unsigned int)&varMaterial->textureTable[-1].u.water
                                                                                           + 3) >> 26) & 0x38)))[((int)&varMaterial->textureTable[-1].u.water + 3) & 0x1FFFFFFF];
        }
    }
    constantTable = v1->constantTable;
    if ( constantTable )
    {
        if ( constantTable == (MaterialConstantDef *)-1 )
        {
            v5 = __ROL4__(v1->constantCount, 5);
            v6 = (unsigned __int8 *)((unsigned int)(g_streamPos + 15) & 0xFFFFFFF0);
            g_streamPos = v6;
            varMaterialConstantDef = (MaterialConstantDef *)v6;
            v1->constantTable = (MaterialConstantDef *)v6;
            Load_Stream(1, v6, v5);
            v1 = varMaterial;
        }
        else
        {
            v1->constantTable = (MaterialConstantDef *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                               + ((((unsigned int)&v1->constantTable[-1].literal[3]
                                                                                    + 3) >> 26) & 0x38)))[((int)&v1->constantTable[-1].literal[3]
                                                                                                           + 3) & 0x1FFFFFFF];
        }
    }
    stateBitsTable = v1->stateBitsTable;
    if ( stateBitsTable )
    {
        if ( stateBitsTable == (GfxStateBits *)-1 )
        {
            v8 = __ROL4__(v1->stateBitsCount, 3);
            v9 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v9;
            varGfxStateBits = (GfxStateBits *)v9;
            v1->stateBitsTable = (GfxStateBits *)v9;
            Load_Stream(1, v9, v8);
            DB_PopStreamPos();
            return;
        }
        v1->stateBitsTable = (GfxStateBits *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                     + ((((unsigned int)&v1->stateBitsTable[-1].loadBits[1] + 3) >> 26) & 0x38)))[((int)&v1->stateBitsTable[-1].loadBits[1] + 3) & 0x1FFFFFFF];
    }
    DB_PopStreamPos();
}


// ?Load_MaterialHandle@@YAX_N@Z at 0x822abbb0
void Assets::Load_MaterialHandle(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    Material **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varMaterialHandle, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varMaterialHandle;
    if ( *varMaterialHandle )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varMaterialHandle = *(Material **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                       + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varMaterialHandle = (Material *)v3;
        varMaterial = (Material *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_Material(1);
        v5 = varMaterialHandle;
        *v5 = (Material *)DB_AddXAsset((XAssetHeader *)4, (XAssetHeader *)*varMaterialHandle, v6);
        if ( inserted )
            *inserted = *varMaterialHandle;
    }
    DB_PopStreamPos();
}


// ?Load_Font@@YAX_N@Z at 0x822abc98
void Assets::Load_Font(QDataStream *aStream)
{
    Glyph *glyphs; // r10
    int glyphCount; // r10
    Glyph *v3; // r4

    Load_Stream(1, varFont, 0x18u);
    DB_PushStreamPos(4u);
    varXString = &varFont->fontName;
    Load_XString(0);
    varMaterialHandle = &varFont->material;
    Load_MaterialHandle(0);
    varMaterialHandle = &varFont->glowMaterial;
    Load_MaterialHandle(0);
    glyphs = varFont->glyphs;
    if ( glyphs )
    {
        if ( glyphs == (Glyph *)-1 )
        {
            glyphCount = varFont->glyphCount;
            v3 = (Glyph *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            varFont->glyphs = v3;
            g_streamPos = (unsigned __int8 *)v3;
            varGlyph = v3;
            Load_Stream(1, v3, 24 * glyphCount);
        }
        else
        {
            varFont->glyphs = (Glyph *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                               + ((((unsigned int)&varFont->glyphs[-1].t1 + 3) >> 26) & 0x38)))[((int)&varFont->glyphs[-1].t1 + 3) & 0x1FFFFFFF];
        }
    }
    DB_PopStreamPos();
}


// ?Load_MaterialMemory@@YAX_N@Z at 0x822abda0
void Assets::Load_MaterialMemory(QDataStream *aStream)
{
    Load_Stream(0, varMaterialMemory, 8u);
    varMaterialHandle = &varMaterialMemory->material;
    Load_MaterialHandle(0);
}


// ?Load_sunflare_t@@YAX_N@Z at 0x822abdf0
void Assets::Load_sunflare_t(QDataStream *aStream)
{
    Load_Stream(0, varsunflare_t, 0x60u);
    varMaterialHandle = &varsunflare_t->spriteMaterial;
    Load_MaterialHandle(0);
    varMaterialHandle = &varsunflare_t->flareMaterial;
    Load_MaterialHandle(0);
}


// ?Load_windowDef_t@@YAX_N@Z at 0x822abe60
void Assets::Load_windowDef_t(QDataStream *aStream)
{
    Load_Stream(0, varwindowDef_t, 0xA8u);
    varXString = &varwindowDef_t->name;
    Load_XString(0);
    varXString = &varwindowDef_t->group;
    Load_XString(0);
    varMaterialHandle = &varwindowDef_t->background;
    Load_MaterialHandle(0);
}


// ?Load_listBoxDef_t@@YAX_N@Z at 0x822abee0
void Assets::Load_listBoxDef_t(QDataStream *aStream)
{
    Load_Stream(1, varlistBoxDef_t, 0x168u);
    varXString = &varlistBoxDef_t->doubleClick;
    Load_XString(0);
    varMaterialHandle = &varlistBoxDef_t->selectIcon;
    Load_MaterialHandle(0);
}


// ?Load_GfxSurface@@YAX_N@Z at 0x822abf48
void Assets::Load_GfxSurface(QDataStream *aStream)
{
    Load_Stream(0, varGfxSurface, 0x48u);
    varMaterialHandle = &varGfxSurface->material;
    Load_MaterialHandle(0);
}


// ?Load_MaterialHandleArray@@YAX_NH@Z at 0x822abf98
void Assets::Load_MaterialHandleArray(QDataStream *aStream, int count)
{
    int v2; // r30
    Material **v3; // r31

    v2 = count;
    Load_Stream(atStreamStart, varMaterialHandle, 4 * count);
    v3 = varMaterialHandle;
    if ( v2 > 0 )
    {
        do
        {
            varMaterialHandle = v3;
            Load_MaterialHandle(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_FontHandle@@YAX_N@Z at 0x822abfe8
void Assets::Load_FontHandle(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    Font_s **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varFontHandle, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varFontHandle;
    if ( *varFontHandle )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varFontHandle = *(Font_s **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                 + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varFontHandle = (Font_s *)v3;
        varFont = (Font_s *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_Font(1);
        v5 = varFontHandle;
        *v5 = (Font_s *)DB_AddXAsset((XAssetHeader *)0x14, (XAssetHeader *)*varFontHandle, v6);
        if ( inserted )
            *inserted = *varFontHandle;
    }
    DB_PopStreamPos();
}


// ?Load_MaterialMemoryArray@@YAX_NH@Z at 0x822ac0d0
void Assets::Load_MaterialMemoryArray(QDataStream *aStream, int count)
{
    int v2; // r30
    MaterialMemory *v3; // r31

    v2 = count;
    Load_Stream(1, varMaterialMemory, 8 * count);
    v3 = varMaterialMemory;
    if ( v2 > 0 )
    {
        do
        {
            varMaterialMemory = v3;
            Load_Stream(0, v3, 8u);
            varMaterialHandle = &varMaterialMemory->material;
            Load_MaterialHandle(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_Window@@YAX_N@Z at 0x822ac140
void Assets::Load_Window(QDataStream *aStream)
{
    Load_Stream(0, varWindow, 0xA8u);
    varwindowDef_t = varWindow;
    Load_windowDef_t(0);
}


// ?Load_FxElemMarkVisuals@@YAX_N@Z at 0x822ac1c0
void Assets::Load_FxElemMarkVisuals(QDataStream *aStream)
{
    Material **v1; // r30
    int v2; // r31

    Load_Stream(0, varFxElemMarkVisuals, 8u);
    varMaterialHandle = (Material **)varFxElemMarkVisuals;
    Load_Stream(0, varFxElemMarkVisuals, 8u);
    v1 = varMaterialHandle;
    v2 = 2;
    do
    {
        varMaterialHandle = v1;
        Load_MaterialHandle(0);
        --v2;
        ++v1;
    }
    while ( v2 );
}


// ?Load_XModel@@YAX_N@Z at 0x822ac228
void Assets::Load_XModel(QDataStream *aStream)
{
    XModel *v1; // r11
    unsigned __int16 *boneNames; // r10
    int numBones; // r4
    unsigned __int8 *parentList; // r10
    unsigned __int8 *v5; // r4
    size_t v6; // r5
    __int16 *quats; // r10
    unsigned __int8 *v8; // r4
    size_t v9; // r5
    float *trans; // r10
    unsigned __int8 *v11; // r4
    size_t v12; // r5
    unsigned __int8 *partClassification; // r10
    unsigned __int8 *v14; // r4
    size_t v15; // r5
    DObjAnimMat *baseMat; // r10
    size_t v17; // r5
    unsigned __int8 *v18; // r4
    int numsurfs; // r4
    int v20; // r4
    int numCollSurfs; // r4
    int v22; // r10
    unsigned __int8 *v23; // r4
    XModelHighMipBounds *v24; // r4
    PhysGeomList *physGeoms; // r10

    Load_Stream(1, varXModel, 0xCCu);
    DB_PushStreamPos(4u);
    varXString = &varXModel->name;
    Load_XString(0);
    v1 = varXModel;
    boneNames = varXModel->boneNames;
    if ( boneNames )
    {
        if ( boneNames == (unsigned __int16 *)-1 )
        {
            numBones = varXModel->numBones;
            g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 1) & 0xFFFFFFFE);
            varScriptString = (unsigned __int16 *)g_streamPos;
            varXModel->boneNames = (unsigned __int16 *)g_streamPos;
            Load_ScriptStringArray(1, numBones);
            v1 = varXModel;
        }
        else
        {
            varXModel->boneNames = (unsigned __int16 *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                               + ((((unsigned int)varXModel->boneNames - 1) >> 26) & 0x38)))[((int)varXModel->boneNames - 1) & 0x1FFFFFFF];
        }
    }
    parentList = v1->parentList;
    if ( parentList )
    {
        if ( parentList == (unsigned __int8 *)-1 )
        {
            v5 = g_streamPos;
            v6 = v1->numBones - v1->numRootBones;
            varbyte = g_streamPos;
            v1->parentList = g_streamPos;
            Load_Stream(1, v5, v6);
            v1 = varXModel;
        }
        else
        {
            v1->parentList = &(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                     + (((unsigned int)(v1->parentList - 1) >> 26) & 0x38)))[(int)(v1->parentList - 1) & 0x1FFFFFFF];
        }
    }
    quats = v1->quats;
    if ( quats )
    {
        if ( quats == (__int16 *)-1 )
        {
            v8 = (unsigned __int8 *)((unsigned int)(g_streamPos + 1) & 0xFFFFFFFE);
            v9 = 8 * (v1->numBones - v1->numRootBones);
            g_streamPos = v8;
            v1->quats = (__int16 *)v8;
            varshort = (__int16 *)v8;
            Load_Stream(1, v8, v9);
            v1 = varXModel;
        }
        else
        {
            v1->quats = (__int16 *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                           + ((((unsigned int)v1->quats - 1) >> 26) & 0x38)))[((int)v1->quats - 1) & 0x1FFFFFFF];
        }
    }
    trans = v1->trans;
    if ( trans )
    {
        if ( trans == (float *)-1 )
        {
            v11 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            v12 = 16 * (v1->numBones - v1->numRootBones);
            g_streamPos = v11;
            v1->trans = (float *)v11;
            varfloat = (float *)v11;
            Load_Stream(1, v11, v12);
            v1 = varXModel;
        }
        else
        {
            v1->trans = (float *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                         + ((((unsigned int)v1->trans - 1) >> 26) & 0x38)))[((int)v1->trans - 1) & 0x1FFFFFFF];
        }
    }
    partClassification = v1->partClassification;
    if ( partClassification )
    {
        if ( partClassification == (unsigned __int8 *)-1 )
        {
            v14 = g_streamPos;
            v15 = v1->numBones;
            varbyte = g_streamPos;
            v1->partClassification = g_streamPos;
            Load_Stream(1, v14, v15);
            v1 = varXModel;
        }
        else
        {
            v1->partClassification = &(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                             + (((unsigned int)(v1->partClassification - 1) >> 26) & 0x38)))[(int)(v1->partClassification - 1) & 0x1FFFFFFF];
        }
    }
    baseMat = v1->baseMat;
    if ( baseMat )
    {
        if ( baseMat == (DObjAnimMat *)-1 )
        {
            v17 = __ROL4__(v1->numBones, 5);
            v18 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v18;
            varDObjAnimMat = (DObjAnimMat *)v18;
            v1->baseMat = (DObjAnimMat *)v18;
            Load_Stream(1, v18, v17);
            v1 = varXModel;
        }
        else
        {
            v1->baseMat = (DObjAnimMat *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                 + ((((unsigned int)&v1->baseMat[-1].transWeight + 3) >> 26) & 0x38)))[((int)&v1->baseMat[-1].transWeight + 3) & 0x1FFFFFFF];
        }
    }
    if ( v1->surfs )
    {
        numsurfs = v1->numsurfs;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varXSurface = (XSurface *)g_streamPos;
        v1->surfs = (XSurface *)g_streamPos;
        Load_XSurfaceArray(1, numsurfs);
        v1 = varXModel;
    }
    if ( v1->materialHandles )
    {
        v20 = v1->numsurfs;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varMaterialHandle = (Material **)g_streamPos;
        v1->materialHandles = (Material **)g_streamPos;
        Load_MaterialHandleArray(1, v20);
        v1 = varXModel;
    }
    if ( v1->collSurfs )
    {
        numCollSurfs = v1->numCollSurfs;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varXModelCollSurf = (XModelCollSurf_s *)g_streamPos;
        v1->collSurfs = (XModelCollSurf_s *)g_streamPos;
        Load_XModelCollSurfArray(1, numCollSurfs);
        v1 = varXModel;
    }
    if ( v1->boneInfo )
    {
        v22 = v1->numBones;
        v23 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v1->boneInfo = (XBoneInfo *)v23;
        g_streamPos = v23;
        varXBoneInfo = (XBoneInfo *)v23;
        Load_Stream(1, v23, 8 * (v22 + __ROL4__(v22, 2)));
        v1 = varXModel;
    }
    varXModelStreamInfo = &v1->streamInfo;
    Load_Stream(0, &v1->streamInfo, 4u);
    if ( varXModelStreamInfo->highMipBounds )
    {
        v24 = (XModelHighMipBounds *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varXModelStreamInfo->highMipBounds = v24;
        varXModelHighMipBounds = v24;
        g_streamPos = (unsigned __int8 *)v24;
        Load_Stream(1, v24, 8 * (varXModel->lodInfo[0].numsurfs + __ROL4__(varXModel->lodInfo[0].numsurfs, 1)));
    }
    varPhysPresetPtr = &varXModel->physPreset;
    Load_PhysPresetPtr(0);
    physGeoms = varXModel->physGeoms;
    if ( physGeoms )
    {
        if ( physGeoms == (PhysGeomList *)-1 )
        {
            g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            varPhysGeomList = (PhysGeomList *)g_streamPos;
            varXModel->physGeoms = (PhysGeomList *)g_streamPos;
            Load_PhysGeomList(1);
            DB_PopStreamPos();
            return;
        }
        varXModel->physGeoms = (PhysGeomList *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                       + ((((unsigned int)&varXModel->physGeoms[-1].mass.productsOfInertia[2]
                                                                            + 3) >> 26) & 0x38)))[((int)&varXModel->physGeoms[-1].mass.productsOfInertia[2]
                                                                                                   + 3) & 0x1FFFFFFF];
    }
    DB_PopStreamPos();
}


// ?Load_GfxSurfaceArray@@YAX_NH@Z at 0x822ac6b0
void Assets::Load_GfxSurfaceArray(QDataStream *aStream, int count)
{
    int v2; // r30
    GfxSurface *v3; // r31

    v2 = count;
    Load_Stream(1, varGfxSurface, 72 * count);
    v3 = varGfxSurface;
    if ( v2 > 0 )
    {
        do
        {
            varGfxSurface = v3;
            Load_Stream(0, v3, 0x48u);
            varMaterialHandle = &varGfxSurface->material;
            Load_MaterialHandle(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_itemDefData_t@@YAX_N@Z at 0x822ac730
void Assets::Load_itemDefData_t(QDataStream *aStream)
{
    int type; // r11
    unsigned __int8 *v2; // r11
    unsigned __int8 *v3; // r11
    unsigned __int8 *v4; // r4

    type = varitemDef_t->type;
    switch ( type )
    {
    case 6:
        varlistBoxDef_ptr = &varitemDefData_t->listBox;
        Load_Stream(0, varitemDefData_t, 4u);
        if ( *varlistBoxDef_ptr )
        {
            v2 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v2;
            *varlistBoxDef_ptr = (listBoxDef_s *)v2;
            varlistBoxDef_t = (listBoxDef_s *)v2;
            Load_listBoxDef_t(1);
        }
        break;
    case 4:
    case 9:
    case 16:
    case 18:
    case 11:
    case 14:
    case 10:
    case 0:
    case 17:
        vareditFieldDef_ptr = (editFieldDef_s **)varitemDefData_t;
        Load_Stream(0, varitemDefData_t, 4u);
        if ( *vareditFieldDef_ptr )
        {
            v4 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v4;
            *vareditFieldDef_ptr = (editFieldDef_s *)v4;
            vareditFieldDef_t = (editFieldDef_s *)v4;
            Load_Stream(1, v4, 0x20u);
        }
        break;
    case 12:
        varmultiDef_ptr = (multiDef_s **)varitemDefData_t;
        Load_Stream(0, varitemDefData_t, 4u);
        if ( *varmultiDef_ptr )
        {
            v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v3;
            *varmultiDef_ptr = (multiDef_s *)v3;
            varMultiDef = (multiDef_s *)v3;
            Load_MultiDef(1);
        }
        break;
    case 13:
        varXString = (const char **)varitemDefData_t;
        Load_XString(0);
        break;
    }
}


// ?Load_FxElemMarkVisualsArray@@YAX_NH@Z at 0x822ac918
void Assets::Load_FxElemMarkVisualsArray(QDataStream *aStream, int count)
{
    int v2; // r31
    FxElemMarkVisuals *v3; // r30

    v2 = count;
    Load_Stream(1, varFxElemMarkVisuals, 8 * count);
    v3 = varFxElemMarkVisuals;
    if ( v2 > 0 )
    {
        do
        {
            varFxElemMarkVisuals = v3;
            Load_FxElemMarkVisuals(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_XModelPtr@@YAX_N@Z at 0x822ac970
void Assets::Load_XModelPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    XModel **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varXModelPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varXModelPtr;
    if ( *varXModelPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varXModelPtr = *(XModel **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varXModelPtr = (XModel *)v3;
        varXModel = (XModel *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_XModel(1);
        v5 = varXModelPtr;
        *v5 = (XModel *)DB_AddXAsset((XAssetHeader *)3, (XAssetHeader *)*varXModelPtr, v6);
        if ( inserted )
            *inserted = *varXModelPtr;
    }
    DB_PopStreamPos();
}


// ?Load_GfxStaticModelDrawInst@@YAX_N@Z at 0x822aca58
void Assets::Load_GfxStaticModelDrawInst(QDataStream *aStream)
{
    Load_Stream(0, varGfxStaticModelDrawInst, 0x2Cu);
    varXModelPtr = &varGfxStaticModelDrawInst->model;
    Load_XModelPtr(0);
}


// ?Load_itemDef_t@@YAX_N@Z at 0x822acaa8
void Assets::Load_itemDef_t(QDataStream *aStream)
{
    ItemDef *v1; // r11
    unsigned __int8 *v2; // r10

    Load_Stream(1, varitemDef_t, 0x1D4u);
    varWindow = &varitemDef_t->window;
    Load_Stream(0, varitemDef_t, 0xA8u);
    varwindowDef_t = varWindow;
    Load_windowDef_t(0);
    varXString = &varitemDef_t->text;
    Load_XString(0);
    varXString = &varitemDef_t->mouseEnterText;
    Load_XString(0);
    varXString = &varitemDef_t->mouseExitText;
    Load_XString(0);
    varXString = &varitemDef_t->mouseEnter;
    Load_XString(0);
    varXString = &varitemDef_t->mouseExit;
    Load_XString(0);
    varXString = &varitemDef_t->action;
    Load_XString(0);
    varXString = &varitemDef_t->onAccept;
    Load_XString(0);
    varXString = &varitemDef_t->onFocus;
    Load_XString(0);
    varXString = &varitemDef_t->leaveFocus;
    Load_XString(0);
    varXString = &varitemDef_t->dvar;
    Load_XString(0);
    varXString = &varitemDef_t->dvarTest;
    Load_XString(0);
    v1 = varitemDef_t;
    if ( varitemDef_t->onKey )
    {
        v2 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v2;
        varitemDef_t->onKey = (XItemKeyHandler *)v2;
        varItemKeyHandler = (XItemKeyHandler *)v2;
        Load_ItemKeyHandler(1);
        v1 = varitemDef_t;
    }
    varXString = &v1->enableDvar;
    Load_XString(0);
    varsnd_alias_list_ptr = &varitemDef_t->focusSound;
    Load_snd_alias_list_ptr(0);
    varitemDefData_t = &varitemDef_t->typeData;
    Load_itemDefData_t(0);
    varstatement = &varitemDef_t->visibleExp;
    Load_statement(0);
    varstatement = &varitemDef_t->textExp;
    Load_statement(0);
    varstatement = &varitemDef_t->materialExp;
    Load_statement(0);
    varstatement = &varitemDef_t->rectXExp;
    Load_statement(0);
    varstatement = &varitemDef_t->rectYExp;
    Load_statement(0);
    varstatement = &varitemDef_t->rectWExp;
    Load_statement(0);
    varstatement = &varitemDef_t->rectHExp;
    Load_statement(0);
    varstatement = &varitemDef_t->forecolorAExp;
    Load_statement(0);
}


// ?Load_cStaticModel_t@@YAX_N@Z at 0x822acd18
void Assets::Load_cStaticModel_t(QDataStream *aStream)
{
    Load_Stream(0, varcStaticModel_t, 0x50u);
    varXModelPtr = &varcStaticModel_t->xmodel;
    Load_XModelPtr(0);
}


// ?Load_FxElemVisuals@@YAX_N@Z at 0x822acd68
void Assets::Load_FxElemVisuals(QDataStream *aStream)
{
    int elemType; // r11

    elemType = varFxElemDef->elemType;
    switch ( elemType )
    {
    case 5:
        varXModelPtr = (XModel **)varFxElemVisuals;
        Load_XModelPtr(0);
        break;
    case 10:
        varFxEffectDefRef = (FxEffectDefRef *)varFxElemVisuals;
        Load_FxEffectDefRef(0);
        break;
    case 8:
        varXString = (const char **)varFxElemVisuals;
        Load_XString(0);
        break;
    default:
        if ( elemType != 6 && elemType != 7 )
        {
            varMaterialHandle = (Material **)varFxElemVisuals;
            Load_MaterialHandle(0);
        }
        break;
    }
}


// ?Load_XModelPiece@@YAX_N@Z at 0x822ace00
void Assets::Load_XModelPiece(QDataStream *aStream)
{
    Load_Stream(0, varXModelPiece, 0x10u);
    varXModelPtr = &varXModelPiece->model;
    Load_XModelPtr(0);
}


// ?Load_XModelPtrArray@@YAX_NH@Z at 0x822ace50
void Assets::Load_XModelPtrArray(QDataStream *aStream, int count)
{
    XModel **v2; // r30
    int v3; // r31

    Load_Stream(0, varXModelPtr, 0x40u);
    v2 = varXModelPtr;
    v3 = 16;
    do
    {
        varXModelPtr = v2;
        Load_XModelPtr(0);
        --v3;
        ++v2;
    }
    while ( v3 );
}


// ?Load_GfxStaticModelDrawInstArray@@YAX_NH@Z at 0x822acea0
void Assets::Load_GfxStaticModelDrawInstArray(QDataStream *aStream, int count)
{
    int v2; // r30
    GfxStaticModelDrawInst *v3; // r31

    v2 = count;
    Load_Stream(1, varGfxStaticModelDrawInst, 44 * count);
    v3 = varGfxStaticModelDrawInst;
    if ( v2 > 0 )
    {
        do
        {
            varGfxStaticModelDrawInst = v3;
            Load_Stream(0, v3, 0x2Cu);
            varXModelPtr = &varGfxStaticModelDrawInst->model;
            Load_XModelPtr(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_cStaticModel_tArray@@YAX_NH@Z at 0x822acf48
void Assets::Load_cStaticModel_tArray(QDataStream *aStream, int count)
{
    int v2; // r30
    cStaticModel_s *v3; // r31

    v2 = count;
    Load_Stream(1, varcStaticModel_t, 80 * count);
    v3 = varcStaticModel_t;
    if ( v2 > 0 )
    {
        do
        {
            varcStaticModel_t = v3;
            Load_Stream(0, v3, 0x50u);
            varXModelPtr = &varcStaticModel_t->xmodel;
            Load_XModelPtr(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_FxElemVisualsArray@@YAX_NH@Z at 0x822acfc8
void Assets::Load_FxElemVisualsArray(QDataStream *aStream, int count)
{
    int v2; // r31
    FxElemVisuals *v3; // r30

    v2 = count;
    Load_Stream(1, varFxElemVisuals, 4 * count);
    v3 = varFxElemVisuals;
    if ( v2 > 0 )
    {
        do
        {
            varFxElemVisuals = v3;
            Load_FxElemVisuals(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_XModelPieceArray@@YAX_NH@Z at 0x822ad020
void Assets::Load_XModelPieceArray(QDataStream *aStream, int count)
{
    int v2; // r30
    XModelPiece *v3; // r31

    v2 = count;
    Load_Stream(1, varXModelPiece, 16 * count);
    v3 = varXModelPiece;
    if ( v2 > 0 )
    {
        do
        {
            varXModelPiece = v3;
            Load_Stream(0, v3, 0x10u);
            varXModelPtr = &varXModelPiece->model;
            Load_XModelPtr(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_GfxWorldDpvsStatic@@YAX_N@Z at 0x822ad090
void Assets::Load_GfxWorldDpvsStatic(QDataStream *aStream)
{
    bool v1; // r3
    GfxWorldDpvsStatic *v2; // r31
    unsigned __int8 *v3; // r4
    size_t smodelCount; // r5
    bool v5; // r3
    unsigned __int8 *v6; // r4
    size_t v7; // r5
    bool v8; // r3
    unsigned __int8 *v9; // r4
    size_t v10; // r5
    bool v11; // r3
    unsigned __int8 *v12; // r4
    size_t staticSurfaceCount; // r5
    bool v14; // r3
    unsigned __int8 *v15; // r4
    size_t v16; // r5
    bool v17; // r3
    unsigned __int8 *v18; // r4
    size_t v19; // r5
    bool v20; // r3
    size_t v21; // r5
    unsigned __int8 *v22; // r4
    size_t v23; // r5
    unsigned __int8 *v24; // r4
    size_t v25; // r5
    unsigned __int8 *v26; // r4
    unsigned __int8 *v27; // r11
    GfxCullGroup *v28; // r4
    int v29; // r4
    bool v30; // r3
    size_t v31; // r5
    unsigned __int8 *v32; // r4
    bool v33; // r3
    size_t v34; // r5
    unsigned __int8 *v35; // r4

    Load_Stream(0, varGfxWorldDpvsStatic, 0x64u);
    DB_PushStreamPos(1u);
    v2 = varGfxWorldDpvsStatic;
    if ( varGfxWorldDpvsStatic->smodelVisData[0] )
    {
        v3 = g_streamPos;
        smodelCount = varGfxWorldDpvsStatic->smodelCount;
        varraw_byte = g_streamPos;
        varGfxWorldDpvsStatic->smodelVisData[0] = g_streamPos;
        Load_Stream(v1, v3, smodelCount);
        v2 = varGfxWorldDpvsStatic;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v2->smodelVisData[1] )
    {
        v6 = g_streamPos;
        v7 = v2->smodelCount;
        varraw_byte = g_streamPos;
        v2->smodelVisData[1] = g_streamPos;
        Load_Stream(v5, v6, v7);
        v2 = varGfxWorldDpvsStatic;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v2->smodelVisData[2] )
    {
        v9 = g_streamPos;
        v10 = v2->smodelCount;
        varraw_byte = g_streamPos;
        v2->smodelVisData[2] = g_streamPos;
        Load_Stream(v8, v9, v10);
        v2 = varGfxWorldDpvsStatic;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v2->surfaceVisData[0] )
    {
        v12 = g_streamPos;
        staticSurfaceCount = v2->staticSurfaceCount;
        varraw_byte = g_streamPos;
        v2->surfaceVisData[0] = g_streamPos;
        Load_Stream(v11, v12, staticSurfaceCount);
        v2 = varGfxWorldDpvsStatic;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v2->surfaceVisData[1] )
    {
        v15 = g_streamPos;
        v16 = v2->staticSurfaceCount;
        varraw_byte = g_streamPos;
        v2->surfaceVisData[1] = g_streamPos;
        Load_Stream(v14, v15, v16);
        v2 = varGfxWorldDpvsStatic;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v2->surfaceVisData[2] )
    {
        v18 = g_streamPos;
        v19 = v2->staticSurfaceCount;
        varraw_byte = g_streamPos;
        v2->surfaceVisData[2] = g_streamPos;
        Load_Stream(v17, v18, v19);
        v2 = varGfxWorldDpvsStatic;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v2->lodData )
    {
        v21 = 8 * v2->smodelVisDataCount;
        v22 = (unsigned __int8 *)((unsigned int)(g_streamPos + 127) & 0xFFFFFF80);
        g_streamPos = v22;
        varraw_uint128 = (unsigned int *)v22;
        v2->lodData = (unsigned int *)v22;
        Load_Stream(v20, v22, v21);
        v2 = varGfxWorldDpvsStatic;
    }
    DB_PopStreamPos();
    if ( v2->sortedSurfIndex )
    {
        v23 = 2 * v2->staticSurfaceCount;
        v24 = (unsigned __int8 *)((unsigned int)(g_streamPos + 1) & 0xFFFFFFFE);
        g_streamPos = v24;
        varushort = (unsigned __int16 *)v24;
        v2->sortedSurfIndex = (unsigned __int16 *)v24;
        Load_Stream(1, v24, v23);
        v2 = varGfxWorldDpvsStatic;
    }
    if ( v2->smodelInsts )
    {
        v25 = 28 * v2->smodelCount;
        v26 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v26;
        v2->smodelInsts = (GfxStaticModelInst *)v26;
        varGfxStaticModelInst = (GfxStaticModelInst *)v26;
        Load_Stream(1, v26, v25);
        v2 = varGfxWorldDpvsStatic;
    }
    if ( v2->surfaces )
    {
        v27 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v2->surfaces = (GfxSurface *)v27;
        g_streamPos = v27;
        varGfxSurface = (GfxSurface *)v27;
        Load_GfxSurfaceArray(1, varGfxWorld->surfaceCount);
        v2 = varGfxWorldDpvsStatic;
    }
    if ( v2->cullGroups )
    {
        v28 = (GfxCullGroup *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v2->cullGroups = v28;
        varGfxCullGroup = v28;
        g_streamPos = (unsigned __int8 *)v28;
        Load_Stream(1, v28, 32 * varGfxWorld->cullGroupCount);
        v2 = varGfxWorldDpvsStatic;
    }
    if ( v2->smodelDrawInsts )
    {
        v29 = v2->smodelCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varGfxStaticModelDrawInst = (GfxStaticModelDrawInst *)g_streamPos;
        v2->smodelDrawInsts = (GfxStaticModelDrawInst *)g_streamPos;
        Load_GfxStaticModelDrawInstArray(1, v29);
        v2 = varGfxWorldDpvsStatic;
    }
    DB_PushStreamPos(1u);
    if ( v2->surfaceMaterials )
    {
        v31 = 8 * v2->staticSurfaceCount;
        v32 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v32;
        varGfxDrawSurfFields = (GfxDrawSurfFields *)v32;
        v2->surfaceMaterials = (GfxDrawSurfFields *)v32;
        Load_Stream(v30, v32, v31);
        v2 = varGfxWorldDpvsStatic;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v2->surfaceCastsSunShadow )
    {
        v34 = 4 * v2->surfaceVisDataCount;
        v35 = (unsigned __int8 *)((unsigned int)(g_streamPos + 127) & 0xFFFFFF80);
        g_streamPos = v35;
        varraw_uint128 = (unsigned int *)v35;
        v2->surfaceCastsSunShadow = (unsigned int *)v35;
        Load_Stream(v33, v35, v34);
    }
    DB_PopStreamPos();
}


// ?Load_itemDef_ptrArray@@YAX_NH@Z at 0x822ad3f0
void Assets::Load_itemDef_ptrArray(QDataStream *aStream, int count)
{
    int v2; // r31
    ItemDef **v3; // r29

    v2 = count;
    Load_Stream(1, varitemDef_ptr, 4 * count);
    v3 = varitemDef_ptr;
    if ( v2 > 0 )
    {
        do
        {
            varitemDef_ptr = v3;
            Load_Stream(0, v3, 4u);
            if ( *varitemDef_ptr )
            {
                g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
                varitemDef_t = (ItemDef *)g_streamPos;
                *varitemDef_ptr = (ItemDef *)g_streamPos;
                Load_itemDef_t(1);
            }
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_FxElemDefVisuals@@YAX_N@Z at 0x822ad488
void Assets::Load_FxElemDefVisuals(QDataStream *aStream)
{
    FxElemDef *v1; // r9
    unsigned __int8 *v2; // r11
    int visualCount; // r4
    unsigned __int8 *v4; // r11
    int v5; // r4

    v1 = varFxElemDef;
    if ( varFxElemDef->elemType == 9 )
    {
        if ( varFxElemDefVisuals->markArray )
        {
            v2 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v2;
            varFxElemDefVisuals->markArray = (FxElemMarkVisuals *)v2;
            visualCount = v1->visualCount;
            varFxElemMarkVisuals = (FxElemMarkVisuals *)v2;
            Load_FxElemMarkVisualsArray(1, visualCount);
        }
    }
    else if ( varFxElemDef->visualCount > 1u )
    {
        if ( varFxElemDefVisuals->markArray )
        {
            v4 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v4;
            varFxElemDefVisuals->markArray = (FxElemMarkVisuals *)v4;
            v5 = v1->visualCount;
            varFxElemVisuals = (FxElemVisuals *)v4;
            Load_FxElemVisualsArray(1, v5);
        }
    }
    else
    {
        varFxElemVisuals = (FxElemVisuals *)varFxElemDefVisuals;
        Load_FxElemVisuals(0);
    }
}


// ?Load_XModelPieces@@YAX_N@Z at 0x822ad540
void Assets::Load_XModelPieces(QDataStream *aStream)
{
    int numpieces; // r4
    unsigned __int8 *v2; // r11

    Load_Stream(1, varXModelPieces, 0xCu);
    varXString = &varXModelPieces->name;
    Load_XString(0);
    if ( varXModelPieces->pieces )
    {
        numpieces = varXModelPieces->numpieces;
        v2 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v2;
        varXModelPieces->pieces = (XModelPiece *)v2;
        varXModelPiece = (XModelPiece *)v2;
        Load_XModelPieceArray(1, numpieces);
    }
}


// ?Load_GfxWorld@@YAX_N@Z at 0x822ad5c8
void Assets::Load_GfxWorld(QDataStream *aStream)
{
    GfxWorld *v1; // r11
    size_t v2; // r5
    unsigned __int8 *v3; // r4
    D3DIndexBuffer *p_indexBuffer; // r30
    unsigned __int16 *indices; // r28
    GfxWorld *v6; // r11
    size_t v7; // r5
    unsigned __int8 *v8; // r4
    GfxWorld *v9; // r30
    GfxLight *sunLight; // r11
    int reflectionProbeCount; // r4
    bool v12; // r3
    size_t v13; // r5
    unsigned __int8 *v14; // r4
    GfxWorld *v15; // r11
    int cellCount; // r4
    int lightmapCount; // r4
    bool v18; // r3
    GfxWorld *v19; // r30
    size_t v20; // r5
    unsigned __int8 *v21; // r4
    bool v22; // r3
    size_t v23; // r5
    unsigned __int8 *v24; // r4
    size_t v25; // r5
    unsigned __int8 *v26; // r4
    int materialMemoryCount; // r4
    bool v28; // r3
    GfxWorld *v29; // r30
    unsigned __int8 *v30; // r4
    int v31; // r11
    bool v32; // r3
    unsigned int v33; // r11
    unsigned __int8 *v34; // r4
    bool v35; // r3
    size_t v36; // r5
    unsigned __int8 *v37; // r4
    bool v38; // r3
    unsigned __int8 *v39; // r4
    size_t v40; // r5
    bool v41; // r3
    unsigned __int8 *v42; // r4
    int v43; // r11
    bool v44; // r3
    unsigned __int8 *v45; // r4
    int v46; // r11
    bool v47; // r3
    unsigned __int8 *v48; // r4
    size_t v49; // r5
    int primaryLightCount; // r4
    int v51; // r4

    Load_Stream(1, varGfxWorld, 0x33Cu);
    DB_PushStreamPos(4u);
    varXString = &varGfxWorld->name;
    Load_XString(0);
    varXString = &varGfxWorld->baseName;
    Load_XString(0);
    v1 = varGfxWorld;
    if ( varGfxWorld->indices )
    {
        v2 = 2 * varGfxWorld->indexCount;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 1) & 0xFFFFFFFE);
        g_streamPos = v3;
        varr_index_t = (unsigned __int16 *)v3;
        varGfxWorld->indices = (unsigned __int16 *)v3;
        Load_Stream(1, v3, v2);
        v1 = varGfxWorld;
    }
    varGfxIndexBuffer = &v1->indexBuffer;
    Load_Stream(0, &v1->indexBuffer, 0x20u);
    p_indexBuffer = &varGfxWorld->indexBuffer;
    indices = varGfxWorld->indices;
    XGSetIndexBufferHeader(2 * varGfxWorld->indexCount, 0, D3DFMT_INDEX16, 0, 0, &varGfxWorld->indexBuffer);
    XGOffsetResourceAddress(p_indexBuffer, indices);
    varGfxWorldStreamInfo = &varGfxWorld->streamInfo;
    Load_GfxWorldStreamInfo(0);
    v6 = varGfxWorld;
    if ( varGfxWorld->skyStartSurfs )
    {
        v7 = 4 * varGfxWorld->skySurfCount;
        v8 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v8;
        varint = (int *)v8;
        varGfxWorld->skyStartSurfs = (int *)v8;
        Load_Stream(1, v8, v7);
        v6 = varGfxWorld;
    }
    varGfxImagePtr = &v6->skyImage;
    Load_GfxImagePtr(0);
    v9 = varGfxWorld;
    sunLight = varGfxWorld->sunLight;
    if ( sunLight )
    {
        if ( sunLight == (GfxLight *)-1 )
        {
            g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            varGfxLight = (GfxLight *)g_streamPos;
            varGfxWorld->sunLight = (GfxLight *)g_streamPos;
            Load_GfxLight(1);
            v9 = varGfxWorld;
        }
        else
        {
            varGfxWorld->sunLight = (GfxLight *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                        + ((((unsigned int)&varGfxWorld->sunLight[-1].def + 3) >> 26) & 0x38)))[((int)&varGfxWorld->sunLight[-1].def + 3) & 0x1FFFFFFF];
        }
    }
    if ( v9->reflectionProbes )
    {
        reflectionProbeCount = v9->reflectionProbeCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varGfxReflectionProbe = (GfxReflectionProbe *)g_streamPos;
        v9->reflectionProbes = (GfxReflectionProbe *)g_streamPos;
        Load_GfxReflectionProbeArray(1, reflectionProbeCount);
        v9 = varGfxWorld;
    }
    DB_PushStreamPos(1u);
    if ( v9->reflectionProbeTextures )
    {
        v13 = 4 * v9->reflectionProbeCount;
        v14 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v14;
        varGfxRawTexture = (GfxTexture *)v14;
        v9->reflectionProbeTextures = (GfxTexture *)v14;
        Load_Stream(v12, v14, v13);
        v9 = varGfxWorld;
    }
    DB_PopStreamPos();
    varGfxWorldDpvsPlanes = &v9->dpvsPlanes;
    Load_GfxWorldDpvsPlanes(0);
    v15 = varGfxWorld;
    if ( varGfxWorld->cells )
    {
        cellCount = varGfxWorld->dpvsPlanes.cellCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varGfxCell = (GfxCell *)g_streamPos;
        varGfxWorld->cells = (GfxCell *)g_streamPos;
        Load_GfxCellArray(1, cellCount);
        v15 = varGfxWorld;
    }
    if ( v15->lightmaps )
    {
        lightmapCount = v15->lightmapCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varGfxLightmapArray = (GfxLightmapArray *)g_streamPos;
        v15->lightmaps = (GfxLightmapArray *)g_streamPos;
        Load_GfxLightmapArrayArray(1, lightmapCount);
        v15 = varGfxWorld;
    }
    varGfxLightGrid = &v15->lightGrid;
    Load_GfxLightGrid(0);
    DB_PushStreamPos(1u);
    v19 = varGfxWorld;
    if ( varGfxWorld->lightmapPrimaryTextures )
    {
        v20 = 4 * varGfxWorld->lightmapCount;
        v21 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v21;
        varGfxRawTexture = (GfxTexture *)v21;
        varGfxWorld->lightmapPrimaryTextures = (GfxTexture *)v21;
        Load_Stream(v18, v21, v20);
        v19 = varGfxWorld;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v19->lightmapSecondaryTextures )
    {
        v23 = 4 * v19->lightmapCount;
        v24 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v24;
        varGfxRawTexture = (GfxTexture *)v24;
        v19->lightmapSecondaryTextures = (GfxTexture *)v24;
        Load_Stream(v22, v24, v23);
        v19 = varGfxWorld;
    }
    DB_PopStreamPos();
    if ( v19->models )
    {
        v25 = 56 * v19->modelCount;
        v26 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v26;
        v19->models = (GfxBrushModel *)v26;
        varGfxBrushModel = (GfxBrushModel *)v26;
        Load_Stream(1, v26, v25);
        v19 = varGfxWorld;
    }
    if ( v19->materialMemory )
    {
        materialMemoryCount = v19->materialMemoryCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varMaterialMemory = (MaterialMemory *)g_streamPos;
        v19->materialMemory = (MaterialMemory *)g_streamPos;
        Load_MaterialMemoryArray(1, materialMemoryCount);
        v19 = varGfxWorld;
    }
    varGfxWorldVertexData = &v19->vd;
    Load_GfxWorldVertexData(0);
    varGfxWorldVertexLayerData = &varGfxWorld->vld;
    Load_GfxWorldVertexLayerData(0);
    varsunflare_t = &varGfxWorld->sun;
    Load_sunflare_t(0);
    varGfxImagePtr = &varGfxWorld->outdoorImage;
    Load_GfxImagePtr(0);
    DB_PushStreamPos(1u);
    v29 = varGfxWorld;
    if ( varGfxWorld->cellCasterBits )
    {
        v30 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v31 = ((varGfxWorld->dpvsPlanes.cellCount + 31) >> 5) * varGfxWorld->dpvsPlanes.cellCount;
        g_streamPos = v30;
        varraw_uint = (unsigned int *)v30;
        varGfxWorld->cellCasterBits = (unsigned int *)v30;
        Load_Stream(v28, v30, 4 * v31);
        v29 = varGfxWorld;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v29->sceneDynModel )
    {
        v33 = v29->dpvsDyn.dynEntClientCount[0];
        v34 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v34;
        varGfxSceneDynModel = (GfxSceneDynModel *)v34;
        v29->sceneDynModel = (GfxSceneDynModel *)v34;
        Load_Stream(v32, v34, 6 * v33);
        v29 = varGfxWorld;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v29->sceneDynBrush )
    {
        v36 = 4 * v29->dpvsDyn.dynEntClientCount[1];
        v37 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v37;
        varGfxSceneDynBrush = (GfxSceneDynBrush *)v37;
        v29->sceneDynBrush = (GfxSceneDynBrush *)v37;
        Load_Stream(v35, v37, v36);
        v29 = varGfxWorld;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v29->primaryLightEntityShadowVis )
    {
        v39 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v40 = (v29->primaryLightCount - v29->sunPrimaryLightIndex - 1) << 14;
        g_streamPos = v39;
        varraw_uint = (unsigned int *)v39;
        v29->primaryLightEntityShadowVis = (unsigned int *)v39;
        Load_Stream(v38, v39, v40);
        v29 = varGfxWorld;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v29->primaryLightDynEntShadowVis[0] )
    {
        v42 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v43 = (v29->primaryLightCount - v29->sunPrimaryLightIndex - 1) * v29->dpvsDyn.dynEntClientCount[0];
        g_streamPos = v42;
        v29->primaryLightDynEntShadowVis[0] = (unsigned int *)v42;
        varraw_uint = (unsigned int *)v42;
        Load_Stream(v41, v42, 4 * v43);
        v29 = varGfxWorld;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v29->primaryLightDynEntShadowVis[1] )
    {
        v45 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v46 = (v29->primaryLightCount - v29->sunPrimaryLightIndex - 1) * v29->dpvsDyn.dynEntClientCount[1];
        g_streamPos = v45;
        v29->primaryLightDynEntShadowVis[1] = (unsigned int *)v45;
        varraw_uint = (unsigned int *)v45;
        Load_Stream(v44, v45, 4 * v46);
        v29 = varGfxWorld;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v29->nonSunPrimaryLightForModelDynEnt )
    {
        v48 = g_streamPos;
        v49 = v29->dpvsDyn.dynEntClientCount[0];
        varraw_byte = g_streamPos;
        v29->nonSunPrimaryLightForModelDynEnt = g_streamPos;
        Load_Stream(v47, v48, v49);
        v29 = varGfxWorld;
    }
    DB_PopStreamPos();
    if ( v29->shadowGeom )
    {
        primaryLightCount = v29->primaryLightCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varGfxShadowGeometry = (GfxShadowGeometry *)g_streamPos;
        v29->shadowGeom = (GfxShadowGeometry *)g_streamPos;
        Load_GfxShadowGeometryArray(1, primaryLightCount);
        v29 = varGfxWorld;
    }
    if ( v29->lightRegion )
    {
        v51 = v29->primaryLightCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varGfxLightRegion = (GfxLightRegion *)g_streamPos;
        v29->lightRegion = (GfxLightRegion *)g_streamPos;
        Load_GfxLightRegionArray(1, v51);
        v29 = varGfxWorld;
    }
    varGfxWorldDpvsStatic = &v29->dpvs;
    Load_GfxWorldDpvsStatic(0);
    varGfxWorldDpvsDynamic = &varGfxWorld->dpvsDyn;
    Load_GfxWorldDpvsDynamic(0);
    DB_PopStreamPos();
}


// ?Load_menuDef_t@@YAX_N@Z at 0x822adca0
void Assets::Load_menuDef_t(QDataStream *aStream)
{
    menuDef_t *v1; // r11
    int itemCount; // r4

    Load_Stream(1, varmenuDef_t, 0x134u);
    DB_PushStreamPos(4u);
    varWindow = &varmenuDef_t->window;
    Load_Stream(0, varmenuDef_t, 0xA8u);
    varwindowDef_t = varWindow;
    Load_windowDef_t(0);
    varXString = &varmenuDef_t->font;
    Load_XString(0);
    varXString = &varmenuDef_t->onOpen;
    Load_XString(0);
    varXString = &varmenuDef_t->onClose;
    Load_XString(0);
    varXString = &varmenuDef_t->onESC;
    Load_XString(0);
    v1 = varmenuDef_t;
    if ( varmenuDef_t->onKey )
    {
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varItemKeyHandler = (XItemKeyHandler *)g_streamPos;
        varmenuDef_t->onKey = (XItemKeyHandler *)g_streamPos;
        Load_ItemKeyHandler(1);
        v1 = varmenuDef_t;
    }
    varstatement = &v1->visibleExp;
    Load_statement(0);
    varXString = &varmenuDef_t->allowedBinding;
    Load_XString(0);
    varXString = &varmenuDef_t->soundName;
    Load_XString(0);
    varstatement = &varmenuDef_t->rectXExp;
    Load_statement(0);
    varstatement = &varmenuDef_t->rectYExp;
    Load_statement(0);
    if ( varmenuDef_t->items )
    {
        itemCount = varmenuDef_t->itemCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varitemDef_ptr = (ItemDef **)g_streamPos;
        varmenuDef_t->items = (ItemDef **)g_streamPos;
        Load_itemDef_ptrArray(1, itemCount);
    }
    DB_PopStreamPos();
}


// ?Load_FxElemDef@@YAX_N@Z at 0x822ade30
void Assets::Load_FxElemDef(QDataStream *aStream)
{
    FxElemDef *v1; // r11
    int v2; // r10
    FxElemVelStateSample *v3; // r4
    int v4; // r10
    FxElemVisStateSample *v5; // r4

    Load_Stream(0, (void *)varFxElemDef, 0xFCu);
    v1 = varFxElemDef;
    if ( varFxElemDef->velSamples )
    {
        v2 = varFxElemDef->velIntervalCount + 1;
        v3 = (FxElemVelStateSample *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varFxElemDef->velSamples = v3;
        g_streamPos = (unsigned __int8 *)v3;
        varFxElemVelStateSample = v3;
        Load_Stream(1, (void *)v3, 96 * v2);
        v1 = varFxElemDef;
    }
    if ( v1->visSamples )
    {
        v4 = v1->visStateIntervalCount + 1;
        v5 = (FxElemVisStateSample *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v1->visSamples = v5;
        g_streamPos = (unsigned __int8 *)v5;
        varFxElemVisStateSample = v5;
        Load_Stream(1, (void *)v5, 48 * v4);
        v1 = varFxElemDef;
    }
    varFxElemDefVisuals = &v1->visuals;
    Load_FxElemDefVisuals(0);
    varFxEffectDefRef = &varFxElemDef->effectOnImpact;
    Load_FxEffectDefRef(0);
    varFxEffectDefRef = &varFxElemDef->effectOnDeath;
    Load_FxEffectDefRef(0);
    varFxEffectDefRef = &varFxElemDef->effectEmitted;
    Load_FxEffectDefRef(0);
    if ( varFxElemDef->trailDef )
    {
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varFxTrailDef = (FxTrailDef *)g_streamPos;
        varFxElemDef->trailDef = (FxTrailDef *)g_streamPos;
        Load_FxTrailDef(1);
    }
}


// ?Load_GfxWorldPtr@@YAX_N@Z at 0x822adfd8
void Assets::Load_GfxWorldPtr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r30
    GfxWorld **v5; // r31
    XAssetHeader *v6; // r5

    Load_Stream(0, varGfxWorldPtr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varGfxWorldPtr;
    if ( *varGfxWorldPtr )
    {
        if ( v1 != -1 && v1 != -2 )
        {
            *varGfxWorldPtr = *(GfxWorld **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                    + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
            return;
        }
        v2 = v1 == -2;
        v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v3;
        *varGfxWorldPtr = (GfxWorld *)v3;
        varGfxWorld = (GfxWorld *)v3;
        if ( v2 )
            inserted = DB_InsertPointer();
        else
            inserted = 0;
        Load_GfxWorld(1);
        v5 = varGfxWorldPtr;
        *v5 = (GfxWorld *)DB_AddXAsset((XAssetHeader *)0x11, (XAssetHeader *)*varGfxWorldPtr, v6);
        if ( inserted )
            *inserted = *varGfxWorldPtr;
    }
    DB_PopStreamPos();
}


// ?Load_menuDef_ptr@@YAX_N@Z at 0x822ae0c0
void Assets::Load_menuDef_ptr(QDataStream *aStream)
{
    int v1; // r11
    bool v2; // cr58
    unsigned __int8 *v3; // r11
    const void **inserted; // r31
    XAssetHeader *v5; // r5
    int v6; // r4

    Load_Stream(0, varmenuDef_ptr, 4u);
    DB_PushStreamPos(0);
    v1 = (int)*varmenuDef_ptr;
    if ( *varmenuDef_ptr )
    {
        if ( v1 == -1 || v1 == -2 )
        {
            v2 = v1 == -2;
            v3 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
            g_streamPos = v3;
            *varmenuDef_ptr = (menuDef_t *)v3;
            varmenuDef_t = (menuDef_t *)v3;
            if ( v2 )
                inserted = DB_InsertPointer();
            else
                inserted = 0;
            Load_menuDef_t(1);
            Load_MenuAsset(varmenuDef_ptr, v6, v5);
            if ( inserted )
                *inserted = *varmenuDef_ptr;
        }
        else
        {
            *varmenuDef_ptr = *(menuDef_t **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                     + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
        }
    }
    DB_PopStreamPos();
}


// ?Load_FxElemDefArray@@YAX_NH@Z at 0x822ae1b0
void Assets::Load_FxElemDefArray(QDataStream *aStream, int count)
{
    int v2; // r31
    FxElemDef *v3; // r30

    v2 = count;
    Load_Stream(1, (void *)varFxElemDef, 252 * count);
    v3 = varFxElemDef;
    if ( v2 > 0 )
    {
        do
        {
            varFxElemDef = v3;
            Load_FxElemDef(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }
}


// ?Load_menuDef_ptrArray@@YAX_NH@Z at 0x822ae208
QVector<menuDef_t> Assets::Load_menuDef_ptrArray(QDataStream *aStream, int count)
{
    QVector<menuDef_t> result;
    QVector<qint32> menuDefPtr;

    for (int i = 0; i < count; i++) {
        menuDef_t menuDef;

        *aStream
                >> menuDef.

                result << menuDef;
    }

    v2 = count;
    Load_Stream(1, varmenuDef_ptr, 4 * count);
    v3 = varmenuDef_ptr;
    if ( v2 > 0 )
    {
        do
        {
            varmenuDef_ptr = v3;
            Load_menuDef_ptr(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }

    return result;
}


// ?Load_FxEffectDef@@YAX_N@Z at 0x822ae260
FxEffectDef Assets::Load_FxEffectDef(QDataStream *aStream)
{
    FxEffectDef result;

    *aStream
            >> result.namePtr
            >> result.flags
            >> result.totalSize
            >> result.msecLoopingLife
            >> result.elemDefCountLooping
            >> result.elemDefCountOneShot
            >> result.elemDefCountEmission
            >> result.elemDefsPtr;

    if (result.namePtr)
    {
        result.name = Load_XStringCustom(aStream);
    }

    if (result.elemDefsPtr)
    {
        result.elemDefs = Load_FxElemDefArray(aStream, result.elemDefCountEmission + result.elemDefCountOneShot + result.elemDefCountLooping);
    }

    return result;
}


// ?Load_FxEffectDefHandle@@YAX_N@Z at 0x822ae308
FxEffectDef Assets::Load_FxEffectDefHandle(QDataStream *aStream)
{
    FxEffectDef result;

    qint32 fxEffectDefPtr;
    *aStream >> fxEffectDefPtr;

    if (fxEffectDefPtr)
    {
        if (fxEffectDefPtr == -1 || fxEffectDefPtr == -2)
        {
            result = Load_FxEffectDef(aStream);
        }
        else {
            *varFxEffectDefHandle = *(const FxEffectDef **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                                   + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
            DB_PopStreamPos();
        }
    }

    return result
}


// ?Load_WeaponDef@@YAX_N@Z at 0x822ae3f0
WeaponDef Assets::Load_WeaponDef(QDataStream *aStream)
{
    WeaponDef result;

    *aStream
            >> result.szInternalNamePtr
            >> result.szDisplayNamePtr
            >> result.szOverlayNamePtr
            >> result.gunXModelPtr
            >> result.handXModelPtr;

    for (int i = 0; i < 33; i++) {
        *aStream >> result.szXAnimsPtr[i];
    }

    *aStream
            >> result.szModeNamePtr
            >> result.hideTags[8];

    for (int i = 0; i < 8; i++)
    {
        *aStream >> result.hideTags[i];
    }
    for (int i = 0; i < 16; i++)
    {
        *aStream >> result.notetrackSoundMapKeys[i];
    }
    for (int i = 0; i < 16; i++)
    {
        *aStream >> result.notetrackSoundMapValues[i];
    }

    *aStream
            >> result.playerAnimType
            >> result.weapType
            >> result.weapClass
            >> result.penetrateType
            >> result.impactType
            >> result.inventoryType
            >> result.fireType
            >> result.offhandClass
            >> result.stance
            >> result.viewFlashEffectPtr
            >> result.worldFlashEffectPtr
            >> result.pickupSoundPtr
            >> result.pickupSoundPlayerPtr
            >> result.ammoPickupSoundPtr
            >> result.ammoPickupSoundPlayerPtr
            >> result.projectileSoundPtr
            >> result.pullbackSoundPtr
            >> result.pullbackSoundPlayerPtr
            >> result.fireSoundPtr
            >> result.fireSoundPlayerPtr
            >> result.fireLoopSoundPtr
            >> result.fireLoopSoundPlayerPtr
            >> result.fireStopSoundPtr
            >> result.fireStopSoundPlayerPtr
            >> result.fireLastSoundPtr
            >> result.fireLastSoundPlayerPtr
            >> result.emptyFireSoundPtr
            >> result.emptyFireSoundPlayerPtr
            >> result.meleeSwipeSoundPtr
            >> result.meleeSwipeSoundPlayerPtr
            >> result.meleeHitSoundPtr
            >> result.meleeMissSoundPtr
            >> result.rechamberSoundPtr
            >> result.rechamberSoundPlayerPtr
            >> result.reloadSoundPtr
            >> result.reloadSoundPlayerPtr
            >> result.reloadEmptySoundPtr
            >> result.reloadEmptySoundPlayerPtr
            >> result.reloadStartSoundPtr
            >> result.reloadStartSoundPlayerPtr
            >> result.reloadEndSoundPtr
            >> result.reloadEndSoundPlayerPtr
            >> result.detonateSoundPtr
            >> result.detonateSoundPlayerPtr
            >> result.nightVisionWearSoundPtr
            >> result.nightVisionWearSoundPlayerPtr
            >> result.nightVisionRemoveSoundPtr
            >> result.nightVisionRemoveSoundPlayerPtr
            >> result.altSwitchSoundPtr
            >> result.altSwitchSoundPlayerPtr
            >> result.raiseSoundPtr
            >> result.raiseSoundPlayerPtr
            >> result.firstRaiseSoundPtr
            >> result.firstRaiseSoundPlayerPtr
            >> result.putawaySoundPtr
            >> result.putawaySoundPlayerPtr
            >> result.bounceSoundPtr
            >> result.viewShellEjectEffectPtr
            >> result.worldShellEjectEffectPtr
            >> result.viewLastShotEjectEffectPtr
            >> result.worldLastShotEjectEffectPtr
            >> result.reticleCenterPtr
            >> result.reticleSidePtr
            >> result.iReticleCenterSize
            >> result.iReticleSideSize
            >> result.iReticleMinOfs
            >> result.activeReticleType
            >> result.vStandMove[0]
            >> result.vStandMove[1]
            >> result.vStandMove[2]
            >> result.vStandRot[0]
            >> result.vStandRot[1]
            >> result.vStandRot[2]
            >> result.vDuckedOfs[0]
            >> result.vDuckedOfs[1]
            >> result.vDuckedOfs[2]
            >> result.vDuckedMove[0]
            >> result.vDuckedMove[1]
            >> result.vDuckedMove[2]
            >> result.vDuckedRot[0]
            >> result.vDuckedRot[1]
            >> result.vDuckedRot[2]
            >> result.vProneOfs[0]
            >> result.vProneOfs[1]
            >> result.vProneOfs[2]
            >> result.vProneMove[0]
            >> result.vProneMove[1]
            >> result.vProneMove[2]
            >> result.vProneRot[0]
            >> result.vProneRot[1]
            >> result.vProneRot[2]
            >> result.fPosMoveRate
            >> result.fPosProneMoveRate
            >> result.fStandMoveMinSpeed
            >> result.fDuckedMoveMinSpeed
            >> result.fProneMoveMinSpeed
            >> result.fPosRotRate
            >> result.fPosProneRotRate
            >> result.fStandRotMinSpeed
            >> result.fDuckedRotMinSpeed
            >> result.fProneRotMinSpeed
            >> result.worldModelPtr
            >> result.worldClipModelPtr
            >> result.rocketModelPtr
            >> result.knifeModelPtr
            >> result.worldKnifeModelPtr
            >> result.hudIconPtr
            >> result.hudIconRatio
            >> result.ammoCounterIconPtr
            >> result.ammoCounterIconRatio
            >> result.iStartAmmo
            >> result.szAmmoNamePtr
            >> result.iAmmoIndex
            >> result.szClipNamePtr
            >> result.iClipIndex
            >> result.iMaxAmmo
            >> result.iClipSize
            >> result.shotCount
            >> result.szSharedAmmoCapNamePtr
            >> result.iSharedAmmoCapIndex
            >> result.iSharedAmmoCap
            >> result.damage
            >> result.playerDamage
            >> result.iMeleeDamage
            >> result.iDamageType
            >> result.iFireDelay
            >> result.iMeleeDelay
            >> result.meleeChargeDelay
            >> result.iDetonateDelay
            >> result.iFireTime
            >> result.iRechamberTime
            >> result.iRechamberBoltTime
            >> result.iHoldFireTime
            >> result.iDetonateTime
            >> result.iMeleeTime
            >> result.meleeChargeTime
            >> result.iReloadTime
            >> result.reloadShowRocketTime
            >> result.iReloadEmptyTime
            >> result.iReloadAddTime
            >> result.iReloadStartTime
            >> result.iReloadStartAddTime
            >> result.iReloadEndTime
            >> result.iDropTime
            >> result.iRaiseTime
            >> result.iAltDropTime
            >> result.iAltRaiseTime
            >> result.quickDropTime
            >> result.quickRaiseTime
            >> result.iFirstRaiseTime
            >> result.iEmptyRaiseTime
            >> result.iEmptyDropTime
            >> result.sprintInTime
            >> result.sprintLoopTime
            >> result.sprintOutTime
            >> result.nightVisionWearTime
            >> result.nightVisionWearTimeFadeOutEnd
            >> result.nightVisionWearTimePowerUp
            >> result.nightVisionRemoveTime
            >> result.nightVisionRemoveTimePowerDown
            >> result.nightVisionRemoveTimeFadeInStart
            >> result.fuseTime
            >> result.aiFuseTime
            >> result.requireLockonToFire
            >> result.noAdsWhenMagEmpty
            >> result.avoidDropCleanup
            >> result.autoAimRange
            >> result.aimAssistRange
            >> result.aimAssistRangeAds
            >> result.aimPadding
            >> result.enemyCrosshairRange
            >> result.crosshairColorChange
            >> result.moveSpeedScale
            >> result.adsMoveSpeedScale
            >> result.sprintDurationScale
            >> result.fAdsZoomFov
            >> result.fAdsZoomInFrac
            >> result.fAdsZoomOutFrac
            >> result.overlayMaterialPtr
            >> result.overlayMaterialLowResPtr
            >> result.overlayReticle
            >> result.overlayInterface
            >> result.overlayWidth
            >> result.overlayHeight
            >> result.fAdsBobFactor
            >> result.fAdsViewBobMult
            >> result.fHipSpreadStandMin
            >> result.fHipSpreadDuckedMin
            >> result.fHipSpreadProneMin
            >> result.hipSpreadStandMax
            >> result.hipSpreadDuckedMax
            >> result.hipSpreadProneMax
            >> result.fHipSpreadDecayRate
            >> result.fHipSpreadFireAdd
            >> result.fHipSpreadTurnAdd
            >> result.fHipSpreadMoveAdd
            >> result.fHipSpreadDuckedDecay
            >> result.fHipSpreadProneDecay
            >> result.fHipReticleSidePos
            >> result.iAdsTransInTime
            >> result.iAdsTransOutTime
            >> result.fAdsIdleAmount
            >> result.fHipIdleAmount
            >> result.adsIdleSpeed
            >> result.hipIdleSpeed
            >> result.fIdleCrouchFactor
            >> result.fIdleProneFactor
            >> result.fGunMaxPitch
            >> result.fGunMaxYaw
            >> result.swayMaxAngle
            >> result.swayLerpSpeed
            >> result.swayPitchScale
            >> result.swayYawScale
            >> result.swayHorizScale
            >> result.swayVertScale
            >> result.swayShellShockScale
            >> result.adsSwayMaxAngle
            >> result.adsSwayLerpSpeed
            >> result.adsSwayPitchScale
            >> result.adsSwayYawScale
            >> result.adsSwayHorizScale
            >> result.adsSwayVertScale
            >> result.bRifleBullet
            >> result.armorPiercing
            >> result.bBoltAction
            >> result.aimDownSight
            >> result.bRechamberWhileAds
            >> result.adsViewErrorMin
            >> result.adsViewErrorMax
            >> result.bCookOffHold
            >> result.bClipOnly
            >> result.adsFireOnly
            >> result.cancelAutoHolsterWhenEmpty
            >> result.suppressAmmoReserveDisplay
            >> result.enhanced
            >> result.laserSightDuringNightvision
            >> result.killIconPtr
            >> result.killIconRatio
            >> result.flipKillIcon
            >> result.dpadIconPtr
            >> result.dpadIconRatio
            >> result.bNoPartialReload
            >> result.bSegmentedReload
            >> result.iReloadAmmoAdd
            >> result.iReloadStartAdd
            >> result.szAltWeaponNamePtr
            >> result.dpadIconRatio
            >> result.dpadIconRatio
            >> result.dpadIconRatio
            >> result.altWeaponIndex
            >> result.iDropAmmoMin
            >> result.iDropAmmoMax
            >> result.blocksProne
            >> result.silenced
            >> result.iExplosionRadius
            >> result.iExplosionRadiusMin
            >> result.iExplosionInnerDamage
            >> result.iExplosionOuterDamage
            >> result.damageConeAngle
            >> result.iProjectileSpeed
            >> result.iProjectileSpeedUp
            >> result.iProjectileSpeedForward
            >> result.iProjectileActivateDist
            >> result.projLifetime
            >> result.timeToAccelerate
            >> result.projectileCurvature
            >> result.projectileModelPtr
            >> result.projExplosion
            >> result.projExplosionEffectPtr
            >> result.projExplosionEffectForceNormalUp
            >> result.projDudEffectPtr
            >> result.projExplosionSoundPtr
            >> result.projDudSoundPtr
            >> result.bProjImpactExplode
            >> result.stickiness
            >> result.bProjImpactExplode
            >> result.hasDetonator
            >> result.bProjImpactExplode
            >> result.timedDetonation
            >> result.rotate
            >> result.holdButtonToThrow
            >> result.freezeMovementWhenFiring
            >> result.lowAmmoWarningThreshold
            >> result.bProjImpactExplode;

    for (int i = 0; i < 29; i++) {
        *aStream >> result.parallelBounce[i];
    }
    for (int i = 0; i < 29; i++) {
        *aStream >> result.perpendicularBounce[i];
    }

    *aStream
            >> result.projTrailEffectPtr
            >> result.vProjectileColor[0]
            >> result.vProjectileColor[1]
            >> result.vProjectileColor[2]
            >> result.guidedMissileType
            >> result.maxSteeringAccel
            >> result.projIgnitionDelay
            >> result.projIgnitionEffect
            >> result.projIgnitionSoundPtr
            >> result.fAdsAimPitch
            >> result.fAdsCrosshairInFrac
            >> result.fAdsCrosshairOutFrac
            >> result.adsGunKickReducedKickBullets
            >> result.adsGunKickReducedKickPercent
            >> result.fAdsGunKickPitchMin
            >> result.fAdsGunKickPitchMax
            >> result.fAdsGunKickYawMin
            >> result.fAdsGunKickYawMax
            >> result.fAdsGunKickAccel
            >> result.fAdsGunKickSpeedMax
            >> result.fAdsGunKickSpeedDecay
            >> result.fAdsGunKickStaticDecay
            >> result.fAdsViewKickPitchMin
            >> result.fAdsViewKickPitchMax
            >> result.fAdsViewKickYawMin
            >> result.fAdsViewKickYawMax
            >> result.fAdsViewKickCenterSpeed
            >> result.fAdsViewScatterMin
            >> result.fAdsViewScatterMax
            >> result.fAdsSpread
            >> result.hipGunKickReducedKickBullets
            >> result.hipGunKickReducedKickPercent
            >> result.fHipGunKickPitchMin
            >> result.fHipGunKickPitchMax
            >> result.fHipGunKickYawMin
            >> result.fHipGunKickYawMax
            >> result.fHipGunKickAccel
            >> result.fHipGunKickSpeedMax
            >> result.fHipGunKickSpeedDecay
            >> result.fHipGunKickStaticDecay
            >> result.fHipViewKickPitchMin
            >> result.fHipViewKickPitchMax
            >> result.fHipViewKickYawMin
            >> result.fHipViewKickYawMax
            >> result.fHipViewKickCenterSpeed
            >> result.fHipViewScatterMin
            >> result.fHipViewScatterMax
            >> result.fightDist
            >> result.maxDist
            >> result.accuracyGraphNamePtr[0]
            >> result.accuracyGraphNamePtr[1]
            >> result.accuracyGraphKnotsPtr[0]
            >> result.accuracyGraphKnotsPtr[1]
            >> result.originalAccuracyGraphKnotsPtr[0]
            >> result.originalAccuracyGraphKnotsPtr[1]
            >> result.accuracyGraphKnotCount[0]
            >> result.accuracyGraphKnotCount[1]
            >> result.originalAccuracyGraphKnotCount[0]
            >> result.originalAccuracyGraphKnotCount[1]
            >> result.iPositionReloadTransTime
            >> result.leftArc
            >> result.rightArc
            >> result.topArc
            >> result.bottomArc
            >> result.accuracy
            >> result.aiSpread
            >> result.playerSpread
            >> result.minTurnSpeed[0]
            >> result.minTurnSpeed[1]
            >> result.maxTurnSpeed[0]
            >> result.maxTurnSpeed[1]
            >> result.pitchConvergenceTime
            >> result.yawConvergenceTime
            >> result.suppressTime
            >> result.maxRange
            >> result.fAnimHorRotateInc
            >> result.fPlayerPositionDist
            >> result.szUseHintStringPtr
            >> result.dropHintStringPtr
            >> result.iUseHintStringIndex
            >> result.dropHintStringIndex
            >> result.horizViewJitter
            >> result.vertViewJitter
            >> result.szScriptPtr
            >> result.fOOPosAnimLength[0]
            >> result.fOOPosAnimLength[1]
            >> result.minDamage
            >> result.minPlayerDamage
            >> result.fMaxDamageRange
            >> result.fMinDamageRange
            >> result.destabilizationRateTime
            >> result.destabilizationCurvatureMax
            >> result.destabilizeDistance;

    for (int i = 0; i < 29; i++) {
        *aStream >> result.locationDamageMultipliers[i];
    }

    *aStream
            >> result.fireRumblePtr
            >> result.meleeImpactRumblePtr
            >> result.adsDofStart
            >> result.adsDofEnd;

    if (result.szInternalNamePtr == -1) {
        result.szInternalName = Load_XStringCustom(aStream);
    }
    if (result.szDisplayNamePtr == -1) {
        result.szDisplayName = Load_XStringCustom(aStream);
    }
    if (result.szOverlayNamePtr == -1) {
        result.szOverlayName = Load_XStringCustom(aStream);
    }
    if (result.gunXModelPtr) {
        result.gunXModel = Load_XModelPtrArray(aStream, 16);
    }
    if (result.handXModelPtr) {
        result.handXModel = Load_XModelPtr(aStream);
    }

    for (int i = 0; i < 33; i++) {
        if (result.szXAnimsPtr[i]) {
            result.szXAnims[i] = Load_XStringCustom(aStream);
        }
    }

    if (result.szModeNamePtr) {
        result.szModeName = Load_XStringCustom(aStream);
    }

    if (result.hideTagsPtr) {
        result.hideTags = Load_ScriptStringArray(aStream, 8);
    }
    if (result.notetrackSoundMapKeysPtr) {
        result.notetrackSoundMapKeys = Load_ScriptStringArray(aStream, 16);
    }
    if (result.notetrackSoundMapValuesPtr) {
        result.notetrackSoundMapValues = Load_ScriptStringArray(aStream, 16);
    }

    if (result.viewFlashEffectPtr) {
        result.viewFlashEffect = Load_FxEffectDefHandle(aStream);
    }
    if (result.worldFlashEffectPtr) {
        result.worldFlashEffect = Load_FxEffectDefHandle(aStream);
    }

    if (result.pickupSoundPtr) {
        result.pickupSound = Load_SndAliasCustom(aStream);
    }
    if (result.pickupSoundPlayerPtr) {
        result.pickupSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.ammoPickupSoundPtr) {
        result.ammoPickupSound = Load_SndAliasCustom(aStream);
    }
    if (result.ammoPickupSoundPlayerPtr) {
        result.ammoPickupSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.projectileSoundPtr) {
        result.projectileSound = Load_SndAliasCustom(aStream);
    }
    if (result.pullbackSoundPtr) {
        result.pullbackSound = Load_SndAliasCustom(aStream);
    }
    if (result.pullbackSoundPlayerPtr) {
        result.pullbackSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.fireSoundPtr) {
        result.fireSound = Load_SndAliasCustom(aStream);
    }
    if (result.fireSoundPlayerPtr) {
        result.fireSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.fireLoopSoundPtr) {
        result.fireLoopSound = Load_SndAliasCustom(aStream);
    }
    if (result.fireLoopSoundPlayerPtr) {
        result.fireLoopSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.fireStopSoundPtr) {
        result.fireStopSound = Load_SndAliasCustom(aStream);
    }
    if (result.fireStopSoundPlayerPtr) {
        result.fireStopSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.fireLastSoundPtr) {
        result.fireLastSound = Load_SndAliasCustom(aStream);
    }
    if (result.fireLastSoundPlayerPtr) {
        result.fireLastSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.emptyFireSoundPtr) {
        result.emptyFireSound = Load_SndAliasCustom(aStream);
    }
    if (result.emptyFireSoundPlayerPtr) {
        result.emptyFireSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.meleeSwipeSoundPtr) {
        result.meleeSwipeSound = Load_SndAliasCustom(aStream);
    }
    if (result.meleeSwipeSoundPlayerPtr) {
        result.meleeSwipeSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.meleeHitSoundPtr) {
        result.meleeHitSound = Load_SndAliasCustom(aStream);
    }
    if (result.meleeMissSoundPtr) {
        result.meleeMissSound = Load_SndAliasCustom(aStream);
    }
    if (result.rechamberSoundPtr) {
        result.rechamberSound = Load_SndAliasCustom(aStream);
    }
    if (result.rechamberSoundPlayerPtr) {
        result.rechamberSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.reloadSoundPtr) {
        result.reloadSound = Load_SndAliasCustom(aStream);
    }
    if (result.reloadSoundPlayerPtr) {
        result.reloadSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.reloadEmptySoundPtr) {
        result.reloadEmptySound = Load_SndAliasCustom(aStream);
    }
    if (result.reloadEmptySoundPlayerPtr) {
        result.reloadEmptySoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.reloadStartSoundPtr) {
        result.reloadStartSound = Load_SndAliasCustom(aStream);
    }
    if (result.reloadStartSoundPlayerPtr) {
        result.reloadStartSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.reloadEndSoundPtr) {
        result.reloadEndSound = Load_SndAliasCustom(aStream);
    }
    if (result.reloadEndSoundPlayerPtr) {
        result.reloadEndSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.nightVisionWearSoundPtr) {
        result.nightVisionWearSound = Load_SndAliasCustom(aStream);
    }
    if (result.detonateSoundPlayerPtr) {
        result.detonateSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.nightVisionWearSoundPtr) {
        result.nightVisionWearSound = Load_SndAliasCustom(aStream);
    }
    if (result.nightVisionRemoveSoundPtr) {
        result.nightVisionRemoveSound = Load_SndAliasCustom(aStream);
    }
    if (result.nightVisionRemoveSoundPlayerPtr) {
        result.nightVisionRemoveSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.altSwitchSoundPtr) {
        result.altSwitchSound = Load_SndAliasCustom(aStream);
    }
    if (result.altSwitchSoundPlayerPtr) {
        result.altSwitchSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.raiseSoundPtr) {
        result.raiseSound = Load_SndAliasCustom(aStream);
    }
    if (result.raiseSoundPlayerPtr) {
        result.raiseSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.firstRaiseSoundPtr) {
        result.firstRaiseSound = Load_SndAliasCustom(aStream);
    }
    if (result.firstRaiseSoundPlayerPtr) {
        result.firstRaiseSoundPlayer = Load_SndAliasCustom(aStream);
    }
    if (result.putawaySoundPtr) {
        result.putawaySound = Load_SndAliasCustom(aStream);
    }
    if (result.putawaySoundPlayerPtr) {
        result.putawaySoundPlayer = Load_SndAliasCustom(aStream);
    }

    if (result.bounceSoundPtr)
    {
        if (result.bounceSoundPtr == -1)
        {
            result.bounceSound = Load_snd_alias_list_nameArray(aStream, 29);
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //varWeaponDef->bounceSound = (snd_alias_list_t **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                         + ((((unsigned int)varWeaponDef->bounceSound
            //                                                                              - 1) >> 26) & 0x38)))[((int)varWeaponDef->bounceSound - 1) & 0x1FFFFFFF];
        }
    }

    if (result.viewShellEjectEffectPtr) {
        result.viewShellEjectEffect = Load_FxEffectDefHandle(aStream);
    }
    if (result.worldShellEjectEffectPtr) {
        result.worldShellEjectEffect = Load_FxEffectDefHandle(aStream);
    }
    if (result.viewLastShotEjectEffectPtr) {
        result.viewLastShotEjectEffect = Load_FxEffectDefHandle(aStream);
    }
    if (result.worldLastShotEjectEffectPtr) {
        result.worldLastShotEjectEffect = Load_FxEffectDefHandle(aStream);
    }

    if (result.reticleCenterPtr) {
        result.reticleCenter = Load_MaterialHandle(aStream);
    }
    if (result.reticleSidePtr) {
        result.reticleSide = Load_MaterialHandle(aStream);
    }

    if (result.worldModelPtr) {
        result.worldModel = Load_XModelPtrArray(aStream, 16);
    }

    if (result.worldClipModelPtr) {
        result.worldClipModel = Load_XModelPtr(aStream);
    }
    if (result.rocketModelPtr) {
        result.rocketModel = Load_XModelPtr(aStream);
    }
    if (result.knifeModelPtr) {
        result.knifeModel = Load_XModelPtr(aStream);
    }
    if (result.worldKnifeModelPtr) {
        result.worldKnifeModel = Load_XModelPtr(aStream);
    }

    if (result.hudIconPtr) {
        result.hudIcon = Load_MaterialHandle(aStream);
    }
    if (result.ammoCounterIconPtr) {
        result.ammoCounterIcon = Load_MaterialHandle(aStream);
    }

    if (result.szAmmoNamePtr == -1) {
        result.szAmmoName = Load_XStringCustom(aStream);
    }
    if (result.szAmmoNamePtr == -1) {
        result.szAmmoName = Load_XStringCustom(aStream);
    }
    if (result.szSharedAmmoCapNamePtr == -1) {
        result.szSharedAmmoCapName = Load_XStringCustom(aStream);
    }

    if (result.overlayMaterialPtr) {
        result.overlayMaterial = Load_MaterialHandle(aStream);
    }
    if (result.overlayMaterialLowResPtr) {
        result.overlayMaterialLowRes = Load_MaterialHandle(aStream);
    }
    if (result.killIconPtr) {
        result.killIcon = Load_MaterialHandle(aStream);
    }
    if (result.dpadIconPtr) {
        result.dpadIcon = Load_MaterialHandle(aStream);
    }

    if (result.szAltWeaponNamePtr == -1) {
        result.szAltWeaponName = Load_XStringCustom(aStream);
    }

    if (result.projectileModelPtr) {
        result.projectileModel = Load_XModelPtr(aStream);
    }

    if (result.projExplosionEffectPtr) {
        result.projExplosionEffect = Load_FxEffectDefHandle(aStream);
    }
    if (result.projDudEffectPtr) {
        result.projDudEffect = Load_FxEffectDefHandle(aStream);
    }

    if (result.projExplosionSoundPtr) {
        result.projExplosionSound = Load_SndAliasCustom(aStream);
    }
    if (result.projDudSoundPtr) {
        result.projDudSound = Load_SndAliasCustom(aStream);
    }

    if (result.projTrailEffectPtr) {
        result.projTrailEffect = Load_FxEffectDefHandle(aStream);
    }
    if (result.projIgnitionEffectPtr) {
        result.projIgnitionEffect = Load_FxEffectDefHandle(aStream);
    }

    if (result.projIgnitionSoundPtr) {
        result.projIgnitionSound = Load_SndAliasCustom(aStream);
    }

    if (result.accuracyGraphNamePtr[0] == -1) {
        result.accuracyGraphName[0] = Load_XStringCustom(aStream);
    }

    if (result.accuracyGraphKnotsPtr[0])
    {
        if (result.accuracyGraphKnotsPtr[0] == -1)
        {
            for (int i = 0; i < varWeaponDef->accuracyGraphKnotCount[0]; i++) {
                *aStream >> result.accaccuracyGraphKnots[i];
            }
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //varWeaponDef->accuracyGraphKnots[0] = (float (*)[2])&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                            + ((((unsigned int)&(*varWeaponDef->accuracyGraphKnots[0])[0]
            //                                                                                 - 1) >> 26) & 0x38)))[((int)&(*varWeaponDef->accuracyGraphKnots[0])[0] - 1) & 0x1FFFFFFF];
        }
    }
    if (result.originalAccuracyGraphKnotsPtr[0])
    {
        if (result.originalAccuracyGraphKnotsPtr[0] == -1)
        {
            for (int i = 0; i < varWeaponDef->accuracyGraphKnotCount[0]; i++) {
                *aStream >> result.originalAccuracyGraphKnots[i];
            }
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //v5->originalAccuracyGraphKnots[0] = (float (*)[2])&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                          + ((((unsigned int)&(*v5->originalAccuracyGraphKnots[0])[0]
            //                                                                               - 1) >> 26) & 0x38)))[((int)&(*v5->originalAccuracyGraphKnots[0])[0] - 1) & 0x1FFFFFFF];
        }
    }
    if (result.accuracyGraphNamePtr[1] == -1) {
        result.accuracyGraphName[1] = Load_XStringCustom(aStream);
    }

    if (result.accuracyGraphKnotsPtr[1])
    {
        if (result.accuracyGraphKnotsPtr[1] == -1)
        {
            for (int i = 0; i < varWeaponDef->accuracyGraphKnotCount[1]; i++) {
                *aStream >> result.accuracyGraphKnots[i];
            }
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //varWeaponDef->accuracyGraphKnots[1] = (float (*)[2])&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                            + ((((unsigned int)&(*varWeaponDef->accuracyGraphKnots[1])[0]
            //                                                                                 - 1) >> 26) & 0x38)))[((int)&(*varWeaponDef->accuracyGraphKnots[1])[0] - 1) & 0x1FFFFFFF];
        }
    }
    if (result.originalAccuracyGraphKnotsPtr[1])
    {
        if (result.originalAccuracyGraphKnotsPtr[1] == -1)
        {
            for (int i = 0; i < varWeaponDef->accuracyGraphKnotCount[1]; i++) {
                *aStream >> result.originalAccuracyGraphKnots[i];
            }
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //v12->originalAccuracyGraphKnots[1] = (float (*)[2])&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                           + ((((unsigned int)&(*v12->originalAccuracyGraphKnots[1])[0]
            //                                                                                - 1) >> 26) & 0x38)))[((int)&(*v12->originalAccuracyGraphKnots[1])[0] - 1) & 0x1FFFFFFF];
        }
    }

    if (result.szUseHintStringPtr == -1) {
        result.szUseHintString = Load_XStringCustom(aStream);
    }
    if (result.dropHintStringPtr == -1) {
        result.dropHintString = Load_XStringCustom(aStream);
    }
    if (result.szScriptPtr == -1) {
        result.szScript = Load_XStringCustom(aStream);
    }
    if (result.fireRumblePtr == -1) {
        result.fireRumble = Load_XStringCustom(aStream);
    }
    if (result.meleeImpactRumblePtr == -1) {
        result.meleeImpactRumble = Load_XStringCustom(aStream);
    }

    return result;
}


// ?Load_MenuList@@YAX_N@Z at 0x822aeff8
MenuList Assets::Load_MenuList(QDataStream *aStream)
{
    MenuList result;

    *aStream >>
            result.namePtr
            result.menuCount
            result.menusPtr;

    if (result.namePtr) {
        result.name = Load_XStringCustom(aStream);
    }

    if (result.menusPtr)
    {
        result.menus << Load_menuDef_ptrArray(aStream, result.menuCount);
    }

    return result;
}


// ?Load_DynEntityDef@@YAX_N@Z at 0x822af090
DynEntityDef Assets::Load_DynEntityDef(QDataStream *aStream)
{
    DynEntityDef result;

    *aStream
            >> result.type
            >> result.pose
            >> result.xModelPtr
            >> result.brushModel
            >> result.physicsBrushModel
            >> result.destroyFxPtr
            >> result.destroyPiecesPtr
            >> result.physPresetPtr
            >> result.health
            >> result.mass
            >> result.contents;

    if (result.xModelPtr) {
        result.xModel = Load_XModelPtr(aStream);
    }
    if (result.destroyFxPtr) {
        result.destroyFx = Load_FxEffectDefHandle(aStream);
    }
    if (result.destroyPiecesPtr) {
        result.destroyPieces = Load_XModelPiecesPtr(aStream);
    }
    if (result.physPresetPtr) {
        result.physPreset = Load_PhysPresetPtr(aStream);
    }

    return result;
}


// ?Load_FxEffectDefHandleArray@@YAX_NH@Z at 0x822af148
QVector<FxEffectDefHandle> Assets::Load_FxEffectDefHandleArray(QDataStream *aStream, int count)
{
    QVector<FxEffectDefHandle> result;

    for (int i = 0; i < count; i++) {

    }

    v2 = count;
    Load_Stream(0, varFxEffectDefHandle, 4 * count);
    v3 = varFxEffectDefHandle;
    if ( v2 > 0 )
    {
        do
        {
            varFxEffectDefHandle = v3;
            Load_FxEffectDefHandle(0);
            --v2;
            ++v3;
        }
        while ( v2 );
    }

    return result;
}


// ?Load_WeaponDefPtr@@YAX_N@Z at 0x822af1a0
WeaponDef Assets::Load_WeaponDefPtr(QDataStream *aStream)
{
    WeaponDef result;
    qint32 weaponDefPtr;

    *aStream >> weaponDefPtr;

    if (weaponDefPtr)
    {
        if (weaponDefPtr == -1 || weaponDefPtr == -2)
        {
            result = Load_WeaponDef(aStream);
        }
        else
        {
            // Resolve contents from g_streamBlocks
            //*varWeaponDefPtr = *(WeaponDef **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                          + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];

        }
    }
    return result;
}


// ?Load_FxImpactEntry@@YAX_N@Z at 0x822af288
FxImpactEntry Assets::Load_FxImpactEntry(QDataStream *aStream)
{
    FxImpactEntry result;

    for (int i = 0; i < 29; i++) {
        qint32 nonFleshPtr;

        *aStream >> nonFleshPtr;

        result.nonFleshPtrs[i] = nonFleshPtr
    }
    for (int i = 0; i < 4; i++) {
        qint32 fleshPtr;

        *aStream >> fleshPtr;

        result.fleshPtrs[i] = fleshPtr
    }


    for (int i = 0; i < 29; i++) {
        qint32 nonFleshPtr;

        *aStream >> nonFleshPtr;

        result.nonFleshPtrs[i] = nonFleshPtr
    }
    for (int i = 0; i < 4; i++) {
        qint32 fleshPtr;

        *aStream >> fleshPtr;

        result.fleshPtrs[i] = fleshPtr
    }

    v2 = 29;
    do
    {
        varFxEffectDefHandle = v1;
        Load_FxEffectDefHandle(0);
        --v2;
        ++v1;
    }
    while ( v2 );
    varFxEffectDefHandle = varFxImpactEntry->flesh;
    Load_Stream(0, varFxImpactEntry->flesh, 0x10u);
    v3 = varFxEffectDefHandle;
    v4 = 4;
    do
    {
        varFxEffectDefHandle = v3;
        Load_FxEffectDefHandle(0);
        --v4;
        ++v3;
    }
    while ( v4 );

    return result;
}


// ?Load_MenuListPtr@@YAX_N@Z at 0x822af328
MenuList Assets::Load_MenuListPtr(QDataStream *aStream)
{
    MenuList result;
    qint32 menuListPtr;

    *aStream >> menuListPtr;

    if (menuListPtr)
    {
        if (menuListPtr == -1 || menuListPtr == -2)
        {
            result = Load_MenuList(aStream);
        }
        else {
            // Resolve contents from g_streamBlocks
            //*varMenuListPtr = *(MenuList **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                        + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
        }
    }
    return result;
}


// ?Load_DynEntityDefArray@@YAX_NH@Z at 0x822af410
QVector<DynEntityDef> Assets::Load_DynEntityDefArray(QDataStream *aStream, int count)
{
    QVector<DynEntityDef> result;

    for (int i = 0; i < count; i++) {
        result << Load_DynEntityDef(aStream);
    }

    return result;
}


// ?Load_FxImpactEntryArray@@YAX_NH@Z at 0x822af470
QVector<FxImpactEntry> Assets::Load_FxImpactEntryArray(QDataStream *aStream, int count)
{
    QVector<FxImpactEntry> result;

    for (int i = 0; i < count; i++) {
        result << Assets::Load_FxImpactEntry(aStream);
    }

    return result;
}


// ?Load_clipMap_t@@YAX_N@Z at 0x822af4c0
clipMap_t Assets::Load_clipMap_t(QDataStream *aStream)
{
    clipMap_t result;

    *aStream
            >> result.namePtr
            >> result.isInUse
            >> result.planeCount
            >> result.planesPtr
            >> result.numStaticModels
            >> result.staticModelListPtr
            >> result.numMaterials
            >> result.materialsPtr
            >> result.numBrushSides
            >> result.brushsidesPtr
            >> result.numBrushEdges
            >> result.brushEdgesPtr
            >> result.numNodes
            >> result.nodesPtr
            >> result.leafsPtr
            >> result.leafbrushNodesCount
            >> result.leafbrushNodesPtr
            >> result.numLeafBrushes
            >> result.leafbrushesPtr
            >> result.numLeafSurfaces
            >> result.leafsurfacesPtr
            >> result.vertCount
            >> result.verts[0]
            >> result.verts[1]
            >> result.verts[2]
            >> result.triCount
            >> result.triIndicesPtr
            >> result.triEdgeIsWalkablePtr
            >> result.borderCount
            >> result.bordersPtr
            >> result.partitionCount
            >> result.partitionsPtr
            >> result.aabbTreeCount
            >> result.aabbTreesPtr
            >> result.numSubModels
            >> result.cmodelsPtr
            >> result.numBrushes
            >> result.brushesPtr
            >> result.numClusters
            >> result.clusterBytes
            >> result.visibilityPtr
            >> result.vised
            >> result.visibilityPtr
            >> result.visibilityPtr
            >> result.visibilityPtr
            >> result.visibilityPtr;

    if (result.namePtr == -1) {
        result.name = Assets::Load_XStringCustom(aStream);
    }
    if (result.planesPtr)
    {
        if (result.planesPtr == -1)
        {
            for (int i = 0; i < result.planeCount; i++) {
                result.planes << XAsset::Load_cplane_s(aStream);
            }
        }
        else
        {

            //varclipMap_t->planes = (cplane_s *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                           + (((unsigned int)&varclipMap_t->planes[-1].pad[1] >> 26) & 0x38)))[(int)&varclipMap_t->planes[-1].pad[1] & 0x1FFFFFFF];
        }
    }
    if (result.staticModelListPtr)
    {
        result.staticModelList = Load_cStaticModel_tArray(aStream, result.numStaticModels);
    }
    if (result.materialsPtr)
    {
        result.materials = Load_dmaterial_tArray(aStream, result.numMaterials);
    }
    if (result.brushsidesPtr)
    {
        result.brushsides = Load_cbrushside_tArray(aStream, result.numBrushSides);
    }
    if (result.brushEdgesPtr)
    {
        result.brushEdges = Load_cbrushedge_tArray(aStream, result.numBrushEdges);
    }
    if (result.nodesPtr)
    {
        result.nodes = Load_cNode_tArray(aStream, result.numNodes);
    }
    if (result.leafsPtr)
    {
        result.leafs = Load_cLeaf_tArray(aStream, result.numLeafs);
    }
    if (result.leafbrushesPtr)
    {
        result.leafbrushes = Load_LeafBrushArray(aStream, result.numLeafBrushes);
    }
    if ( v1->leafbrushNodes )
    {
        leafbrushNodesCount = v1->leafbrushNodesCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varcLeafBrushNode_t = (CLeafBrushNode *)g_streamPos;
        v1->leafbrushNodes = (CLeafBrushNode *)g_streamPos;
        Load_cLeafBrushNode_tArray(1, leafbrushNodesCount);
        v1 = varclipMap_t;
    }
    if ( v1->leafsurfaces )
    {
        v17 = 4 * v1->numLeafSurfaces;
        v18 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v18;
        varuint = (unsigned int *)v18;
        v1->leafsurfaces = (unsigned int *)v18;
        Load_Stream(1, v18, v17);
        v1 = varclipMap_t;
    }
    if ( v1->verts )
    {
        vertCount = v1->vertCount;
        v20 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v1->verts = (float (*)[3])v20;
        g_streamPos = v20;
        varvec3_t = (float (*)[3])v20;
        Load_Stream(1, v20, 12 * vertCount);
        v1 = varclipMap_t;
    }
    if ( v1->triIndices )
    {
        triCount = v1->triCount;
        v22 = (unsigned __int8 *)((unsigned int)(g_streamPos + 1) & 0xFFFFFFFE);
        v1->triIndices = (unsigned __int16 *)v22;
        g_streamPos = v22;
        varUnsignedShort = (unsigned __int16 *)v22;
        Load_Stream(1, v22, 6 * triCount);
        v1 = varclipMap_t;
    }
    if ( v1->triEdgeIsWalkable )
    {
        v23 = g_streamPos;
        v24 = v1->triCount;
        v1->triEdgeIsWalkable = g_streamPos;
        g_streamPos = v23;
        varbyte = v23;
        Load_Stream(1, v23, ((3 * v24 + 31) >> 3) & 0xFFFFFFFC);
        v1 = varclipMap_t;
    }
    if ( v1->borders )
    {
        v25 = 28 * v1->borderCount;
        v26 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v1->borders = (CollisionBorder *)v26;
        g_streamPos = v26;
        varCollisionBorder = (CollisionBorder *)v26;
        Load_Stream(1, v26, v25);
        v1 = varclipMap_t;
    }
    if ( v1->partitions )
    {
        partitionCount = v1->partitionCount;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varCollisionPartition = (CollisionPartition *)g_streamPos;
        v1->partitions = (CollisionPartition *)g_streamPos;
        Load_CollisionPartitionArray(1, partitionCount);
        v1 = varclipMap_t;
    }
    if ( v1->aabbTrees )
    {
        v28 = 32 * v1->aabbTreeCount;
        v29 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v29;
        varCollisionAabbTree = (CollisionAabbTree *)v29;
        v1->aabbTrees = (CollisionAabbTree *)v29;
        Load_Stream(1, v29, v28);
        v1 = varclipMap_t;
    }
    if ( v1->cmodels )
    {
        numSubModels = v1->numSubModels;
        v31 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v1->cmodels = (cmodel_t *)v31;
        g_streamPos = v31;
        varcmodel_t = (cmodel_t *)v31;
        Load_Stream(1, v31, 72 * numSubModels);
        v1 = varclipMap_t;
    }
    if ( v1->brushes )
    {
        numBrushes = v1->numBrushes;
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 15) & 0xFFFFFFF0);
        varcbrush_t = (cbrush_t *)g_streamPos;
        v1->brushes = (cbrush_t *)g_streamPos;
        Load_cbrush_tArray(1, numBrushes);
        v1 = varclipMap_t;
    }
    if ( v1->visibility )
    {
        v33 = g_streamPos;
        v34 = v1->clusterBytes * v1->numClusters;
        v1->visibility = g_streamPos;
        varbyte = v33;
        Load_Stream(1, v33, v34);
        v1 = varclipMap_t;
    }
    varMapEntsPtr = &v1->mapEnts;
    Load_MapEntsPtr(0);
    v35 = varclipMap_t;
    box_brush = varclipMap_t->box_brush;
    if ( box_brush )
    {
        if ( box_brush == (cbrush_t *)-1 )
        {
            g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 15) & 0xFFFFFFF0);
            varcbrush_t = (cbrush_t *)g_streamPos;
            varclipMap_t->box_brush = (cbrush_t *)g_streamPos;
            Load_CBrush(1);
            v35 = varclipMap_t;
        }
        else
        {
            varclipMap_t->box_brush = (cbrush_t *)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
                                                                          + (((unsigned int)varclipMap_t->box_brush[-1].edgeCount[5] >> 26) & 0x38)))[(int)varclipMap_t->box_brush[-1].edgeCount[5] & 0x1FFFFFFF];
        }
    }
    if ( v35->dynEntDefList[0] )
    {
        v37 = v35->dynEntCount[0];
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varDynEntityDef = (DynEntityDef *)g_streamPos;
        v35->dynEntDefList[0] = (DynEntityDef *)g_streamPos;
        Load_DynEntityDefArray(1, v37);
        v35 = varclipMap_t;
    }
    if ( v35->dynEntDefList[1] )
    {
        v38 = v35->dynEntCount[1];
        g_streamPos = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        varDynEntityDef = (DynEntityDef *)g_streamPos;
        v35->dynEntDefList[1] = (DynEntityDef *)g_streamPos;
        Load_DynEntityDefArray(1, v38);
        v35 = varclipMap_t;
    }
    DB_PushStreamPos(1u);
    if ( v35->dynEntPoseList[0] )
    {
        v40 = __ROL4__(v35->dynEntCount[0], 5);
        v41 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v41;
        varDynEntityPose = (DynEntityPose *)v41;
        v35->dynEntPoseList[0] = (DynEntityPose *)v41;
        Load_Stream(v39, v41, v40);
        v35 = varclipMap_t;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v35->dynEntPoseList[1] )
    {
        v43 = __ROL4__(v35->dynEntCount[1], 5);
        v44 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        g_streamPos = v44;
        varDynEntityPose = (DynEntityPose *)v44;
        v35->dynEntPoseList[1] = (DynEntityPose *)v44;
        Load_Stream(v42, v44, v43);
        v35 = varclipMap_t;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v35->dynEntClientList[0] )
    {
        v46 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v47 = 4 * (v35->dynEntCount[0] + __ROL4__(v35->dynEntCount[0], 1));
        g_streamPos = v46;
        varDynEntityClient = (DynEntityClient *)v46;
        v35->dynEntClientList[0] = (DynEntityClient *)v46;
        Load_Stream(v45, v46, v47);
        v35 = varclipMap_t;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v35->dynEntClientList[1] )
    {
        v49 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v50 = 4 * (v35->dynEntCount[1] + __ROL4__(v35->dynEntCount[1], 1));
        g_streamPos = v49;
        varDynEntityClient = (DynEntityClient *)v49;
        v35->dynEntClientList[1] = (DynEntityClient *)v49;
        Load_Stream(v48, v49, v50);
        v35 = varclipMap_t;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v35->dynEntCollList[0] )
    {
        v52 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v53 = 4 * (v35->dynEntCount[0] + __ROL4__(v35->dynEntCount[0], 2));
        g_streamPos = v52;
        varDynEntityColl = (DynEntityColl *)v52;
        v35->dynEntCollList[0] = (DynEntityColl *)v52;
        Load_Stream(v51, v52, v53);
        v35 = varclipMap_t;
    }
    DB_PopStreamPos();
    DB_PushStreamPos(1u);
    if ( v35->dynEntCollList[1] )
    {
        v55 = (unsigned __int8 *)((unsigned int)(g_streamPos + 3) & 0xFFFFFFFC);
        v56 = 4 * (v35->dynEntCount[1] + __ROL4__(v35->dynEntCount[1], 2));
        g_streamPos = v55;
        varDynEntityColl = (DynEntityColl *)v55;
        v35->dynEntCollList[1] = (DynEntityColl *)v55;
        Load_Stream(v54, v55, v56);
    }
    DB_PopStreamPos();
    DB_PopStreamPos();
}


// ?Load_FxImpactTable@@YAX_N@Z at 0x822afc40
FxImpactTable Assets::Load_FxImpactTable(QDataStream *aStream)
{
    FxImpactTable result;

    *aStream
            >> result.namePtr
            >> result.tablePtr;

    if (result.namePtr == -1) {
        result.name = Assets::Load_XStringCustom(aStream);
    }

    if (result.tablePtr)
    {
        result.table = Assets::Load_FxImpactEntryArray(1, 12);
    }
    DB_PopStreamPos();
}


// ?Load_clipMap_ptr@@YAX_N@Z at 0x822afcd8
clipMap_t Assets::Load_clipMap_ptr(QDataStream *aStream)
{
    clipMap_t result;
    qint32 clipMapPtr;

    *aStream >> clipMapPtr;

    if (clipMapPtr)
    {
        if (clipMapPtr != -1 || clipMapPtr != -2)
        {
            result = Assets::Load_clipMap_t(aStream);
        }
        else
        {
            // Resolve contents to g_streamBlocks
            //*varclipMap_ptr = *(clipMap_t **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                         + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
        }
    }
}


// ?Load_FxImpactTablePtr@@YAX_N@Z at 0x822afdc0
FxImpactTable Assets::Load_FxImpactTablePtr(QDataStream *aStream)
{
    FxImpactTable result;
    qint32 fxImpactTablePtr;

    *aStream >> fxImpactTablePtr;

    if (fxImpactTablePtr)
    {
        if (fxImpactTablePtr == -1 || fxImpactTablePtr != -2)
        {
            result = Assets::Load_FxImpactTable(aStream);
        }
        else
        {
            // Resolve contents to g_streamBlocks
            //*varFxImpactTablePtr = *(FxImpactTable **)&(*(unsigned __int8 **)((char *)&g_streamBlocks->data
            //                                                                  + (((unsigned int)(v1 - 1) >> 26) & 0x38)))[(v1 - 1) & 0x1FFFFFFF];
        }
    }

    return result;
}


struct XAsset
{
    XAssetType type;
    XAssetHeader header;
};

// ?Load_XAssetHeader@@YAX_N@Z at 0x822afea8
XAssetHeader Assets::Load_XAssetHeader(QDataStream *aStream, XAsset aAsset)
{
    XAssetHeader result;

    switch (aAsset.type)
    {
    case ASSET_TYPE_PHYSPRESET:
        result = Assets::Load_PhysPresetPtr(aStream);
        break;
    case ASSET_TYPE_XANIMPARTS:
        result = Assets::Load_XAnimPartsPtr(aStream);
        break;
    case ASSET_TYPE_XMODEL:
        result = Assets::Load_XModelPtr(aStream);
        break;
    case ASSET_TYPE_MATERIAL:
        result = Assets::Load_MaterialHandle(aStream);
        break;
    case ASSET_TYPE_PIXELSHADER:
        result = Assets::Load_MaterialPixelShaderPtr(aStream);
        break;
    case ASSET_TYPE_TECHNIQUE_SET:
        result = Assets::Load_MaterialTechniqueSetPtr(aStream);
        break;
    case ASSET_TYPE_IMAGE:
        varGfxImagePtr = (GfxImage **)varXAssetHeader;
        result = Assets::Load_GfxImagePtr(aStream);
        break;
    case ASSET_TYPE_SOUND:
        result = Assets::Load_snd_alias_list_ptr(aStream);
        break;
    case ASSET_TYPE_SOUND_CURVE:
        result = Assets::Load_SndCurvePtr(aStream);
        break;
    case ASSET_TYPE_LOADED_SOUND:
        result = Assets::Load_LoadedSoundPtr(aStream);
        break;
    case ASSET_TYPE_CLIPMAP:
    case ASSET_TYPE_CLIPMAP_PVS:
        varclipMap_ptr = (clipMap_t **)varXAssetHeader;
        result = Assets::Load_clipMap_ptr(aStream);
        break;
    case ASSET_TYPE_COMWORLD:
        result = Assets::Load_ComWorldPtr(aStream);
        break;
    case ASSET_TYPE_GAMEWORLD_SP:
        result = Assets::Load_GameWorldSpPtr(aStream);
        break;
    case ASSET_TYPE_GAMEWORLD_MP:
        result = Assets::Load_GameWorldMpPtr(aStream);
        break;
    case ASSET_TYPE_MAP_ENTS:
        result = Assets::Load_MapEntsPtr(aStream);
        break;
    case ASSET_TYPE_GFXWORLD:
        result = Assets::Load_GfxWorldPtr(aStream);
        break;
    case ASSET_TYPE_LIGHT_DEF:
        result = Assets::Load_GfxLightDefPtr(aStream);
        break;
    case ASSET_TYPE_FONT:
        result = Assets::Load_FontHandle(aStream);
        break;
    case ASSET_TYPE_MENULIST:
        result = Assets::Load_MenuListPtr(aStream);
        break;
    case ASSET_TYPE_MENU:
        result = Assets::Load_menuDef_ptr(aStream);
        break;
    case ASSET_TYPE_LOCALIZE_ENTRY:
        result = Assets::Load_LocalizeEntryPtr(aStream);
        break;
    case ASSET_TYPE_WEAPON:
        result = Assets::Load_WeaponDefPtr(aStream);
        break;
    case ASSET_TYPE_SNDDRIVER_GLOBALS:
        result = Assets::Load_SndDriverGlobalsPtr(aStream);
        break;
    case ASSET_TYPE_FX:
        result = Assets::Load_FxEffectDefHandle(aStream);
        break;
    case ASSET_TYPE_IMPACT_FX:
        result = Assets::Load_FxImpactTablePtr(aStream);
        break;
    case ASSET_TYPE_RAWFILE:
        result = Assets::Load_RawFilePtr(aStream);
        break;
    case ASSET_TYPE_STRINGTABLE:
        result = Assets::Load_StringTablePtr(aStream);
        break;
    }

    return result;
}

// ?Load_XAsset@@YAX_N@Z at 0x822b0220
XAsset Assets::Load_XAsset(QDataStream *aStream)
{
    XAsset result;

    *aStream
            >> result.type
            >> result.header

            result.header = Load_XAssetHeader(aStream, result);

    return result;
}


