96 // unpacks ammostore data from the selected ammo.plist to a sequence of engine commands |
96 // unpacks ammostore data from the selected ammo.plist to a sequence of engine commands |
97 -(void) provideAmmoData:(NSString *)ammostoreName forPlayingTeams:(NSInteger) numberOfTeams { |
97 -(void) provideAmmoData:(NSString *)ammostoreName forPlayingTeams:(NSInteger) numberOfTeams { |
98 NSString *weaponPath = [[NSString alloc] initWithFormat:@"%@/%@",WEAPONS_DIRECTORY(),ammostoreName]; |
98 NSString *weaponPath = [[NSString alloc] initWithFormat:@"%@/%@",WEAPONS_DIRECTORY(),ammostoreName]; |
99 NSDictionary *ammoData = [[NSDictionary alloc] initWithContentsOfFile:weaponPath]; |
99 NSDictionary *ammoData = [[NSDictionary alloc] initWithContentsOfFile:weaponPath]; |
100 [weaponPath release]; |
100 [weaponPath release]; |
101 |
101 NSString *update = @""; |
102 NSString *ammloadt = [[NSString alloc] initWithFormat:@"eammloadt %@", [ammoData objectForKey:@"ammostore_initialqt"]]; |
102 |
|
103 // if we're loading an older version of ammos fill the engine message with 0s |
|
104 int diff = CURRENT_AMMOSIZE - [[ammoData objectForKey:@"version"] intValue]; |
|
105 if (diff != 0) |
|
106 update = [NSString stringWithCharacters:(const unichar*)"0000000000000000000000000000000000" length:diff]; |
|
107 |
|
108 NSString *ammloadt = [[NSString alloc] initWithFormat:@"eammloadt %@%@", [ammoData objectForKey:@"ammostore_initialqt"], update]; |
103 [self sendToEngine: ammloadt]; |
109 [self sendToEngine: ammloadt]; |
104 [ammloadt release]; |
110 [ammloadt release]; |
105 |
111 |
106 NSString *ammprob = [[NSString alloc] initWithFormat:@"eammprob %@", [ammoData objectForKey:@"ammostore_probability"]]; |
112 NSString *ammprob = [[NSString alloc] initWithFormat:@"eammprob %@%@", [ammoData objectForKey:@"ammostore_probability"], update]; |
107 [self sendToEngine: ammprob]; |
113 [self sendToEngine: ammprob]; |
108 [ammprob release]; |
114 [ammprob release]; |
109 |
115 |
110 NSString *ammdelay = [[NSString alloc] initWithFormat:@"eammdelay %@", [ammoData objectForKey:@"ammostore_delay"]]; |
116 NSString *ammdelay = [[NSString alloc] initWithFormat:@"eammdelay %@%@", [ammoData objectForKey:@"ammostore_delay"], update]; |
111 [self sendToEngine: ammdelay]; |
117 [self sendToEngine: ammdelay]; |
112 [ammdelay release]; |
118 [ammdelay release]; |
113 |
119 |
114 NSString *ammreinf = [[NSString alloc] initWithFormat:@"eammreinf %@", [ammoData objectForKey:@"ammostore_crate"]]; |
120 NSString *ammreinf = [[NSString alloc] initWithFormat:@"eammreinf %@%@", [ammoData objectForKey:@"ammostore_crate"], update]; |
115 [self sendToEngine: ammreinf]; |
121 [self sendToEngine: ammreinf]; |
116 [ammreinf release]; |
122 [ammreinf release]; |
117 |
123 |
118 // sent twice so it applies to both teams |
124 // sent twice so it applies to both teams |
119 NSString *ammstore = [[NSString alloc] initWithString:@"eammstore"]; |
125 NSString *ammstore = [[NSString alloc] initWithString:@"eammstore"]; |