author | koda |
Sat, 28 Aug 2010 05:03:26 +0200 | |
changeset 3781 | 2bfda544ae48 |
parent 3778 | 2e61bb50cc57 |
child 3783 | 8e9daf967406 |
permissions | -rw-r--r-- |
3547 | 1 |
// |
2 |
// CommodityFunctions.m |
|
3 |
// HedgewarsMobile |
|
4 |
// |
|
5 |
// Created by Vittorio on 08/04/10. |
|
6 |
// Copyright 2010 __MyCompanyName__. All rights reserved. |
|
7 |
// |
|
8 |
||
9 |
#import "CommodityFunctions.h" |
|
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
10 |
#import <sys/types.h> |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
11 |
#import <sys/sysctl.h> |
3547 | 12 |
#import <mach/mach.h> |
13 |
#import <mach/mach_host.h> |
|
14 |
||
15 |
void createTeamNamed (NSString *nameWithoutExt) { |
|
16 |
NSString *teamsDirectory = TEAMS_DIRECTORY(); |
|
3697 | 17 |
|
3547 | 18 |
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) { |
3697 | 19 |
[[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory |
20 |
withIntermediateDirectories:NO |
|
21 |
attributes:nil |
|
3547 | 22 |
error:NULL]; |
23 |
} |
|
3697 | 24 |
|
3547 | 25 |
NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: MAX_HOGS]; |
3697 | 26 |
|
3547 | 27 |
for (int i = 0; i < MAX_HOGS; i++) { |
28 |
NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i]; |
|
29 |
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:0],@"level", |
|
30 |
hogName,@"hogname", @"NoHat",@"hat", nil]; |
|
31 |
[hogName release]; |
|
32 |
[hedgehogs addObject:hog]; |
|
33 |
[hog release]; |
|
34 |
} |
|
3697 | 35 |
|
3660 | 36 |
NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:@"0",@"hash", |
3547 | 37 |
@"Statue",@"grave", @"Plane",@"fort", @"Default",@"voicepack", |
38 |
@"hedgewars",@"flag", hedgehogs,@"hedgehogs", nil]; |
|
39 |
[hedgehogs release]; |
|
3697 | 40 |
|
3547 | 41 |
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt]; |
42 |
||
43 |
[theTeam writeToFile:teamFile atomically:YES]; |
|
44 |
[teamFile release]; |
|
45 |
[theTeam release]; |
|
46 |
} |
|
47 |
||
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
48 |
void createWeaponNamed (NSString *nameWithoutExt, int type) { |
3547 | 49 |
NSString *weaponsDirectory = WEAPONS_DIRECTORY(); |
50 |
||
51 |
if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) { |
|
3697 | 52 |
[[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory |
53 |
withIntermediateDirectories:NO |
|
54 |
attributes:nil |
|
3547 | 55 |
error:NULL]; |
56 |
} |
|
3697 | 57 |
|
3778 | 58 |
NSDictionary *theWeapon = nil; |
3737
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
59 |
switch (type) { |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
60 |
case 0: //default |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
61 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
62 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
63 |
@"939192942219912103223511100120100000021111011101",@"ammostore_initialqt", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
64 |
@"040504054160065554655446477657666666615551011111",@"ammostore_probability", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
65 |
@"000000000000020550000004000700400000000020000000",@"ammostore_delay", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
66 |
@"131111031211111112311411111111111111121111111111",@"ammostore_crate", nil]; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
67 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
68 |
case 1: //crazy |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
69 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
70 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
71 |
@"999999999999999999299999999999999929999999999999",@"ammostore_initialqt", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
72 |
@"111111011111111111111111111111111111111111111111",@"ammostore_probability", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
73 |
@"000000000000000000000000000000000000000000000000",@"ammostore_delay", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
74 |
@"131111031211111112311411111111111111121111010111",@"ammostore_crate", nil]; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
75 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
76 |
case 2: //pro mode |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
77 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
78 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
79 |
@"909000900000000000000900000000000000000000090000",@"ammostore_initialqt", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
80 |
@"000000000000000000000000000000000000000000000000",@"ammostore_probability", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
81 |
@"000000000000020550000004000700400000000020000000",@"ammostore_delay", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
82 |
@"111111111111111111111111111111111111111110011111",@"ammostore_crate", nil]; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
83 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
84 |
case 3: //shoppa |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
85 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
86 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
87 |
@"000000990000000000000000000000000000000000000000",@"ammostore_initialqt", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
88 |
@"444441004424440221011212122242200000000200040001",@"ammostore_probability", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
89 |
@"000000000000000000000000000000000000000000000000",@"ammostore_delay", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
90 |
@"111111111111111111111111111111111111111110111111",@"ammostore_crate", nil]; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
91 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
92 |
case 4: //basketball |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
93 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
94 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
95 |
@"939192942219912103223511100120100000021111011100",@"ammostore_initialqt", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
96 |
@"000000000000000000000000000000000000000000000000",@"ammostore_probability", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
97 |
@"000000000000000550000004000700400000000020000000",@"ammostore_delay", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
98 |
@"111111111111111111111111111111111111111111111111",@"ammostore_crate", nil]; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
99 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
100 |
case 5: //minefield |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
101 |
theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys: |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
102 |
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
103 |
@"000000990009000000030000000000000000000000000000",@"ammostore_initialqt", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
104 |
@"000000000000000000000000000000000000000000000000",@"ammostore_probability", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
105 |
@"000000000000020550000004000700400000000020000000",@"ammostore_delay", |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
106 |
@"111111111111111111111111111111111111111111111111",@"ammostore_crate", nil]; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
107 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
108 |
default: |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
109 |
NSLog(@"Nope"); |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
110 |
break; |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
111 |
} |
2ba6ac8a114b
reworked the initialization functions, now it should be safe to update and no more need of spinning wheel at first launch
koda
parents:
3697
diff
changeset
|
112 |
|
3547 | 113 |
NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt]; |
3697 | 114 |
|
3547 | 115 |
[theWeapon writeToFile:weaponFile atomically:YES]; |
116 |
[weaponFile release]; |
|
117 |
[theWeapon release]; |
|
118 |
} |
|
119 |
||
120 |
void createSchemeNamed (NSString *nameWithoutExt) { |
|
121 |
NSString *schemesDirectory = SCHEMES_DIRECTORY(); |
|
3697 | 122 |
|
3547 | 123 |
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) { |
3697 | 124 |
[[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory |
125 |
withIntermediateDirectories:NO |
|
126 |
attributes:nil |
|
3547 | 127 |
error:NULL]; |
128 |
} |
|
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
129 |
|
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
130 |
NSMutableArray *basicArray = [[NSMutableArray alloc] initWithObjects: |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
131 |
[NSNumber numberWithInt:100], //damagemodifier |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
132 |
[NSNumber numberWithInt:45], //turntime |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
133 |
[NSNumber numberWithInt:100], //initialhealth |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
134 |
[NSNumber numberWithInt:15], //suddendeathtimeout |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
135 |
[NSNumber numberWithInt:5], //cratedrops |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
136 |
[NSNumber numberWithInt:3], //minestime |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
137 |
[NSNumber numberWithInt:4], //mines |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
138 |
[NSNumber numberWithInt:0], //dudmines |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
139 |
[NSNumber numberWithInt:2], //explosives |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
140 |
nil]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
141 |
|
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
142 |
NSMutableArray *gamemodArray= [[NSMutableArray alloc] initWithObjects: |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
143 |
[NSNumber numberWithBool:NO], //fortmode |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
144 |
[NSNumber numberWithBool:NO], //divideteam |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
145 |
[NSNumber numberWithBool:NO], //solidland |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
146 |
[NSNumber numberWithBool:NO], //addborder |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
147 |
[NSNumber numberWithBool:NO], //lowgravity |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
148 |
[NSNumber numberWithBool:NO], //lasersight |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
149 |
[NSNumber numberWithBool:NO], //invulnerable |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
150 |
[NSNumber numberWithBool:YES], //addmines |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
151 |
[NSNumber numberWithBool:NO], //vampirism |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
152 |
[NSNumber numberWithBool:NO], //karma |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
153 |
[NSNumber numberWithBool:NO], //artillery |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
154 |
[NSNumber numberWithBool:YES], //randomorder |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
155 |
[NSNumber numberWithBool:NO], //king |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
156 |
[NSNumber numberWithBool:NO], //placehedgehogs |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
157 |
[NSNumber numberWithBool:NO], //clansharesammo |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
158 |
[NSNumber numberWithBool:NO], //disablegirders |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
159 |
[NSNumber numberWithBool:NO], //disablelandobjects |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
160 |
[NSNumber numberWithBool:NO], //aisurvival |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
161 |
nil]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
162 |
|
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
163 |
NSMutableDictionary *theScheme = [[NSMutableDictionary alloc] initWithObjectsAndKeys: |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
164 |
basicArray,@"basic", |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
165 |
gamemodArray,@"gamemod", |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
166 |
nil]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
167 |
[gamemodArray release]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
168 |
[basicArray release]; |
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
169 |
|
3547 | 170 |
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt]; |
3781
2bfda544ae48
modified file format for schemes files (which is going to introduce a lot of pre-release bugs, i'm sure)
koda
parents:
3778
diff
changeset
|
171 |
|
3547 | 172 |
[theScheme writeToFile:schemeFile atomically:YES]; |
173 |
[schemeFile release]; |
|
174 |
[theScheme release]; |
|
175 |
} |
|
176 |
||
177 |
BOOL rotationManager (UIInterfaceOrientation interfaceOrientation) { |
|
3551 | 178 |
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || |
3697 | 179 |
(interfaceOrientation == UIInterfaceOrientationLandscapeLeft); |
3547 | 180 |
} |
181 |
||
182 |
NSInteger randomPort () { |
|
183 |
srandom(time(NULL)); |
|
184 |
return (random() % 64511) + 1024; |
|
185 |
} |
|
186 |
||
187 |
void popError (const char *title, const char *message) { |
|
188 |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:title] |
|
189 |
message:[NSString stringWithUTF8String:message] |
|
190 |
delegate:nil |
|
191 |
cancelButtonTitle:@"Ok" |
|
192 |
otherButtonTitles:nil]; |
|
193 |
[alert show]; |
|
194 |
[alert release]; |
|
195 |
} |
|
196 |
||
197 |
// by http://landonf.bikemonkey.org/code/iphone/Determining_Available_Memory.20081203.html |
|
198 |
void print_free_memory () { |
|
199 |
mach_port_t host_port; |
|
200 |
mach_msg_type_number_t host_size; |
|
201 |
vm_size_t pagesize; |
|
3697 | 202 |
|
3547 | 203 |
host_port = mach_host_self(); |
204 |
host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); |
|
3697 | 205 |
host_page_size(host_port, &pagesize); |
206 |
||
3547 | 207 |
vm_statistics_data_t vm_stat; |
3697 | 208 |
|
3547 | 209 |
if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) |
210 |
DLog(@"Failed to fetch vm statistics"); |
|
3697 | 211 |
|
212 |
/* Stats in bytes */ |
|
3547 | 213 |
natural_t mem_used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pagesize; |
214 |
natural_t mem_free = vm_stat.free_count * pagesize; |
|
215 |
natural_t mem_total = mem_used + mem_free; |
|
216 |
DLog(@"used: %u free: %u total: %u", mem_used, mem_free, mem_total); |
|
217 |
} |
|
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3660
diff
changeset
|
218 |
|
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
219 |
BOOL isPhone () { |
3668
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3660
diff
changeset
|
220 |
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone); |
3f7a95234d8a
tap to play piano notes, fix for audio and pause glitch
koda
parents:
3660
diff
changeset
|
221 |
} |
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
222 |
|
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
223 |
NSString *modelType () { |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
224 |
size_t size; |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
225 |
// set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space |
3697 | 226 |
sysctlbyname("hw.machine", NULL, &size, NULL, 0); |
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
227 |
char *name = (char *)malloc(sizeof(char) * size); |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
228 |
// get the platform name |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
229 |
sysctlbyname("hw.machine", name, &size, NULL, 0); |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
230 |
NSString *modelId = [NSString stringWithUTF8String:name]; |
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
231 |
free(name); |
3697 | 232 |
|
3670
4c673e57f0d7
use llvm to compile, don't preview map on wimpier devices, merge vsync, fix iphone launch image
koda
parents:
3668
diff
changeset
|
233 |
return modelId; |
3697 | 234 |
} |