cocoaTouch/GameSetup.m
changeset 2698 90585aba87ad
parent 2697 75880595a9f1
child 2699 249adefa9c1c
equal deleted inserted replaced
2697:75880595a9f1 2698:90585aba87ad
    20 -(id) init {
    20 -(id) init {
    21 	self = [super init];
    21 	self = [super init];
    22 	self.localeString = [[[NSLocale currentLocale] localeIdentifier] stringByAppendingString:@".txt"];
    22 	self.localeString = [[[NSLocale currentLocale] localeIdentifier] stringByAppendingString:@".txt"];
    23 	self.systemSettings = nil;
    23 	self.systemSettings = nil;
    24 	engineProtocolStarted = NO;
    24 	engineProtocolStarted = NO;
    25 	ipcPort = 51342;
    25 	ipcPort = 51432;
    26 	return self;
    26 	return self;
    27 }
    27 }
    28 
    28 
    29 -(void) dealloc {
    29 -(void) dealloc {
    30 	if (systemSettings) [self.systemSettings release];
    30 	if (systemSettings) [self.systemSettings release];
    98 			
    98 			
    99 			if ('C' == buffer[0]) {
    99 			if ('C' == buffer[0]) {
   100 				NSLog(@"engineProtocol - sending game config");
   100 				NSLog(@"engineProtocol - sending game config");
   101 				
   101 				
   102 				// send config data data
   102 				// send config data data
   103 				
   103 				/*seed is arbitrary string
   104 				// local game
   104 				[16:12] unC0Rr:
       
   105 				addteam <color> <team name>
       
   106 				[16:13] unC0Rr:
       
   107 				addhh <level> <health> <hedgehog name>
       
   108 				[16:13] unC0Rr:
       
   109 				<level> is 0 for human, 1-5 for bots (5 is the most stupid)*/				// local game
   105 				[self sendToEngine:@"TL"];
   110 				[self sendToEngine:@"TL"];
   106 				
   111 				
   107 				// seed info
   112 				// seed info
   108 				[self sendToEngine:@"eseed {232c1b42-7d39-4ee6-adf8-4240e1f1efb8}"];
   113 				[self sendToEngine:@"eseed {232c1b42-7d39-4ee6-adf8-4240e1f1efb8}"];
   109 				
   114 				
   126 				[self sendToEngine:@"e$sd_turns 15"];
   131 				[self sendToEngine:@"e$sd_turns 15"];
   127 												
   132 												
   128 				// various flags
   133 				// various flags
   129 				[self sendToEngine:@"e$casefreq 5"];
   134 				[self sendToEngine:@"e$casefreq 5"];
   130 				
   135 				
   131 				// various flags
   136 				// dimension of the map
   132 				[self sendToEngine:@"e$template_filter 1"];
   137 				[self sendToEngine:@"e$template_filter 1"];
   133 								
   138 								
   134 				// theme info
   139 				// theme info
   135 				[self sendToEngine:@"etheme Freeway"];
   140 				[self sendToEngine:@"etheme Freeway"];
   136 				
   141 				
   246 }
   251 }
   247 
   252 
   248 #pragma mark -
   253 #pragma mark -
   249 #pragma mark Settings setup methods
   254 #pragma mark Settings setup methods
   250 -(void) loadSettingsFromFile:(NSString *)fileName forKey:(NSString *)objName {
   255 -(void) loadSettingsFromFile:(NSString *)fileName forKey:(NSString *)objName {
   251 	NSString *filePath = [SDLUIKitDelegate dataFilePath:fileName];
   256 	NSString *filePath = [[SDLUIKitDelegate sharedAppDelegate] dataFilePath:fileName];
   252 	
   257 	
   253 	if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {	
   258 	if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {	
   254 		NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:filePath];
   259 		NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:filePath];
   255 		[self setValue:dict forKey:objName];
   260 		[self setValue:dict forKey:objName];
   256 		[dict release];
   261 		[dict release];
   260 	}
   265 	}
   261 
   266 
   262 }
   267 }
   263 
   268 
   264 -(void) unloadSettings {
   269 -(void) unloadSettings {
   265 	[systemSettings dealloc];
   270 	[systemSettings release];
   266 }
   271 }
   267 
       
   268 -(void) setArgsForLocalPlay {
       
   269 	NSString *portNumber = [[NSString alloc] initWithFormat:@"%d", ipcPort];
       
   270 	//NSString *username = [[NSString alloc] initWithString:[systemSettings objectForKey:@"username"]];
       
   271 	/*for (NSString *theString in [NSLocale ISOLanguageCodes]) {
       
   272 		NSLog(theString);
       
   273 	}*/
       
   274 	
       
   275 	memset(forward_argv, 0, forward_argc);
       
   276 	
       
   277 	forward_argc = 18;
       
   278 	forward_argv = (char **)realloc(forward_argv, forward_argc * sizeof(char *));
       
   279 	//forward_argv[i] = malloc( (strlen(argv[i])+1) * sizeof(char));
       
   280 	forward_argv[ 1] = forward_argv[0];					// (UNUSED)
       
   281 	forward_argv[ 2] = "320";							// cScreenWidth
       
   282 	forward_argv[ 3] = "480";							// cScreenHeight
       
   283 	forward_argv[ 4] = "16";							// cBitsStr
       
   284 	forward_argv[ 5] = [portNumber UTF8String];			// ipcPort;
       
   285 	forward_argv[ 6] = "1";								// cFullScreen (NO EFFECT)
       
   286 	forward_argv[ 7] = [[systemSettings objectForKey:@"effects"] UTF8String];	// isSoundEnabled
       
   287 	forward_argv[ 8] = "1";								// cVSyncInUse (UNUSED)
       
   288 	forward_argv[ 9] = [localeString UTF8String];		// cLocaleFName
       
   289 	forward_argv[10] = [[systemSettings objectForKey:@"volume"] UTF8String];	// cInitVolume
       
   290 	forward_argv[11] = "8";								// cTimerInterval
       
   291 	forward_argv[12] = "Data";							// PathPrefix
       
   292 	forward_argv[13] = "1";								// cShowFPS (TOSET?)
       
   293 	forward_argv[14] = [[systemSettings objectForKey:@"alternate"] UTF8String];	// cAltDamage (TOSET)
       
   294 	forward_argv[15] = "Koda";				// UserNick (DecodeBase64(ParamStr(15)) FTW) <- TODO
       
   295 	forward_argv[16] = [[systemSettings objectForKey:@"music"] UTF8String];		// isMusicEnabled
       
   296 	forward_argv[17] = "0";								// cReducedQuality
       
   297 
       
   298 	[portNumber release];
       
   299 	return;
       
   300 }
       
   301 
       
   302 
       
   303 
       
   304 
       
   305 
   272 
   306 
   273 
   307 @end
   274 @end