Completed
Push — work-fleets ( 3604bd...203362 )
by SuperNova.WS
06:25
created
classes/V2Unit/V2UnitList.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -31,6 +31,9 @@
 block discarded – undo
31 31
 
32 32
   }
33 33
 
34
+  /**
35
+   * @param integer $snId
36
+   */
34 37
   public function unitAdd($snId, $level) {
35 38
     if($this->indexIsSet($snId)) {
36 39
       $this->indexGetObject($snId)->$level += $level;
Please login to merge, or discard this patch.
classes/V2Fleet/V2FleetModel.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,6 @@
 block discarded – undo
7 7
 
8 8
 use Common\V2Location;
9 9
 use DBStatic\DBStaticFleetACS;
10
-use V2Unit\V2UnitList;
11 10
 use Vector\Vector;
12 11
 use Entity\KeyedModel;
13 12
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -93,28 +93,28 @@  discard block
 block discarded – undo
93 93
   public function __construct(\Common\GlobalContainer $gc) {
94 94
     parent::__construct($gc);
95 95
 
96
-    $this->accessors->set(P_CONTAINER_SET, 'dbId', function (V2FleetContainer $that, $value) {
96
+    $this->accessors->set(P_CONTAINER_SET, 'dbId', function(V2FleetContainer $that, $value) {
97 97
       $that->setDirect('dbId', $value);
98 98
       $that->location->setLocationId($value);
99 99
     });
100 100
 
101
-    $this->accessors->set(P_CONTAINER_SET, 'ownerId', function (V2FleetContainer $that, $value) {
101
+    $this->accessors->set(P_CONTAINER_SET, 'ownerId', function(V2FleetContainer $that, $value) {
102 102
       $that->setDirect('ownerId', $value);
103 103
       $that->location->setLocationPlayerId($value);
104 104
     });
105 105
 
106
-    $this->accessors->set(P_CONTAINER_SET, 'owner', function (V2FleetContainer $that, $value) {
106
+    $this->accessors->set(P_CONTAINER_SET, 'owner', function(V2FleetContainer $that, $value) {
107 107
       $that->owner = $value;
108
-      if(isset($value['id'])) {
108
+      if (isset($value['id'])) {
109 109
         $that->ownerId = $value['id'];
110 110
       } else {
111 111
         $that->ownerId = 0;
112 112
       }
113 113
     });
114 114
 
115
-    $this->accessors->set(P_CONTAINER_SET, 'departure', function (V2FleetContainer $that, $value) {
115
+    $this->accessors->set(P_CONTAINER_SET, 'departure', function(V2FleetContainer $that, $value) {
116 116
       $that->departure = $value;
117
-      if(isset($value['id'])) {
117
+      if (isset($value['id'])) {
118 118
         $that->departurePlanetId = $value['id'];
119 119
         $that->vectorDeparture = $value;
120 120
       } else {
@@ -122,20 +122,20 @@  discard block
 block discarded – undo
122 122
       }
123 123
     });
124 124
 
125
-    $this->accessors->set(P_CONTAINER_GET, 'vectorDeparture', function (V2FleetContainer $that) {
125
+    $this->accessors->set(P_CONTAINER_GET, 'vectorDeparture', function(V2FleetContainer $that) {
126 126
       $vector = new Vector();
127 127
       $that->setDirect('vectorDeparture', $vector);
128 128
 
129 129
       return $vector;
130 130
     }, ACCESSOR_SHARED);
131
-    $this->accessors->set(P_CONTAINER_SET, 'vectorDeparture', function (V2FleetContainer $that, $value) {
131
+    $this->accessors->set(P_CONTAINER_SET, 'vectorDeparture', function(V2FleetContainer $that, $value) {
132 132
       $vector = $that->vectorDeparture;
133 133
 
134
-      if(is_array($value)) {
134
+      if (is_array($value)) {
135 135
         $value = Vector::convertToVector($value);
136 136
       }
137 137
 
138
-      if($value instanceof Vector) {
138
+      if ($value instanceof Vector) {
139 139
         $vector->readFromVector($value);
140 140
       } else {
141 141
         throw new \Exception('V2Fleet::vectorDeparture setter - value is not a Vector or array!', ERR_ERROR);
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     $this->accessors->set(P_CONTAINER_EXPORT, 'vectorArrive', array($this, 'exportVector'));
149 149
 
150 150
 
151
-    $this->accessors->set(P_CONTAINER_GET, 'location', function (V2FleetContainer $that) {
151
+    $this->accessors->set(P_CONTAINER_GET, 'location', function(V2FleetContainer $that) {
152 152
 //      if (is_null($location = $that->getDirect('location'))) {}
153 153
       $location = new V2Location(LOC_FLEET);
154 154
       $that->setDirect('location', $location);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
       return $location;
157 157
     }, ACCESSOR_SHARED);
158 158
 
159
-    $this->accessors->set(P_CONTAINER_GET, 'units', function (V2FleetContainer $that) {
159
+    $this->accessors->set(P_CONTAINER_GET, 'units', function(V2FleetContainer $that) {
160 160
 //      if (is_null($units = $that->getDirect('units'))) {}
161 161
       $units = \classSupernova::$gc->unitList;
162 162
       $that->setDirect('units', $units);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
       return $units;
165 165
     }, ACCESSOR_SHARED);
166 166
 
167
-    $this->accessors->set(P_CONTAINER_GET, 'isReturning', function (V2FleetContainer $that) {
167
+    $this->accessors->set(P_CONTAINER_GET, 'isReturning', function(V2FleetContainer $that) {
168 168
       return $that->status == FLEET_FLAG_RETURNING;
169 169
     });
170 170
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -213,7 +213,7 @@
 block discarded – undo
213 213
   /**
214 214
    * @param int|string $dbId
215 215
    *
216
-   * @return V2FleetContainer|false
216
+   * @return V2FleetContainer
217 217
    */
218 218
   public function loadById($dbId) {
219 219
     /**
Please login to merge, or discard this patch.
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_mission_transport.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
   $source_planet = &$mission_data->src_planet;
19 19
   $destination_planet = &$mission_data->dst_planet;
20 20
 
21
-  if(empty($destination_planet['id_owner'])) {
21
+  if (empty($destination_planet['id_owner'])) {
22 22
     $objFleet->markReturnedAndSave();
23 23
 
24 24
     return $result;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     $fleet_resources[RES_DEUTERIUM], classLocale::$lang['Deuterium']);
34 34
   DBStaticMessages::msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_transport'], $Message);
35 35
 
36
-  if($objFleet->target_owner_id <> $objFleet->playerOwnerId) {
36
+  if ($objFleet->target_owner_id <> $objFleet->playerOwnerId) {
37 37
     DBStaticMessages::msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_transport'], $Message);
38 38
   }
39 39
 
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.
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;"
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
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
 
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
      * @var Fleet[] $array_of_Fleet
200 200
      */
201 201
     $array_of_Fleet = array();
202
-    if(!empty($fleet_db_list) && $fleet_db_list->count()) {
203
-      foreach($fleet_db_list->_container as $fleet_id => $objFleet) {
202
+    if (!empty($fleet_db_list) && $fleet_db_list->count()) {
203
+      foreach ($fleet_db_list->_container as $fleet_id => $objFleet) {
204 204
         $array_of_Fleet[$fleet_id] = $objFleet;
205 205
       }
206 206
       $planet_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet);
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
       "SELECT * FROM `{{iraks}}`" .
250 250
       (!empty($where) ? " WHERE {$where}" : '') .
251 251
       " FOR UPDATE;");
252
-    while($missile_db_row = db_fetch($query)) {
252
+    while ($missile_db_row = db_fetch($query)) {
253 253
       /**
254 254
        * @var Fleet $objFleet
255 255
        */
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
    */
272 272
   public static function dbGetFleetListAndMissileINCOMING($owner_id) {
273 273
     $owner_id_safe = idval($owner_id);
274
-    if(empty($owner_id_safe)) {
274
+    if (empty($owner_id_safe)) {
275 275
       return array();
276 276
     }
277 277
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
    */
306 306
   public static function fleet_count_flying($player_id, $mission_id = 0) {
307 307
     $player_id_safe = idval($player_id);
308
-    if(!empty($player_id_safe)) {
308
+    if (!empty($player_id_safe)) {
309 309
       $mission_id_safe = intval($mission_id);
310 310
       $result = static::db_fleet_count(
311 311
         "`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.