Completed
Push — work-fleets ( 6bf235...9b7cc1 )
by SuperNova.WS
07:25
created
classes/Common/GlobalContainer.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -43,62 +43,62 @@
 block discarded – undo
43 43
     $gc = $this;
44 44
 
45 45
     // Default db
46
-    $gc->db = function ($c) {
46
+    $gc->db = function($c) {
47 47
       classSupernova::$db = $db = new \db_mysql($c);
48 48
 
49 49
       return $db;
50 50
     };
51 51
 
52
-    $gc->debug = function ($c) {
52
+    $gc->debug = function($c) {
53 53
       return new \debug();
54 54
     };
55 55
 
56
-    $gc->types = function ($c) {
56
+    $gc->types = function($c) {
57 57
       return new \Common\Types();
58 58
     };
59 59
 
60
-    $gc->cache = function ($c) {
60
+    $gc->cache = function($c) {
61 61
       return new \classCache(classSupernova::$cache_prefix);
62 62
     };
63 63
 
64
-    $gc->config = function ($c) {
64
+    $gc->config = function($c) {
65 65
       return new \classConfig(classSupernova::$cache_prefix);
66 66
     };
67 67
 
68
-    $gc->localePlayer = function (GlobalContainer $c) {
68
+    $gc->localePlayer = function(GlobalContainer $c) {
69 69
       return new \classLocale($c->config->server_locale_log_usage);
70 70
     };
71 71
 
72
-    $gc->dbGlobalRowOperator = function (GlobalContainer $c) {
72
+    $gc->dbGlobalRowOperator = function(GlobalContainer $c) {
73 73
       return new \DbRowDirectOperator($c->db);
74 74
     };
75 75
 
76
-    $gc->query = $gc->factory(function (GlobalContainer $c) {
76
+    $gc->query = $gc->factory(function(GlobalContainer $c) {
77 77
       return new \DbQueryConstructor($c->db);
78 78
     });
79 79
 
80
-    $gc->cacheOperator = function (GlobalContainer $gc) {
80
+    $gc->cacheOperator = function(GlobalContainer $gc) {
81 81
       return new \SnDbCachedOperator($gc);
82 82
     };
83 83
 
84 84
     $gc->snCacheClass = 'SnCache';
85
-    $gc->snCache = function (GlobalContainer $gc) {
85
+    $gc->snCache = function(GlobalContainer $gc) {
86 86
       return $gc->db->snCache;
87 87
     };
88 88
 
89 89
     $gc->buddyClass = 'Buddy\BuddyModel';
90
-    $gc->buddyModel = function (GlobalContainer $c) {
90
+    $gc->buddyModel = function(GlobalContainer $c) {
91 91
       return new $c->buddyClass($c);
92 92
     };
93 93
 
94
-    $gc->unitModel = function (GlobalContainer $c) {
94
+    $gc->unitModel = function(GlobalContainer $c) {
95 95
       return new \V2Unit\V2UnitModel($c);
96 96
     };
97
-    $gc->unitList = $this->factory(function (GlobalContainer $c) {
97
+    $gc->unitList = $this->factory(function(GlobalContainer $c) {
98 98
       return new \V2Unit\V2UnitList($c);
99 99
     });
100 100
 
101
-    $gc->fleetModel = function (GlobalContainer $c) {
101
+    $gc->fleetModel = function(GlobalContainer $c) {
102 102
       return new V2FleetModel($c);
103 103
     };
104 104
   }
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.
classes/Common/Accessors.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
    * @return bool
41 41
    */
42 42
   public function exists($varName, $accessor) {
43
-    return isset($this->accessors[$varName . $accessor]);
43
+    return isset($this->accessors[$varName.$accessor]);
44 44
   }
45 45
 
46 46
   /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     if (empty($callable)) {
59 59
       return;
60 60
     } elseif (!is_callable($callable)) {
61
-      throw new \Exception('Error assigning callable in ' . get_called_class() . '::set()! Callable typed [' . $accessor . '] is not a callable or not accessible in the scope');
61
+      throw new \Exception('Error assigning callable in '.get_called_class().'::set()! Callable typed ['.$accessor.'] is not a callable or not accessible in the scope');
62 62
     }
63 63
 
64 64
     // Converting method array-callable to closure
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
 //      $callable = $method->getClosure($callable[0]);
69 69
 //    }
70 70
 
71
-    if($invoker = Invoker::build($callable)) {
71
+    if ($invoker = Invoker::build($callable)) {
72 72
       $callable = $invoker;
73 73
     }
74 74
 
75
-    $this->accessors[$varName . $accessor] = $callable;
76
-    if($shared) {
77
-      $this->shared[$varName . $accessor] = true;
75
+    $this->accessors[$varName.$accessor] = $callable;
76
+    if ($shared) {
77
+      $this->shared[$varName.$accessor] = true;
78 78
     }
79 79
   }
80 80
 
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
    */
101 101
   public function execute($varName, $accessor, $params) {
102 102
     if (!$this->exists($varName, $accessor)) {
103
-      throw new \Exception("No [{$accessor}] accessor found for variable [{$varName}] on " . get_called_class() . "::" . __METHOD__);
103
+      throw new \Exception("No [{$accessor}] accessor found for variable [{$varName}] on ".get_called_class()."::".__METHOD__);
104 104
     }
105 105
 
106
-    $functionName = $varName . $accessor;
106
+    $functionName = $varName.$accessor;
107 107
 
108
-    if(isset($this->shared[$functionName])) {
109
-      if(!array_key_exists($functionName, $this->executed)) {
108
+    if (isset($this->shared[$functionName])) {
109
+      if (!array_key_exists($functionName, $this->executed)) {
110 110
         $this->executed[$functionName] = call_user_func_array($this->accessors[$functionName], $params);
111 111
       }
112 112
       return $this->executed[$functionName];
Please login to merge, or discard this patch.
classes/Entity/KeyedModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
       )
28 28
     );
29 29
 
30
-    if(property_exists($this, 'newProperties')) {
30
+    if (property_exists($this, 'newProperties')) {
31 31
       $this->extendProperties($this->newProperties);
32 32
     }
33 33
   }
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   +8 added lines, -12 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 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
@@ -49,13 +45,13 @@  discard block
 block discarded – undo
49 45
     $handler = fopen('event.log', 'a+');
50 46
   }
51 47
 
52
-  fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n");
48
+  fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n");
53 49
 }
54 50
 
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
     }
@@ -181,7 +177,7 @@  discard block
 block discarded – undo
181 177
     MT_EXPLORE   => 'flt_mission_explore',
182 178
   );
183 179
   foreach ($missions_used as $mission_id => $cork) {
184
-    require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX);
180
+    require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX);
185 181
   }
186 182
 
187 183
 //log_file('Обработка миссий');
@@ -248,7 +244,7 @@  discard block
 block discarded – undo
248 244
     $objMission->fleet_event = $fleet_event['fleet_event'];
249 245
 
250 246
     // Fleet that have planet destination is returned
251
-    if($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) {
247
+    if ($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) {
252 248
       $objFleet->markReturnedAndSave();
253 249
       sn_db_transaction_commit();
254 250
       continue;
Please login to merge, or discard this patch.
includes/includes/flt_mission_recycle.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
   $RecyclerCapacity = 0;
17 17
   $OtherFleetCapacity = 0;
18 18
 
19
-  foreach($objFleet->shipsIterator() as $unit_id => $unit) {
20
-    if(in_array($unit_id, Fleet::$snGroupFleet)) {
19
+  foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
20
+    if (in_array($unit_id, Fleet::$snGroupFleet)) {
21 21
       $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit->count;
22
-      if(in_array($unit_id, Fleet::$snGroupRecyclers)) {
22
+      if (in_array($unit_id, Fleet::$snGroupRecyclers)) {
23 23
         $RecyclerCapacity += $capacity;
24 24
       } else {
25 25
         $OtherFleetCapacity += $capacity;
@@ -28,33 +28,33 @@  discard block
 block discarded – undo
28 28
   }
29 29
 
30 30
   $fleet_resources_amount = $objFleet->resourcesGetTotal();
31
-  if($fleet_resources_amount > $OtherFleetCapacity) {
31
+  if ($fleet_resources_amount > $OtherFleetCapacity) {
32 32
     // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков
33 33
     // Уменьшаем ёмкость переработчиков на указанную величину
34 34
     $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity);
35 35
   }
36 36
 
37 37
   $resources_recycled = array();
38
-  if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
38
+  if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
39 39
     $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
40 40
     $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
41 41
   } else {
42
-    if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
42
+    if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
43 43
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)
44 44
     ) {
45 45
       $resources_recycled[RES_METAL] = $RecyclerCapacity / 2;
46 46
       $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2;
47 47
     } else {
48
-      if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
48
+      if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
49 49
         $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
50
-        if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
50
+        if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
51 51
           $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL];
52 52
         } else {
53 53
           $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
54 54
         }
55 55
       } else {
56 56
         $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
57
-        if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
57
+        if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
58 58
           $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL];
59 59
         } else {
60 60
           $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
Please login to merge, or discard this patch.
includes/includes/flt_mission_relocate.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 function flt_mission_relocate($mission_data) {
13 13
   $objFleet = $mission_data->fleet;
14 14
   $destination_planet = &$mission_data->dst_planet;
15
-  if($objFleet->playerOwnerId != $destination_planet['id_owner']) {
15
+  if ($objFleet->playerOwnerId != $destination_planet['id_owner']) {
16 16
     $objFleet->markReturnedAndSave();
17 17
 
18 18
     return;
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
       $fleet_resources[RES_METAL], classLocale::$lang['Metal'],
26 26
       $fleet_resources[RES_CRYSTAL], classLocale::$lang['Crystal'],
27 27
       $fleet_resources[RES_DEUTERIUM], classLocale::$lang['Deuterium']
28
-    ) . '<br />' . classLocale::$lang['sys_relocate_mess_user'];
29
-  foreach($objFleet->shipsIterator() as $ship_id => $ship) {
30
-    $Message .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship->count . '<br />';
28
+    ).'<br />'.classLocale::$lang['sys_relocate_mess_user'];
29
+  foreach ($objFleet->shipsIterator() as $ship_id => $ship) {
30
+    $Message .= classLocale::$lang['tech'][$ship_id].' - '.$ship->count.'<br />';
31 31
   }
32 32
   DBStaticMessages::msg_send_simple_message(
33 33
     $objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, classLocale::$lang['sys_mess_qg'], classLocale::$lang['sys_stay_mess_stay'], $Message
Please login to merge, or discard this patch.