@@ -187,6 +187,9 @@ |
||
187 | 187 | return $error_backtrace; |
188 | 188 | } |
189 | 189 | |
190 | + /** |
|
191 | + * @param string $die_message |
|
192 | + */ |
|
190 | 193 | public function error_fatal($die_message, $details = 'There is a fatal error on page') { |
191 | 194 | // TODO - Записывать детали ошибки в лог-файл |
192 | 195 | die($die_message); |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | |
33 | 33 | defined('INSIDE') || die(); |
34 | 34 | |
35 | -if(php_sapi_name() == "cli") { |
|
35 | +if (php_sapi_name() == "cli") { |
|
36 | 36 | // In cli-mode |
37 | 37 | define('__DEBUG_CRLF', "\r\n"); |
38 | - define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF); |
|
38 | + define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF); |
|
39 | 39 | } else { |
40 | 40 | // Not in cli-mode |
41 | 41 | define('__DEBUG_CRLF', '<br />'); |
@@ -52,17 +52,17 @@ discard block |
||
52 | 52 | public function log_file($message, $ident_change = 0) { |
53 | 53 | static $ident = 0; |
54 | 54 | |
55 | - if(!defined('SN_DEBUG_LOG')) { |
|
55 | + if (!defined('SN_DEBUG_LOG')) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | - if($this->log_file_handler === null) { |
|
60 | - $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
|
59 | + if ($this->log_file_handler === null) { |
|
60 | + $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+'); |
|
61 | 61 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
62 | 62 | } |
63 | 63 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
64 | - if($this->log_file_handler) { |
|
65 | - @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
|
64 | + if ($this->log_file_handler) { |
|
65 | + @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n"); |
|
66 | 66 | } |
67 | 67 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
68 | 68 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | public function echo_log() { |
85 | - echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
85 | + echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
86 | 86 | die(); |
87 | 87 | } |
88 | 88 | |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | $result = array(); |
93 | 93 | $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId(); |
94 | 94 | $result[] = "tID {$transaction_id}"; |
95 | - foreach($backtrace as $a_trace) { |
|
96 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
95 | + foreach ($backtrace as $a_trace) { |
|
96 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | $function = |
100 | 100 | ($a_trace['type'] |
101 | 101 | ? ($a_trace['type'] == '->' |
102 | - ? "({$a_trace['class']})" . get_class($a_trace['object']) |
|
102 | + ? "({$a_trace['class']})".get_class($a_trace['object']) |
|
103 | 103 | : $a_trace['class'] |
104 | - ) . $a_trace['type'] |
|
104 | + ).$a_trace['type'] |
|
105 | 105 | : '' |
106 | - ) . $a_trace['function'] . '()'; |
|
106 | + ).$a_trace['function'].'()'; |
|
107 | 107 | |
108 | 108 | $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file'])); |
109 | 109 | |
110 | 110 | // $result[] = "{$function} ({$a_trace['line']})'{$file}'"; |
111 | 111 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
112 | 112 | |
113 | - if(!$long_comment) { |
|
113 | + if (!$long_comment) { |
|
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
@@ -124,26 +124,26 @@ discard block |
||
124 | 124 | public function dump($dump = false, $force_base = false, $deadlock = false) { |
125 | 125 | global $user, $planetrow; |
126 | 126 | |
127 | - if($dump === false) { |
|
127 | + if ($dump === false) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $error_backtrace = array(); |
132 | 132 | $base_dump = false; |
133 | 133 | |
134 | - if($force_base === true) { |
|
134 | + if ($force_base === true) { |
|
135 | 135 | $base_dump = true; |
136 | 136 | } |
137 | 137 | |
138 | - if($dump === true) { |
|
138 | + if ($dump === true) { |
|
139 | 139 | $base_dump = true; |
140 | 140 | } else { |
141 | - if(!is_array($dump)) { |
|
141 | + if (!is_array($dump)) { |
|
142 | 142 | $dump = array('var' => $dump); |
143 | 143 | } |
144 | 144 | |
145 | - foreach($dump as $dump_var_name => $dump_var) { |
|
146 | - if($dump_var_name == 'base_dump') { |
|
145 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
146 | + if ($dump_var_name == 'base_dump') { |
|
147 | 147 | $base_dump = $dump_var; |
148 | 148 | } else { |
149 | 149 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -151,22 +151,21 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
154 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
155 | 155 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
156 | 156 | $error_backtrace['locks'] = classSupernova::$gc->snCache->getLocks(); |
157 | 157 | $error_backtrace['cSN_data'] = classSupernova::$gc->snCache->getData(); |
158 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
159 | - foreach($location as $location_id => &$location_data) { |
|
160 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
161 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
158 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
159 | + foreach ($location as $location_id => &$location_data) { |
|
160 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
162 | 161 | } |
163 | 162 | } |
164 | 163 | $error_backtrace['cSN_queries'] = classSupernova::$gc->snCache->getQueries(); |
165 | 164 | } |
166 | 165 | |
167 | - if($base_dump) { |
|
168 | - if(is_array($this->log_array) && count($this->log_array) > 0) { |
|
169 | - foreach($this->log_array as $log) { |
|
166 | + if ($base_dump) { |
|
167 | + if (is_array($this->log_array) && count($this->log_array) > 0) { |
|
168 | + foreach ($this->log_array as $log) { |
|
170 | 169 | $error_backtrace['queries'][] = $log; |
171 | 170 | } |
172 | 171 | } |
@@ -195,14 +194,14 @@ discard block |
||
195 | 194 | public function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
196 | 195 | global $sys_stop_log_hit, $sys_log_disabled, $user; |
197 | 196 | |
198 | - if(empty(classSupernova::$db->connected)) { |
|
197 | + if (empty(classSupernova::$db->connected)) { |
|
199 | 198 | // TODO - писать ошибку в файл |
200 | 199 | die('SQL server currently unavailable. Please contact Administration...'); |
201 | 200 | } |
202 | 201 | |
203 | 202 | sn_db_transaction_rollback(); |
204 | 203 | |
205 | - if(classSupernova::$config->debug == 1) { |
|
204 | + if (classSupernova::$config->debug == 1) { |
|
206 | 205 | echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; |
207 | 206 | echo "<table>{$this->log}</table>"; |
208 | 207 | } |
@@ -214,16 +213,16 @@ discard block |
||
214 | 213 | |
215 | 214 | $userId = empty($user['id']) ? 0 : $user['id']; |
216 | 215 | |
217 | - if(!$sys_log_disabled) { |
|
216 | + if (!$sys_log_disabled) { |
|
218 | 217 | $query = "INSERT INTO `{{logs}}` SET |
219 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
220 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
221 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
218 | + `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."', |
|
219 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
220 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
222 | 221 | // ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";"; |
223 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
224 | - classSupernova::$db->doSql($query, true) or die($fatal_error . classSupernova::$db->db_error()); |
|
222 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
223 | + classSupernova::$db->doSql($query, true) or die($fatal_error.classSupernova::$db->db_error()); |
|
225 | 224 | |
226 | - $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . classSupernova::$db->db_insert_id() . "</b>"; |
|
225 | + $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".classSupernova::$db->db_insert_id()."</b>"; |
|
227 | 226 | |
228 | 227 | $sys_stop_log_hit = true; |
229 | 228 | $sys_log_disabled = true; |
@@ -233,7 +232,7 @@ discard block |
||
233 | 232 | ob_start(); |
234 | 233 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
235 | 234 | |
236 | - foreach($error_backtrace as $name => $value) { |
|
235 | + foreach ($error_backtrace as $name => $value) { |
|
237 | 236 | print(__DEBUG_LINE); |
238 | 237 | pdump($value, $name); |
239 | 238 | } |
@@ -245,7 +244,7 @@ discard block |
||
245 | 244 | public function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
246 | 245 | global $user, $sys_log_disabled; |
247 | 246 | |
248 | - if(empty(classSupernova::$db->connected)) { |
|
247 | + if (empty(classSupernova::$db->connected)) { |
|
249 | 248 | // TODO - писать ошибку в файл |
250 | 249 | die('SQL server currently unavailable. Please contact Administration...'); |
251 | 250 | } |
@@ -254,12 +253,12 @@ discard block |
||
254 | 253 | |
255 | 254 | $userId = empty($user['id']) ? 0 : $user['id']; |
256 | 255 | |
257 | - if(!$sys_log_disabled) { |
|
256 | + if (!$sys_log_disabled) { |
|
258 | 257 | $query = "INSERT INTO `{{logs}}` SET |
259 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
260 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
261 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
262 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
258 | + `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."', |
|
259 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
260 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
261 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
263 | 262 | classSupernova::$db->doSql($query, true); |
264 | 263 | } else { |
265 | 264 | // // TODO Здесь надо писать в файло |
@@ -272,11 +271,11 @@ discard block |
||
272 | 271 | // Dump variables nicer then var_dump() |
273 | 272 | |
274 | 273 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
275 | - if(isset($varname)) { |
|
274 | + if (isset($varname)) { |
|
276 | 275 | $varname .= " = "; |
277 | 276 | } |
278 | 277 | |
279 | - if($level == -1) { |
|
278 | + if ($level == -1) { |
|
280 | 279 | $trans[' '] = '∴'; |
281 | 280 | $trans["\t"] = '⇒'; |
282 | 281 | $trans["\n"] = '¶;'; |
@@ -285,31 +284,31 @@ discard block |
||
285 | 284 | |
286 | 285 | return strtr(htmlspecialchars($value), $trans); |
287 | 286 | } |
288 | - if($level == 0) { |
|
287 | + if ($level == 0) { |
|
289 | 288 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
290 | - $dumper = mt_rand(10, 99) . '|' . $varname; |
|
289 | + $dumper = mt_rand(10, 99).'|'.$varname; |
|
291 | 290 | } |
292 | 291 | |
293 | 292 | $type = gettype($value); |
294 | 293 | $dumper .= $type; |
295 | 294 | |
296 | - if($type == TYPE_STRING) { |
|
297 | - $dumper .= '(' . strlen($value) . ')'; |
|
295 | + if ($type == TYPE_STRING) { |
|
296 | + $dumper .= '('.strlen($value).')'; |
|
298 | 297 | $value = dump($value, '', -1); |
299 | - } elseif($type == TYPE_BOOLEAN) { |
|
298 | + } elseif ($type == TYPE_BOOLEAN) { |
|
300 | 299 | $value = ($value ? 'true' : 'false'); |
301 | - } elseif($type == 'object') { |
|
300 | + } elseif ($type == 'object') { |
|
302 | 301 | $props = get_class_vars(get_class($value)); |
303 | - $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
|
304 | - foreach($props as $key => $val) { |
|
305 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
|
302 | + $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
|
303 | + foreach ($props as $key => $val) { |
|
304 | + $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => '; |
|
306 | 305 | $dumper .= dump($value->$key, '', $level + 1); |
307 | 306 | } |
308 | 307 | $value = ''; |
309 | - } elseif($type == TYPE_ARRAY) { |
|
310 | - $dumper .= '(' . count($value) . ')'; |
|
311 | - foreach($value as $key => $val) { |
|
312 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
|
308 | + } elseif ($type == TYPE_ARRAY) { |
|
309 | + $dumper .= '('.count($value).')'; |
|
310 | + foreach ($value as $key => $val) { |
|
311 | + $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => '; |
|
313 | 312 | $dumper .= dump($val, '', $level + 1); |
314 | 313 | } |
315 | 314 | $value = ''; |
@@ -328,24 +327,24 @@ discard block |
||
328 | 327 | // $backtrace = $backtrace[1]; |
329 | 328 | |
330 | 329 | $caller = ''; |
331 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
332 | - $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
|
333 | - (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
|
334 | - $backtrace[1]['function'] . |
|
330 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
331 | + $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : ''). |
|
332 | + (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : ''). |
|
333 | + $backtrace[1]['function']. |
|
335 | 334 | (!empty($backtrace[0]['file']) |
336 | 335 | ? ( |
337 | - ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) . |
|
338 | - (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') . |
|
336 | + ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN). |
|
337 | + (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : ''). |
|
339 | 338 | ')' |
340 | 339 | ) |
341 | 340 | : '' |
342 | 341 | ); |
343 | - $caller = "\r\n" . $caller; |
|
342 | + $caller = "\r\n".$caller; |
|
344 | 343 | } |
345 | 344 | |
346 | - print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' . |
|
347 | - dump($value, $varname) . |
|
348 | - $caller . |
|
345 | + print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'. |
|
346 | + dump($value, $varname). |
|
347 | + $caller. |
|
349 | 348 | '</pre>' |
350 | 349 | ); |
351 | 350 | } |
@@ -355,24 +354,24 @@ discard block |
||
355 | 354 | } |
356 | 355 | |
357 | 356 | function pr($prePrint = false) { |
358 | - if($prePrint) { |
|
357 | + if ($prePrint) { |
|
359 | 358 | print(__DEBUG_CRLF); |
360 | 359 | } |
361 | - print(mt_rand() . __DEBUG_CRLF); |
|
360 | + print(mt_rand().__DEBUG_CRLF); |
|
362 | 361 | } |
363 | 362 | |
364 | 363 | function pc($prePrint = false) { |
365 | 364 | global $_PRINT_COUNT_VALUE; |
366 | 365 | $_PRINT_COUNT_VALUE++; |
367 | 366 | |
368 | - if($prePrint) { |
|
367 | + if ($prePrint) { |
|
369 | 368 | print(__DEBUG_CRLF); |
370 | 369 | } |
371 | - print($_PRINT_COUNT_VALUE . __DEBUG_CRLF); |
|
370 | + print($_PRINT_COUNT_VALUE.__DEBUG_CRLF); |
|
372 | 371 | } |
373 | 372 | |
374 | 373 | function prep($message) { |
375 | - print('<pre>' . $message . '</pre>'); |
|
374 | + print('<pre>'.$message.'</pre>'); |
|
376 | 375 | } |
377 | 376 | |
378 | 377 | function backtrace_no_arg() { |
@@ -396,9 +395,9 @@ discard block |
||
396 | 395 | */ |
397 | 396 | function pdie($message = '', $level = 0) { |
398 | 397 | $backtrace = debug_backtrace(); |
399 | - for($i = 0; $i < $level; $i++) { |
|
398 | + for ($i = 0; $i < $level; $i++) { |
|
400 | 399 | array_pop($backtrace); |
401 | 400 | } |
402 | 401 | |
403 | - die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']); |
|
402 | + die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']); |
|
404 | 403 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $template->assign_vars($quest_templatized); |
180 | 180 | if (!empty($quest_templatized['quest_rewards_list'])) { |
181 | 181 | foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) { |
182 | - $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward); |
|
182 | + $template->assign_block_vars(($block_name ? $block_name.'.' : '').'quest_rewards_list', $quest_reward); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | |
249 | 249 | $comment_reward = array(); |
250 | 250 | foreach ($reward_list as $unit_id => $unit_amount) { |
251 | - $comment_reward[] = $unit_amount . ' ' . classLocale::$lang['tech'][$unit_id]; |
|
251 | + $comment_reward[] = $unit_amount.' '.classLocale::$lang['tech'][$unit_id]; |
|
252 | 252 | $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount; |
253 | 253 | } |
254 | - $comment .= " {$classLocale['qst_msg_your_reward']} " . implode(',', $comment_reward); |
|
254 | + $comment .= " {$classLocale['qst_msg_your_reward']} ".implode(',', $comment_reward); |
|
255 | 255 | |
256 | 256 | DBStaticMessages::msg_send_simple_message($user['id'], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, classLocale::$lang['msg_from_admin'], classLocale::$lang['qst_msg_complete_subject'], $comment); |
257 | 257 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | if (!empty($resourcesChange)) { |
291 | 291 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
292 | - if($planet_id) { |
|
292 | + if ($planet_id) { |
|
293 | 293 | // update planet |
294 | 294 | DBStaticPlanet::db_planet_update_resources($resourcesChange, $planet_id); |
295 | 295 | } else { |
@@ -314,6 +314,9 @@ discard block |
||
314 | 314 | return $result; |
315 | 315 | } |
316 | 316 | |
317 | + /** |
|
318 | + * @param integer $location_type |
|
319 | + */ |
|
317 | 320 | public static function db_ins_field_set($location_type, $field_set, $serialize = false) { |
318 | 321 | // TODO multiinsert |
319 | 322 | !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set, $serialize) : false; |
@@ -350,7 +353,7 @@ discard block |
||
350 | 353 | /** |
351 | 354 | * Блокирует указанные таблицу/список таблиц |
352 | 355 | * |
353 | - * @param string|array $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов |
|
356 | + * @param string $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов |
|
354 | 357 | * <p>string - название таблицы для блокировки</p> |
355 | 358 | * <p>array - массив, где ключ - имя таблицы, а значение - условия блокировки элементов</p> |
356 | 359 | */ |
@@ -298,9 +298,11 @@ |
||
298 | 298 | $set = trim($set); |
299 | 299 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
300 | 300 | if ($result = $this->db->doInsert("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
301 | - if ($this->db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
301 | + if ($this->db->db_affected_rows()) { |
|
302 | + // Обновляем данные только если ряд был затронут |
|
302 | 303 | { |
303 | 304 | $record_id = $this->db->db_insert_id(); |
305 | + } |
|
304 | 306 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
305 | 307 | $result = $this->db_get_record_by_id($location_type, $record_id); |
306 | 308 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -230,7 +230,7 @@ |
||
230 | 230 | array("distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id"), |
231 | 231 | $filter, |
232 | 232 | // Always selecting all records for correctly perform FILTER locks |
233 | - $fetch ? DB_RECORD_ONE : DB_RECORDS_ALL, |
|
233 | + $fetch ? DB_RECORD_ONE : DB_RECORDS_ALL, |
|
234 | 234 | // DB_RECORDS_ALL, |
235 | 235 | DB_SELECT_PLAIN |
236 | 236 | ); |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | */ |
194 | 194 | // TODO - Change $filter to only array class |
195 | 195 | public function db_get_record_list($location_type, $filter = '', $fetch = false, $no_return = false) { |
196 | - if(is_array($filter)) { |
|
196 | + if (is_array($filter)) { |
|
197 | 197 | // TODO - TEMPORARY |
198 | 198 | $filterString = array(); |
199 | - if(!empty($filter)) { |
|
199 | + if (!empty($filter)) { |
|
200 | 200 | foreach ($filter as $key => $value) { |
201 | - if(!is_int($key)) { |
|
202 | - $value = "`$key` = '" . $this->db->db_escape($value). "'"; |
|
201 | + if (!is_int($key)) { |
|
202 | + $value = "`$key` = '".$this->db->db_escape($value)."'"; |
|
203 | 203 | } |
204 | 204 | $filterString[$key] = $value; |
205 | 205 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | $filterString = implode(',', $filterString); |
209 | 209 | } else { |
210 | - $filterString = $filter; |
|
210 | + $filterString = $filter; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | $query = $this->db->doSelect( |
239 | 239 | "SELECT |
240 | 240 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
241 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
242 | - ($filter ? ' WHERE ' . $filter : '') . |
|
241 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
242 | + ($filter ? ' WHERE '.$filter : ''). |
|
243 | 243 | ($fetch ? ' LIMIT 1' : '')); |
244 | 244 | } |
245 | 245 | while ($row = db_fetch($query)) { |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $indexes_str = implode(',', $parent_id_list); |
255 | 255 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
256 | 256 | $this->db_get_record_list($owner_location_type, |
257 | - $parent_id_field . ( |
|
257 | + $parent_id_field.( |
|
258 | 258 | count($parent_id_list) > 1 |
259 | 259 | ? " IN ({$indexes_str})" |
260 | 260 | : " = {$indexes_str}" |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ); |
278 | 278 | } else { |
279 | 279 | $query = $this->db->doSelect( |
280 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
280 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
281 | 281 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
282 | 282 | . " FOR UPDATE" |
283 | 283 | ); |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | public function db_lock_tables($tables) { |
456 | 456 | $tables = is_array($tables) ? $tables : array($tables => ''); |
457 | 457 | foreach ($tables as $table_name => $condition) { |
458 | - $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
458 | + $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | define('INSTALL', false); |
13 | 13 | define('IN_ADMIN', true); |
14 | 14 | |
15 | -require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
15 | +require('../common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
16 | 16 | |
17 | -if($user['authlevel'] < 3) { |
|
17 | +if ($user['authlevel'] < 3) { |
|
18 | 18 | AdminMessage(classLocale::$lang['adm_err_denied']); |
19 | 19 | } |
20 | 20 | |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | ), |
29 | 29 | ); |
30 | 30 | $template->assign_block_vars('int_type_selected', $allowed_types[-1]); |
31 | -foreach(DBStaticMessages::$snMessageClassList as $key => $value) { |
|
32 | - if($key == MSG_TYPE_NEW || $key == MSG_TYPE_OUTBOX) { |
|
31 | +foreach (DBStaticMessages::$snMessageClassList as $key => $value) { |
|
32 | + if ($key == MSG_TYPE_NEW || $key == MSG_TYPE_OUTBOX) { |
|
33 | 33 | continue; |
34 | 34 | } |
35 | 35 | |
@@ -41,21 +41,21 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | $deletedMessages = ''; |
44 | -if($idMessageDelete = sys_get_param_id('msg_del')) { |
|
44 | +if ($idMessageDelete = sys_get_param_id('msg_del')) { |
|
45 | 45 | DBStaticMessages::db_message_delete_by_id($idMessageDelete); |
46 | 46 | $deletedMessages = $idMessageDelete; |
47 | -} elseif(sys_get_param('str_delete_selected') && is_array($message_delete = sys_get_param('selected')) && !empty($message_delete)) { |
|
47 | +} elseif (sys_get_param('str_delete_selected') && is_array($message_delete = sys_get_param('selected')) && !empty($message_delete)) { |
|
48 | 48 | $message_delete = implode(', ', $message_delete); |
49 | 49 | DBStaticMessages::db_message_list_delete_set($message_delete); |
50 | 50 | $deletedMessages = $message_delete; |
51 | 51 | } |
52 | 52 | |
53 | -if($deletedMessages) { |
|
53 | +if ($deletedMessages) { |
|
54 | 54 | $template->assign_block_vars('result', array('MESSAGE' => sprintf(classLocale::$lang['mlst_messages_deleted'], $deletedMessages))); |
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | -if(sys_get_param('str_delete_date') && checkdate($month = sys_get_param_id('delete_month'), $day = sys_get_param_id('delete_day'), $year = sys_get_param_id('delete_year'))) { |
|
58 | +if (sys_get_param('str_delete_date') && checkdate($month = sys_get_param_id('delete_month'), $day = sys_get_param_id('delete_day'), $year = sys_get_param_id('delete_year'))) { |
|
59 | 59 | $delete_date = "{$year}-{$month}-{$day}"; |
60 | 60 | DBStaticMessages::db_message_list_delete_by_date($delete_date, $int_type_selected); |
61 | 61 | $template->assign_block_vars('result', array('MESSAGE' => sprintf(classLocale::$lang['mlst_messages_deleted_date'], $allowed_types[$int_type_selected]['TEXT'], $delete_date))); |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | |
68 | 68 | $int_page_current = min(sys_get_param_id('int_page_current', 1), $page_max); |
69 | 69 | |
70 | -if(sys_get_param('page_prev') && $int_page_current > 1) { |
|
70 | +if (sys_get_param('page_prev') && $int_page_current > 1) { |
|
71 | 71 | $int_page_current--; |
72 | -} elseif(sys_get_param('page_next') && $int_page_current < $page_max) { |
|
72 | +} elseif (sys_get_param('page_next') && $int_page_current < $page_max) { |
|
73 | 73 | $int_page_current++; |
74 | 74 | } |
75 | 75 | |
76 | -for($i = 1; $i <= $page_max; $i++) { |
|
76 | +for ($i = 1; $i <= $page_max; $i++) { |
|
77 | 77 | $template->assign_block_vars('page', array('NUMBER' => $i)); |
78 | 78 | } |
79 | 79 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $StartRec = ($int_page_current - 1) * 25; |
82 | 82 | |
83 | 83 | $Messages = DBStaticMessages::db_message_list_admin_by_type($int_type_selected, $StartRec); |
84 | -while($row = db_fetch($Messages)) { |
|
84 | +while ($row = db_fetch($Messages)) { |
|
85 | 85 | $row['FROM'] = htmlentities($row['FROM'], ENT_COMPAT, 'UTF-8'); |
86 | 86 | $row['OWNER_NAME'] = htmlentities($row['OWNER_NAME'], ENT_COMPAT, 'UTF-8'); |
87 | 87 | $row['TEXT'] = nl2br($row['TEXT']); |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * Преобразовывает данные симулятора в данные для расчета боя |
460 | 460 | * |
461 | 461 | * @param $side_info |
462 | - * @param $attacker |
|
462 | + * @param boolean $attacker |
|
463 | 463 | * @param int $player_id |
464 | 464 | * |
465 | 465 | */ |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
524 | - * @return int |
|
524 | + * @return double |
|
525 | 525 | */ |
526 | 526 | public function get_time_spent() { |
527 | 527 | return $this->time_spent; |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
567 | - * @param $template |
|
567 | + * @param null|template $template |
|
568 | 568 | * |
569 | 569 | * @return template |
570 | 570 | */ |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $this->players->db_load_player_by_id($player_id, UBE_PLAYER_IS_DEFENDER); |
148 | 148 | |
149 | 149 | $player_db_row = $this->players[$player_id]->getDbRow(); |
150 | - if($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) { |
|
150 | + if ($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) { |
|
151 | 151 | $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $fortifier_level); |
152 | 152 | } |
153 | 153 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $this->rounds[0] = new UBERound(0); |
179 | 179 | $this->rounds[0]->make_snapshot($this->fleet_list); |
180 | 180 | |
181 | - for($round = 1; $round <= 10; $round++) { |
|
181 | + for ($round = 1; $round <= 10; $round++) { |
|
182 | 182 | // Проводим раунд |
183 | 183 | defined('DEBUG_UBE') ? print("Round {$round}<br>") : false; |
184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // Анализируем итоги текущего раунда и готовим данные для следующего |
193 | 193 | $this->combat_result = $this->fleet_list->ubeAnalyzeFleetOutcome($round); |
194 | - if($this->combat_result != UBE_COMBAT_RESULT_DRAW) { |
|
194 | + if ($this->combat_result != UBE_COMBAT_RESULT_DRAW) { |
|
195 | 195 | break; |
196 | 196 | } |
197 | 197 | |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | // Генерируем результат боя |
221 | 221 | $this->fleet_list->ube_analyze_fleets($this->is_simulator, $this->debris, $this->resource_exchange_rates); |
222 | 222 | |
223 | - if(!$this->is_ube_loaded) { |
|
223 | + if (!$this->is_ube_loaded) { |
|
224 | 224 | $this->moon_calculator->calculate_moon($this); |
225 | 225 | |
226 | 226 | // Лутаем ресурсы - если аттакер выиграл |
227 | - if($this->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
227 | + if ($this->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
228 | 228 | $this->sn_ube_combat_analyze_loot(); |
229 | 229 | } |
230 | 230 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | RES_DEUTERIUM => 0, |
245 | 245 | ); |
246 | 246 | |
247 | - if( |
|
247 | + if ( |
|
248 | 248 | (($planet_resource_total = $this->fleet_list[0]->get_resources_amount()) > 0) |
249 | 249 | && |
250 | 250 | (($total_capacity = $this->fleet_list->ube_get_capacity_attackers()) > 0) |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | $planet_lootable_percent = $planet_lootable / $planet_resource_total; |
257 | 257 | |
258 | 258 | // Вычисляем сколько ресурсов вывезено |
259 | - foreach($this->fleet_list->_container as $fleet_id => $fleet) { |
|
259 | + foreach ($this->fleet_list->_container as $fleet_id => $fleet) { |
|
260 | 260 | $looted_in_metal = 0; |
261 | - foreach($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) { |
|
261 | + foreach ($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) { |
|
262 | 262 | // Вычисляем какой процент общей емкости трюмов атакующих будет задействован |
263 | 263 | $fleet_lootable_percent = $fleet->fleet_capacity / $total_capacity; |
264 | 264 | $looted = floor($resource_amount * $planet_lootable_percent * $fleet_lootable_percent); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $destination_user_id = $this->fleet_list[0]->owner_id; |
324 | 324 | |
325 | 325 | // Обновляем поле обломков на планете |
326 | - if(!$this->is_admin_in_combat && $this->debris->debris_total() > 0) { |
|
326 | + if (!$this->is_admin_in_combat && $this->debris->debris_total() > 0) { |
|
327 | 327 | DBStaticPlanet::db_planet_update_by_gspt( |
328 | 328 | $this->ube_planet_info[PLANET_GALAXY], $this->ube_planet_info[PLANET_SYSTEM], $this->ube_planet_info[PLANET_PLANET], PT_PLANET, |
329 | 329 | array(), |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | ); |
335 | 335 | } |
336 | 336 | |
337 | - foreach($this->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
337 | + foreach ($this->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
338 | 338 | $ship_count_lost = $UBEFleet->unit_list->unitCountLost(); |
339 | 339 | |
340 | - if($fleet_id) { |
|
340 | + if ($fleet_id) { |
|
341 | 341 | // Флот |
342 | 342 | $UBEFleet->db_save_combat_result_fleet($this->is_small_fleet_recce, $this->moon_calculator->get_reapers_status()); |
343 | 343 | } else { |
@@ -345,18 +345,18 @@ discard block |
||
345 | 345 | |
346 | 346 | // Сохраняем изменения ресурсов - если они есть |
347 | 347 | $resource_delta = $UBEFleet->ube_combat_result_calculate_resources(); |
348 | - if(!empty($resource_delta)) { |
|
348 | + if (!empty($resource_delta)) { |
|
349 | 349 | $temp = array(); |
350 | - foreach($resource_delta as $resource_id => $resource_amount) { |
|
350 | + foreach ($resource_delta as $resource_id => $resource_amount) { |
|
351 | 351 | $resource_db_name = pname_resource_name($resource_id); |
352 | 352 | $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})"; |
353 | 353 | } |
354 | 354 | DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($this->ube_planet_info[PLANET_ID], implode(',', $temp)); |
355 | 355 | } |
356 | 356 | |
357 | - if($ship_count_lost) { |
|
357 | + if ($ship_count_lost) { |
|
358 | 358 | $planet_row_cache = $this->players[$destination_user_id]->getDbRow(); |
359 | - foreach($UBEFleet->unit_list->_container as $UBEUnit) { |
|
359 | + foreach ($UBEFleet->unit_list->_container as $UBEUnit) { |
|
360 | 360 | DBStaticUnit::dbUpdateOrInsertUnit($UBEUnit->unitId, -$UBEUnit->units_lost, $planet_row_cache, $this->ube_planet_info[PLANET_ID]); |
361 | 361 | } |
362 | 362 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL |
367 | 367 | // Для САБов |
368 | 368 | $fleet_group_id_list = $this->fleet_list->ube_get_groups(); |
369 | - if(!empty($fleet_group_id_list)) { |
|
369 | + if (!empty($fleet_group_id_list)) { |
|
370 | 370 | $fleet_group_id_list = implode(',', $fleet_group_id_list); |
371 | 371 | DBStaticFleetACS::db_acs_delete_by_list($fleet_group_id_list); |
372 | 372 | } |
@@ -375,19 +375,19 @@ discard block |
||
375 | 375 | |
376 | 376 | $bashing_list = array(); |
377 | 377 | $players_sides = $this->players->get_player_sides(); |
378 | - foreach($players_sides as $player_id => $player_side) { |
|
379 | - if($player_side != UBE_PLAYER_IS_ATTACKER) { |
|
378 | + foreach ($players_sides as $player_id => $player_side) { |
|
379 | + if ($player_side != UBE_PLAYER_IS_ATTACKER) { |
|
380 | 380 | continue; |
381 | 381 | } |
382 | - if($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) { |
|
382 | + if ($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) { |
|
383 | 383 | $bashing_list[] = "({$player_id}, {$this->ube_planet_info[PLANET_ID]}, {$this->combat_timestamp})"; |
384 | 384 | } |
385 | - if($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) { |
|
385 | + if ($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) { |
|
386 | 386 | $str_loose_or_win = $this->combat_result == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose'; |
387 | 387 | DBStaticUser::db_user_set_by_id_DEPRECATED($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1"); |
388 | 388 | } |
389 | 389 | } |
390 | - if(!empty($bashing_list)) { |
|
390 | + if (!empty($bashing_list)) { |
|
391 | 391 | DBStaticFleetBashing::db_bashing_insert($bashing_list); |
392 | 392 | } |
393 | 393 | |
@@ -413,20 +413,19 @@ discard block |
||
413 | 413 | $planet_info[PLANET_SYSTEM], |
414 | 414 | $planet_info[PLANET_PLANET], |
415 | 415 | htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'), |
416 | - classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : |
|
417 | - ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
416 | + classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
418 | 417 | ); |
419 | 418 | |
420 | 419 | $text_defender = ''; |
421 | 420 | $debris = $this->debris->get_debris(); |
422 | - foreach($debris as $resource_id => $resource_amount) { |
|
423 | - if($resource_id == RES_DEUTERIUM) { |
|
421 | + foreach ($debris as $resource_id => $resource_amount) { |
|
422 | + if ($resource_id == RES_DEUTERIUM) { |
|
424 | 423 | continue; |
425 | 424 | } |
426 | 425 | |
427 | - $text_defender .= "{$classLocale['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />'; |
|
426 | + $text_defender .= "{$classLocale['tech'][$resource_id]}: ".pretty_number($resource_amount).'<br />'; |
|
428 | 427 | } |
429 | - if($text_defender) { |
|
428 | + if ($text_defender) { |
|
430 | 429 | $text_defender = "{$classLocale['ube_report_msg_body_debris']}{$text_defender}<br />"; |
431 | 430 | } |
432 | 431 | |
@@ -436,8 +435,8 @@ discard block |
||
436 | 435 | |
437 | 436 | // TODO: Оптимизировать отсылку сообщений - отсылать пакетами |
438 | 437 | $player_sides = $this->players->get_player_sides(); |
439 | - foreach($player_sides as $player_id => $player_side) { |
|
440 | - $message = $text_common . ($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender); |
|
438 | + foreach ($player_sides as $player_id => $player_side) { |
|
439 | + $message = $text_common.($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender); |
|
441 | 440 | DBStaticMessages::msg_send_simple_message($player_id, '', $this->combat_timestamp, MSG_TYPE_COMBAT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_attack_report'], $message); |
442 | 441 | } |
443 | 442 | |
@@ -472,11 +471,11 @@ discard block |
||
472 | 471 | $player_id = $player_id == -1 ? $this->players->count() : $player_id; |
473 | 472 | $fleet_id = $player_id; // FOR SIMULATOR! |
474 | 473 | |
475 | - if(empty($this->players[$player_id])) { |
|
474 | + if (empty($this->players[$player_id])) { |
|
476 | 475 | $this->players[$player_id] = new UBEPlayer(); |
477 | 476 | } |
478 | 477 | |
479 | - foreach($side_info as $fleet_data) { |
|
478 | + foreach ($side_info as $fleet_data) { |
|
480 | 479 | $this->players[$player_id]->name = $player_id; |
481 | 480 | $this->players[$player_id]->setSide($attacker); |
482 | 481 | |
@@ -484,32 +483,32 @@ discard block |
||
484 | 483 | $this->fleet_list[$fleet_id] = $objFleet; |
485 | 484 | |
486 | 485 | $this->fleet_list[$fleet_id]->owner_id = $player_id; |
487 | - foreach($fleet_data as $unit_id => $unit_count) { |
|
488 | - if(!$unit_count) { |
|
486 | + foreach ($fleet_data as $unit_id => $unit_count) { |
|
487 | + if (!$unit_count) { |
|
489 | 488 | continue; |
490 | 489 | } |
491 | 490 | |
492 | 491 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
493 | 492 | |
494 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
493 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
495 | 494 | $this->fleet_list[$fleet_id]->unit_list->unitAdjustCount($unit_id, $unit_count); |
496 | - } elseif($unit_type == UNIT_RESOURCES) { |
|
495 | + } elseif ($unit_type == UNIT_RESOURCES) { |
|
497 | 496 | $this->fleet_list[$fleet_id]->resource_list[$unit_id] = $unit_count; |
498 | - } elseif($unit_type == UNIT_TECHNOLOGIES) { |
|
499 | - if($unit_id == TECH_WEAPON) { |
|
497 | + } elseif ($unit_type == UNIT_TECHNOLOGIES) { |
|
498 | + if ($unit_id == TECH_WEAPON) { |
|
500 | 499 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_WEAPON, $unit_count); |
501 | - } elseif($unit_id == TECH_SHIELD) { |
|
500 | + } elseif ($unit_id == TECH_SHIELD) { |
|
502 | 501 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_SHIELD, $unit_count); |
503 | - } elseif($unit_id == TECH_ARMOR) { |
|
502 | + } elseif ($unit_id == TECH_ARMOR) { |
|
504 | 503 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_ARMOR, $unit_count); |
505 | 504 | } |
506 | - } elseif($unit_type == UNIT_GOVERNORS) { |
|
507 | - if($unit_id == MRC_FORTIFIER) { |
|
505 | + } elseif ($unit_type == UNIT_GOVERNORS) { |
|
506 | + if ($unit_id == MRC_FORTIFIER) { |
|
508 | 507 | // Фортифаер даёт бонус ко всему |
509 | 508 | $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $unit_count); |
510 | 509 | } |
511 | - } elseif($unit_type == UNIT_MERCENARIES) { |
|
512 | - if($unit_id == MRC_ADMIRAL) { |
|
510 | + } elseif ($unit_type == UNIT_MERCENARIES) { |
|
511 | + if ($unit_id == MRC_ADMIRAL) { |
|
513 | 512 | $this->players[$player_id]->player_bonus->add_unit_by_snid(MRC_ADMIRAL, $unit_count); |
514 | 513 | } |
515 | 514 | } |
@@ -563,7 +562,7 @@ discard block |
||
563 | 562 | |
564 | 563 | $ube->sn_ube_message_send(); |
565 | 564 | |
566 | - defined('DEBUG_UBE') ? die('DIE at ' . __FILE__ . ' ' . __LINE__) : false; |
|
565 | + defined('DEBUG_UBE') ? die('DIE at '.__FILE__.' '.__LINE__) : false; |
|
567 | 566 | |
568 | 567 | return false; |
569 | 568 | } |
@@ -578,7 +577,7 @@ discard block |
||
578 | 577 | |
579 | 578 | $ube_report = new UBEReport(); |
580 | 579 | $ube = $ube_report->sn_ube_report_load(sys_get_param_str('cypher')); |
581 | - if($ube != UBE_REPORT_NOT_FOUND) { |
|
580 | + if ($ube != UBE_REPORT_NOT_FOUND) { |
|
582 | 581 | $ube_report->sn_ube_report_generate($ube, $template_result); |
583 | 582 | |
584 | 583 | $template = gettemplate('ube_combat_report', $template); |
@@ -606,9 +605,9 @@ discard block |
||
606 | 605 | $ube->sn_ube_combat(); |
607 | 606 | $ube_report = new UBEReport(); |
608 | 607 | |
609 | - if(sys_get_param_str('reload')) { |
|
608 | + if (sys_get_param_str('reload')) { |
|
610 | 609 | $ube_new = $ube_report->sn_ube_report_load($ube->get_cypher()); // $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]); |
611 | - if($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) { |
|
610 | + if ($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) { |
|
612 | 611 | $ube = $ube_new; |
613 | 612 | } |
614 | 613 | } |
@@ -656,7 +655,7 @@ discard block |
||
656 | 655 | $this->debris->load_from_report_row($report_row); |
657 | 656 | |
658 | 657 | $query = classSupernova::$db->doSelect("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
659 | - while($player_row = db_fetch($query)) { |
|
658 | + while ($player_row = db_fetch($query)) { |
|
660 | 659 | $this->players->init_player_from_report_info($player_row); |
661 | 660 | } |
662 | 661 |
@@ -7,7 +7,7 @@ |
||
7 | 7 | /** |
8 | 8 | * @param UBE $ube |
9 | 9 | * |
10 | - * @return bool|string |
|
10 | + * @return false|string |
|
11 | 11 | * |
12 | 12 | * @version 2016-02-25 23:42:45 41a4.68 |
13 | 13 | */ |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function sn_ube_report_save($ube) { |
15 | 15 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
16 | - if($ube->get_cypher()) { |
|
16 | + if ($ube->get_cypher()) { |
|
17 | 17 | return false; |
18 | 18 | } |
19 | 19 | |
20 | 20 | // Генерируем уникальный секретный ключ и проверяем наличие в базе |
21 | 21 | do { |
22 | 22 | $ube->report_cypher = sys_random_string(32); |
23 | - } while(classSupernova::$db->doSelectFetch("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE")); |
|
23 | + } while (classSupernova::$db->doSelectFetch("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE")); |
|
24 | 24 | |
25 | 25 | // Инициализация таблицы для пакетной вставки информации |
26 | 26 | $sql_perform = array( |
@@ -106,21 +106,21 @@ discard block |
||
106 | 106 | |
107 | 107 | // Сохраняем общую информацию о бое |
108 | 108 | classSupernova::$db->doInsertSet(TABLE_UBE_REPORT, array( |
109 | - 'ube_report_cypher' => (string)$ube->report_cypher, |
|
110 | - 'ube_report_time_combat' => (string)date(FMT_DATE_TIME_SQL, $ube->combat_timestamp), |
|
111 | - 'ube_report_time_spent' => (float)$ube->time_spent, |
|
112 | - 'ube_report_combat_admin' => (int)$ube->is_admin_in_combat, |
|
113 | - 'ube_report_mission_type' => (int)$ube->mission_type_id, |
|
114 | - 'ube_report_combat_result' => (int)$ube->combat_result, |
|
115 | - 'ube_report_combat_sfr' => (int)$ube->is_small_fleet_recce, |
|
116 | - 'ube_report_planet_id' => (int)$ube->ube_planet_info[PLANET_ID], |
|
117 | - 'ube_report_planet_name' => (string)$ube->ube_planet_info[PLANET_NAME], |
|
118 | - 'ube_report_planet_size' => (int)$ube->ube_planet_info[PLANET_SIZE], |
|
119 | - 'ube_report_planet_galaxy' => (int)$ube->ube_planet_info[PLANET_GALAXY], |
|
120 | - 'ube_report_planet_system' => (int)$ube->ube_planet_info[PLANET_SYSTEM], |
|
121 | - 'ube_report_planet_planet' => (int)$ube->ube_planet_info[PLANET_PLANET], |
|
122 | - 'ube_report_planet_planet_type' => (int)$ube->ube_planet_info[PLANET_TYPE], |
|
123 | - 'ube_report_capture_result' => (int)$ube->capture_result, |
|
109 | + 'ube_report_cypher' => (string) $ube->report_cypher, |
|
110 | + 'ube_report_time_combat' => (string) date(FMT_DATE_TIME_SQL, $ube->combat_timestamp), |
|
111 | + 'ube_report_time_spent' => (float) $ube->time_spent, |
|
112 | + 'ube_report_combat_admin' => (int) $ube->is_admin_in_combat, |
|
113 | + 'ube_report_mission_type' => (int) $ube->mission_type_id, |
|
114 | + 'ube_report_combat_result' => (int) $ube->combat_result, |
|
115 | + 'ube_report_combat_sfr' => (int) $ube->is_small_fleet_recce, |
|
116 | + 'ube_report_planet_id' => (int) $ube->ube_planet_info[PLANET_ID], |
|
117 | + 'ube_report_planet_name' => (string) $ube->ube_planet_info[PLANET_NAME], |
|
118 | + 'ube_report_planet_size' => (int) $ube->ube_planet_info[PLANET_SIZE], |
|
119 | + 'ube_report_planet_galaxy' => (int) $ube->ube_planet_info[PLANET_GALAXY], |
|
120 | + 'ube_report_planet_system' => (int) $ube->ube_planet_info[PLANET_SYSTEM], |
|
121 | + 'ube_report_planet_planet' => (int) $ube->ube_planet_info[PLANET_PLANET], |
|
122 | + 'ube_report_planet_planet_type' => (int) $ube->ube_planet_info[PLANET_TYPE], |
|
123 | + 'ube_report_capture_result' => (int) $ube->capture_result, |
|
124 | 124 | ) |
125 | 125 | + $ube->debris->report_generate_array() |
126 | 126 | + $ube->moon_calculator->report_generate_array() |
@@ -129,22 +129,22 @@ discard block |
||
129 | 129 | |
130 | 130 | // Сохраняем общую информацию по игрокам |
131 | 131 | $player_sides = $ube->players->get_player_sides(); |
132 | - foreach($player_sides as $player_id => $player_side) { |
|
132 | + foreach ($player_sides as $player_id => $player_side) { |
|
133 | 133 | $sql_perform['ube_report_player'][] = array( |
134 | 134 | $ube_report_id, |
135 | 135 | $player_id, |
136 | 136 | |
137 | - "'" . db_escape($ube->players[$player_id]->name) . "'", |
|
137 | + "'".db_escape($ube->players[$player_id]->name)."'", |
|
138 | 138 | $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0, |
139 | 139 | |
140 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
141 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
142 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
140 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
141 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
142 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Всякая информация по флотам |
147 | - foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
147 | + foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
148 | 148 | // Сохраняем общую информацию по флотам |
149 | 149 | $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id); |
150 | 150 | |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list); |
160 | 160 | |
161 | 161 | // Пакетная вставка данных |
162 | - foreach($sql_perform as $table_name => $table_data) { |
|
163 | - if(count($table_data) < 2) { |
|
162 | + foreach ($sql_perform as $table_name => $table_data) { |
|
163 | + if (count($table_data) < 2) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | - foreach($table_data as &$record_data) { |
|
167 | - $record_data = '(' . implode(',', $record_data) . ')'; |
|
166 | + foreach ($table_data as &$record_data) { |
|
167 | + $record_data = '('.implode(',', $record_data).')'; |
|
168 | 168 | } |
169 | 169 | $fields = $table_data[0]; |
170 | 170 | unset($table_data[0]); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $report_cypher = db_escape($report_cypher); |
187 | 187 | |
188 | 188 | $report_row = classSupernova::$db->doSelectFetch("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1"); |
189 | - if(!$report_row) { |
|
189 | + if (!$report_row) { |
|
190 | 190 | return UBE_REPORT_NOT_FOUND; |
191 | 191 | } |
192 | 192 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param $template_result |
203 | 203 | */ |
204 | 204 | public function sn_ube_report_generate(UBE $ube, &$template_result) { |
205 | - if(!is_object($ube)) { |
|
205 | + if (!is_object($ube)) { |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | |
218 | 218 | // Координаты, тип и название планеты - если есть |
219 | 219 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
220 | - if(isset($ube->ube_planet_info)) { |
|
220 | + if (isset($ube->ube_planet_info)) { |
|
221 | 221 | $template_result += $ube->ube_planet_info; |
222 | 222 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
223 | 223 | } |
224 | 224 | |
225 | 225 | // Обломки |
226 | 226 | $debris = array(); |
227 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
228 | - if($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
227 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
228 | + if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
229 | 229 | $debris[] = array( |
230 | 230 | 'NAME' => classLocale::$lang['tech'][$resource_id], |
231 | 231 | 'AMOUNT' => pretty_number($resource_amount), |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | // Инфа об устройстве и браузере - общая для всех |
88 | 88 | sn_db_transaction_start(); |
89 | 89 | $this->device_cypher = $_COOKIE[SN_COOKIE_D]; |
90 | - if($this->device_cypher) { |
|
90 | + if ($this->device_cypher) { |
|
91 | 91 | $cypher_safe = db_escape($this->device_cypher); |
92 | 92 | $device_id = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE"); |
93 | - if(!empty($device_id['device_id'])) { |
|
93 | + if (!empty($device_id['device_id'])) { |
|
94 | 94 | $this->device_id = $device_id['device_id']; |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - if($this->device_id <= 0) { |
|
98 | + if ($this->device_id <= 0) { |
|
99 | 99 | do { |
100 | 100 | $cypher_safe = db_escape($this->device_cypher = sys_random_string()); |
101 | 101 | $row = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE"); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string'); |
119 | 119 | sn_db_transaction_commit(); |
120 | 120 | |
121 | - if($this->write_full_url) { |
|
121 | + if ($this->write_full_url) { |
|
122 | 122 | sn_db_transaction_start(); |
123 | 123 | $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE)); |
124 | - if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
124 | + if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
125 | 125 | $this->page_url = '/simulator.php'; |
126 | 126 | } |
127 | 127 | $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string'); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function db_security_entry_insert($user_id_unsafe) { |
146 | 146 | // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL'; |
147 | - if(empty($user_id_unsafe)) { |
|
147 | + if (empty($user_id_unsafe)) { |
|
148 | 148 | // self::flog('Нет ИД пользователя'); |
149 | 149 | return true; |
150 | 150 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function db_counter_insert($user_id_unsafe) { |
167 | 167 | global $sys_stop_log_hit; |
168 | 168 | |
169 | - if($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
169 | + if ($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function debris_add_resource($resource_id, $resource_amount) { |
29 | 29 | // В обломках может быть только металл или кристалл |
30 | - if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
30 | + if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | $this->debris[$resource_id] += $resource_amount; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param bool $is_simulator |
39 | 39 | */ |
40 | 40 | public function add_wrecks(array $wreckage, $is_simulator) { |
41 | - foreach($wreckage as $resource_id => $resource_amount) { |
|
41 | + foreach ($wreckage as $resource_id => $resource_amount) { |
|
42 | 42 | $this->debris_add_resource($resource_id, floor($resource_amount * |
43 | 43 | ($is_simulator |
44 | 44 | ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param bool $is_simulator |
55 | 55 | */ |
56 | 56 | public function add_cargo_drop(array $dropped_resources, $is_simulator) { |
57 | - foreach($dropped_resources as $resource_id => $resource_amount) { |
|
57 | + foreach ($dropped_resources as $resource_id => $resource_amount) { |
|
58 | 58 | $this->debris_add_resource($resource_id, floor($resource_amount * |
59 | 59 | ($is_simulator |
60 | 60 | ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param $moon_debris_left_part |
94 | 94 | */ |
95 | 95 | public function debris_adjust_proportional($moon_debris_left_part) { |
96 | - foreach($this->debris as $resource_id => &$resource_amount) { |
|
96 | + foreach ($this->debris as $resource_id => &$resource_amount) { |
|
97 | 97 | $resource_amount = floor($resource_amount * $moon_debris_left_part); |
98 | 98 | } |
99 | 99 | } |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function report_generate_array() { |
116 | 116 | return array( |
117 | - 'ube_report_debris_metal' => (float)$this->debris_get_resource(RES_METAL), |
|
118 | - 'ube_report_debris_crystal' => (float)$this->debris_get_resource(RES_CRYSTAL), |
|
119 | - 'ube_report_debris_total_in_metal' => (float)$this->debris_in_metal(), |
|
117 | + 'ube_report_debris_metal' => (float) $this->debris_get_resource(RES_METAL), |
|
118 | + 'ube_report_debris_crystal' => (float) $this->debris_get_resource(RES_CRYSTAL), |
|
119 | + 'ube_report_debris_total_in_metal' => (float) $this->debris_in_metal(), |
|
120 | 120 | ); |
121 | 121 | } |
122 | 122 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $debris_for_moon = $debris->debris_total(); |
72 | 72 | |
73 | - if(!$debris_for_moon) { |
|
73 | + if (!$debris_for_moon) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure |
79 | 79 | $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0; |
80 | 80 | $this->create_chance = $moon_chance; |
81 | - if($moon_chance) { |
|
82 | - if($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
81 | + if ($moon_chance) { |
|
82 | + if ($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
83 | 83 | $this->status = UBE_MOON_CREATE_SUCCESS; |
84 | 84 | $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999)); |
85 | 85 | |
86 | - if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
86 | + if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
87 | 87 | $debris->_reset(); |
88 | 88 | } else { |
89 | 89 | $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function moon_destroy_try($reapers) { |
104 | 104 | // TODO: $is_simulator |
105 | - if($reapers <= 0) { |
|
105 | + if ($reapers <= 0) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @version 2016-02-25 23:42:45 41a4.68 |
121 | 121 | */ |
122 | 122 | public function calculate_moon(UBE $ube) { |
123 | - if(UBE_MOON_EXISTS == $this->status) { |
|
124 | - if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
123 | + if (UBE_MOON_EXISTS == $this->status) { |
|
124 | + if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
125 | 125 | $reapers = $ube->fleet_list->ube_calculate_attack_reapers(); |
126 | 126 | $this->moon_destroy_try($reapers); |
127 | 127 | } |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function report_generate_array() { |
137 | 137 | return array( |
138 | - 'ube_report_moon' => (int)$this->status, |
|
139 | - 'ube_report_moon_chance' => (int)$this->create_chance, |
|
140 | - 'ube_report_moon_size' => (float)$this->moon_diameter, |
|
141 | - 'ube_report_moon_reapers' => (int)$this->reapers_status, |
|
142 | - 'ube_report_moon_destroy_chance' => (int)$this->destroy_chance, |
|
143 | - 'ube_report_moon_reapers_die_chance' => (int)$this->reaper_die_chance, |
|
138 | + 'ube_report_moon' => (int) $this->status, |
|
139 | + 'ube_report_moon_chance' => (int) $this->create_chance, |
|
140 | + 'ube_report_moon_size' => (float) $this->moon_diameter, |
|
141 | + 'ube_report_moon_reapers' => (int) $this->reapers_status, |
|
142 | + 'ube_report_moon_destroy_chance' => (int) $this->destroy_chance, |
|
143 | + 'ube_report_moon_reapers_die_chance' => (int) $this->reaper_die_chance, |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | * @param $planet_id |
172 | 172 | */ |
173 | 173 | public function db_apply_result($planet_info, $destination_user_id) { |
174 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
174 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
175 | 175 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false); |
176 | 176 | $this->moon_name = $moon_row['name']; |
177 | 177 | unset($moon_row); |
178 | - } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
178 | + } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
179 | 179 | DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]); |
180 | 180 | } |
181 | 181 | } |
@@ -184,18 +184,18 @@ discard block |
||
184 | 184 | $classLocale = classLocale::$lang; |
185 | 185 | |
186 | 186 | $text_defender = ''; |
187 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
187 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
188 | 188 | $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />"; |
189 | - } elseif($this->status == UBE_MOON_CREATE_FAILED) { |
|
189 | + } elseif ($this->status == UBE_MOON_CREATE_FAILED) { |
|
190 | 190 | $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />"; |
191 | 191 | } |
192 | 192 | |
193 | - if($ube->mission_type_id == MT_DESTROY) { |
|
194 | - if($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
193 | + if ($ube->mission_type_id == MT_DESTROY) { |
|
194 | + if ($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
195 | 195 | $text_defender .= classLocale::$lang['ube_report_moon_reapers_none']; |
196 | 196 | } else { |
197 | 197 | $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. "; |
198 | - $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />"; |
|
198 | + $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure']."<br />"; |
|
199 | 199 | |
200 | 200 | $text_defender .= "{$classLocale['ube_report_moon_reapers_outcome']} {$this->reaper_die_chance}%. "; |
201 | 201 | $text_defender .= classLocale::$lang[$this->reapers_status == UBE_MOON_REAPERS_RETURNED ? 'ube_report_moon_reapers_survive' : 'ube_report_moon_reapers_died']; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @version 2016-02-25 23:42:45 41a4.68 |
221 | 221 | */ |
222 | 222 | public function ubeInitLoadStatis($destination_planet) { |
223 | - if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
223 | + if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
224 | 224 | $this->status = UBE_MOON_EXISTS; |
225 | 225 | $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter']; |
226 | 226 | $this->reapers_status = UBE_MOON_REAPERS_NONE; |