4 // |
4 // |
5 // Created by Vittorio on 10/01/10. |
5 // Created by Vittorio on 10/01/10. |
6 // Copyright 2010 __MyCompanyName__. All rights reserved. |
6 // Copyright 2010 __MyCompanyName__. All rights reserved. |
7 // |
7 // |
8 |
8 |
|
9 #include <sys/types.h> |
|
10 #include <sys/sysctl.h> |
|
11 |
9 #import "GameSetup.h" |
12 #import "GameSetup.h" |
10 #import "SDL_uikitappdelegate.h" |
13 #import "SDL_uikitappdelegate.h" |
11 #import "SDL_net.h" |
14 #import "SDL_net.h" |
12 #import "PascalImports.h" |
15 #import "PascalImports.h" |
13 #include <sys/types.h> |
16 #import "CommodityFunctions.h" |
14 #include <sys/sysctl.h> |
|
15 |
17 |
16 #define BUFFER_SIZE 256 |
18 #define BUFFER_SIZE 256 |
17 #define debug(format, ...) CFShow([NSString stringWithFormat:format, ## __VA_ARGS__]); |
19 #define debug(format, ...) CFShow([NSString stringWithFormat:format, ## __VA_ARGS__]); |
18 |
20 |
19 @implementation GameSetup |
21 @implementation GameSetup |
326 */ |
327 */ |
327 |
328 |
328 // prevents using an empty nickname |
329 // prevents using an empty nickname |
329 NSString *username; |
330 NSString *username; |
330 NSString *originalUsername = [systemSettings objectForKey:@"username"]; |
331 NSString *originalUsername = [systemSettings objectForKey:@"username"]; |
331 if ([originalUsername isEqualToString:@""]) { |
332 if ([originalUsername length] == 0) { |
332 username = [[NSString alloc] initWithFormat:@"MobileUser-%@",ipcString]; |
333 username = [[NSString alloc] initWithFormat:@"MobileUser-%@",ipcString]; |
333 } else { |
334 } else { |
334 username = [[NSString alloc] initWithString:originalUsername]; |
335 username = [[NSString alloc] initWithString:originalUsername]; |
335 } |
336 } |
336 |
337 |
337 gameArgs[0] = [username UTF8String]; //UserNick |
338 gameArgs[0] = [username UTF8String]; //UserNick |
338 gameArgs[1] = [ipcString UTF8String]; //ipcPort |
339 gameArgs[1] = [ipcString UTF8String]; //ipcPort |
339 gameArgs[2] = [[[systemSettings objectForKey:@"sounds"] stringValue] UTF8String]; //isSoundEnabled |
340 gameArgs[2] = [[[systemSettings objectForKey:@"sound"] stringValue] UTF8String]; //isSoundEnabled |
340 gameArgs[3] = [[[systemSettings objectForKey:@"music"] stringValue] UTF8String]; //isMusicEnabled |
341 gameArgs[3] = [[[systemSettings objectForKey:@"music"] stringValue] UTF8String]; //isMusicEnabled |
341 gameArgs[4] = [localeString UTF8String]; //cLocaleFName |
342 gameArgs[4] = [localeString UTF8String]; //cLocaleFName |
342 gameArgs[5] = [[[systemSettings objectForKey:@"alternate"] stringValue] UTF8String]; //cAltDamage |
343 gameArgs[5] = [[[systemSettings objectForKey:@"alternate"] stringValue] UTF8String]; //cAltDamage |
343 gameArgs[6] = [wSize UTF8String]; //cScreenHeight |
344 gameArgs[6] = [wSize UTF8String]; //cScreenHeight |
344 gameArgs[7] = [hSize UTF8String]; //cScreenWidth |
345 gameArgs[7] = [hSize UTF8String]; //cScreenWidth |
345 |
346 |
346 [wSize release]; |
347 [wSize release]; |
347 [hSize release]; |
348 [hSize release]; |
348 [localeString release]; |
349 [localeString release]; |
349 [ipcString release]; |
350 [ipcString release]; |