Main/src/MultiplayerScreen.cpp
// Get a song for given audio hash and level
// If we find a match find a matching hash but not level, just go with any level
Get a song for given audio hash and level
If we find a match find a matching hash but not level, just go with any level
Get a song for given audio hash and level If we find a match find a matching hash but not level just go with any level
ChartIndex* MultiplayerScreen::m_getChartByHash(const String& hash, const String& path, uint32* diffIndex, int32 level)
{
	if (hash.length() == 0)
		return m_getChartByShortPath(path, diffIndex, level, true);
	Logf("[Multiplayer] looking up song hash '%s' level %u", Logger::Severity::Info, *hash, level);
	for (auto folder : m_mapDatabase->FindFoldersByHash(hash))
	{
		ChartIndex* newChart = NULL;
		for (size_t ind = 0; ind < folder.second->charts.size(); ind++)
		{
			ChartIndex* chart = folder.second->charts[ind];
			if (chart->level == level)
			{
				newChart = chart;
				*diffIndex = ind;
			}
		}
		if (newChart == NULL)
		{
			assert(folder.second->charts.size() > 0);
			*diffIndex = 0;
			newChart = folder.second->charts[0];
		}
		if (newChart != NULL)
		{
			Logf("[Multiplayer] Found: diff_id=%d mapid=%d index=%u path=%s", Logger::Severity::Info, newChart->id, newChart->folderId, *diffIndex, newChart->path.c_str());
			return newChart;
		}
	}
	Log("[Multiplayer] Could not find song by hash, falling back to foldername", Logger::Severity::Warning);
	return m_getChartByShortPath(path, diffIndex, level, true);
}
ChartIndex * MultiplayerScreen :: m_getChartByHash ( const String & hash , const String & path , uint32 * diffIndex , int32 level ) { if ( hash . length ( ) == 0 ) return m_getChartByShortPath ( path , diffIndex , level , true ) ; Logf ( " " , Logger :: Severity :: Info , * hash , level ) ; for ( auto folder : m_mapDatabase -> FindFoldersByHash ( hash ) ) { ChartIndex * newChart = NULL ; for ( size_t ind = 0 ; ind < folder . second -> charts . size ( ) ; ind ++ ) { ChartIndex * chart = folder . second -> charts [ ind ] ; if ( chart -> level == level ) { newChart = chart ; * diffIndex = ind ; } } if ( newChart == NULL ) { assert ( folder . second -> charts . size ( ) > 0 ) ; * diffIndex = 0 ; newChart = folder . second -> charts [ 0 ] ; } if ( newChart != NULL ) { Logf ( " " , Logger :: Severity :: Info , newChart -> id , newChart -> folderId , * diffIndex , newChart -> path . c_str ( ) ) ; return newChart ; } } Log ( " " , Logger :: Severity :: Warning ) ; return m_getChartByShortPath ( path , diffIndex , level , true ) ; }
Get a song for given audio hash and level
If we find a match find a matching hash but not level, just go with any level
Get a song for given audio hash and level If we find a match find a matching hash but not level just go with any level
// Fallback on an empty hash // We found a matching level for this hash, good to go // We didn't find the exact level, but we should still use this map anyway