Completed
Push — work-fleets ( 1bdd41...8f5403 )
by SuperNova.WS
04:54
created
includes/classes/PlayerList.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
    * @version 41a6.16
24 24
    */
25 25
   protected function db_load_player_by_id($player_id) {
26
-    if(isset($this[$player_id])) {
26
+    if (isset($this[$player_id])) {
27 27
       return;
28 28
     }
29 29
 
Please login to merge, or discard this patch.
includes/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.
includes/classes/DBRow.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 
132 132
     // If method is not getter or setter OR property name not exists in $_properties - raising exception
133 133
     // Descendants can catch this Exception to make own __call magic
134
-    if(($left3 != 'get' && $left3 != 'set') || empty(static::$_properties[$propertyName])) {
134
+    if (($left3 != 'get' && $left3 != 'set') || empty(static::$_properties[$propertyName])) {
135 135
       throw new ExceptionPropertyNotExists('Property ' . $propertyName . ' not exists when calling getter/setter ' . get_called_class() . '::' . $name, ERR_ERROR);
136 136
     }
137 137
 
138 138
     // TODO check for read-only
139 139
 
140
-    if($left3 == 'set') {
141
-      if(!empty($this->propertiesAdjusted[$propertyName])) {
140
+    if ($left3 == 'set') {
141
+      if (!empty($this->propertiesAdjusted[$propertyName])) {
142 142
         throw new PropertyAccessException('Property ' . $propertyName . ' already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::' . $name, ERR_ERROR);
143 143
       }
144 144
       $this->propertiesChanged[$propertyName] = 1;
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
     // Now deciding - will we call a protected setter or will we work with protected property
148 148
 
149 149
     // If method exists - just calling it
150
-    if(method_exists($this, $name)) {
150
+    if (method_exists($this, $name)) {
151 151
       return call_user_func_array(array($this, $name), $arguments);
152 152
     }
153 153
     // No getter/setter exists - works directly with protected property
154 154
 
155 155
     // Is it getter?
156
-    if($left3 === 'get') {
156
+    if ($left3 === 'get') {
157 157
       return $this->{'_' . $propertyName};
158 158
     }
159 159
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 //    $this->_reset();
175 175
 
176 176
     $dbId = idval($dbId);
177
-    if($dbId <= 0) {
177
+    if ($dbId <= 0) {
178 178
       classSupernova::$debug->error(get_called_class() . '::dbLoad $dbId not positive = ' . $dbId);
179 179
 
180 180
       return;
181 181
     }
182 182
 
183 183
     $db_row = doquery("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $dbId . " LIMIT 1 FOR UPDATE;", true);
184
-    if(empty($db_row)) {
184
+    if (empty($db_row)) {
185 185
       return;
186 186
     }
187 187
 
@@ -197,26 +197,26 @@  discard block
 block discarded – undo
197 197
    */
198 198
   // TODO - perform operations only if properties was changed
199 199
   public function dbSave() {
200
-    if($this->isNew()) {
200
+    if ($this->isNew()) {
201 201
       // No DB_ID - new unit
202
-      if($this->isEmpty()) {
202
+      if ($this->isEmpty()) {
203 203
         classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave');
204 204
       }
205 205
       $this->dbInsert();
206 206
     } else {
207 207
       // DB_ID is present
208
-      if($this->isEmpty()) {
208
+      if ($this->isEmpty()) {
209 209
         $this->dbDelete();
210 210
       } else {
211
-        if(!sn_db_transaction_check(false)) {
211
+        if (!sn_db_transaction_check(false)) {
212 212
           classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate');
213 213
         }
214 214
         $this->dbUpdate();
215 215
       }
216 216
     }
217 217
 
218
-    if(!empty($this->triggerDbOperationOn)) {
219
-      foreach($this->triggerDbOperationOn as $item) {
218
+    if (!empty($this->triggerDbOperationOn)) {
219
+      foreach ($this->triggerDbOperationOn as $item) {
220 220
         $item->dbSave();
221 221
       }
222 222
     }
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
    * @return int|string
236 236
    */
237 237
   public function dbInsert() {
238
-    if(!$this->isNew()) {
238
+    if (!$this->isNew()) {
239 239
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert');
240 240
     }
241 241
     $this->_dbId = $this->db_field_set_create($this->dbMakeFieldSet());
242 242
 
243
-    if(empty($this->_dbId)) {
243
+    if (empty($this->_dbId)) {
244 244
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert');
245 245
     }
246 246
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
    */
253 253
   public function dbUpdate() {
254 254
     // TODO - Update
255
-    if($this->isNew()) {
255
+    if ($this->isNew()) {
256 256
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate');
257 257
     }
258 258
     $this->db_field_update($this->dbMakeFieldSet(true));
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
    * Deletes record from DB
263 263
    */
264 264
   public function dbDelete() {
265
-    if($this->isNew()) {
265
+    if ($this->isNew()) {
266 266
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete');
267 267
     }
268 268
     doquery("DELETE FROM {{" . static::$_table . "}} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId);
@@ -304,18 +304,18 @@  discard block
 block discarded – undo
304 304
    * @param array $db_row
305 305
    */
306 306
   public function dbRowParse(array $db_row) {
307
-    foreach(static::$_properties as $property_name => &$property_data) {
307
+    foreach (static::$_properties as $property_name => &$property_data) {
308 308
       // Advanced values extraction procedure. Should be used when at least one of following rules is matched:
309 309
       // - one field should translate to several properties;
310 310
       // - one property should be filled according to several fields;
311 311
       // - property filling requires some lookup in object values;
312
-      if(!empty($property_data[P_METHOD_EXTRACT]) && is_callable(array($this, $property_data[P_METHOD_EXTRACT]))) {
312
+      if (!empty($property_data[P_METHOD_EXTRACT]) && is_callable(array($this, $property_data[P_METHOD_EXTRACT]))) {
313 313
         call_user_func_array(array($this, $property_data[P_METHOD_EXTRACT]), array(&$db_row));
314 314
         continue;
315 315
       }
316 316
 
317 317
       // If property is read-only - doing nothing
318
-      if(!empty($property_data[P_READ_ONLY])) {
318
+      if (!empty($property_data[P_READ_ONLY])) {
319 319
         continue;
320 320
       }
321 321
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
       !empty($property_data[P_FUNC_INPUT]) && is_callable($property_data[P_FUNC_INPUT]) ? $value = call_user_func($property_data[P_FUNC_INPUT], $value) : false;
327 327
 
328 328
       // If there is setter for this field - using it. Setters is always a methods of $THIS
329
-      if(!empty($property_data[P_METHOD_SET]) && is_callable(array($this, $property_data[P_METHOD_SET]))) {
329
+      if (!empty($property_data[P_METHOD_SET]) && is_callable(array($this, $property_data[P_METHOD_SET]))) {
330 330
         call_user_func(array($this, $property_data[P_METHOD_SET]), $value);
331 331
       } else {
332 332
         $this->{$property_name} = $value;
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
   protected function dbMakeFieldSet($isUpdate = false) {
343 343
     $array = array();
344 344
 
345
-    foreach(static::$_properties as $property_name => &$property_data) {
345
+    foreach (static::$_properties as $property_name => &$property_data) {
346 346
       // TODO - on isUpdate add only changed/adjusted properties
347 347
 
348
-      if(!empty($property_data[P_METHOD_INJECT]) && is_callable(array($this, $property_data[P_METHOD_INJECT]))) {
348
+      if (!empty($property_data[P_METHOD_INJECT]) && is_callable(array($this, $property_data[P_METHOD_INJECT]))) {
349 349
         call_user_func_array(array($this, $property_data[P_METHOD_INJECT]), array(&$array));
350 350
         continue;
351 351
       }
352 352
 
353 353
       // Skipping properties which have no corresponding field in DB
354
-      if(empty($property_data[P_DB_FIELD])) {
354
+      if (empty($property_data[P_DB_FIELD])) {
355 355
         continue;
356 356
       }
357 357
 
358 358
       // Checking - is property was adjusted or changed
359
-      if($isUpdate && array_key_exists($property_name, $this->propertiesAdjusted)) {
359
+      if ($isUpdate && array_key_exists($property_name, $this->propertiesAdjusted)) {
360 360
         // For adjusted property - take value from propertiesAdjusted array
361 361
         // TODO - differ how treated conversion to string for changed and adjusted properties
362 362
         $value = $this->propertiesAdjusted[$property_name];
@@ -386,17 +386,17 @@  discard block
 block discarded – undo
386 386
    */
387 387
   protected function isFieldChanged($fieldName) {
388 388
     $isFieldChanged = false;
389
-    foreach($this->propertiesChanged as $propertyName => $cork) {
389
+    foreach ($this->propertiesChanged as $propertyName => $cork) {
390 390
       $propertyScheme = static::$_properties[$propertyName];
391
-      if(!empty($propertyScheme[P_DB_FIELDS_LINKED])) {
392
-        foreach($propertyScheme[P_DB_FIELDS_LINKED] as $linkedFieldName) {
393
-          if($linkedFieldName == $fieldName) {
391
+      if (!empty($propertyScheme[P_DB_FIELDS_LINKED])) {
392
+        foreach ($propertyScheme[P_DB_FIELDS_LINKED] as $linkedFieldName) {
393
+          if ($linkedFieldName == $fieldName) {
394 394
             $isFieldChanged = $propertyName;
395 395
             break 2;
396 396
           }
397 397
         }
398 398
       }
399
-      if(!empty($propertyScheme[P_DB_FIELD]) && $propertyScheme[P_DB_FIELD] == $fieldName) {
399
+      if (!empty($propertyScheme[P_DB_FIELD]) && $propertyScheme[P_DB_FIELD] == $fieldName) {
400 400
         $isFieldChanged = $propertyName;
401 401
         break;
402 402
       }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
     $fields = implode(',', array_keys($field_set));
419 419
 
420 420
     $result = 0;
421
-    if(classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) {
421
+    if (classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) {
422 422
       $result = db_insert_id();
423 423
     }
424 424
 
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
     sn_db_field_set_safe_flag_clear($field_set);
437 437
 
438 438
     $set = array();
439
-    foreach($field_set as $fieldName => $value) {
440
-      if(!($changedProperty = $this->isFieldChanged($fieldName))) {
439
+    foreach ($field_set as $fieldName => $value) {
440
+      if (!($changedProperty = $this->isFieldChanged($fieldName))) {
441 441
         continue;
442 442
       }
443 443
 
444 444
       // TODO - separate sets from adjusts
445
-      if(array_key_exists($changedProperty, $this->propertiesAdjusted)) {
445
+      if (array_key_exists($changedProperty, $this->propertiesAdjusted)) {
446 446
         $value = "`{$fieldName}` + ($value)"; // braces for negative values
447 447
       }
448 448
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -411,7 +411,7 @@
 block discarded – undo
411 411
   /**
412 412
    * @param array $field_set
413 413
    *
414
-   * @return int|string
414
+   * @return integer
415 415
    */
416 416
   protected function db_field_set_create(array $field_set) {
417 417
     !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set) : false;
Please login to merge, or discard this patch.
includes/includes/flt_mission_colonize.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
   $TargetAddress = sprintf($lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']);
21 21
 
22 22
   $TheMessage = $lang['sys_colo_no_colonizer'];
23
-  if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) {
23
+  if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) {
24 24
     $TheMessage = $lang['sys_colo_notfree'];
25
-    if(empty($mission_data->dst_planet)) {
25
+    if (empty($mission_data->dst_planet)) {
26 26
       $iPlanetCount = get_player_current_colonies($src_user_row);
27 27
 
28 28
       // Can we colonize more planets?
29 29
       $TheMessage = $lang['sys_colo_maxcolo'];
30
-      if($iPlanetCount < get_player_max_colonies($src_user_row)) {
30
+      if ($iPlanetCount < get_player_max_colonies($src_user_row)) {
31 31
         // Yes, we can colonize
32 32
         $TheMessage = $lang['sys_colo_badpos'];
33 33
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
           $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'],
36 36
           $objFleet->playerOwnerId, "{$lang['sys_colo_defaultname']} {$iPlanetCount}", false,
37 37
           array('user_row' => $src_user_row));
38
-        if($NewOwnerPlanet) {
38
+        if ($NewOwnerPlanet) {
39 39
           $TheMessage = $lang['sys_colo_arrival'] . $TargetAddress . $lang['sys_colo_allisok'];
40 40
           msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage);
41 41
 
Please login to merge, or discard this patch.
includes/classes/UBE/UBEFleet.php 2 patches
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
       $this->owner_id,
163 163
       $this->db_id,
164 164
 
165
-      (float)$this->UBE_PLANET[PLANET_ID],
165
+      (float) $this->UBE_PLANET[PLANET_ID],
166 166
       "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'",
167
-      (int)$this->UBE_PLANET[PLANET_GALAXY],
168
-      (int)$this->UBE_PLANET[PLANET_SYSTEM],
169
-      (int)$this->UBE_PLANET[PLANET_PLANET],
170
-      (int)$this->UBE_PLANET[PLANET_TYPE],
171
-
172
-      (float)$this->resource_list[RES_METAL],
173
-      (float)$this->resource_list[RES_CRYSTAL],
174
-      (float)$this->resource_list[RES_DEUTERIUM],
175
-
176
-      (float)$this->fleet_bonus->calcBonus(P_ATTACK),
177
-      (float)$this->fleet_bonus->calcBonus(P_SHIELD),
178
-      (float)$this->fleet_bonus->calcBonus(P_ARMOR),
167
+      (int) $this->UBE_PLANET[PLANET_GALAXY],
168
+      (int) $this->UBE_PLANET[PLANET_SYSTEM],
169
+      (int) $this->UBE_PLANET[PLANET_PLANET],
170
+      (int) $this->UBE_PLANET[PLANET_TYPE],
171
+
172
+      (float) $this->resource_list[RES_METAL],
173
+      (float) $this->resource_list[RES_CRYSTAL],
174
+      (float) $this->resource_list[RES_DEUTERIUM],
175
+
176
+      (float) $this->fleet_bonus->calcBonus(P_ATTACK),
177
+      (float) $this->fleet_bonus->calcBonus(P_SHIELD),
178
+      (float) $this->fleet_bonus->calcBonus(P_ARMOR),
179 179
     );
180 180
   }
181 181
 
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
     $this->group_id = $objFleet->group_id;
191 191
 
192 192
     $fleet_unit_list = $objFleet->shipsGetArray();
193
-    foreach($fleet_unit_list as $unit_id => $unit_count) {
194
-      if(!$unit_count) {
193
+    foreach ($fleet_unit_list as $unit_id => $unit_count) {
194
+      if (!$unit_count) {
195 195
         continue;
196 196
       }
197 197
 
198 198
       $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
199
-      if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
199
+      if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
200 200
         $this->unit_list->unitAdjustCount($unit_id, $unit_count);
201 201
       }
202 202
     }
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
 //      }
233 233
 //    }
234 234
 
235
-    foreach($sn_group_combat as $unit_id) {
236
-      if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
235
+    foreach ($sn_group_combat as $unit_id) {
236
+      if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
237 237
         $this->unit_list->unitAdjustCount($unit_id, $unit_count);
238 238
       }
239 239
     }
240 240
 
241
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
241
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
242 242
       $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id));
243 243
     }
244 244
 
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
       $ube_report_id,
298 298
       $this->db_id,
299 299
 
300
-      (float)$this->resources_lost_on_units[RES_METAL],
301
-      (float)$this->resources_lost_on_units[RES_CRYSTAL],
302
-      (float)$this->resources_lost_on_units[RES_DEUTERIUM],
303
-      (float)$this->cargo_dropped[RES_METAL],
304
-      (float)$this->cargo_dropped[RES_CRYSTAL],
305
-      (float)$this->cargo_dropped[RES_DEUTERIUM],
306
-      (float)$this->resources_looted[RES_METAL],
307
-      (float)$this->resources_looted[RES_CRYSTAL],
308
-      (float)$this->resources_looted[RES_DEUTERIUM],
309
-      (float)$this->resources_lost_in_metal[RES_METAL],
300
+      (float) $this->resources_lost_on_units[RES_METAL],
301
+      (float) $this->resources_lost_on_units[RES_CRYSTAL],
302
+      (float) $this->resources_lost_on_units[RES_DEUTERIUM],
303
+      (float) $this->cargo_dropped[RES_METAL],
304
+      (float) $this->cargo_dropped[RES_CRYSTAL],
305
+      (float) $this->cargo_dropped[RES_DEUTERIUM],
306
+      (float) $this->resources_looted[RES_METAL],
307
+      (float) $this->resources_looted[RES_CRYSTAL],
308
+      (float) $this->resources_looted[RES_DEUTERIUM],
309
+      (float) $this->resources_lost_in_metal[RES_METAL],
310 310
     );
311 311
   }
312 312
 
313 313
   public function report_render_outcome_side_fleet() {
314 314
     $UBE_DEFENCE_RESTORE = array();
315 315
     $UBE_UNITS_LOST = array();
316
-    foreach($this->unit_list->_container as $UBEUnit) {
317
-      if($UBEUnit->units_restored) {
316
+    foreach ($this->unit_list->_container as $UBEUnit) {
317
+      if ($UBEUnit->units_restored) {
318 318
         $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored;
319 319
       }
320
-      if($UBEUnit->units_lost) {
320
+      if ($UBEUnit->units_lost) {
321 321
         $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost;
322 322
       }
323 323
     }
@@ -344,16 +344,16 @@  discard block
 block discarded – undo
344 344
     global $lang;
345 345
 
346 346
     $result = array();
347
-    if(!empty($array)) {
348
-      foreach($array as $unit_id => $unit_count) {
349
-        if($unit_count) {
347
+    if (!empty($array)) {
348
+      foreach ($array as $unit_id => $unit_count) {
349
+        if ($unit_count) {
350 350
           $result[] = array(
351 351
             'NAME' => $lang['tech'][$unit_id],
352 352
             'LOSS' => pretty_number($unit_count),
353 353
           );
354 354
         }
355 355
       }
356
-      if($lang_header_index && count($result)) {
356
+      if ($lang_header_index && count($result)) {
357 357
         array_unshift($result, array('NAME' => $lang[$lang_header_index]));
358 358
       }
359 359
     }
@@ -366,16 +366,16 @@  discard block
 block discarded – undo
366 366
     $fleet_id = $this->db_id;
367 367
 
368 368
     $unit_sort_order = 0;
369
-    foreach($this->unit_list->_container as $UBEUnit) {
370
-      if($UBEUnit->units_lost || $UBEUnit->units_restored) {
369
+    foreach ($this->unit_list->_container as $UBEUnit) {
370
+      if ($UBEUnit->units_lost || $UBEUnit->units_restored) {
371 371
         $unit_sort_order++;
372 372
         $sql_perform_report_unit[] = array(
373 373
           $ube_report_id,
374 374
           $fleet_id,
375 375
 
376 376
           $UBEUnit->unitId,
377
-          (float)$UBEUnit->units_restored,
378
-          (float)$UBEUnit->units_lost,
377
+          (float) $UBEUnit->units_restored,
378
+          (float) $UBEUnit->units_lost,
379 379
 
380 380
           $unit_sort_order,
381 381
         );
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
   function ube_combat_result_calculate_resources() {
392 392
     $resource_delta_fleet = array();
393 393
     // Если во флоте остались юниты или это планета - генерируем изменение ресурсов
394
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
395
-      $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id];
396
-      if($resource_change) {
394
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
395
+      $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id];
396
+      if ($resource_change) {
397 397
         $resource_delta_fleet[$resource_id] = -($resource_change);
398 398
       }
399 399
     }
@@ -426,12 +426,12 @@  discard block
 block discarded – undo
426 426
     );
427 427
 
428 428
     $this->fleet_capacity = 0;
429
-    foreach($this->unit_list->_container as $UBEUnit) {
429
+    foreach ($this->unit_list->_container as $UBEUnit) {
430 430
       $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount();
431 431
 
432
-      if($UBEUnit->units_lost) {
433
-        foreach($UBEUnit->price as $resource_id => $unit_resource_price) {
434
-          if(!$unit_resource_price) {
432
+      if ($UBEUnit->units_lost) {
433
+        foreach ($UBEUnit->price as $resource_id => $unit_resource_price) {
434
+          if (!$unit_resource_price) {
435 435
             continue;
436 436
           }
437 437
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
           $this->resources_lost_on_units[$resource_id] += $resources_lost;
440 440
           // Если это корабль - прибавляем потери к обломкам на орбите
441 441
           // TODO - опция выбрасывания обороны в обломки
442
-          if($UBEUnit->getType() == UNIT_SHIPS) {
442
+          if ($UBEUnit->getType() == UNIT_SHIPS) {
443 443
             $this->resources_lost_on_ships[$resource_id] += $resources_lost;
444 444
           }
445 445
         }
@@ -451,11 +451,11 @@  discard block
 block discarded – undo
451 451
 
452 452
     // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй
453 453
     // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются
454
-    if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
454
+    if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
455 455
       $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена
456
-      foreach($this->resource_list as $resource_id => &$resource_amount) {
456
+      foreach ($this->resource_list as $resource_id => &$resource_amount) {
457 457
         // Не просчитываем ресурсы, которых нет на борту кораблей флота
458
-        if(!$resource_amount) {
458
+        if (!$resource_amount) {
459 459
           continue;
460 460
         }
461 461
 
@@ -476,19 +476,19 @@  discard block
 block discarded – undo
476 476
     $objFleet2->setDbId($this->db_id);
477 477
 
478 478
     // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли
479
-    if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
479
+    if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
480 480
       $objFleet2->dbDelete();
481
-    } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
481
+    } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
482 482
       $objFleet2->dbDelete();
483 483
     } else {
484
-      if($ship_count_lost) {
484
+      if ($ship_count_lost) {
485 485
         // Просматриваем результаты изменения флотов
486
-        foreach($this->unit_list->_container as $UBEUnit) {
486
+        foreach ($this->unit_list->_container as $UBEUnit) {
487 487
           // Перебираем аутком на случай восстановления юнитов
488 488
 //          if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) {
489 489
 //            $fleet_real_array[$UBEUnit->unitId] = $units_left;
490 490
 //          };
491
-          if(floatval($UBEUnit->units_lost) != 0) {
491
+          if (floatval($UBEUnit->units_lost) != 0) {
492 492
             $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost));
493 493
           };
494 494
         }
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
       $objFleet2->resourcesAdjust($resource_delta_fleet);
499 499
 
500 500
       // Если защитник и не РМФ - отправляем флот назад
501
-      if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
501
+      if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
502 502
         $objFleet2->markReturned();
503 503
       }
504 504
       $objFleet2->dbSave();
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
   public function calculate_unit_partial_data(UBEASA $side_ASA) {
529 529
     $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor();
530 530
 
531
-    foreach($this->unit_list->_container as $UBEUnit) {
531
+    foreach ($this->unit_list->_container as $UBEUnit) {
532 532
       $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor();
533 533
     }
534 534
   }
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
    * @version 2016-02-25 23:42:45 41a4.68
541 541
    */
542 542
   public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) {
543
-    foreach($fleet_list->_container as $defending_fleet) {
543
+    foreach ($fleet_list->_container as $defending_fleet) {
544 544
       // Не атакуются флоты на своей стороне
545
-      if($this->is_attacker == $defending_fleet->is_attacker) {
545
+      if ($this->is_attacker == $defending_fleet->is_attacker) {
546 546
         continue;
547 547
       }
548 548
       $this->attack_fleet($defending_fleet, $is_simulator);
@@ -558,12 +558,12 @@  discard block
 block discarded – undo
558 558
   public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) {
559 559
     UBEDebug::unit_dump_header();
560 560
 
561
-    foreach($this->unit_list->_container as $attacking_unit_pool) {
561
+    foreach ($this->unit_list->_container as $attacking_unit_pool) {
562 562
       UBEDebug::unit_dump($attacking_unit_pool, 'attacker');
563 563
 
564 564
       // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..."
565
-      foreach($defending_fleet->unit_list->_container as $defending_unit_pool) {
566
-        if($defending_unit_pool->isEmpty()) {
565
+      foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) {
566
+        if ($defending_unit_pool->isEmpty()) {
567 567
           continue;
568 568
         }
569 569
 
Please login to merge, or discard this patch.
Doc Comments   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
   }
151 151
 
152 152
   /**
153
-   * @param $ube_report_id
153
+   * @param integer $ube_report_id
154 154
    *
155 155
    * @return array
156 156
    *
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
 
290 290
   /**
291
-   * @param $ube_report_id
291
+   * @param integer $ube_report_id
292 292
    *
293 293
    * @return array
294 294
    */
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
   // Рендерит таблицу общего результата боя
337 337
   /**
338 338
    * @param $array
339
-   * @param $lang_header_index
339
+   * @param string $lang_header_index
340 340
    *
341 341
    * @return array
342 342
    */
@@ -362,6 +362,9 @@  discard block
 block discarded – undo
362 362
   }
363 363
 
364 364
 
365
+  /**
366
+   * @param integer $ube_report_id
367
+   */
365 368
   public function sql_generate_outcome_unit_array(&$sql_perform_report_unit, $ube_report_id) {
366 369
     $fleet_id = $this->db_id;
367 370
 
@@ -468,6 +471,10 @@  discard block
 block discarded – undo
468 471
     $this->fleet_capacity -= $fleet_total_resources;
469 472
   }
470 473
 
474
+  /**
475
+   * @param integer $is_small_fleet_recce
476
+   * @param integer $reapers_status
477
+   */
471 478
   public function db_save_combat_result_fleet($is_small_fleet_recce, $reapers_status) {
472 479
     $ship_count_initial = $this->unit_list->unitsCount();
473 480
     $ship_count_lost = $this->unit_list->unitCountLost();
@@ -535,7 +542,7 @@  discard block
 block discarded – undo
535 542
 
536 543
   /**
537 544
    * @param UBEFleetList $fleet_list
538
-   * @param              $is_simulator
545
+   * @param              boolean $is_simulator
539 546
    *
540 547
    * @version 2016-02-25 23:42:45 41a4.68
541 548
    */
Please login to merge, or discard this patch.
galaxy.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 $uni_system = sys_get_param_int('system', $planetrow['system']);
19 19
 $planet = sys_get_param_int('planet', $planetrow['planet']);
20 20
 
21
-if($mode == 'name') {
21
+if ($mode == 'name') {
22 22
   require_once('includes/includes/uni_rename.php');
23 23
 }
24 24
 
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 
40 40
 $flying_fleet_count = FleetList::fleet_count_flying($user['id']);
41 41
 
42
-if($mode == 1) {
43
-} elseif($mode == 2 || $mode == 3) {
42
+if ($mode == 1) {
43
+} elseif ($mode == 2 || $mode == 3) {
44 44
   $planet = $planetrow['planet'];
45 45
 } else {
46 46
   $uni_galaxy = $planetrow['galaxy'];
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 $PhalanxRange = GetPhalanxRange($HavePhalanx);
67 67
 
68 68
 $planet_precache_query = db_planet_list_in_system($uni_galaxy, $uni_system);
69
-if(!empty($planet_precache_query)) {
70
-  foreach($planet_precache_query as $planet_row) {
69
+if (!empty($planet_precache_query)) {
70
+  foreach ($planet_precache_query as $planet_row) {
71 71
     $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row;
72 72
   }
73 73
 }
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
  * @var Fleet[][][] $fleet_list
86 86
  */
87 87
 $fleet_list = array();
88
-foreach($system_fleet_list->_container as $objFleetSystem) {
89
-  if(!$objFleetSystem->isReturning()) {
88
+foreach ($system_fleet_list->_container as $objFleetSystem) {
89
+  if (!$objFleetSystem->isReturning()) {
90 90
     $fleet_planet = $objFleetSystem->fleet_end_planet;
91 91
     $fleet_type = $objFleetSystem->fleet_end_type;
92 92
   } else {
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 $recycler_info = array();
102 102
 $planet_recyclers_orbiting = 0;
103 103
 $recyclers_fleet = array();
104
-foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
104
+foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
105 105
   $recycler_info[$recycler_id] = get_ship_data($recycler_id, $user);
106 106
   $recyclers_fleet[$recycler_id] = mrc_get_level($user, $planetrow, $recycler_id);
107 107
   $planet_recyclers_orbiting += $recyclers_fleet[$recycler_id];
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 $fleet_id = 1;
112 112
 $fleets = array();
113 113
 $config_game_max_planet = $config->game_maxPlanet + 1;
114
-for($Planet = 1; $Planet < $config_game_max_planet; $Planet++) {
114
+for ($Planet = 1; $Planet < $config_game_max_planet; $Planet++) {
115 115
   unset($uni_galaxyRowPlanet);
116 116
   unset($uni_galaxyRowMoon);
117 117
   unset($uni_galaxyRowUser);
@@ -121,27 +121,27 @@  discard block
 block discarded – undo
121 121
   $uni_galaxyRowPlanet = $planet_list[$Planet][PT_PLANET];
122 122
 
123 123
   $planet_fleet_id = 0;
124
-  if($uni_galaxyRowPlanet['destruyed']) {
124
+  if ($uni_galaxyRowPlanet['destruyed']) {
125 125
     CheckAbandonPlanetState($uni_galaxyRowPlanet);
126
-  } elseif($uni_galaxyRowPlanet['id']) {
127
-    if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) {
126
+  } elseif ($uni_galaxyRowPlanet['id']) {
127
+    if ($cached['users'][$uni_galaxyRowPlanet['id_owner']]) {
128 128
       $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']];
129 129
     } else {
130 130
       $uni_galaxyRowUser = db_user_by_id($uni_galaxyRowPlanet['id_owner']);
131 131
       $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser;
132 132
     }
133 133
 
134
-    if(!$uni_galaxyRowUser['id']) {
134
+    if (!$uni_galaxyRowUser['id']) {
135 135
       $debug->warning("Planet '{$uni_galaxyRowPlanet['name']}' [{$uni_galaxy}:{$uni_system}:{$Planet}] has no owner!", 'Userless planet', 503);
136 136
       $uni_galaxyRowPlanet['destruyed'] = SN_TIME_NOW + 60 * 60 * 24;
137 137
       $uni_galaxyRowPlanet['id_owner'] = 0;
138 138
       db_planet_set_by_id($uni_galaxyRowPlanet['id'], "id_owner = 0, destruyed = {$uni_galaxyRowPlanet['destruyed']}");
139 139
     }
140 140
 
141
-    if($uni_galaxyRowUser['id']) {
141
+    if ($uni_galaxyRowUser['id']) {
142 142
       $planetcount++;
143
-      if($uni_galaxyRowUser['ally_id']) {
144
-        if($cached['allies'][$uni_galaxyRowUser['ally_id']]) {
143
+      if ($uni_galaxyRowUser['ally_id']) {
144
+        if ($cached['allies'][$uni_galaxyRowUser['ally_id']]) {
145 145
           $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']];
146 146
         } else {
147 147
           $allyquery = db_ally_get_by_id($uni_galaxyRowUser['ally_id']);
@@ -150,19 +150,19 @@  discard block
 block discarded – undo
150 150
       }
151 151
 
152 152
       $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_PLANET]);
153
-      if(!empty($fleets_to_planet['own']['count'])) {
153
+      if (!empty($fleets_to_planet['own']['count'])) {
154 154
         $planet_fleet_id = $fleet_id;
155 155
         $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id);
156 156
         $fleet_id++;
157 157
       }
158 158
 
159 159
       $uni_galaxyRowMoon = $planet_list[$Planet][PT_MOON];
160
-      if($uni_galaxyRowMoon['destruyed']) {
160
+      if ($uni_galaxyRowMoon['destruyed']) {
161 161
         CheckAbandonPlanetState($uni_galaxyRowMoon);
162 162
       } else {
163 163
         $moon_fleet_id = 0;
164 164
         $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_MOON]);
165
-        if(!empty($fleets_to_planet['own']['count'])) {
165
+        if (!empty($fleets_to_planet['own']['count'])) {
166 166
           $moon_fleet_id = $fleet_id;
167 167
           $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id);
168 168
           $fleet_id++;
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
 
174 174
   $recyclers_incoming_capacity = 0;
175 175
   $uni_galaxyRowPlanet['debris'] = $uni_galaxyRowPlanet['debris_metal'] + $uni_galaxyRowPlanet['debris_crystal'];
176
-  if($uni_galaxyRowPlanet['debris']) {
177
-    if(!empty($fleet_list[$Planet][PT_DEBRIS])) {
178
-      foreach($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) {
179
-        if($objFleetToDebris->playerOwnerId == $user['id']) {
176
+  if ($uni_galaxyRowPlanet['debris']) {
177
+    if (!empty($fleet_list[$Planet][PT_DEBRIS])) {
178
+      foreach ($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) {
179
+        if ($objFleetToDebris->playerOwnerId == $user['id']) {
180 180
           $recyclers_incoming_capacity += $objFleetToDebris->shipsGetCapacityRecyclers($recycler_info);
181 181
         }
182 182
       }
@@ -253,21 +253,21 @@  discard block
 block discarded – undo
253 253
 
254 254
 tpl_assign_fleet($template, $fleets);
255 255
 
256
-foreach(sn_get_groups('defense_active') as $unit_id) {
256
+foreach (sn_get_groups('defense_active') as $unit_id) {
257 257
   $template->assign_block_vars('defense_active', array(
258 258
     'ID'   => $unit_id,
259 259
     'NAME' => $lang['tech'][$unit_id],
260 260
   ));
261 261
 }
262 262
 
263
-foreach($cached['users'] as $PlanetUser) {
264
-  if(!$PlanetUser) {
263
+foreach ($cached['users'] as $PlanetUser) {
264
+  if (!$PlanetUser) {
265 265
     continue;
266 266
   }
267 267
 
268 268
   $user_ally = $cached['allies'][$PlanetUser['ally_id']];
269
-  if(isset($user_ally)) {
270
-    if($PlanetUser['id'] == $user_ally['ally_owner']) {
269
+  if (isset($user_ally)) {
270
+    if ($PlanetUser['id'] == $user_ally['ally_owner']) {
271 271
       $user_rank_title = $user_ally['ally_owner_range'];
272 272
     } else {
273 273
       $ally_ranks = explode(';', $user_ally['ranklist']);
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
   ));
291 291
 }
292 292
 
293
-foreach($cached['allies'] as $PlanetAlly) {
294
-  if($PlanetAlly) {
293
+foreach ($cached['allies'] as $PlanetAlly) {
294
+  if ($PlanetAlly) {
295 295
     $template->assign_block_vars('alliances', array(
296 296
       'ID'      => $PlanetAlly['id'],
297 297
       'NAME_JS' => js_safe_string($PlanetAlly['ally_name']),
Please login to merge, or discard this patch.
includes/classes/Fleet.php 2 patches
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -591,6 +591,9 @@  discard block
 block discarded – undo
591 591
     return max(0, $this->shipsGetCapacity() - $this->resourcesGetTotal());
592 592
   }
593 593
 
594
+  /**
595
+   * @param integer $ship_id
596
+   */
594 597
   public function shipsGetTotalById($ship_id) {
595 598
     return $this->unitList->unitsCountById($ship_id);
596 599
   }
@@ -705,7 +708,7 @@  discard block
 block discarded – undo
705 708
   /**
706 709
    * Set current resource list from array of units
707 710
    *
708
-   * @param array $resource_list
711
+   * @param integer[] $resource_list
709 712
    */
710 713
   public function resourcesSet($resource_list) {
711 714
     if(!empty($this->propertiesAdjusted['resource_list'])) {
@@ -781,7 +784,6 @@  discard block
 block discarded – undo
781 784
    * Restores fleet or resources to planet
782 785
    *
783 786
    * @param bool $start
784
-   * @param bool $only_resources
785 787
    * @param int  $result
786 788
    *
787 789
    * @return int
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
   public function dbInsert() {
284 284
     // WARNING! MISSION TIMES MUST BE SET WITH set_times() method!
285 285
     // TODO - more checks!
286
-    if(empty($this->_time_launch)) {
286
+    if (empty($this->_time_launch)) {
287 287
       die('Fleet time not set!');
288 288
     }
289 289
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
     // Записываем изменения в БД
364 364
     $this->dbSave();
365 365
 
366
-    if($this->_group_id) {
366
+    if ($this->_group_id) {
367 367
       // TODO: Make here to delete only one AKS - by adding aks_fleet_count to AKS table
368 368
       db_fleet_aks_purge();
369 369
     }
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
    */
435 435
   // TODO - separate shipList and unitList
436 436
   public function unitsSetFromArray($unit_array) {
437
-    foreach($unit_array as $unit_id => $unit_count) {
437
+    foreach ($unit_array as $unit_id => $unit_count) {
438 438
       $unit_count = floatval($unit_count);
439
-      if(!$unit_count) {
439
+      if (!$unit_count) {
440 440
         continue;
441 441
       }
442 442
 
443
-      if($this->isShip($unit_id)) {
443
+      if ($this->isShip($unit_id)) {
444 444
         $this->unitList->unitSetCount($unit_id, $unit_count);
445
-      } elseif($this->isResource($unit_id)) {
445
+      } elseif ($this->isResource($unit_id)) {
446 446
         $this->resource_list[$unit_id] = $unit_count;
447 447
       } else {
448 448
         throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR);
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
   public function parse_missile_db_row($missile_db_row) {
472 472
 //    $this->_reset();
473 473
 
474
-    if(empty($missile_db_row) || !is_array($missile_db_row)) {
474
+    if (empty($missile_db_row) || !is_array($missile_db_row)) {
475 475
       return;
476 476
     }
477 477
 
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
   public function shipsGetCapacityRecyclers(array $recycler_info) {
608 608
     $recyclers_incoming_capacity = 0;
609 609
     $fleet_data = $this->shipsGetArray();
610
-    foreach($recycler_info as $recycler_id => $recycler_data) {
610
+    foreach ($recycler_info as $recycler_id => $recycler_data) {
611 611
       $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity'];
612 612
     }
613 613
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
     sn_db_transaction_check(true);
628 628
 
629 629
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
630
-    if($this->isEmpty()) {
630
+    if ($this->isEmpty()) {
631 631
       return $result;
632 632
     }
633 633
 
@@ -649,18 +649,18 @@  discard block
 block discarded – undo
649 649
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
650 650
     // Флот, который возвращается на захваченную планету, пропадает
651 651
     // Ship landing is possible only to fleet owner's planet
652
-    if($this->getPlayerOwnerId() == $planet_arrival['id_owner']) {
652
+    if ($this->getPlayerOwnerId() == $planet_arrival['id_owner']) {
653 653
       $db_changeset = array();
654 654
 
655 655
       $fleet_array = $this->shipsGetArray();
656
-      foreach($fleet_array as $ship_id => $ship_count) {
657
-        if($ship_count) {
656
+      foreach ($fleet_array as $ship_id => $ship_count) {
657
+        if ($ship_count) {
658 658
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $planet_arrival['id']);
659 659
         }
660 660
       }
661 661
 
662 662
       // Adjusting ship amount on planet
663
-      if(!empty($db_changeset)) {
663
+      if (!empty($db_changeset)) {
664 664
         db_changeset_apply($db_changeset);
665 665
       }
666 666
 
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
    * @param array $resource_list
709 709
    */
710 710
   public function resourcesSet($resource_list) {
711
-    if(!empty($this->propertiesAdjusted['resource_list'])) {
711
+    if (!empty($this->propertiesAdjusted['resource_list'])) {
712 712
       throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
713 713
     }
714 714
     $this->resourcesAdjust($resource_list, true);
@@ -722,13 +722,13 @@  discard block
 block discarded – undo
722 722
   public function resourcesAdjust($resource_delta_list, $replace_value = false) {
723 723
     !is_array($resource_delta_list) ? $resource_delta_list = array() : false;
724 724
 
725
-    foreach($resource_delta_list as $resource_id => $unit_delta) {
726
-      if(!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
725
+    foreach ($resource_delta_list as $resource_id => $unit_delta) {
726
+      if (!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
727 727
         // Not a resource or no resources - continuing
728 728
         continue;
729 729
       }
730 730
 
731
-      if($replace_value) {
731
+      if ($replace_value) {
732 732
         $this->resource_list[$resource_id] = $unit_delta;
733 733
       } else {
734 734
         $this->resource_list[$resource_id] += $unit_delta;
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
       }
739 739
 
740 740
       // Check for negative unit value
741
-      if($this->resource_list[$resource_id] < 0) {
741
+      if ($this->resource_list[$resource_id] < 0) {
742 742
         // TODO
743 743
         throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
744 744
       }
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
     sn_db_transaction_check(true);
791 791
 
792 792
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
793
-    if(!$this->resourcesGetTotal()) {
793
+    if (!$this->resourcesGetTotal()) {
794 794
       return $result;
795 795
     }
796 796
 
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
811 811
 
812 812
     // Restoring resources to planet
813
-    if($this->resourcesGetTotal()) {
813
+    if ($this->resourcesGetTotal()) {
814 814
       $fleet_resources = $this->resourcesGetList();
815 815
       db_planet_set_by_id($planet_arrival['id'],
816 816
         "`metal` = `metal` + '{$fleet_resources[RES_METAL]}', `crystal` = `crystal` + '{$fleet_resources[RES_CRYSTAL]}', `deuterium` = `deuterium` + '{$fleet_resources[RES_DEUTERIUM]}'");
Please login to merge, or discard this patch.
includes/includes/flt_flying_fleet_handler2.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
  *
11 11
  * @param Fleet $objFleet
12 12
  * @param bool  $start
13
- * @param null  $result
13
+ * @param integer  $result
14 14
  *
15 15
  * @return mixed
16 16
  */
Please login to merge, or discard this patch.
Spacing   +22 added lines, -26 removed lines patch added patch discarded remove patch
@@ -19,15 +19,11 @@  discard block
 block discarded – undo
19 19
 // ------------------------------------------------------------------
20 20
 function flt_flyingFleetsSort($a, $b) {
21 21
   // Сравниваем время флотов - кто раньше, тот и первый обрабатывается
22
-  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 :
23
-    // Если время - одинаковое, сравниваем события флотов
22
+  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов
24 23
     // Если события - одинаковые, то флоты равны
25
-    ($a['fleet_event'] == $b['fleet_event'] ? 0 :
26
-      // Если события разные - первыми считаем прибывающие флоты
27
-      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 :
28
-        // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
29
-        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 :
30
-          // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
24
+    ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты
25
+      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
26
+        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
31 27
           // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска
32 28
           (
33 29
           0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
@@ -41,7 +37,7 @@  discard block
 block discarded – undo
41 37
 function log_file($msg) {
42 38
   static $handler;
43 39
 
44
-  if(!$handler) {
40
+  if (!$handler) {
45 41
     $handler = fopen('event.log', 'a+');
46 42
   }
47 43
 
@@ -81,12 +77,12 @@  discard block
 block discarded – undo
81 77
   */
82 78
   global $debug;
83 79
 
84
-  if(classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) {
80
+  if (classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) {
85 81
     return;
86 82
   }
87 83
 
88 84
   sn_db_transaction_start();
89
-  if(classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) {
85
+  if (classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) {
90 86
     sn_db_transaction_rollback();
91 87
 
92 88
     return;
@@ -94,14 +90,14 @@  discard block
 block discarded – undo
94 90
 
95 91
 
96 92
   // Watchdog timer
97
-  if(classSupernova::$config->db_loadItem('fleet_update_lock')) {
98
-    if(defined('DEBUG_FLYING_FLEETS')) {
93
+  if (classSupernova::$config->db_loadItem('fleet_update_lock')) {
94
+    if (defined('DEBUG_FLYING_FLEETS')) {
99 95
       $random = 0;
100 96
     } else {
101 97
       $random = mt_rand(240, 300);
102 98
     }
103 99
 
104
-    if(SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) {
100
+    if (SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) {
105 101
       sn_db_transaction_rollback();
106 102
 
107 103
       return;
@@ -125,11 +121,11 @@  discard block
 block discarded – undo
125 121
   $missions_used = array();
126 122
 
127 123
   $objFleetList = FleetList::dbGetFleetListCurrentTick();
128
-  foreach($objFleetList->_container as $objFleet) {
124
+  foreach ($objFleetList->_container as $objFleet) {
129 125
     set_time_limit(15);
130 126
     // TODO - Унифицировать код с темплейтным разбором эвентов на планете!
131 127
     $missions_used[$objFleet->mission_type] = 1;
132
-    if($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) {
128
+    if ($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) {
133 129
       $fleet_event_list[] = array(
134 130
         'object'      => $objFleet,
135 131
         'fleet_time'  => $objFleet->time_arrive_to_target,
@@ -137,7 +133,7 @@  discard block
 block discarded – undo
137 133
       );
138 134
     }
139 135
 
140
-    if($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) {
136
+    if ($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) {
141 137
       $fleet_event_list[] = array(
142 138
         'object'      => $objFleet,
143 139
         'fleet_time'  => $objFleet->time_mission_job_complete,
@@ -145,7 +141,7 @@  discard block
 block discarded – undo
145 141
       );
146 142
     }
147 143
 
148
-    if($objFleet->time_return_to_source <= SN_TIME_NOW) {
144
+    if ($objFleet->time_return_to_source <= SN_TIME_NOW) {
149 145
       $fleet_event_list[] = array(
150 146
         'object'      => $objFleet,
151 147
         'fleet_time'  => $objFleet->time_return_to_source,
@@ -171,17 +167,17 @@  discard block
 block discarded – undo
171 167
 //    MT_MISSILE => 'flt_mission_missile.php',
172 168
     MT_EXPLORE   => 'flt_mission_explore',
173 169
   );
174
-  foreach($missions_used as $mission_id => $cork) {
170
+  foreach ($missions_used as $mission_id => $cork) {
175 171
     require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX);
176 172
   }
177 173
 
178 174
 //log_file('Обработка миссий');
179 175
   $sn_groups_mission = sn_get_groups('missions');
180
-  foreach($fleet_event_list as $fleet_event) {
176
+  foreach ($fleet_event_list as $fleet_event) {
181 177
     // TODO: Указатель тут потом сделать
182 178
     // TODO: СЕЙЧАС НАДО ПРОВЕРЯТЬ ПО БАЗЕ - А ЖИВОЙ ЛИ ФЛОТ?!
183 179
     $fleet_row = $fleet_event['fleet_row'];
184
-    if(empty($fleet_event['object'])) {
180
+    if (empty($fleet_event['object'])) {
185 181
       // Fleet was destroyed in course of previous actions
186 182
       continue;
187 183
     }
@@ -205,20 +201,20 @@  discard block
 block discarded – undo
205 201
 
206 202
     $objFleet->dbLoad($objFleet->dbId);
207 203
 
208
-    if(!$objFleet->dbId) {
204
+    if (!$objFleet->dbId) {
209 205
       // Fleet was destroyed in course of previous actions
210 206
       sn_db_transaction_commit();
211 207
       continue;
212 208
     }
213 209
 
214
-    if($fleet_event['fleet_event'] == EVENT_FLT_RETURN) {
210
+    if ($fleet_event['fleet_event'] == EVENT_FLT_RETURN) {
215 211
       // Fleet returns to planet
216 212
       $objFleet->shipsLand(true);
217 213
       sn_db_transaction_commit();
218 214
       continue;
219 215
     }
220 216
 
221
-    if($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) {
217
+    if ($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) {
222 218
       // При событии EVENT_FLT_ARRIVE флот всегда должен иметь fleet_mess == 0
223 219
       // В противном случае это означает, что флот уже был обработан ранее - например, при САБе
224 220
       sn_db_transaction_commit();
@@ -238,13 +234,13 @@  discard block
 block discarded – undo
238 234
     $objMission->dst_planet = $mission_data['dst_planet'] ? db_planet_by_vector($objFleet->target_coordinates_typed(), '', true, '`id`, `id_owner`, `name`') : null;
239 235
     $objMission->fleet_event = $fleet_event['fleet_event'];
240 236
 
241
-    if($objMission->dst_planet && $objMission->dst_planet['id_owner']) {
237
+    if ($objMission->dst_planet && $objMission->dst_planet['id_owner']) {
242 238
       $update_result = sys_o_get_updated($objMission->dst_planet['id_owner'], $objMission->dst_planet['id'], $objFleet->time_arrive_to_target);
243 239
       $objMission->dst_user = !empty($objMission->dst_user) ? $update_result['user'] : null;
244 240
       $objMission->dst_planet = $update_result['planet'];
245 241
     }
246 242
 
247
-    switch($objFleet->mission_type) {
243
+    switch ($objFleet->mission_type) {
248 244
       // Для боевых атак нужно обновлять по САБу и по холду - таки надо возвращать данные из обработчика миссий!
249 245
       case MT_AKS:
250 246
       case MT_ATTACK:
Please login to merge, or discard this patch.
includes/classes/UnitList.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
    * @param Unit  $value
89 89
    */
90 90
   public function offsetSet($offset, $value) {
91
-    if(isset($this->mapUnitIdToDb[$value->unitId])) {
91
+    if (isset($this->mapUnitIdToDb[$value->unitId])) {
92 92
       classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists');
93 93
     }
94 94
     $this->mapUnitIdToDb[$value->unitId] = $value;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
   }
97 97
 
98 98
   public function offsetUnset($offset) {
99
-    if(!empty($this[$offset]->unitId)) {
99
+    if (!empty($this[$offset]->unitId)) {
100 100
 //      $unit_id = $this[$offset]->unitId;
101 101
 //      $this->mapUnitIdToDb[$unit_id] = null;
102 102
 //      unset($this->mapUnitIdToDb[$unit_id]);
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
   public function dbLoad($dbId) {
119 119
 //    $this->_reset();
120 120
 
121
-    if($dbId <= 0) {
121
+    if ($dbId <= 0) {
122 122
       return;
123 123
     }
124 124
 
125
-    if(!is_object($this->locatedAt)) {
125
+    if (!is_object($this->locatedAt)) {
126 126
       classSupernova::$debug->error('UnitList::dbLoad have no locatedAt field set');
127 127
     }
128 128
 
129 129
     $unit_array = classSupernova::db_get_unit_list_by_location(0, $this->getLocationType(), $this->getLocationDbId());
130
-    if(!is_array($unit_array)) {
130
+    if (!is_array($unit_array)) {
131 131
       return;
132 132
     }
133 133
 
134
-    foreach($unit_array as $unit_db_row) {
134
+    foreach ($unit_array as $unit_db_row) {
135 135
       $unit = $this->_createElement();
136 136
       $unit->setLocatedAt($this);
137 137
       $unit->dbRowParse($unit_db_row);
@@ -147,25 +147,25 @@  discard block
 block discarded – undo
147 147
   }
148 148
 
149 149
   public function dbSave() {
150
-    if(!is_object($this->locatedAt)) {
150
+    if (!is_object($this->locatedAt)) {
151 151
       classSupernova::$debug->error('UnitList::dbSave have no locatedAt field set');
152 152
     }
153 153
 
154
-    foreach($this->mapUnitIdToDb as $unit) {
154
+    foreach ($this->mapUnitIdToDb as $unit) {
155 155
       $unit_db_id = $unit->dbId;
156 156
       $unit->dbSave();
157 157
 
158
-      if($unit->isEmpty()) {
158
+      if ($unit->isEmpty()) {
159 159
         // Removing unit object
160 160
         // TODO - change when there will be common bus for all objects
161 161
         // ...or should I? If COUNT is empty - it means that object does not exists in DB. So it should be deleted from PHP memory and cache too
162 162
         unset($this[$unit_db_id]);
163 163
       } else {
164
-        if($unit->dbId <= 0) {
164
+        if ($unit->dbId <= 0) {
165 165
           classSupernova::$debug->error('Error writing unit to DB');
166 166
         }
167 167
         // If unit is new then putting unit object to container
168
-        if(empty($this->_container[$unit->dbId])) {
168
+        if (empty($this->_container[$unit->dbId])) {
169 169
           $this->_container[$unit->dbId] = $unit;
170 170
         }
171 171
       }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
   }
201 201
 
202 202
   public function unitGetCount($unit_id) {
203
-    if(empty($this->mapUnitIdToDb[$unit_id])) {
203
+    if (empty($this->mapUnitIdToDb[$unit_id])) {
204 204
       throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList');
205 205
     }
206 206
     return $this->mapUnitIdToDb[$unit_id]->count;
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
    * @param bool $replace_value
216 216
    */
217 217
   public function unitAdjustCount($unit_id, $unit_count = 0, $replace_value = false) {
218
-    if(empty($this->mapUnitIdToDb[$unit_id])) {
218
+    if (empty($this->mapUnitIdToDb[$unit_id])) {
219 219
       // If unit not exists - creating one and setting all attributes
220 220
       $this->mapUnitIdToDb[$unit_id] = $this->_createElement();
221 221
       $this->mapUnitIdToDb[$unit_id]->setUnitId($unit_id);
222 222
       $this->mapUnitIdToDb[$unit_id]->setLocatedAt($this);
223 223
     }
224 224
 
225
-    if($replace_value) {
225
+    if ($replace_value) {
226 226
       $this->mapUnitIdToDb[$unit_id]->count = $unit_count;
227 227
     } else {
228 228
       $this->mapUnitIdToDb[$unit_id]->adjustCount($unit_count);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
    */
237 237
   public function unitsGetArray() {
238 238
     $result = array();
239
-    foreach($this->mapUnitIdToDb as $unit) {
239
+    foreach ($this->mapUnitIdToDb as $unit) {
240 240
       $result[$unit->unitId] = $unit->count;
241 241
     }
242 242
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
   }
245 245
 
246 246
   public function unitsCountApplyLossMultiplier($ships_lost_multiplier) {
247
-    foreach($this->mapUnitIdToDb as $unit_id => $unit) {
247
+    foreach ($this->mapUnitIdToDb as $unit_id => $unit) {
248 248
       $unit->count = floor($unit->count * $ships_lost_multiplier);
249 249
     }
250 250
   }
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 
271 271
   public function unitsPropertySumById($unit_id = 0, $propertyName = 'count') {
272 272
     $result = 0;
273
-    foreach($this->mapUnitIdToDb as $unit) {
274
-      if(!$unit_id || $unit->unitId == $unit_id) {
273
+    foreach ($this->mapUnitIdToDb as $unit) {
274
+      if (!$unit_id || $unit->unitId == $unit_id) {
275 275
         $result += $unit->$propertyName;
276 276
       }
277 277
     }
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
     print('</tr>');
354 354
 
355
-    foreach($this->mapUnitIdToDb as $unit) {
355
+    foreach ($this->mapUnitIdToDb as $unit) {
356 356
       print('<tr>');
357 357
 
358 358
       print('<td>');
@@ -403,14 +403,14 @@  discard block
 block discarded – undo
403 403
 
404 404
 
405 405
   public function unitZeroDbId() {
406
-    foreach($this->mapUnitIdToDb as $unit) {
406
+    foreach ($this->mapUnitIdToDb as $unit) {
407 407
       $unit->zeroDbId();
408 408
     }
409 409
   }
410 410
 
411 411
 
412 412
   public function unitZeroCount() {
413
-    foreach($this->mapUnitIdToDb as $unit) {
413
+    foreach ($this->mapUnitIdToDb as $unit) {
414 414
       $unit->count = 0;
415 415
     }
416 416
   }
Please login to merge, or discard this patch.