Beispiel #1
0
void SendProxy_UtlVectorElement(
    const SendProp *pProp,
    const void *pStruct,
    const void *pData,
    DVariant *pOut,
    int iElement,
    int objectID )
{
    CSendPropExtra_UtlVector *pExtra = (CSendPropExtra_UtlVector*)pProp->GetExtraData();
    Assert( pExtra );

    // Kind of lame overloading element stride to hold the element index,
    // but we can easily move it into its SetExtraData stuff if we need to.
    iElement = pProp->GetElementStride();

    // NOTE: this is cheesy, but it does the trick.
    CUtlVector<int> *pUtlVec = (CUtlVector<int>*)((char*)pStruct + pExtra->m_Offset);
    if ( iElement >= pUtlVec->Count() )
    {
        // Pass in zero value.
        memset( pOut, 0, sizeof( *pOut ) );
    }
    else
    {
        // Call through to the proxy they passed in, making pStruct=the CUtlVector and forcing iElement to 0.
        pExtra->m_ProxyFn( pProp, pData, (char*)pUtlVec->Base() + iElement*pExtra->m_ElementStride, pOut, 0, objectID );
    }
}
Beispiel #2
0
void* SendProxy_LengthTable( const SendProp *pProp, const void *pStructBase, const void *pData, CSendProxyRecipients *pRecipients, int objectID )
{
    // Make sure the array has space to hold all the elements.
    CSendPropExtra_UtlVector *pExtra = (CSendPropExtra_UtlVector*)pProp->GetExtraData();
    pExtra->m_EnsureCapacityFn( (void*)pStructBase, pExtra->m_Offset, pExtra->m_nMaxElements );
    return (void*)pData;
}
Beispiel #3
0
void* SendProxy_UtlVectorElement_DataTable(
    const SendProp *pProp,
    const void *pStructBase,
    const void *pData,
    CSendProxyRecipients *pRecipients,
    int objectID )
{
    CSendPropExtra_UtlVector *pExtra = (CSendPropExtra_UtlVector*)pProp->GetExtraData();

    int iElement = pProp->m_ElementStride;
    Assert( iElement < pExtra->m_nMaxElements );

    // This should have gotten called in SendProxy_LengthTable before we get here, so
    // the capacity should be correct.
#ifdef _DEBUG
    pExtra->m_EnsureCapacityFn( (void*)pStructBase, pExtra->m_Offset, pExtra->m_nMaxElements );
#endif

    // NOTE: this is cheesy because we're assuming the type of the template class, but it does the trick.
    CUtlVector<int> *pUtlVec = (CUtlVector<int>*)((char*)pStructBase + pExtra->m_Offset);

    // Call through to the proxy they passed in, making pStruct=the CUtlVector and forcing iElement to 0.
    return pExtra->m_DataTableProxyFn( pProp, pData, (char*)pUtlVec->Base() + iElement*pExtra->m_ElementStride, pRecipients, objectID );
}