Fix non-networked race with AIs country flag handling

This commit is contained in:
Benau 2019-06-27 10:21:03 +08:00
parent 24c4f4c8de
commit 12f08c410d
5 changed files with 56 additions and 33 deletions

View File

@ -211,12 +211,15 @@ void FreeForAll::getKartsDisplayInfo(
rank_info.m_outlined_font = true;
rank_info.m_color = getColor(i);
rank_info.m_text = getKart(i)->getController()->getName();
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(i).getCountryCode());
if (!flag.empty())
if (race_manager->getKartGlobalPlayerId(i) > -1)
{
rank_info.m_text += L" ";
rank_info.m_text += flag;
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(i).getCountryCode());
if (!flag.empty())
{
rank_info.m_text += L" ";
rank_info.m_text += flag;
}
}
rank_info.m_text += core::stringw(L" (") +
StringUtils::toWString(m_scores[i]) + L")";

View File

@ -640,12 +640,15 @@ void LinearWorld::getKartsDisplayInfo(
else if (kart->hasFinishedRace())
{
rank_info.m_text = kart->getController()->getName();
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(i).getCountryCode());
if (!flag.empty())
if (race_manager->getKartGlobalPlayerId(i) > -1)
{
rank_info.m_text += L" ";
rank_info.m_text += flag;
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(i).getCountryCode());
if (!flag.empty())
{
rank_info.m_text += L" ";
rank_info.m_text += flag;
}
}
}
else

View File

@ -277,8 +277,11 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
sd.m_correct_goal = isCorrectGoal(m_ball_hitter, first_goal);
sd.m_kart = getKart(m_ball_hitter)->getIdent();
sd.m_player = getKart(m_ball_hitter)->getController()->getName();
sd.m_country_flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(m_ball_hitter).getCountryCode());
if (race_manager->getKartGlobalPlayerId(m_ball_hitter) > -1)
{
sd.m_country_flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(m_ball_hitter).getCountryCode());
}
if (sd.m_correct_goal)
{
m_karts[m_ball_hitter]->getKartModel()
@ -711,7 +714,7 @@ void SoccerWorld::enterRaceOverState()
for (const int &i : m_goal_frame)
squared_sum = squared_sum + (double(i - mean) * double(i - mean));
// Use sample st. deviation (n1) as the profiling can't be run forever
// Use sample st. deviation (n-1) as the profiling can't be run forever
const int stdev = int(sqrt(squared_sum / (m_goal_frame.size() - 1)));
int median = 0;

View File

@ -222,6 +222,8 @@ int RaceManager::getLocalPlayerGPRank(const int player_id) const
*/
void RaceManager::setNumPlayers(int players, int local_players)
{
// Clear all previous game info (like country flags)
m_player_karts.clear();
m_player_karts.resize(players);
if(local_players>-1)
m_num_local_players = local_players;

View File

@ -566,12 +566,15 @@ void RaceResultGUI::displayCTFResults()
if (ctf->getKartTeam(kart_id) != KART_TEAM_RED)
continue;
result_text = kart->getController()->getName();
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(i).getCountryCode());
if (!flag.empty())
if (race_manager->getKartGlobalPlayerId(i) > -1)
{
result_text += L" ";
result_text += flag;
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(i).getCountryCode());
if (!flag.empty())
{
result_text += L" ";
result_text += flag;
}
}
result_text.append(" ");
if (kart->isEliminated())
@ -611,12 +614,15 @@ void RaceResultGUI::displayCTFResults()
if (ctf->getKartTeam(kart_id) != KART_TEAM_BLUE)
continue;
result_text = kart->getController()->getName();
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(i).getCountryCode());
if (!flag.empty())
if (race_manager->getKartGlobalPlayerId(i) > -1)
{
result_text += L" ";
result_text += flag;
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(i).getCountryCode());
if (!flag.empty())
{
result_text += L" ";
result_text += flag;
}
}
result_text.append(" ");
if (kart->isEliminated())
@ -715,12 +721,15 @@ void RaceResultGUI::displayCTFResults()
RowInfo *ri = &(m_all_row_infos[position - first_position]);
ri->m_is_player_kart = kart->getController()->isLocalPlayerController();
ri->m_kart_name = kart->getController()->getName();
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(kart->getWorldKartId()).getCountryCode());
if (!flag.empty())
if (race_manager->getKartGlobalPlayerId(kart->getWorldKartId()) > -1)
{
ri->m_kart_name += L" ";
ri->m_kart_name += flag;
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(kart->getWorldKartId()).getCountryCode());
if (!flag.empty())
{
ri->m_kart_name += L" ";
ri->m_kart_name += flag;
}
}
video::ITexture *icon =
kart->getKartProperties()->getIconMaterial()->getTexture();
@ -1122,12 +1131,15 @@ void RaceResultGUI::displayCTFResults()
kart->getKartProperties()->getIconMaterial()->getTexture();
ri->m_is_player_kart = kart->getController()->isLocalPlayerController();
ri->m_kart_name = kart->getController()->getName();
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(kart->getWorldKartId()).getCountryCode());
if (!flag.empty())
if (race_manager->getKartGlobalPlayerId(kart->getWorldKartId()) > -1)
{
ri->m_kart_name += L" ";
ri->m_kart_name += flag;
const core::stringw& flag = StringUtils::getCountryFlag(
race_manager->getKartInfo(kart->getWorldKartId()).getCountryCode());
if (!flag.empty())
{
ri->m_kart_name += L" ";
ri->m_kart_name += flag;
}
}
// In FTL karts do have a time, which is shown even when the kart
// is eliminated