perform an additional check on gamestart
authorkoda
Sat, 06 Nov 2010 19:40:49 +0100
changeset 4150 050163c35c83
parent 4149 51200479f9d8
child 4151 08b95ec1bfdf
perform an additional check on gamestart
hedgewars/PascalExports.pas
project_files/HedgewarsMobile/Classes/GameConfigViewController.m
project_files/HedgewarsMobile/Resources/Settings/iFrontend/gameFlags_en.plist
--- a/hedgewars/PascalExports.pas	Sat Nov 06 18:21:30 2010 +0100
+++ b/hedgewars/PascalExports.pas	Sat Nov 06 19:40:49 2010 +0100
@@ -194,7 +194,8 @@
 
 function HW_isAmmoMenuNotAllowed: boolean; cdecl; export;
 begin;
-    exit ( (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) );
+    exit ( (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or
+           ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) );
 end;
 
 function HW_isPaused: boolean; cdecl; export;
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Sat Nov 06 18:21:30 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Sat Nov 06 19:40:49 2010 +0100
@@ -140,7 +140,7 @@
         [alert release];
         return NO;
     }
-    
+
     // play only if there is more than one team
     if ([self.teamConfigViewController.listOfSelectedTeams count] < 2) {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too few teams playing",@"")
@@ -152,7 +152,7 @@
         [alert release];
         return NO;
     }
-    
+
     // play if there's room for enough hogs in the selected map
     int hogs = 0;
     for (NSDictionary *teamData in teamConfigViewController.listOfSelectedTeams)
@@ -168,7 +168,8 @@
         [alert release];
         return NO;
     }
-    
+
+    // play if there aren't too many teams
     if ([self.teamConfigViewController.listOfSelectedTeams count] > HW_getMaxNumberOfTeams()) {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many teams",@"")
                                                         message:NSLocalizedString(@"Max six teams are allowed in the same game",@"")
@@ -179,7 +180,8 @@
         [alert release];
         return NO;
     }
-    
+
+    // play only if one scheme and one weapon are selected
     if ([self.schemeWeaponConfigViewController.selectedScheme length] == 0 || [self.schemeWeaponConfigViewController.selectedWeapon length] == 0 ) {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Missing detail",@"")
                                                         message:NSLocalizedString(@"Select one Scheme and one Weapon for this game",@"")
@@ -191,6 +193,21 @@
         return NO;
     }
 
+    // play if the gameflags are set correctly (divideteam works only with 2 teams
+    NSString *schemePath = [[NSString alloc] initWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),self.schemeWeaponConfigViewController.selectedScheme];
+    NSArray *gameFlags = [[NSDictionary dictionaryWithContentsOfFile:schemePath] objectForKey:@"gamemod"];
+    [schemePath release];
+    if ([[gameFlags objectAtIndex:2] boolValue] && [self.teamConfigViewController.listOfSelectedTeams count] != 2) {
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Scheme mismatch",@"")
+                                                        message:NSLocalizedString(@"The scheme you selected allows only for two teams",@"")
+                                                       delegate:nil
+                                              cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"")
+                                              otherButtonTitles:nil];
+        [alert show];
+        [alert release];
+        return NO;
+    }
+
     return YES;
 }
 
--- a/project_files/HedgewarsMobile/Resources/Settings/iFrontend/gameFlags_en.plist	Sat Nov 06 18:21:30 2010 +0100
+++ b/project_files/HedgewarsMobile/Resources/Settings/iFrontend/gameFlags_en.plist	Sat Nov 06 19:40:49 2010 +0100
@@ -20,11 +20,11 @@
 	</dict>
 	<dict>
 		<key>description</key>
-		<string>Teams will start on opposite sides of the terrain (two teams only)</string>
+		<string>Teams will start on opposite sides of the terrain</string>
 		<key>image</key>
 		<string>TeamsDivide</string>
 		<key>title</key>
-		<string>Divide Team</string>
+		<string>Divide Team (max 2 teams)</string>
 	</dict>
 	<dict>
 		<key>description</key>
@@ -84,7 +84,7 @@
 	</dict>
 	<dict>
 		<key>description</key>
-		<string>Defend your fort and destroy the opponents (two teams only)</string>
+		<string>Defend your fort and destroy the opponents</string>
 		<key>image</key>
 		<string>Forts</string>
 		<key>title</key>