NetPlayClient: Deduplicate code for player list retrieval

This commit is contained in:
Lioncash 2016-01-24 23:06:04 -05:00
parent e6ad76fa70
commit 7304c863a6
1 changed files with 19 additions and 22 deletions

View File

@ -575,29 +575,26 @@ void NetPlayClient::GetPlayerList(std::string& list, std::vector<int>& pid_list)
std::ostringstream ss; std::ostringstream ss;
std::map<PlayerId, Player>::const_iterator const auto enumerate_player_controller_mappings = [&ss](const PadMappingArray& mappings, const Player& player) {
i = m_players.begin(), for (size_t i = 0; i < mappings.size(); i++)
e = m_players.end();
for (; i != e; ++i)
{ {
const Player *player = &(i->second); if (mappings[i] == player.pid)
ss << player->name << "[" << (int)player->pid << "] : " << player->revision << " | "; ss << i + 1;
for (unsigned int j = 0; j < 4; j++)
{
if (m_pad_map[j] == player->pid)
ss << j + 1;
else else
ss << '-'; ss << '-';
} }
for (unsigned int j = 0; j < 4; j++) };
for (const auto& entry : m_players)
{ {
if (m_wiimote_map[j] == player->pid) const Player& player = entry.second;
ss << j + 1; ss << player.name << "[" << static_cast<int>(player.pid) << "] : " << player.revision << " | ";
else
ss << '-'; enumerate_player_controller_mappings(m_pad_map, player);
} enumerate_player_controller_mappings(m_wiimote_map, player);
ss << " |\nPing: " << player->ping << "ms\n\n";
pid_list.push_back(player->pid); ss << " |\nPing: " << player.ping << "ms\n\n";
pid_list.push_back(player.pid);
} }
list = ss.str(); list = ss.str();