Replace a kart in saved grand prix only if this kart exist.

We should avoid situation when for example add-on kart was uninstalled. Now when not exist, these karts are random.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14272 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
deveee 2013-10-16 12:48:31 +00:00
parent 0ce990d5ea
commit ca2a1c3671

View File

@ -19,6 +19,7 @@
#include "config/saved_grand_prix.hpp"
#include "karts/kart_properties_manager.hpp"
#include "utils/ptr_vector.hpp"
#include "utils/string_utils.hpp"
@ -145,10 +146,12 @@ void SavedGrandPrix::loadKarts(std::vector<RaceManager::KartStatus> & kart_list)
int aikarts = 0;
for(int i = 0; i < m_karts.size(); i++)
{
const KartProperties *kp = kart_properties_manager->getKart(m_karts[i].m_ident);
if(m_karts[i].m_local_player_id == -1)
{
//AI kart found
kart_list[aikarts].m_ident = m_karts[i].m_ident;
if(kp) kart_list[aikarts].m_ident = m_karts[i].m_ident;
kart_list[aikarts].m_score = m_karts[i].m_score;
kart_list[aikarts].m_overall_time = m_karts[i].m_overall_time;
aikarts++;