From 324a93cd65701b55d1ac4202bd2cc33c2ccfa6a8 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Fri, 24 Jul 2015 02:10:23 +0200 Subject: [PATCH] Fix karts without a type --- src/karts/abstract_kart.cpp | 9 +++++++-- src/karts/kart_properties.cpp | 13 +++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index 4e803c00e..f158e0858 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -66,8 +66,13 @@ AbstractKart::AbstractKart(const std::string& ident, m_characteristic->addCharacteristic(kart_properties_manager-> getDifficultyCharacteristic(race_manager->getDifficultyAsString( race_manager->getDifficulty()))); - m_characteristic->addCharacteristic(kart_properties_manager-> - getKartTypeCharacteristic(m_kart_properties->getKartType())); + + // Try to get the kart type + const AbstractCharacteristic *characteristic = kart_properties_manager-> + getKartTypeCharacteristic(m_kart_properties->getKartType()); + if (characteristic) + m_characteristic->addCharacteristic(characteristic); + m_characteristic->addCharacteristic(kart_properties_manager-> getPlayerCharacteristic(KartProperties::getPerPlayerDifficultyAsString( m_difficulty))); diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index e9e298f49..ebc91162f 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -312,8 +312,17 @@ void KartProperties::combineCharacteristics() m_combined_characteristic = new CombinedCharacteristic(); m_combined_characteristic->addCharacteristic(kart_properties_manager-> getBaseCharacteristic()); - m_combined_characteristic->addCharacteristic(kart_properties_manager-> - getKartTypeCharacteristic(m_kart_type)); + + // Try to get the kart type + const AbstractCharacteristic *characteristic = kart_properties_manager-> + getKartTypeCharacteristic(m_kart_type); + if (!characteristic) + Log::warn("KartProperties", "Can't find kart type '%s' for kart '%s'", + m_kart_type.c_str(), m_name.c_str()); + else + // Kart type found + m_combined_characteristic->addCharacteristic(characteristic); + m_combined_characteristic->addCharacteristic(m_characteristic); } // combineCharacteristics