wow all these files only for land preview and seed generation
authorkoda
Sun, 25 Apr 2010 02:30:42 +0000
changeset 3365 37ac593e9027
parent 3364 e5403e2bf02c
child 3366 f0e5ff24fb72
wow all these files only for land preview and seed generation
cocoaTouch/GameConfigViewController.h
cocoaTouch/GameConfigViewController.m
cocoaTouch/GameSetup.h
cocoaTouch/GameSetup.m
cocoaTouch/MapConfigViewController.h
cocoaTouch/MapConfigViewController.m
cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m
cocoaTouch/SingleTeamViewController.m
cocoaTouch/SplitViewRootController.m
cocoaTouch/TeamConfigViewController.m
cocoaTouch/otherSrc/CommodityFunctions.h
cocoaTouch/otherSrc/CommodityFunctions.m
cocoaTouch/otherSrc/PascalImports.h
cocoaTouch/xib/GameConfigViewController-iPhone.xib
cocoaTouch/xib/MapConfigViewController-iPhone.xib
hedgewars/hwengine.pas
hedgewars/uLand.pas
hedgewars/uMisc.pas
project_files/HedgewarsMobile/HedgewarsMobile.xcodeproj/project.pbxproj
--- a/cocoaTouch/GameConfigViewController.h	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/GameConfigViewController.h	Sun Apr 25 02:30:42 2010 +0000
@@ -9,6 +9,7 @@
 #import <UIKit/UIKit.h>
 
 @class TeamConfigViewController;
+@class MapConfigViewController;
 
 @interface GameConfigViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
     UITableView *availableTeamsTableView;
@@ -19,6 +20,7 @@
     UIBarButtonItem *startButton;
     
     UIViewController *activeController;
+    MapConfigViewController *mapConfigViewController;
     TeamConfigViewController *teamConfigViewController;
 }
 
@@ -30,5 +32,7 @@
 @property (nonatomic,retain) IBOutlet UIBarButtonItem *startButton;
 
 -(IBAction) buttonPressed:(id) sender;
+-(IBAction) segmentPressed:(id) sender;
 -(void) startGame;
+
 @end
--- a/cocoaTouch/GameConfigViewController.m	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/GameConfigViewController.m	Sun Apr 25 02:30:42 2010 +0000
@@ -9,6 +9,7 @@
 #import "GameConfigViewController.h"
 #import "SDL_uikitappdelegate.h"
 #import "CommodityFunctions.h"
+#import "MapConfigViewController.h"
 #import "TeamConfigViewController.h"
 
 @implementation GameConfigViewController
@@ -24,41 +25,98 @@
     UIButton *theButton = (UIButton *)sender;
     switch (theButton.tag) {
         case 0:
-            [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
+            [[self parentViewController] dismissModalViewControllerAnimated:YES];
             break;
         case 1:
             [self performSelector:@selector(startGame)
                        withObject:nil
                        afterDelay:0.25];
             break;
+
     }
 }
 
+-(IBAction) segmentPressed:(id) sender {
+    UISegmentedControl *theSegment = (UISegmentedControl *)sender;
+    NSLog(@"%d", theSegment.selectedSegmentIndex);
+    switch (theSegment.selectedSegmentIndex) {
+        case 0:
+            // this init here is just aestetic as this controller was already set up in viewDidLoad
+            if (mapConfigViewController == nil) {
+                mapConfigViewController = [[MapConfigViewController alloc] initWithNibName:@"MapConfigViewController-iPhone" bundle:nil];
+                [mapConfigViewController viewWillAppear:NO];  
+            }
+            activeController = mapConfigViewController;
+            break;
+        case 1:
+            if (teamConfigViewController == nil) {
+                teamConfigViewController = [[TeamConfigViewController alloc] initWithStyle:UITableViewStyleGrouped];
+                // this message is compulsory otherwise the team table won't be loaded at all
+                [teamConfigViewController viewWillAppear:NO];  
+            }
+            activeController = teamConfigViewController;
+            break;
+        case 2:
+            
+            break;
+    }
+    
+    [self.view addSubview:activeController.view];
+}
+
 -(void) startGame {
+    // play only if there is more than one team
     if ([teamConfigViewController.listOfSelectedTeams count] < 2) {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too few teams playing",@"")
-                                                        message:NSLocalizedString(@"You need to select at least two teams to play a Game",@"")
+                                                        message:NSLocalizedString(@"You need to select at least two teams to play a game",@"")
                                                        delegate:nil
                                               cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"")
                                               otherButtonTitles:nil];
         [alert show];
         [alert release];
-    } else {
-        [teamConfigViewController.listOfSelectedTeams writeToFile:GAMECONFIG_FILE() atomically:YES];
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
-        [[SDLUIKitDelegate sharedAppDelegate] startSDLgame];
+        return;
     }
+    
+    // play if there's room for enough hogs in the selected map
+    int hogs = 0;
+    for (NSDictionary *teamData in teamConfigViewController.listOfSelectedTeams)
+        hogs += [[teamData objectForKey:@"number"] intValue];
+
+    if (hogs > mapConfigViewController.maxHogs) {
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many hogs",@"")
+                                                        message:NSLocalizedString(@"The map you selected is too small for that many hogs",@"")
+                                                       delegate:nil
+                                              cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"")
+                                              otherButtonTitles:nil];
+        [alert show];
+        [alert release];
+        return;
+    } 
+    NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:mapConfigViewController.seedCommand,@"seed_command",
+                                                                      teamConfigViewController.listOfSelectedTeams,@"teams_list",nil];
+    [dict writeToFile:GAMECONFIG_FILE() atomically:YES];
+    [dict release];
+    [[self parentViewController] dismissModalViewControllerAnimated:YES];
+    [[SDLUIKitDelegate sharedAppDelegate] startSDLgame];
 }
 
 -(void) viewDidLoad {
-    teamConfigViewController = [[TeamConfigViewController alloc] initWithStyle:UITableViewStyleGrouped];
-    activeController = teamConfigViewController;
+    mapConfigViewController = [[MapConfigViewController alloc] initWithNibName:@"MapConfigViewController-iPhone" bundle:nil];
+    activeController = mapConfigViewController;
     
-    [self.view insertSubview:teamConfigViewController.view atIndex:0];
+    [self.view insertSubview:mapConfigViewController.view atIndex:0];
     
     [super viewDidLoad];
 }
 
+-(void) viewWillAppear:(BOOL)animated {
+    [mapConfigViewController viewWillAppear:animated];
+    [teamConfigViewController viewWillAppear:animated];
+    // ADD other controllers here
+     
+    [super viewWillAppear:animated];
+}
+
 -(void) didReceiveMemoryWarning {
     // Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];
@@ -67,7 +125,9 @@
 
 
 -(void) viewDidUnload {
+    NSLog(@"unloading");
     activeController = nil;
+    mapConfigViewController = nil;
     teamConfigViewController = nil;
     self.availableTeamsTableView = nil;
     self.weaponsButton = nil;
@@ -81,6 +141,7 @@
 
 -(void) dealloc {
     [activeController release];
+    [mapConfigViewController release];
     [teamConfigViewController release];
     [availableTeamsTableView release];
     [weaponsButton release];
@@ -91,24 +152,4 @@
     [super dealloc];
 }
 
--(void) viewWillAppear:(BOOL)animated {
-    [super viewWillAppear:animated];
-    [activeController viewWillAppear:animated];
-}
-
--(void) viewWillDisappear:(BOOL)animated {
-    [super viewWillDisappear:animated];
-    [activeController viewWillDisappear:animated];
-}
-
--(void) viewDidAppear:(BOOL)animated {
-    [super viewDidLoad];
-    [activeController viewDidAppear:animated];
-}
-
--(void) viewDidDisappear:(BOOL)animated {
-    [super viewDidUnload];
-    [activeController viewDidDisappear:animated];
-}
-
 @end
--- a/cocoaTouch/GameSetup.h	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/GameSetup.h	Sun Apr 25 02:30:42 2010 +0000
@@ -11,14 +11,14 @@
 
 @interface GameSetup : NSObject {
 	NSDictionary *systemSettings;
-    NSArray *teamsConfig;
+    NSDictionary *gameConfig;
     
 	NSInteger ipcPort;
 	TCPsocket sd, csd; // Socket descriptor, Client socket descriptor
 }
 
 @property (nonatomic, retain) NSDictionary *systemSettings;
-@property (nonatomic, retain) NSArray *teamsConfig;
+@property (nonatomic, retain) NSDictionary *gameConfig;
 
 -(void) engineProtocol;
 -(void) startThread: (NSString *)selector;
--- a/cocoaTouch/GameSetup.m	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/GameSetup.m	Sun Apr 25 02:30:42 2010 +0000
@@ -20,25 +20,30 @@
 
 @implementation GameSetup
 
-@synthesize systemSettings, teamsConfig;
+@synthesize systemSettings, gameConfig;
 
 -(id) init {
 	if (self = [super init]) {
     	srandom(time(NULL));
-        ipcPort = (random() % 64541) + 1025;
+        ipcPort = randomPort();
         
-        self.systemSettings = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()]; //should check it exists
-        self.teamsConfig = [[NSArray alloc] initWithContentsOfFile:GAMECONFIG_FILE()];
+        NSDictionary *dictSett = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()]; //should check it exists
+        self.systemSettings = dictSett;
+        [dictSett release];
+        
+        NSDictionary *dictGame = [[NSDictionary alloc] initWithContentsOfFile:GAMECONFIG_FILE()];
+        self.gameConfig = dictGame;
+        [dictGame release];
     } 
     return self;
 }
 
 -(NSString *)description {
-    return [NSString stringWithFormat:@"ipcport: %d\nsockets: %d,%d\n teams: %@\n systemSettings: %@",ipcPort,sd,csd,teamsConfig,systemSettings];
+    return [NSString stringWithFormat:@"ipcport: %d\nsockets: %d,%d\n teams: %@\n systemSettings: %@",ipcPort,sd,csd,gameConfig,systemSettings];
 }
 
 -(void) dealloc {
-    [teamsConfig release];
+    [gameConfig release];
     [systemSettings release];
 	[super dealloc];
 }
@@ -130,26 +135,27 @@
 	char buffer[BUFFER_SIZE], string[BUFFER_SIZE];
 	Uint8 msgSize;
 	Uint16 gameTicks;
-	
+
+    serverQuit = NO;
+
 	if (SDLNet_Init() < 0) {
 		NSLog(@"SDLNet_Init: %s", SDLNet_GetError());
-		exit(EXIT_FAILURE);
+        serverQuit = YES;
 	}
 	
 	/* Resolving the host using NULL make network interface to listen */
 	if (SDLNet_ResolveHost(&ip, NULL, ipcPort) < 0) {
 		NSLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError());
-		exit(EXIT_FAILURE);
+        serverQuit = YES;
 	}
 	
 	/* Open a connection with the IP provided (listen on the host's port) */
 	if (!(sd = SDLNet_TCP_Open(&ip))) {
 		NSLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), ipcPort);
-		exit(EXIT_FAILURE);
+        serverQuit = YES;
 	}
 	
 	NSLog(@"engineProtocol - Waiting for a client on port %d", ipcPort);
-	serverQuit = NO;
 	while (!serverQuit) {
 		
 		/* This check the sd if there is a pending connection.
@@ -175,13 +181,12 @@
 				addteam <32charsMD5hash> <color> <team name>
 				addhh <level> <health> <hedgehog name>
 				  <level> is 0 for human, 1-5 for bots (5 is the most stupid)
-				ammostore is one byte/number for each ammocount then one for each probability or so
 				*/
 				// local game
 				[self sendToEngine:@"TL"];
 				
 				// seed info
-				[self sendToEngine:@"eseed {232c1b42-7d39-4ee6-adf8-4240e1f1efb8}"];
+				[self sendToEngine:[self.gameConfig objectForKey:@"seed_command"]];
 				
 				// various flags
 				[self sendToEngine:@"e$gmflags 256"]; 
@@ -198,7 +203,8 @@
 				// theme info
 				[self sendToEngine:@"etheme Compost"];
 				
-                for (NSDictionary *teamData in self.teamsConfig) {
+                NSArray *teamsConfig = [self.gameConfig objectForKey:@"teams_list"];
+                for (NSDictionary *teamData in teamsConfig) {
                     [self sendTeamData:[teamData objectForKey:@"team"] 
                        withPlayingHogs:[[teamData objectForKey:@"number"] intValue]
                                ofColor:[teamData objectForKey:@"color"]];
@@ -210,7 +216,7 @@
                                           @"0405040541600655546554464776576666666155501",@"ammostore_probability",
                                           @"0000000000000205500000040007004000000000200",@"ammostore_delay",
                                           @"1311110312111111123114111111111111111211101",@"ammostore_crate", nil];
-                [self sendAmmoData:ammoData forTeams:[self.teamsConfig count]];
+                [self sendAmmoData:ammoData forTeams:[teamsConfig count]];
                 [ammoData release];
                 
                 clientQuit = NO;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/MapConfigViewController.h	Sun Apr 25 02:30:42 2010 +0000
@@ -0,0 +1,28 @@
+//
+//  MapConfigViewController.h
+//  HedgewarsMobile
+//
+//  Created by Vittorio on 22/04/10.
+//  Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "SDL_net.h"
+
+@interface MapConfigViewController : UIViewController {
+    TCPsocket sd, csd;
+    NSInteger maxHogs;
+    unsigned char map[128*32];
+
+    UIButton *previewButton;
+    NSString *seedCommand;
+}
+
+@property (nonatomic) NSInteger maxHogs;
+@property (nonatomic,retain) UIButton *previewButton;
+@property (nonatomic,retain) NSString *seedCommand;
+
+-(IBAction) updatePreview;
+-(void) engineProtocol:(NSInteger) port;
+
+@end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/MapConfigViewController.m	Sun Apr 25 02:30:42 2010 +0000
@@ -0,0 +1,189 @@
+//
+//  MapConfigViewController.m
+//  HedgewarsMobile
+//
+//  Created by Vittorio on 22/04/10.
+//  Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import "MapConfigViewController.h"
+#import "PascalImports.h"
+#import "CommodityFunctions.h"
+#import "UIImageExtra.h"
+#import "SDL_net.h"
+#import <pthread.h>
+
+@implementation MapConfigViewController
+@synthesize previewButton, maxHogs, seedCommand;
+
+
+-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+    return rotationManager(interfaceOrientation);
+}
+
+#pragma mark -
+#pragma mark Preview Handling
+-(int) sendToEngine: (NSString *)string {
+	unsigned char length = [string length];
+	
+	SDLNet_TCP_Send(csd, &length , 1);
+	return SDLNet_TCP_Send(csd, [string UTF8String], length);
+}
+
+-(void) engineProtocol:(NSInteger) port {
+	IPaddress ip;
+	BOOL clientQuit, serverQuit;
+
+    serverQuit = NO;
+    clientQuit =NO;
+	if (SDLNet_Init() < 0) {
+		NSLog(@"SDLNet_Init: %s", SDLNet_GetError());
+        serverQuit = YES;
+	}
+	
+	/* Resolving the host using NULL make network interface to listen */
+	if (SDLNet_ResolveHost(&ip, NULL, port) < 0) {
+		NSLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError());
+        serverQuit = YES;
+	}
+	
+	/* Open a connection with the IP provided (listen on the host's port) */
+	if (!(sd = SDLNet_TCP_Open(&ip))) {
+		NSLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), port);
+        serverQuit = YES;
+	}
+	
+	NSLog(@"engineProtocol - Waiting for a client on port %d", port);
+	while (!serverQuit) {
+		/* This check the sd if there is a pending connection.
+		 * If there is one, accept that, and open a new socket for communicating */
+		csd = SDLNet_TCP_Accept(sd);
+		if (NULL != csd) {			
+			NSLog(@"engineProtocol - Client found");
+            
+            [self sendToEngine:self.seedCommand];
+            [self sendToEngine:@"e$template_filter 1"];
+            [self sendToEngine:@"e$mapgen 0"];
+            [self sendToEngine:@"e$maze_size 1"];
+            [self sendToEngine:@"!"];
+                
+            memset(map, 0, 128*32);
+            SDLNet_TCP_Recv(csd, map, 128*32);
+            SDLNet_TCP_Recv(csd, &maxHogs, sizeof(Uint8));
+
+			SDLNet_TCP_Close(csd);
+			serverQuit = YES;
+		}
+	}
+	
+	SDLNet_TCP_Close(sd);
+	SDLNet_Quit();
+}
+
+
+-(void) updatePreview {
+    pthread_t thread_id;
+    
+    // generate a seed
+    char randomStr[36];
+    for (int i = 0; i<36; i++) {
+         randomStr[i] = random()%255;
+    }
+    NSString *seedCmd = [[NSString alloc] initWithFormat:@"eseed {%s}", randomStr];
+    self.seedCommand = seedCmd;
+    [seedCmd release];
+    
+    // select the port for IPC
+    int port = randomPort();
+    pthread_create(&thread_id, NULL, (void *)GenLandPreview, (void *)port);
+    [self engineProtocol:port];
+
+    // draw the buffer (1 pixel per component, 0= transparent 1= color)
+    int xc = 0;
+    int yc = 0;
+    UIGraphicsBeginImageContext(CGSizeMake(256,128));      
+    CGContextRef context = UIGraphicsGetCurrentContext();       
+    UIGraphicsPushContext(context);  
+    for (int x = 0; x < 32*128; x++) {
+        unsigned char byte = map[x];
+        for (int z = 0; z < 8; z++) {
+            // select the color
+            if ((byte & 0x00000001) != 0)
+                CGContextSetRGBFillColor(context, 0.5, 0.5, 0.7, 1.0);
+            else
+                CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 0.0);
+            
+            // draw pixel
+            CGContextFillRect(context,CGRectMake(xc,yc,1,1));
+            // move coordinates
+            xc = (xc+1)%256;
+            if (xc == 0) yc++;
+            
+            // shift to next bit
+            byte = byte >> 1;
+        }
+    }
+    UIGraphicsPopContext();
+    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
+    UIGraphicsEndImageContext();
+
+    /*
+    CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray();
+    CGContextRef bitmapImage = CGBitmapContextCreate(mapExp, 128, 32, 8, 128, colorspace, kCGImageAlphaNone);
+    CGColorSpaceRelease(colorspace);
+    
+    CGImageRef previewCGImage = CGBitmapContextCreateImage(bitmapImage);
+    UIImage *previewImage = [[UIImage alloc] initWithCGImage:previewCGImage];
+    CGImageRelease(previewCGImage);
+    */
+    
+    // set the image in the button
+    [self.previewButton setImage:image forState:UIControlStateNormal];
+}
+
+#pragma mark -
+#pragma mark view management
+-(void) viewDidLoad {
+    srandom(time(NULL));
+    [super viewDidLoad];
+
+    CGSize screenSize = [[UIScreen mainScreen] bounds].size;
+    self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
+    
+    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
+    button.frame = CGRectMake(32, 32, 256, 128);
+    [button addTarget:self action:@selector(updatePreview) forControlEvents:UIControlEventTouchUpInside];
+    self.previewButton = button;
+    [button release];
+    [self.view addSubview:self.previewButton];
+}
+
+-(void) viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
+    [self updatePreview];
+}
+
+-(void) didReceiveMemoryWarning {
+    // Releases the view if it doesn't have a superview.
+    [super didReceiveMemoryWarning];
+    // Release any cached data, images, etc that aren't in use.
+}
+
+#pragma mark -
+#pragma mark memory
+-(void) viewDidUnload {
+    self.previewButton = nil;
+    self.seedCommand = nil;
+    [super viewDidUnload];
+    // Release any retained subviews of the main view.
+    // e.g. self.myOutlet = nil;
+}
+
+-(void) dealloc {
+    [previewButton release];
+    [seedCommand release];
+    [super dealloc];
+}
+
+
+@end
--- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Sun Apr 25 02:30:42 2010 +0000
@@ -123,7 +123,7 @@
 	[uiwindow addSubview:viewController.view];
 	
 	// Set working directory to resource path
-	[[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
+	[[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] resourcePath]];
 
 	[uiwindow makeKeyAndVisible];
 	[uiwindow layoutSubviews];
--- a/cocoaTouch/SingleTeamViewController.m	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/SingleTeamViewController.m	Sun Apr 25 02:30:42 2010 +0000
@@ -342,7 +342,7 @@
 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     NSInteger row = [indexPath row];
     NSInteger section = [indexPath section];
-    UITableViewController *nextController;
+    UITableViewController *nextController = nil;
     UITableViewCell *cell;
     
     if (2 == section) {
--- a/cocoaTouch/SplitViewRootController.m	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/SplitViewRootController.m	Sun Apr 25 02:30:42 2010 +0000
@@ -64,7 +64,6 @@
         [self.view addSubview:detailedNavController.view];
     }
 
-
     [super viewDidLoad];
 }
          
--- a/cocoaTouch/TeamConfigViewController.m	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/TeamConfigViewController.m	Sun Apr 25 02:30:42 2010 +0000
@@ -27,7 +27,6 @@
     self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
 }
 
-
 -(void) viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
 
@@ -50,7 +49,6 @@
     [emptyArray release];
 
     [self.tableView reloadData];
-    NSLog(@"%@",listOfTeams);
 }
 
 /*
@@ -69,7 +67,6 @@
 }
 */
 
-
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     return rotationManager(interfaceOrientation);
 }
--- a/cocoaTouch/otherSrc/CommodityFunctions.h	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/otherSrc/CommodityFunctions.h	Sun Apr 25 02:30:42 2010 +0000
@@ -29,4 +29,4 @@
 
 void createTeamNamed (NSString *nameWithoutExt);
 BOOL rotationManager (UIInterfaceOrientation interfaceOrientation);
-
+NSInteger randomPort();
--- a/cocoaTouch/otherSrc/CommodityFunctions.m	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/otherSrc/CommodityFunctions.m	Sun Apr 25 02:30:42 2010 +0000
@@ -49,3 +49,9 @@
         return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
 
 }
+
+NSInteger randomPort() {
+    return (random() % 64541) + 1025;
+}
+
+
--- a/cocoaTouch/otherSrc/PascalImports.h	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/otherSrc/PascalImports.h	Sun Apr 25 02:30:42 2010 +0000
@@ -19,6 +19,7 @@
 	 */
 
 	void Game(const char *args[]);
+    void GenLandPreview();
 
 
 	void HW_versionInfo(short int*, char**);
--- a/cocoaTouch/xib/GameConfigViewController-iPhone.xib	Thu Apr 22 17:43:12 2010 +0000
+++ b/cocoaTouch/xib/GameConfigViewController-iPhone.xib	Sun Apr 25 02:30:42 2010 +0000
@@ -12,7 +12,7 @@
 		</object>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
-			<integer value="2"/>
+			<integer value="20"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
@@ -50,7 +50,7 @@
 							<object class="IBUISegmentedControl" id="563596142">
 								<reference key="NSNextResponder" ref="836721772"/>
 								<int key="NSvFlags">292</int>
-								<string key="NSFrame">{{85, 8}, {269, 30}}</string>
+								<string key="NSFrame">{{97, 8}, {245, 30}}</string>
 								<reference key="NSSuperview" ref="836721772"/>
 								<bool key="IBUIOpaque">NO</bool>
 								<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -59,9 +59,9 @@
 								<int key="IBSelectedSegmentIndex">0</int>
 								<object class="NSArray" key="IBSegmentTitles">
 									<bool key="EncodedWithXMLCoder">YES</bool>
+									<string>Map</string>
 									<string>Teams</string>
-									<string>Weapons</string>
-									<string>Schemes</string>
+									<string>Details</string>
 								</object>
 								<object class="NSMutableArray" key="IBSegmentWidths">
 									<bool key="EncodedWithXMLCoder">YES</bool>
@@ -168,6 +168,15 @@
 					</object>
 					<int key="connectionID">23</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchEventConnection" key="connection">
+						<string key="label">segmentPressed:</string>
+						<reference key="source" ref="563596142"/>
+						<reference key="destination" ref="841351856"/>
+						<int key="IBEventType">13</int>
+					</object>
+					<int key="connectionID">29</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
@@ -292,7 +301,7 @@
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">24</int>
+			<int key="maxID">29</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -301,15 +310,23 @@
 					<string key="className">GameConfigViewController</string>
 					<string key="superclassName">UIViewController</string>
 					<object class="NSMutableDictionary" key="actions">
-						<string key="NS.key.0">buttonPressed:</string>
-						<string key="NS.object.0">id</string>
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>buttonPressed:</string>
+							<string>segmentPressed:</string>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>id</string>
+							<string>id</string>
+						</object>
 					</object>
 					<object class="NSMutableDictionary" key="outlets">
 						<bool key="EncodedWithXMLCoder">YES</bool>
 						<object class="NSArray" key="dict.sortedKeys">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>availableTeamsTableView</string>
-							<string>backButton</string>
 							<string>mapButton</string>
 							<string>randomButton</string>
 							<string>schemesButton</string>
@@ -322,8 +339,7 @@
 							<string>UIButton</string>
 							<string>UIButton</string>
 							<string>UIButton</string>
-							<string>UIButton</string>
-							<string>UIButton</string>
+							<string>UIBarButtonItem</string>
 							<string>UIButton</string>
 						</object>
 					</object>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cocoaTouch/xib/MapConfigViewController-iPhone.xib	Sun Apr 25 02:30:42 2010 +0000
@@ -0,0 +1,488 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
+	<data>
+		<int key="IBDocument.SystemTarget">800</int>
+		<string key="IBDocument.SystemVersion">10D573</string>
+		<string key="IBDocument.InterfaceBuilderVersion">762</string>
+		<string key="IBDocument.AppKitVersion">1038.29</string>
+		<string key="IBDocument.HIToolboxVersion">460.00</string>
+		<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+			<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+			<string key="NS.object.0">87</string>
+		</object>
+		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+			<bool key="EncodedWithXMLCoder">YES</bool>
+			<integer value="8"/>
+		</object>
+		<object class="NSArray" key="IBDocument.PluginDependencies">
+			<bool key="EncodedWithXMLCoder">YES</bool>
+			<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+		</object>
+		<object class="NSMutableDictionary" key="IBDocument.Metadata">
+			<bool key="EncodedWithXMLCoder">YES</bool>
+			<object class="NSArray" key="dict.sortedKeys" id="0">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+			</object>
+			<object class="NSMutableArray" key="dict.values">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+			</object>
+		</object>
+		<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+			<bool key="EncodedWithXMLCoder">YES</bool>
+			<object class="IBProxyObject" id="372490531">
+				<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+				<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+			</object>
+			<object class="IBProxyObject" id="975951072">
+				<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+				<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+			</object>
+			<object class="IBUIView" id="191373211">
+				<reference key="NSNextResponder"/>
+				<int key="NSvFlags">274</int>
+				<object class="NSMutableArray" key="NSSubviews">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+					<object class="IBUIPickerView" id="450385738">
+						<reference key="NSNextResponder" ref="191373211"/>
+						<int key="NSvFlags">290</int>
+						<string key="NSFrame">{{240, 60}, {240, 216}}</string>
+						<reference key="NSSuperview" ref="191373211"/>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<bool key="IBUIShowsSelectionIndicator">YES</bool>
+					</object>
+					<object class="IBUISegmentedControl" id="88728219">
+						<reference key="NSNextResponder" ref="191373211"/>
+						<int key="NSvFlags">292</int>
+						<string key="NSFrame">{{240, 9}, {240, 44}}</string>
+						<reference key="NSSuperview" ref="191373211"/>
+						<bool key="IBUIOpaque">NO</bool>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<int key="IBNumberOfSegments">3</int>
+						<int key="IBSelectedSegmentIndex">0</int>
+						<object class="NSArray" key="IBSegmentTitles">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>Map</string>
+							<string>Random</string>
+							<string>Maze</string>
+						</object>
+						<object class="NSMutableArray" key="IBSegmentWidths">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<real value="0.0"/>
+							<real value="0.0"/>
+							<real value="0.0"/>
+						</object>
+						<object class="NSMutableArray" key="IBSegmentEnabledStates">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<boolean value="YES"/>
+							<boolean value="YES"/>
+							<boolean value="YES"/>
+						</object>
+						<object class="NSMutableArray" key="IBSegmentContentOffsets">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>{0, 0}</string>
+							<string>{0, 0}</string>
+							<string>{0, 0}</string>
+						</object>
+						<object class="NSMutableArray" key="IBSegmentImages">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<object class="NSNull" id="4"/>
+							<reference ref="4"/>
+							<reference ref="4"/>
+						</object>
+					</object>
+					<object class="IBUISlider" id="938256702">
+						<reference key="NSNextResponder" ref="191373211"/>
+						<int key="NSvFlags">292</int>
+						<string key="NSFrame">{{18.5, 234}, {150, 23}}</string>
+						<reference key="NSSuperview" ref="191373211"/>
+						<bool key="IBUIOpaque">NO</bool>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<int key="IBUIContentHorizontalAlignment">0</int>
+						<int key="IBUIContentVerticalAlignment">0</int>
+						<float key="IBUIValue">0.05000000074505806</float>
+						<float key="IBUIMaxValue">0.05000000074505806</float>
+					</object>
+				</object>
+				<string key="NSFrameSize">{480, 276}</string>
+				<reference key="NSSuperview"/>
+				<object class="NSColor" key="IBUIBackgroundColor">
+					<int key="NSColorSpace">3</int>
+					<bytes key="NSWhite">MQA</bytes>
+				</object>
+				<object class="IBUISimulatedToolbarMetrics" key="IBUISimulatedBottomBarMetrics"/>
+				<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
+					<int key="interfaceOrientation">3</int>
+				</object>
+				<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+			</object>
+		</object>
+		<object class="IBObjectContainer" key="IBDocument.Objects">
+			<object class="NSMutableArray" key="connectionRecords">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">view</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="191373211"/>
+					</object>
+					<int key="connectionID">3</int>
+				</object>
+			</object>
+			<object class="IBMutableOrderedSet" key="objectRecords">
+				<object class="NSArray" key="orderedObjects">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+					<object class="IBObjectRecord">
+						<int key="objectID">0</int>
+						<reference key="object" ref="0"/>
+						<reference key="children" ref="1000"/>
+						<nil key="parent"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">1</int>
+						<reference key="object" ref="191373211"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="88728219"/>
+							<reference ref="450385738"/>
+							<reference ref="938256702"/>
+						</object>
+						<reference key="parent" ref="0"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-1</int>
+						<reference key="object" ref="372490531"/>
+						<reference key="parent" ref="0"/>
+						<string key="objectName">File's Owner</string>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-2</int>
+						<reference key="object" ref="975951072"/>
+						<reference key="parent" ref="0"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">6</int>
+						<reference key="object" ref="450385738"/>
+						<reference key="parent" ref="191373211"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">7</int>
+						<reference key="object" ref="88728219"/>
+						<reference key="parent" ref="191373211"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">8</int>
+						<reference key="object" ref="938256702"/>
+						<reference key="parent" ref="191373211"/>
+					</object>
+				</object>
+			</object>
+			<object class="NSMutableDictionary" key="flattenedProperties">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="NSArray" key="dict.sortedKeys">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+					<string>-1.CustomClassName</string>
+					<string>-2.CustomClassName</string>
+					<string>1.IBEditorWindowLastContentRect</string>
+					<string>1.IBPluginDependency</string>
+					<string>6.IBPluginDependency</string>
+					<string>7.IBPluginDependency</string>
+					<string>8.IBPluginDependency</string>
+				</object>
+				<object class="NSMutableArray" key="dict.values">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+					<string>MapConfigViewController</string>
+					<string>UIResponder</string>
+					<string>{{556, 572}, {480, 320}}</string>
+					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				</object>
+			</object>
+			<object class="NSMutableDictionary" key="unlocalizedProperties">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<reference key="dict.sortedKeys" ref="0"/>
+				<object class="NSMutableArray" key="dict.values">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+				</object>
+			</object>
+			<nil key="activeLocalization"/>
+			<object class="NSMutableDictionary" key="localizations">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<reference key="dict.sortedKeys" ref="0"/>
+				<object class="NSMutableArray" key="dict.values">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+				</object>
+			</object>
+			<nil key="sourceID"/>
+			<int key="maxID">8</int>
+		</object>
+		<object class="IBClassDescriber" key="IBDocument.Classes">
+			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="IBPartialClassDescription">
+					<string key="className">MapConfigViewController</string>
+					<string key="superclassName">UIViewController</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBProjectSource</string>
+						<string key="minorKey">../../cocoaTouch/MapConfigViewController.h</string>
+					</object>
+				</object>
+			</object>
+			<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSError.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSNetServices.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSObject.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSPort.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSStream.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSThread.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSURL.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">Foundation.framework/Headers/NSXMLParser.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">QuartzCore.framework/Headers/CAAnimation.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">QuartzCore.framework/Headers/CALayer.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UIAccessibility.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UINibLoading.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier" id="567455553">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UIResponder.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UIControl</string>
+					<string key="superclassName">UIView</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UIControl.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UIPickerView</string>
+					<string key="superclassName">UIView</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UIPickerView.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UIResponder</string>
+					<string key="superclassName">NSObject</string>
+					<reference key="sourceIdentifier" ref="567455553"/>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UISearchBar</string>
+					<string key="superclassName">UIView</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UISearchBar.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UISearchDisplayController</string>
+					<string key="superclassName">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UISearchDisplayController.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UISegmentedControl</string>
+					<string key="superclassName">UIControl</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UISegmentedControl.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UISlider</string>
+					<string key="superclassName">UIControl</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UISlider.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UIView</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UITextField.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UIView</string>
+					<string key="superclassName">UIResponder</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UIView.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UIViewController</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UINavigationController.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UIViewController</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UIPopoverController.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UIViewController</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UISplitViewController.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UIViewController</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UITabBarController.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">UIViewController</string>
+					<string key="superclassName">UIResponder</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBFrameworkSource</string>
+						<string key="minorKey">UIKit.framework/Headers/UIViewController.h</string>
+					</object>
+				</object>
+			</object>
+		</object>
+		<int key="IBDocument.localizationMode">0</int>
+		<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
+		<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
+			<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
+			<integer value="800" key="NS.object.0"/>
+		</object>
+		<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
+			<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
+			<integer value="3000" key="NS.object.0"/>
+		</object>
+		<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+		<string key="IBDocument.LastKnownRelativeProjectPath">../project_files/HedgewarsMobile/HedgewarsMobile.xcodeproj</string>
+		<int key="IBDocument.defaultPropertyAccessControl">3</int>
+		<string key="IBCocoaTouchPluginVersion">87</string>
+	</data>
+</archive>
--- a/hedgewars/hwengine.pas	Thu Apr 22 17:43:12 2010 +0000
+++ b/hedgewars/hwengine.pas	Sun Apr 25 02:30:42 2010 +0000
@@ -324,6 +324,8 @@
 
 procedure initEverything;
 begin
+    Randomize();
+
     uConsts.initModule;
     uMisc.initModule;
     uConsole.initModule;    // MUST happen after uMisc
@@ -395,21 +397,27 @@
 end;
 
 /////////////////////////
-procedure GenLandPreview;
+procedure GenLandPreview{$IFDEF IPHONEOS}(port: LongInt){$ENDIF}; {$IFDEF HWLIBRARY}cdecl; export;{$ENDIF}
 var Preview: TPreview;
-    h: byte;
 begin
+{$IFDEF IPHONEOS}
+    initEverything();
+    WriteLnToConsole('Preview connecting on port ' + inttostr(port));
+    ipcPort:= port;
+{$ENDIF}
     InitIPC;
     IPCWaitPongEvent;
     TryDo(InitStepsFlags = cifRandomize, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
 
-    Preview:= GenPreview;
+    Preview:= GenPreview();
     WriteLnToConsole('Sending preview...');
     SendIPCRaw(@Preview, sizeof(Preview));
-    h:= MaxHedgehogs;
-    SendIPCRaw(@h, sizeof(h));
+    SendIPCRaw(@MaxHedgehogs, sizeof(byte));
     WriteLnToConsole('Preview sent, disconnect');
     CloseIPC();
+{$IFDEF IPHONEOS}
+    freeEverything();
+{$ENDIF}
 end;
 
 {$IFNDEF HWLIBRARY}
@@ -580,7 +588,6 @@
     WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
     
     GetParams();
-    Randomize();
 
     if GameType = gmtLandPreview then GenLandPreview()
     else if GameType = gmtSyntax then DisplayUsage()
--- a/hedgewars/uLand.pas	Thu Apr 22 17:43:12 2010 +0000
+++ b/hedgewars/uLand.pas	Sun Apr 25 02:30:42 2010 +0000
@@ -723,10 +723,10 @@
 
 while (tries < 5) and not found_cell do
 begin
-    if when_seen(x + dir.x, y + dir.y) = current_step then //we're seeing ourselves, try another direction
+    if when_seen(x + dir.x, y + dir.y) = current_step then //we are seeing ourselves, try another direction
     begin
         //we have already seen the target cell, decide if we should remove the wall anyway
-        //(or put a wall there if maze_inverted, but we're not doing that right now)
+        //(or put a wall there if maze_inverted, but we are not doing that right now)
         if not maze_inverted and (GetRandom(braidness) = 0) then
         //or just warn that inverted+braid+indestructible terrain != good idea
         begin
@@ -762,7 +762,7 @@
                 dir := DIR_S;
         end
     end
-    else if when_seen(x + dir.x, y + dir.y) = -1 then //cell wasn't seen yet, go there
+    else if when_seen(x + dir.x, y + dir.y) = -1 then //cell was not seen yet, go there
     begin
         case dir.y of
             -1: xwalls[x, y-1] := false;
@@ -779,7 +779,7 @@
         came_from[current_step, came_from_pos[current_step]].y := y;
         found_cell := true;
     end
-    else //we're seeing someone else, quit
+    else //we are seeing someone else, quit
     begin
         step_done[current_step] := true;
         found_cell := true;
@@ -1284,26 +1284,28 @@
 var x, y, xx, yy, t, bit: LongInt;
     Preview: TPreview;
 begin
-WriteLnToConsole('Generating preview...');
-case cMapGen of
-    0: GenBlank(EdgeTemplates[SelectTemplate]);
-    1: GenMaze;
-end;
+    WriteLnToConsole('Generating preview...');
+    case cMapGen of
+        0: GenBlank(EdgeTemplates[SelectTemplate]);
+        1: GenMaze;
+    end;
 
-for y:= 0 to 127 do
-    for x:= 0 to 31 do
+    for y:= 0 to 127 do
+        for x:= 0 to 31 do
         begin
-        Preview[y, x]:= 0;
-        for bit:= 0 to 7 do
+            Preview[y, x]:= 0;
+            for bit:= 0 to 7 do
             begin
-            t:= 0;
-            for yy:= y * (LAND_HEIGHT div 128) to y * (LAND_HEIGHT div 128) + 7 do
-                for xx:= x * (LAND_WIDTH div 32) + bit * 8 to x * (LAND_WIDTH div 32) + bit * 8 + 7 do
-                    if Land[yy, xx] <> 0 then inc(t);
-            if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit)
-            end
+                t:= 0;
+                for yy:= y * (LAND_HEIGHT div 128) to y * (LAND_HEIGHT div 128) + 7 do
+                    for xx:= x * (LAND_WIDTH div 32) + bit * 8 to x * (LAND_WIDTH div 32) + bit * 8 + 7 do
+                        if Land[yy, xx] <> 0 then inc(t);
+                if t > 8 then
+                    Preview[y, x]:= Preview[y, x] or ($80 shr bit);
+            end;
         end;
-GenPreview:= Preview
+
+    GenPreview:= Preview
 end;
 
 procedure initModule;
--- a/hedgewars/uMisc.pas	Thu Apr 22 17:43:12 2010 +0000
+++ b/hedgewars/uMisc.pas	Sun Apr 25 02:30:42 2010 +0000
@@ -661,9 +661,9 @@
 endian:= independent;
 {$ELSE}
 endian:= (((independent and $FF000000) shr 24) or
-    ((independent and $00FF0000) shr 8) or
-    ((independent and $0000FF00) shl 8) or
-    ((independent and $000000FF) shl 24))
+          ((independent and $00FF0000) shr 8) or
+          ((independent and $0000FF00) shl 8) or
+          ((independent and $000000FF) shl 24))
 {$ENDIF}
 end;
 
--- a/project_files/HedgewarsMobile/HedgewarsMobile.xcodeproj/project.pbxproj	Thu Apr 22 17:43:12 2010 +0000
+++ b/project_files/HedgewarsMobile/HedgewarsMobile.xcodeproj/project.pbxproj	Sun Apr 25 02:30:42 2010 +0000
@@ -40,6 +40,7 @@
 		61370676117B32EF004EE44A /* GameConfigViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61370674117B32EF004EE44A /* GameConfigViewController.m */; };
 		6151347E116C2803001F16D1 /* Icon-iPad.png in Resources */ = {isa = PBXBuildFile; fileRef = 6151347D116C2803001F16D1 /* Icon-iPad.png */; };
 		615134B1116C2C5F001F16D1 /* OverlayViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 615134B0116C2C5F001F16D1 /* OverlayViewController.xib */; };
+		615A92911183E31C006CA772 /* MapConfigViewController-iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 615A92901183E31C006CA772 /* MapConfigViewController-iPhone.xib */; };
 		61798816114AA34C00BA94A9 /* hwengine.pas in Sources */ = {isa = PBXBuildFile; fileRef = 617987E7114AA34C00BA94A9 /* hwengine.pas */; };
 		61798818114AA34C00BA94A9 /* hwLibrary.pas in Sources */ = {isa = PBXBuildFile; fileRef = 617987E9114AA34C00BA94A9 /* hwLibrary.pas */; };
 		6179881B114AA34C00BA94A9 /* PascalExports.pas in Sources */ = {isa = PBXBuildFile; fileRef = 617987EC114AA34C00BA94A9 /* PascalExports.pas */; };
@@ -130,6 +131,7 @@
 		61A11AE11168DC6E00359010 /* SingleTeamViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A11AE01168DC6E00359010 /* SingleTeamViewController.m */; };
 		61A11AE41168DC9400359010 /* HogHatViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A11AE31168DC9400359010 /* HogHatViewController.m */; };
 		61AA7ACA117FCC8200FDDD4D /* openalbridge_t.h in Headers */ = {isa = PBXBuildFile; fileRef = 61AA7AC9117FCC8200FDDD4D /* openalbridge_t.h */; };
+		61B22E0F1180FBF400B2FCE0 /* MapConfigViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B22E0D1180FBF400B2FCE0 /* MapConfigViewController.m */; };
 		61C325451179A336001E70B1 /* globals.h in Headers */ = {isa = PBXBuildFile; fileRef = 61C3253B1179A336001E70B1 /* globals.h */; };
 		61C325461179A336001E70B1 /* loaders.c in Sources */ = {isa = PBXBuildFile; fileRef = 61C3253C1179A336001E70B1 /* loaders.c */; };
 		61C325471179A336001E70B1 /* loaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 61C3253D1179A336001E70B1 /* loaders.h */; };
@@ -242,6 +244,7 @@
 		61370674117B32EF004EE44A /* GameConfigViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GameConfigViewController.m; path = ../../cocoaTouch/GameConfigViewController.m; sourceTree = SOURCE_ROOT; };
 		6151347D116C2803001F16D1 /* Icon-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-iPad.png"; path = "../../cocoaTouch/resources/Icon-iPad.png"; sourceTree = SOURCE_ROOT; };
 		615134B0116C2C5F001F16D1 /* OverlayViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = OverlayViewController.xib; path = ../../cocoaTouch/xib/OverlayViewController.xib; sourceTree = SOURCE_ROOT; };
+		615A92901183E31C006CA772 /* MapConfigViewController-iPhone.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "MapConfigViewController-iPhone.xib"; path = "../../cocoaTouch/xib/MapConfigViewController-iPhone.xib"; sourceTree = SOURCE_ROOT; };
 		617987E1114AA34C00BA94A9 /* CCHandlers.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = CCHandlers.inc; path = ../../hedgewars/CCHandlers.inc; sourceTree = SOURCE_ROOT; };
 		617987E4114AA34C00BA94A9 /* GSHandlers.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = GSHandlers.inc; path = ../../hedgewars/GSHandlers.inc; sourceTree = SOURCE_ROOT; };
 		617987E5114AA34C00BA94A9 /* HHHandlers.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = HHHandlers.inc; path = ../../hedgewars/HHHandlers.inc; sourceTree = SOURCE_ROOT; };
@@ -354,6 +357,8 @@
 		61A11AE21168DC9400359010 /* HogHatViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HogHatViewController.h; path = ../../cocoaTouch/HogHatViewController.h; sourceTree = SOURCE_ROOT; };
 		61A11AE31168DC9400359010 /* HogHatViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HogHatViewController.m; path = ../../cocoaTouch/HogHatViewController.m; sourceTree = SOURCE_ROOT; };
 		61AA7AC9117FCC8200FDDD4D /* openalbridge_t.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = openalbridge_t.h; path = ../../misc/openalbridge/openalbridge_t.h; sourceTree = SOURCE_ROOT; };
+		61B22E0C1180FBF400B2FCE0 /* MapConfigViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MapConfigViewController.h; path = ../../cocoaTouch/MapConfigViewController.h; sourceTree = SOURCE_ROOT; };
+		61B22E0D1180FBF400B2FCE0 /* MapConfigViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MapConfigViewController.m; path = ../../cocoaTouch/MapConfigViewController.m; sourceTree = SOURCE_ROOT; };
 		61C3251D1179A300001E70B1 /* libopenalbridge.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libopenalbridge.a; sourceTree = BUILT_PRODUCTS_DIR; };
 		61C3253B1179A336001E70B1 /* globals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = globals.h; path = ../../misc/openalbridge/globals.h; sourceTree = SOURCE_ROOT; };
 		61C3253C1179A336001E70B1 /* loaders.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = loaders.c; path = ../../misc/openalbridge/loaders.c; sourceTree = SOURCE_ROOT; };
@@ -521,6 +526,7 @@
 		6100DB1711544E8400F455E0 /* XIB */ = {
 			isa = PBXGroup;
 			children = (
+				615A92901183E31C006CA772 /* MapConfigViewController-iPhone.xib */,
 				611E127C117BACC60044B62F /* GameConfigViewController-iPad.xib */,
 				61A118C911683C7600359010 /* MainMenuViewController-iPad.xib */,
 				611E127E117BACCD0044B62F /* GameConfigViewController-iPhone.xib */,
@@ -559,6 +565,8 @@
 			children = (
 				61370673117B32EF004EE44A /* GameConfigViewController.h */,
 				61370674117B32EF004EE44A /* GameConfigViewController.m */,
+				61B22E0C1180FBF400B2FCE0 /* MapConfigViewController.h */,
+				61B22E0D1180FBF400B2FCE0 /* MapConfigViewController.m */,
 				61272422117E17CF005B90CF /* TeamConfigViewController.h */,
 				61272423117E17CF005B90CF /* TeamConfigViewController.m */,
 			);
@@ -967,6 +975,7 @@
 				611E127D117BACC60044B62F /* GameConfigViewController-iPad.xib in Resources */,
 				611E127F117BACCD0044B62F /* GameConfigViewController-iPhone.xib in Resources */,
 				611E12FF117BBBDA0044B62F /* Entitlements-Development.plist in Resources */,
+				615A92911183E31C006CA772 /* MapConfigViewController-iPhone.xib in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1086,6 +1095,7 @@
 				61272424117E17CF005B90CF /* TeamConfigViewController.m in Sources */,
 				612724D3117E28AF005B90CF /* HogButtonView.m in Sources */,
 				61CF4971117E702F00BF05B7 /* SquareButtonView.m in Sources */,
+				61B22E0F1180FBF400B2FCE0 /* MapConfigViewController.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1161,7 +1171,7 @@
 				CODE_SIGN_ENTITLEMENTS = "Entitlements-Distribution.plist";
 				CODE_SIGN_IDENTITY = "iPhone Distribution";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
-				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix -dLOWRES";
+				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix";
 				FPC_COMPILER_BINARY_DIR = /usr/local/lib/fpc/2.5.1;
 				FPC_MAIN_FILE = "$(PROJECT_DIR)/../../hedgewars/hwLibrary.pas";
 				FPC_RTL_UNITS_BASE = /usr/local/lib/fpc;
@@ -1365,7 +1375,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer: Vittorio Giovara (DC2BRETXAC)";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Vittorio Giovara (DC2BRETXAC)";
 				DEBUG_INFORMATION_FORMAT = stabs;
-				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix -dLOWRES";
+				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix";
 				FPC_COMPILER_BINARY_DIR = /usr/local/lib/fpc/2.5.1;
 				FPC_MAIN_FILE = "$(PROJECT_DIR)/../../hedgewars/hwLibrary.pas";
 				FPC_RTL_UNITS_BASE = /usr/local/lib/fpc;
@@ -1404,7 +1414,7 @@
 				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
 				CODE_SIGN_IDENTITY = "iPhone Developer: Vittorio Giovara (DC2BRETXAC)";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Vittorio Giovara (DC2BRETXAC)";
-				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix -dLOWRES";
+				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix";
 				FPC_COMPILER_BINARY_DIR = /usr/local/lib/fpc/2.5.1;
 				FPC_MAIN_FILE = "$(PROJECT_DIR)/../../hedgewars/hwLibrary.pas";
 				FPC_RTL_UNITS_BASE = /usr/local/lib/fpc;