void App::rebuildPlayerList()
{
	if (!listPlayers || !mClient)  return;
	listPlayers->removeAllItems();

	//  Add self
	unsigned peerCount = mClient->getPeerCount();
	listPlayers->addItem("#C0E0FF"+pSet->nickname);
	listPlayers->setSubItemNameAt(1, 0, "#80FFFF"+sListCar); // Car
	listPlayers->setSubItemNameAt(2, 0, "#C0C0FF"+toStr(peerCount)); // Peers
	listPlayers->setSubItemNameAt(3, 0, "#C0FFFF""0");  bool rd = mClient->isReady(); // Ping
	listPlayers->setSubItemNameAt(4, 0, (rd?"#80FF80":"#FF8080")+yesno(rd)); // Ready state

	//  Add others
	bool allReady = true;
	const PeerMap peers = mClient->getPeers();
	for (PeerMap::const_iterator it = peers.begin(); it != peers.end(); ++it)
	{
		if (it->second.name.empty() || it->second.connection == PeerInfo::DISCONNECTED)
			continue;
		// Determine if everyone is ready and connected
		if (it->second.peers != peerCount || !it->second.ready)
			allReady = false;

		// Add list item
		listPlayers->addItem("#C0E0FF"+it->second.name);  int l = listPlayers->getItemCount()-1;
		listPlayers->setSubItemNameAt(1, l, "#80FFFF"+it->second.car);
		listPlayers->setSubItemNameAt(2, l, "#C0C0FF"+toStr(it->second.peers));
		listPlayers->setSubItemNameAt(3, l, "#C0FFFF"+toStr(it->second.ping));  bool rd = it->second.ready;
		listPlayers->setSubItemNameAt(4, l, (rd?"#80FF80":"#FF8080")+yesno(rd));
	}
	//  Allow host to start the game
	if (mLobbyState == HOSTING)
		btnNetReady->setEnabled(allReady);
}
BBObject *cpfind( void *obj ){
	if( !obj ) return &bbNullObject;
	PeerMap::iterator it = peerMap.find( obj );
	if( it != peerMap.end() ) return it->second;
	return &bbNullObject;
}