project_files/HedgewarsMobile/Classes/GameSetup.m
changeset 3670 4c673e57f0d7
parent 3660 bc125bea5849
child 3697 d5b30d6373fc
equal deleted inserted replaced
3668:3f7a95234d8a 3670:4c673e57f0d7
     3 //  hwengine
     3 //  hwengine
     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 
       
     9 #include <sys/types.h>
       
    10 #include <sys/sysctl.h>
       
    11 
     8 
    12 #import "GameSetup.h"
     9 #import "GameSetup.h"
    13 #import "SDL_uikitappdelegate.h"
    10 #import "SDL_uikitappdelegate.h"
    14 #import "SDL_net.h"
    11 #import "SDL_net.h"
    15 #import "PascalImports.h"
    12 #import "PascalImports.h"
   372     NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width];
   369     NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width];
   373     NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height];
   370     NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height];
   374     const char **gameArgs = (const char**) malloc(sizeof(char *) * 10);
   371     const char **gameArgs = (const char**) malloc(sizeof(char *) * 10);
   375     NSInteger tmpQuality;
   372     NSInteger tmpQuality;
   376     
   373     
   377     size_t size;
   374     NSString *modelId = modelType();
   378     // Set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space
       
   379     sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
       
   380     char *name = (char *)malloc(sizeof(char) * size);
       
   381     // Get the platform name
       
   382     sysctlbyname("hw.machine", name, &size, NULL, 0);
       
   383     NSString *modelId = [[NSString alloc] initWithUTF8String:name];
       
   384     free(name);
       
   385 
       
   386     if ([modelId hasPrefix:@"iPhone1"] ||                                   // = iPhone or iPhone 3G
   375     if ([modelId hasPrefix:@"iPhone1"] ||                                   // = iPhone or iPhone 3G
   387         [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])   // = iPod Touch or iPod Touch 2G
   376         [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])   // = iPod Touch or iPod Touch 2G
   388         tmpQuality = 0x00000001 | 0x00000002 | 0x00000040;  // rqLowRes | rqBlurryLand | rqKillFlakes
   377         tmpQuality = 0x00000001 | 0x00000002 | 0x00000040;  // rqLowRes | rqBlurryLand | rqKillFlakes
   389     else if ([modelId hasPrefix:@"iPhone2"] ||                              // = iPhone 3GS
   378     else if ([modelId hasPrefix:@"iPhone2"] ||                              // = iPhone 3GS
   390              [modelId hasPrefix:@"iPod3"])                                  // = iPod Touch 3G
   379              [modelId hasPrefix:@"iPod3"])                                  // = iPod Touch 3G
   393                 tmpQuality = 0x00000002;                    // rqBlurryLand
   382                 tmpQuality = 0x00000002;                    // rqBlurryLand
   394             else                                                            // = everything else
   383             else                                                            // = everything else
   395                 tmpQuality = 0;                             // full quality
   384                 tmpQuality = 0;                             // full quality
   396     if (![modelId hasPrefix:@"iPad"])                                       // = disable tooltips unless iPad
   385     if (![modelId hasPrefix:@"iPad"])                                       // = disable tooltips unless iPad
   397         tmpQuality = tmpQuality | 0x00000400;
   386         tmpQuality = tmpQuality | 0x00000400;
   398     [modelId release];
       
   399     
   387     
   400     gameArgs[9] = [[[NSNumber numberWithInteger:tmpQuality] stringValue] UTF8String];
   388     gameArgs[9] = [[[NSNumber numberWithInteger:tmpQuality] stringValue] UTF8String];
   401 
   389 
   402     // prevents using an empty nickname
   390     // prevents using an empty nickname
   403     NSString *username;
   391     NSString *username;