Ok i want to edit the core to dump stats such as memory, CPU etc to a XML stats file in the way that as*ent does. I have looked at their source for a way to do it and found in WorldCreator.cpp this which i THINK is part of what i need:
void BuildStats(MapMgr * mgr, char * m_file, Instance * inst, MapInfo * inf)
{
char tmp[200];
strcpy(tmp, "");
#define pushline strcat(m_file, tmp)
snprintf(tmp, 200, " <instance>\\n"); pushline;
snprintf(tmp, 200, " <map>%u</map>\\n", mgr->GetMapId()); pushline;
snprintf(tmp, 200, " <maptype>%u</maptype>\\n", inf->type); pushline;
snprintf(tmp, 200, " <players>%u</players>\\n", mgr->GetPlayerCount()); pushline;
snprintf(tmp, 200, " <maxplayers>%u</maxplayers>\\n", inf->playerlimit); pushline;
//<creationtime>
if (inst)
{
tm *ttime = localtime( &inst->m_creation );
snprintf(tmp, 200, " <creationtime>%02u:%02u:%02u %02u/%02u/%u</creationtime>\\n",ttime->tm_hour, ttime->tm_min, ttime->tm_sec, ttime->tm_mday, ttime->tm_mon, uint32( ttime->tm_year + 1900 ));
pushline;
}
else
{
snprintf(tmp, 200, " <creationtime>N/A</creationtime>\\n");
pushline;
}
//<expirytime>
if (inst && inst->m_expiration)
{
tm *ttime = localtime( &inst->m_expiration );
snprintf(tmp, 200, " <expirytime>%02u:%02u:%02u %02u/%02u/%u</expirytime>\\n",ttime->tm_hour, ttime->tm_min, ttime->tm_sec, ttime->tm_mday, ttime->tm_mon, uint32( ttime->tm_year + 1900 ));
pushline;
}
else
{
snprintf(tmp, 200, " <expirytime>N/A</expirytime>\\n");
pushline;
}
//<idletime>
if (mgr->InactiveMoveTime)
{
tm *ttime = localtime( &mgr->InactiveMoveTime );
snprintf(tmp, 200, " <idletime>%02u:%02u:%02u %02u/%02u/%u</idletime>\\n",ttime->tm_hour, ttime->tm_min, ttime->tm_sec, ttime->tm_mday, ttime->tm_mon, uint32( ttime->tm_year + 1900 ));
pushline;
}
else
{
snprintf(tmp, 200, " <idletime>N/A</idletime>\\n");
pushline;
}
snprintf(tmp, 200, " </instance>\\n"); pushline;
#undef pushline
}
void InstanceMgr::BuildXMLStats(char * m_file)
{
uint32 i;
InstanceMap::iterator itr;
InstanceMap * instancemap;
Instance * in;
m_mapLock.Acquire();
for(i = 0; i < NUM_MAPS; ++i)
{
if(m_singleMaps[i] != NULL)
BuildStats(m_singleMaps[i], m_file, NULL, m_singleMaps[i]->GetMapInfo());
else
{
instancemap = m_instances[i];
if(instancemap != NULL)
{
for(itr = instancemap->begin(); itr != instancemap->end()
{
in = itr->second;
++itr;
if(in->m_mapMgr==NULL)
continue;
BuildStats(in->m_mapMgr, m_file, in, in->m_mapInfo);
}
}
}
}
m_mapLock.Release();
}
as im not to hot on the C++ side i was just wondering if someone could help me out with this? Any pointers would be great
I think i need more code though as that only looks like it generates the Instance stats..