Completed
Push — work-fleets ( 13a233...1735a9 )
by SuperNova.WS
05:19
created
includes/classes/Fleet.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -398,31 +398,31 @@  discard block
 block discarded – undo
398 398
 
399 399
     return doquery(
400 400
     // Блокировка самого флота
401
-      "SELECT 1 FROM {{fleets}} AS f " .
401
+      "SELECT 1 FROM {{fleets}} AS f ".
402 402
 
403 403
       // Блокировка всех юнитов, принадлежащих этому флоту
404
-      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " .
404
+      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ".
405 405
 
406 406
       // Блокировка всех прилетающих и улетающих флотов, если нужно
407 407
       // TODO - lock fleets by COORDINATES
408
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') .
408
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '').
409 409
       // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination
410
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') .
410
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : '').
411 411
 
412
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') .
412
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '').
413 413
       // Блокировка всех юнитов, принадлежащих владельцу планеты-цели
414
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') .
414
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '').
415 415
       // Блокировка планеты-цели
416
-      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') .
416
+      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '').
417 417
       // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели
418 418
 //      ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') .
419 419
 
420 420
 
421
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') .
421
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '').
422 422
       // Блокировка всех юнитов, принадлежащих владельцу флота
423
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') .
423
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '').
424 424
       // Блокировка планеты отправления
425
-      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') .
425
+      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '').
426 426
       // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота
427 427
 //      ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') .
428 428
 
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
   public function dbGetLockById($dbId) {
440 440
     doquery(
441 441
     // Блокировка самого флота
442
-      "SELECT 1 FROM {{fleets}} AS FLEET0 " .
442
+      "SELECT 1 FROM {{fleets}} AS FLEET0 ".
443 443
       // Lock fleet owner
444
-      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " .
444
+      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ".
445 445
       // Блокировка всех юнитов, принадлежащих этому флоту
446
-      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " .
446
+      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ".
447 447
 
448 448
       // Без предварительной выборки неизвестно - куда летит этот флот.
449 449
       // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота.
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
         FLEET1.fleet_end_planet = FLEET0.fleet_end_planet
460 460
       " .
461 461
       // Блокировка всех юнитов, принадлежащих этим флотам
462
-      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " .
462
+      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ".
463 463
       // Lock fleet owner
464
-      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " .
464
+      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ".
465 465
 
466 466
       "LEFT JOIN {{fleets}} AS FLEET2 ON
467 467
         FLEET2.fleet_mess = 1   AND FLEET0.fleet_mess = 0 AND
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
       " .
472 472
       // Блокировка всех юнитов, принадлежащих этим флотам
473 473
       "LEFT JOIN {{unit}} as UNIT2 ON
474
-        UNIT2.unit_location_type = " . LOC_FLEET . " AND
474
+        UNIT2.unit_location_type = " . LOC_FLEET." AND
475 475
         UNIT2.unit_location_id = FLEET2.fleet_id
476 476
       " .
477 477
       // Lock fleet owner
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
       " .
489 489
       // Блокировка всех юнитов, принадлежащих этим флотам
490 490
       "LEFT JOIN {{unit}} as UNIT3 ON
491
-        UNIT3.unit_location_type = " . LOC_FLEET . " AND
491
+        UNIT3.unit_location_type = " . LOC_FLEET." AND
492 492
         UNIT3.unit_location_id = FLEET3.fleet_id
493 493
       " .
494 494
       // Lock fleet owner
495
-      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " .
495
+      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ".
496 496
 
497 497
       "LEFT JOIN {{fleets}} AS FLEET4 ON
498 498
         FLEET4.fleet_mess = 1   AND FLEET0.fleet_mess = 1 AND
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
       " .
503 503
       // Блокировка всех юнитов, принадлежащих этим флотам
504 504
       "LEFT JOIN {{unit}} as UNIT4 ON
505
-        UNIT4.unit_location_type = " . LOC_FLEET . " AND
505
+        UNIT4.unit_location_type = " . LOC_FLEET." AND
506 506
         UNIT4.unit_location_id = FLEET4.fleet_id
507 507
       " .
508 508
       // Lock fleet owner
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
       " .
525 525
       // Блокировка всех юнитов, принадлежащих этой планете
526 526
       "LEFT JOIN {{unit}} as UNIT5 ON
527
-        UNIT5.unit_location_type = " . LOC_PLANET . " AND
527
+        UNIT5.unit_location_type = " . LOC_PLANET." AND
528 528
         UNIT5.unit_location_id = PLANETS5.id
529 529
       " .
530 530
 
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
       " .
543 543
       // Блокировка всех юнитов, принадлежащих этой планете
544 544
       "LEFT JOIN {{unit}} as UNIT6 ON
545
-        UNIT6.unit_location_type = " . LOC_PLANET . " AND
545
+        UNIT6.unit_location_type = " . LOC_PLANET." AND
546 546
         UNIT6.unit_location_id = PLANETS6.id
547 547
       " .
548 548
       "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE"
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
       } elseif ($this->isResource($unit_id)) {
662 662
         $this->resource_list[$unit_id] = $unit_count;
663 663
       } else {
664
-        throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR);
664
+        throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), ERR_ERROR);
665 665
       }
666 666
     }
667 667
   }
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
    */
987 987
   public function resourcesSet($resource_list) {
988 988
     if (!empty($this->propertiesAdjusted['resource_list'])) {
989
-      throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
989
+      throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR);
990 990
     }
991 991
     $this->resourcesAdjust($resource_list, true);
992 992
   }
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
       // Check for negative unit value
1021 1021
       if ($this->resource_list[$resource_id] < 0) {
1022 1022
         // TODO
1023
-        throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
1023
+        throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR);
1024 1024
       }
1025 1025
     }
1026 1026
   }
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 
1194 1194
   protected function printErrorIfNoShips() {
1195 1195
     if ($this->unitList->unitsCount() <= 0) {
1196
-      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
1196
+      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5);
1197 1197
     }
1198 1198
   }
1199 1199
 
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
     } catch (Exception $e) {
1541 1541
 
1542 1542
       // TODO - MESSAGE BOX
1543
-      if($e instanceof ExceptionFleetInvalid) {
1543
+      if ($e instanceof ExceptionFleetInvalid) {
1544 1544
         sn_db_transaction_rollback();
1545 1545
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1546 1546
       } else {
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
       $validator->validate();
1630 1630
     } catch (Exception $e) {
1631 1631
       // TODO - MESSAGE BOX
1632
-      if($e instanceof ExceptionFleetInvalid) {
1632
+      if ($e instanceof ExceptionFleetInvalid) {
1633 1633
         sn_db_transaction_rollback();
1634 1634
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1635 1635
       } else {
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
 
1691 1691
 
1692 1692
     if (!empty($captain['unit_id'])) {
1693
-      db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$this->_dbId}");
1693
+      db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = ".LOC_FLEET.", `unit_location_id` = {$this->_dbId}");
1694 1694
     }
1695 1695
 
1696 1696
 //    return $this->fleet->acs['ankunft'] - $this->fleet->time_launch >= $this->fleet->travelData['duration'];
@@ -1702,7 +1702,7 @@  discard block
 block discarded – undo
1702 1702
     $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob);
1703 1703
 
1704 1704
     $template_result += array(
1705
-      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''),
1705
+      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''),
1706 1706
       'dist'            => pretty_number($this->travelData['distance']),
1707 1707
       'speed'           => pretty_number($this->travelData['fleet_speed']),
1708 1708
       'deute_need'      => pretty_number($this->travelData['consumption']),
Please login to merge, or discard this patch.
includes/classes/DBStaticRecord.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
             $result[] = 'NULL';
46 46
           break;
47 47
           default:
48
-            $string = (string)$fieldName;
49
-            if($string == '') {
48
+            $string = (string) $fieldName;
49
+            if ($string == '') {
50 50
               throw new ExceptionDBFieldEmpty();
51 51
             }
52
-            $result[] = '`' . $string . '`';
52
+            $result[] = '`'.$string.'`';
53 53
         }
54 54
       }
55 55
     } else {
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
     if (!empty($fieldList)) {
78 78
       $user_record = self::$dbStatic->doquery(
79 79
         (
80
-          "SELECT {$fieldList}" .
81
-          " FROM {{" . self::$_table . "}}" .
82
-          (!empty($where) ? " WHERE {$where}" : '') .
83
-          (!empty($for_update) ? " FOR UPDATE" : '') .
80
+          "SELECT {$fieldList}".
81
+          " FROM {{".self::$_table."}}".
82
+          (!empty($where) ? " WHERE {$where}" : '').
83
+          (!empty($for_update) ? " FOR UPDATE" : '').
84 84
           ($returnFirst ? ' LIMIT 1' : '')
85 85
         ),
86 86
         $returnFirst
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
    * @return int
111 111
    */
112 112
   public static function getMaxId() {
113
-    $maxId = self::$dbStatic->doquery("SELECT MAX(`" . static::$_idField . "`) AS `maxId` FROM `{{" . static::$_table . "}}`", true);
113
+    $maxId = self::$dbStatic->doquery("SELECT MAX(`".static::$_idField."`) AS `maxId` FROM `{{".static::$_table."}}`", true);
114 114
 
115 115
     return !empty($maxId['maxId']) ? $maxId['maxId'] : 0;
116 116
   }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
    * @return array|null
124 124
    */
125 125
   public static function getRecordById($user_id, $fieldList = array(), $for_update = false) {
126
-    return static::getRecord(static::$_idField . ' = ' . $user_id, $fieldList, $for_update);
126
+    return static::getRecord(static::$_idField.' = '.$user_id, $fieldList, $for_update);
127 127
   }
128 128
 
129 129
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
   public static function queryExistsIdInList($idList) {
136 136
     $query = null;
137 137
     if (!empty($idList)) {
138
-      $query = self::$dbStatic->doquery("SELECT `" . static::$_idField . "` FROM `{{" . static::$_table . "}}` WHERE `" . static::$_idField . "` IN (" . implode(',', $idList) . ")");
138
+      $query = self::$dbStatic->doquery("SELECT `".static::$_idField."` FROM `{{".static::$_table."}}` WHERE `".static::$_idField."` IN (".implode(',', $idList).")");
139 139
     }
140 140
 
141 141
     return !empty($query) ? $query : null;
Please login to merge, or discard this patch.
includes/classes/FleetValidator.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 //pdump($checkResult, $condition);
60 60
 
61 61
       if (is_array($action)) {
62
-        if(!empty($action[$checkResult])) {
62
+        if (!empty($action[$checkResult])) {
63 63
           $action = $action[$checkResult];
64 64
         } else {
65 65
           continue;
@@ -882,8 +882,8 @@  discard block
 block discarded – undo
882 882
    */
883 883
   protected function checkACSInvited() {
884 884
     $playersInvited = !empty($this->fleet->acs['eingeladen']) ? explode(',', $this->fleet->acs['eingeladen']) : array();
885
-    foreach($playersInvited as $playerId) {
886
-      if(intval($playerId) == $this->fleet->dbOwnerRow['id']) {
885
+    foreach ($playersInvited as $playerId) {
886
+      if (intval($playerId) == $this->fleet->dbOwnerRow['id']) {
887 887
         return true;
888 888
       }
889 889
     }
@@ -970,9 +970,9 @@  discard block
 block discarded – undo
970 970
 
971 971
     // Retrieving flying fleets
972 972
     $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $this->fleet->dbTargetRow);
973
-    foreach($objFleetsBashing->_container as $fleetBashing) {
973
+    foreach ($objFleetsBashing->_container as $fleetBashing) {
974 974
       // Checking for ACS - each ACS count only once
975
-      if($fleetBashing->group_id) {
975
+      if ($fleetBashing->group_id) {
976 976
         $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target;
977 977
       } else {
978 978
         $bashing_list[] = $fleetBashing->time_arrive_to_target;
@@ -980,12 +980,12 @@  discard block
 block discarded – undo
980 980
     }
981 981
 
982 982
     // Check for joining to ACS - if there are already fleets in ACS no checks should be done
983
-    if($this->fleet->mission_type == MT_ACS && $bashing_list["{$user['id']}_{$this->fleet->group_id}"]) {
983
+    if ($this->fleet->mission_type == MT_ACS && $bashing_list["{$user['id']}_{$this->fleet->group_id}"]) {
984 984
       return true;
985 985
     }
986 986
 
987 987
     $query = db_bashing_list_get($user, $this->fleet->dbTargetRow, $time_limit);
988
-    while($bashing_row = db_fetch($query)) {
988
+    while ($bashing_row = db_fetch($query)) {
989 989
       $bashing_list[] = $bashing_row['bashing_time'];
990 990
     }
991 991
 
@@ -994,9 +994,9 @@  discard block
 block discarded – undo
994 994
     $last_attack = 0;
995 995
     $wave = 0;
996 996
     $attack = 1;
997
-    foreach($bashing_list as &$bash_time) {
997
+    foreach ($bashing_list as &$bash_time) {
998 998
       $attack++;
999
-      if(
999
+      if (
1000 1000
         $bash_time - $last_attack > classSupernova::$config->fleet_bashing_interval
1001 1001
         ||
1002 1002
         $attack > classSupernova::$config->fleet_bashing_attacks
Please login to merge, or discard this patch.