add some memory aware code
authorkoda
Mon, 31 May 2010 19:33:42 +0000
changeset 3487 b1d00f1950c8
parent 3486 e1b1a4c18c5b
child 3488 6c5d74cf4396
add some memory aware code revert sdl calls to past implementation (the one that did not crash) add some debug methods found online
cocoaTouch/DetailViewController.m
cocoaTouch/GameConfigViewController.m
cocoaTouch/GameSetup.m
cocoaTouch/MapConfigViewController.m
cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h
cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m
cocoaTouch/SplitViewRootController.m
cocoaTouch/TeamConfigViewController.m
cocoaTouch/otherSrc/CommodityFunctions.h
cocoaTouch/xib/MapConfigViewController-iPad.xib
hedgewars/hwengine.pas
misc/openalbridge/wrappers.c
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
project_files/HedgewarsMobile/Hedgewars_Prefix.pch
--- a/cocoaTouch/DetailViewController.m	Fri May 28 20:13:47 2010 +0000
+++ b/cocoaTouch/DetailViewController.m	Mon May 31 19:33:42 2010 +0000
@@ -146,13 +146,13 @@
 #ifdef __IPHONE_3_2
 -(void) splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc {
     barButtonItem.title = @"Master List";
-    [self.navigationController.navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:YES];
+    [self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
     self.popoverController = pc;
 }
 
 // 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.navigationController.navigationBar.topItem setLeftBarButtonItem:nil animated:YES];
+    [self.navigationItem setLeftBarButtonItem:nil animated:YES];
     self.popoverController = nil;
 }
 #endif
@@ -166,6 +166,11 @@
     // 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;
+    MSG_MEMCLEAN();
 }
 
 -(void) viewDidUnload {
--- a/cocoaTouch/GameConfigViewController.m	Fri May 28 20:13:47 2010 +0000
+++ b/cocoaTouch/GameConfigViewController.m	Mon May 31 19:33:42 2010 +0000
@@ -137,6 +137,12 @@
     // 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 ) 
+        mapConfigViewController = nil;
+    if (teamConfigViewController.view.superview == nil)
+        teamConfigViewController = nil;
+    activeController = nil;
+    MSG_MEMCLEAN();
 }
 
 
--- a/cocoaTouch/GameSetup.m	Fri May 28 20:13:47 2010 +0000
+++ b/cocoaTouch/GameSetup.m	Mon May 31 19:33:42 2010 +0000
@@ -154,6 +154,7 @@
 -(NSInteger) provideScheme:(NSString *)schemeName {
     NSString *schemePath = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),schemeName];
     NSArray *scheme = [[NSArray alloc] initWithContentsOfFile:schemePath];
+    [schemePath release];
     int result = 0;
     int i = 0;
     
@@ -231,6 +232,7 @@
     [self sendToEngine:explosives];
     [explosives release];
     
+    [scheme release];
     return result;
 }
 
--- a/cocoaTouch/MapConfigViewController.m	Fri May 28 20:13:47 2010 +0000
+++ b/cocoaTouch/MapConfigViewController.m	Mon May 31 19:33:42 2010 +0000
@@ -88,6 +88,7 @@
     int port = randomPort();
     pthread_t thread_id;
     pthread_create(&thread_id, NULL, (void *)GenLandPreview, (void *)port);
+    pthread_detach(thread_id);
     [self engineProtocol:port];
 
     // draw the buffer (1 pixel per component, 0= transparent 1= color)
@@ -128,7 +129,8 @@
     [indicator removeFromSuperview];
     
     [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];
 
     /*
     // http://developer.apple.com/mac/library/qa/qa2001/qa1037.html
@@ -360,6 +362,9 @@
             mazeCommand = @"e$maze_size 0";
             break;
         default:
+            labelText = nil;
+            templateCommand = nil;
+            mazeCommand = nil;
             break;
     }
     
@@ -402,6 +407,10 @@
             [self sliderChanged:nil];
             self.slider.enabled = YES;
             break;
+        
+        default:
+            mapgen = nil;
+            break;
     }
     self.mapGenCommand = mapgen;
     [self updatePreview];
--- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h	Fri May 28 20:13:47 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.h	Mon May 31 19:33:42 2010 +0000
@@ -27,10 +27,15 @@
 @class OverlayViewController;
 
 @interface SDLUIKitDelegate:NSObject<UIApplicationDelegate> {
+    SDL_Window *window; 	 
+    UIWindow *uiwindow;
     MainMenuViewController *mainViewController;
     BOOL isInGame;
 }
 
+@property (readwrite, assign) SDL_Window *window; 	 
+@property (readwrite, retain) UIWindow *uiwindow;
+
 +(SDLUIKitDelegate *)sharedAppDelegate;
 -(void) startSDLgame;
 -(void) displayOverlayLater;
--- a/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Fri May 28 20:13:47 2010 +0000
+++ b/cocoaTouch/SDLOverrides/SDL_uikitappdelegate.m	Mon May 31 19:33:42 2010 +0000
@@ -55,6 +55,7 @@
 }
 
 @implementation SDLUIKitDelegate
+@synthesize uiwindow, window;
 
 // convenience method
 +(SDLUIKitDelegate *)sharedAppDelegate {
@@ -66,11 +67,15 @@
 	if (self = [super init]){
         mainViewController = nil;
         isInGame = NO;
+        self.uiwindow = nil; 	 
+        self.window = NULL;
     }
     return self;
 }
 
 -(void) dealloc {
+    SDL_DestroyWindow(self.window);
+     [uiwindow release];
     [mainViewController release];
 	[super dealloc];
 }
@@ -89,7 +94,7 @@
 	[setup release];
 
     // since the sdlwindow is not yet created, we add the overlayController with a delay
-    [self performSelector:@selector(displayOverlayLater) withObject:nil afterDelay:4];
+    [self performSelector:@selector(displayOverlayLater) withObject:nil afterDelay:1];
     
     // this is the pascal fuction that starts the game (wrapped around isInGame)
     isInGame = YES;
@@ -117,9 +122,11 @@
     [application setStatusBarHidden:YES];
     [application setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];  
     
-    UIWindow *uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+    uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
 	uiwindow.backgroundColor = [UIColor blackColor];
-	
+    // needed to keep the app running after a game (gets released in sdl_uikitwindow)
+	[uiwindow retain];
+    
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
         mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil];
     else
@@ -146,6 +153,7 @@
     if (isInGame) {
         HW_pause();
         
+        /*
         // Send every window on every screen a MINIMIZED event.
         SDL_VideoDevice *_this = SDL_GetVideoDevice();
         if (!_this)
@@ -158,6 +166,7 @@
             for (window = display->windows; window != nil; window = window->next)
                 SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
         }
+        */
     }
 }
 
@@ -166,6 +175,7 @@
     if (isInGame) {
         HW_pause();
 
+        /*
         // Send every window on every screen a RESTORED event.
         SDL_VideoDevice *_this = SDL_GetVideoDevice();
         if (!_this)
@@ -178,6 +188,7 @@
             for (window = display->windows; window != nil; window = window->next)
                 SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
         }
+        */
     }
 }
 
--- a/cocoaTouch/SplitViewRootController.m	Fri May 28 20:13:47 2010 +0000
+++ b/cocoaTouch/SplitViewRootController.m	Mon May 31 19:33:42 2010 +0000
@@ -22,6 +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;
+    MSG_MEMCLEAN();
 }
 
 // load the view programmatically; we need a splitViewController that handles a MasterViewController 
--- a/cocoaTouch/TeamConfigViewController.m	Fri May 28 20:13:47 2010 +0000
+++ b/cocoaTouch/TeamConfigViewController.m	Mon May 31 19:33:42 2010 +0000
@@ -132,44 +132,6 @@
 }
 
 
-/*
-// Override to support conditional editing of the table view.
-- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
-    // Return NO if you do not want the specified item to be editable.
-    return YES;
-}
-*/
-
-
-/*
-// Override to support editing the table view.
-- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
-    
-    if (editingStyle == UITableViewCellEditingStyleDelete) {
-        // Delete the row from the data source
-        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
-    }   
-    else if (editingStyle == UITableViewCellEditingStyleInsert) {
-        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
-    }   
-}
-*/
-
-
-/*
-// Override to support rearranging the table view.
-- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
-}
-*/
-
-/*
-// Override to support conditional rearranging of the table view.
-- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
-    // Return NO if you do not want the item to be re-orderable.
-    return YES;
-}
-*/
-
 #pragma mark -
 #pragma mark Table view delegate
 -(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
--- a/cocoaTouch/otherSrc/CommodityFunctions.h	Fri May 28 20:13:47 2010 +0000
+++ b/cocoaTouch/otherSrc/CommodityFunctions.h	Mon May 31 19:33:42 2010 +0000
@@ -34,6 +34,8 @@
 #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");
+
 void createTeamNamed (NSString *nameWithoutExt);
 void createSchemeNamed (NSString *nameWithoutExt);
 BOOL rotationManager (UIInterfaceOrientation interfaceOrientation);
--- a/cocoaTouch/xib/MapConfigViewController-iPad.xib	Fri May 28 20:13:47 2010 +0000
+++ b/cocoaTouch/xib/MapConfigViewController-iPad.xib	Mon May 31 19:33:42 2010 +0000
@@ -86,7 +86,7 @@
 					<object class="IBUISlider" id="938256702">
 						<reference key="NSNextResponder" ref="191373211"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{573, 37}, {149, 23}}</string>
+						<string key="NSFrame">{{570, 117}, {149, 23}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<string key="targetRuntimeIdentifier">IBIPadFramework</string>
@@ -126,7 +126,7 @@
 					<object class="IBUILabel" id="634417433">
 						<reference key="NSNextResponder" ref="191373211"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{627, 110}, {42, 21}}</string>
+						<string key="NSFrame">{{623, 20}, {42, 21}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClipsSubviews">YES</bool>
@@ -146,7 +146,7 @@
 					<object class="IBUILabel" id="743202682">
 						<reference key="NSNextResponder" ref="191373211"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{575, 67}, {145, 29}}</string>
+						<string key="NSFrame">{{572, 66}, {145, 29}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClipsSubviews">YES</bool>
@@ -346,10 +346,10 @@
 							<reference ref="88728219"/>
 							<reference ref="565214171"/>
 							<reference ref="967260168"/>
+							<reference ref="326163764"/>
 							<reference ref="938256702"/>
+							<reference ref="743202682"/>
 							<reference ref="634417433"/>
-							<reference ref="743202682"/>
-							<reference ref="326163764"/>
 						</object>
 						<reference key="parent" ref="0"/>
 					</object>
@@ -422,7 +422,7 @@
 					<bool key="EncodedWithXMLCoder">YES</bool>
 					<string>MapConfigViewController</string>
 					<string>UIResponder</string>
-					<string>{{255, 106}, {1024, 768}}</string>
+					<string>{{255, 115}, {1024, 768}}</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
--- a/hedgewars/hwengine.pas	Fri May 28 20:13:47 2010 +0000
+++ b/hedgewars/hwengine.pas	Mon May 31 19:33:42 2010 +0000
@@ -183,6 +183,7 @@
     PrevTime:= SDL_GetTicks;
     while isTerminated = false do
     begin
+{$IFNDEF IPHONEOS}
 // have to remove this cycle because otherwise it segfaults at exit
         while SDL_PollEvent(@event) <> 0 do
         begin
@@ -209,6 +210,7 @@
                 SDL_QUITEV: isTerminated:= true
             end; // end case event.type_
         end; // end while SDL_PollEvent(@event) <> 0
+{$ENDIF}
 
         if isTerminated = false then
         begin
--- a/misc/openalbridge/wrappers.c	Fri May 28 20:13:47 2010 +0000
+++ b/misc/openalbridge/wrappers.c	Mon May 31 19:33:42 2010 +0000
@@ -72,7 +72,7 @@
 
     if (type == AL_FADE_IN) {
 #ifdef DEBUG
-        err_msg("(%s) INFO - Fade-in in progress [index %d quantity %d]", prog, index, quantity);
+        fprintf(stderr,"(Bridge Info) - Fade-in in progress [index %d quantity %d]", index, quantity);
 #endif
 
         // save the volume desired after the fade
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Fri May 28 20:13:47 2010 +0000
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Mon May 31 19:33:42 2010 +0000
@@ -31,6 +31,7 @@
 		611E12FF117BBBDA0044B62F /* Entitlements-Development.plist in Resources */ = {isa = PBXBuildFile; fileRef = 611E12FE117BBBDA0044B62F /* Entitlements-Development.plist */; };
 		611E1316117BBE5A0044B62F /* WeaponSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 611E1315117BBE5A0044B62F /* WeaponSettingsViewController.m */; };
 		611E1319117BBE700044B62F /* SchemeSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 611E1318117BBE700044B62F /* SchemeSettingsViewController.m */; };
+		611F4D4B11B27A9900F9759A /* uScript.pas in Sources */ = {isa = PBXBuildFile; fileRef = 611F4D4A11B27A9900F9759A /* uScript.pas */; };
 		6122CD01116BECCA002648E9 /* Default-Landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = 6122CD00116BECCA002648E9 /* Default-Landscape.png */; };
 		61272334117DF764005B90CF /* libSDL_image.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61272333117DF752005B90CF /* libSDL_image.a */; };
 		61272339117DF778005B90CF /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61272338117DF778005B90CF /* MobileCoreServices.framework */; };
@@ -70,7 +71,6 @@
 		61798832114AA34C00BA94A9 /* uLocale.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798804114AA34C00BA94A9 /* uLocale.pas */; };
 		61798833114AA34C00BA94A9 /* uMisc.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798805114AA34C00BA94A9 /* uMisc.pas */; };
 		61798834114AA34C00BA94A9 /* uRandom.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798806114AA34C00BA94A9 /* uRandom.pas */; };
-		61798835114AA34C00BA94A9 /* uScript.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798807114AA34C00BA94A9 /* uScript.pas */; };
 		61798836114AA34C00BA94A9 /* uSHA.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798808114AA34C00BA94A9 /* uSHA.pas */; };
 		61798837114AA34C00BA94A9 /* uSound.pas in Sources */ = {isa = PBXBuildFile; fileRef = 61798809114AA34C00BA94A9 /* uSound.pas */; };
 		61798838114AA34C00BA94A9 /* uStats.pas in Sources */ = {isa = PBXBuildFile; fileRef = 6179880A114AA34C00BA94A9 /* uStats.pas */; };
@@ -230,6 +230,7 @@
 		611E1315117BBE5A0044B62F /* WeaponSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WeaponSettingsViewController.m; path = ../../cocoaTouch/WeaponSettingsViewController.m; sourceTree = SOURCE_ROOT; };
 		611E1317117BBE700044B62F /* SchemeSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SchemeSettingsViewController.h; path = ../../cocoaTouch/SchemeSettingsViewController.h; sourceTree = SOURCE_ROOT; };
 		611E1318117BBE700044B62F /* SchemeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SchemeSettingsViewController.m; path = ../../cocoaTouch/SchemeSettingsViewController.m; sourceTree = SOURCE_ROOT; };
+		611F4D4A11B27A9900F9759A /* uScript.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uScript.pas; path = ../../hedgewars/uScript.pas; sourceTree = SOURCE_ROOT; };
 		611FD9C81155A1F200C2203D /* Background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Background.png; path = ../../QTfrontend/res/Background.png; sourceTree = SOURCE_ROOT; };
 		611FD9CB1155A28C00C2203D /* HedgewarsTitle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = HedgewarsTitle.png; path = ../../QTfrontend/res/HedgewarsTitle.png; sourceTree = SOURCE_ROOT; };
 		611FD9CF1155A40700C2203D /* NetworkPlay.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = NetworkPlay.png; path = ../../QTfrontend/res/NetworkPlay.png; sourceTree = SOURCE_ROOT; };
@@ -281,7 +282,6 @@
 		61798804114AA34C00BA94A9 /* uLocale.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uLocale.pas; path = ../../hedgewars/uLocale.pas; sourceTree = SOURCE_ROOT; };
 		61798805114AA34C00BA94A9 /* uMisc.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uMisc.pas; path = ../../hedgewars/uMisc.pas; sourceTree = SOURCE_ROOT; };
 		61798806114AA34C00BA94A9 /* uRandom.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uRandom.pas; path = ../../hedgewars/uRandom.pas; sourceTree = SOURCE_ROOT; };
-		61798807114AA34C00BA94A9 /* uScript.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uScript.pas; path = ../../hedgewars/uScript.pas; sourceTree = SOURCE_ROOT; };
 		61798808114AA34C00BA94A9 /* uSHA.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uSHA.pas; path = ../../hedgewars/uSHA.pas; sourceTree = SOURCE_ROOT; };
 		61798809114AA34C00BA94A9 /* uSound.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uSound.pas; path = ../../hedgewars/uSound.pas; sourceTree = SOURCE_ROOT; };
 		6179880A114AA34C00BA94A9 /* uStats.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uStats.pas; path = ../../hedgewars/uStats.pas; sourceTree = SOURCE_ROOT; };
@@ -582,12 +582,12 @@
 		61798892114AA56300BA94A9 /* inc */ = {
 			isa = PBXGroup;
 			children = (
+				61798852114AA44900BA94A9 /* config.inc */,
+				617987EB114AA34C00BA94A9 /* options.inc */,
 				618736B8118CA28600123B23 /* GearDrawing.inc */,
-				61798852114AA44900BA94A9 /* config.inc */,
 				617987E1114AA34C00BA94A9 /* CCHandlers.inc */,
 				617987E4114AA34C00BA94A9 /* GSHandlers.inc */,
 				617987E5114AA34C00BA94A9 /* HHHandlers.inc */,
-				617987EB114AA34C00BA94A9 /* options.inc */,
 				617987F0114AA34C00BA94A9 /* SinTable.inc */,
 			);
 			name = inc;
@@ -768,7 +768,7 @@
 				61798804114AA34C00BA94A9 /* uLocale.pas */,
 				61798805114AA34C00BA94A9 /* uMisc.pas */,
 				61798806114AA34C00BA94A9 /* uRandom.pas */,
-				61798807114AA34C00BA94A9 /* uScript.pas */,
+				611F4D4A11B27A9900F9759A /* uScript.pas */,
 				61798808114AA34C00BA94A9 /* uSHA.pas */,
 				61798809114AA34C00BA94A9 /* uSound.pas */,
 				6179880A114AA34C00BA94A9 /* uStats.pas */,
@@ -1060,7 +1060,6 @@
 				61798832114AA34C00BA94A9 /* uLocale.pas in Sources */,
 				61798833114AA34C00BA94A9 /* uMisc.pas in Sources */,
 				61798834114AA34C00BA94A9 /* uRandom.pas in Sources */,
-				61798835114AA34C00BA94A9 /* uScript.pas in Sources */,
 				61798836114AA34C00BA94A9 /* uSHA.pas in Sources */,
 				61798837114AA34C00BA94A9 /* uSound.pas in Sources */,
 				61798838114AA34C00BA94A9 /* uStats.pas in Sources */,
@@ -1096,6 +1095,7 @@
 				61B22E0F1180FBF400B2FCE0 /* MapConfigViewController.m in Sources */,
 				61AE62C711A067FE008DC32E /* SplitViewRootController.m in Sources */,
 				615FBA5811A93D6700B139F9 /* SingleSchemeViewController.m in Sources */,
+				611F4D4B11B27A9900F9759A /* uScript.pas in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1129,6 +1129,7 @@
 			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;
@@ -1148,6 +1149,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
+				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
 				CODE_SIGN_ENTITLEMENTS = "Entitlements-Development.plist";
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -1169,7 +1171,7 @@
 		6137064B117B1CB3004EE44A /* Distribution */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
 				CODE_SIGN_ENTITLEMENTS = "Entitlements-Distribution.plist";
 				CODE_SIGN_IDENTITY = "iPhone Distribution";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
@@ -1211,7 +1213,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
-				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
 				CODE_SIGN_ENTITLEMENTS = "Entitlements-Distribution.plist";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
 				COPY_PHASE_STRIP = YES;
@@ -1372,7 +1374,7 @@
 		C01FCF4F08A954540054247B /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				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;
@@ -1386,6 +1388,7 @@
 				GCC_DEBUGGING_SYMBOLS = full;
 				GCC_FAST_MATH = NO;
 				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
 				GCC_THUMB_SUPPORT = NO;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
@@ -1411,7 +1414,7 @@
 		C01FCF5008A954540054247B /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				FPC_COMMON_OPTIONS = "-dIPHONEOS -Cs2000000 -vwi -B  -Sgix";
--- a/project_files/HedgewarsMobile/Hedgewars_Prefix.pch	Fri May 28 20:13:47 2010 +0000
+++ b/project_files/HedgewarsMobile/Hedgewars_Prefix.pch	Mon May 31 19:33:42 2010 +0000
@@ -7,3 +7,17 @@
 #import <CoreGraphics/CoreGraphics.h>
 #import <UIKit/UIKit.h>
 #endif
+
+// by http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/
+#ifdef DEBUG
+  #define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
+  #define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
+#else
+  #define DLog(...) do { } while (0)
+  #ifndef NS_BLOCK_ASSERTIONS
+    #define NS_BLOCK_ASSERTIONS
+  #endif
+  #define ALog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
+#endif
+ 
+#define ZAssert(condition, ...) do { if (!(condition)) { ALog(__VA_ARGS__); }} while(0)