void SendTable_PrintStats( void ) { int numTables = 0; int numFloats = 0; int numStrings = 0; int numArrays = 0; int numInts = 0; int numVecs = 0; int numSubTables = 0; int numSendProps = 0; int numFlatProps = 0; int numExcludeProps = 0; for ( int i=0; i < g_SendTables.Count(); i++ ) { SendTable *st = g_SendTables[i]; numTables++; numSendProps += st->GetNumProps(); numFlatProps += st->m_pPrecalc->GetNumProps(); for ( int j=0; j < st->GetNumProps(); j++ ) { SendProp* sp = st->GetProp( j ); if ( sp->IsExcludeProp() ) { numExcludeProps++; continue; // no real sendprops } if ( sp->IsInsideArray() ) continue; switch( sp->GetType() ) { case DPT_Int : numInts++; break; case DPT_Float : numFloats++; break; case DPT_Vector : numVecs++; break; case DPT_String : numStrings++; break; case DPT_Array : numArrays++; break; case DPT_DataTable : numSubTables++; break; } } } Msg("Total Send Table stats\n"); Msg("Send Tables : %i\n", numTables ); Msg("Send Props : %i\n", numSendProps ); Msg("Flat Props : %i\n", numFlatProps ); Msg("Int Props : %i\n", numInts ); Msg("Float Props : %i\n", numFloats ); Msg("Vector Props: %i\n", numVecs ); Msg("String Props: %i\n", numStrings ); Msg("Array Props : %i\n", numArrays ); Msg("Table Props : %i\n", numSubTables ); Msg("Exclu Props : %i\n", numExcludeProps ); }
//--------------------------------------------------------------------------------- // Purpose: returns the specified prop offset relative to the table provided. // if offset or table not found, bErr returns true and offset returned is 0 //--------------------------------------------------------------------------------- unsigned int GetPropOffsetFromTable(const char *pTableName, const char *pPropName) { ServerClass *pClass = pServerDLL->GetAllServerClasses(); if (!pClass) { Warning("servergamedll->GetAllServerClasses() returned null\n"); return 0; } while (pClass) { SendTable *pTable = GetDataTable( pTableName, pClass->m_pTable ); if (pTable == NULL) { pClass = pClass->m_pNext; continue; } int num = pTable->GetNumProps(); for (int i = 0; i < num; i++) { SendProp *pProp = pTable->GetProp(i); if ( FStrEq( pPropName, pProp->GetName() ) ) { return pProp->GetOffset(); } } pClass = pClass->m_pNext; } Warning("prop %s not found in %s or table name incorrect\n", pPropName, pTableName); return 0; }
//--------------------------------------------------------------------------------- // Purpose: returns the specified prop from the class and table provided. // if prop or table not found, pointer returns NULL //--------------------------------------------------------------------------------- SendProp *GetPropFromClassAndTable(const char *szClassName, const char *szTableName, const char *szPropName) { ServerClass *pServerClass = pServerDLL->GetAllServerClasses(); if (!pServerClass) { Warning("servergamedll->GetAllServerClasses() returned null\n"); return NULL; } while (pServerClass) { if ( FStrEq(szClassName, pServerClass->GetName()) ) { SendTable *pTable = GetDataTable( szTableName, pServerClass->m_pTable ); if (pTable) { int numprops = pTable->GetNumProps(); for (int i = 0; i < numprops; ++i) { SendProp *pProp = pTable->GetProp(i); if (pProp && FStrEq(szPropName, pProp->GetName()) ) { return pProp; } } } } pServerClass = pServerClass->m_pNext; } Warning("prop %s not found in %s => %s\n", szPropName, szClassName, szTableName); return NULL; }
cell_t GetNumProps(IPluginContext *pContext, const cell_t *params) { Handle_t hndl = static_cast<Handle_t>(params[1]); HandleError err; HandleSecurity sec; sec.pOwner = NULL; sec.pIdentity = myself->GetIdentity(); SendTable *pTable; if ((err=g_pHandleSys->ReadHandle(hndl, g_SendTableHandle, &sec, (void **)&pTable)) != HandleError_None) { return pContext->ThrowNativeError("Invalid SendTable handle %x (error %d)", hndl, err); } return pTable->GetNumProps(); }
int EntityPropsManager::getPropOffset(const std::string &path) { // Try to find if we have already this offset int iOffset = 0; int index = this->getIndexInList(path); if(index > -1) { iOffset = EntityPropsList.at(index).propOffset; } if(iOffset) { return iOffset; } // If not, we have to find it. iOffset = 0; int i = 0; std::string cpath; std::vector<std::string> props; strSplit(path, ".", &props); ServerClass *pAllClasses = gamedll->GetAllServerClasses(); while(pAllClasses) { if(pAllClasses->GetName() == props.at(0)) // If we found the class { const int pSize = props.size(); // The use of const will accelerate the for instruction if(pSize > 2) // path containing class.datatable.(...).prop { SendTable *lastTable = pAllClasses->m_pTable; int iProps = 0; for(int iPath = 1; iPath < pSize-1; iPath++) // get the last datatable in path { cpath = props.at(iPath); iProps = lastTable->GetNumProps(); for(i = 0; i < iProps; i++) { if(lastTable->GetProp(i)->GetName() == props.at(iPath)) { lastTable = lastTable->GetProp(i)->GetDataTable(); i = iProps; } } } iProps = lastTable->m_nProps; for(i = 0; i < iProps; i++) // get the prop offset { if(lastTable->GetProp(i)->GetName() == props.back()) { iOffset = lastTable->GetProp(i)->GetOffset(); if(iOffset < 0) // The offset must be not negative { iOffset *= -1; } return iOffset; } } } else // path containing only class.prop { const int iProps = pAllClasses->m_pTable->GetNumProps(); for(i = 0; i < iProps; i++) { //Msg(pAllClasses->m_pTable->GetProp(i)->GetName()); //Msg("\n"); if(pAllClasses->m_pTable->GetProp(i)->GetName() == props.back()) { iOffset = pAllClasses->m_pTable->GetProp(i)->GetOffset(); if(iOffset < 0) // The offset must be not negative { iOffset *= -1; } return iOffset; } } break; } } // End if(pAllClasses->GetName() == props.at(0)) pAllClasses = pAllClasses->m_pNext; } // End while(!pAllClasses) return 0; }