Fixed second location where the kart/playe rname was used.

This commit is contained in:
hiker 2016-05-07 00:14:55 +10:00
parent 6c9f3d73b5
commit bc418acb05
2 changed files with 26 additions and 28 deletions

View File

@ -494,25 +494,7 @@ void RaceResultGUI::backToLobby()
// Save a pointer to the current row_info entry
RowInfo *ri = &(m_all_row_infos[position - first_position]);
ri->m_is_player_kart = kart->getController()->isLocalPlayerController();
// Identify Human player, if so display real name other than kart name
const EndController *ec =
dynamic_cast<const EndController*>(kart->getController());
// If the race was given up, there is no end controller for the
// players, so this case needs to be handled separately
if(ec && ec->isLocalPlayerController())
ri->m_kart_name = ec->getName();
else
{
const PlayerController *pc =
dynamic_cast<const PlayerController*>(kart->getController());
// Check if the kart is a player controller to get the real name
if(pc)
ri->m_kart_name = pc->getName();
else
ri->m_kart_name = translations->fribidize(kart->getName());
}
ri->m_kart_name = getKartDisplayName(kart);
video::ITexture *icon =
kart->getKartProperties()->getIconMaterial()->getTexture();
@ -877,16 +859,8 @@ void RaceResultGUI::backToLobby()
RowInfo *ri = &(m_all_row_infos[rank]);
ri->m_kart_icon =
kart->getKartProperties()->getIconMaterial()->getTexture();
const int rm_id = kart_id -
(race_manager->getNumberOfKarts() - race_manager->getNumPlayers());
if (rm_id >= 0 && !race_manager->isWatchingReplay())
ri->m_kart_name = race_manager->getKartInfo(rm_id).getPlayerName();
else
ri->m_kart_name = translations->fribidize(kart->getName());
ri->m_is_player_kart = kart->getController()->isLocalPlayerController();
ri->m_kart_name = getKartDisplayName(kart);
// In FTL karts do have a time, which is shown even when the kart
// is eliminated
@ -937,6 +911,29 @@ void RaceResultGUI::backToLobby()
} // i < num_karts
} // determineGPLayout
//-----------------------------------------------------------------------------
/** Returns a string to display next to a kart. For a player that's the name
* of the player, for an AI kart it's the name of the driver.
*/
core::stringw RaceResultGUI::getKartDisplayName(const AbstractKart *kart) const
{
const EndController *ec =
dynamic_cast<const EndController*>(kart->getController());
// If the race was given up, there is no end controller for the
// players, so this case needs to be handled separately
if(ec && ec->isLocalPlayerController())
return ec->getName();
else
{
// No end controller, check explicitely for a player controller
const PlayerController *pc =
dynamic_cast<const PlayerController*>(kart->getController());
// Check if the kart is a player controller to get the real name
if(pc) return pc->getName();
}
return translations->fribidize(kart->getName());
} // getKartDisplayName
//-----------------------------------------------------------------------------
/** Displays the race results for a single kart.
* \param n Index of the kart to be displayed.

View File

@ -194,6 +194,7 @@ private:
void displayHighScores();
void displaySoccerResults();
void displayScreenShots();
irr::core::stringw getKartDisplayName(const AbstractKart *kart) const;
int getFontHeight () const;