project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m
changeset 6908 896ed2afcfb8
parent 6870 f72cac290325
child 10108 c68cf030eded
equal deleted inserted replaced
6907:a2f9a9a62dc5 6908:896ed2afcfb8
    24 
    24 
    25 @implementation EngineProtocolNetwork
    25 @implementation EngineProtocolNetwork
    26 @synthesize delegate, stream, csd, enginePort;
    26 @synthesize delegate, stream, csd, enginePort;
    27 
    27 
    28 -(id) initWithPort:(NSInteger) port {
    28 -(id) initWithPort:(NSInteger) port {
    29     if (self = [super init]) {
    29     if ((self = [super init])) {
    30         self.delegate = nil;
    30         self.delegate = nil;
    31         self.csd = NULL;
    31         self.csd = NULL;
    32         self.stream = nil;
    32         self.stream = nil;
    33         self.enginePort = port;
    33         self.enginePort = port;
    34     }
    34     }
   116     [weaponPath release];
   116     [weaponPath release];
   117 
   117 
   118     // if we're loading an older version of ammos fill the engine message with 0s
   118     // if we're loading an older version of ammos fill the engine message with 0s
   119     int diff = HW_getNumberOfWeapons() - [[ammoData objectForKey:@"ammostore_initialqt"] length];
   119     int diff = HW_getNumberOfWeapons() - [[ammoData objectForKey:@"ammostore_initialqt"] length];
   120     NSString *update = @"";
   120     NSString *update = @"";
   121     while ([update length] < diff)
   121     while ((int)[update length] < diff)
   122         update = [update stringByAppendingString:@"0"];
   122         update = [update stringByAppendingString:@"0"];
   123 
   123 
   124     NSString *ammloadt = [[NSString alloc] initWithFormat:@"eammloadt %@%@", [ammoData objectForKey:@"ammostore_initialqt"], update];
   124     NSString *ammloadt = [[NSString alloc] initWithFormat:@"eammloadt %@%@", [ammoData objectForKey:@"ammostore_initialqt"], update];
   125     [self sendToEngine: ammloadt];
   125     [self sendToEngine: ammloadt];
   126     [ammloadt release];
   126     [ammloadt release];
   168 
   168 
   169     // basic game flags
   169     // basic game flags
   170     result = [[basicArray objectAtIndex:0] intValue];
   170     result = [[basicArray objectAtIndex:0] intValue];
   171     NSArray *basic = [[NSArray alloc] initWithContentsOfFile:BASICFLAGS_FILE()];
   171     NSArray *basic = [[NSArray alloc] initWithContentsOfFile:BASICFLAGS_FILE()];
   172 
   172 
   173     for (int i = 1; i < [basicArray count]; i++) {
   173     for (NSUInteger i = 1; i < [basicArray count]; i++) {
   174         NSDictionary *dict = [basic objectAtIndex:i];
   174         NSDictionary *dict = [basic objectAtIndex:i];
   175         NSString *command = [dict objectForKey:@"command"];
   175         NSString *command = [dict objectForKey:@"command"];
   176         NSInteger value = [[basicArray objectAtIndex:i] intValue];
   176         NSInteger value = [[basicArray objectAtIndex:i] intValue];
   177         if ([[dict objectForKey:@"checkOverMax"] boolValue] && value >= [[dict objectForKey:@"max"] intValue])
   177         if ([[dict objectForKey:@"checkOverMax"] boolValue] && value >= [[dict objectForKey:@"max"] intValue])
   178             value = 9999;
   178             value = 9999;