typedescription_t *UTIL_FindInDataMap(datamap_t *pMap, const char *name) { while (pMap) { for (int i=0; i<pMap->dataNumFields; i++) { if (pMap->dataDesc[i].fieldName == NULL) { continue; } if (strcmp(name, pMap->dataDesc[i].fieldName) == 0) { return &(pMap->dataDesc[i]); } if (pMap->dataDesc[i].td) { typedescription_t *_td; if ((_td=UTIL_FindInDataMap(pMap->dataDesc[i].td, name)) != NULL) { return _td; } } } pMap = pMap->baseMap; } return NULL; }
typedescription_t *UTIL_FindInDataMap(datamap_t *pMap, const char *name, bool *isNested) { if (isNested) { *isNested = false; } while (pMap) { for (int i=0; i<pMap->dataNumFields; i++) { if (pMap->dataDesc[i].fieldName == NULL) { continue; } if (strcmp(name, pMap->dataDesc[i].fieldName) == 0) { return &(pMap->dataDesc[i]); } if (pMap->dataDesc[i].td) { if (isNested) { *isNested = (UTIL_FindInDataMap(pMap->dataDesc[i].td, name, NULL) != NULL); if (*isNested) { return NULL; } else { continue; } } else { // Use the old behaviour, we dont want to spring this on extensions - even if they're doing bad things. typedescription_t *_td; if ((_td=UTIL_FindInDataMap(pMap->dataDesc[i].td, name, NULL)) != NULL) { return _td; } } } } pMap = pMap->baseMap; } return NULL; }
typedescription_t *CHalfLife2::FindInDataMap(datamap_t *pMap, const char *offset) { typedescription_t *td = NULL; DataMapTrie &val = m_Maps[pMap]; if (!val.trie) { val.trie = sm_trie_create(); } if (!sm_trie_retrieve(val.trie, offset, (void **)&td)) { if ((td = UTIL_FindInDataMap(pMap, offset)) != NULL) { sm_trie_insert(val.trie, offset, td); } } return td; }