Improved sendtable dump output (bug 5471, r=psychonic).

This commit is contained in:
Asher Baker 2012-11-15 17:50:11 +00:00
parent c19712dccc
commit a991d327e6

View File

@ -329,24 +329,22 @@ void UTIL_DrawServerClass_XML(FILE *fp, ServerClass *sc)
fprintf(fp, "</serverclass>\n"); fprintf(fp, "</serverclass>\n");
} }
void UTIL_DrawSendTable(FILE *fp, SendTable *pTable, int level) void UTIL_DrawSendTable(FILE *fp, SendTable *pTable, int level = 1)
{ {
char spaces[255];
for (int i=0; i<level; i++)
spaces[i] = ' ';
spaces[level] = '\0';
const char *name, *type;
SendProp *pProp; SendProp *pProp;
const char *type;
fprintf(fp, "%sSub-Class Table (%d Deep): %s\n", spaces, level, pTable->GetName()); for (int i = 0; i < pTable->GetNumProps(); i++)
for (int i=0; i<pTable->GetNumProps(); i++)
{ {
pProp = pTable->GetProp(i); pProp = pTable->GetProp(i);
name = pProp->GetName();
if (pProp->GetDataTable()) if (pProp->GetDataTable())
{ {
fprintf(fp, "%*sTable: %s (offset %d) (type %s)\n",
level, "",
pProp->GetName(),
pProp->GetOffset(),
pProp->GetDataTable()->GetName());
UTIL_DrawSendTable(fp, pProp->GetDataTable(), level + 1); UTIL_DrawSendTable(fp, pProp->GetDataTable(), level + 1);
} }
else else
@ -356,8 +354,8 @@ void UTIL_DrawSendTable(FILE *fp, SendTable *pTable, int level)
if (type != NULL) if (type != NULL)
{ {
fprintf(fp, fprintf(fp,
"%s-Member: %s (offset %d) (type %s) (bits %d)\n", "%*sMember: %s (offset %d) (type %s) (bits %d)\n",
spaces, level, "",
pProp->GetName(), pProp->GetName(),
pProp->GetOffset(), pProp->GetOffset(),
type, type,
@ -366,8 +364,8 @@ void UTIL_DrawSendTable(FILE *fp, SendTable *pTable, int level)
else else
{ {
fprintf(fp, fprintf(fp,
"%s-Member: %s (offset %d) (type %d) (bits %d)\n", "%*sMember: %s (offset %d) (type %d) (bits %d)\n",
spaces, level, "",
pProp->GetName(), pProp->GetName(),
pProp->GetOffset(), pProp->GetOffset(),
pProp->GetType(), pProp->GetType(),
@ -453,8 +451,8 @@ CON_COMMAND(sm_dump_netprops, "Dumps the networkable property table as a text fi
ServerClass *pBase = gamedll->GetAllServerClasses(); ServerClass *pBase = gamedll->GetAllServerClasses();
while (pBase != NULL) while (pBase != NULL)
{ {
fprintf(fp, "%s:\n", pBase->GetName()); fprintf(fp, "%s (type %s)\n", pBase->GetName(), pBase->m_pTable->GetName());
UTIL_DrawSendTable(fp, pBase->m_pTable, 1); UTIL_DrawSendTable(fp, pBase->m_pTable);
pBase = pBase->m_pNext; pBase = pBase->m_pNext;
} }