project_files/HedgewarsMobile/Classes/otherSrc/CommodityFunctions.m
changeset 3522 156c04c6a3d8
parent 3514 59dbd31e9953
equal deleted inserted replaced
3520:c3dcb80bdb1d 3522:156c04c6a3d8
    39     NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt];
    39     NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt];
    40 
    40 
    41     [theTeam writeToFile:teamFile atomically:YES];
    41     [theTeam writeToFile:teamFile atomically:YES];
    42     [teamFile release];
    42     [teamFile release];
    43     [theTeam release];
    43     [theTeam release];
       
    44 }
       
    45 
       
    46 void createWeaponNamed (NSString *nameWithoutExt) {
       
    47     NSString *weaponsDirectory = WEAPONS_DIRECTORY();
       
    48 
       
    49     if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) {
       
    50         [[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory 
       
    51                                   withIntermediateDirectories:NO 
       
    52                                                    attributes:nil 
       
    53                                                         error:NULL];
       
    54     }
       
    55     
       
    56     NSDictionary *theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
       
    57                                @"9391929422199121032235111001201000000211190911",@"ammostore_initialqt",
       
    58                                @"0405040541600655546554464776576666666155501000",@"ammostore_probability",
       
    59                                @"0000000000000205500000040007004000000000200000",@"ammostore_delay",
       
    60                                @"1311110312111111123114111111111111111211101111",@"ammostore_crate", nil];
       
    61     
       
    62     NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt];
       
    63     
       
    64     [theWeapon writeToFile:weaponFile atomically:YES];
       
    65     [weaponFile release];
       
    66     [theWeapon release];
    44 }
    67 }
    45 
    68 
    46 void createSchemeNamed (NSString *nameWithoutExt) {
    69 void createSchemeNamed (NSString *nameWithoutExt) {
    47     NSString *schemesDirectory = SCHEMES_DIRECTORY();
    70     NSString *schemesDirectory = SCHEMES_DIRECTORY();
    48     
    71     
   126               
   149               
   127     if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS)
   150     if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS)
   128         DLog(@"Failed to fetch vm statistics");
   151         DLog(@"Failed to fetch vm statistics");
   129  
   152  
   130     /* Stats in bytes */ 
   153     /* Stats in bytes */ 
   131     natural_t mem_used = (vm_stat.active_count +
   154     natural_t mem_used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pagesize;
   132                           vm_stat.inactive_count +
       
   133                           vm_stat.wire_count) * pagesize;
       
   134     natural_t mem_free = vm_stat.free_count * pagesize;
   155     natural_t mem_free = vm_stat.free_count * pagesize;
   135     natural_t mem_total = mem_used + mem_free;
   156     natural_t mem_total = mem_used + mem_free;
   136     DLog(@"used: %u free: %u total: %u", mem_used, mem_free, mem_total);
   157     DLog(@"used: %u free: %u total: %u", mem_used, mem_free, mem_total);
   137 }
   158 }