Tolerate mismatching number of levels in the score file
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Thu, 24 Feb 2011 18:11:22 +0000 (18:11 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Thu, 24 Feb 2011 18:11:22 +0000 (18:11 +0000)
git-svn-id: https://s.snth.net/svn/neverball/trunk@3509 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/set.c

index f641724..56f309a 100644 (file)
@@ -147,13 +147,12 @@ static void set_load_hs(void)
     {
         char states[MAXLVL + 2];
 
-        if (fs_gets(states, sizeof (states), fp) &&
-            strlen(states) - 1 == s->count)
+        if (fs_gets(states, sizeof (states), fp))
         {
             struct level *l;
-            int i;
+            int i, n = MIN(strlen(states) - 1, s->count);
 
-            for (i = 0; i < s->count; i++)
+            for (i = 0; i < n; i++)
             {
                 l = &level_v[i];
 
@@ -164,7 +163,7 @@ static void set_load_hs(void)
             get_score(fp, &s->time_score);
             get_score(fp, &s->coin_score);
 
-            for (i = 0; i < s->count; i++)
+            for (i = 0; i < n; i++)
             {
                 l = &level_v[i];