8 |
8 |
9 #import "GameSetup.h" |
9 #import "GameSetup.h" |
10 #import "SDL_uikitappdelegate.h" |
10 #import "SDL_uikitappdelegate.h" |
11 #import "SDL_net.h" |
11 #import "SDL_net.h" |
12 #import "PascalImports.h" |
12 #import "PascalImports.h" |
|
13 #include <sys/types.h> |
|
14 #include <sys/sysctl.h> |
13 |
15 |
14 #define BUFFER_SIZE 256 |
16 #define BUFFER_SIZE 256 |
15 |
17 |
16 @implementation GameSetup |
18 @implementation GameSetup |
17 |
19 |
244 } |
246 } |
245 |
247 |
246 #pragma mark - |
248 #pragma mark - |
247 #pragma mark Setting methods |
249 #pragma mark Setting methods |
248 -(const char **)getSettings { |
250 -(const char **)getSettings { |
249 const char **gameArgs = (const char**) malloc(sizeof(char*) * 6); |
|
250 NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", ipcPort]; |
251 NSString *ipcString = [[NSString alloc] initWithFormat:@"%d", ipcPort]; |
251 NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
252 NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]]; |
252 CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
253 CGRect screenBounds = [[UIScreen mainScreen] bounds]; |
253 NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width]; |
254 NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width]; |
254 NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height]; |
255 NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height]; |
|
256 const char **gameArgs = (const char**) malloc(sizeof(char*) * 8); |
|
257 |
|
258 /* |
|
259 size_t size; |
|
260 // Set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space |
|
261 sysctlbyname("hw.machine", NULL, &size, NULL, 0); |
|
262 char *name = malloc(size); |
|
263 // Get the platform name |
|
264 sysctlbyname("hw.machine", name, &size, NULL, 0); |
|
265 NSString *machine = [[NSString alloc] initWithUTF8String:name]; |
|
266 free(name); |
|
267 |
|
268 const char **gameArgs = (const char**) malloc(sizeof(char*) * 9); |
|
269 |
|
270 // if the machine is less than iphone 3gs or less than ipod touch 3g use reduced graphics (land array) |
|
271 if ([machine hasPrefix:@"iPhone1"] || ([machine hasPrefix:@"iPod"] && ([machine hasSuffix:@"1,1"] || [machine hasSuffix:@"2,1"]))) |
|
272 gameArgs[8] = "1"; |
|
273 else |
|
274 gameArgs[8] = "0"; |
|
275 [machine release]; |
|
276 */ |
255 |
277 |
256 gameArgs[0] = [[systemSettings objectForKey:@"username"] UTF8String]; //UserNick |
278 gameArgs[0] = [[systemSettings objectForKey:@"username"] UTF8String]; //UserNick |
257 gameArgs[1] = [ipcString UTF8String]; //ipcPort |
279 gameArgs[1] = [ipcString UTF8String]; //ipcPort |
258 gameArgs[2] = [[systemSettings objectForKey:@"sounds"] UTF8String]; //isSoundEnabled |
280 gameArgs[2] = [[systemSettings objectForKey:@"sounds"] UTF8String]; //isSoundEnabled |
259 gameArgs[3] = [[systemSettings objectForKey:@"music"] UTF8String]; //isMusicEnabled |
281 gameArgs[3] = [[systemSettings objectForKey:@"music"] UTF8String]; //isMusicEnabled |