project_files/HedgewarsMobile/Classes/FortsViewController.m
branchios-revival
changeset 11184 e03bb95edf44
parent 11148 064a53861759
child 12872 00215a7ec5f5
--- a/project_files/HedgewarsMobile/Classes/FortsViewController.m	Fri Sep 18 05:37:55 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/FortsViewController.m	Fri Sep 18 06:03:49 2015 +0200
@@ -38,11 +38,13 @@
 
     NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:FORTS_DIRECTORY() error:NULL];
     NSMutableArray *filteredContents = [[NSMutableArray alloc] initWithCapacity:([directoryContents count] / IMGNUM_PER_FORT)];
-    // we need to remove the double entries and the L.png suffix
-    for (NSUInteger i = 0; i < [directoryContents count]; i++) {
-        if (i % IMGNUM_PER_FORT == IMGNUM_PER_FORT-1) {
-            NSString *currentName = [directoryContents objectAtIndex:i];
-            NSString *correctName = [currentName substringToIndex:([currentName length] - 5)];
+    // we assume here that fort's images has one image with the 'L.png' suffix and we remove this suffix to get the correct name
+    for (NSUInteger i = 0; i < [directoryContents count]; i++)
+    {
+        NSString *currentName = [directoryContents objectAtIndex:i];
+        if ([currentName rangeOfString:@"L.png"].location != NSNotFound)
+        {
+            NSString *correctName = [currentName stringByReplacingOccurrencesOfString:@"L.png" withString:@""];
             [filteredContents addObject:correctName];
         }
     }