/** Remove (eliminate) a kart from the race */ void World::eliminateKart(int kart_id, bool notify_of_elimination) { AbstractKart *kart = m_karts[kart_id]; if (kart->isGhostKart()) return; // Display a message about the eliminated kart in the race guia if (notify_of_elimination) { for(unsigned int i=0; i<Camera::getNumCameras(); i++) { Camera *camera = Camera::getCamera(i); if(camera->getKart()==kart) m_race_gui->addMessage(_("You have been eliminated!"), kart, 2.0f); else m_race_gui->addMessage(_("'%s' has been eliminated.", kart->getName()), camera->getKart(), 2.0f); } // for i < number of cameras } // if notify_of_elimination if(kart->getController()->isLocalPlayerController()) { for(unsigned int i=0; i<Camera::getNumCameras(); i++) { // Change the camera so that it will be attached to the leader // and facing backwards. Camera *camera = Camera::getCamera(i); if(camera->getKart()==kart) camera->setMode(Camera::CM_LEADER_MODE); } m_eliminated_players++; } // The kart can't be really removed from the m_kart array, since otherwise // a race can't be restarted. So it's only marked to be eliminated (and // ignored in all loops). Important:world->getCurrentNumKarts() returns // the number of karts still racing. This value can not be used for loops // over all karts, use race_manager->getNumKarts() instead! kart->eliminate(); m_eliminated_karts++; } // eliminateKart
/** Remove (eliminate) a kart from the race */ void World::eliminateKart(int kart_number, bool notify_of_elimination) { AbstractKart *kart = m_karts[kart_number]; // Display a message about the eliminated kart in the race gui if (notify_of_elimination) { for (KartList::iterator i = m_karts.begin(); i != m_karts.end(); i++ ) { if(!(*i)->getCamera()) continue; if(*i==kart) { m_race_gui->addMessage(_("You have been eliminated!"), *i, 2.0f); } else { m_race_gui->addMessage(_("'%s' has been eliminated.", core::stringw(kart->getName())), *i, 2.0f); } } // for i in kart } if(kart->getController()->isPlayerController()) { // Change the camera so that it will be attached to the leader // and facing backwards. Camera* camera=kart->getCamera(); camera->setMode(Camera::CM_LEADER_MODE); m_eliminated_players++; } // The kart can't be really removed from the m_kart array, since otherwise // a race can't be restarted. So it's only marked to be eliminated (and // ignored in all loops). Important:world->getCurrentNumKarts() returns // the number of karts still racing. This value can not be used for loops // over all karts, use race_manager->getNumKarts() instead! kart->eliminate(); m_eliminated_karts++; } // eliminateKart