void LocalRAUser::OnFriendListCB( RequestObject* pObj ) { if( pObj->m_bResponse ) { if( strncmp( pObj->m_sResponse, "OK:", 3 ) == 0 ) { if( pObj->m_sResponse[3] != '\0' ) { char* cpIter = &(pObj->m_sResponse[3]); unsigned int nCharsRead = 0; do { char* pUser = _ReadStringTil( '&', cpIter, TRUE ); char* pPoints = _ReadStringTil( '&', cpIter, TRUE ); char* pActivity = _ReadStringTil( '\n', cpIter, TRUE ); unsigned int nScore = strtol( pPoints, NULL, 10 ); if( !pActivity || strlen( pActivity ) < 2 || strcmp( pActivity, "_" ) == 0 ) pActivity = "Unknown!"; if( pUser && pPoints && pActivity ) { RAUser& NewFriend = AddFriend( pUser, nScore ); //TBD NewFriend.UpdateActivity( pActivity ); //TBD } } while ( (*cpIter) != '\0' ); } } else { // Issues?! //assert(0); } } }
void RA_RichPresenceInterpretter::ParseRichPresenceFile( const char* sFilename ) { m_formats.clear(); m_lookups.clear(); m_sDisplay.clear(); const char EndLine = '\n'; const char* LookupStr = "Lookup:"; const char* FormatStr = "Format:"; const char* FormatTypeStr = "FormatType="; const char* DisplayableStr = "Display:"; FILE* pFile = NULL; fopen_s( &pFile, sFilename, "r" ); if( pFile != NULL ) { DWORD nCharsRead = 0; char buffer[4096]; _ReadTil( EndLine, buffer, 4096, &nCharsRead, pFile ); while( nCharsRead != 0 ) { if( strncmp( LookupStr, buffer, strlen( LookupStr ) ) == 0 ) { // Lookup type char* pBuf = buffer + ( strlen( LookupStr ) ); RA_Lookup newLookup( _ReadStringTil( EndLine, pBuf, TRUE ) ); while( nCharsRead != 0 && ( buffer[0] != EndLine ) ) { _ReadTil( EndLine, buffer, 4096, &nCharsRead, pFile ); if( nCharsRead > 2 ) { char* pBuf = &buffer[0]; const char* pValue = _ReadStringTil( '=', pBuf, TRUE ); const char* pName = _ReadStringTil( EndLine, pBuf, TRUE ); int nBase = 10; if( pValue[0] == '0' && pValue[1] == 'x' ) nBase = 16; DataPos nVal = static_cast<DataPos>( strtol( pValue, NULL, nBase ) ); newLookup.AddLookupData( nVal, pName ); } } RA_LOG( "RP: Adding Lookup %s\n", newLookup.Description().c_str() ); m_lookups.push_back( newLookup ); } else if( strncmp( FormatStr, buffer, strlen( FormatStr ) ) == 0 ) { // char* pBuf = &buffer[0]; const char* pUnused = _ReadStringTil( ':', pBuf, TRUE ); std::string sDesc = _ReadStringTil( EndLine, pBuf, TRUE ); _ReadTil( EndLine, buffer, 4096, &nCharsRead, pFile ); if( nCharsRead > 0 && strncmp( FormatTypeStr, buffer, strlen( FormatTypeStr ) ) == 0 ) { char* pBuf = &buffer[0]; const char* pUnused = _ReadStringTil( '=', pBuf, TRUE ); const char* pType = _ReadStringTil( EndLine, pBuf, TRUE ); RA_Leaderboard::FormatType nType; if( strcmp( pType, "SCORE" ) == 0 || strcmp( pType, "POINTS" ) == 0 ) { nType = RA_Leaderboard::Format_Score; } else if( strcmp( pType, "TIME" ) == 0 || strcmp( pType, "FRAMES" ) == 0 ) { nType = RA_Leaderboard::Format_TimeFrames; } else if( strcmp( pType, "SECS" ) == 0 ) { nType = RA_Leaderboard::Format_TimeSecs; } else if( strcmp( pType, "MILLISECS" ) == 0 ) { nType = RA_Leaderboard::Format_TimeMillisecs; } else if( strcmp( pType, "VALUE" ) == 0 ) { nType = RA_Leaderboard::Format_Value; } else { nType = RA_Leaderboard::Format_Other; } RA_LOG( "RP: Adding Formatter %s (%s)\n", sDesc.c_str(), pType ); m_formats.push_back( RA_Formattable( sDesc, nType ) ); } } else if( strncmp( DisplayableStr, buffer, strlen( DisplayableStr ) ) == 0 ) { _ReadTil( EndLine, buffer, 4096, &nCharsRead, pFile ); char* pBuf = &buffer[0]; m_sDisplay = _ReadStringTil( '\n', pBuf, TRUE ); // Terminates \n instead } _ReadTil( EndLine, buffer, 4096, &nCharsRead, pFile ); } fclose( pFile ); } }