a bunch of minor stuff
authorkoda
Wed, 02 Jun 2010 13:52:23 +0000
changeset 3490 016b3172b645
parent 3489 aedf289192f5
child 3491 4619b1ae99b5
a bunch of minor stuff
cocoaTouch/DetailViewController.h
cocoaTouch/DetailViewController.m
cocoaTouch/FlagsViewController.m
cocoaTouch/FortsViewController.h
cocoaTouch/FortsViewController.m
cocoaTouch/GameConfigViewController.m
cocoaTouch/GameSetup.m
cocoaTouch/GeneralSettingsViewController.m
cocoaTouch/GravesViewController.m
cocoaTouch/HogHatViewController.m
cocoaTouch/LevelViewController.m
cocoaTouch/MainMenuViewController.m
cocoaTouch/MapConfigViewController.h
cocoaTouch/MapConfigViewController.m
cocoaTouch/MasterViewController.m
cocoaTouch/OverlayViewController.h
cocoaTouch/OverlayViewController.m
cocoaTouch/PopoverMenuViewController.m
cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m
cocoaTouch/SchemeSettingsViewController.m
cocoaTouch/SingleSchemeViewController.m
cocoaTouch/SingleTeamViewController.m
cocoaTouch/SplitViewRootController.h
cocoaTouch/SplitViewRootController.m
cocoaTouch/TeamConfigViewController.m
cocoaTouch/TeamSettingsViewController.m
cocoaTouch/VoicesViewController.m
cocoaTouch/otherSrc/CommodityFunctions.h
cocoaTouch/otherSrc/CommodityFunctions.m
hedgewars/hwengine.pas
hedgewars/uStore.pas
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
--- a/cocoaTouch/DetailViewController.h	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/DetailViewController.h	Wed Jun 02 13:52:23 2010 +0000
@@ -12,23 +12,21 @@
 @class TeamSettingsViewController;
 @class WeaponSettingsViewController;
 @class SchemeSettingsViewController;
-#ifdef __IPHONE_3_2
-@interface DetailViewController : UITableViewController <UIPopoverControllerDelegate, UISplitViewControllerDelegate> {
-#else
-@interface DetailViewController : UITableViewController {
-#endif
-    id popoverController;
+
+@interface DetailViewController : UITableViewController <UISplitViewControllerDelegate, UIPopoverControllerDelegate> {
     NSArray *controllerNames;
+    
     GeneralSettingsViewController *generalSettingsViewController;
     TeamSettingsViewController *teamSettingsViewController;
     WeaponSettingsViewController *weaponSettingsViewController;
     SchemeSettingsViewController *schemeSettingsViewController;
+    UIPopoverController *popoverController;
 }
 
 // used in iphone version
 -(IBAction) dismissSplitView;
 
-@property (nonatomic, retain) id popoverController;
 @property (nonatomic, retain) NSArray *controllerNames;
+@property (nonatomic,retain) UIPopoverController *popoverController;
 
 @end
--- a/cocoaTouch/DetailViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/DetailViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -15,13 +15,17 @@
 #import "CommodityFunctions.h"
 
 @implementation DetailViewController
-@synthesize popoverController, controllerNames;
+@synthesize controllerNames,popoverController;
 
 
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
 	return rotationManager(interfaceOrientation);
 }
 
+-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
+    self.view.frame = CGRectMake(0, 0, 1024, 1024);
+}
+
 -(void) viewDidLoad {
     self.title = NSLocalizedString(@"Settings",@"");
 
@@ -120,45 +124,50 @@
     [self.navigationController pushViewController:nextController animated:YES];
 }
 
-/*
-#pragma mark -
-#pragma mark Managing the popover controller
-// When setting the detail item, update the view and dismiss the popover controller if it's showing.
--(void) setDetailItem:(id) newDetailItem {
-    if (detailItem != newDetailItem) {
-        [detailItem release];
-        detailItem = [newDetailItem retain];
-        
-        // Update the view.
-       // navigationBar.topItem.title = (NSString*) detailItem;
-
-		//test.text=(NSString*) detailItem;
-    }
-
-  //  if (popoverController != nil) {
-  //      [popoverController dismissPopoverAnimated:YES];
-  //  }        
+-(IBAction) dismissSplitView {
+    [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
 }
-*/
 
 #pragma mark -
-#pragma mark Split view support
-#ifdef __IPHONE_3_2
--(void) splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc {
-    barButtonItem.title = @"Master List";
-    [self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
-    self.popoverController = pc;
+#pragma mark splitview support
+-(void) splitViewController:(UISplitViewController *)svc popoverController:(UIPopoverController *)pc willPresentViewController:(UIViewController *)aViewController {
+    if (popoverController != nil) {
+        [popoverController dismissPopoverAnimated:YES];
+    }
 }
 
-// Called when the view is shown again in the split view, invalidating the button and popover controller.
--(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
-    [self.navigationItem setLeftBarButtonItem:nil animated:YES];
-    self.popoverController = nil;
+// Called when the master view controller is about to be hidden
+-(void) splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController 
+            withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
+
+  /*  barButtonItem.title = @"Master View";
+    UIToolbar *toolbar = self.parentViewController.navigationController.toolbar;
+    NSMutableArray *items = [[toolbar items] mutableCopy];
+    [items insertObject:barButtonItem atIndex:0];
+    [toolbar setItems:items animated:YES];
+
+    [items release];
+
+    self.popoverController = pc;*/
+    barButtonItem.title = aViewController.title;
+    self.navigationItem.rightBarButtonItem = barButtonItem;
 }
-#endif
+
+// Called when the master view controller is about to appear
+-(void) splitViewController: (UISplitViewController*)svc  willShowViewController:(UIViewController *)aViewController 
+            invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
+    /*UIToolbar *toolbar = self.parentViewController.navigationController.toolbar;
 
--(IBAction) dismissSplitView {
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissModalView" object:nil];
+    NSMutableArray *items = [[toolbar items] mutableCopy];
+    [items removeObjectAtIndex:0];
+
+    [toolbar setItems:items animated:YES];
+
+    [items release];
+
+    self.popoverController = nil;*/
+        self.navigationItem.rightBarButtonItem = nil;
+
 }
 
 
@@ -166,26 +175,29 @@
     // Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];
     // Release any cached data, images, etc that aren't in use.
-    generalSettingsViewController = nil;
-    teamSettingsViewController = nil;
-    weaponSettingsViewController = nil;
-    schemeSettingsViewController = nil;
+    if (generalSettingsViewController.view.superview == nil)
+        generalSettingsViewController = nil;
+    if (teamSettingsViewController.view.superview == nil)
+        teamSettingsViewController = nil;
+    if (weaponSettingsViewController.view.superview == nil)
+        weaponSettingsViewController = nil;
+    if (schemeSettingsViewController.view.superview == nil)
+        schemeSettingsViewController = nil;
     MSG_MEMCLEAN();
 }
 
 -(void) viewDidUnload {
     self.controllerNames = nil;
-    self.popoverController = nil;
     generalSettingsViewController = nil;
     teamSettingsViewController = nil;
     weaponSettingsViewController = nil;
     schemeSettingsViewController = nil;
     [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
     [controllerNames release];
-    [popoverController release];
     [generalSettingsViewController release];
     [teamSettingsViewController release];
     [weaponSettingsViewController release];
--- a/cocoaTouch/FlagsViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/FlagsViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -111,6 +111,7 @@
     self.lastIndexPath = nil;
     self.flagArray = nil;
     [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
--- a/cocoaTouch/FortsViewController.h	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/FortsViewController.h	Wed Jun 02 13:52:23 2010 +0000
@@ -13,7 +13,6 @@
     NSDictionary *teamDictionary;
 
     NSArray *fortArray;
-//    NSArray *fortSprites;
     NSIndexPath *lastIndexPath;
 }
 
--- a/cocoaTouch/FortsViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/FortsViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -143,8 +143,8 @@
     self.teamDictionary = nil;
     self.lastIndexPath = nil;
     self.fortArray = nil;
-//    self.fortSprites = nil;
     [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 
--- a/cocoaTouch/GameConfigViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/GameConfigViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -64,6 +64,18 @@
 }
 
 -(void) startGame {
+    // don't start playing if the preview is in progress
+    if ([mapConfigViewController busy]) {
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Wait for the Preview",@"")
+                                                        message:NSLocalizedString(@"Before playing the preview needs to be generated",@"")
+                                                       delegate:nil
+                                              cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"")
+                                              otherButtonTitles:nil];
+        [alert show];
+        [alert release];
+        return;
+    }
+    
     // play only if there is more than one team
     if ([teamConfigViewController.listOfSelectedTeams count] < 2) {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too few teams playing",@"")
@@ -91,6 +103,8 @@
         [alert release];
         return;
     }
+    
+    // create the configuration file that is going to be sent to engine
     NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:mapConfigViewController.seedCommand,@"seed_command",
                                                                       mapConfigViewController.templateFilterCommand,@"templatefilter_command",
                                                                       mapConfigViewController.mapGenCommand,@"mapgen_command",
@@ -99,6 +113,8 @@
                                                                       teamConfigViewController.listOfSelectedTeams,@"teams_list",nil];
     [dict writeToFile:GAMECONFIG_FILE() atomically:YES];
     [dict release];
+
+    // finally launch game and remove this controller
     [[self parentViewController] dismissModalViewControllerAnimated:YES];
     [[SDLUIKitDelegate sharedAppDelegate] startSDLgame];
 }
@@ -137,7 +153,7 @@
     // Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];
     // Release any cached data, images, etc that aren't in use.
-    if (mapConfigViewController.view.superview == nil ) 
+    if (mapConfigViewController.view.superview == nil) 
         mapConfigViewController = nil;
     if (teamConfigViewController.view.superview == nil)
         teamConfigViewController = nil;
@@ -147,11 +163,11 @@
 
 
 -(void) viewDidUnload {
-    NSLog(@"unloading");
     activeController = nil;
     mapConfigViewController = nil;
     teamConfigViewController = nil;
     [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 
--- a/cocoaTouch/GameSetup.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/GameSetup.m	Wed Jun 02 13:52:23 2010 +0000
@@ -292,7 +292,7 @@
 				[self sendToEngine:[self.gameConfig objectForKey:@"seed_command"]];
 				
                 // scheme (returns initial health)
-                NSInteger health = [self provideScheme:@"testing"];
+                NSInteger health = [self provideScheme:@"Scheme 0"];
 
 				// dimension of the map
 				[self sendToEngine:[self.gameConfig objectForKey:@"templatefilter_command"]];
@@ -384,7 +384,8 @@
     [[NSFileManager defaultManager] removeItemAtPath:GAMECONFIG_FILE() error:NULL];
     
 	[pool release];
-	[NSThread exit];
+    //Invoking this method should be avoided as it does not give your thread a chance to clean up any resources it allocated during its execution.
+    //[NSThread exit];
 }
 
 #pragma mark -
--- a/cocoaTouch/GeneralSettingsViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/GeneralSettingsViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -382,6 +382,7 @@
 	self.soundSwitch = nil;
 	self.altDamageSwitch = nil;
 	[super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
--- a/cocoaTouch/GravesViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/GravesViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -109,10 +109,11 @@
 }
 
 - (void)viewDidUnload {
-    [super viewDidUnload];
     self.lastIndexPath = nil;
     self.teamDictionary = nil;
     self.graveArray = nil;
+    [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 - (void)dealloc {
--- a/cocoaTouch/HogHatViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/HogHatViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -128,11 +128,12 @@
 }
 
 - (void)viewDidUnload {
-    [super viewDidUnload];
     self.lastIndexPath = nil;
     self.normalHogSprite = nil;
     self.teamDictionary = nil;
     self.hatArray = nil;
+    [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 - (void)dealloc {
--- a/cocoaTouch/LevelViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/LevelViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -156,11 +156,12 @@
 }
 
 -(void) viewDidUnload {
-    [super viewDidUnload];
     self.lastIndexPath = nil;
     self.teamDictionary = nil;
     self.levelArray = nil;
     self.levelSprites = nil;
+    [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
--- a/cocoaTouch/MainMenuViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/MainMenuViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -23,6 +23,11 @@
 - (void)didReceiveMemoryWarning {
 	// Releases the view if it doesn't have a superview.
 	[super didReceiveMemoryWarning];
+    if (settingsViewController.view.superview == nil) 
+        settingsViewController = nil;
+    if (gameConfigViewController.view.superview == nil) 
+        gameConfigViewController = nil;
+    MSG_MEMCLEAN();
 }
 
 -(void) viewDidLoad {
@@ -67,9 +72,10 @@
     [indicator release];
     
     // create a team
-    createTeamNamed(@"Default Team");
+    createTeamNamed(@"Pirates");
+    createTeamNamed(@"Ninjas");
     
-    createSchemeNamed(@"testing ftw");
+    createSchemeNamed(@"Scheme 0");
     
     // create settings.plist
     NSMutableDictionary *saveDict = [[NSMutableDictionary alloc] init];
@@ -158,6 +164,7 @@
     gameConfigViewController = nil;
     settingsViewController = nil;
 	[super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
--- a/cocoaTouch/MapConfigViewController.h	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/MapConfigViewController.h	Wed Jun 02 13:52:23 2010 +0000
@@ -39,6 +39,7 @@
 }
 
 @property (nonatomic) NSInteger maxHogs;
+@property (nonatomic) BOOL busy;
 @property (nonatomic,retain) NSString *seedCommand;
 @property (nonatomic,retain) NSString *templateFilterCommand;
 @property (nonatomic,retain) NSString *mapGenCommand;
--- a/cocoaTouch/MapConfigViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/MapConfigViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -17,7 +17,7 @@
 
 @implementation MapConfigViewController
 @synthesize previewButton, maxHogs, seedCommand, templateFilterCommand, mapGenCommand, mazeSizeCommand, themeCommand,
-            tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, themeArray, mapArray;
+            tableView, maxLabel, sizeLabel, segmentedControl, slider, lastIndexPath, themeArray, mapArray, busy;
 
 
 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
@@ -54,13 +54,13 @@
         serverQuit = YES;
 	}
 	
-	NSLog(@"engineProtocol - Waiting for a client on port %d", port);
+	DLog(@"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");
+			DLog(@"Client found");
             
             [self sendToEngine:self.seedCommand];
             [self sendToEngine:self.templateFilterCommand];
@@ -70,7 +70,7 @@
                 
             memset(map, 0, 128*32);
             SDLNet_TCP_Recv(csd, map, 128*32);
-            SDLNet_TCP_Recv(csd, &maxHogs, sizeof(Uint8));
+            SDLNet_TCP_Recv(csd, &maxHogs, sizeof(uint8_t));
 
 			SDLNet_TCP_Close(csd);
 			serverQuit = YES;
@@ -218,7 +218,6 @@
     self.previewButton.enabled = NO;
     self.maxLabel.text = @"...";
     self.segmentedControl.enabled = NO;
-    self.tableView.allowsSelection = NO;
     self.slider.enabled = NO;
 }
 
@@ -226,7 +225,6 @@
     self.previewButton.alpha = 1.0f;
     self.previewButton.enabled = YES;
     self.segmentedControl.enabled = YES;
-    self.tableView.allowsSelection = YES;
     self.slider.enabled = YES;
     busy = NO;
 }
@@ -505,6 +503,7 @@
     self.mapArray = nil;
     
     [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
--- a/cocoaTouch/MasterViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/MasterViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -112,7 +112,16 @@
 -(void) didReceiveMemoryWarning {
     // Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];
-    // Relinquish ownership any cached data, images, etc that aren't in use.
+    // Relinquish ownership any cached data, images, etc that aren't in use.    
+    if (generalSettingsViewController.view.superview == nil)
+        generalSettingsViewController = nil;
+    if (teamSettingsViewController.view.superview == nil)
+        teamSettingsViewController = nil;
+    if (weaponSettingsViewController.view.superview == nil)
+        weaponSettingsViewController = nil;
+    if (schemeSettingsViewController.view.superview == nil)
+        schemeSettingsViewController = nil;
+    MSG_MEMCLEAN();
 }
 
 -(void) viewDidUnload {
@@ -124,6 +133,7 @@
     weaponSettingsViewController = nil;
     schemeSettingsViewController = nil;
     [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
--- a/cocoaTouch/OverlayViewController.h	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/OverlayViewController.h	Wed Jun 02 13:52:23 2010 +0000
@@ -12,7 +12,7 @@
 
 @interface OverlayViewController : UIViewController {
     NSTimer *dimTimer;
-#ifdef __IPHONE_3_2
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
     UIPopoverController *popoverController;
 #else
     id popoverController;
--- a/cocoaTouch/OverlayViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/OverlayViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -32,6 +32,8 @@
 	// Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];
 	// Release any cached data, images, etc that aren't in use.
+    if (popupMenu.view.superview == nil) 
+        popupMenu = nil;
 }
 
 -(void) didRotate:(NSNotification *)notification {	
@@ -148,6 +150,7 @@
     self.popoverController = nil;
     self.popupMenu = nil;
     [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
@@ -236,8 +239,9 @@
     CGRect anchorForPopover;
     Class popoverControllerClass = NSClassFromString(@"UIPopoverController");
     if (popoverControllerClass) {
-#ifdef __IPHONE_3_2
-        popupMenu = [[PopoverMenuViewController alloc] initWithStyle:UITableViewStylePlain];
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
+        if (popupMenu == nil) 
+            popupMenu = [[PopoverMenuViewController alloc] initWithStyle:UITableViewStylePlain];
         popoverController = [[popoverControllerClass alloc] initWithContentViewController:popupMenu];
         [popoverController setPopoverContentSize:CGSizeMake(220, 170) animated:YES];
         [popoverController setPassthroughViews:[NSArray arrayWithObject:self.view]];
@@ -253,7 +257,8 @@
                                          animated:YES];
 #endif
     } else {
-        popupMenu = [[PopoverMenuViewController alloc] initWithStyle:UITableViewStyleGrouped];
+        if (popupMenu == nil) 
+            popupMenu = [[PopoverMenuViewController alloc] initWithStyle:UITableViewStyleGrouped];
         popupMenu.view.backgroundColor = [UIColor clearColor];
         popupMenu.view.frame = CGRectMake(480, 0, 200, 170);
         [self.view addSubview:popupMenu.view];
@@ -272,7 +277,7 @@
         isPopoverVisible = NO;
         
         if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
-#ifdef __IPHONE_3_2
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
             [popoverController dismissPopoverAnimated:YES];
 #endif
         } else {
--- a/cocoaTouch/PopoverMenuViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/PopoverMenuViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -37,6 +37,10 @@
     [super viewDidLoad];
 }
 
+-(void) viewDidUnload {
+    [super viewDidUnload];
+    MSG_DIDUNLOAD();
+}
 
 -(void) dealloc {
     [menuList release];
--- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Wed Jun 02 13:52:23 2010 +0000
@@ -43,9 +43,8 @@
 #ifdef VALGRIND_REXEC
     // Using the valgrind build config, rexec ourself in valgrind
     // from http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind.20081224.html
-    if (argc < 2 || (argc >= 2 && strcmp(argv[1], "-valgrind") != 0)) {
-        execl(VALGRIND, VALGRIND, "--leak-check=full", "--show-reachable=yes", argv[0], "-valgrind", NULL);
-    }
+    if (argc < 2 || (argc >= 2 && strcmp(argv[1], "-valgrind") != 0))
+        execl(VALGRIND, VALGRIND, "--leak-check=full", argv[0], "-valgrind", NULL);
 #endif
 
 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
--- a/cocoaTouch/SchemeSettingsViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/SchemeSettingsViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -139,11 +139,15 @@
 #pragma mark Memory management
 -(void)didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];
+    if (childController.view.superview == nil )
+        childController = nil;
 }
 
 -(void) viewDidUnload {
     self.listOfSchemes = nil;
     childController = nil;
+    [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 
--- a/cocoaTouch/SingleSchemeViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/SingleSchemeViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -302,6 +302,8 @@
     self.schemeArray = nil;
     self.basicSettingList = nil;
     self.gameModifierArray = nil;
+    [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
--- a/cocoaTouch/SingleTeamViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/SingleTeamViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -405,6 +405,18 @@
     // Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];
     // Relinquish ownership any cached data, images, etc that aren't in use.
+    if (hogHatViewController.view.superview == nil)
+        hogHatViewController = nil;
+    if (gravesViewController.view.superview == nil)
+        gravesViewController = nil;
+    if (voicesViewController.view.superview == nil)
+        voicesViewController = nil;
+    if (fortsViewController.view.superview == nil)
+        fortsViewController = nil;
+    if (flagsViewController.view.superview == nil)
+        flagsViewController = nil;
+    if (levelViewController.view.superview == nil)
+        levelViewController = nil;
 }
 
 -(void) viewDidUnload {
@@ -419,6 +431,7 @@
     gravesViewController = nil;
     levelViewController = nil;
     [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
--- a/cocoaTouch/SplitViewRootController.h	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/SplitViewRootController.h	Wed Jun 02 13:52:23 2010 +0000
@@ -9,7 +9,7 @@
 #import <UIKit/UIKit.h>
 
 @class DetailViewController;
-@interface SplitViewRootController : UIViewController {
+@interface SplitViewRootController : UIViewController  <UISplitViewControllerDelegate, UIPopoverControllerDelegate>{
     DetailViewController *detailViewController;
 }
 
--- a/cocoaTouch/SplitViewRootController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/SplitViewRootController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -22,7 +22,8 @@
     // Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];    
     // Release any cached data, images, etc that aren't in use.
-    detailViewController = nil;
+    if (detailViewController.view.superview == nil)
+        detailViewController = nil;
     MSG_MEMCLEAN();
 }
 
@@ -33,34 +34,29 @@
     UINavigationController *detailedNavController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
     [detailViewController release];
 
+    CGRect rect = [[UIScreen mainScreen] bounds];
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
-        self.view.frame = CGRectMake(0, 0, 1024, 768);
-    
-    //id splitViewRootController;
-    
+        self.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width);
+        
     Class splitViewControllerClass = NSClassFromString(@"UISplitViewController");
     if (splitViewControllerClass) {
-#ifdef __IPHONE_3_2
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
         UISplitViewController *splitViewRootController = [[UISplitViewController alloc] init];
-        //[[splitViewRootController view] setAutoresizingMask: UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
+        //splitViewRootController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;        
+        splitViewRootController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width);
         
-        splitViewRootController.view.frame = CGRectMake(0, 0, 1024, 768);
         MasterViewController *masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
-        
         UINavigationController *mainNavController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
-    
-        masterViewController.detailViewController = detailViewController;        
         [masterViewController release];
 
+        splitViewRootController.delegate = detailViewController;
+        masterViewController.detailViewController = detailViewController;        
         splitViewRootController.viewControllers = [NSArray arrayWithObjects: mainNavController, detailedNavController, nil];
         [mainNavController release];
         [detailedNavController release];
         
-        splitViewRootController.delegate = detailViewController;
-        [detailViewController release];
-
         // add view to main controller
-        [self.view addSubview:[splitViewRootController view]];
+        [self.view addSubview:splitViewRootController.view];
 #endif
     } else {
         [self.view addSubview:detailedNavController.view];
@@ -72,12 +68,16 @@
 -(void) viewDidUnload {
     detailViewController = nil;
     [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
     [detailViewController release];
     [super dealloc];
 }
+-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
+    [detailViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
+}
 
 #pragma mark -
 #pragma mark additional methods as we're using a UINavigationController programmatically
--- a/cocoaTouch/TeamConfigViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/TeamConfigViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -159,6 +159,8 @@
 
 -(void) viewDidUnload {
     self.listOfTeams = nil;
+    [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 
--- a/cocoaTouch/TeamSettingsViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/TeamSettingsViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -145,12 +145,15 @@
     // Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];
     // Relinquish ownership any cached data, images, etc that aren't in use.
+    if (childController.view.superview == nil )
+        childController = nil;
 }
 
 -(void) viewDidUnload {
     self.listOfTeams = nil;
     childController = nil;
     [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
 -(void) dealloc {
--- a/cocoaTouch/VoicesViewController.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/VoicesViewController.m	Wed Jun 02 13:52:23 2010 +0000
@@ -173,7 +173,7 @@
 
 #pragma mark -
 #pragma mark Memory management
-- (void)didReceiveMemoryWarning {
+-(void) didReceiveMemoryWarning {
     openal_stopsound(voiceBeingPlayed);
     openal_freesound(voiceBeingPlayed);
     voiceBeingPlayed = -1;
@@ -182,17 +182,17 @@
     // Relinquish ownership any cached data, images, etc that aren't in use.
 }
 
-- (void)viewDidUnload {
-    [super viewDidUnload];
-
+-(void) viewDidUnload {
     openal_close();
     voiceBeingPlayed = -1;
     self.lastIndexPath = nil;
     self.teamDictionary = nil;
     self.voiceArray = nil;
+    [super viewDidUnload];
+    MSG_DIDUNLOAD();
 }
 
-- (void)dealloc {
+-(void) dealloc {
     [voiceArray release];
     [teamDictionary release];
     [lastIndexPath release];
--- a/cocoaTouch/otherSrc/CommodityFunctions.h	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/otherSrc/CommodityFunctions.h	Wed Jun 02 13:52:23 2010 +0000
@@ -34,16 +34,17 @@
 #define MAPS_DIRECTORY()        [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Maps/"]
 #define VOICES_DIRECTORY()      [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/Data/Sounds/voices/"]
 
-#define MSG_MEMCLEAN()          DLog(@"has cleaned up some memory");
+#define MSG_MEMCLEAN()          DLog(@"has cleaned up some memory"); print_free_memory()
+#define MSG_DIDUNLOAD()         DLog(@"did unload");
 
 void createTeamNamed (NSString *nameWithoutExt);
 void createSchemeNamed (NSString *nameWithoutExt);
 BOOL rotationManager (UIInterfaceOrientation interfaceOrientation);
 NSInteger randomPort ();
 void popError (const char *title, const char *message);
-
+void print_free_memory ();
 
-#ifndef __IPHONE_3_2	// if iPhoneOS is 3.2 or greater then __IPHONE_3_2 will be defined
+#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_3_2
 typedef enum {
     UIUserInterfaceIdiomPhone,           // iPhone and iPod touch style UI
     UIUserInterfaceIdiomPad,             // iPad style UI
--- a/cocoaTouch/otherSrc/CommodityFunctions.m	Tue Jun 01 19:33:45 2010 +0000
+++ b/cocoaTouch/otherSrc/CommodityFunctions.m	Wed Jun 02 13:52:23 2010 +0000
@@ -8,6 +8,8 @@
 
 #import "CommodityFunctions.h"
 #import "SDL_uikitappdelegate.h"
+#import <mach/mach.h>
+#import <mach/mach_host.h>
 
 void createTeamNamed (NSString *nameWithoutExt) {
     NSString *teamsDirectory = TEAMS_DIRECTORY();
@@ -110,6 +112,27 @@
     [alert show];
     [alert release];
 }
+
+// by http://landonf.bikemonkey.org/code/iphone/Determining_Available_Memory.20081203.html
+void print_free_memory () {
+    mach_port_t host_port;
+    mach_msg_type_number_t host_size;
+    vm_size_t pagesize;
     
-
-
+    host_port = mach_host_self();
+    host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
+    host_page_size(host_port, &pagesize);        
+ 
+    vm_statistics_data_t vm_stat;
+              
+    if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS)
+        DLog(@"Failed to fetch vm statistics");
+ 
+    /* Stats in bytes */ 
+    natural_t mem_used = (vm_stat.active_count +
+                          vm_stat.inactive_count +
+                          vm_stat.wire_count) * pagesize;
+    natural_t mem_free = vm_stat.free_count * pagesize;
+    natural_t mem_total = mem_used + mem_free;
+    DLog(@"used: %u free: %u total: %u", mem_used, mem_free, mem_total);
+}
--- a/hedgewars/hwengine.pas	Tue Jun 01 19:33:45 2010 +0000
+++ b/hedgewars/hwengine.pas	Wed Jun 02 13:52:23 2010 +0000
@@ -245,7 +245,6 @@
 begin
 {$IFDEF HWLIBRARY}
     initEverything();
-    Randomize();
 
     cBits:= 32;
     cFullScreen:= false;
@@ -417,6 +416,8 @@
     initEverything();
     WriteLnToConsole('Preview connecting on port ' + inttostr(port));
     ipcPort:= port;
+    // this function is so quick that we need slow it down
+    SDL_Delay(250);
 {$ENDIF}
     InitIPC;
     IPCWaitPongEvent;
--- a/hedgewars/uStore.pas	Tue Jun 01 19:33:45 2010 +0000
+++ b/hedgewars/uStore.pas	Wed Jun 02 13:52:23 2010 +0000
@@ -1072,7 +1072,9 @@
 var tmpsurf: PSDL_Surface;
     s: shortstring;
 begin
-    WriteToConsole(msgLoading + filename + '.png [flags:');
+    WriteToConsole(msgLoading + filename + '.png (flags: ' + inttostr(imageFlags)+') ');
+{$IFDEF DEBUGFILE}
+    WriteToConsole('[flag translation:');
     if imageFlags = ifNone then
         WriteToConsole(' None')
     else
@@ -1084,6 +1086,7 @@
         if (imageFlags and ifLowRes) <> 0 then WriteToConsole(' LowRes');
         end;
     WriteToConsole('] ');
+{$ENDIF}
 
     s:= filename + '.png';
     tmpsurf:= IMG_Load(Str2PChar(s));
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Tue Jun 01 19:33:45 2010 +0000
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Wed Jun 02 13:52:23 2010 +0000
@@ -22,7 +22,7 @@
 
 /* Begin PBXBuildFile section */
 		1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
-		1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
+		1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
 		28FD15000DC6FC520079059D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD14FF0DC6FC520079059D /* OpenGLES.framework */; };
 		28FD15080DC6FC5B0079059D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FD15070DC6FC5B0079059D /* QuartzCore.framework */; };
 		611B0AA1116B626E00112153 /* GeneralSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 611B0AA0116B626E00112153 /* GeneralSettingsViewController.m */; };
@@ -1149,7 +1149,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
-				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				CODE_SIGN_ENTITLEMENTS = "Entitlements-Development.plist";
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -1175,7 +1175,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";
+				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix -dLOWRES";
 				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;
@@ -1278,6 +1278,115 @@
 			};
 			name = Distribution;
 		};
+		6164429D11B5CDE500B9A6F3 /* Valgrind */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				CODE_SIGN_IDENTITY = "iPhone Developer: Vittorio Giovara (DC2BRETXAC)";
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Vittorio Giovara (DC2BRETXAC)";
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix -dLOWRES";
+				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;
+				FPC_SPECIFIC_OPTIONS = "-dDEBUGFILE -O- -gl -gw2 -gs -gt -ghttt -Xs-";
+				FPC_UNITS_PATH = "-Fu\"$(PROJECT_DIR)\"";
+				GCC_C_LANGUAGE_STANDARD = c99;
+				GCC_DEBUGGING_SYMBOLS = full;
+				GCC_FAST_MATH = NO;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					VALGRIND_REXEC,
+					DEBUG,
+				);
+				GCC_THUMB_SUPPORT = NO;
+				GCC_VERSION = 4.2;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				HEADER_SEARCH_PATHS = (
+					/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/OpenAL.framework/Headers,
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include\"/**",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src\"/**",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net\"",
+				);
+				IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+				ONLY_ACTIVE_ARCH = NO;
+				OTHER_LDFLAGS = (
+					"-lz",
+					"-Wl,-no_order_inits",
+				);
+				PREBINDING = NO;
+				SDKROOT = iphonesimulator3.2;
+				TARGETED_DEVICE_FAMILY = "1,2";
+				VALIDATE_PRODUCT = NO;
+			};
+			name = Valgrind;
+		};
+		6164429E11B5CDE500B9A6F3 /* Valgrind */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PRECOMPILE_PREFIX_HEADER = YES;
+				GCC_PREFIX_HEADER = Hedgewars_Prefix.pch;
+				INFOPLIST_FILE = Info.plist;
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					"\"$(SRCROOT)\"",
+				);
+				PRODUCT_NAME = Hedgewars;
+				TARGETED_DEVICE_FAMILY = "1,2";
+			};
+			name = Valgrind;
+		};
+		6164429F11B5CDE500B9A6F3 /* Valgrind */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				PREBINDING = NO;
+				PRODUCT_NAME = fpc;
+			};
+			name = Valgrind;
+		};
+		616442A011B5CDE500B9A6F3 /* Valgrind */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				HEADER_SEARCH_PATHS = (
+					/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk/System/Library/Frameworks/OpenAL.framework/Headers,
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/include\"/**",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL/src\"/**",
+					"\"$(SRCROOT)/../../../Library/lpng141\"",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_net\"",
+					"\"$(SRCROOT)/../../../Library/SDL-1.3/SDL_mixer\"",
+					"\"$(SRCROOT)/../../../Library/libvorbis-1.3.1/include\"",
+					"\"$(SRCROOT)/../../../Library/libogg-1.2.0/include\"",
+				);
+				OTHER_LDFLAGS = "";
+				PREBINDING = NO;
+				PRODUCT_NAME = openalbridge;
+			};
+			name = Valgrind;
+		};
+		616442A111B5CDE500B9A6F3 /* Valgrind */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				PRODUCT_NAME = UpdateDataFolder;
+			};
+			name = Valgrind;
+		};
 		6179928C114AE0C800BA94A9 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -1377,12 +1486,12 @@
 				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
 				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";
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix -dLOWRES";
 				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;
-				FPC_SPECIFIC_OPTIONS = "-dDEBUGFILE -O- -gl -gw2 -gs -gt -ghttt -Xs-";
+				FPC_SPECIFIC_OPTIONS = "-dDEBUGFILE -O- -gl -gw2 -gt -ghttt -Xs-";
 				FPC_UNITS_PATH = "-Fu\"$(PROJECT_DIR)\"";
 				GCC_C_LANGUAGE_STANDARD = c99;
 				GCC_DEBUGGING_SYMBOLS = full;
@@ -1414,10 +1523,10 @@
 		C01FCF5008A954540054247B /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix";
+				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix -dLOWRES";
 				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;
@@ -1427,6 +1536,7 @@
 				GCC_DEBUGGING_SYMBOLS = default;
 				GCC_FAST_MATH = YES;
 				GCC_OPTIMIZATION_LEVEL = 2;
+				GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
 				GCC_THUMB_SUPPORT = NO;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
@@ -1460,6 +1570,7 @@
 				1D6058940D05DD3E006BFB54 /* Debug */,
 				1D6058950D05DD3E006BFB54 /* Release */,
 				6137064C117B1CB3004EE44A /* Distribution */,
+				6164429E11B5CDE500B9A6F3 /* Valgrind */,
 			);
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
@@ -1470,6 +1581,7 @@
 				6179928C114AE0C800BA94A9 /* Debug */,
 				6179928D114AE0C800BA94A9 /* Release */,
 				6137064F117B1CB3004EE44A /* Distribution */,
+				616442A111B5CDE500B9A6F3 /* Valgrind */,
 			);
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
@@ -1480,6 +1592,7 @@
 				61C3251E1179A300001E70B1 /* Debug */,
 				61C3251F1179A300001E70B1 /* Release */,
 				6137064E117B1CB3004EE44A /* Distribution */,
+				616442A011B5CDE500B9A6F3 /* Valgrind */,
 			);
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
@@ -1490,6 +1603,7 @@
 				928301180F10CAFD00CC5A3C /* Debug */,
 				928301190F10CAFD00CC5A3C /* Release */,
 				6137064D117B1CB3004EE44A /* Distribution */,
+				6164429F11B5CDE500B9A6F3 /* Valgrind */,
 			);
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
@@ -1500,6 +1614,7 @@
 				C01FCF4F08A954540054247B /* Debug */,
 				C01FCF5008A954540054247B /* Release */,
 				6137064B117B1CB3004EE44A /* Distribution */,
+				6164429D11B5CDE500B9A6F3 /* Valgrind */,
 			);
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;