@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $this->sql_index_field = "{$table_name}_name"; |
34 | 34 | $this->sql_value_field = "{$table_name}_value"; |
35 | 35 | |
36 | - if(!$this->_DB_LOADED) { |
|
36 | + if (!$this->_DB_LOADED) { |
|
37 | 37 | $this->db_loadAll(); |
38 | 38 | } |
39 | 39 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function db_loadItem($index) { |
55 | 55 | $result = null; |
56 | - if($index) { |
|
56 | + if ($index) { |
|
57 | 57 | $index_safe = db_escape($index); |
58 | 58 | $queryResult = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true); |
59 | - if(is_array($queryResult) && !empty($queryResult)) { |
|
59 | + if (is_array($queryResult) && !empty($queryResult)) { |
|
60 | 60 | $this->$index = $result = $queryResult[$this->sql_value_field]; |
61 | 61 | } |
62 | 62 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $this->loadDefaults(); |
69 | 69 | |
70 | 70 | $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;"); |
71 | - while($row = db_fetch($query)) { |
|
71 | + while ($row = db_fetch($query)) { |
|
72 | 72 | $this->$row[$this->sql_index_field] = $row[$this->sql_value_field]; |
73 | 73 | } |
74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | public function loadDefaults() { |
79 | - foreach($this->defaults as $defName => $defValue) { |
|
79 | + foreach ($this->defaults as $defName => $defValue) { |
|
80 | 80 | $this->$defName = $defValue; |
81 | 81 | } |
82 | 82 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | public function db_saveItem($item_list, $value = NULL) { |
95 | - if(empty($item_list)) { |
|
95 | + if (empty($item_list)) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | |
101 | 101 | // Сначала записываем данные в базу - что бы поймать все блокировки |
102 | 102 | $qry = array(); |
103 | - foreach($item_list as $item_name => $item_value) { |
|
104 | - if($item_name) { |
|
103 | + foreach ($item_list as $item_name => $item_value) { |
|
104 | + if ($item_name) { |
|
105 | 105 | $item_value = db_escape($item_value === NULL ? $this->$item_name : $item_value); |
106 | 106 | $item_name = db_escape($item_name); |
107 | 107 | $qry[] = "('{$item_name}', '{$item_value}')"; |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";"); |
111 | 111 | |
112 | 112 | // И только после взятия блокировок - меняем значения в кэше |
113 | - foreach($item_list as $item_name => $item_value) { |
|
114 | - if($item_name && $item_value !== null) { |
|
113 | + foreach ($item_list as $item_name => $item_value) { |
|
114 | + if ($item_name && $item_value !== null) { |
|
115 | 115 | $this->__set($item_name, $item_value); |
116 | 116 | } |
117 | 117 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | public function __get($name) { |
129 | - if($this->force) { |
|
129 | + if ($this->force) { |
|
130 | 130 | $this->force = false; |
131 | 131 | $this->db_loadItem($name); |
132 | 132 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | public function __set($name, $value) { |
138 | - if($this->force) { |
|
138 | + if ($this->force) { |
|
139 | 139 | $this->force = false; |
140 | 140 | $this->db_saveItem($name, $value); |
141 | 141 | } |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
113 | 113 | if (preg_match($rexep, $date, $out)) { |
114 | 114 | $ret = array( |
115 | - "tm_sec" => (int)$out['S'], |
|
116 | - "tm_min" => (int)$out['M'], |
|
117 | - "tm_hour" => (int)$out['H'], |
|
118 | - "tm_mday" => (int)$out['d'], |
|
115 | + "tm_sec" => (int) $out['S'], |
|
116 | + "tm_min" => (int) $out['M'], |
|
117 | + "tm_hour" => (int) $out['H'], |
|
118 | + "tm_mday" => (int) $out['d'], |
|
119 | 119 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
120 | 120 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
121 | 121 | ); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return int |
151 | 151 | */ |
152 | 152 | function datePart($fullDate) { |
153 | - return (int)strtotime(date('Y-m-d', $fullDate)); |
|
153 | + return (int) strtotime(date('Y-m-d', $fullDate)); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @return bool |
179 | 179 | * @throws ErrorException |
180 | 180 | */ |
181 | - function ($errno, $errstr, $errfile, $errline) { |
|
181 | + function($errno, $errstr, $errfile, $errline) { |
|
182 | 182 | throw new ErrorException($errstr, 0, $errno, $errfile, $errline); |
183 | 183 | } |
184 | 184 | ); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * que esperabas!!! soy newbie!!! D':< |
25 | 25 | */ |
26 | 26 | |
27 | -if(!defined('INSIDE')) { |
|
27 | +if (!defined('INSIDE')) { |
|
28 | 28 | die("attemp hacking"); |
29 | 29 | } |
30 | 30 | |
@@ -37,16 +37,16 @@ discard block |
||
37 | 37 | function log_file($message, $ident_change = 0) { |
38 | 38 | static $ident = 0; |
39 | 39 | |
40 | - if(!defined('SN_DEBUG_LOG')) { |
|
40 | + if (!defined('SN_DEBUG_LOG')) { |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
44 | - if($this->log_file_handler === null) { |
|
44 | + if ($this->log_file_handler === null) { |
|
45 | 45 | $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
46 | 46 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
47 | 47 | } |
48 | 48 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
49 | - if($this->log_file_handler) { |
|
49 | + if ($this->log_file_handler) { |
|
50 | 50 | @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
51 | 51 | } |
52 | 52 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | $result = array(); |
82 | 82 | $transaction_id = SN::db_transaction_check(false) ? SN::$transaction_id : SN::$transaction_id++; |
83 | 83 | $result[] = "tID {$transaction_id}"; |
84 | - foreach($backtrace as $a_trace) { |
|
85 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
84 | + foreach ($backtrace as $a_trace) { |
|
85 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | $function = |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $line = !empty($a_trace['line']) ? $a_trace['line'] : '_UNDEFINED_'; |
100 | 100 | $result[] = "{$function} - '{$file}' Line {$line}"; |
101 | 101 | |
102 | - if(!$long_comment) { |
|
102 | + if (!$long_comment) { |
|
103 | 103 | break; |
104 | 104 | } |
105 | 105 | } |
@@ -108,26 +108,26 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | function dump($dump = false, $force_base = false, $deadlock = false) { |
111 | - if($dump === false) { |
|
111 | + if ($dump === false) { |
|
112 | 112 | return; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $error_backtrace = array(); |
116 | 116 | $base_dump = false; |
117 | 117 | |
118 | - if($force_base === true) { |
|
118 | + if ($force_base === true) { |
|
119 | 119 | $base_dump = true; |
120 | 120 | } |
121 | 121 | |
122 | - if($dump === true) { |
|
122 | + if ($dump === true) { |
|
123 | 123 | $base_dump = true; |
124 | 124 | } else { |
125 | - if(!is_array($dump)) { |
|
125 | + if (!is_array($dump)) { |
|
126 | 126 | $dump = array('var' => $dump); |
127 | 127 | } |
128 | 128 | |
129 | - foreach($dump as $dump_var_name => $dump_var) { |
|
130 | - if($dump_var_name == 'base_dump') { |
|
129 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
130 | + if ($dump_var_name == 'base_dump') { |
|
131 | 131 | $base_dump = $dump_var; |
132 | 132 | } else { |
133 | 133 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -135,24 +135,23 @@ discard block |
||
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - if($deadlock && ($q = db_fetch(SN::$db->mysql_get_innodb_status()))) { |
|
138 | + if ($deadlock && ($q = db_fetch(SN::$db->mysql_get_innodb_status()))) { |
|
139 | 139 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
140 | 140 | $error_backtrace['locks'] = _SnCacheInternal::$locks; |
141 | 141 | $error_backtrace['cSN_data'] = _SnCacheInternal::$data; |
142 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
143 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
142 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
143 | + foreach ($location as $location_id => &$location_data) // $location_data = $location_id; |
|
144 | 144 | { |
145 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
146 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
145 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
147 | 146 | } |
148 | 147 | } |
149 | 148 | } |
150 | 149 | |
151 | - if($base_dump) { |
|
152 | - if(!is_array($this->log_array) || empty($this->log_array)) { |
|
150 | + if ($base_dump) { |
|
151 | + if (!is_array($this->log_array) || empty($this->log_array)) { |
|
153 | 152 | $this->log_array = []; |
154 | 153 | } else { |
155 | - foreach($this->log_array as $log) { |
|
154 | + foreach ($this->log_array as $log) { |
|
156 | 155 | $error_backtrace['queries'][] = $log; |
157 | 156 | } |
158 | 157 | } |
@@ -164,17 +163,17 @@ discard block |
||
164 | 163 | // Converting object instances to object names |
165 | 164 | |
166 | 165 | foreach ($error_backtrace['backtrace'] as &$backtrace) { |
167 | - if(is_object($backtrace['object'])) { |
|
166 | + if (is_object($backtrace['object'])) { |
|
168 | 167 | $backtrace['object'] = get_class($backtrace['object']); |
169 | 168 | } |
170 | 169 | |
171 | - if(empty($backtrace['args'])) { |
|
170 | + if (empty($backtrace['args'])) { |
|
172 | 171 | continue; |
173 | 172 | } |
174 | 173 | |
175 | 174 | // Doing same conversion for backtrace params |
176 | - foreach($backtrace['args'] as &$arg) { |
|
177 | - if(is_object($arg)) { |
|
175 | + foreach ($backtrace['args'] as &$arg) { |
|
176 | + if (is_object($arg)) { |
|
178 | 177 | $arg = 'object::' . get_class($arg); |
179 | 178 | } |
180 | 179 | } |
@@ -203,14 +202,14 @@ discard block |
||
203 | 202 | function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
204 | 203 | global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user; |
205 | 204 | |
206 | - if(empty(SN::$db->connected)) { |
|
205 | + if (empty(SN::$db->connected)) { |
|
207 | 206 | // TODO - писать ошибку в файл |
208 | 207 | die('SQL server currently unavailable. Please contact Administration...'); |
209 | 208 | } |
210 | 209 | |
211 | 210 | sn_db_transaction_rollback(); |
212 | 211 | |
213 | - if(SN::$config->debug == 1) { |
|
212 | + if (SN::$config->debug == 1) { |
|
214 | 213 | echo "<h2>{$title}</h2><br><font color=red>" . htmlspecialchars($message) . "</font><br><hr>"; |
215 | 214 | echo "<table>{$this->log}</table>"; |
216 | 215 | } |
@@ -220,7 +219,7 @@ discard block |
||
220 | 219 | $error_text = db_escape($message); |
221 | 220 | $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false); |
222 | 221 | |
223 | - if(!$sys_log_disabled) { |
|
222 | + if (!$sys_log_disabled) { |
|
224 | 223 | $query = "INSERT INTO `{{logs}}` SET |
225 | 224 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "', |
226 | 225 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -238,7 +237,7 @@ discard block |
||
238 | 237 | ob_start(); |
239 | 238 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
240 | 239 | |
241 | - foreach($error_backtrace as $name => $value) { |
|
240 | + foreach ($error_backtrace as $name => $value) { |
|
242 | 241 | print('<hr>'); |
243 | 242 | pdump($value, $name); |
244 | 243 | } |
@@ -250,14 +249,14 @@ discard block |
||
250 | 249 | function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
251 | 250 | global $user, $lang, $sys_log_disabled; |
252 | 251 | |
253 | - if(empty(SN::$db->connected)) { |
|
252 | + if (empty(SN::$db->connected)) { |
|
254 | 253 | // TODO - писать ошибку в файл |
255 | 254 | die('SQL server currently unavailable. Please contact Administration...'); |
256 | 255 | } |
257 | 256 | |
258 | 257 | $error_backtrace = $this->dump($dump, false); |
259 | 258 | |
260 | - if(!$sys_log_disabled) { |
|
259 | + if (!$sys_log_disabled) { |
|
261 | 260 | $query = "INSERT INTO `{{logs}}` SET |
262 | 261 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "', |
263 | 262 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -275,11 +274,11 @@ discard block |
||
275 | 274 | // Dump variables nicer then var_dump() |
276 | 275 | |
277 | 276 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
278 | - if(isset($varname)) { |
|
277 | + if (isset($varname)) { |
|
279 | 278 | $varname .= " = "; |
280 | 279 | } |
281 | 280 | |
282 | - if($level == -1) { |
|
281 | + if ($level == -1) { |
|
283 | 282 | $trans[' '] = '∴'; |
284 | 283 | $trans["\t"] = '⇒'; |
285 | 284 | $trans["\n"] = '¶;'; |
@@ -288,7 +287,7 @@ discard block |
||
288 | 287 | |
289 | 288 | return strtr(htmlspecialchars($value), $trans); |
290 | 289 | } |
291 | - if($level == 0) { |
|
290 | + if ($level == 0) { |
|
292 | 291 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
293 | 292 | $dumper = mt_rand(10, 99) . '|' . $varname; |
294 | 293 | } |
@@ -296,22 +295,22 @@ discard block |
||
296 | 295 | $type = gettype($value); |
297 | 296 | $dumper .= $type; |
298 | 297 | |
299 | - if($type == 'string') { |
|
298 | + if ($type == 'string') { |
|
300 | 299 | $dumper .= '(' . strlen($value) . ')'; |
301 | 300 | $value = dump($value, '', -1); |
302 | - } elseif($type == 'boolean') { |
|
301 | + } elseif ($type == 'boolean') { |
|
303 | 302 | $value = ($value ? 'true' : 'false'); |
304 | - } elseif($type == 'object') { |
|
303 | + } elseif ($type == 'object') { |
|
305 | 304 | $props = get_class_vars(get_class($value)); |
306 | 305 | $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
307 | - foreach($props as $key => $val) { |
|
306 | + foreach ($props as $key => $val) { |
|
308 | 307 | $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
309 | 308 | $dumper .= dump($value->$key, '', $level + 1); |
310 | 309 | } |
311 | 310 | $value = ''; |
312 | - } elseif($type == 'array') { |
|
311 | + } elseif ($type == 'array') { |
|
313 | 312 | $dumper .= '(' . count($value) . ')'; |
314 | - foreach($value as $key => $val) { |
|
313 | + foreach ($value as $key => $val) { |
|
315 | 314 | $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
316 | 315 | $dumper .= dump($val, '', $level + 1); |
317 | 316 | } |
@@ -331,7 +330,7 @@ discard block |
||
331 | 330 | // $backtrace = $backtrace[1]; |
332 | 331 | |
333 | 332 | $caller = ''; |
334 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
333 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
335 | 334 | $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
336 | 335 | (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
337 | 336 | $backtrace[1]['function'] . |
@@ -358,7 +357,7 @@ discard block |
||
358 | 357 | } |
359 | 358 | |
360 | 359 | function pr($prePrint = false) { |
361 | - if($prePrint) { |
|
360 | + if ($prePrint) { |
|
362 | 361 | print("<br>"); |
363 | 362 | } |
364 | 363 | print(mt_rand() . "<br>"); |
@@ -368,7 +367,7 @@ discard block |
||
368 | 367 | global $_PRINT_COUNT_VALUE; |
369 | 368 | $_PRINT_COUNT_VALUE++; |
370 | 369 | |
371 | - if($prePrint) { |
|
370 | + if ($prePrint) { |
|
372 | 371 | print("<br>"); |
373 | 372 | } |
374 | 373 | print($_PRINT_COUNT_VALUE . "<br>"); |
@@ -68,8 +68,7 @@ |
||
68 | 68 | $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0; |
69 | 69 | $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0; |
70 | 70 | $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0; |
71 | - $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : |
|
72 | - (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
71 | + $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
73 | 72 | $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type; |
74 | 73 | |
75 | 74 | return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields); |
@@ -8,8 +8,8 @@ |
||
8 | 8 | const MOON_MIN_SIZE = 1100; |
9 | 9 | const MOON_MAX_SIZE = 8999; |
10 | 10 | |
11 | - const MOON_DEBRIS_MIN = 1000000; // Minimum amount of debris to span a moon |
|
12 | - const MOON_CHANCE_MIN_PERCENT = 1; // Minimum chance to span a moon |
|
11 | + const MOON_DEBRIS_MIN = 1000000; // Minimum amount of debris to span a moon |
|
12 | + const MOON_CHANCE_MIN_PERCENT = 1; // Minimum chance to span a moon |
|
13 | 13 | const MOON_CHANCE_MAX_PERCENT = 30; // Maximum chance to span a moon |
14 | 14 | |
15 | 15 | /** |
@@ -465,15 +465,11 @@ |
||
465 | 465 | protected function flt_flyingFleetsSort($a, $b) { |
466 | 466 | return |
467 | 467 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
468 | - $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : |
|
469 | - // Если время - одинаковое, сравниваем события флотов |
|
468 | + $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
470 | 469 | // Если события - одинаковые, то флоты равны |
471 | - ($a['fleet_event'] == $b['fleet_event'] ? 0 : |
|
472 | - // Если события разные - первыми считаем прибывающие флоты |
|
473 | - ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : |
|
474 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
475 | - ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : |
|
476 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
470 | + ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
471 | + ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
472 | + ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
477 | 473 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
478 | 474 | ( |
479 | 475 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -142,9 +142,7 @@ |
||
142 | 142 | // Простое условие - $field_id = $field_value |
143 | 143 | if (is_string($field_id)) { |
144 | 144 | $field_value = |
145 | - $field_value === null ? 'NULL' : |
|
146 | - (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
147 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
145 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
148 | 146 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
149 | 147 | } else { |
150 | 148 | die('Неподдерживаемый тип условия'); |
@@ -91,95 +91,95 @@ |
||
91 | 91 | |
92 | 92 | // Services -------------------------------------------------------------------------------------------------------- |
93 | 93 | // Default db |
94 | - $gc->db = function (GlobalContainer $c) { |
|
94 | + $gc->db = function(GlobalContainer $c) { |
|
95 | 95 | SN::$db = new \db_mysql($c); |
96 | 96 | |
97 | 97 | return SN::$db; |
98 | 98 | }; |
99 | 99 | |
100 | - $gc->debug = function (/** @noinspection PhpUnusedParameterInspection */ |
|
100 | + $gc->debug = function(/** @noinspection PhpUnusedParameterInspection */ |
|
101 | 101 | GlobalContainer $c) { |
102 | 102 | return new \debug(); |
103 | 103 | }; |
104 | 104 | |
105 | - $gc->cache = function (GlobalContainer $gc) { |
|
105 | + $gc->cache = function(GlobalContainer $gc) { |
|
106 | 106 | return new \classCache($gc->cachePrefix); |
107 | 107 | }; |
108 | 108 | |
109 | - $gc->config = function (GlobalContainer $gc) { |
|
109 | + $gc->config = function(GlobalContainer $gc) { |
|
110 | 110 | return new \classConfig($gc->cachePrefix); |
111 | 111 | }; |
112 | 112 | |
113 | 113 | |
114 | - $gc->repository = function (GlobalContainer $gc) { |
|
114 | + $gc->repository = function(GlobalContainer $gc) { |
|
115 | 115 | return new Repository($gc); |
116 | 116 | }; |
117 | 117 | |
118 | - $gc->storage = function (GlobalContainer $gc) { |
|
118 | + $gc->storage = function(GlobalContainer $gc) { |
|
119 | 119 | return new \Storage($gc); |
120 | 120 | }; |
121 | 121 | |
122 | - $gc->design = function (GlobalContainer $gc) { |
|
122 | + $gc->design = function(GlobalContainer $gc) { |
|
123 | 123 | return new \Design($gc); |
124 | 124 | }; |
125 | 125 | |
126 | - $gc->bbCodeParser = function (GlobalContainer $gc) { |
|
126 | + $gc->bbCodeParser = function(GlobalContainer $gc) { |
|
127 | 127 | return new \BBCodeParser($gc); |
128 | 128 | }; |
129 | 129 | |
130 | - $gc->fleetDispatcher = function (GlobalContainer $gc) { |
|
130 | + $gc->fleetDispatcher = function(GlobalContainer $gc) { |
|
131 | 131 | return new \Fleet\FleetDispatcher($gc); |
132 | 132 | }; |
133 | 133 | |
134 | - $gc->watchdog = function (GlobalContainer $gc) { |
|
134 | + $gc->watchdog = function(GlobalContainer $gc) { |
|
135 | 135 | return new Watchdog($gc); |
136 | 136 | }; |
137 | 137 | |
138 | - $gc->eventBus = function (GlobalContainer $gc) { |
|
138 | + $gc->eventBus = function(GlobalContainer $gc) { |
|
139 | 139 | return new EventBus($gc); |
140 | 140 | }; |
141 | 141 | |
142 | - $gc->valueStorage = function (GlobalContainer $gc) { |
|
142 | + $gc->valueStorage = function(GlobalContainer $gc) { |
|
143 | 143 | return new ValueStorage([]); |
144 | 144 | }; |
145 | 145 | |
146 | - $gc->bonusCatalog = function (GlobalContainer $gc) { |
|
146 | + $gc->bonusCatalog = function(GlobalContainer $gc) { |
|
147 | 147 | return new BonusCatalog($gc); |
148 | 148 | }; |
149 | 149 | |
150 | - $gc->general = function (GlobalContainer $gc) { |
|
150 | + $gc->general = function(GlobalContainer $gc) { |
|
151 | 151 | return new General($gc); |
152 | 152 | }; |
153 | 153 | |
154 | - $gc->economicHelper = function (GlobalContainer $gc) { |
|
154 | + $gc->economicHelper = function(GlobalContainer $gc) { |
|
155 | 155 | return new EconomicHelper($gc); |
156 | 156 | }; |
157 | 157 | |
158 | - $gc->playerLevelHelper = function (GlobalContainer $gc) { |
|
158 | + $gc->playerLevelHelper = function(GlobalContainer $gc) { |
|
159 | 159 | return new PlayerLevelHelper($gc); |
160 | 160 | }; |
161 | 161 | |
162 | - $gc->pimp = function (GlobalContainer $gc) { |
|
162 | + $gc->pimp = function(GlobalContainer $gc) { |
|
163 | 163 | return new SnPimp($gc); |
164 | 164 | }; |
165 | 165 | |
166 | - $gc->modules = function (GlobalContainer $gc) { |
|
166 | + $gc->modules = function(GlobalContainer $gc) { |
|
167 | 167 | return new ModulesManager($gc); |
168 | 168 | }; |
169 | 169 | |
170 | 170 | // Dummy objects --------------------------------------------------------------------------------------------------- |
171 | - $gc->theUser = function (GlobalContainer $gc) { |
|
171 | + $gc->theUser = function(GlobalContainer $gc) { |
|
172 | 172 | return new \TheUser($gc); |
173 | 173 | }; |
174 | 174 | |
175 | 175 | |
176 | 176 | // Models ---------------------------------------------------------------------------------------------------------- |
177 | 177 | $gc->skinEntityClass = \SkinV2::class; |
178 | - $gc->skinModel = function (GlobalContainer $gc) { |
|
178 | + $gc->skinModel = function(GlobalContainer $gc) { |
|
179 | 179 | return new \SkinModel($gc); |
180 | 180 | }; |
181 | 181 | |
182 | - $gc->textModel = function (GlobalContainer $gc) { |
|
182 | + $gc->textModel = function(GlobalContainer $gc) { |
|
183 | 183 | return new \TextModel($gc); |
184 | 184 | }; |
185 | 185 |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | use DBAL\OldDbChangeSet; |
8 | 8 | use Planet\DBStaticPlanet; |
9 | 9 | |
10 | -function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') |
|
11 | -{ |
|
10 | +function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') { |
|
12 | 11 | // Here we select which part of defense should take damage: structure or shield |
13 | 12 | // $damageTo = P_SHIELD; |
14 | 13 | // $damageTo = P_STRUCTURE; |
@@ -37,8 +36,7 @@ discard block |
||
37 | 36 | $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] ); |
38 | 37 | $structures[$targetedStructure][0] -= $structsDestroyed; |
39 | 38 | $MIPDamage -= $structsDestroyed*$damageDone; |
40 | - } |
|
41 | - else |
|
39 | + } else |
|
42 | 40 | { |
43 | 41 | // REALLY random attack |
44 | 42 | $can_be_damaged = sn_get_groups('defense_active'); |