equal
deleted
inserted
replaced
38 // should check they exist and throw and exection if not |
38 // should check they exist and throw and exection if not |
39 NSDictionary *dictSett = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()]; |
39 NSDictionary *dictSett = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()]; |
40 self.systemSettings = dictSett; |
40 self.systemSettings = dictSett; |
41 [dictSett release]; |
41 [dictSett release]; |
42 |
42 |
43 self.gameConfig = gameDictionary; |
43 self.gameConfig = [gameDictionary objectForKey:@"game_dictionary"]; |
44 self.savePath = [SAVES_DIRECTORY() stringByAppendingFormat:@"%@.hws", [[NSDate date] description]]; |
44 isNetGame = [[gameDictionary objectForKey:@"netgame"] boolValue]; |
|
45 NSString *path = [gameDictionary objectForKey:@"savefile"]; |
|
46 // if path is empty it means i have to create a new file, otherwise i read from that file |
|
47 if ([path isEqualToString:@""] == YES) |
|
48 self.savePath = [SAVES_DIRECTORY() stringByAppendingFormat:@"%@.hws", [[NSDate date] description]]; |
|
49 else |
|
50 self.savePath = [SAVES_DIRECTORY() stringByAppendingString:path]; |
45 } |
51 } |
46 return self; |
52 return self; |
47 } |
53 } |
48 |
54 |
49 -(void) dealloc { |
55 -(void) dealloc { |
303 |
309 |
304 switch (buffer[0]) { |
310 switch (buffer[0]) { |
305 case 'C': |
311 case 'C': |
306 DLog(@"sending game config...\n%@",self.gameConfig); |
312 DLog(@"sending game config...\n%@",self.gameConfig); |
307 |
313 |
308 // local game |
314 if (isNetGame == YES) |
309 [self sendToEngineNoSave:@"TL"]; |
315 [self sendToEngineNoSave:@"TN"]; |
|
316 else |
|
317 [self sendToEngineNoSave:@"TL"]; |
310 NSString *saveHeader = @"TS"; |
318 NSString *saveHeader = @"TS"; |
311 [[NSString stringWithFormat:@"%c%@",[saveHeader length], saveHeader] appendToFile:savePath]; |
319 [[NSString stringWithFormat:@"%c%@",[saveHeader length], saveHeader] appendToFile:savePath]; |
312 |
320 |
313 // seed info |
321 // seed info |
314 [self sendToEngine:[self.gameConfig objectForKey:@"seed_command"]]; |
322 [self sendToEngine:[self.gameConfig objectForKey:@"seed_command"]]; |
395 } |
403 } |
396 |
404 |
397 #pragma mark - |
405 #pragma mark - |
398 #pragma mark Setting methods |
406 #pragma mark Setting methods |
399 // returns an array of c-strings that are read by engine at startup |
407 // returns an array of c-strings that are read by engine at startup |
400 -(const char **)getSettings { |
408 -(const char **)getSettings: (NSString *)recordFile { |
401 NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", ipcPort]; |
409 NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", ipcPort]; |
402 NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
410 NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
403 CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
411 CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
404 NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width]; |
412 NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width]; |
405 NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height]; |
413 NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height]; |
436 gameArgs[ 5] = [username UTF8String]; //UserNick |
444 gameArgs[ 5] = [username UTF8String]; //UserNick |
437 gameArgs[ 6] = [[[self.systemSettings objectForKey:@"sound"] stringValue] UTF8String]; //isSoundEnabled |
445 gameArgs[ 6] = [[[self.systemSettings objectForKey:@"sound"] stringValue] UTF8String]; //isSoundEnabled |
438 gameArgs[ 7] = [[[self.systemSettings objectForKey:@"music"] stringValue] UTF8String]; //isMusicEnabled |
446 gameArgs[ 7] = [[[self.systemSettings objectForKey:@"music"] stringValue] UTF8String]; //isMusicEnabled |
439 gameArgs[ 8] = [[[self.systemSettings objectForKey:@"alternate"] stringValue] UTF8String]; //cAltDamage |
447 gameArgs[ 8] = [[[self.systemSettings objectForKey:@"alternate"] stringValue] UTF8String]; //cAltDamage |
440 gameArgs[ 9] = NULL; //unused |
448 gameArgs[ 9] = NULL; //unused |
441 gameArgs[10] = NULL; //recordFileName |
449 gameArgs[10] = [recordFile UTF8String]; //recordFileName |
442 //[[SAVES_DIRECTORY() stringByAppendingString:@"/2010-09-21 23/30/10 +0200.hws"] UTF8String]; //recordFileName |
|
443 |
450 |
444 [wSize release]; |
451 [wSize release]; |
445 [hSize release]; |
452 [hSize release]; |
446 [localeString release]; |
453 [localeString release]; |
447 [ipcString release]; |
454 [ipcString release]; |