Completed
Push — work-fleets ( ff9274...a405f7 )
by SuperNova.WS
06:32
created
classes/Pimple/Container.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 
240 240
         $factory = $this->values[$id];
241 241
 
242
-        $extended = function ($c) use ($callable, $factory) {
242
+        $extended = function($c) use ($callable, $factory) {
243 243
             return $callable($factory($c), $c);
244 244
         };
245 245
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
  *
32 32
  * @author  Fabien Potencier
33 33
  */
34
-class Container implements \ArrayAccess
35
-{
34
+class Container implements \ArrayAccess {
36 35
     private $values = array();
37 36
     private $factories;
38 37
     private $protected;
@@ -47,8 +46,7 @@  discard block
 block discarded – undo
47 46
      *
48 47
      * @param array $values The parameters or objects.
49 48
      */
50
-    public function __construct(array $values = array())
51
-    {
49
+    public function __construct(array $values = array()) {
52 50
         $this->factories = new \SplObjectStorage();
53 51
         $this->protected = new \SplObjectStorage();
54 52
 
@@ -71,8 +69,7 @@  discard block
 block discarded – undo
71 69
      *
72 70
      * @throws \RuntimeException Prevent override of a frozen service
73 71
      */
74
-    public function offsetSet($id, $value)
75
-    {
72
+    public function offsetSet($id, $value) {
76 73
         if (isset($this->frozen[$id])) {
77 74
             throw new \RuntimeException(sprintf('Cannot override frozen service "%s".', $id));
78 75
         }
@@ -90,8 +87,7 @@  discard block
 block discarded – undo
90 87
      *
91 88
      * @throws \InvalidArgumentException if the identifier is not defined
92 89
      */
93
-    public function offsetGet($id)
94
-    {
90
+    public function offsetGet($id) {
95 91
         if (!isset($this->keys[$id])) {
96 92
             throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
97 93
         }
@@ -125,8 +121,7 @@  discard block
 block discarded – undo
125 121
      *
126 122
      * @return bool
127 123
      */
128
-    public function offsetExists($id)
129
-    {
124
+    public function offsetExists($id) {
130 125
         return isset($this->keys[$id]);
131 126
     }
132 127
 
@@ -135,8 +130,7 @@  discard block
 block discarded – undo
135 130
      *
136 131
      * @param string $id The unique identifier for the parameter or object
137 132
      */
138
-    public function offsetUnset($id)
139
-    {
133
+    public function offsetUnset($id) {
140 134
         if (isset($this->keys[$id])) {
141 135
             if (is_object($this->values[$id])) {
142 136
                 unset($this->factories[$this->values[$id]], $this->protected[$this->values[$id]]);
@@ -155,8 +149,7 @@  discard block
 block discarded – undo
155 149
      *
156 150
      * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
157 151
      */
158
-    public function factory($callable)
159
-    {
152
+    public function factory($callable) {
160 153
         if (!method_exists($callable, '__invoke')) {
161 154
             throw new \InvalidArgumentException('Service definition is not a Closure or invokable object.');
162 155
         }
@@ -177,8 +170,7 @@  discard block
 block discarded – undo
177 170
      *
178 171
      * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
179 172
      */
180
-    public function protect($callable)
181
-    {
173
+    public function protect($callable) {
182 174
         if (!method_exists($callable, '__invoke')) {
183 175
             throw new \InvalidArgumentException('Callable is not a Closure or invokable object.');
184 176
         }
@@ -197,8 +189,7 @@  discard block
 block discarded – undo
197 189
      *
198 190
      * @throws \InvalidArgumentException if the identifier is not defined
199 191
      */
200
-    public function raw($id)
201
-    {
192
+    public function raw($id) {
202 193
         if (!isset($this->keys[$id])) {
203 194
             throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
204 195
         }
@@ -223,8 +214,7 @@  discard block
 block discarded – undo
223 214
      *
224 215
      * @throws \InvalidArgumentException if the identifier is not defined or not a service definition
225 216
      */
226
-    public function extend($id, $callable)
227
-    {
217
+    public function extend($id, $callable) {
228 218
         if (!isset($this->keys[$id])) {
229 219
             throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
230 220
         }
@@ -256,8 +246,7 @@  discard block
 block discarded – undo
256 246
      *
257 247
      * @return array An array of value names
258 248
      */
259
-    public function keys()
260
-    {
249
+    public function keys() {
261 250
         return array_keys($this->values);
262 251
     }
263 252
 
@@ -269,8 +258,7 @@  discard block
 block discarded – undo
269 258
      *
270 259
      * @return static
271 260
      */
272
-    public function register(ServiceProviderInterface $provider, array $values = array())
273
-    {
261
+    public function register(ServiceProviderInterface $provider, array $values = array()) {
274 262
         $provider->register($this);
275 263
 
276 264
         foreach ($values as $key => $value) {
Please login to merge, or discard this patch.
classes/Unit.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
    * @param string $group_name
155 155
    */
156 156
   public static function _init($group_name = '') {
157
-    if(static::$_is_static_init) {
157
+    if (static::$_is_static_init) {
158 158
       return;
159 159
     }
160 160
 
161
-    if($group_name) {
161
+    if ($group_name) {
162 162
       static::$_sn_group_name = $group_name;
163 163
     }
164 164
 
165
-    if(static::$_sn_group_name) {
165
+    if (static::$_sn_group_name) {
166 166
       static::$_group_unit_id_list = sn_get_groups(static::$_sn_group_name);
167 167
       empty(static::$_group_unit_id_list) ? static::$_group_unit_id_list = array() : false;
168 168
     }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     // TODO - Reset combat stats??
188 188
     $this->_unitId = $unitId;
189 189
 
190
-    if($this->_unitId) {
190
+    if ($this->_unitId) {
191 191
       $this->info = get_unit_param($this->_unitId);
192 192
       $this->_type = $this->info[P_UNIT_TYPE];
193 193
     } else {
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
   protected function setCount($value) {
200 200
     // TODO - Reset combat stats??
201
-    if($value < 0) {
201
+    if ($value < 0) {
202 202
       classSupernova::$debug->error('Can not set Unit::$count to negative value');
203 203
     }
204 204
     $this->_count = $value;
Please login to merge, or discard this patch.
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.