//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: Xbox Remote Commands // //=====================================================================================// #include "xbox/xbox_console.h" #include "xbox/xbox_vxconsole.h" #include "tier0/tslist.h" #include "tier0/memdbgon.h" CInterlockedInt g_xbx_numProfileCounters; unsigned int g_xbx_profileCounters[XBX_MAX_PROFILE_COUNTERS]; char g_xbx_profileName[32]; //----------------------------------------------------------------------------- // XBX_rSetProfileAttributes // // Expose profile counters attributes to the console. //----------------------------------------------------------------------------- int CXboxConsole::SetProfileAttributes( const char *pProfileName, int numCounters, const char *names[], unsigned int colors[] ) { char dbgCommand[XBX_MAX_RCMDLENGTH]; int retVal; xrProfile_t* profileList; if ( numCounters > XBX_MAX_PROFILE_COUNTERS ) { numCounters = XBX_MAX_PROFILE_COUNTERS; } profileList = new xrProfile_t[numCounters]; memset( profileList, 0, numCounters*sizeof( xrProfile_t ) ); for ( int i=0; i XBX_MAX_PROFILE_COUNTERS ) { numCounters = XBX_MAX_PROFILE_COUNTERS; } memcpy( g_xbx_profileCounters, pCounters, numCounters * sizeof( unsigned int ) ); // mark for sending g_xbx_numProfileCounters = numCounters; lastTime = time; } } //----------------------------------------------------------------------------- // XBX_rMemDump // // Send signal to remote console to read mempry dump in specified filename. //----------------------------------------------------------------------------- int CXboxConsole::MemDump( const char *pDumpFileName ) { char dbgCommand[XBX_MAX_RCMDLENGTH]; _snprintf( dbgCommand, sizeof( dbgCommand ), "MemDump() %s", pDumpFileName ); XBX_SendRemoteCommand( dbgCommand, true ); return 0; } //----------------------------------------------------------------------------- // XBX_rTimeStampLog // // Send time stamp to remote console //----------------------------------------------------------------------------- int CXboxConsole::TimeStampLog( float time, const char *pString ) { char dbgCommand[XBX_MAX_RCMDLENGTH]; int retVal; xrTimeStamp_t timeStamp; MEMORYSTATUS stat; static int lastMemoryStamp = 0; static float lastTimeStamp = 0; // get current available memory GlobalMemoryStatus( &stat ); if ( !lastTimeStamp || time < lastTimeStamp ) { // first entry or restart, reset stamps lastMemoryStamp = stat.dwAvailPhys; lastTimeStamp = time; } timeStamp.time = time; timeStamp.deltaTime = time - lastTimeStamp; timeStamp.memory = stat.dwAvailPhys; timeStamp.deltaMemory = stat.dwAvailPhys - lastMemoryStamp; strncpy( timeStamp.messageString, pString, sizeof( timeStamp.messageString ) ); timeStamp.messageString[sizeof( timeStamp.messageString ) - 1] = '\0'; _snprintf( dbgCommand, sizeof( dbgCommand ), "TimeStampLog() 0x%8.8x 0x%8.8x", &timeStamp, &retVal ); XBX_SendRemoteCommand( dbgCommand, false ); lastTimeStamp = time; lastMemoryStamp = stat.dwAvailPhys; return retVal; } //----------------------------------------------------------------------------- // XBX_rMaterialList // // Send material list to remote console //----------------------------------------------------------------------------- int CXboxConsole::MaterialList( int nMaterials, const xMaterialList_t* pXMaterialList ) { char dbgCommand[XBX_MAX_RCMDLENGTH]; int retVal; xrMaterial_t* pRemoteList; pRemoteList = new xrMaterial_t[nMaterials]; memset( pRemoteList, 0, nMaterials*sizeof( xrMaterial_t ) ); for ( int i=0; iposition, 3 * sizeof( float ) ); memcpy( xrMapInfo.angle, pXMapInfo->angle, 3 * sizeof( float ) ); strncpy( xrMapInfo.mapPath, pXMapInfo->mapPath, sizeof( xrMapInfo.mapPath ) ); xrMapInfo.mapPath[sizeof( xrMapInfo.mapPath ) - 1] = '\0'; strncpy( xrMapInfo.savePath, pXMapInfo->savePath, sizeof( xrMapInfo.savePath ) ); xrMapInfo.savePath[sizeof( xrMapInfo.savePath ) - 1] = '\0'; xrMapInfo.build = pXMapInfo->build; xrMapInfo.skill = pXMapInfo->skill; _snprintf( dbgCommand, sizeof( dbgCommand ), "MapInfo() 0x%8.8x 0x%8.8x", &xrMapInfo, &retVal ); XBX_SendRemoteCommand( dbgCommand, false ); return retVal; } //----------------------------------------------------------------------------- // XBX_rAddCommands // // Expose commands to remote console //----------------------------------------------------------------------------- int CXboxConsole::AddCommands( int numCommands, const char* commands[], const char* help[] ) { char dbgCommand[XBX_MAX_RCMDLENGTH]; int retVal; xrCommand_t* cmdList; cmdList = new xrCommand_t[numCommands]; memset( cmdList, 0, numCommands*sizeof( xrCommand_t ) ); for ( int i=0; i