21 self = [super init]; |
21 self = [super init]; |
22 srandom(time(NULL)); |
22 srandom(time(NULL)); |
23 ipcPort = (random() % 64541) + 1025; |
23 ipcPort = (random() % 64541) + 1025; |
24 |
24 |
25 NSString *filePath = [[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"]; |
25 NSString *filePath = [[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"]; |
26 self.systemSettings = [[NSDictionary alloc] initWithContentsOfFile:filePath]; //should check it exists |
26 systemSettings = [[NSDictionary alloc] initWithContentsOfFile:filePath]; //should check it exists |
27 return self; |
27 return self; |
28 } |
28 } |
29 |
29 |
30 -(void) dealloc { |
30 -(void) dealloc { |
|
31 [systemSettings release]; |
31 [super dealloc]; |
32 [super dealloc]; |
32 } |
33 } |
33 |
34 |
34 #pragma mark - |
35 #pragma mark - |
35 #pragma mark Thread/Network relevant code |
36 #pragma mark Thread/Network relevant code |
247 -(const char **)getSettings { |
248 -(const char **)getSettings { |
248 const char **gameArgs = (const char**) malloc(sizeof(char*) * 6); |
249 const char **gameArgs = (const char**) malloc(sizeof(char*) * 6); |
249 NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", ipcPort]; |
250 NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", ipcPort]; |
250 NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
251 NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
251 CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
252 CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
252 NSString *wSize = [[[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width] autorelease]; |
253 NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width]; |
253 NSString *hSize = [[[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height] autorelease]; |
254 NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height]; |
254 |
255 |
255 gameArgs[0] = [[systemSettings objectForKey:@"username"] UTF8String]; //UserNick |
256 gameArgs[0] = [[systemSettings objectForKey:@"username"] UTF8String]; //UserNick |
256 gameArgs[1] = [ipcString UTF8String]; //ipcPort |
257 gameArgs[1] = [ipcString UTF8String]; //ipcPort |
257 gameArgs[2] = [[systemSettings objectForKey:@"sounds"] UTF8String]; //isSoundEnabled |
258 gameArgs[2] = [[systemSettings objectForKey:@"sounds"] UTF8String]; //isSoundEnabled |
258 gameArgs[3] = [[systemSettings objectForKey:@"music"] UTF8String]; //isMusicEnabled |
259 gameArgs[3] = [[systemSettings objectForKey:@"music"] UTF8String]; //isMusicEnabled |
259 gameArgs[4] = [localeString UTF8String]; //cLocaleFName |
260 gameArgs[4] = [localeString UTF8String]; //cLocaleFName |
260 gameArgs[5] = [[systemSettings objectForKey:@"alternate"] UTF8String]; //cAltDamage |
261 gameArgs[5] = [[systemSettings objectForKey:@"alternate"] UTF8String]; //cAltDamage |
261 gameArgs[6] = [wSize UTF8String]; |
262 gameArgs[6] = [wSize UTF8String]; //cScreenHeight |
262 gameArgs[7] = [hSize UTF8String]; |
263 gameArgs[7] = [hSize UTF8String]; //cScreenWidth |
263 |
264 |
|
265 [wSize release]; |
|
266 [hSize release]; |
264 [localeString release]; |
267 [localeString release]; |
265 [ipcString release]; |
268 [ipcString release]; |
266 return gameArgs; |
269 return gameArgs; |
267 } |
270 } |
268 |
271 |