Completed
Push — work-fleets ( bdccb3...6d7489 )
by SuperNova.WS
05:15
created
includes/general.php 1 patch
Doc Comments   +27 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 require_once('general_pname.php');
13 13
 
14 14
 /**
15
- * @param       $func_name
15
+ * @param       string $func_name
16 16
  * @param array $func_arg
17 17
  *
18 18
  * @return mixed
@@ -63,6 +63,9 @@  discard block
 block discarded – undo
63 63
 
64 64
 // ----------------------------------------------------------------------------------------------------------------
65 65
 // Fonction de lecture / ecriture / exploitation de templates
66
+/**
67
+ * @param string $filename
68
+ */
66 69
 function sys_file_read($filename) {
67 70
   return @file_get_contents($filename);
68 71
 }
@@ -105,7 +108,7 @@  discard block
 block discarded – undo
105 108
 /**
106 109
  * Получение курса обмены валюты в серверную валюту
107 110
  *
108
- * @param $currency_symbol
111
+ * @param string $currency_symbol
109 112
  *
110 113
  * @return float
111 114
  */
@@ -146,7 +149,7 @@  discard block
 block discarded – undo
146 149
  * @param float     $n
147 150
  * @param int|bool  $floor
148 151
  * @param int|bool  $color
149
- * @param int|bool  $limit
152
+ * @param boolean  $limit
150 153
  * @param bool|null $style
151 154
  *
152 155
  * @return array|float|string
@@ -247,6 +250,9 @@  discard block
 block discarded – undo
247 250
   return preg_replace($ListCensure, '*', $String);
248 251
 }
249 252
 
253
+/**
254
+ * @param string $email
255
+ */
250 256
 function is_email($email) {
251 257
   return (preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email));
252 258
 }
@@ -283,6 +289,9 @@  discard block
 block discarded – undo
283 289
   return floatval(sys_get_param($param_name, $default));
284 290
 }
285 291
 
292
+/**
293
+ * @param string $param_name
294
+ */
286 295
 function sys_get_param_escaped($param_name, $default = '') {
287 296
   return db_escape(sys_get_param($param_name, $default));
288 297
 }
@@ -515,6 +524,9 @@  discard block
 block discarded – undo
515 524
 }
516 525
 
517 526
 // Generates random string of $length symbols from $allowed_chars charset
527
+/**
528
+ * @param string $allowed_chars
529
+ */
518 530
 function sys_random_string($length = 16, $allowed_chars = SN_SYS_SEC_CHARS_ALLOWED) {
519 531
   $allowed_length = strlen($allowed_chars);
520 532
 
@@ -619,6 +631,9 @@  discard block
 block discarded – undo
619 631
   return implode(';', $fleet_string);
620 632
 }
621 633
 
634
+/**
635
+ * @param string $body
636
+ */
622 637
 function mymail($email_unsafe, $title, $body, $from = '', $html = false) {
623 638
   $from = trim($from ? $from : classSupernova::$config->game_adminEmail);
624 639
 
@@ -873,6 +888,9 @@  discard block
 block discarded – undo
873 888
   return serialize($nick_array);
874 889
 }
875 890
 
891
+/**
892
+ * @param string $nick_string
893
+ */
876 894
 function player_nick_uncompact($nick_string) {
877 895
   try {
878 896
     $result = unserialize($nick_string);
@@ -1120,6 +1138,9 @@  discard block
 block discarded – undo
1120 1138
   return $ranks;
1121 1139
 }
1122 1140
 
1141
+/**
1142
+ * @param boolean $planet_id
1143
+ */
1123 1144
 function sys_player_new_adjust($user_id, $planet_id) { return sn_function_call(__FUNCTION__, array($user_id, $planet_id, &$result)); }
1124 1145
 
1125 1146
 function sn_sys_player_new_adjust($user_id, $planet_id, &$result) {
@@ -1430,6 +1451,9 @@  discard block
 block discarded – undo
1430 1451
   return version_compare(sn_version_compare_extra($ver1), sn_version_compare_extra($ver2));
1431 1452
 }
1432 1453
 
1454
+/**
1455
+ * @param string $name
1456
+ */
1433 1457
 function sn_setcookie($name, $value = null, $expire = null, $path = SN_ROOT_RELATIVE, $domain = null, $secure = null, $httponly = null) {
1434 1458
   $_COOKIE[$name] = $value;
1435 1459
 
Please login to merge, or discard this patch.
includes/classes/Fleet.php 1 patch
Spacing   +76 added lines, -77 removed lines patch added patch discarded remove patch
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
   public function renderAvailableShips(&$template_result, $playerRow, $planetRow) {
315 315
     $record_index = 0;
316 316
     $ship_list = array();
317
-    foreach(sn_get_groups('fleet') as $n => $unit_id) {
317
+    foreach (sn_get_groups('fleet') as $n => $unit_id) {
318 318
       $unit_level = mrc_get_level($playerRow, $planetRow, $unit_id, false, true);
319
-      if($unit_level <= 0) {
319
+      if ($unit_level <= 0) {
320 320
         continue;
321 321
       }
322 322
       $ship_data = get_ship_data($unit_id, $playerRow);
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
     sortUnitRenderedList($ship_list, classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT], classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE]);
339 339
 
340
-    foreach($ship_list as $ship_data) {
340
+    foreach ($ship_list as $ship_data) {
341 341
       $template_result['.']['ships'][] = $ship_data;
342 342
     }
343 343
   }
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
   public function dbInsert() {
357 357
     // WARNING! MISSION TIMES MUST BE SET WITH set_times() method!
358 358
     // TODO - more checks!
359
-    if(empty($this->_time_launch)) {
359
+    if (empty($this->_time_launch)) {
360 360
       die('Fleet time not set!');
361 361
     }
362 362
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
     // Записываем изменения в БД
566 566
     $this->dbSave();
567 567
 
568
-    if($this->_group_id) {
568
+    if ($this->_group_id) {
569 569
       // TODO: Make here to delete only one AKS - by adding aks_fleet_count to AKS table
570 570
       db_fleet_aks_purge();
571 571
     }
@@ -632,18 +632,18 @@  discard block
 block discarded – undo
632 632
    */
633 633
   // TODO - separate shipList and unitList
634 634
   public function unitsSetFromArray($unit_array) {
635
-    if(empty($unit_array) || !is_array($unit_array)) {
635
+    if (empty($unit_array) || !is_array($unit_array)) {
636 636
       return;
637 637
     }
638
-    foreach($unit_array as $unit_id => $unit_count) {
638
+    foreach ($unit_array as $unit_id => $unit_count) {
639 639
       $unit_count = floatval($unit_count);
640
-      if(!$unit_count) {
640
+      if (!$unit_count) {
641 641
         continue;
642 642
       }
643 643
 
644
-      if($this->isShip($unit_id)) {
644
+      if ($this->isShip($unit_id)) {
645 645
         $this->unitList->unitSetCount($unit_id, $unit_count);
646
-      } elseif($this->isResource($unit_id)) {
646
+      } elseif ($this->isResource($unit_id)) {
647 647
         $this->resource_list[$unit_id] = $unit_count;
648 648
       } else {
649 649
         throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR);
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
   public function parse_missile_db_row($missile_db_row) {
673 673
 //    $this->_reset();
674 674
 
675
-    if(empty($missile_db_row) || !is_array($missile_db_row)) {
675
+    if (empty($missile_db_row) || !is_array($missile_db_row)) {
676 676
       return;
677 677
     }
678 678
 
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
   public function shipsGetCapacityRecyclers(array $recycler_info) {
836 836
     $recyclers_incoming_capacity = 0;
837 837
     $fleet_data = $this->shipsGetArray();
838
-    foreach($recycler_info as $recycler_id => $recycler_data) {
838
+    foreach ($recycler_info as $recycler_id => $recycler_data) {
839 839
       $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity'];
840 840
     }
841 841
 
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
     sn_db_transaction_check(true);
856 856
 
857 857
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
858
-    if($this->isEmpty()) {
858
+    if ($this->isEmpty()) {
859 859
       return $result;
860 860
     }
861 861
 
@@ -877,18 +877,18 @@  discard block
 block discarded – undo
877 877
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
878 878
     // Флот, который возвращается на захваченную планету, пропадает
879 879
     // Ship landing is possible only to fleet owner's planet
880
-    if($this->getPlayerOwnerId() == $planet_arrival['id_owner']) {
880
+    if ($this->getPlayerOwnerId() == $planet_arrival['id_owner']) {
881 881
       $db_changeset = array();
882 882
 
883 883
       $fleet_array = $this->shipsGetArray();
884
-      foreach($fleet_array as $ship_id => $ship_count) {
885
-        if($ship_count) {
884
+      foreach ($fleet_array as $ship_id => $ship_count) {
885
+        if ($ship_count) {
886 886
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $planet_arrival['id']);
887 887
         }
888 888
       }
889 889
 
890 890
       // Adjusting ship amount on planet
891
-      if(!empty($db_changeset)) {
891
+      if (!empty($db_changeset)) {
892 892
         db_changeset_apply($db_changeset);
893 893
       }
894 894
 
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
    * @param array $resource_list
937 937
    */
938 938
   public function resourcesSet($resource_list) {
939
-    if(!empty($this->propertiesAdjusted['resource_list'])) {
939
+    if (!empty($this->propertiesAdjusted['resource_list'])) {
940 940
       throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
941 941
     }
942 942
     $this->resourcesAdjust($resource_list, true);
@@ -950,13 +950,13 @@  discard block
 block discarded – undo
950 950
   public function resourcesAdjust($resource_delta_list, $replace_value = false) {
951 951
     !is_array($resource_delta_list) ? $resource_delta_list = array() : false;
952 952
 
953
-    foreach($resource_delta_list as $resource_id => $unit_delta) {
954
-      if(!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
953
+    foreach ($resource_delta_list as $resource_id => $unit_delta) {
954
+      if (!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
955 955
         // Not a resource or no resources - continuing
956 956
         continue;
957 957
       }
958 958
 
959
-      if($replace_value) {
959
+      if ($replace_value) {
960 960
         $this->resource_list[$resource_id] = $unit_delta;
961 961
       } else {
962 962
         $this->resource_list[$resource_id] += $unit_delta;
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
       }
967 967
 
968 968
       // Check for negative unit value
969
-      if($this->resource_list[$resource_id] < 0) {
969
+      if ($this->resource_list[$resource_id] < 0) {
970 970
         // TODO
971 971
         throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
972 972
       }
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
     sn_db_transaction_check(true);
1019 1019
 
1020 1020
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
1021
-    if(!$this->resourcesGetTotal()) {
1021
+    if (!$this->resourcesGetTotal()) {
1022 1022
       return $result;
1023 1023
     }
1024 1024
 
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
1039 1039
 
1040 1040
     // Restoring resources to planet
1041
-    if($this->resourcesGetTotal()) {
1041
+    if ($this->resourcesGetTotal()) {
1042 1042
       $fleet_resources = $this->resourcesGetList();
1043 1043
       db_planet_set_by_id($planet_arrival['id'],
1044 1044
         "`metal` = `metal` + '{$fleet_resources[RES_METAL]}', `crystal` = `crystal` + '{$fleet_resources[RES_CRYSTAL]}', `deuterium` = `deuterium` + '{$fleet_resources[RES_DEUTERIUM]}'");
@@ -1103,12 +1103,12 @@  discard block
 block discarded – undo
1103 1103
 
1104 1104
   protected function populateTargetPlanet() {
1105 1105
     $targetPlanetCoords = $this->targetVector;
1106
-    if($this->mission_type != MT_NONE) {
1106
+    if ($this->mission_type != MT_NONE) {
1107 1107
       $this->restrictTargetTypeByMission();
1108 1108
 
1109 1109
       // TODO - Нельзя тут просто менять тип планеты или координат!
1110 1110
       // If current planet type is not allowed on mission - switch planet type
1111
-      if(empty($this->allowed_planet_types[$this->targetVector->type])) {
1111
+      if (empty($this->allowed_planet_types[$this->targetVector->type])) {
1112 1112
         $targetPlanetCoords->type = reset($this->allowed_planet_types);
1113 1113
       }
1114 1114
     }
@@ -1117,14 +1117,14 @@  discard block
 block discarded – undo
1117 1117
   }
1118 1118
 
1119 1119
   protected function restrictTargetTypeByMission() {
1120
-    if($this->_mission_type == MT_MISSILE) {
1120
+    if ($this->_mission_type == MT_MISSILE) {
1121 1121
       $this->allowed_planet_types = array(PT_PLANET => PT_PLANET);
1122
-    } elseif($this->_mission_type == MT_COLONIZE || $this->_mission_type == MT_EXPLORE) {
1122
+    } elseif ($this->_mission_type == MT_COLONIZE || $this->_mission_type == MT_EXPLORE) {
1123 1123
       // TODO - PT_NONE
1124 1124
       $this->allowed_planet_types = array(PT_PLANET => PT_PLANET);
1125
-    } elseif($this->_mission_type == MT_RECYCLE) {
1125
+    } elseif ($this->_mission_type == MT_RECYCLE) {
1126 1126
       $this->allowed_planet_types = array(PT_DEBRIS => PT_DEBRIS);
1127
-    } elseif($this->_mission_type == MT_DESTROY) {
1127
+    } elseif ($this->_mission_type == MT_DESTROY) {
1128 1128
       $this->allowed_planet_types = array(PT_MOON => PT_MOON);
1129 1129
     } else {
1130 1130
       $this->allowed_planet_types = array(PT_PLANET => PT_PLANET, PT_MOON => PT_MOON);
@@ -1156,13 +1156,13 @@  discard block
 block discarded – undo
1156 1156
 
1157 1157
 
1158 1158
   public function restrictToKnownSpace() {
1159
-    if(!$this->targetVector->isInKnownSpace()) {
1159
+    if (!$this->targetVector->isInKnownSpace()) {
1160 1160
       throw new Exception('FLIGHT_VECTOR_BEYOND_SYSTEM', FLIGHT_VECTOR_BEYOND_SYSTEM);
1161 1161
     }
1162 1162
   }
1163 1163
 
1164 1164
   public function restrictToTypePlanet($errorCode) {
1165
-    if($this->targetVector->type != PT_PLANET) {
1165
+    if ($this->targetVector->type != PT_PLANET) {
1166 1166
       throw new Exception($errorCode, $errorCode);
1167 1167
     }
1168 1168
   }
@@ -1170,56 +1170,56 @@  discard block
 block discarded – undo
1170 1170
   public function restrictToNoMissiles() {
1171 1171
     $missilesAttack = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERPLANET);
1172 1172
     $missilesDefense = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERCEPTOR);
1173
-    if($missilesAttack > 0 || $missilesDefense > 0) {
1173
+    if ($missilesAttack > 0 || $missilesDefense > 0) {
1174 1174
       throw new Exception('FLIGHT_SHIPS_NO_MISSILES', FLIGHT_SHIPS_NO_MISSILES);
1175 1175
     }
1176 1176
   }
1177 1177
 
1178 1178
   public function restrictToTargetOwn() {
1179
-    if($this->dbTargetRow['id'] != $this->getPlayerOwnerId()) {
1179
+    if ($this->dbTargetRow['id'] != $this->getPlayerOwnerId()) {
1180 1180
       throw new Exception('FLIGHT_VECTOR_ONLY_OWN', FLIGHT_VECTOR_ONLY_OWN);
1181 1181
     }
1182 1182
   }
1183 1183
 
1184 1184
   public function restrictToTargetOther() {
1185
-    if($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) {
1185
+    if ($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) {
1186 1186
       throw new Exception('FLIGHT_VECTOR_ONLY_OTHER', FLIGHT_VECTOR_ONLY_OTHER);
1187 1187
     }
1188 1188
   }
1189 1189
 
1190 1190
   public function restrictToNotOnlySpies() {
1191
-    if($this->unitList->unitsCountById(SHIP_SPY) == $this->shipsGetTotal()) {
1191
+    if ($this->unitList->unitsCountById(SHIP_SPY) == $this->shipsGetTotal()) {
1192 1192
       throw new Exception('FLIGHT_SHIPS_NOT_ONLY_SPIES', FLIGHT_SHIPS_NOT_ONLY_SPIES);
1193 1193
     }
1194 1194
   }
1195 1195
 
1196 1196
   protected function restrictToUniverse() {
1197
-    if(!$this->targetVector->isInUniverse()) {
1197
+    if (!$this->targetVector->isInUniverse()) {
1198 1198
       throw new Exception('FLIGHT_VECTOR_BEYOND_UNIVERSE', FLIGHT_VECTOR_BEYOND_UNIVERSE);
1199 1199
     }
1200 1200
   }
1201 1201
 
1202 1202
   protected function restrictToMovable() {
1203
-    if(!$this->unitList->unitsIsAllMovable($this->dbOwnerRow)) {
1203
+    if (!$this->unitList->unitsIsAllMovable($this->dbOwnerRow)) {
1204 1204
       throw new Exception('FLIGHT_SHIPS_UNMOVABLE', FLIGHT_SHIPS_UNMOVABLE);
1205 1205
     }
1206 1206
   }
1207 1207
 
1208 1208
   protected function restrictToFleetUnits() {
1209
-    if(!$this->unitList->unitsInGroup(sn_get_groups(array('fleet', 'missile')))) {
1209
+    if (!$this->unitList->unitsInGroup(sn_get_groups(array('fleet', 'missile')))) {
1210 1210
       throw new Exception('FLIGHT_SHIPS_UNIT_WRONG', FLIGHT_SHIPS_UNIT_WRONG);
1211 1211
     }
1212 1212
   }
1213 1213
 
1214 1214
   protected function restrictToColonizer() {
1215 1215
     // Colonization fleet should have at least one colonizer
1216
-    if(!$this->unitList->unitsCountById(SHIP_COLONIZER) <= 0) {
1216
+    if (!$this->unitList->unitsCountById(SHIP_COLONIZER) <= 0) {
1217 1217
       throw new Exception('FLIGHT_SHIPS_NO_COLONIZER', FLIGHT_SHIPS_NO_COLONIZER);
1218 1218
     }
1219 1219
   }
1220 1220
 
1221 1221
   protected function restrictToTargetExists() {
1222
-    if(empty($this->dbTargetRow) || empty($this->dbTargetRow['id'])) {
1222
+    if (empty($this->dbTargetRow) || empty($this->dbTargetRow['id'])) {
1223 1223
       throw new Exception('FLIGHT_VECTOR_NO_TARGET', FLIGHT_VECTOR_NO_TARGET);
1224 1224
     }
1225 1225
   }
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 
1228 1228
   protected function restrictKnownSpaceOrMissionExplore() {
1229 1229
     // Is it exploration - fleet sent beyond of system?
1230
-    if($this->targetVector->isInKnownSpace()) {
1230
+    if ($this->targetVector->isInKnownSpace()) {
1231 1231
       // No exploration beyond this point
1232 1232
       unset($this->allowed_missions[MT_EXPLORE]);
1233 1233
 
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 
1246 1246
   protected function restrictTargetExistsOrMissionColonize() {
1247 1247
     // Is it colonization - fleet sent to empty place?
1248
-    if(!empty($this->dbTargetRow)) {
1248
+    if (!empty($this->dbTargetRow)) {
1249 1249
       // No colonization beyond this point
1250 1250
       unset($this->allowed_missions[MT_COLONIZE]);
1251 1251
 
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
   }
1265 1265
 
1266 1266
   protected function restrictNotDebrisOrMissionRecycle() {
1267
-    if($this->targetVector->type != PT_DEBRIS) {
1267
+    if ($this->targetVector->type != PT_DEBRIS) {
1268 1268
       // No recycling beyond this point
1269 1269
       unset($this->allowed_missions[MT_RECYCLE]);
1270 1270
 
@@ -1275,11 +1275,11 @@  discard block
 block discarded – undo
1275 1275
 
1276 1276
     // restrict to recyclers
1277 1277
     $recyclers = 0;
1278
-    foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
1278
+    foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
1279 1279
       $recyclers += $this->unitList->unitsCountById($recycler_id);
1280 1280
     }
1281 1281
 
1282
-    if($recyclers <= 0) {
1282
+    if ($recyclers <= 0) {
1283 1283
       throw new Exception('FLIGHT_SHIPS_NO_RECYCLERS', FLIGHT_SHIPS_NO_RECYCLERS);
1284 1284
     }
1285 1285
 
@@ -1290,14 +1290,14 @@  discard block
 block discarded – undo
1290 1290
 
1291 1291
   protected function restrictMissionMissile() {
1292 1292
     $missilesAttack = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERPLANET);
1293
-    if($missilesAttack <= 0) {
1293
+    if ($missilesAttack <= 0) {
1294 1294
       // No missile attack beyond this point
1295 1295
       unset($this->allowed_missions[MT_MISSILE]);
1296 1296
 
1297 1297
       return;
1298 1298
     }
1299 1299
 
1300
-    if($missilesAttack != $this->shipsGetTotal()) {
1300
+    if ($missilesAttack != $this->shipsGetTotal()) {
1301 1301
       throw new Exception('FLIGHT_SHIPS_ONLY_MISSILES', FLIGHT_SHIPS_ONLY_MISSILES);
1302 1302
     }
1303 1303
 
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
   }
1310 1310
 
1311 1311
   protected function restrictToNotOnlySpiesOrMissionSpy() {
1312
-    if($this->unitList->unitsCountById(SHIP_SPY) != $this->shipsGetTotal()) {
1312
+    if ($this->unitList->unitsCountById(SHIP_SPY) != $this->shipsGetTotal()) {
1313 1313
 //      throw new Exception('FLIGHT_SHIPS_ONLY_SPIES', FLIGHT_SHIPS_ONLY_SPIES);
1314 1314
       unset($this->allowed_missions[MT_SPY]);
1315 1315
 
@@ -1325,14 +1325,14 @@  discard block
 block discarded – undo
1325 1325
   protected function restrictMissionDestroy() {
1326 1326
     // If target vector is not Moon - then it can't be Destroy mission
1327 1327
     // If no Reapers (i.e. Death Star) in fleet - then mission Moon Destroy is unaccessible
1328
-    if($this->targetVector->type != PT_MOON || $this->unitList->unitsCountById(SHIP_HUGE_DEATH_STAR) <= 0) {
1328
+    if ($this->targetVector->type != PT_MOON || $this->unitList->unitsCountById(SHIP_HUGE_DEATH_STAR) <= 0) {
1329 1329
       unset($this->allowed_missions[MT_DESTROY]);
1330 1330
     }
1331 1331
   }
1332 1332
 
1333 1333
   protected function restrictMissionACS() {
1334 1334
     // If no ACS group is shown - then it can't be an ACS attack
1335
-    if(empty($this->_group_id)) {
1335
+    if (empty($this->_group_id)) {
1336 1336
       unset($this->allowed_missions[MT_ACS]);
1337 1337
     }
1338 1338
   }
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
   /** @throws Exception */
1341 1341
   protected function restrictFriendOrFoe() {
1342 1342
     // Checking target owner
1343
-    if($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) {
1343
+    if ($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) {
1344 1344
       // Spying can't be done on owner's planet/moon
1345 1345
       unset($this->allowed_missions[MT_SPY]);
1346 1346
       // Attack can't be done on owner's planet/moon
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
    * @throws Exception
1402 1402
    */
1403 1403
   public function restrictMission() {
1404
-    if($this->targetVector->isEqualToPlanet($this->dbSourcePlanetRow)) {
1404
+    if ($this->targetVector->isEqualToPlanet($this->dbSourcePlanetRow)) {
1405 1405
       throw new Exception('FLIGHT_VECTOR_SAME_SOURCE', FLIGHT_VECTOR_SAME_SOURCE);
1406 1406
     }
1407 1407
 
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
 
1433 1433
 
1434 1434
   protected function printErrorIfNoShips() {
1435
-    if($this->unitList->unitsCount() <= 0) {
1435
+    if ($this->unitList->unitsCount() <= 0) {
1436 1436
       message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
1437 1437
     }
1438 1438
   }
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 
1470 1470
     lng_include('overview');
1471 1471
 
1472
-    if(empty($this->dbSourcePlanetRow)) {
1472
+    if (empty($this->dbSourcePlanetRow)) {
1473 1473
       message(classLocale::$lang['fl_noplanetrow'], classLocale::$lang['fl_error']);
1474 1474
     }
1475 1475
 
@@ -1545,9 +1545,9 @@  discard block
 block discarded – undo
1545 1545
 
1546 1546
     try {
1547 1547
       $this->restrictMission();
1548
-    } catch(Exception $e) {
1548
+    } catch (Exception $e) {
1549 1549
       // TODO - MESSAGE BOX
1550
-      if($e->getCode() != FLIGHT_ALLOWED) {
1550
+      if ($e->getCode() != FLIGHT_ALLOWED) {
1551 1551
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1552 1552
       } else {
1553 1553
         pdump('FLIGHT_ALLOWED', FLIGHT_ALLOWED);
@@ -1557,20 +1557,19 @@  discard block
 block discarded – undo
1557 1557
     $this->renderAllowedMissions($template_result);
1558 1558
     $this->renderFleet($template_result);
1559 1559
 
1560
-    $max_duration = $this->_mission_type == MT_EXPLORE ? get_player_max_expedition_duration($this->dbOwnerRow) :
1561
-      (isset($this->allowed_missions[MT_HOLD]) ? 12 : 0);
1560
+    $max_duration = $this->_mission_type == MT_EXPLORE ? get_player_max_expedition_duration($this->dbOwnerRow) : (isset($this->allowed_missions[MT_HOLD]) ? 12 : 0);
1562 1561
     $this->renderDuration($template_result, $max_duration);
1563 1562
 
1564 1563
     $travel_data = $this->flt_travel_data($this->oldSpeedInTens);
1565 1564
 
1566 1565
     $sn_group_resources = sn_get_groups('resources_loot');
1567 1566
     $planetResources = array();
1568
-    foreach($sn_group_resources as $resource_id) {
1567
+    foreach ($sn_group_resources as $resource_id) {
1569 1568
       $planetResources[$resource_id] = floor(mrc_get_level($this->dbOwnerRow, $this->dbSourcePlanetRow, $resource_id) - ($resource_id == RES_DEUTERIUM ? $travel_data['consumption'] : 0));
1570 1569
     }
1571 1570
     $this->renderPlanetResources($planetResources, $template_result);
1572 1571
 
1573
-    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) {
1572
+    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) {
1574 1573
       $template_result += array(
1575 1574
         'CAPTAIN_ID'     => $captain['unit_id'],
1576 1575
         'CAPTAIN_LEVEL'  => $captain['captain_level'],
@@ -1612,10 +1611,10 @@  discard block
 block discarded – undo
1612 1611
   protected function renderAllowedMissions(&$template_result) {
1613 1612
     ksort($this->allowed_missions);
1614 1613
     // If mission is not set - setting first mission from allowed
1615
-    if(empty($this->_mission_type) && is_array($this->allowed_missions)) {
1614
+    if (empty($this->_mission_type) && is_array($this->allowed_missions)) {
1616 1615
       $this->_mission_type = reset($this->allowed_missions);
1617 1616
     }
1618
-    foreach($this->allowed_missions as $key => $value) {
1617
+    foreach ($this->allowed_missions as $key => $value) {
1619 1618
       $template_result['.']['missions'][] = array(
1620 1619
         'ID'   => $key,
1621 1620
         'NAME' => classLocale::$lang['type_mission'][$key],
@@ -1627,9 +1626,9 @@  discard block
 block discarded – undo
1627 1626
    * @param $template_result
1628 1627
    */
1629 1628
   protected function renderDuration(&$template_result, $max_duration) {
1630
-    if($max_duration) {
1629
+    if ($max_duration) {
1631 1630
       $config_game_speed_expedition = ($this->_mission_type == MT_EXPLORE && classSupernova::$config->game_speed_expedition ? classSupernova::$config->game_speed_expedition : 1);
1632
-      for($i = 1; $i <= $max_duration; $i++) {
1631
+      for ($i = 1; $i <= $max_duration; $i++) {
1633 1632
         $template_result['.']['duration'][] = array(
1634 1633
           'ID'   => $i,
1635 1634
           'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)),
@@ -1645,7 +1644,7 @@  discard block
 block discarded – undo
1645 1644
   protected function renderPlanetResources(&$planetResources, &$template_result) {
1646 1645
     // TODO - REDO to resource_id
1647 1646
     $i = 0;
1648
-    foreach($planetResources as $resource_id => $resource_amount) {
1647
+    foreach ($planetResources as $resource_id => $resource_amount) {
1649 1648
       $template_result['.']['resources'][] = array(
1650 1649
         'ID'        => $i++, // $resource_id,
1651 1650
         'ON_PLANET' => $resource_amount,
@@ -1659,7 +1658,7 @@  discard block
 block discarded – undo
1659 1658
    * @param $template_result
1660 1659
    */
1661 1660
   protected function renderAllowedPlanetTypes(&$template_result) {
1662
-    foreach($this->allowed_planet_types as $possible_planet_type_id) {
1661
+    foreach ($this->allowed_planet_types as $possible_planet_type_id) {
1663 1662
       $template_result['.']['possible_planet_type_id'][] = array(
1664 1663
         'ID'         => $possible_planet_type_id,
1665 1664
         'NAME'       => classLocale::$lang['sys_planet_type'][$possible_planet_type_id],
@@ -1682,14 +1681,14 @@  discard block
 block discarded – undo
1682 1681
       'TYPE_PRINT' => classLocale::$lang['fl_shrtcup'][$shortcut['planet_type']],
1683 1682
     );
1684 1683
 
1685
-    if(isset($shortcut['priority'])) {
1684
+    if (isset($shortcut['priority'])) {
1686 1685
       $result += array(
1687 1686
         'PRIORITY'       => $shortcut['priority'],
1688 1687
         'PRIORITY_CLASS' => $note_priority_classes[$shortcut['priority']],
1689 1688
       );
1690 1689
     }
1691 1690
 
1692
-    if(isset($shortcut['id'])) {
1691
+    if (isset($shortcut['id'])) {
1693 1692
       $result += array(
1694 1693
         'ID' => $shortcut['id'],
1695 1694
       );
@@ -1704,7 +1703,7 @@  discard block
 block discarded – undo
1704 1703
   protected function renderFleetShortcuts(&$template_result) {
1705 1704
     // Building list of shortcuts
1706 1705
     $query = db_note_list_select_by_owner_and_planet($this->dbOwnerRow);
1707
-    while($row = db_fetch($query)) {
1706
+    while ($row = db_fetch($query)) {
1708 1707
       $template_result['.']['shortcut'][] = $this->renderFleet1TargetSelect($row);
1709 1708
     }
1710 1709
   }
@@ -1716,12 +1715,12 @@  discard block
 block discarded – undo
1716 1715
    */
1717 1716
   protected function renderOwnPlanets(&$template_result) {
1718 1717
     $colonies = db_planet_list_sorted($this->dbOwnerRow);
1719
-    if(count($colonies) <= 1) {
1718
+    if (count($colonies) <= 1) {
1720 1719
       return;
1721 1720
     }
1722 1721
 
1723
-    foreach($colonies as $row) {
1724
-      if($row['id'] == $this->dbSourcePlanetRow['id']) {
1722
+    foreach ($colonies as $row) {
1723
+      if ($row['id'] == $this->dbSourcePlanetRow['id']) {
1725 1724
         continue;
1726 1725
       }
1727 1726
 
@@ -1734,10 +1733,10 @@  discard block
 block discarded – undo
1734 1733
    */
1735 1734
   protected function renderACSList(&$template_result) {
1736 1735
     $query = db_acs_get_list();
1737
-    while($row = db_fetch($query)) {
1736
+    while ($row = db_fetch($query)) {
1738 1737
       $members = explode(',', $row['eingeladen']);
1739
-      foreach($members as $a => $b) {
1740
-        if($b == $this->dbOwnerRow['id']) {
1738
+      foreach ($members as $a => $b) {
1739
+        if ($b == $this->dbOwnerRow['id']) {
1741 1740
           $template_result['.']['acss'][] = $this->renderFleet1TargetSelect($row);
1742 1741
         }
1743 1742
       }
@@ -1748,7 +1747,7 @@  discard block
 block discarded – undo
1748 1747
    * @param $template_result
1749 1748
    */
1750 1749
   protected function renderShipSortOptions(&$template_result) {
1751
-    foreach(classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) {
1750
+    foreach (classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) {
1752 1751
       $template_result['.']['ship_sort_list'][] = array(
1753 1752
         'VALUE' => $sort_id,
1754 1753
         'TEXT'  => $sort_text,
Please login to merge, or discard this patch.