@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | 'factor' => 1.5, |
| 17 | 17 | ), |
| 18 | 18 | P_UNIT_PRODUCTION => array( |
| 19 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) { return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 20 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 19 | + RES_METAL => function($level, $production_factor, $user, $planet_row) { return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 20 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 21 | 21 | ), |
| 22 | 22 | P_MINING_IS_MANAGED => true, |
| 23 | 23 | ), |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | 'factor' => 1.6, |
| 35 | 35 | ), |
| 36 | 36 | P_UNIT_PRODUCTION => array( |
| 37 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) { return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 38 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 37 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) { return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 38 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 39 | 39 | ), |
| 40 | 40 | P_MINING_IS_MANAGED => true, |
| 41 | 41 | ), |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | 'factor' => 1.5, |
| 53 | 53 | ), |
| 54 | 54 | P_UNIT_PRODUCTION => array( |
| 55 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) { return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
| 56 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 55 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) { return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
| 56 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 57 | 57 | ), |
| 58 | 58 | P_MINING_IS_MANAGED => true, |
| 59 | 59 | ), |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | 'factor' => 1.5, |
| 71 | 71 | ), |
| 72 | 72 | P_UNIT_PRODUCTION => array( |
| 73 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 73 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 74 | 74 | ), |
| 75 | 75 | P_MINING_IS_MANAGED => true, |
| 76 | 76 | ), |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | 'factor' => 1.8, |
| 89 | 89 | ), |
| 90 | 90 | P_UNIT_PRODUCTION => array( |
| 91 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) { return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 92 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
| 91 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) { return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
| 92 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
| 93 | 93 | ), |
| 94 | 94 | P_MINING_IS_MANAGED => true, |
| 95 | 95 | ), |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | 'factor' => 2, |
| 107 | 107 | ), |
| 108 | 108 | 'storage' => array( |
| 109 | - RES_METAL => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 109 | + RES_METAL => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 110 | 110 | ), |
| 111 | 111 | ), |
| 112 | 112 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | 'factor' => 2, |
| 123 | 123 | ), |
| 124 | 124 | 'storage' => array( |
| 125 | - RES_CRYSTAL => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 125 | + RES_CRYSTAL => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 126 | 126 | ), |
| 127 | 127 | ), |
| 128 | 128 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | 'factor' => 2, |
| 139 | 139 | ), |
| 140 | 140 | 'storage' => array( |
| 141 | - RES_DEUTERIUM => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 141 | + RES_DEUTERIUM => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
| 142 | 142 | ), |
| 143 | 143 | ), |
| 144 | 144 | |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />"); |
| 53 | 53 | if ($hard && !empty(_SnCacheInternal::$data[$location_type])) { |
| 54 | 54 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
| 55 | - array_walk(_SnCacheInternal::$data[$location_type], function (&$item) { $item = null; }); |
|
| 55 | + array_walk(_SnCacheInternal::$data[$location_type], function(&$item) { $item = null; }); |
|
| 56 | 56 | } |
| 57 | 57 | _SnCacheInternal::$locator[$location_type] = []; |
| 58 | 58 | _SnCacheInternal::$queries[$location_type] = []; |
@@ -139,11 +139,13 @@ |
||
| 139 | 139 | $error_backtrace['locks'] = _SnCacheInternal::$locks; |
| 140 | 140 | $error_backtrace['cSN_data'] = _SnCacheInternal::$data; |
| 141 | 141 | foreach($error_backtrace['cSN_data'] as &$location) { |
| 142 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
| 142 | + foreach($location as $location_id => &$location_data) { |
|
| 143 | + // $location_data = $location_id; |
|
| 143 | 144 | { |
| 144 | 145 | $location_data = isset($location_data['username']) ? $location_data['username'] : |
| 145 | 146 | (isset($location_data['name']) ? $location_data['name'] : $location_id); |
| 146 | 147 | } |
| 148 | + } |
|
| 147 | 149 | } |
| 148 | 150 | } |
| 149 | 151 | |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | |
| 81 | 81 | $result = array(); |
| 82 | 82 | $transaction_id = SN::db_transaction_check(false) ? SN::$transaction_id : SN::$transaction_id++; |
| 83 | - $result[] = "tID {$transaction_id}"; |
|
| 83 | + $result[] = "tid {$transaction_id}"; |
|
| 84 | 84 | foreach($backtrace as $a_trace) { |
| 85 | 85 | if(in_array($a_trace['function'], $exclude_functions)) { |
| 86 | 86 | continue; |
@@ -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>"); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | "SELECT `id` AS `ID`, `username` AS `NAME`, `ally_name` AS `ALLY`, `total_points` AS `STAT_POINTS`, |
| 181 | 181 | `onlinetime` AS `ACTIVITY` |
| 182 | 182 | FROM `{{users}}` |
| 183 | - WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) ." ORDER BY user_as_ally, `". $TypeSort ."` ASC;"); |
|
| 183 | + WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) . " ORDER BY user_as_ally, `" . $TypeSort . "` ASC;"); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | return doquery("SELECT u.*, COUNT(r.id) AS referral_count, SUM(r.dark_matter) AS referral_dm FROM {{users}} as u |
| 196 | 196 | LEFT JOIN {{referrals}} as r on r.id_partner = u.id |
| 197 | 197 | WHERE" . |
| 198 | - ($online ? " `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') . |
|
| 198 | + ($online ? " `onlinetime` >= " . (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') . |
|
| 199 | 199 | " GROUP BY u.id |
| 200 | 200 | ORDER BY user_as_ally, {$sort} ASC"); |
| 201 | 201 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | !is_array($user_id_list) ? $user_id_list = array($user_id_list) : false; |
| 212 | 212 | |
| 213 | 213 | $user_list = array(); |
| 214 | - foreach($user_id_list as $user_id_unsafe) { |
|
| 214 | + foreach ($user_id_list as $user_id_unsafe) { |
|
| 215 | 215 | $user = db_user_by_id($user_id_unsafe); |
| 216 | 216 | !empty($user) ? $user_list[$user_id_unsafe] = $user : false; |
| 217 | 217 | } |
@@ -56,8 +56,7 @@ discard block |
||
| 56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
| 57 | 57 | sn_db_transaction_commit(); |
| 58 | 58 | throw new exception('buddy_err_accept_none', ERR_NONE); |
| 59 | - } |
|
| 60 | - else |
|
| 59 | + } else |
|
| 61 | 60 | { |
| 62 | 61 | throw new exception('buddy_err_accept_internal', ERR_ERROR); |
| 63 | 62 | } |
@@ -69,9 +68,11 @@ discard block |
||
| 69 | 68 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
| 70 | 69 | } |
| 71 | 70 | |
| 72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
| 71 | + if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
| 72 | + // Existing friendship |
|
| 73 | 73 | { |
| 74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | msg_send_simple_message($ex_friend_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_unfriend_title'], |
| 77 | 78 | sprintf($lang['buddy_msg_unfriend_text'], $user['username'])); |
@@ -79,17 +80,19 @@ discard block |
||
| 79 | 80 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 80 | 81 | sn_db_transaction_commit(); |
| 81 | 82 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
| 82 | - } |
|
| 83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
| 83 | + } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
| 84 | + // Player's outcoming request - either denied or waiting |
|
| 84 | 85 | { |
| 85 | 86 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 87 | + } |
|
| 86 | 88 | sn_db_transaction_commit(); |
| 87 | 89 | throw new exception('buddy_err_delete_own', ERR_NONE); |
| 88 | - } |
|
| 89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
| 90 | + } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) { |
|
| 91 | + // Deny incoming request |
|
| 90 | 92 | { |
| 91 | 93 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
| 92 | 94 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
| 95 | + } |
|
| 93 | 96 | |
| 94 | 97 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_DENIED . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 95 | 98 | sn_db_transaction_commit(); |
@@ -104,8 +107,7 @@ discard block |
||
| 104 | 107 | if($new_friend_id = sys_get_param_id('request_user_id')) |
| 105 | 108 | { |
| 106 | 109 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
| 107 | - } |
|
| 108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 110 | + } elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 109 | 111 | { |
| 110 | 112 | $new_friend_row = db_user_by_username($new_friend_name); |
| 111 | 113 | $new_friend_name = db_escape($new_friend_name); |
@@ -138,8 +140,7 @@ discard block |
||
| 138 | 140 | sn_db_transaction_commit(); |
| 139 | 141 | throw new exception('buddy_err_adding_none', ERR_NONE); |
| 140 | 142 | } |
| 141 | -} |
|
| 142 | -catch(exception $e) |
|
| 143 | +} catch(exception $e) |
|
| 143 | 144 | { |
| 144 | 145 | $result[] = array( |
| 145 | 146 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -18,39 +18,39 @@ discard block |
||
| 18 | 18 | { |
| 19 | 19 | sn_db_transaction_start(); |
| 20 | 20 | |
| 21 | - if($buddy_id = sys_get_param_id('buddy_id')) |
|
| 21 | + if ($buddy_id = sys_get_param_id('buddy_id')) |
|
| 22 | 22 | { |
| 23 | 23 | $buddy_row = doquery("SELECT BUDDY_SENDER_ID, BUDDY_OWNER_ID, BUDDY_STATUS FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1 FOR UPDATE;", true); |
| 24 | - if(!is_array($buddy_row)) |
|
| 24 | + if (!is_array($buddy_row)) |
|
| 25 | 25 | { |
| 26 | 26 | throw new exception('buddy_err_not_exist', ERR_ERROR); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - switch($mode = sys_get_param_str('mode')) |
|
| 29 | + switch ($mode = sys_get_param_str('mode')) |
|
| 30 | 30 | { |
| 31 | 31 | case 'accept': |
| 32 | - if($buddy_row['BUDDY_SENDER_ID'] == $user['id']) |
|
| 32 | + if ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) |
|
| 33 | 33 | { |
| 34 | 34 | throw new exception('buddy_err_accept_own', ERR_ERROR); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if($buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 37 | + if ($buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 38 | 38 | { |
| 39 | 39 | throw new exception('buddy_err_accept_alien', ERR_ERROR); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) |
|
| 42 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) |
|
| 43 | 43 | { |
| 44 | 44 | throw new exception('buddy_err_accept_already', ERR_WARNING); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) |
|
| 47 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) |
|
| 48 | 48 | { |
| 49 | 49 | throw new exception('buddy_err_accept_denied', ERR_ERROR); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_ACTIVE . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 53 | - if(SN::$db->db_affected_rows()) |
|
| 53 | + if (SN::$db->db_affected_rows()) |
|
| 54 | 54 | { |
| 55 | 55 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_accept_title'], |
| 56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | break; |
| 65 | 65 | |
| 66 | 66 | case 'delete': |
| 67 | - if($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 67 | + if ($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 68 | 68 | { |
| 69 | 69 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
| 72 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
| 73 | 73 | { |
| 74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
| 75 | 75 | |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | sn_db_transaction_commit(); |
| 81 | 81 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
| 82 | 82 | } |
| 83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
| 83 | + elseif ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
| 84 | 84 | { |
| 85 | 85 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 86 | 86 | sn_db_transaction_commit(); |
| 87 | 87 | throw new exception('buddy_err_delete_own', ERR_NONE); |
| 88 | 88 | } |
| 89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
| 89 | + elseif ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
| 90 | 90 | { |
| 91 | 91 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
| 92 | 92 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
@@ -101,24 +101,24 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | // New request? |
| 103 | 103 | // Checking for user ID - in case if it was request from outside buddy system |
| 104 | - if($new_friend_id = sys_get_param_id('request_user_id')) |
|
| 104 | + if ($new_friend_id = sys_get_param_id('request_user_id')) |
|
| 105 | 105 | { |
| 106 | 106 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
| 107 | 107 | } |
| 108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 108 | + elseif ($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 109 | 109 | { |
| 110 | 110 | $new_friend_row = db_user_by_username($new_friend_name); |
| 111 | 111 | $new_friend_name = db_escape($new_friend_name); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if($new_friend_row['id'] == $user['id']) |
|
| 114 | + if ($new_friend_row['id'] == $user['id']) |
|
| 115 | 115 | { |
| 116 | 116 | unset($new_friend_row); |
| 117 | 117 | throw new exception('buddy_err_adding_self', ERR_ERROR); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Checking for user name & request text - in case if it was request to adding new request |
| 121 | - if(isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) |
|
| 121 | + if (isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) |
|
| 122 | 122 | { |
| 123 | 123 | $check_relation = doquery("SELECT `BUDDY_ID` FROM {{buddy}} WHERE |
| 124 | 124 | (`BUDDY_SENDER_ID` = {$user['id']} AND `BUDDY_OWNER_ID` = {$new_friend_row['id']}) |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | (`BUDDY_SENDER_ID` = {$new_friend_row['id']} AND `BUDDY_OWNER_ID` = {$user['id']}) |
| 127 | 127 | LIMIT 1 FOR UPDATE;" |
| 128 | 128 | , true); |
| 129 | - if(isset($check_relation['BUDDY_ID'])) |
|
| 129 | + if (isset($check_relation['BUDDY_ID'])) |
|
| 130 | 130 | { |
| 131 | 131 | throw new exception('buddy_err_adding_exists', ERR_WARNING); |
| 132 | 132 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | throw new exception('buddy_err_adding_none', ERR_NONE); |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | -catch(exception $e) |
|
| 142 | +catch (exception $e) |
|
| 143 | 143 | { |
| 144 | 144 | $result[] = array( |
| 145 | 145 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | sn_db_transaction_rollback(); |
| 151 | 151 | |
| 152 | 152 | $query = db_buddy_list_by_user($user['id']); |
| 153 | -while($row = db_fetch($query)) |
|
| 153 | +while ($row = db_fetch($query)) |
|
| 154 | 154 | { |
| 155 | 155 | $row['BUDDY_REQUEST'] = HelperString::nl2br($row['BUDDY_REQUEST']); |
| 156 | 156 | |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | * @return bool |
| 47 | 47 | */ |
| 48 | 48 | public function changeTitle(AllianceTitle $title) { |
| 49 | - if(!$title instanceof AllianceTitle) { |
|
| 49 | + if (!$title instanceof AllianceTitle) { |
|
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | continue; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $result[] = (string)$title; |
|
| 48 | + $result[] = (string) $title; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return implode(';', $result); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * Updates title names and access rights with current ones |
| 68 | 68 | */ |
| 69 | 69 | public function updateTitles() { |
| 70 | - $this->alliance->titleList = (string)$this; |
|
| 70 | + $this->alliance->titleList = (string) $this; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | protected function extractTitles() { |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | * @return int |
| 59 | 59 | */ |
| 60 | 60 | public static function calcBonusPower($unitInfo) { |
| 61 | - return isset($unitInfo[P_BONUS_VALUE]) ? $unitInfo[P_BONUS_VALUE] : |
|
| 62 | - (static::calcBonusType($unitInfo) == BONUS_ABILITY ? 1 : 0); |
|
| 61 | + return isset($unitInfo[P_BONUS_VALUE]) ? $unitInfo[P_BONUS_VALUE] : (static::calcBonusType($unitInfo) == BONUS_ABILITY ? 1 : 0); |
|
| 63 | 62 | } |
| 64 | 63 | |
| 65 | 64 | /** |
@@ -58,8 +58,8 @@ |
||
| 58 | 58 | protected function bonusSort(BonusAtom $a, BonusAtom $b) { |
| 59 | 59 | static $bonusOrder = [BonusAtom::class, BonusAtomAbility::class, BonusAtomAdd::class, BonusAtomPercent::class, BonusAtomMultiply::class]; |
| 60 | 60 | |
| 61 | - $indexA = (int)array_search(get_class($a), $bonusOrder); |
|
| 62 | - $indexB = (int)array_search(get_class($b), $bonusOrder); |
|
| 61 | + $indexA = (int) array_search(get_class($a), $bonusOrder); |
|
| 62 | + $indexB = (int) array_search(get_class($b), $bonusOrder); |
|
| 63 | 63 | |
| 64 | 64 | return $indexA == $indexB ? 0 : ($indexA > $indexB ? +1 : -1); |
| 65 | 65 | } |