project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
changeset 5696 972bf04d4a79
parent 5664 dfc574d7f49e
child 5709 36cf87a4f6ae
equal deleted inserted replaced
5695:f1015857deb8 5696:972bf04d4a79
    43     }
    43     }
    44     return self;
    44     return self;
    45 }
    45 }
    46 
    46 
    47 -(void) dealloc {
    47 -(void) dealloc {
    48     releaseAndNil(parentController);
       
    49     releaseAndNil(engineProtocol);
    48     releaseAndNil(engineProtocol);
    50     releaseAndNil(savePath);
    49     releaseAndNil(savePath);
    51     releaseAndNil(overlayController);
    50     releaseAndNil(overlayController);
    52     [super dealloc];
    51     [super dealloc];
    53 }
    52 }
   176     [self.overlayController removeOverlay];
   175     [self.overlayController removeOverlay];
   177 
   176 
   178     // warn our host that it's going to be visible again
   177     // warn our host that it's going to be visible again
   179     [self.parentController viewWillAppear:YES];
   178     [self.parentController viewWillAppear:YES];
   180 
   179 
   181     // release the network manager and the savepath as they are not needed anymore
       
   182     releaseAndNil(self.engineProtocol);
       
   183     releaseAndNil(self.savePath);
       
   184 
       
   185     if ([[userDefaults objectForKey:@"music"] boolValue])
   180     if ([[userDefaults objectForKey:@"music"] boolValue])
   186         [HedgewarsAppDelegate playBackgroundMusic];
   181         [HedgewarsAppDelegate playBackgroundMusic];
   187 }
   182 }
   188 
   183 
   189 // set up variables for a local game
   184 // set up variables for a local game
   190 -(void) startLocalGame:(NSDictionary *)withDictionary {
   185 -(void) startLocalGame:(NSDictionary *)withDictionary {
   191     self.gameType = gtLocal;
   186     self.gameType = gtLocal;
   192 
   187 
   193     NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
   188     NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
   194     [outputFormatter setDateFormat:@"yyyy-MM-dd '@' HH.mm"];
   189     [outputFormatter setDateFormat:@"yyyy-MM-dd '@' HH.mm"];
   195     self.savePath = [[NSString alloc] initWithFormat:@"%@%@.hws",SAVES_DIRECTORY(),[outputFormatter stringFromDate:[NSDate date]]];
   190     NSString *path = [[NSString alloc] initWithFormat:@"%@%@.hws",SAVES_DIRECTORY(),[outputFormatter stringFromDate:[NSDate date]]];
   196     [outputFormatter release];
   191     [outputFormatter release];
       
   192     self.savePath = path;
       
   193     [path release];
   197 
   194 
   198     // in the rare case in which a savefile with the same name exists the older one must be removed (or it gets corrupted)
   195     // in the rare case in which a savefile with the same name exists the older one must be removed (or it gets corrupted)
   199     if ([[NSFileManager defaultManager] fileExistsAtPath:self.savePath])
   196     if ([[NSFileManager defaultManager] fileExistsAtPath:self.savePath])
   200         [[NSFileManager defaultManager] removeItemAtPath:self.savePath error:nil];
   197         [[NSFileManager defaultManager] removeItemAtPath:self.savePath error:nil];
   201 
   198 
   204 }
   201 }
   205 
   202 
   206 // set up variables for a save game
   203 // set up variables for a save game
   207 -(void) startSaveGame:(NSString *)atPath {
   204 -(void) startSaveGame:(NSString *)atPath {
   208     self.gameType = gtSave;
   205     self.gameType = gtSave;
   209     self.savePath = [atPath retain];
   206     self.savePath = atPath;
   210 
   207 
   211     [self.engineProtocol spawnThread:self.savePath];
   208     [self.engineProtocol spawnThread:self.savePath];
   212     [self prepareEngineLaunch];
   209     [self prepareEngineLaunch];
   213 }
   210 }
   214 
   211