disable AI teleport
authorkoda
Sat, 14 Aug 2010 02:10:27 +0200
changeset 3739 97cf933e5bd2
parent 3738 f10626e18b8a
child 3740 2e7dda50fddd
child 3741 73246d25dfe1
disable AI teleport show on screen controls only if hedgehog is not a hog fix reloading of teams
hedgewars/PascalExports.pas
hedgewars/hwengine.pas
hedgewars/uAIAmmoTests.pas
project_files/HedgewarsMobile/Classes/GameConfigViewController.m
project_files/HedgewarsMobile/Classes/OverlayViewController.m
project_files/HedgewarsMobile/Classes/TeamConfigViewController.h
project_files/HedgewarsMobile/Classes/TeamConfigViewController.m
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
project_files/HedgewarsMobile/Resources/MainMenuViewController-iPad.xib
--- a/hedgewars/PascalExports.pas	Fri Aug 13 02:44:44 2010 +0200
+++ b/hedgewars/PascalExports.pas	Sat Aug 14 02:10:27 2010 +0200
@@ -202,7 +202,7 @@
 
 function HW_isWeaponRequiringClick: boolean; cdecl; export;
 begin
-    if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then
+    if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
         exit( (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0 )
     else
         exit(false);
@@ -213,12 +213,15 @@
 begin
     CurSlot:= CurrentHedgehog^.CurSlot;
     CurAmmo:= CurrentHedgehog^.CurAmmo;
-    exit( (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0)
+    if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
+        exit( (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0)
+    else
+        exit(false);
 end;
 
 function HW_isWeaponSwitch: boolean cdecl; export;
 begin
-    if CurAmmoGear <> nil then
+    if (CurAmmoGear <> nil) and (CurrentHedgehog^.BotLevel = 0) then
         exit(CurAmmoGear^.AmmoType = amSwitch)
     else
         exit(false)
@@ -229,7 +232,10 @@
 begin
     CurSlot:= CurrentHedgehog^.CurSlot;
     CurAmmo:= CurrentHedgehog^.CurAmmo;
-    exit (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].AmmoType = amRope)
+    if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then
+        exit (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].AmmoType = amRope)
+    else
+        exit(false);
 end;
 
 procedure HW_setGrenadeTime(time: LongInt); cdecl; export;
@@ -243,7 +249,8 @@
     CurSlot:= CurrentHedgehog^.CurSlot;
     CurAmmo:= CurrentHedgehog^.CurAmmo;
     // this most likely won't work in network game
-    if (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].AmmoType = amPiano) then
+    if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0)
+       and (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].AmmoType = amPiano) then
         case snd of
             0: PlaySound(sndPiano0);
             1: PlaySound(sndPiano1);
@@ -256,8 +263,6 @@
             else PlaySound(sndPiano8);
         end;
 end;
-
-//amSwitch
 {$ENDIF}
 
 end.
--- a/hedgewars/hwengine.pas	Fri Aug 13 02:44:44 2010 +0200
+++ b/hedgewars/hwengine.pas	Sat Aug 14 02:10:27 2010 +0200
@@ -216,7 +216,7 @@
 {$IFDEF DEBUGFILE}
     cShowFPS:= true;
 {$ELSE}
-    cShowFPS:= true;    // update me at release time
+    cShowFPS:= false;    // update me at release time
 {$ENDIF}
     cInitVolume:= 100;
 
--- a/hedgewars/uAIAmmoTests.pas	Fri Aug 13 02:44:44 2010 +0200
+++ b/hedgewars/uAIAmmoTests.pas	Sat Aug 14 02:10:27 2010 +0200
@@ -71,7 +71,8 @@
             (proc: nil;              flags: 0), // amMineStrike
             (proc: nil;              flags: 0), // amBlowTorch
             (proc: nil;              flags: 0), // amGirder
-            (proc: @TestTeleport;    flags: amtest_OnTurn), // amTeleport
+            (proc: nil;              flags: 0), // amTeleport
+            //(proc: @TestTeleport;    flags: amtest_OnTurn), // amTeleport
             (proc: nil;              flags: 0), // amSwitch
             (proc: @TestMortar;      flags: 0), // amMortar
             (proc: nil;              flags: 0), // amKamikaze
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Fri Aug 13 02:44:44 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Sat Aug 14 02:10:27 2010 +0200
@@ -33,10 +33,8 @@
                                                       otherButtonTitles:nil];
                 [alert show];
                 [alert release];
-            } else {
+            } else
                 [[self parentViewController] dismissModalViewControllerAnimated:YES];
-
-            }
             break;
         case 1:
             theButton.enabled = NO;
@@ -230,6 +228,20 @@
     [super viewDidAppear:animated];
 }
 
+-(void) viewWillDisappear:(BOOL)animated {
+    [mapConfigViewController viewWillDisappear:animated];
+    [teamConfigViewController viewWillDisappear:animated];
+    [schemeWeaponConfigViewController viewWillDisappear:animated];
+    [super viewWillDisappear:animated];
+}
+
+-(void) viewDidDisappear:(BOOL)animated {
+    [mapConfigViewController viewDidDisappear:animated];
+    [teamConfigViewController viewDidDisappear:animated];
+    [schemeWeaponConfigViewController viewDidDisappear:animated];
+    [super viewDidDisappear:animated];
+}
+
 -(void) didReceiveMemoryWarning {
     if (activeController.view.superview == nil)
         activeController = nil;
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Fri Aug 13 02:44:44 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sat Aug 14 02:10:27 2010 +0200
@@ -133,8 +133,6 @@
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
     SDL_VideoDisplay *display = &_this->displays[0];
     sdlwindow = display->windows;
-
-    doDim();
 }
 
 -(void) viewDidUnload {
--- a/project_files/HedgewarsMobile/Classes/TeamConfigViewController.h	Fri Aug 13 02:44:44 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/TeamConfigViewController.h	Sat Aug 14 02:10:27 2010 +0200
@@ -12,10 +12,11 @@
 @interface TeamConfigViewController : UITableViewController {
     NSMutableArray *listOfTeams;
     NSMutableArray *listOfSelectedTeams;
-    BOOL isFirstLoad;
+    NSArray *cachedContentsOfDir;
 }
 
 @property (nonatomic, retain) NSMutableArray *listOfTeams;
 @property (nonatomic, retain) NSMutableArray *listOfSelectedTeams;
+@property (nonatomic, retain) NSArray *cachedContentsOfDir;
 
 @end
--- a/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m	Fri Aug 13 02:44:44 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m	Sat Aug 14 02:10:27 2010 +0200
@@ -12,7 +12,7 @@
 #import "SquareButtonView.h"
 
 @implementation TeamConfigViewController
-@synthesize listOfTeams, listOfSelectedTeams;
+@synthesize listOfTeams, listOfSelectedTeams, cachedContentsOfDir;
 
 #define NUMBERBUTTON_TAG 123456
 #define SQUAREBUTTON_TAG 654321
@@ -25,7 +25,6 @@
 
     CGSize screenSize = [[UIScreen mainScreen] bounds].size;
     self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
-    isFirstLoad = YES;
     
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
         [self.tableView setBackgroundView:nil];
@@ -38,11 +37,11 @@
 -(void) viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
 
+    NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
     // avoid overwriting selected teams when returning on this view
-    if (isFirstLoad) {
+    if ([cachedContentsOfDir isEqualToArray:contentsOfDir] == NO) {
         // integer representation of various color (defined in SquareButtonView)
         NSUInteger colors[6] = { 4421353, 4100897, 10632635, 16749353, 14483456, 7566195 };
-        NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
         NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:[contentsOfDir count]];
         for (int i = 0; i < [contentsOfDir count]; i++) {
             NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
@@ -58,7 +57,8 @@
         NSMutableArray *emptyArray = [[NSMutableArray alloc] initWithObjects:nil];
         self.listOfSelectedTeams = emptyArray;
         [emptyArray release];
-        isFirstLoad = NO;
+        
+        cachedContentsOfDir = [[NSArray alloc] initWithArray:contentsOfDir copyItems:YES];
     }
     [self.tableView reloadData];
 }
@@ -191,17 +191,22 @@
     // Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];
     // Relinquish ownership any cached data, images, etc that aren't in use.
+    self.cachedContentsOfDir = nil;
 }
 
 -(void) viewDidUnload {
     self.listOfTeams = nil;
+    self.listOfSelectedTeams = nil;
+    self.cachedContentsOfDir = nil;
     MSG_DIDUNLOAD();
     [super viewDidUnload];
 }
 
 
 -(void) dealloc {
-    [self.listOfTeams release];
+    [listOfTeams release];
+    [listOfSelectedTeams release];
+    [cachedContentsOfDir release];
     [super dealloc];
 }
 
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Fri Aug 13 02:44:44 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Sat Aug 14 02:10:27 2010 +0200
@@ -2020,7 +2020,7 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
-			shellScript = "#copy new stuff over old stuff\nrm -rf ${PROJECT_DIR}/Data\ncp -R ${PROJECT_DIR}/../../share/hedgewars/Data ${PROJECT_DIR}/Data\n\n#copy some files from QTfrontend/res\nmkdir ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/btn*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/ammopic.png ${PROJECT_DIR}/Data/Graphics/Btn/iconAmmo.png\ncp ${PROJECT_DIR}/../../QTfrontend/res/icon*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp -R ${PROJECT_DIR}/../../QTfrontend/res/botlevels ${PROJECT_DIR}/Data/Graphics/Hedgehog/botlevels\n\n#delete all CMakeLists.txt and image source files\nfind ${PROJECT_DIR}/Data -name CMakeLists.txt -delete\nfind ${PROJECT_DIR}/Data -name *.svg -delete\nfind ${PROJECT_DIR}/Data -name *.sifz -delete\nfind ${PROJECT_DIR}/Data -name *.xcf -delete\n\n#delete desktop frontend translation\nrm -rf ${PROJECT_DIR}/Data/Locale/hedgewars_*\n\n#delete dummy maps\nrm -rf ${PROJECT_DIR}/Data/Maps/{test*,KnockBall,Ruler,BasketBall}\n\n#the following ones must be removed when their support is implemented\n\n#delete some voices\nrm -rf ${PROJECT_DIR}/Data/Sounds/voices/{Classic,British,Mobster,Pirate,Robot,Russian,Singer,Surfer}\n\n#delete all names\nrm -rf ${PROJECT_DIR}/Data/Names/\n\n#delete all missions\nrm -rf ${PROJECT_DIR}/Data/Missions/\n\n#delete all reserved hats\nrm -rf ${PROJECT_DIR}/Data/Graphics/Hats/Reserved/";
+			shellScript = "#copy new stuff over old stuff\nrm -rf ${PROJECT_DIR}/Data\ncp -R ${PROJECT_DIR}/../../share/hedgewars/Data ${PROJECT_DIR}/Data\n\n#copy some files from QTfrontend/res\nmkdir ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/btn*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp ${PROJECT_DIR}/../../QTfrontend/res/ammopic.png ${PROJECT_DIR}/Data/Graphics/Btn/iconAmmo.png\ncp ${PROJECT_DIR}/../../QTfrontend/res/icon*.png ${PROJECT_DIR}/Data/Graphics/Btn\ncp -R ${PROJECT_DIR}/../../QTfrontend/res/botlevels ${PROJECT_DIR}/Data/Graphics/Hedgehog/botlevels\n\n#delete all CMakeLists.txt and image source files\nfind ${PROJECT_DIR}/Data -name CMakeLists.txt -delete\nfind ${PROJECT_DIR}/Data -name *.svg -delete\nfind ${PROJECT_DIR}/Data -name *.sifz -delete\nfind ${PROJECT_DIR}/Data -name *.xcf -delete\n\n#delete desktop frontend translation\nrm -rf ${PROJECT_DIR}/Data/Locale/hedgewars_*\n\n#delete dummy maps\nrm -rf ${PROJECT_DIR}/Data/Maps/{test*,KnockBall,Ruler,BasketBall}\n\n#delete forbidden maps\nrm -rf ${PROJECT_DIR}/Data/Maps/{Cheese}\nrm -rf ${PROJECT_DIR}/Data/Themes/City/Flake.png\n\n#the following ones must be removed when their support is implemented\n\n#delete some voices\nrm -rf ${PROJECT_DIR}/Data/Sounds/voices/{Classic,British,Mobster,Robot,Russian,Singer,Surfer}\n\n#delete all names\nrm -rf ${PROJECT_DIR}/Data/Names/\n\n#delete all missions\nrm -rf ${PROJECT_DIR}/Data/Missions/\n\n#delete all reserved hats\nrm -rf ${PROJECT_DIR}/Data/Graphics/Hats/Reserved/";
 			showEnvVarsInLog = 0;
 		};
 		9283011B0F10CB2D00CC5A3C /* Build libfpc.a */ = {
--- a/project_files/HedgewarsMobile/Resources/MainMenuViewController-iPad.xib	Fri Aug 13 02:44:44 2010 +0200
+++ b/project_files/HedgewarsMobile/Resources/MainMenuViewController-iPad.xib	Sat Aug 14 02:10:27 2010 +0200
@@ -57,7 +57,7 @@
 					<object class="IBUIButton" id="867308721">
 						<reference key="NSNextResponder" ref="191373211"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{383, 444}, {258, 215}}</string>
+						<string key="NSFrame">{{383, 444}, {263, 244}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<string key="targetRuntimeIdentifier">IBIPadFramework</string>
@@ -68,7 +68,7 @@
 							<double key="NSSize">15</double>
 							<int key="NSfFlags">16</int>
 						</object>
-						<double key="IBUITitleEdgeInsets.top">188</double>
+						<double key="IBUITitleEdgeInsets.top">215</double>
 						<double key="IBUITitleEdgeInsets.bottom">0.0</double>
 						<double key="IBUITitleEdgeInsets.left">0.0</double>
 						<double key="IBUITitleEdgeInsets.right">0.0</double>
@@ -93,7 +93,7 @@
 					<object class="IBUIButton" id="607338789">
 						<reference key="NSNextResponder" ref="191373211"/>
 						<int key="NSvFlags">-2147483356</int>
-						<string key="NSFrame">{{611, 417}, {258, 215}}</string>
+						<string key="NSFrame">{{611, 417}, {263, 244}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<int key="IBUITag">1</int>
@@ -101,7 +101,7 @@
 						<int key="IBUIContentHorizontalAlignment">0</int>
 						<int key="IBUIContentVerticalAlignment">0</int>
 						<reference key="IBUIFont" ref="917635782"/>
-						<double key="IBUITitleEdgeInsets.top">188</double>
+						<double key="IBUITitleEdgeInsets.top">215</double>
 						<double key="IBUITitleEdgeInsets.bottom">0.0</double>
 						<double key="IBUITitleEdgeInsets.left">0.0</double>
 						<double key="IBUITitleEdgeInsets.right">0.0</double>