Tried to fix compilation problems due to merging.

This commit is contained in:
hiker 2018-12-16 02:36:16 +11:00
parent 4269ac6294
commit 0eca431627
4 changed files with 28 additions and 9 deletions

View File

@ -486,8 +486,7 @@ void ClientLobby::disconnectedPlayer(Event* event)
uint32_t host_id = data.getUInt32();
// Use the friend icon to avoid an error-like message
MessageQueue::add(MessageQueue::MT_FRIEND, msg);
TracksScreen::getInstance()->removeVote(
name + StringUtils::toString(host_id));
TracksScreen::getInstance()->removeVote(host_id);
}
} // disconnectedPlayer

View File

@ -947,7 +947,7 @@ void ServerLobby::startSelection(const Event *event)
ns->addUInt8(LE_START_SELECTION)
.addFloat(ServerConfig::m_voting_timeout)
.addUInt8(m_game_setup->isGrandPrixStarted() ? 1 : 0)
.addUInt8(ServerConfig::m_auto_lap_ratio > 0.0f ? 1 : 0);
.addUInt8(ServerConfig::m_auto_game_time_ratio > 0.0f ? 1 : 0);
// Remove karts / tracks from server that are not supported on all clients
std::set<std::string> karts_erase, tracks_erase;
@ -1962,7 +1962,7 @@ void ServerLobby::handlePlayerVote(Event* event)
vote.m_num_laps =
(uint8_t)(fmaxf(1.0f,
(float)t->getDefaultNumberOfLaps()
*ServerConfig::m_auto_lap_ratio ) );
*ServerConfig::m_auto_game_time_ratio ) );
}
else
{
@ -1975,17 +1975,17 @@ void ServerLobby::handlePlayerVote(Event* event)
vote.m_num_laps = (uint8_t)3;
}
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER &&
ServerConfig::m_auto_game_time_ratio > 0.0f)
ServerConfig::m_auto_game_time_ratio > 0.0f )
{
if (m_game_setup->isSoccerGoalTarget())
{
lap = (uint8_t)(ServerConfig::m_auto_game_time_ratio *
UserConfigParams::m_num_goals);
vote.m_num_laps = (uint8_t)(ServerConfig::m_auto_game_time_ratio *
UserConfigParams::m_num_goals);
}
else
{
lap = (uint8_t)(ServerConfig::m_auto_game_time_ratio *
UserConfigParams::m_soccer_time_limit);
vote.m_num_laps = (uint8_t)(ServerConfig::m_auto_game_time_ratio *
UserConfigParams::m_soccer_time_limit);
}
}

View File

@ -577,6 +577,25 @@ void TracksScreen::addVote(int host_id)
showVote(host_id);
} // addVote
// ----------------------------------------------------------------------------
/** Removes a vote, which is triggered when a client disconnects.
* \param host_id Host id of the disconnected client.
*/
void TracksScreen::removeVote(int host_id)
{
auto it = std::find(m_index_to_hostid.begin(), m_index_to_hostid.end(),
host_id);
Log::verbose("TracksScreen", "removeVote: hostid %d found %d",
host_id, it != m_index_to_hostid.end());
// Add a new index if this is the first vote for the host/
if (it != m_index_to_hostid.end())
{
m_index_to_hostid.erase(it);
}
} //removeVote
// ----------------------------------------------------------------------------
/** Populates one entry in the voting list with the vote from the
* corresponding host. A mapping of host_id to index MUST exist for this

View File

@ -88,6 +88,7 @@ private:
public:
void addVote(int host_id);
void removeVote(int host_id);
void showVote(int host_id);
void setResult(const PeerVote &winner_vote);
void showVoteResult();