bool Entities::GetSubProp(RecvTable *table, const char *propName, RecvProp *&prop, int &offset) { for (int i = 0; i < table->GetNumProps(); i++) { offset = 0; RecvProp *currentProp = table->GetProp(i); if (strcmp(currentProp->GetName(), propName) == 0) { prop = currentProp; offset = currentProp->GetOffset(); return true; } if (currentProp->GetType() == DPT_DataTable) { if (GetSubProp(currentProp->GetDataTable(), propName, prop, offset)) { offset += currentProp->GetOffset(); return true; } } } return false; }
void Array_Decode( DecodeInfo *pInfo ) { SendProp *pArrayProp = pInfo->m_pProp->GetArrayProp(); AssertMsg( pArrayProp, ("Array_Decode: missing m_pArrayProp for a property.") ); // Setup a DecodeInfo that is used to decode each of the child properties. DecodeInfo subDecodeInfo; subDecodeInfo.CopyVars( pInfo ); subDecodeInfo.m_pProp = pArrayProp; int elementStride = 0; ArrayLengthRecvProxyFn lengthProxy = 0; if ( pInfo->m_pRecvProp ) { RecvProp *pArrayRecvProp = pInfo->m_pRecvProp->GetArrayProp(); subDecodeInfo.m_pRecvProp = pArrayRecvProp; // Note we get the OFFSET from the array element property and the STRIDE from the array itself. subDecodeInfo.m_pData = (char*)pInfo->m_pData + pArrayRecvProp->GetOffset(); elementStride = pInfo->m_pRecvProp->GetElementStride(); Assert( elementStride != -1 ); // (Make sure it was set..) lengthProxy = pInfo->m_pRecvProp->GetArrayLengthProxy(); } int nElements = pInfo->m_pIn->ReadUBitLong( pInfo->m_pProp->GetNumArrayLengthBits() ); if ( lengthProxy ) lengthProxy( pInfo->m_pStruct, pInfo->m_ObjectID, nElements ); for ( subDecodeInfo.m_iElement=0; subDecodeInfo.m_iElement < nElements; subDecodeInfo.m_iElement++ ) { g_PropTypeFns[pArrayProp->GetType()].Decode( &subDecodeInfo ); subDecodeInfo.m_pData = (char*)subDecodeInfo.m_pData + elementStride; } }