Completed
Push — work-fleets ( 77506a...17c73c )
by SuperNova.WS
05:37
created
includes/classes/Fleet.php 1 patch
Spacing   +144 added lines, -145 removed lines patch added patch discarded remove patch
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
316 316
   public function renderAvailableShips(&$template_result, $playerRow, $planetRow) {
317 317
     $record_index = 0;
318 318
     $ship_list = array();
319
-    foreach(sn_get_groups('fleet') as $n => $unit_id) {
319
+    foreach (sn_get_groups('fleet') as $n => $unit_id) {
320 320
       $unit_level = mrc_get_level($playerRow, $planetRow, $unit_id, false, true);
321
-      if($unit_level <= 0) {
321
+      if ($unit_level <= 0) {
322 322
         continue;
323 323
       }
324 324
       $ship_data = get_ship_data($unit_id, $playerRow);
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 
340 340
     sortUnitRenderedList($ship_list, classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT], classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE]);
341 341
 
342
-    foreach($ship_list as $ship_data) {
342
+    foreach ($ship_list as $ship_data) {
343 343
       $template_result['.']['ships'][] = $ship_data;
344 344
     }
345 345
   }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
   public function dbInsert() {
359 359
     // WARNING! MISSION TIMES MUST BE SET WITH set_times() method!
360 360
     // TODO - more checks!
361
-    if(empty($this->_time_launch)) {
361
+    if (empty($this->_time_launch)) {
362 362
       die('Fleet time not set!');
363 363
     }
364 364
 
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
     // Записываем изменения в БД
568 568
     $this->dbSave();
569 569
 
570
-    if($this->_group_id) {
570
+    if ($this->_group_id) {
571 571
       // TODO: Make here to delete only one AKS - by adding aks_fleet_count to AKS table
572 572
       db_fleet_aks_purge();
573 573
     }
@@ -634,18 +634,18 @@  discard block
 block discarded – undo
634 634
    */
635 635
   // TODO - separate shipList and unitList
636 636
   public function unitsSetFromArray($unit_array) {
637
-    if(empty($unit_array) || !is_array($unit_array)) {
637
+    if (empty($unit_array) || !is_array($unit_array)) {
638 638
       return;
639 639
     }
640
-    foreach($unit_array as $unit_id => $unit_count) {
640
+    foreach ($unit_array as $unit_id => $unit_count) {
641 641
       $unit_count = floatval($unit_count);
642
-      if(!$unit_count) {
642
+      if (!$unit_count) {
643 643
         continue;
644 644
       }
645 645
 
646
-      if($this->isShip($unit_id)) {
646
+      if ($this->isShip($unit_id)) {
647 647
         $this->unitList->unitSetCount($unit_id, $unit_count);
648
-      } elseif($this->isResource($unit_id)) {
648
+      } elseif ($this->isResource($unit_id)) {
649 649
         $this->resource_list[$unit_id] = $unit_count;
650 650
       } else {
651 651
         throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR);
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
   public function parse_missile_db_row($missile_db_row) {
675 675
 //    $this->_reset();
676 676
 
677
-    if(empty($missile_db_row) || !is_array($missile_db_row)) {
677
+    if (empty($missile_db_row) || !is_array($missile_db_row)) {
678 678
       return;
679 679
     }
680 680
 
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
   public function shipsGetCapacityRecyclers(array $recycler_info) {
838 838
     $recyclers_incoming_capacity = 0;
839 839
     $fleet_data = $this->shipsGetArray();
840
-    foreach($recycler_info as $recycler_id => $recycler_data) {
840
+    foreach ($recycler_info as $recycler_id => $recycler_data) {
841 841
       $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity'];
842 842
     }
843 843
 
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
     sn_db_transaction_check(true);
858 858
 
859 859
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
860
-    if($this->isEmpty()) {
860
+    if ($this->isEmpty()) {
861 861
       return $result;
862 862
     }
863 863
 
@@ -879,18 +879,18 @@  discard block
 block discarded – undo
879 879
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
880 880
     // Флот, который возвращается на захваченную планету, пропадает
881 881
     // Ship landing is possible only to fleet owner's planet
882
-    if($this->getPlayerOwnerId() == $planet_arrival['id_owner']) {
882
+    if ($this->getPlayerOwnerId() == $planet_arrival['id_owner']) {
883 883
       $db_changeset = array();
884 884
 
885 885
       $fleet_array = $this->shipsGetArray();
886
-      foreach($fleet_array as $ship_id => $ship_count) {
887
-        if($ship_count) {
886
+      foreach ($fleet_array as $ship_id => $ship_count) {
887
+        if ($ship_count) {
888 888
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $planet_arrival['id']);
889 889
         }
890 890
       }
891 891
 
892 892
       // Adjusting ship amount on planet
893
-      if(!empty($db_changeset)) {
893
+      if (!empty($db_changeset)) {
894 894
         db_changeset_apply($db_changeset);
895 895
       }
896 896
 
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
    * @param array $resource_list
939 939
    */
940 940
   public function resourcesSet($resource_list) {
941
-    if(!empty($this->propertiesAdjusted['resource_list'])) {
941
+    if (!empty($this->propertiesAdjusted['resource_list'])) {
942 942
       throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
943 943
     }
944 944
     $this->resourcesAdjust($resource_list, true);
@@ -952,13 +952,13 @@  discard block
 block discarded – undo
952 952
   public function resourcesAdjust($resource_delta_list, $replace_value = false) {
953 953
     !is_array($resource_delta_list) ? $resource_delta_list = array() : false;
954 954
 
955
-    foreach($resource_delta_list as $resource_id => $unit_delta) {
956
-      if(!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
955
+    foreach ($resource_delta_list as $resource_id => $unit_delta) {
956
+      if (!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
957 957
         // Not a resource or no resources - continuing
958 958
         continue;
959 959
       }
960 960
 
961
-      if($replace_value) {
961
+      if ($replace_value) {
962 962
         $this->resource_list[$resource_id] = $unit_delta;
963 963
       } else {
964 964
         $this->resource_list[$resource_id] += $unit_delta;
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
       }
969 969
 
970 970
       // Check for negative unit value
971
-      if($this->resource_list[$resource_id] < 0) {
971
+      if ($this->resource_list[$resource_id] < 0) {
972 972
         // TODO
973 973
         throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
974 974
       }
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
     sn_db_transaction_check(true);
1021 1021
 
1022 1022
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
1023
-    if(!$this->resourcesGetTotal()) {
1023
+    if (!$this->resourcesGetTotal()) {
1024 1024
       return $result;
1025 1025
     }
1026 1026
 
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
1041 1041
 
1042 1042
     // Restoring resources to planet
1043
-    if($this->resourcesGetTotal()) {
1043
+    if ($this->resourcesGetTotal()) {
1044 1044
       $fleet_resources = $this->resourcesGetList();
1045 1045
       db_planet_set_by_id($planet_arrival['id'],
1046 1046
         "`metal` = `metal` + '{$fleet_resources[RES_METAL]}', `crystal` = `crystal` + '{$fleet_resources[RES_CRYSTAL]}', `deuterium` = `deuterium` + '{$fleet_resources[RES_DEUTERIUM]}'");
@@ -1106,12 +1106,12 @@  discard block
 block discarded – undo
1106 1106
 
1107 1107
   protected function populateTargetPlanet() {
1108 1108
     $targetPlanetCoords = $this->targetVector;
1109
-    if($this->mission_type != MT_NONE) {
1109
+    if ($this->mission_type != MT_NONE) {
1110 1110
       $this->restrictTargetTypeByMission();
1111 1111
 
1112 1112
       // TODO - Нельзя тут просто менять тип планеты или координат!
1113 1113
       // If current planet type is not allowed on mission - switch planet type
1114
-      if(empty($this->allowed_planet_types[$this->targetVector->type])) {
1114
+      if (empty($this->allowed_planet_types[$this->targetVector->type])) {
1115 1115
         $targetPlanetCoords->type = reset($this->allowed_planet_types);
1116 1116
       }
1117 1117
     }
@@ -1120,14 +1120,14 @@  discard block
 block discarded – undo
1120 1120
   }
1121 1121
 
1122 1122
   protected function restrictTargetTypeByMission() {
1123
-    if($this->_mission_type == MT_MISSILE) {
1123
+    if ($this->_mission_type == MT_MISSILE) {
1124 1124
       $this->allowed_planet_types = array(PT_PLANET => PT_PLANET);
1125
-    } elseif($this->_mission_type == MT_COLONIZE || $this->_mission_type == MT_EXPLORE) {
1125
+    } elseif ($this->_mission_type == MT_COLONIZE || $this->_mission_type == MT_EXPLORE) {
1126 1126
       // TODO - PT_NONE
1127 1127
       $this->allowed_planet_types = array(PT_PLANET => PT_PLANET);
1128
-    } elseif($this->_mission_type == MT_RECYCLE) {
1128
+    } elseif ($this->_mission_type == MT_RECYCLE) {
1129 1129
       $this->allowed_planet_types = array(PT_DEBRIS => PT_DEBRIS);
1130
-    } elseif($this->_mission_type == MT_DESTROY) {
1130
+    } elseif ($this->_mission_type == MT_DESTROY) {
1131 1131
       $this->allowed_planet_types = array(PT_MOON => PT_MOON);
1132 1132
     } else {
1133 1133
       $this->allowed_planet_types = array(PT_PLANET => PT_PLANET, PT_MOON => PT_MOON);
@@ -1159,13 +1159,13 @@  discard block
 block discarded – undo
1159 1159
 
1160 1160
 
1161 1161
   public function restrictToKnownSpace() {
1162
-    if(!$this->targetVector->isInKnownSpace()) {
1162
+    if (!$this->targetVector->isInKnownSpace()) {
1163 1163
       throw new Exception('FLIGHT_VECTOR_BEYOND_SYSTEM', FLIGHT_VECTOR_BEYOND_SYSTEM);
1164 1164
     }
1165 1165
   }
1166 1166
 
1167 1167
   public function restrictToTypePlanet($errorCode) {
1168
-    if($this->targetVector->type != PT_PLANET) {
1168
+    if ($this->targetVector->type != PT_PLANET) {
1169 1169
       throw new Exception($errorCode, $errorCode);
1170 1170
     }
1171 1171
   }
@@ -1173,56 +1173,56 @@  discard block
 block discarded – undo
1173 1173
   public function restrictToNoMissiles() {
1174 1174
     $missilesAttack = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERPLANET);
1175 1175
     $missilesDefense = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERCEPTOR);
1176
-    if($missilesAttack > 0 || $missilesDefense > 0) {
1176
+    if ($missilesAttack > 0 || $missilesDefense > 0) {
1177 1177
       throw new Exception('FLIGHT_SHIPS_NO_MISSILES', FLIGHT_SHIPS_NO_MISSILES);
1178 1178
     }
1179 1179
   }
1180 1180
 
1181 1181
   public function restrictToTargetOwn() {
1182
-    if($this->dbTargetRow['id'] != $this->getPlayerOwnerId()) {
1182
+    if ($this->dbTargetRow['id'] != $this->getPlayerOwnerId()) {
1183 1183
       throw new Exception('FLIGHT_VECTOR_ONLY_OWN', FLIGHT_VECTOR_ONLY_OWN);
1184 1184
     }
1185 1185
   }
1186 1186
 
1187 1187
   public function restrictToTargetOther() {
1188
-    if($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) {
1188
+    if ($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) {
1189 1189
       throw new Exception('FLIGHT_VECTOR_ONLY_OTHER', FLIGHT_VECTOR_ONLY_OTHER);
1190 1190
     }
1191 1191
   }
1192 1192
 
1193 1193
   public function restrictToNotOnlySpies() {
1194
-    if($this->unitList->unitsCountById(SHIP_SPY) == $this->shipsGetTotal()) {
1194
+    if ($this->unitList->unitsCountById(SHIP_SPY) == $this->shipsGetTotal()) {
1195 1195
       throw new Exception('FLIGHT_SHIPS_NOT_ONLY_SPIES', FLIGHT_SHIPS_NOT_ONLY_SPIES);
1196 1196
     }
1197 1197
   }
1198 1198
 
1199 1199
   protected function restrictToUniverse() {
1200
-    if(!$this->targetVector->isInUniverse()) {
1200
+    if (!$this->targetVector->isInUniverse()) {
1201 1201
       throw new Exception('FLIGHT_VECTOR_BEYOND_UNIVERSE', FLIGHT_VECTOR_BEYOND_UNIVERSE);
1202 1202
     }
1203 1203
   }
1204 1204
 
1205 1205
   protected function restrictToMovable() {
1206
-    if(!$this->unitList->unitsIsAllMovable($this->dbOwnerRow)) {
1206
+    if (!$this->unitList->unitsIsAllMovable($this->dbOwnerRow)) {
1207 1207
       throw new Exception('FLIGHT_SHIPS_UNMOVABLE', FLIGHT_SHIPS_UNMOVABLE);
1208 1208
     }
1209 1209
   }
1210 1210
 
1211 1211
   protected function restrictToFleetUnits() {
1212
-    if(!$this->unitList->unitsInGroup(sn_get_groups(array('fleet', 'missile')))) {
1212
+    if (!$this->unitList->unitsInGroup(sn_get_groups(array('fleet', 'missile')))) {
1213 1213
       throw new Exception('FLIGHT_SHIPS_UNIT_WRONG', FLIGHT_SHIPS_UNIT_WRONG);
1214 1214
     }
1215 1215
   }
1216 1216
 
1217 1217
   protected function restrictToColonizer() {
1218 1218
     // Colonization fleet should have at least one colonizer
1219
-    if(!$this->unitList->unitsCountById(SHIP_COLONIZER) <= 0) {
1219
+    if (!$this->unitList->unitsCountById(SHIP_COLONIZER) <= 0) {
1220 1220
       throw new Exception('FLIGHT_SHIPS_NO_COLONIZER', FLIGHT_SHIPS_NO_COLONIZER);
1221 1221
     }
1222 1222
   }
1223 1223
 
1224 1224
   protected function restrictToTargetExists() {
1225
-    if(empty($this->dbTargetRow) || empty($this->dbTargetRow['id'])) {
1225
+    if (empty($this->dbTargetRow) || empty($this->dbTargetRow['id'])) {
1226 1226
       throw new Exception('FLIGHT_VECTOR_NO_TARGET', FLIGHT_VECTOR_NO_TARGET);
1227 1227
     }
1228 1228
   }
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 
1231 1231
   protected function restrictKnownSpaceOrMissionExplore() {
1232 1232
     // Is it exploration - fleet sent beyond of system?
1233
-    if($this->targetVector->isInKnownSpace()) {
1233
+    if ($this->targetVector->isInKnownSpace()) {
1234 1234
       // No exploration beyond this point
1235 1235
       unset($this->allowed_missions[MT_EXPLORE]);
1236 1236
 
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
 
1249 1249
   protected function restrictTargetExistsOrMissionColonize() {
1250 1250
     // Is it colonization - fleet sent to empty place?
1251
-    if(!empty($this->dbTargetRow)) {
1251
+    if (!empty($this->dbTargetRow)) {
1252 1252
       // No colonization beyond this point
1253 1253
       unset($this->allowed_missions[MT_COLONIZE]);
1254 1254
 
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
   }
1268 1268
 
1269 1269
   protected function restrictNotDebrisOrMissionRecycle() {
1270
-    if($this->targetVector->type != PT_DEBRIS) {
1270
+    if ($this->targetVector->type != PT_DEBRIS) {
1271 1271
       // No recycling beyond this point
1272 1272
       unset($this->allowed_missions[MT_RECYCLE]);
1273 1273
 
@@ -1278,11 +1278,11 @@  discard block
 block discarded – undo
1278 1278
 
1279 1279
     // restrict to recyclers
1280 1280
     $recyclers = 0;
1281
-    foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
1281
+    foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
1282 1282
       $recyclers += $this->unitList->unitsCountById($recycler_id);
1283 1283
     }
1284 1284
 
1285
-    if($recyclers <= 0) {
1285
+    if ($recyclers <= 0) {
1286 1286
       throw new Exception('FLIGHT_SHIPS_NO_RECYCLERS', FLIGHT_SHIPS_NO_RECYCLERS);
1287 1287
     }
1288 1288
 
@@ -1293,14 +1293,14 @@  discard block
 block discarded – undo
1293 1293
 
1294 1294
   protected function restrictMissionMissile() {
1295 1295
     $missilesAttack = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERPLANET);
1296
-    if($missilesAttack <= 0) {
1296
+    if ($missilesAttack <= 0) {
1297 1297
       // No missile attack beyond this point
1298 1298
       unset($this->allowed_missions[MT_MISSILE]);
1299 1299
 
1300 1300
       return;
1301 1301
     }
1302 1302
 
1303
-    if($missilesAttack != $this->shipsGetTotal()) {
1303
+    if ($missilesAttack != $this->shipsGetTotal()) {
1304 1304
       throw new Exception('FLIGHT_SHIPS_ONLY_MISSILES', FLIGHT_SHIPS_ONLY_MISSILES);
1305 1305
     }
1306 1306
 
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
   }
1313 1313
 
1314 1314
   protected function restrictToNotOnlySpiesOrMissionSpy() {
1315
-    if($this->unitList->unitsCountById(SHIP_SPY) != $this->shipsGetTotal()) {
1315
+    if ($this->unitList->unitsCountById(SHIP_SPY) != $this->shipsGetTotal()) {
1316 1316
 //      throw new Exception('FLIGHT_SHIPS_ONLY_SPIES', FLIGHT_SHIPS_ONLY_SPIES);
1317 1317
       unset($this->allowed_missions[MT_SPY]);
1318 1318
 
@@ -1328,14 +1328,14 @@  discard block
 block discarded – undo
1328 1328
   protected function restrictMissionDestroy() {
1329 1329
     // If target vector is not Moon - then it can't be Destroy mission
1330 1330
     // If no Reapers (i.e. Death Star) in fleet - then mission Moon Destroy is unaccessible
1331
-    if($this->targetVector->type != PT_MOON || $this->unitList->unitsCountById(SHIP_HUGE_DEATH_STAR) <= 0) {
1331
+    if ($this->targetVector->type != PT_MOON || $this->unitList->unitsCountById(SHIP_HUGE_DEATH_STAR) <= 0) {
1332 1332
       unset($this->allowed_missions[MT_DESTROY]);
1333 1333
     }
1334 1334
   }
1335 1335
 
1336 1336
   protected function restrictMissionACS() {
1337 1337
     // If no ACS group is shown - then it can't be an ACS attack
1338
-    if(empty($this->_group_id)) {
1338
+    if (empty($this->_group_id)) {
1339 1339
       unset($this->allowed_missions[MT_ACS]);
1340 1340
     }
1341 1341
   }
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
   /** @throws Exception */
1344 1344
   protected function restrictFriendOrFoe() {
1345 1345
     // Checking target owner
1346
-    if($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) {
1346
+    if ($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) {
1347 1347
       // Spying can't be done on owner's planet/moon
1348 1348
       unset($this->allowed_missions[MT_SPY]);
1349 1349
       // Attack can't be done on owner's planet/moon
@@ -1399,51 +1399,51 @@  discard block
 block discarded – undo
1399 1399
   }
1400 1400
 
1401 1401
   protected function restrictToNotSource() {
1402
-    if($this->targetVector->isEqualToPlanet($this->dbSourcePlanetRow)) {
1402
+    if ($this->targetVector->isEqualToPlanet($this->dbSourcePlanetRow)) {
1403 1403
       throw new Exception('FLIGHT_VECTOR_SAME_SOURCE', FLIGHT_VECTOR_SAME_SOURCE);
1404 1404
     }
1405 1405
   }
1406 1406
 
1407 1407
   protected function restrictToNonVacationSender() {
1408
-    if(!empty($this->dbOwnerRow['vacation']) && $this->dbOwnerRow['vacation'] >= SN_TIME_NOW) {
1408
+    if (!empty($this->dbOwnerRow['vacation']) && $this->dbOwnerRow['vacation'] >= SN_TIME_NOW) {
1409 1409
       throw new Exception('FLIGHT_PLAYER_VACATION_OWN', FLIGHT_PLAYER_VACATION_OWN);
1410 1410
     }
1411 1411
   }
1412 1412
 
1413 1413
   protected function restrictToValidSpeedPercentOld() {
1414 1414
     $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
1415
-    if(!in_array($this->oldSpeedInTens, $speed_possible)) {
1415
+    if (!in_array($this->oldSpeedInTens, $speed_possible)) {
1416 1416
       throw new Exception('FLIGHT_FLEET_SPEED_WRONG', FLIGHT_FLEET_SPEED_WRONG);
1417 1417
     }
1418 1418
 
1419 1419
   }
1420 1420
 
1421 1421
   protected function restrict2ToAllowedMissions() {
1422
-    if(empty($this->allowed_missions[$this->_mission_type])) {
1422
+    if (empty($this->allowed_missions[$this->_mission_type])) {
1423 1423
       throw new Exception('FLIGHT_MISSION_IMPOSSIBLE', FLIGHT_MISSION_IMPOSSIBLE);
1424 1424
     }
1425 1425
   }
1426 1426
 
1427 1427
   protected function restrict2ToAllowedPlanetTypes() {
1428
-    if(empty($this->allowed_planet_types[$this->targetVector->type])) {
1428
+    if (empty($this->allowed_planet_types[$this->targetVector->type])) {
1429 1429
       throw new Exception('FLIGHT_MISSION_IMPOSSIBLE', FLIGHT_MISSION_IMPOSSIBLE);
1430 1430
     }
1431 1431
   }
1432 1432
 
1433 1433
   protected function restrict2ToMaxFleets() {
1434
-    if(FleetList::fleet_count_flying($this->getPlayerOwnerId()) >= GetMaxFleets($this->dbOwnerRow)) {
1434
+    if (FleetList::fleet_count_flying($this->getPlayerOwnerId()) >= GetMaxFleets($this->dbOwnerRow)) {
1435 1435
       throw new Exception('FLIGHT_FLEET_NO_SLOTS', FLIGHT_FLEET_NO_SLOTS);
1436 1436
     }
1437 1437
   }
1438 1438
 
1439 1439
   protected function restrict2ToEnoughShips() {
1440
-    if(!$this->unitList->shipsIsEnoughOnPlanet($this->dbSourcePlanetRow)) {
1440
+    if (!$this->unitList->shipsIsEnoughOnPlanet($this->dbSourcePlanetRow)) {
1441 1441
       throw new Exception('FLIGHT_SHIPS_NOT_ENOUGH', FLIGHT_SHIPS_NOT_ENOUGH);
1442 1442
     }
1443 1443
   }
1444 1444
 
1445 1445
   protected function restrict2ToEnoughCapacity($fleetCapacity, $fleetConsumption) {
1446
-    if(floor($fleetCapacity) < ceil(array_sum($this->resource_list) + $fleetConsumption)) {
1446
+    if (floor($fleetCapacity) < ceil(array_sum($this->resource_list) + $fleetConsumption)) {
1447 1447
       throw new Exception('FLIGHT_FLEET_OVERLOAD', FLIGHT_FLEET_OVERLOAD);
1448 1448
     }
1449 1449
   }
@@ -1451,13 +1451,13 @@  discard block
 block discarded – undo
1451 1451
   protected function restrict2ByResources($fleetConsumption) {
1452 1452
     $fleetResources = $this->resource_list;
1453 1453
     $fleetResources[RES_DEUTERIUM] = ceil($fleetResources[RES_DEUTERIUM] + $fleetConsumption);
1454
-    foreach($fleetResources as $resourceId => $resourceAmount) {
1455
-      if($fleetResources[$resourceId] < 0) {
1454
+    foreach ($fleetResources as $resourceId => $resourceAmount) {
1455
+      if ($fleetResources[$resourceId] < 0) {
1456 1456
         throw new Exception('FLIGHT_RESOURCES_NEGATIVE', FLIGHT_RESOURCES_NEGATIVE);
1457 1457
       }
1458 1458
 
1459
-      if(mrc_get_level($this->dbOwnerRow, $this->dbSourcePlanetRow, $resourceId) < ceil($fleetResources[$resourceId])) {
1460
-        if($resourceId == RES_DEUTERIUM) {
1459
+      if (mrc_get_level($this->dbOwnerRow, $this->dbSourcePlanetRow, $resourceId) < ceil($fleetResources[$resourceId])) {
1460
+        if ($resourceId == RES_DEUTERIUM) {
1461 1461
           throw new Exception('FLIGHT_RESOURCES_FUEL_NOT_ENOUGH', FLIGHT_RESOURCES_FUEL_NOT_ENOUGH);
1462 1462
         } else {
1463 1463
           throw new Exception('FLIGHT_RESOURCES_NOT_ENOUGH', FLIGHT_RESOURCES_NOT_ENOUGH);
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
 
1511 1511
 
1512 1512
   protected function printErrorIfNoShips() {
1513
-    if($this->unitList->unitsCount() <= 0) {
1513
+    if ($this->unitList->unitsCount() <= 0) {
1514 1514
       message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
1515 1515
     }
1516 1516
   }
@@ -1548,11 +1548,11 @@  discard block
 block discarded – undo
1548 1548
   protected function renderAllowedMissions(&$template_result) {
1549 1549
     ksort($this->allowed_missions);
1550 1550
     // If mission is not set - setting first mission from allowed
1551
-    if(empty($this->_mission_type) && is_array($this->allowed_missions)) {
1551
+    if (empty($this->_mission_type) && is_array($this->allowed_missions)) {
1552 1552
       reset($this->allowed_missions);
1553 1553
       $this->_mission_type = key($this->allowed_missions);
1554 1554
     }
1555
-    foreach($this->allowed_missions as $key => $value) {
1555
+    foreach ($this->allowed_missions as $key => $value) {
1556 1556
       $template_result['.']['missions'][] = array(
1557 1557
         'ID'   => $key,
1558 1558
         'NAME' => classLocale::$lang['type_mission'][$key],
@@ -1564,9 +1564,9 @@  discard block
 block discarded – undo
1564 1564
    * @param $template_result
1565 1565
    */
1566 1566
   protected function renderDuration(&$template_result, $max_duration) {
1567
-    if($max_duration) {
1567
+    if ($max_duration) {
1568 1568
       $config_game_speed_expedition = ($this->_mission_type == MT_EXPLORE && classSupernova::$config->game_speed_expedition ? classSupernova::$config->game_speed_expedition : 1);
1569
-      for($i = 1; $i <= $max_duration; $i++) {
1569
+      for ($i = 1; $i <= $max_duration; $i++) {
1570 1570
         $template_result['.']['duration'][] = array(
1571 1571
           'ID'   => $i,
1572 1572
           'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)),
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
   protected function renderPlanetResources(&$planetResources, &$template_result) {
1583 1583
     // TODO - REDO to resource_id
1584 1584
     $i = 0;
1585
-    foreach($planetResources as $resource_id => $resource_amount) {
1585
+    foreach ($planetResources as $resource_id => $resource_amount) {
1586 1586
       $template_result['.']['resources'][] = array(
1587 1587
         'ID'        => $i++, // $resource_id,
1588 1588
         'ON_PLANET' => $resource_amount,
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
    * @param $template_result
1597 1597
    */
1598 1598
   protected function renderAllowedPlanetTypes(&$template_result) {
1599
-    foreach($this->allowed_planet_types as $possible_planet_type_id) {
1599
+    foreach ($this->allowed_planet_types as $possible_planet_type_id) {
1600 1600
       $template_result['.']['possible_planet_type_id'][] = array(
1601 1601
         'ID'         => $possible_planet_type_id,
1602 1602
         'NAME'       => classLocale::$lang['sys_planet_type'][$possible_planet_type_id],
@@ -1619,14 +1619,14 @@  discard block
 block discarded – undo
1619 1619
       'TYPE_PRINT' => classLocale::$lang['fl_shrtcup'][$shortcut['planet_type']],
1620 1620
     );
1621 1621
 
1622
-    if(isset($shortcut['priority'])) {
1622
+    if (isset($shortcut['priority'])) {
1623 1623
       $result += array(
1624 1624
         'PRIORITY'       => $shortcut['priority'],
1625 1625
         'PRIORITY_CLASS' => $note_priority_classes[$shortcut['priority']],
1626 1626
       );
1627 1627
     }
1628 1628
 
1629
-    if(isset($shortcut['id'])) {
1629
+    if (isset($shortcut['id'])) {
1630 1630
       $result += array(
1631 1631
         'ID' => $shortcut['id'],
1632 1632
       );
@@ -1641,7 +1641,7 @@  discard block
 block discarded – undo
1641 1641
   protected function renderFleetShortcuts(&$template_result) {
1642 1642
     // Building list of shortcuts
1643 1643
     $query = db_note_list_select_by_owner_and_planet($this->dbOwnerRow);
1644
-    while($row = db_fetch($query)) {
1644
+    while ($row = db_fetch($query)) {
1645 1645
       $template_result['.']['shortcut'][] = $this->renderFleet1TargetSelect($row);
1646 1646
     }
1647 1647
   }
@@ -1653,12 +1653,12 @@  discard block
 block discarded – undo
1653 1653
    */
1654 1654
   protected function renderOwnPlanets(&$template_result) {
1655 1655
     $colonies = db_planet_list_sorted($this->dbOwnerRow);
1656
-    if(count($colonies) <= 1) {
1656
+    if (count($colonies) <= 1) {
1657 1657
       return;
1658 1658
     }
1659 1659
 
1660
-    foreach($colonies as $row) {
1661
-      if($row['id'] == $this->dbSourcePlanetRow['id']) {
1660
+    foreach ($colonies as $row) {
1661
+      if ($row['id'] == $this->dbSourcePlanetRow['id']) {
1662 1662
         continue;
1663 1663
       }
1664 1664
 
@@ -1671,10 +1671,10 @@  discard block
 block discarded – undo
1671 1671
    */
1672 1672
   protected function renderACSList(&$template_result) {
1673 1673
     $query = db_acs_get_list();
1674
-    while($row = db_fetch($query)) {
1674
+    while ($row = db_fetch($query)) {
1675 1675
       $members = explode(',', $row['eingeladen']);
1676
-      foreach($members as $a => $b) {
1677
-        if($b == $this->dbOwnerRow['id']) {
1676
+      foreach ($members as $a => $b) {
1677
+        if ($b == $this->dbOwnerRow['id']) {
1678 1678
           $template_result['.']['acss'][] = $this->renderFleet1TargetSelect($row);
1679 1679
         }
1680 1680
       }
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
    * @param $template_result
1686 1686
    */
1687 1687
   protected function renderShipSortOptions(&$template_result) {
1688
-    foreach(classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) {
1688
+    foreach (classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) {
1689 1689
       $template_result['.']['ship_sort_list'][] = array(
1690 1690
         'VALUE' => $sort_id,
1691 1691
         'TEXT'  => $sort_text,
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
 
1705 1705
     lng_include('overview');
1706 1706
 
1707
-    if(empty($this->dbSourcePlanetRow)) {
1707
+    if (empty($this->dbSourcePlanetRow)) {
1708 1708
       message(classLocale::$lang['fl_noplanetrow'], classLocale::$lang['fl_error']);
1709 1709
     }
1710 1710
 
@@ -1780,9 +1780,9 @@  discard block
 block discarded – undo
1780 1780
 
1781 1781
     try {
1782 1782
       $this->restrictMission();
1783
-    } catch(Exception $e) {
1783
+    } catch (Exception $e) {
1784 1784
       // TODO - MESSAGE BOX
1785
-      if($e->getCode() != FLIGHT_ALLOWED) {
1785
+      if ($e->getCode() != FLIGHT_ALLOWED) {
1786 1786
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1787 1787
       } else {
1788 1788
         pdump('FLIGHT_ALLOWED', FLIGHT_ALLOWED);
@@ -1792,20 +1792,19 @@  discard block
 block discarded – undo
1792 1792
     $this->renderAllowedMissions($template_result);
1793 1793
     $this->renderFleet($template_result);
1794 1794
 
1795
-    $max_duration = $this->_mission_type == MT_EXPLORE ? get_player_max_expedition_duration($this->dbOwnerRow) :
1796
-      (isset($this->allowed_missions[MT_HOLD]) ? 12 : 0);
1795
+    $max_duration = $this->_mission_type == MT_EXPLORE ? get_player_max_expedition_duration($this->dbOwnerRow) : (isset($this->allowed_missions[MT_HOLD]) ? 12 : 0);
1797 1796
     $this->renderDuration($template_result, $max_duration);
1798 1797
 
1799 1798
     $travel_data = $this->flt_travel_data($this->oldSpeedInTens);
1800 1799
 
1801 1800
     $sn_group_resources = sn_get_groups('resources_loot');
1802 1801
     $planetResources = array();
1803
-    foreach($sn_group_resources as $resource_id) {
1802
+    foreach ($sn_group_resources as $resource_id) {
1804 1803
       $planetResources[$resource_id] = floor(mrc_get_level($this->dbOwnerRow, $this->dbSourcePlanetRow, $resource_id) - ($resource_id == RES_DEUTERIUM ? $travel_data['consumption'] : 0));
1805 1804
     }
1806 1805
     $this->renderPlanetResources($planetResources, $template_result);
1807 1806
 
1808
-    if(sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($this->dbSourcePlanetRow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
1807
+    if (sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($this->dbSourcePlanetRow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
1809 1808
       $template_result += array(
1810 1809
         'CAPTAIN_ID'     => $captain['unit_id'],
1811 1810
         'CAPTAIN_LEVEL'  => $captain['captain_level'],
@@ -1841,24 +1840,24 @@  discard block
 block discarded – undo
1841 1840
 
1842 1841
 
1843 1842
   public function restrict2MissionTransportWithResources($fleetResources) {
1844
-    if($this->_mission_type != MT_TRANSPORT) {
1843
+    if ($this->_mission_type != MT_TRANSPORT) {
1845 1844
       return;
1846 1845
     }
1847 1846
 
1848
-    if(array_sum($fleetResources) <= 0) {
1847
+    if (array_sum($fleetResources) <= 0) {
1849 1848
       throw new Exception('FLIGHT_RESOURCES_EMPTY', FLIGHT_RESOURCES_EMPTY);
1850 1849
     }
1851 1850
   }
1852 1851
 
1853 1852
   protected function restrict2MissionExploreAvailable() {
1854
-    if($this->_mission_type != MT_EXPLORE) {
1853
+    if ($this->_mission_type != MT_EXPLORE) {
1855 1854
       return;
1856 1855
     }
1857 1856
 
1858
-    if(($expeditionsMax = get_player_max_expeditons($this->dbOwnerRow)) <= 0) {
1857
+    if (($expeditionsMax = get_player_max_expeditons($this->dbOwnerRow)) <= 0) {
1859 1858
       throw new Exception('FLIGHT_MISSION_EXPLORE_NO_ASTROTECH', FLIGHT_MISSION_EXPLORE_NO_ASTROTECH);
1860 1859
     }
1861
-    if(FleetList::fleet_count_flying($this->getPlayerOwnerId(), MT_EXPLORE) >= $expeditionsMax) {
1860
+    if (FleetList::fleet_count_flying($this->getPlayerOwnerId(), MT_EXPLORE) >= $expeditionsMax) {
1862 1861
       throw new Exception('FLIGHT_MISSION_EXPLORE_NO_SLOTS', FLIGHT_MISSION_EXPLORE_NO_SLOTS);
1863 1862
     }
1864 1863
 
@@ -1885,10 +1884,10 @@  discard block
 block discarded – undo
1885 1884
 
1886 1885
     $this->dbOwnerRow = db_user_by_id($this->dbOwnerRow['id'], true);
1887 1886
     $this->dbSourcePlanetRow = db_planet_by_id($this->dbSourcePlanetRow['id'], true);
1888
-    if(!empty($this->dbTargetRow['id'])) {
1887
+    if (!empty($this->dbTargetRow['id'])) {
1889 1888
       $this->dbTargetRow = db_planet_by_id($this->dbTargetRow['id'], true);
1890 1889
     }
1891
-    if(!empty($this->dbTargetRow['id_owner'])) {
1890
+    if (!empty($this->dbTargetRow['id_owner'])) {
1892 1891
       $this->dbTargetOwnerRow = db_planet_by_id($this->dbTargetRow['id_owner'], true);
1893 1892
     }
1894 1893
 
@@ -1913,9 +1912,9 @@  discard block
 block discarded – undo
1913 1912
       try {
1914 1913
         // TODO  - ALL OF THE ABOVE!
1915 1914
         $this->restrictMission();
1916
-      } catch(Exception $e) {
1915
+      } catch (Exception $e) {
1917 1916
         // If mission is restricted - rethrow exception
1918
-        if($e->getCode() != FLIGHT_ALLOWED) {
1917
+        if ($e->getCode() != FLIGHT_ALLOWED) {
1919 1918
           throw new Exception($e->getMessage(), $e->getCode());
1920 1919
         }
1921 1920
       }
@@ -1954,9 +1953,9 @@  discard block
 block discarded – undo
1954 1953
 
1955 1954
 
1956 1955
 //      $this->restrict2MissionTransportWithResources($fleetResources);
1957
-    } catch(Exception $e) {
1956
+    } catch (Exception $e) {
1958 1957
       // TODO - MESSAGE BOX
1959
-      if($e->getCode() != FLIGHT_ALLOWED) {
1958
+      if ($e->getCode() != FLIGHT_ALLOWED) {
1960 1959
         sn_db_transaction_rollback();
1961 1960
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1962 1961
       } else {
@@ -1976,46 +1975,46 @@  discard block
 block discarded – undo
1976 1975
     $TransDeuterium = max(0, floor(sys_get_param_float('resource2')));
1977 1976
     $StorageNeeded = $TransMetal + $TransCrystal + $TransDeuterium;
1978 1977
 
1979
-    if(!$StorageNeeded && $target_mission == MT_TRANSPORT) {
1978
+    if (!$StorageNeeded && $target_mission == MT_TRANSPORT) {
1980 1979
       $errorlist .= classLocale::$lang['fl_noenoughtgoods'];
1981 1980
     }
1982 1981
 
1983 1982
 
1984
-    if($target_mission == MT_EXPLORE) {
1985
-      if($MaxExpeditions == 0) {
1983
+    if ($target_mission == MT_EXPLORE) {
1984
+      if ($MaxExpeditions == 0) {
1986 1985
         $errorlist .= classLocale::$lang['fl_expe_notech'];
1987
-      } elseif($FlyingExpeditions >= $MaxExpeditions) {
1986
+      } elseif ($FlyingExpeditions >= $MaxExpeditions) {
1988 1987
         $errorlist .= classLocale::$lang['fl_expe_max'];
1989 1988
       }
1990 1989
     } else {
1991
-      if($TargetPlanet['id_owner']) {
1992
-        if($target_mission == MT_COLONIZE) {
1990
+      if ($TargetPlanet['id_owner']) {
1991
+        if ($target_mission == MT_COLONIZE) {
1993 1992
           $errorlist .= classLocale::$lang['fl_colonized'];
1994 1993
         }
1995 1994
 
1996
-        if($TargetPlanet['id_owner'] == $planetrow['id_owner']) {
1997
-          if($target_mission == MT_ATTACK) {
1995
+        if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) {
1996
+          if ($target_mission == MT_ATTACK) {
1998 1997
             $errorlist .= classLocale::$lang['fl_no_self_attack'];
1999 1998
           }
2000 1999
 
2001
-          if($target_mission == MT_SPY) {
2000
+          if ($target_mission == MT_SPY) {
2002 2001
             $errorlist .= classLocale::$lang['fl_no_self_spy'];
2003 2002
           }
2004 2003
         } else {
2005
-          if($target_mission == MT_RELOCATE) {
2004
+          if ($target_mission == MT_RELOCATE) {
2006 2005
             $errorlist .= classLocale::$lang['fl_only_stay_at_home'];
2007 2006
           }
2008 2007
         }
2009 2008
       } else {
2010
-        if($target_mission < MT_COLONIZE) {
2009
+        if ($target_mission < MT_COLONIZE) {
2011 2010
           $errorlist .= classLocale::$lang['fl_unknow_target'];
2012 2011
         } else {
2013 2012
 //          if($target_mission == MT_DESTROY) {
2014 2013
 //            $errorlist .= classLocale::$lang['fl_nomoon'];
2015 2014
 //          }
2016 2015
 
2017
-          if($target_mission == MT_RECYCLE) {
2018
-            if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) {
2016
+          if ($target_mission == MT_RECYCLE) {
2017
+            if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) {
2019 2018
               $errorlist .= classLocale::$lang['fl_nodebris'];
2020 2019
             }
2021 2020
           }
@@ -2024,12 +2023,12 @@  discard block
 block discarded – undo
2024 2023
     }
2025 2024
 
2026 2025
 
2027
-    if(sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) {
2026
+    if (sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) {
2028 2027
       $captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id']);
2029
-      if(!$captain) {
2028
+      if (!$captain) {
2030 2029
         $errorlist .= classLocale::$lang['module_unit_captain_error_no_captain'];
2031
-      } elseif($captain['unit_location_type'] == LOC_PLANET) {
2032
-        if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) {
2030
+      } elseif ($captain['unit_location_type'] == LOC_PLANET) {
2031
+        if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) {
2033 2032
           $errorlist .= classLocale::$lang['module_unit_captain_error_captain_already_bound'];
2034 2033
         }
2035 2034
       } else {
@@ -2037,7 +2036,7 @@  discard block
 block discarded – undo
2037 2036
       }
2038 2037
     }
2039 2038
 
2040
-    if($errorlist) {
2039
+    if ($errorlist) {
2041 2040
       sn_db_transaction_rollback();
2042 2041
       message("<span class='error'><ul>{$errorlist}</ul></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, false);
2043 2042
     }
@@ -2048,10 +2047,10 @@  discard block
 block discarded – undo
2048 2047
     //But is it acs??
2049 2048
     //Well all acs fleets must have a fleet code.
2050 2049
     //The co-ords must be the same as where the acs fleet is going.
2051
-    if($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") {
2050
+    if ($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") {
2052 2051
       //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!)
2053 2052
       $aks = db_acs_get_by_group_id($fleet_group);
2054
-      if(!$aks) {
2053
+      if (!$aks) {
2055 2054
         $fleet_group = 0;
2056 2055
       } else {
2057 2056
         //Also it must be mission type 2
@@ -2062,26 +2061,26 @@  discard block
 block discarded – undo
2062 2061
         $planet = $aks['planet'];
2063 2062
         $planet_type = $aks['planet_type'];
2064 2063
       }
2065
-    } elseif($target_mission == MT_ACS) {
2064
+    } elseif ($target_mission == MT_ACS) {
2066 2065
       //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet.
2067 2066
       $target_mission = MT_ATTACK;
2068 2067
     }
2069 2068
 
2070
-    if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
2069
+    if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
2071 2070
       $TargetPlanet = array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'id_owner' => 0);
2072 2071
     }
2073 2072
     $options = array('fleet_speed_percent' => $speed_percent, 'fleet_group' => $fleet_group, 'resources' => $StorageNeeded);
2074 2073
     $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options);
2075 2074
 
2076
-    if($cant_attack !== FLIGHT_ALLOWED) {
2075
+    if ($cant_attack !== FLIGHT_ALLOWED) {
2077 2076
       message("<span class='error'><b>{$classLocale['fl_attack_error'][$cant_attack]}</b></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 99);
2078 2077
     }
2079 2078
 
2080 2079
     $mission_time_in_seconds = 0;
2081 2080
     $arrival_time = SN_TIME_NOW + $time_to_travel;
2082
-    if($target_mission == MT_ACS && $aks) {
2081
+    if ($target_mission == MT_ACS && $aks) {
2083 2082
 //    if($fleet_start_time > $aks['ankunft']) {
2084
-      if($arrival_time > $aks['ankunft']) {
2083
+      if ($arrival_time > $aks['ankunft']) {
2085 2084
         message(classLocale::$lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $arrival_time) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), classLocale::$lang['fl_error']);
2086 2085
       }
2087 2086
       $group_sync_delta_time = $aks['ankunft'] - $arrival_time;
@@ -2090,11 +2089,11 @@  discard block
 block discarded – undo
2090 2089
       // Set return time to ACS return time + fleet's time to travel
2091 2090
       $return_time = $aks['ankunft'] + $time_to_travel;
2092 2091
     } else {
2093
-      if($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) {
2092
+      if ($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) {
2094 2093
         $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0);
2095
-        if($max_duration) {
2094
+        if ($max_duration) {
2096 2095
           $mission_time_in_hours = sys_get_param_id('missiontime');
2097
-          if($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) {
2096
+          if ($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) {
2098 2097
             $debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true));
2099 2098
             die();
2100 2099
           }
@@ -2108,7 +2107,7 @@  discard block
 block discarded – undo
2108 2107
 //    $FleetStorage = 0;
2109 2108
 
2110 2109
     $db_changeset = array();
2111
-    foreach($fleetarray as $Ship => $Count) {
2110
+    foreach ($fleetarray as $Ship => $Count) {
2112 2111
 //      $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count;
2113 2112
       $db_changeset['unit'][] = sn_db_unit_changeset_prepare($Ship, -$Count, $user, $planetrow['id']);
2114 2113
     }
@@ -2161,7 +2160,7 @@  discard block
 block discarded – undo
2161 2160
 
2162 2161
     $template = gettemplate('fleet3', true);
2163 2162
 
2164
-    if(is_array($captain)) {
2163
+    if (is_array($captain)) {
2165 2164
       db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$objFleet->dbId}");
2166 2165
     }
2167 2166
 
@@ -2173,7 +2172,7 @@  discard block
 block discarded – undo
2173 2172
       'START_TIME_TEXT'    => date(FMT_DATE_TIME, $return_time + SN_CLIENT_TIME_DIFF),
2174 2173
       'START_LEFT'         => floor($return_time + 1 - SN_TIME_NOW),
2175 2174
     );
2176
-    if(!empty($TargetPlanet)) {
2175
+    if (!empty($TargetPlanet)) {
2177 2176
       $template_route += array(
2178 2177
         'END_TYPE_TEXT_SH' => classLocale::$lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
2179 2178
         'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -2186,8 +2185,8 @@  discard block
 block discarded – undo
2186 2185
     $template->assign_block_vars('fleets', $template_route);
2187 2186
 
2188 2187
     $sn_groups_fleet = sn_get_groups('fleet');
2189
-    foreach($fleetarray as $ship_id => $ship_count) {
2190
-      if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
2188
+    foreach ($fleetarray as $ship_id => $ship_count) {
2189
+      if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
2191 2190
 //      $ship_base_data = get_ship_data($ship_id, $user);
2192 2191
         $template->assign_block_vars('fleets.ships', array(
2193 2192
           'ID'          => $ship_id,
@@ -2227,16 +2226,16 @@  discard block
 block discarded – undo
2227 2226
    * @throws Exception
2228 2227
    */
2229 2228
   public function checkMissionRestrictions($checklist) {
2230
-    foreach($checklist as $condition => $action) {
2229
+    foreach ($checklist as $condition => $action) {
2231 2230
       $checkResult = call_user_func(array($this, $condition));
2232 2231
 
2233
-      if(is_array($action) && !empty($action[$checkResult])) {
2232
+      if (is_array($action) && !empty($action[$checkResult])) {
2234 2233
         $action = $action[$checkResult];
2235 2234
       }
2236 2235
 
2237
-      if(is_array($action)) {
2236
+      if (is_array($action)) {
2238 2237
         $this->checkMissionRestrictions($action);
2239
-      } elseif(!$checkResult) {
2238
+      } elseif (!$checkResult) {
2240 2239
         throw new Exception($action, $action);
2241 2240
       }
2242 2241
     }
@@ -2309,8 +2308,8 @@  discard block
 block discarded – undo
2309 2308
   }
2310 2309
 
2311 2310
   protected function checkResourcesPositive() {
2312
-    foreach($this->resource_list as $resourceId => $resourceAmount) {
2313
-      if($resourceAmount < 0) {
2311
+    foreach ($this->resource_list as $resourceId => $resourceAmount) {
2312
+      if ($resourceAmount < 0) {
2314 2313
         return false;
2315 2314
       }
2316 2315
     }
@@ -2332,8 +2331,8 @@  discard block
 block discarded – undo
2332 2331
   protected function checkSourceEnoughResources() {
2333 2332
     $fleetResources = $this->resource_list;
2334 2333
     $fleetResources[RES_DEUTERIUM] = ceil($fleetResources[RES_DEUTERIUM] + $this->travelData['consumption']);
2335
-    foreach($fleetResources as $resourceId => $resourceAmount) {
2336
-      if(mrc_get_level($this->dbOwnerRow, $this->dbSourcePlanetRow, $resourceId) < ceil($fleetResources[$resourceId])) {
2334
+    foreach ($fleetResources as $resourceId => $resourceAmount) {
2335
+      if (mrc_get_level($this->dbOwnerRow, $this->dbSourcePlanetRow, $resourceId) < ceil($fleetResources[$resourceId])) {
2337 2336
         return false;
2338 2337
       }
2339 2338
     }
@@ -2376,7 +2375,7 @@  discard block
 block discarded – undo
2376 2375
 
2377 2376
   protected function checkHaveRecyclers() {
2378 2377
     $recyclers = 0;
2379
-    foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
2378
+    foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
2380 2379
       $recyclers += $this->unitList->unitsCountById($recycler_id);
2381 2380
     }
2382 2381
 
@@ -2388,7 +2387,7 @@  discard block
 block discarded – undo
2388 2387
   protected function checkTargetOwn() {
2389 2388
     $result = $this->dbTargetRow['id_owner'] == $this->dbSourcePlanetRow['id_owner'];
2390 2389
 
2391
-    if($result) {
2390
+    if ($result) {
2392 2391
       // Spying can't be done on owner's planet/moon
2393 2392
       unset($this->allowed_missions[MT_SPY]);
2394 2393
       // Attack can't be done on owner's planet/moon
@@ -2425,7 +2424,7 @@  discard block
 block discarded – undo
2425 2424
 
2426 2425
   protected function checkSpiesOnly() {
2427 2426
     $result = $this->unitList->unitsCountById(SHIP_SPY) == $this->shipsGetTotal();
2428
-    if($result) {
2427
+    if ($result) {
2429 2428
       $this->allowed_missions = array(
2430 2429
         MT_SPY => $this->exists_missions[MT_SPY],
2431 2430
       );
@@ -2438,7 +2437,7 @@  discard block
 block discarded – undo
2438 2437
 
2439 2438
   protected function checkTargetAllyDeposit() {
2440 2439
     $result = mrc_get_level($this->dbTargetOwnerRow, $this->dbTargetRow, STRUC_ALLY_DEPOSIT) >= 1;
2441
-    if(!$result) {
2440
+    if (!$result) {
2442 2441
       unset($this->allowed_missions[MT_HOLD]);
2443 2442
     }
2444 2443
 
@@ -2467,7 +2466,7 @@  discard block
 block discarded – undo
2467 2466
 
2468 2467
   protected function checkMission($missionType) {
2469 2468
     $result = !$this->_mission_type || $this->_mission_type == $missionType;
2470
-    if($result) {
2469
+    if ($result) {
2471 2470
       $this->allowed_missions = array(
2472 2471
         $missionType => $this->exists_missions[$missionType],
2473 2472
       );
Please login to merge, or discard this patch.