@@ -31,6 +31,9 @@ |
||
31 | 31 | |
32 | 32 | } |
33 | 33 | |
34 | + /** |
|
35 | + * @param integer $snId |
|
36 | + */ |
|
34 | 37 | public function unitAdd($snId, $level) { |
35 | 38 | if($this->indexIsSet($snId)) { |
36 | 39 | $this->indexGetObject($snId)->$level += $level; |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | * @return static |
121 | 121 | */ |
122 | 122 | public static function convertToVector($coordinates, $prefix = '') { |
123 | - $galaxy = !empty($coordinates[$prefix . 'galaxy']) ? intval($coordinates[$prefix . 'galaxy']) : 0; |
|
124 | - $system = !empty($coordinates[$prefix . 'system']) ? intval($coordinates[$prefix . 'system']) : 0; |
|
125 | - $planet = !empty($coordinates[$prefix . 'planet']) ? intval($coordinates[$prefix . 'planet']) : 0; |
|
126 | - $type = !empty($coordinates[$prefix . 'type']) |
|
127 | - ? intval($coordinates[$prefix . 'type']) |
|
128 | - : (!empty($coordinates[$prefix . 'planet_type']) ? intval($coordinates[$prefix . 'planet_type']) : 0); |
|
123 | + $galaxy = !empty($coordinates[$prefix.'galaxy']) ? intval($coordinates[$prefix.'galaxy']) : 0; |
|
124 | + $system = !empty($coordinates[$prefix.'system']) ? intval($coordinates[$prefix.'system']) : 0; |
|
125 | + $planet = !empty($coordinates[$prefix.'planet']) ? intval($coordinates[$prefix.'planet']) : 0; |
|
126 | + $type = !empty($coordinates[$prefix.'type']) |
|
127 | + ? intval($coordinates[$prefix.'type']) |
|
128 | + : (!empty($coordinates[$prefix.'planet_type']) ? intval($coordinates[$prefix.'planet_type']) : 0); |
|
129 | 129 | |
130 | 130 | return new static($galaxy, $system, $planet, $type); |
131 | 131 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function toArray($prefix = '') { |
139 | 139 | $array = array( |
140 | - $prefix . 'galaxy' => $this->galaxy, |
|
141 | - $prefix . 'system' => $this->system, |
|
142 | - $prefix . 'planet' => $this->planet, |
|
143 | - $prefix . 'type' => $this->type, |
|
140 | + $prefix.'galaxy' => $this->galaxy, |
|
141 | + $prefix.'system' => $this->system, |
|
142 | + $prefix.'planet' => $this->planet, |
|
143 | + $prefix.'type' => $this->type, |
|
144 | 144 | ); |
145 | 145 | |
146 | 146 | return $array; |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
3 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
4 | 4 | |
5 | 5 | $template = gettemplate('viewreport', true); |
6 | 6 | $template->assign_var('PAGE_HINT', classLocale::$lang['cr_view_hint']); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @throws \Exception |
72 | 72 | */ |
73 | 73 | protected function indexDuplicated($object, $data) { |
74 | - throw new \Exception('Duplicate index [' . $data . '] in ' . __CLASS__); |
|
74 | + throw new \Exception('Duplicate index ['.$data.'] in '.__CLASS__); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | if ($this->contains($object)) { |
120 | 120 | $this->indexUnset($object); |
121 | 121 | } |
122 | - if($this->indexSet($object, $data)) { |
|
122 | + if ($this->indexSet($object, $data)) { |
|
123 | 123 | // Attaches object only if index sets successfully |
124 | 124 | parent::attach($object, $data); |
125 | 125 | } |
@@ -43,62 +43,62 @@ |
||
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 | } |
@@ -80,7 +80,7 @@ |
||
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 | } |
@@ -15,7 +15,7 @@ |
||
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; |
@@ -18,7 +18,7 @@ discard block |
||
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 |
||
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 |
@@ -14,7 +14,6 @@ |
||
14 | 14 | * |
15 | 15 | * @param Fleet $objFleet |
16 | 16 | * @param bool $start |
17 | - * @param null $result |
|
18 | 17 | * |
19 | 18 | * @return mixed |
20 | 19 | */ |
@@ -23,15 +23,11 @@ discard block |
||
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 |
||
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 |
||
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('Обработка миссий'); |
@@ -190,7 +186,7 @@ discard block |
||
190 | 186 | // Watchdog timer |
191 | 187 | // If flying fleet handler works more then 10 seconds - stopping it |
192 | 188 | // Let next run handle rest of fleets |
193 | - if(time() - SN_TIME_NOW > 10) { |
|
189 | + if (time() - SN_TIME_NOW > 10) { |
|
194 | 190 | $debug->warning('Flying fleet handler standard routine works more then 10 seconds - watchdog unlocked', 'FFH Warning', 504); |
195 | 191 | break; |
196 | 192 | } |
@@ -256,7 +252,7 @@ discard block |
||
256 | 252 | $objMission->fleet_event = $fleet_event['fleet_event']; |
257 | 253 | |
258 | 254 | // Fleet that have planet destination is returned |
259 | - if($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) { |
|
255 | + if ($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) { |
|
260 | 256 | $objFleet->markReturnedAndSave(); |
261 | 257 | sn_db_transaction_commit(); |
262 | 258 | continue; |