project_files/HedgewarsMobile/Classes/GameSetup.m
changeset 3616 85d69ddb41b6
parent 3613 cfd3c6536a09
child 3617 1df21e06b8ba
equal deleted inserted replaced
3615:b78d7959540a 3616:85d69ddb41b6
    19 
    19 
    20 @implementation GameSetup
    20 @implementation GameSetup
    21 
    21 
    22 @synthesize systemSettings, gameConfig;
    22 @synthesize systemSettings, gameConfig;
    23 
    23 
    24 -(id) init {
    24 -(id) initWithDictionary:(NSDictionary *)gameDictionary {
    25     if (self = [super init]) {
    25     if (self = [super init]) {
    26         ipcPort = randomPort();
    26         ipcPort = randomPort();
    27         
    27         
    28         // should check they exist and throw and exection if not
    28         // should check they exist and throw and exection if not
    29         NSDictionary *dictSett = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
    29         NSDictionary *dictSett = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
    30         self.systemSettings = dictSett;
    30         self.systemSettings = dictSett;
    31         [dictSett release];
    31         [dictSett release];
    32         
    32         
    33         NSDictionary *dictGame = [[NSDictionary alloc] initWithContentsOfFile:GAMECONFIG_FILE()];
    33         self.gameConfig = gameDictionary;
    34         self.gameConfig = dictGame;
       
    35         [dictGame release];
       
    36     } 
    34     } 
    37     return self;
    35     return self;
    38 }
    36 }
    39 
    37 
    40 -(void) dealloc {
    38 -(void) dealloc {
   334                         break;
   332                         break;
   335                 }
   333                 }
   336                 break;
   334                 break;
   337             default:
   335             default:
   338                 // empty packet or just statistics -- in either cases gameTicks is sent
   336                 // empty packet or just statistics -- in either cases gameTicks is sent
   339                 //gameTicks = SDLNet_Read16 (&buffer[msgSize - 2]);
   337                 gameTicks = SDLNet_Read16 (&buffer[msgSize - 2]);
   340                 //DLog(@"engineProtocol - %d: received [%s]", gameTicks, buffer);
   338                 //DLog(@"engineProtocol - %d: received [%s]", gameTicks, buffer);
   341                 break;
   339                 break;
   342         }
   340         }
   343     }
   341     }
   344     DLog(@"Engine exited, closing server");
   342     DLog(@"Engine exited, closing server");
   345     // wait a little to let the client close cleanly
   343     // wait a little to let the client close cleanly
   346     [NSThread sleepForTimeInterval:2];
   344     [NSThread sleepForTimeInterval:2];
   347     // Close the client socket
   345     // Close the client socket
   348     SDLNet_TCP_Close(csd);    
   346     SDLNet_TCP_Close(csd);    
   349     SDLNet_Quit();
   347     SDLNet_Quit();
   350     
   348         
   351     [[NSFileManager defaultManager] removeItemAtPath:GAMECONFIG_FILE() error:NULL];
       
   352     
       
   353     [pool release];
   349     [pool release];
   354     //Invoking this method should be avoided as it does not give your thread a chance to clean up any resources it allocated during its execution.
   350     //Invoking this method should be avoided as it does not give your thread a chance to clean up any resources it allocated during its execution.
   355     //[NSThread exit];
   351     //[NSThread exit];
   356 }
   352 }
   357 
   353