91 if (listOfDescriptions == nil) { |
91 if (listOfDescriptions == nil) { |
92 NSString *descLocation = [[NSString alloc] initWithFormat:@"%@/missions_en.txt",LOCALE_DIRECTORY()]; |
92 NSString *descLocation = [[NSString alloc] initWithFormat:@"%@/missions_en.txt",LOCALE_DIRECTORY()]; |
93 NSString *descComplete = [[NSString alloc] initWithContentsOfFile:descLocation encoding:NSUTF8StringEncoding error:NULL]; |
93 NSString *descComplete = [[NSString alloc] initWithContentsOfFile:descLocation encoding:NSUTF8StringEncoding error:NULL]; |
94 [descLocation release]; |
94 [descLocation release]; |
95 NSArray *descArray = [descComplete componentsSeparatedByString:@"\n"]; |
95 NSArray *descArray = [descComplete componentsSeparatedByString:@"\n"]; |
96 NSMutableArray *filteredArray = [[NSMutableArray alloc] initWithCapacity:[descArray count]]; |
96 NSMutableArray *filteredArray = [[NSMutableArray alloc] initWithCapacity:[descArray count]/3]; |
97 [descComplete release]; |
97 [descComplete release]; |
98 // sanity check to avoid having missions and descriptions conflicts |
98 // sanity check to avoid having missions and descriptions conflicts |
99 for (int i = 0; i < [self.listOfMissions count]; i++) { |
99 for (int i = 0; i < [self.listOfMissions count]; i++) { |
100 NSString *desc = [[self.listOfMissions objectAtIndex:i] stringByDeletingPathExtension]; |
100 NSString *desc = [[self.listOfMissions objectAtIndex:i] stringByDeletingPathExtension]; |
101 for (NSString *str in descArray) |
101 for (NSString *str in descArray) |
102 if ([str hasPrefix:desc]) { |
102 if ([str hasPrefix:desc] && [str hasSuffix:@"\""]) { |
103 NSArray *descriptionText = [str componentsSeparatedByString:@"\""]; |
103 NSArray *descriptionText = [str componentsSeparatedByString:@"\""]; |
104 [filteredArray insertObject:[descriptionText objectAtIndex:1] atIndex:i]; |
104 [filteredArray insertObject:[descriptionText objectAtIndex:1] atIndex:i]; |
105 break; |
105 break; |
106 } |
106 } |
107 } |
107 } |