project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m
changeset 5185 7607a64e1853
parent 5181 102fef5ca5fc
child 5370 a3f87be7b09a
equal deleted inserted replaced
5184:bf7bba60ed93 5185:7607a64e1853
   171     NSArray *basicArray = [schemeDictionary objectForKey:@"basic"];
   171     NSArray *basicArray = [schemeDictionary objectForKey:@"basic"];
   172     NSArray *gamemodArray = [schemeDictionary objectForKey:@"gamemod"];
   172     NSArray *gamemodArray = [schemeDictionary objectForKey:@"gamemod"];
   173     int result = 0;
   173     int result = 0;
   174     int mask = 0x00000004;
   174     int mask = 0x00000004;
   175 
   175 
   176     // pack the gameflags in a single var and send it
   176     // pack the game modifiers in a single var and send it
   177     for (NSNumber *value in gamemodArray) {
   177     for (NSNumber *value in gamemodArray) {
   178         if ([value boolValue] == YES)
   178         if ([value boolValue] == YES)
   179             result |= mask;
   179             result |= mask;
   180         mask <<= 1;
   180         mask <<= 1;
   181     }
   181     }
   182     NSString *flags = [[NSString alloc] initWithFormat:@"e$gmflags %d",result];
   182     NSString *flags = [[NSString alloc] initWithFormat:@"e$gmflags %d",result];
   183     [self sendToEngine:flags];
   183     [self sendToEngine:flags];
   184     [flags release];
   184     [flags release];
   185 
   185 
   186     // game modifiers
   186     // basic game flags
   187     NSString *path = [[NSString alloc] initWithFormat:@"%@/basicFlags_en.plist",IFRONTEND_DIRECTORY()];
       
   188     NSArray *mods = [[NSArray alloc] initWithContentsOfFile:path];
       
   189     [path release];
       
   190 
       
   191     result = [[basicArray objectAtIndex:0] intValue];
   187     result = [[basicArray objectAtIndex:0] intValue];
       
   188     NSArray *basic = [[NSArray alloc] initWithContentsOfFile:BASICFLAGS_FILE()];
   192 
   189 
   193     for (int i = 1; i < [basicArray count]; i++) {
   190     for (int i = 1; i < [basicArray count]; i++) {
   194         NSDictionary *dict = [mods objectAtIndex:i];
   191         NSDictionary *dict = [basic objectAtIndex:i];
   195         NSString *command = [dict objectForKey:@"command"];
   192         NSString *command = [dict objectForKey:@"command"];
   196         NSInteger value = [[basicArray objectAtIndex:i] intValue];
   193         NSInteger value = [[basicArray objectAtIndex:i] intValue];
   197         if ([[dict objectForKey:@"checkOverMax"] boolValue] && value >= [[dict objectForKey:@"max"] intValue])
   194         if ([[dict objectForKey:@"checkOverMax"] boolValue] && value >= [[dict objectForKey:@"max"] intValue])
   198             value = 9999;
   195             value = 9999;
   199         if ([[dict objectForKey:@"times1000"] boolValue])
   196         if ([[dict objectForKey:@"times1000"] boolValue])
   200             value = value * 1000;
   197             value = value * 1000;
   201         NSString *strToSend = [[NSString alloc] initWithFormat:@"%@ %d",command,value];
   198         NSString *strToSend = [[NSString alloc] initWithFormat:@"%@ %d",command,value];
   202         [self sendToEngine:strToSend];
   199         [self sendToEngine:strToSend];
   203         [strToSend release];
   200         [strToSend release];
   204     }
   201     }
   205     [mods release];
   202     [basic release];
   206 
   203 
   207     [schemeDictionary release];
   204     [schemeDictionary release];
   208     return result;
   205     return result;
   209 }
   206 }
   210 
   207