From aef6a4024c11e80a4c547000bd33d2c523756903 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Thu, 9 Sep 2010 03:24:34 +0000 Subject: [PATCH] Improved handling if default (i.e. previously selected) kart can not be found. Now stk will only abort if no kart at all can be found, otherwise use the first kart in the kart properties list. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5943 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/states_screens/kart_selection.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index 10ef74d55..54fcedbe5 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -301,8 +301,18 @@ public: const KartProperties* props = kart_properties_manager->getKart(default_kart); if(!props) { - fprintf(stderr, "Can't find default kart '%s' - aborting.\n", - default_kart.c_str()); + // If the default kart can't be found (e.g. previously a addon + // kart was used, but the addon package was removed, use the + // first kart as a default. This way we don't have to hardcode + // any kart names. + props = kart_properties_manager->getKartById(0); + if(!props) + { + fprintf(stderr, + "Can't find default kart '%s' nor any other kart.\n", + default_kart.c_str()); + exit(-1); + } } KartModel* kartModel = props->getKartModel();