Passed
Push — work-fleets ( 6f822b...6dcfe4 )
by SuperNova.WS
06:31 queued 16s
created
classes/Common/ObjectCollection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
    * @since 5.0.0
81 81
    */
82 82
   public function offsetUnset($offset) {
83
-    if($this->offsetExists($offset)) {
83
+    if ($this->offsetExists($offset)) {
84 84
       parent::offsetUnset($this->offsetGet($offset));
85 85
     }
86 86
   }
Please login to merge, or discard this patch.
classes/Common/Invoker.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
   }
16 16
 
17 17
   public static function build($callable) {
18
-    if(is_array($callable) && count($callable) == 2 && is_object($callable[0])) {
18
+    if (is_array($callable) && count($callable) == 2 && is_object($callable[0])) {
19 19
       return new static($callable);
20 20
     } else {
21 21
       return false;
Please login to merge, or discard this patch.
includes/includes/flt_flying_fleet_handler2.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,6 @@
 block discarded – undo
14 14
  *
15 15
  * @param Fleet $objFleet
16 16
  * @param bool  $start
17
- * @param null  $result
18 17
  *
19 18
  * @return mixed
20 19
  */
Please login to merge, or discard this patch.
Spacing   +7 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,15 +23,11 @@  discard block
 block discarded – undo
23 23
 // ------------------------------------------------------------------
24 24
 function flt_flyingFleetsSort($a, $b) {
25 25
   // Сравниваем время флотов - кто раньше, тот и первый обрабатывается
26
-  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 :
27
-    // Если время - одинаковое, сравниваем события флотов
26
+  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов
28 27
     // Если события - одинаковые, то флоты равны
29
-    ($a['fleet_event'] == $b['fleet_event'] ? 0 :
30
-      // Если события разные - первыми считаем прибывающие флоты
31
-      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 :
32
-        // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
33
-        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 :
34
-          // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
28
+    ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты
29
+      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
30
+        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
35 31
           // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска
36 32
           (
37 33
           0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
@@ -55,7 +51,7 @@  discard block
 block discarded – undo
55 51
 // ------------------------------------------------------------------
56 52
 function flt_flying_fleet_handler($skip_fleet_update = false) {
57 53
   if (true) {
58
-    if(!defined('IN_AJAX')) {
54
+    if (!defined('IN_AJAX')) {
59 55
       print('<div style="color: red; font-size: 300%">Fleet handler is disabled</div>');
60 56
       pdump('Fleet handler is disabled');
61 57
     }
@@ -190,7 +186,7 @@  discard block
 block discarded – undo
190 186
     // Watchdog timer
191 187
     // If flying fleet handler works more then 10 seconds - stopping it
192 188
     // Let next run handle rest of fleets
193
-    if(time() - SN_TIME_NOW > 10) {
189
+    if (time() - SN_TIME_NOW > 10) {
194 190
       $debug->warning('Flying fleet handler standard routine works more then 10 seconds - watchdog unlocked', 'FFH Warning', 504);
195 191
       break;
196 192
     }
@@ -256,7 +252,7 @@  discard block
 block discarded – undo
256 252
     $objMission->fleet_event = $fleet_event['fleet_event'];
257 253
 
258 254
     // Fleet that have planet destination is returned
259
-    if($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) {
255
+    if ($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) {
260 256
       $objFleet->markReturnedAndSave();
261 257
       sn_db_transaction_commit();
262 258
       continue;
Please login to merge, or discard this patch.
includes/includes/flt_mission_attack.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 
10 10
 /**
11 11
  * @param Mission $objMission
12
- * @param array   $mission_data
13 12
  */
14 13
 function flt_mission_attack($objMission) {
15 14
   $objFleet = $objMission->fleet;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@
 block discarded – undo
14 14
 function flt_mission_attack($objMission) {
15 15
   $objFleet = $objMission->fleet;
16 16
 
17
-  if($objFleet->shipsGetTotal() <= 0) {
17
+  if ($objFleet->shipsGetTotal() <= 0) {
18 18
     return;
19 19
   }
20 20
 
21 21
   $destination_user = $objMission->dst_user;
22 22
 
23
-  if(
23
+  if (
24 24
     // Нет данных о планете назначения или её владельце
25 25
     empty($destination_user)
26 26
     ||
Please login to merge, or discard this patch.
classes/FleetList.php 2 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -64,6 +64,10 @@  discard block
 block discarded – undo
64 64
    *
65 65
    */
66 66
   // DEPRECATED
67
+
68
+  /**
69
+   * @param boolean $for_update
70
+   */
67 71
   public static function dbGetFleetList($where_safe = '', $for_update = DB_SELECT_FOR_UPDATE) {
68 72
     $fleetList = new static();
69 73
     $fleetList->dbLoadWhere($where_safe, $for_update);
@@ -246,6 +250,7 @@  discard block
 block discarded – undo
246 250
    * LIST - Get missile attack list by condition
247 251
    *
248 252
    * @param string $where
253
+   * @param boolean $for_update
249 254
    */
250 255
   public function dbMergeMissileList($where, $for_update = DB_SELECT_FOR_UPDATE) {
251 256
     $query = classSupernova::$db->doSelect(
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
       (!empty($where_safe) ? " WHERE {$where_safe}" : '') .
38 38
       ($for_update == DB_SELECT_FOR_UPDATE ? " FOR UPDATE;" : '')
39 39
     );
40
-    while($row = db_fetch($query)) {
40
+    while ($row = db_fetch($query)) {
41 41
       /**
42 42
        * @var Fleet $fleet
43 43
        */
44 44
       $fleet = $this->_createElement();
45 45
       $fleet->dbRowParse($row);
46 46
 
47
-      if(isset($this[$fleet->dbId])) {
47
+      if (isset($this[$fleet->dbId])) {
48 48
         // Нужно ли ????
49 49
         classSupernova::$debug->error('Fleet list already set');
50 50
       }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
    * @return static|array
171 171
    */
172 172
   public static function dbGetFleetListAndMissileByCoordinates($coordinates, $for_phalanx = false) {
173
-    if(empty($coordinates) || !is_array($coordinates)) {
173
+    if (empty($coordinates) || !is_array($coordinates)) {
174 174
       return array();
175 175
     }
176 176
 
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
      * @var Fleet[] $array_of_Fleet
202 202
      */
203 203
     $array_of_Fleet = array();
204
-    if(!empty($fleet_db_list) && $fleet_db_list->count()) {
205
-      foreach($fleet_db_list->_container as $fleet_id => $objFleet) {
204
+    if (!empty($fleet_db_list) && $fleet_db_list->count()) {
205
+      foreach ($fleet_db_list->_container as $fleet_id => $objFleet) {
206 206
         $array_of_Fleet[$fleet_id] = $objFleet;
207 207
       }
208 208
       $planet_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet);
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
       (!empty($where) ? " WHERE {$where}" : '') .
254 254
       ($for_update == DB_SELECT_FOR_UPDATE ? " FOR UPDATE;" : '')
255 255
     );
256
-    while($missile_db_row = db_fetch($query)) {
256
+    while ($missile_db_row = db_fetch($query)) {
257 257
       /**
258 258
        * @var Fleet $objFleet
259 259
        */
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
    */
276 276
   public static function dbGetFleetListAndMissileINCOMING($owner_id) {
277 277
     $owner_id_safe = idval($owner_id);
278
-    if(empty($owner_id_safe)) {
278
+    if (empty($owner_id_safe)) {
279 279
       return array();
280 280
     }
281 281
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
    */
310 310
   public static function fleet_count_flying($player_id, $mission_id = 0) {
311 311
     $player_id_safe = idval($player_id);
312
-    if(!empty($player_id_safe)) {
312
+    if (!empty($player_id_safe)) {
313 313
       $mission_id_safe = intval($mission_id);
314 314
       $result = static::db_fleet_count(
315 315
         "`fleet_owner` = {$player_id_safe}" .
Please login to merge, or discard this patch.
classes/FleetValidator.php 2 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 
821 821
 
822 822
   /**
823
-   * @return int
823
+   * @return boolean
824 824
    */
825 825
   protected function checkExpeditionsMax() {
826 826
     return get_player_max_expeditons($this->fleet->dbOwnerRow) > 0;
@@ -920,6 +920,10 @@  discard block
 block discarded – undo
920 920
       $this->checkMissionExact($missionType);
921 921
   }
922 922
 
923
+  /**
924
+   * @param integer $missionType
925
+   * @param boolean $result
926
+   */
923 927
   protected function checkMissionResultAndUnset($missionType, $result, $forceMission = false) {
924 928
     $this->unsetMission($missionType, $result, $forceMission);
925 929
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     'checkSpeedPercentOld'       => FLIGHT_FLEET_SPEED_WRONG,
17 17
     'checkTargetInUniverse'      => FLIGHT_VECTOR_BEYOND_UNIVERSE,
18 18
     'checkTargetNotSource'       => FLIGHT_VECTOR_SAME_SOURCE,
19
-    'checkSenderNoVacation'      => FLIGHT_PLAYER_VACATION_OWN,  // tODO
19
+    'checkSenderNoVacation'      => FLIGHT_PLAYER_VACATION_OWN, // tODO
20 20
     'checkTargetNoVacation'      => FLIGHT_PLAYER_VACATION,
21 21
     'checkFleetNotEmpty'         => FLIGHT_SHIPS_NO_SHIPS,
22 22
     // 'checkUnitsPositive'         => FLIGHT_SHIPS_NEGATIVE, // Unused - 'cause it's not allowed to put negative units into Unit class
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         $this->checkMissionRestrictions($action);
159 159
       } else {
160 160
         // No - then just performing action
161
-        if($exception) {
161
+        if ($exception) {
162 162
           throw new ExceptionFleetInvalid($action, $action);
163 163
         } else {
164 164
           return $action;
Please login to merge, or discard this patch.
includes/includes/flt_mission_recycle.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
   $RecyclerCapacity = 0;
17 17
   $OtherFleetCapacity = 0;
18 18
 
19
-  foreach($objFleet->shipsIterator() as $unit_id => $unit) {
20
-    if(in_array($unit_id, classSupernova::$gc->groupFleet)) {
19
+  foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
20
+    if (in_array($unit_id, classSupernova::$gc->groupFleet)) {
21 21
       $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit->count;
22
-      if(in_array($unit_id, classSupernova::$gc->groupRecyclers)) {
22
+      if (in_array($unit_id, classSupernova::$gc->groupRecyclers)) {
23 23
         $RecyclerCapacity += $capacity;
24 24
       } else {
25 25
         $OtherFleetCapacity += $capacity;
@@ -28,33 +28,33 @@  discard block
 block discarded – undo
28 28
   }
29 29
 
30 30
   $fleet_resources_amount = $objFleet->resourcesGetTotal();
31
-  if($fleet_resources_amount > $OtherFleetCapacity) {
31
+  if ($fleet_resources_amount > $OtherFleetCapacity) {
32 32
     // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков
33 33
     // Уменьшаем ёмкость переработчиков на указанную величину
34 34
     $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity);
35 35
   }
36 36
 
37 37
   $resources_recycled = array();
38
-  if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
38
+  if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
39 39
     $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
40 40
     $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
41 41
   } else {
42
-    if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
42
+    if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
43 43
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)
44 44
     ) {
45 45
       $resources_recycled[RES_METAL] = $RecyclerCapacity / 2;
46 46
       $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2;
47 47
     } else {
48
-      if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
48
+      if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
49 49
         $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
50
-        if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
50
+        if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
51 51
           $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL];
52 52
         } else {
53 53
           $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
54 54
         }
55 55
       } else {
56 56
         $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
57
-        if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
57
+        if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
58 58
           $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL];
59 59
         } else {
60 60
           $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
Please login to merge, or discard this patch.
includes/includes/flt_functions.php 2 patches
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -8,14 +8,14 @@  discard block
 block discarded – undo
8 8
 use Vector\Vector;
9 9
 
10 10
 function flt_fleet_speed($user, $fleet) {
11
-  if(!is_array($fleet)) {
11
+  if (!is_array($fleet)) {
12 12
     $fleet = array($fleet => 1);
13 13
   }
14 14
 
15 15
   $speeds = array();
16
-  if(!empty($fleet)) {
17
-    foreach($fleet as $ship_id => $amount) {
18
-      if($amount && in_array($ship_id, classSupernova::$gc->groupFleetAndMissiles)) {
16
+  if (!empty($fleet)) {
17
+    foreach ($fleet as $ship_id => $amount) {
18
+      if ($amount && in_array($ship_id, classSupernova::$gc->groupFleetAndMissiles)) {
19 19
         $single_ship_data = get_ship_data($ship_id, $user);
20 20
         $speeds[] = $single_ship_data['speed'];
21 21
       }
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 
48 48
   $game_fleet_speed = flt_server_flight_speed_multiplier();
49 49
   $fleet_speed = flt_fleet_speed($user_row, $fleet_array);
50
-  if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) {
50
+  if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) {
51 51
     $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10;
52 52
     $real_speed = $speed_percent * sqrt($fleet_speed);
53 53
 
54 54
     $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed));
55 55
 
56
-    foreach($fleet_array as $ship_id => $ship_count) {
57
-      if(!$ship_id || !$ship_count) {
56
+    foreach ($fleet_array as $ship_id => $ship_count) {
57
+      if (!$ship_id || !$ship_count) {
58 58
         continue;
59 59
       }
60 60
 
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
 function flt_bashing_check($user, $enemy, $planet_dst, $mission, $flight_duration, $fleet_group = 0) {
83 83
   $config_bashing_attacks = classSupernova::$config->fleet_bashing_attacks;
84 84
   $config_bashing_interval = classSupernova::$config->fleet_bashing_interval;
85
-  if(!$config_bashing_attacks) {
85
+  if (!$config_bashing_attacks) {
86 86
     // Bashing allowed - protection disabled
87 87
     return FLIGHT_ALLOWED;
88 88
   }
89 89
 
90 90
   $bashing_result = FLIGHT_MISSION_ATTACK_BASHING;
91
-  if($user['ally_id'] && $enemy['ally_id']) {
91
+  if ($user['ally_id'] && $enemy['ally_id']) {
92 92
     $relations = ali_relations($user['ally_id'], $enemy['ally_id']);
93
-    if(!empty($relations)) {
93
+    if (!empty($relations)) {
94 94
       $relations = $relations[$enemy['ally_id']];
95
-      switch($relations['alliance_diplomacy_relation']) {
95
+      switch ($relations['alliance_diplomacy_relation']) {
96 96
         case ALLY_DIPLOMACY_WAR:
97
-          if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) {
97
+          if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= classSupernova::$config->fleet_bashing_war_delay) {
98 98
             $bashing_result = FLIGHT_MISSION_ATTACK_BASHING_WAR_DELAY;
99 99
           } else {
100 100
             return FLIGHT_ALLOWED;
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 
117 117
   // Retrieving flying fleets
118 118
   $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $planet_dst);
119
-  foreach($objFleetsBashing->_container as $fleetBashing) {
119
+  foreach ($objFleetsBashing->_container as $fleetBashing) {
120 120
     // Checking for ACS - each ACS count only once
121
-    if($fleetBashing->group_id) {
121
+    if ($fleetBashing->group_id) {
122 122
       $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target;
123 123
     } else {
124 124
       $bashing_list[] = $fleetBashing->time_arrive_to_target;
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
   }
127 127
 
128 128
   // Check for joining to ACS - if there are already fleets in ACS no checks should be done
129
-  if($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) {
129
+  if ($mission == MT_ACS && $bashing_list["{$user['id']}_{$fleet_group}"]) {
130 130
     return FLIGHT_ALLOWED;
131 131
   }
132 132
 
133 133
   $query = DBStaticFleetBashing::db_bashing_list_get($user, $planet_dst, $time_limit);
134
-  while($bashing_row = db_fetch($query)) {
134
+  while ($bashing_row = db_fetch($query)) {
135 135
     $bashing_list[] = $bashing_row['bashing_time'];
136 136
   }
137 137
 
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
   $last_attack = 0;
141 141
   $wave = 0;
142 142
   $attack = 1;
143
-  foreach($bashing_list as &$bash_time) {
143
+  foreach ($bashing_list as &$bash_time) {
144 144
     $attack++;
145
-    if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) {
145
+    if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) {
146 146
       $attack = 1;
147 147
       $wave++;
148 148
     }
@@ -159,16 +159,16 @@  discard block
 block discarded – undo
159 159
   //TODO: try..catch
160 160
   global $user;
161 161
 
162
-  if($user['vacation']) {
162
+  if ($user['vacation']) {
163 163
     return $result = FLIGHT_PLAYER_VACATION_OWN;
164 164
   }
165 165
 
166
-  if(empty($fleet) || !is_array($fleet)) {
166
+  if (empty($fleet) || !is_array($fleet)) {
167 167
     return $result = FLIGHT_SHIPS_NO_SHIPS;
168 168
   }
169 169
 
170 170
   $sn_groups_mission = sn_get_groups('missions');
171
-  if(!isset($sn_groups_mission[$mission])) {
171
+  if (!isset($sn_groups_mission[$mission])) {
172 172
     return $result = FLIGHT_MISSION_UNKNOWN;
173 173
   }
174 174
   $sn_data_mission = $sn_groups_mission[$mission];
@@ -187,32 +187,32 @@  discard block
 block discarded – undo
187 187
   $resources = 0;
188 188
   $ship_ids = classSupernova::$gc->groupFleet;
189 189
   $resource_ids = sn_get_groups('resources_loot');
190
-  foreach($fleet as $ship_id => $ship_count) {
190
+  foreach ($fleet as $ship_id => $ship_count) {
191 191
     $is_ship = in_array($ship_id, $ship_ids);
192 192
     $is_resource = in_array($ship_id, $resource_ids);
193
-    if(!$is_ship && !$is_resource) {
193
+    if (!$is_ship && !$is_resource) {
194 194
       // TODO Спецобработчик для Капитана и модулей
195 195
 //      return FLIGHT_SHIPS_UNIT_WRONG;
196 196
     }
197 197
 
198
-    if($ship_count < 0) {
198
+    if ($ship_count < 0) {
199 199
       return $result = $is_ship ? FLIGHT_SHIPS_NEGATIVE : FLIGHT_RESOURCES_NEGATIVE;
200 200
     }
201 201
 
202
-    if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) {
202
+    if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) {
203 203
       // TODO FLIGHT_MISSION_MISSILE_NO_MISSILES
204 204
       return $result = $is_ship ? FLIGHT_SHIPS_NOT_ENOUGH_OR_RESOURCES : FLIGHT_RESOURCES_NOT_ENOUGH;
205 205
     }
206 206
 
207
-    if($is_ship) {
207
+    if ($is_ship) {
208 208
       $single_ship_data = get_ship_data($ship_id, $user);
209
-      if($single_ship_data[P_SPEED] <= 0) {
209
+      if ($single_ship_data[P_SPEED] <= 0) {
210 210
         return $result = FLIGHT_SHIPS_UNMOVABLE;
211 211
       }
212 212
       $ships += $ship_count;
213 213
       $recyclers += in_array($ship_id, classSupernova::$gc->groupRecyclers) ? $ship_count : 0;
214 214
       $spies += $ship_id == SHIP_SPY ? $ship_count : 0;
215
-    } elseif($is_resource) {
215
+    } elseif ($is_resource) {
216 216
       $resources += $ship_count;
217 217
     }
218 218
   }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
     }
224 224
   */
225 225
 
226
-  if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) {
226
+  if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) {
227 227
     return $result = FLIGHT_RESOURCES_FORBIDDEN;
228 228
   }
229 229
 
@@ -235,78 +235,78 @@  discard block
 block discarded – undo
235 235
   */
236 236
 
237 237
   $speed = $options['fleet_speed_percent'];
238
-  if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) {
238
+  if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) {
239 239
     return $result = FLIGHT_FLEET_SPEED_WRONG;
240 240
   }
241 241
 
242 242
   $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']);
243 243
 
244 244
 
245
-  if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) {
245
+  if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) {
246 246
     return $result = FLIGHT_RESOURCES_FUEL_NOT_ENOUGH;
247 247
   }
248 248
 
249
-  if($travel_data['consumption'] > $travel_data['capacity']) {
249
+  if ($travel_data['consumption'] > $travel_data['capacity']) {
250 250
     return $result = FLIGHT_FLEET_TOO_FAR;
251 251
   }
252 252
 
253
-  if($travel_data['hold'] < $resources) {
253
+  if ($travel_data['hold'] < $resources) {
254 254
     return $result = FLIGHT_FLEET_OVERLOAD;
255 255
   }
256 256
 
257 257
   $fleet_start_time = SN_TIME_NOW + $travel_data['duration'];
258 258
 
259 259
   $fleet_group = $options['fleet_group'];
260
-  if($fleet_group) {
261
-    if($mission != MT_ACS) {
260
+  if ($fleet_group) {
261
+    if ($mission != MT_ACS) {
262 262
       return $result = FLIGHT_MISSION_IMPOSSIBLE;
263 263
     };
264 264
 
265 265
     $acs = DBStaticFleetACS::db_acs_get_by_group_id($fleet_group);
266
-    if(!$acs['id']) {
266
+    if (!$acs['id']) {
267 267
       return $result = FLIGHT_MISSION_ACS_NOT_EXISTS;
268 268
     }
269 269
 
270
-    if($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) {
270
+    if ($planet_dst['galaxy'] != $acs['galaxy'] || $planet_dst['system'] != $acs['system'] || $planet_dst['planet'] != $acs['planet'] || $planet_dst['planet_type'] != $acs['planet_type']) {
271 271
       return $result = FLIGHT_MISSION_ACS_WRONG_TARGET;
272 272
     }
273 273
 
274
-    if($fleet_start_time > $acs['ankunft']) {
274
+    if ($fleet_start_time > $acs['ankunft']) {
275 275
       return $result = FLIGHT_MISSION_ACS_TOO_LATE;
276 276
     }
277 277
   }
278 278
 
279 279
   $flying_fleets = $options['flying_fleets'];
280
-  if(!$flying_fleets) {
280
+  if (!$flying_fleets) {
281 281
     $flying_fleets = FleetList::fleet_count_flying($user['id']);
282 282
   }
283
-  if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) {
283
+  if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) {
284 284
     return $result = FLIGHT_FLEET_NO_SLOTS;
285 285
   }
286 286
 
287 287
   // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт
288
-  if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) {
288
+  if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) {
289 289
     return $result = FLIGHT_SHIPS_NOT_ONLY_SPIES;
290 290
   }
291 291
 
292 292
   // Checking for no planet
293
-  if(!$planet_dst['id_owner']) {
294
-    if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) {
293
+  if (!$planet_dst['id_owner']) {
294
+    if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) {
295 295
       return $result = FLIGHT_SHIPS_NO_COLONIZER;
296 296
     }
297 297
 
298
-    if($mission == MT_EXPLORE || $mission == MT_COLONIZE) {
298
+    if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) {
299 299
       return $result = FLIGHT_ALLOWED;
300 300
     }
301 301
 
302 302
     return $result = FLIGHT_VECTOR_NO_TARGET;
303 303
   }
304 304
 
305
-  if($mission == MT_RECYCLE) {
306
-    if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) {
305
+  if ($mission == MT_RECYCLE) {
306
+    if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) {
307 307
       return $result = FLIGHT_MISSION_RECYCLE_NO_DEBRIS;
308 308
     }
309
-    if($recyclers <= 0) {
309
+    if ($recyclers <= 0) {
310 310
       return $result = FLIGHT_SHIPS_NO_RECYCLERS;
311 311
     }
312 312
 
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
   }
315 315
 
316 316
   // Got planet. Checking if it is ours
317
-  if($planet_dst['id_owner'] == $user['id']) {
318
-    if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) {
317
+  if ($planet_dst['id_owner'] == $user['id']) {
318
+    if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) {
319 319
       return $result = FLIGHT_ALLOWED;
320 320
     }
321 321
 
@@ -323,19 +323,19 @@  discard block
 block discarded – undo
323 323
   }
324 324
 
325 325
   // No, planet not ours. Cutting mission that can't be send to not-ours planet
326
-  if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) {
326
+  if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) {
327 327
     return $result = FLIGHT_MISSION_IMPOSSIBLE;
328 328
   }
329 329
 
330 330
   $enemy = DBStaticUser::db_user_by_id($planet_dst['id_owner']);
331 331
   // We cannot attack or send resource to users in VACATION mode
332
-  if($enemy['vacation'] && $mission != MT_RECYCLE) {
332
+  if ($enemy['vacation'] && $mission != MT_RECYCLE) {
333 333
     return $result = FLIGHT_PLAYER_VACATION;
334 334
   }
335 335
 
336 336
   // Multi IP protection
337 337
   // TODO: Here we need a procedure to check proxies
338
-  if(sys_is_multiaccount($user, $enemy)) {
338
+  if (sys_is_multiaccount($user, $enemy)) {
339 339
     return $result = FLIGHT_PLAYER_SAME_IP;
340 340
   }
341 341
 
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
   $enemy_points = $enemy['total_points'];
344 344
 
345 345
   // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer
346
-  if($mission == MT_TRANSPORT) {
347
-    if($user_points >= $enemy_points || classSupernova::$config->allow_buffing) {
346
+  if ($mission == MT_TRANSPORT) {
347
+    if ($user_points >= $enemy_points || classSupernova::$config->allow_buffing) {
348 348
       return $result = FLIGHT_ALLOWED;
349 349
     } else {
350 350
       return $result = FLIGHT_PLAYER_BUFFING;
@@ -354,66 +354,66 @@  discard block
 block discarded – undo
354 354
   // Only aggresive missions passed to this point. HOLD counts as passive but aggresive
355 355
 
356 356
   // Is it admin with planet protection?
357
-  if($planet_dst['id_level'] > $user['authlevel']) {
357
+  if ($planet_dst['id_level'] > $user['authlevel']) {
358 358
     return $result = FLIGHT_PLAYER_ADMIN;
359 359
   }
360 360
 
361 361
   // Okay. Now skipping protection checks for inactive longer then 1 week
362
-  if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) {
363
-    if(
362
+  if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) {
363
+    if (
364 364
       ($enemy_points <= classSupernova::$config->game_noob_points && $user_points > classSupernova::$config->game_noob_points)
365 365
       ||
366 366
       (classSupernova::$config->game_noob_factor && $user_points > $enemy_points * classSupernova::$config->game_noob_factor)
367 367
     ) {
368
-      if($mission != MT_HOLD) {
368
+      if ($mission != MT_HOLD) {
369 369
         return $result = FLIGHT_PLAYER_NOOB;
370 370
       }
371
-      if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) {
371
+      if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && classSupernova::$config->ally_help_weak)) {
372 372
         return $result = FLIGHT_PLAYER_NOOB;
373 373
       }
374 374
     }
375 375
   }
376 376
 
377 377
   // Is it HOLD mission? If yes - there should be ally deposit
378
-  if($mission == MT_HOLD) {
379
-    if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) {
378
+  if ($mission == MT_HOLD) {
379
+    if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) {
380 380
       return $result = FLIGHT_ALLOWED;
381 381
     }
382 382
 
383 383
     return $result = FLIGHT_MISSION_HOLD_NO_ALLY_DEPOSIT;
384 384
   }
385 385
 
386
-  if($mission == MT_SPY) {
386
+  if ($mission == MT_SPY) {
387 387
     return $result = $spies >= 1 ? FLIGHT_ALLOWED : FLIGHT_MISSION_SPY_NO_SPIES;
388 388
   }
389 389
 
390 390
   // Is it MISSILE mission?
391
-  if($mission == MT_MISSILE) {
391
+  if ($mission == MT_MISSILE) {
392 392
     $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
393
-    if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) {
393
+    if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) {
394 394
       return $result = FLIGHT_MISSION_MISSILE_NO_SILO;
395 395
     }
396 396
 
397
-    if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) {
397
+    if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) {
398 398
       return $result = FLIGHT_MISSION_MISSILE_NO_MISSILES;
399 399
     }
400 400
 
401 401
     $distance = abs($planet_dst['system'] - $planet_src['system']);
402 402
     $mip_range = flt_get_missile_range($user);
403
-    if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) {
403
+    if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) {
404 404
       return $result = FLIGHT_MISSION_MISSILE_TOO_FAR;
405 405
     }
406 406
 
407
-    if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) {
407
+    if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) {
408 408
       return $result = FLIGHT_MISSION_MISSILE_WRONG_STRUCTURE;
409 409
     }
410 410
   }
411 411
 
412
-  if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) {
412
+  if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) {
413 413
     return $result = FLIGHT_MISSION_IMPOSSIBLE;
414 414
   }
415 415
 
416
-  if($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) {
416
+  if ($mission == MT_ATTACK || $mission == MT_ACS || $mission == MT_DESTROY) {
417 417
     return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group);
418 418
   }
419 419
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
   $from = $from['planet'];
441 441
 
442 442
   $can_attack = flt_can_attack($from, $to, $fleet_REAL_array, $mission, $options);
443
-  if($can_attack != FLIGHT_ALLOWED) {
443
+  if ($can_attack != FLIGHT_ALLOWED) {
444 444
     $internal_transaction ? sn_db_transaction_rollback() : false;
445 445
 
446 446
     return $can_attack;
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
   $travel_data = flt_travel_data($user, $from, $to, $fleet_REAL_array, $options['fleet_speed_percent']);
452 452
 
453 453
   $time_on_mission = 0;
454
-  if($mission == MT_EXPLORE || $mission == MT_HOLD) {
454
+  if ($mission == MT_EXPLORE || $mission == MT_HOLD) {
455 455
     // TODO - include some checks about maximum and minumum stay_duration
456 456
     $time_on_mission = $options['stay_time'] * 3600;
457 457
   }
@@ -473,14 +473,14 @@  discard block
 block discarded – undo
473 473
   $sn_group_fleet = classSupernova::$gc->groupFleet;
474 474
   $sn_group_resources_loot = sn_get_groups('resources_loot');
475 475
   $planetRowFieldChanges = array();
476
-  foreach($fleet_REAL_array as $unit_id => $amount) {
477
-    if(!$amount || !$unit_id) {
476
+  foreach ($fleet_REAL_array as $unit_id => $amount) {
477
+    if (!$amount || !$unit_id) {
478 478
       continue;
479 479
     }
480 480
 
481
-    if(in_array($unit_id, $sn_group_fleet)) {
481
+    if (in_array($unit_id, $sn_group_fleet)) {
482 482
       DBStaticUnit::dbUpdateOrInsertUnit($unit_id, -$amount, $user, $from['id']);
483
-    } elseif(in_array($unit_id, $sn_group_resources_loot)) {
483
+    } elseif (in_array($unit_id, $sn_group_resources_loot)) {
484 484
       $planetRowFieldChanges[$unit_id] -= $amount;
485 485
     }
486 486
   }
@@ -512,16 +512,16 @@  discard block
 block discarded – undo
512 512
 
513 513
   $ship_data = array();
514 514
   $fleet_array = array();
515
-  foreach($ship_list as $transport_id => $cork) {
515
+  foreach ($ship_list as $transport_id => $cork) {
516 516
     $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10);
517 517
   }
518 518
   uasort($ship_data, 'flt_calculate_ship_to_transport_sort');
519 519
 
520 520
   $fleet_capacity = 0;
521 521
   $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM);
522
-  foreach($ship_data as $transport_id => &$ship_info) {
522
+  foreach ($ship_data as $transport_id => &$ship_info) {
523 523
     $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption']));
524
-    if($ship_loaded) {
524
+    if ($ship_loaded) {
525 525
       $fleet_array[$transport_id] = $ship_loaded;
526 526
       $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded);
527 527
       $fuel_left -= $ship_info['consumption'] * $ship_loaded;
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -7,6 +7,9 @@
 block discarded – undo
7 7
 use DBStatic\DBStaticUser;
8 8
 use Vector\Vector;
9 9
 
10
+/**
11
+ * @return double
12
+ */
10 13
 function flt_fleet_speed($user, $fleet) {
11 14
   if(!is_array($fleet)) {
12 15
     $fleet = array($fleet => 1);
Please login to merge, or discard this patch.
classes/Fleet.php 3 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
   /**
980 980
    * Set current resource list from array of units
981 981
    *
982
-   * @param array $resource_list
982
+   * @param integer[] $resource_list
983 983
    */
984 984
   public function resourcesSet($resource_list) {
985 985
     if (!empty($this->propertiesAdjusted['resource_list'])) {
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
   }
1028 1028
 
1029 1029
   /**
1030
-   * @param array $rate
1030
+   * @param integer[] $rate
1031 1031
    *
1032 1032
    * @return float
1033 1033
    */
@@ -1058,8 +1058,6 @@  discard block
 block discarded – undo
1058 1058
    * Restores fleet or resources to planet
1059 1059
    *
1060 1060
    * @param bool $start
1061
-   * @param bool $only_resources
1062
-   * @param int  $result
1063 1061
    */
1064 1062
   public function resourcesUnload($start = true) {
1065 1063
     sn_db_transaction_check(true);
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 use DBStatic\DBStaticFleetACS;
3
-use DBStatic\DBStaticNote;
4 3
 use DBStatic\DBStaticPlanet;
5 4
 use DBStatic\DBStaticUnit;
6 5
 use DBStatic\DBStaticUser;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1325,14 +1325,14 @@
 block discarded – undo
1325 1325
       if (FLIGHT_ALLOWED == $validateResult[$missionType]) {
1326 1326
         $this->allowed_missions[$missionType] = $mission;
1327 1327
       } else {
1328
-        if($missionType == $this->mission_type) {
1328
+        if ($missionType == $this->mission_type) {
1329 1329
         }
1330 1330
         unset($this->allowed_missions[$missionType]);
1331 1331
       }
1332 1332
     }
1333 1333
 
1334
-    if(empty($this->allowed_missions)) {
1335
-      if($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) {
1334
+    if (empty($this->allowed_missions)) {
1335
+      if ($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) {
1336 1336
         throw new ExceptionFleetInvalid($validateResult[$this->mission_type], $validateResult[$this->mission_type]);
1337 1337
       } else {
1338 1338
         throw new ExceptionFleetInvalid(FLIGHT_MISSION_IMPOSSIBLE, FLIGHT_MISSION_IMPOSSIBLE);
Please login to merge, or discard this patch.