Remove most isGhostKart() hack when avoidable
This commit is contained in:
@@ -512,8 +512,7 @@ void Kart::setController(Controller *controller)
|
||||
*/
|
||||
void Kart::setPosition(int p)
|
||||
{
|
||||
if (m_controller)
|
||||
m_controller->setPosition(p);
|
||||
m_controller->setPosition(p);
|
||||
m_race_position = p;
|
||||
} // setPosition
|
||||
|
||||
@@ -835,15 +834,14 @@ void Kart::finishedRace(float time)
|
||||
if(m_finished_race) return;
|
||||
m_finished_race = true;
|
||||
m_finish_time = time;
|
||||
if(!isGhostKart())
|
||||
m_controller->finishedRace(time);
|
||||
m_controller->finishedRace(time);
|
||||
m_kart_model->finishedRace();
|
||||
race_manager->kartFinishedRace(this, time);
|
||||
|
||||
if ((race_manager->getMinorMode() == RaceManager::MINOR_MODE_NORMAL_RACE ||
|
||||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL ||
|
||||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
||||
&& (isGhostKart() ? false : m_controller->isPlayerController()))
|
||||
&& m_controller->isPlayerController())
|
||||
{
|
||||
RaceGUIBase* m = World::getWorld()->getRaceGUI();
|
||||
if (m)
|
||||
@@ -890,9 +888,8 @@ void Kart::setRaceResult()
|
||||
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_NORMAL_RACE ||
|
||||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL)
|
||||
{
|
||||
if (isGhostKart() ? false : m_controller->isPlayerController())
|
||||
if (m_controller->isLocalPlayerController()) // if player is on this computer
|
||||
{
|
||||
// if player is on this computer
|
||||
PlayerProfile *player = PlayerManager::getCurrentPlayer();
|
||||
const ChallengeStatus *challenge = player->getCurrentChallengeStatus();
|
||||
// In case of a GP challenge don't make the end animation depend
|
||||
|
||||
@@ -245,33 +245,24 @@ void LinearWorld::newLap(unsigned int kart_index)
|
||||
{
|
||||
KartInfo &kart_info = m_kart_info[kart_index];
|
||||
AbstractKart *kart = m_karts[kart_index];
|
||||
const bool is_gk = kart->isGhostKart();
|
||||
|
||||
// Reset reset-after-lap achievements
|
||||
if (!is_gk)
|
||||
StateManager::ActivePlayer *c = kart->getController()->getPlayer();
|
||||
PlayerProfile *p = PlayerManager::getCurrentPlayer();
|
||||
if (c && c->getConstProfile() == p)
|
||||
{
|
||||
StateManager::ActivePlayer *c = kart->getController()->getPlayer();
|
||||
PlayerProfile *p = PlayerManager::getCurrentPlayer();
|
||||
if (c && c->getConstProfile() == p)
|
||||
{
|
||||
p->getAchievementsStatus()->onLapEnd();
|
||||
}
|
||||
p->getAchievementsStatus()->onLapEnd();
|
||||
}
|
||||
|
||||
// Only update the kart controller if a kart that has already finished
|
||||
// the race crosses the start line again. This avoids 'fastest lap'
|
||||
// messages if the end controller does a fastest lap, but especially
|
||||
// allows the end controller to switch end cameras
|
||||
if (!is_gk)
|
||||
if(kart->hasFinishedRace())
|
||||
{
|
||||
if (kart->hasFinishedRace())
|
||||
{
|
||||
kart->getController()->newLap(kart_info.m_race_lap);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (kart->hasFinishedRace())
|
||||
kart->getController()->newLap(kart_info.m_race_lap);
|
||||
return;
|
||||
}
|
||||
|
||||
const int lap_count = race_manager->getNumLaps();
|
||||
|
||||
@@ -383,8 +374,7 @@ void LinearWorld::newLap(unsigned int kart_index)
|
||||
} // end if new fastest lap
|
||||
|
||||
kart_info.m_lap_start_time = getTime();
|
||||
if (!is_gk)
|
||||
kart->getController()->newLap(kart_info.m_race_lap);
|
||||
kart->getController()->newLap(kart_info.m_race_lap);
|
||||
} // newLap
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -850,8 +840,6 @@ void LinearWorld::updateRacePosition()
|
||||
*/
|
||||
void LinearWorld::checkForWrongDirection(unsigned int i, float dt)
|
||||
{
|
||||
if (m_karts[i]->isGhostKart()) return;
|
||||
|
||||
if (!m_karts[i]->getController()->isLocalPlayerController())
|
||||
return;
|
||||
|
||||
|
||||
@@ -102,25 +102,16 @@ void StandardRace::endRaceEarly()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (kart->isGhostKart())
|
||||
if (kart->getController()->isPlayerController())
|
||||
{
|
||||
// Ghost karts finish
|
||||
setKartPosition(kartid, i - (unsigned int) active_players.size());
|
||||
kart->finishedRace(estimateFinishTimeForKart(kart));
|
||||
// Keep active players apart for now
|
||||
active_players.push_back(kartid);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (kart->getController()->isPlayerController())
|
||||
{
|
||||
// Keep active players apart for now
|
||||
active_players.push_back(kartid);
|
||||
}
|
||||
else
|
||||
{
|
||||
// AI karts finish
|
||||
setKartPosition(kartid, i - (unsigned int) active_players.size());
|
||||
kart->finishedRace(estimateFinishTimeForKart(kart));
|
||||
}
|
||||
// AI karts finish
|
||||
setKartPosition(kartid, i - (unsigned int) active_players.size());
|
||||
kart->finishedRace(estimateFinishTimeForKart(kart));
|
||||
}
|
||||
} // i <= kart_amount
|
||||
// Now make the active players finish
|
||||
|
||||
@@ -520,7 +520,6 @@ void World::terminateRace()
|
||||
}
|
||||
for(unsigned int i = 0; i < kart_amount; i++)
|
||||
{
|
||||
if (m_karts[i]->isGhostKart()) continue;
|
||||
// Retrieve the current player
|
||||
StateManager::ActivePlayer* p = m_karts[i]->getController()->getPlayer();
|
||||
if (p && p->getConstProfile() == PlayerManager::getCurrentPlayer())
|
||||
@@ -546,7 +545,6 @@ void World::terminateRace()
|
||||
{
|
||||
for(unsigned int i = 0; i < kart_amount; i++)
|
||||
{
|
||||
if (m_karts[i]->isGhostKart()) continue;
|
||||
// Retrieve the current player
|
||||
StateManager::ActivePlayer* p = m_karts[i]->getController()->getPlayer();
|
||||
if (p && p->getConstProfile() == PlayerManager::getCurrentPlayer())
|
||||
@@ -1090,7 +1088,6 @@ void World::updateHighscores(int* best_highscore_rank, int* best_finish_time,
|
||||
|
||||
for (unsigned int pos=0; pos<kart_amount; pos++)
|
||||
{
|
||||
if (m_karts[index[pos]]->isGhostKart()) continue;
|
||||
if(index[pos] == 999)
|
||||
{
|
||||
// no kart claimed to be in this position, most likely means
|
||||
@@ -1155,14 +1152,11 @@ AbstractKart *World::getPlayerKart(unsigned int n) const
|
||||
unsigned int count=-1;
|
||||
|
||||
for(unsigned int i=0; i<m_karts.size(); i++)
|
||||
{
|
||||
if(m_karts[i]->isGhostKart()) continue;
|
||||
if(m_karts[i]->getController()->isPlayerController())
|
||||
{
|
||||
count++;
|
||||
if(count==n) return m_karts[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} // getPlayerKart
|
||||
|
||||
@@ -1260,7 +1254,6 @@ void World::unpause()
|
||||
|
||||
for(unsigned int i=0; i<m_karts.size(); i++)
|
||||
{
|
||||
if (m_karts[i]->isGhostKart()) continue;
|
||||
// Note that we can not test for isPlayerController here, since
|
||||
// an EndController will also return 'isPlayerController' if the
|
||||
// kart belonged to a player.
|
||||
|
||||
@@ -859,7 +859,6 @@ void RaceManager::kartFinishedRace(const AbstractKart *kart, float time)
|
||||
m_kart_status[id].m_overall_time += time;
|
||||
m_kart_status[id].m_last_time = time;
|
||||
m_num_finished_karts ++;
|
||||
if(kart->isGhostKart()) return;
|
||||
if(kart->getController()->isPlayerController())
|
||||
m_num_finished_players++;
|
||||
} // kartFinishedRace
|
||||
|
||||
@@ -378,9 +378,9 @@ void RaceGUI::drawGlobalMiniMap()
|
||||
|
||||
// int marker_height = m_marker->getSize().Height;
|
||||
core::rect<s32> source(core::position2di(0, 0), icon->getSize());
|
||||
int marker_half_size = (kart->isGhostKart() ? m_minimap_ai_size :
|
||||
(kart->getController()->isLocalPlayerController() ? m_minimap_player_size :
|
||||
m_minimap_ai_size))>>1;
|
||||
int marker_half_size = (kart->getController()->isLocalPlayerController()
|
||||
? m_minimap_player_size
|
||||
: m_minimap_ai_size )>>1;
|
||||
core::rect<s32> position(m_map_left+(int)(draw_at.getX()-marker_half_size),
|
||||
lower_y -(int)(draw_at.getY()+marker_half_size),
|
||||
m_map_left+(int)(draw_at.getX()+marker_half_size),
|
||||
|
||||
@@ -802,14 +802,13 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
|
||||
// draw icon
|
||||
video::ITexture *icon =
|
||||
kart->getKartProperties()->getIconMaterial()->getTexture();
|
||||
int w = kart->isGhostKart() ? ICON_WIDTH : (kart->getController()
|
||||
int w = kart->getController()
|
||||
->isLocalPlayerController() ? ICON_PLAYER_WIDTH
|
||||
: ICON_WIDTH);
|
||||
: ICON_WIDTH;
|
||||
const core::rect<s32> pos(x, y, x+w, y+w);
|
||||
|
||||
//to bring to light the player's icon: add a background
|
||||
if (kart->isGhostKart() ?
|
||||
false : kart->getController()->isLocalPlayerController())
|
||||
if (kart->getController()->isLocalPlayerController())
|
||||
{
|
||||
video::SColor colors[4];
|
||||
for (unsigned int i=0;i<4;i++)
|
||||
|
||||
@@ -89,7 +89,6 @@ void RaceResultGUI::init()
|
||||
for (unsigned int kart_id = 0; kart_id < num_karts; kart_id++)
|
||||
{
|
||||
const AbstractKart *kart = World::getWorld()->getKart(kart_id);
|
||||
if (kart->isGhostKart()) continue;
|
||||
if (kart->getController()->isPlayerController())
|
||||
human_win = human_win && kart->getRaceResult();
|
||||
}
|
||||
@@ -475,8 +474,7 @@ void RaceResultGUI::determineTableLayout()
|
||||
|
||||
// Save a pointer to the current row_info entry
|
||||
RowInfo *ri = &(m_all_row_infos[position-first_position]);
|
||||
ri->m_is_player_kart = kart->isGhostKart() ? false :
|
||||
kart->getController()->isLocalPlayerController();
|
||||
ri->m_is_player_kart = kart->getController()->isLocalPlayerController();
|
||||
|
||||
// Identify Human player, if so display real name other than kart name
|
||||
const int rm_id = kart->getWorldKartId() -
|
||||
@@ -862,8 +860,7 @@ void RaceResultGUI::determineGPLayout()
|
||||
else
|
||||
ri->m_kart_name = translations->fribidize(kart->getName());
|
||||
|
||||
ri->m_is_player_kart = kart->isGhostKart() ? false :
|
||||
kart->getController()->isLocalPlayerController();
|
||||
ri->m_is_player_kart = kart->getController()->isLocalPlayerController();
|
||||
ri->m_player = ri->m_is_player_kart
|
||||
? kart->getController()->getPlayer() : NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user