Automatically start game when all track votes have been received.

This commit is contained in:
hiker 2015-12-04 08:00:51 +11:00
parent af3f72ae84
commit 637202077f
3 changed files with 14 additions and 0 deletions

View File

@ -692,6 +692,8 @@ void ServerLobbyRoomProtocol::playerTrackVote(Event* event)
NetworkString prefix(1);
prefix.ai8(LE_VOTE_TRACK); // prefix the token with the ype
sendMessageToPeersChangingToken(prefix, other);
if(m_setup->getRaceConfig()->getNumTrackVotes()==m_setup->getPlayerCount())
startGame();
} // playerTrackVote
//-----------------------------------------------------------------------------

View File

@ -447,3 +447,14 @@ const TrackInfo* RaceConfig::getNextTrackInfo() const
} // getNextTrackInfo
//-----------------------------------------------------------------------------
int RaceConfig::getNumTrackVotes() const
{
int count = 0;
for (unsigned int i = 0; i < m_max_players; i++)
{
if (m_votes[i].hasVotedTrack())
count ++;
}
return count;
} // getNumTrackVotes

View File

@ -115,6 +115,7 @@ public:
const TrackInfo* getNextTrackInfo() const;
bool getReverse() const;
bool getLapCount() const;
int getNumTrackVotes() const;
protected:
std::vector<TrackInfo> m_tracks;