Main/src/MultiplayerScreen.cpp
// Get a map from a given "short" path, and level
// The selected index will be written to diffIndex
// diffIndex can be used as a hint to which song to pick
Get a map from a given "short" path, and level
The selected index will be written to diffIndex
diffIndex can be used as a hint to which song to pick
Get a map from a given " short " path and level The selected index will be written to diffIndex diffIndex can be used as a hint to which song to pick
ChartIndex* MultiplayerScreen::m_getChartByShortPath(const String& path, uint32* diffIndex, int32 level, bool useHint)
{
	Logf("[Multiplayer] looking up song '%s' level %u difficulty index hint %u", Logger::Severity::Info, path.c_str(), level, *diffIndex);
	for (auto folder : m_mapDatabase->FindFoldersByPath(path))
	{
		ChartIndex* newChart = NULL;
		for (size_t ind = 0; ind < folder.second->charts.size(); ind++)
		{
			ChartIndex* chart = folder.second->charts[ind];
			if (chart->level == level)
			{
				if (useHint && *diffIndex != ind)
					break;
				newChart = chart;
				*diffIndex = ind;
				break;
			}
		}
		if (newChart == NULL && !useHint)
		{
			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;
		}
	}
	if (useHint)
	{
		*diffIndex = 0;
		return m_getChartByShortPath(path, diffIndex, level, false);
	}
	Log("[Multiplayer] Could not find song", Logger::Severity::Warning);
	return nullptr;
}
ChartIndex * MultiplayerScreen :: m_getChartByShortPath ( const String & path , uint32 * diffIndex , int32 level , bool useHint ) { Logf ( " " , Logger :: Severity :: Info , path . c_str ( ) , level , * diffIndex ) ; for ( auto folder : m_mapDatabase -> FindFoldersByPath ( path ) ) { ChartIndex * newChart = NULL ; for ( size_t ind = 0 ; ind < folder . second -> charts . size ( ) ; ind ++ ) { ChartIndex * chart = folder . second -> charts [ ind ] ; if ( chart -> level == level ) { if ( useHint && * diffIndex != ind ) break ; newChart = chart ; * diffIndex = ind ; break ; } } if ( newChart == NULL && ! useHint ) { 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 ; } } if ( useHint ) { * diffIndex = 0 ; return m_getChartByShortPath ( path , diffIndex , level , false ) ; } Log ( " " , Logger :: Severity :: Warning ) ; return nullptr ; }
Get a map from a given "short" path, and level
The selected index will be written to diffIndex
diffIndex can be used as a hint to which song to pick
Get a map from a given " short " path and level The selected index will be written to diffIndex diffIndex can be used as a hint to which song to pick
// First we try to get exact song (kinda) by matching index hint to level // If we already searched the songs just take any level that matches // If we didn't find any matches and we are on our last try, just pick anything // Search one more time, but ignore the hint this time