# HG changeset patch
# User antonc27 <antonc27@mail.ru>
# Date 1445651762 -7200
# Node ID a954853e9c00b4b52636d42bb8bf7e58eef0f1d5
# Parent  e529b597f9d1f3a50e17f6e660531754deeae438
- Fix for loading non-existing missions in MissionTrainingViewController

diff -r e529b597f9d1 -r a954853e9c00 project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m
--- a/project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m	Sat Oct 24 02:26:54 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/MissionTrainingViewController.m	Sat Oct 24 03:56:02 2015 +0200
@@ -135,6 +135,13 @@
             NSUInteger firstDotLocation = [line rangeOfString:@"."].location;
             
             NSString *missionID = [line substringToIndex:firstDotLocation];
+            
+            NSString *missionFullPath = [NSString stringWithFormat:@"%@%@.lua", TRAININGS_DIRECTORY(), missionID];
+            if (![[NSFileManager defaultManager] fileExistsAtPath:missionFullPath])
+            {
+                continue;
+            }
+            
             NSString *nameOrDesc = [line substringFromIndex:firstDotLocation+1];
             
             NSString *missionParsedName = ([nameOrDesc hasPrefix:@"name="]) ? [nameOrDesc stringByReplacingOccurrencesOfString:@"name=" withString:@""] : nil;