Fix #3875
This commit is contained in:
@@ -588,5 +588,6 @@
|
||||
<network-capabilities>
|
||||
<capabilities name="report_player"/>
|
||||
<capabilities name="color_emoji"/>
|
||||
<capabilities name="ranking_changes"/>
|
||||
</network-capabilities>
|
||||
</config>
|
||||
|
||||
@@ -124,6 +124,7 @@ ClientLobby::~ClientLobby()
|
||||
//-----------------------------------------------------------------------------
|
||||
void ClientLobby::setup()
|
||||
{
|
||||
m_ranking_changes.clear();
|
||||
m_spectator = false;
|
||||
m_server_send_live_load_world = false;
|
||||
m_auto_back_to_lobby_time = std::numeric_limits<uint64_t>::max();
|
||||
@@ -1097,6 +1098,20 @@ void ClientLobby::raceFinished(Event* event)
|
||||
}
|
||||
}
|
||||
|
||||
m_ranking_changes.clear();
|
||||
// Ranking changes from server
|
||||
if (NetworkConfig::get()->getServerCapabilities().find("ranking_changes")
|
||||
!= NetworkConfig::get()->getServerCapabilities().end())
|
||||
{
|
||||
bool has_ranking_changes = (data.getUInt8() & 1) != 0;
|
||||
if (has_ranking_changes)
|
||||
{
|
||||
unsigned count = data.getUInt8();
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
m_ranking_changes.push_back(data.getFloat());
|
||||
}
|
||||
}
|
||||
|
||||
// stop race protocols
|
||||
RaceEventManager::getInstance()->stop();
|
||||
ProtocolManager::lock()->findAndTerminate(PROTOCOL_GAME_EVENTS);
|
||||
|
||||
@@ -128,6 +128,8 @@ private:
|
||||
|
||||
std::vector<LobbyPlayer> m_lobby_players;
|
||||
|
||||
std::vector<float> m_ranking_changes;
|
||||
|
||||
irr::core::stringw m_total_players;
|
||||
|
||||
void liveJoinAcknowledged(Event* event);
|
||||
@@ -178,6 +180,8 @@ public:
|
||||
{ return m_server_enabled_track_voting; }
|
||||
bool serverEnabledReportPlayer() const
|
||||
{ return m_server_enabled_report_player; }
|
||||
const std::vector<float>& getRankingChanges() const
|
||||
{ return m_ranking_changes; }
|
||||
};
|
||||
|
||||
#endif // CLIENT_LOBBY_HPP
|
||||
|
||||
@@ -2389,6 +2389,12 @@ void ServerLobby::checkRaceFinished()
|
||||
m_result_ns->encodeString(static_cast<LinearWorld*>(World::getWorld())
|
||||
->getFastestLapKartName());
|
||||
}
|
||||
|
||||
uint8_t ranking_changes_indication = 0;
|
||||
if (ServerConfig::m_ranked && race_manager->modeHasLaps())
|
||||
ranking_changes_indication = 1;
|
||||
m_result_ns->addUInt8(ranking_changes_indication);
|
||||
|
||||
if (ServerConfig::m_ranked)
|
||||
{
|
||||
computeNewRankings();
|
||||
@@ -2411,13 +2417,17 @@ void ServerLobby::computeNewRankings()
|
||||
// Would this be worth it ?
|
||||
std::vector<double> scores_change;
|
||||
std::vector<double> new_scores;
|
||||
std::vector<double> prev_scores;
|
||||
|
||||
unsigned player_count = race_manager->getNumPlayers();
|
||||
m_result_ns->addUInt8((uint8_t)player_count);
|
||||
for (unsigned i = 0; i < player_count; i++)
|
||||
{
|
||||
const uint32_t id = race_manager->getKartInfo(i).getOnlineId();
|
||||
new_scores.push_back(m_scores.at(id));
|
||||
double prev_score = m_scores.at(id);
|
||||
new_scores.push_back(prev_score);
|
||||
new_scores[i] += distributeBasePoints(id);
|
||||
prev_scores.push_back(prev_score);
|
||||
}
|
||||
|
||||
// First, update the number of ranked races
|
||||
@@ -2537,6 +2547,13 @@ void ServerLobby::computeNewRankings()
|
||||
if (m_scores.at(id) > m_max_scores.at(id))
|
||||
m_max_scores.at(id) = m_scores.at(id);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < player_count; i++)
|
||||
{
|
||||
const uint32_t id = race_manager->getKartInfo(i).getOnlineId();
|
||||
double change = m_scores.at(id) - prev_scores[i];
|
||||
m_result_ns->addFloat((float)change);
|
||||
}
|
||||
} // computeNewRankings
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -735,6 +735,7 @@ void RaceResultGUI::displayCTFResults()
|
||||
int time_precision = race_manager->currentModeTimePrecision();
|
||||
bool active_gp = (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX);
|
||||
|
||||
auto cl = LobbyProtocol::get<ClientLobby>();
|
||||
for (unsigned int position = first_position;
|
||||
position <= race_manager->getNumberOfKarts() - sta; position++)
|
||||
{
|
||||
@@ -780,6 +781,22 @@ void RaceResultGUI::displayCTFResults()
|
||||
std::string time_string = StringUtils::timeToString(time, time_precision);
|
||||
ri->m_finish_time_string = time_string.c_str();
|
||||
}
|
||||
if (cl && !cl->getRankingChanges().empty())
|
||||
{
|
||||
unsigned kart_id = kart->getWorldKartId();
|
||||
if (kart_id < cl->getRankingChanges().size())
|
||||
{
|
||||
ri->m_finish_time_string += L" ";
|
||||
float ranking_change = cl->getRankingChanges()[kart_id];
|
||||
if (ranking_change > 0)
|
||||
{
|
||||
ri->m_finish_time_string += L"+";
|
||||
ri->m_finish_time_string += StringUtils::toWString(ranking_change);
|
||||
}
|
||||
else
|
||||
ri->m_finish_time_string += StringUtils::toWString(ranking_change);
|
||||
}
|
||||
}
|
||||
|
||||
core::dimension2du rect =
|
||||
m_font->getDimension(ri->m_kart_name.c_str());
|
||||
|
||||
Reference in New Issue
Block a user