Add support for nested datatables. (bug 5446, r=asherkin)
This commit is contained in:
@@ -356,8 +356,13 @@ const char *EntityOutputManager::GetEntityClassname(CBaseEntity *pEntity)
|
||||
if (offset == -1)
|
||||
{
|
||||
datamap_t *pMap = gamehelpers->GetDataMap(pEntity);
|
||||
typedescription_t *pDesc = gamehelpers->FindInDataMap(pMap, "m_iClassname");
|
||||
offset = GetTypeDescOffs(pDesc);
|
||||
sm_datatable_info_t info;
|
||||
if (!gamehelpers->FindDataMapInfo(pMap, "m_iClassname", &info))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
offset = info.actual_offset;
|
||||
}
|
||||
|
||||
return *(const char **)(((unsigned char *)pEntity) + offset);
|
||||
|
||||
@@ -585,14 +585,17 @@ CON_COMMAND(sm_dump_classes, "Dumps the class list as a text file")
|
||||
|
||||
fprintf(fp, "// Dump of all classes for \"%s\" as at %s\n//\n\n", g_pSM->GetGameFolderName(), buffer);
|
||||
|
||||
sm_datatable_info_t info;
|
||||
for ( int i = dict->m_Factories.First(); i != dict->m_Factories.InvalidIndex(); i = dict->m_Factories.Next( i ) )
|
||||
{
|
||||
IServerNetworkable *entity = dict->Create(dict->m_Factories.GetElementName(i));
|
||||
ServerClass *sclass = entity->GetServerClass();
|
||||
fprintf(fp,"%s - %s\n",sclass->GetName(), dict->m_Factories.GetElementName(i));
|
||||
|
||||
typedescription_t *datamap = gamehelpers->FindInDataMap(gamehelpers->GetDataMap(entity->GetBaseEntity()), "m_iEFlags");
|
||||
int *eflags = (int *)((char *)entity->GetBaseEntity() + GetTypeDescOffs(datamap));
|
||||
|
||||
if (!gamehelpers->FindDataMapInfo(gamehelpers->GetDataMap(entity->GetBaseEntity()), "m_iEFlags", &info))
|
||||
continue;
|
||||
|
||||
int *eflags = (int *)((char *)entity->GetBaseEntity() + info.actual_offset);
|
||||
*eflags |= (1<<0); // EFL_KILLME
|
||||
}
|
||||
|
||||
@@ -819,14 +822,13 @@ CON_COMMAND(sm_dump_datamaps, "Dumps the data map list as a text file")
|
||||
|
||||
if (offsEFlags == -1)
|
||||
{
|
||||
typedescription_t *datamap = gamehelpers->FindInDataMap(pMap, "m_iEFlags");
|
||||
|
||||
if (!datamap)
|
||||
sm_datatable_info_t info;
|
||||
if (!gamehelpers->FindDataMapInfo(pMap, "m_iEFlags", &info))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
offsEFlags = GetTypeDescOffs(datamap);
|
||||
offsEFlags = info.actual_offset;
|
||||
}
|
||||
|
||||
int *eflags = (int *)((char *)entity->GetBaseEntity() + offsEFlags);
|
||||
|
||||
@@ -548,10 +548,10 @@ static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params)
|
||||
if (frag_prop)
|
||||
{
|
||||
datamap_t *pMap = gamehelpers->GetDataMap(pEntity);
|
||||
typedescription_t *pType = gamehelpers->FindInDataMap(pMap, frag_prop);
|
||||
if (pType != NULL)
|
||||
sm_datatable_info_t info;
|
||||
if (gamehelpers->FindDataMapInfo(pMap, frag_prop, &info))
|
||||
{
|
||||
s_frag_offs = GetTypeDescOffs(pType);
|
||||
s_frag_offs = info.actual_offset;
|
||||
}
|
||||
}
|
||||
if (!s_frag_offs)
|
||||
@@ -684,10 +684,13 @@ static cell_t NativeFindEntityByClassname(IPluginContext *pContext, const cell_t
|
||||
static int offset = -1;
|
||||
if (offset == -1)
|
||||
{
|
||||
offset = GetTypeDescOffs(
|
||||
gamehelpers->FindInDataMap(gamehelpers->GetDataMap(pEntity),
|
||||
"m_iClassname")
|
||||
);
|
||||
sm_datatable_info_t info;
|
||||
if (!gamehelpers->FindDataMapInfo(gamehelpers->GetDataMap(pEntity), "m_iClassname", &info))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset = info.actual_offset;
|
||||
}
|
||||
|
||||
string_t s;
|
||||
|
||||
Reference in New Issue
Block a user