@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | // $same_user = false; |
54 | 54 | // } |
55 | 55 | |
56 | - if(!$user_data) { |
|
56 | + if (!$user_data) { |
|
57 | 57 | message($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10); |
58 | 58 | die(); |
59 | 59 | } |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | $stat_array = array(); |
65 | 65 | $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;"); |
66 | 66 | $stat_count = classSupernova::$db->db_affected_rows(); |
67 | - while($row = db_fetch($query)) { |
|
68 | - foreach($stat_fields as $field_db_name => $field_template_name) { |
|
67 | + while ($row = db_fetch($query)) { |
|
68 | + foreach ($stat_fields as $field_db_name => $field_template_name) { |
|
69 | 69 | // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS |
70 | 70 | $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name]; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | 74 | $stat_array_date = $stat_array['STAT_DATE']; |
75 | - foreach($stat_array_date['DATA'] as $key => $value) { |
|
75 | + foreach ($stat_array_date['DATA'] as $key => $value) { |
|
76 | 76 | $template->assign_block_vars('stat_date', array( |
77 | 77 | 'ID' => $key, |
78 | 78 | 'VALUE' => $value, |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | |
86 | 86 | unset($stat_array['STAT_DATE']); |
87 | 87 | $template_data = array(); |
88 | - foreach($stat_array as $stat_type => &$stat_type_data) { |
|
88 | + foreach ($stat_array as $stat_type => &$stat_type_data) { |
|
89 | 89 | $reverse_min_max = strpos($stat_type, '_RANK') !== false; |
90 | 90 | $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']); |
91 | 91 | $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']); |
92 | 92 | $stat_type_data['AVG'] = average($stat_type_data['DATA']); |
93 | - foreach($stat_type_data['DATA'] as $key => $value) { |
|
93 | + foreach ($stat_type_data['DATA'] as $key => $value) { |
|
94 | 94 | // $stat_type_data['PERCENT'][$key] = $stat_type_data['MAX'] - $value ? ($stat_type_data['MAX'] - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $value) : 100; |
95 | 95 | $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100; |
96 | 96 | $template_data[$stat_type][$key]['ID'] = $key; |
97 | 97 | $template_data[$stat_type][$key]['VALUE'] = $value; |
98 | - $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
98 | + $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
99 | 99 | $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key]; |
100 | 100 | |
101 | 101 | //$template_data[$stat_type][$key]['PERCENT'] = $key ? $stat_type_data['PERCENT'][$key] : 50; // TODO DEBUG |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | // pdump($stat_array['RES_POINTS']); |
105 | 105 | |
106 | - foreach($template_data as $stat_type => $stat_type_data) { |
|
106 | + foreach ($template_data as $stat_type => $stat_type_data) { |
|
107 | 107 | $template->assign_block_vars('stat', array( |
108 | 108 | 'TYPE' => $stat_type, |
109 | 109 | 'TEXT' => $lang['imp_stat_types'][$stat_type], |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'MAX' => $stat_array[$stat_type]['MAX'], |
112 | 112 | 'AVG' => $stat_array[$stat_type]['AVG'], |
113 | 113 | )); |
114 | - foreach($stat_type_data as $stat_entry) { |
|
114 | + foreach ($stat_type_data as $stat_entry) { |
|
115 | 115 | $template->assign_block_vars('stat.entry', $stat_entry); |
116 | 116 | } |
117 | 117 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | // pdump($template_data); |
121 | 121 | |
122 | - if($same_user) { |
|
122 | + if ($same_user) { |
|
123 | 123 | rpg_level_up($user, RPG_STRUCTURE); |
124 | 124 | rpg_level_up($user, RPG_RAID); |
125 | 125 | rpg_level_up($user, RPG_TECH); |
@@ -153,29 +153,29 @@ discard block |
||
153 | 153 | 'builder_xp' => pretty_number($user_data['xpminier']), |
154 | 154 | 'builder_lvl' => pretty_number($user_data['lvl_minier']), |
155 | 155 | 'builder_lvl_st' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'])), |
156 | - 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier']+1)), |
|
156 | + 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'] + 1)), |
|
157 | 157 | 'raid_xp' => pretty_number($user_data['xpraid']), |
158 | 158 | 'raid_lvl' => pretty_number($user_data['lvl_raid']), |
159 | - 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid']+1)), |
|
159 | + 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid'] + 1)), |
|
160 | 160 | 'raids' => pretty_number($user_data['raids']), |
161 | 161 | 'raidswin' => pretty_number($user_data['raidswin']), |
162 | 162 | 'raidsloose' => pretty_number($user_data['raidsloose']), |
163 | 163 | 'tech_xp' => pretty_number($user_data['player_rpg_tech_xp']), |
164 | 164 | 'tech_lvl' => pretty_number($user_data['player_rpg_tech_level']), |
165 | 165 | 'tech_lvl_st' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'])), |
166 | - 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)), |
|
166 | + 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)), |
|
167 | 167 | |
168 | 168 | 'explore_xp' => pretty_number($user_data['player_rpg_explore_xp']), |
169 | 169 | 'explore_lvl' => pretty_number($user_data['player_rpg_explore_level']), |
170 | 170 | 'explore_lvl_st' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'])), |
171 | - 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)), |
|
172 | - |
|
173 | - 'build_points' => pretty_number( $StatRecord['build_points'] ), |
|
174 | - 'tech_points' => pretty_number( $StatRecord['tech_points'] ), |
|
175 | - 'fleet_points' => pretty_number( $StatRecord['fleet_points'] ), |
|
176 | - 'defs_points' => pretty_number( $StatRecord['defs_points'] ), |
|
177 | - 'res_points' => pretty_number( $StatRecord['res_points'] ), |
|
178 | - 'total_points' => pretty_number( $StatRecord['total_points'] ), |
|
171 | + 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)), |
|
172 | + |
|
173 | + 'build_points' => pretty_number($StatRecord['build_points']), |
|
174 | + 'tech_points' => pretty_number($StatRecord['tech_points']), |
|
175 | + 'fleet_points' => pretty_number($StatRecord['fleet_points']), |
|
176 | + 'defs_points' => pretty_number($StatRecord['defs_points']), |
|
177 | + 'res_points' => pretty_number($StatRecord['res_points']), |
|
178 | + 'total_points' => pretty_number($StatRecord['total_points']), |
|
179 | 179 | 'user_rank' => $StatRecord['total_rank'], |
180 | 180 | 'RANK_DIFF' => $StatRecord['total_old_rank'] - $StatRecord['total_rank'], |
181 | 181 |
@@ -14,14 +14,14 @@ |
||
14 | 14 | global $lang, $user, $planetrow; |
15 | 15 | |
16 | 16 | $tech_tree = array(); |
17 | - foreach(get_unit_param('techtree') as $unit_group_id => $unit_list) |
|
17 | + foreach (get_unit_param('techtree') as $unit_group_id => $unit_list) |
|
18 | 18 | { |
19 | 19 | $tech_tree[] = array( |
20 | 20 | 'NAME' => $lang['tech'][$unit_group_id], |
21 | 21 | 'GROUP_ID' => $unit_group_id, |
22 | 22 | ); |
23 | 23 | |
24 | - foreach($unit_list as $unit_id) |
|
24 | + foreach ($unit_list as $unit_id) |
|
25 | 25 | { |
26 | 26 | $sn_data_unit = get_unit_param($unit_id); |
27 | 27 | $level_basic = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id, false, true); |
@@ -140,11 +140,13 @@ |
||
140 | 140 | $error_backtrace['locks'] = classSupernova::$locks; |
141 | 141 | $error_backtrace['cSN_data'] = classSupernova::$data; |
142 | 142 | foreach($error_backtrace['cSN_data'] as &$location) { |
143 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
143 | + foreach($location as $location_id => &$location_data) { |
|
144 | + // $location_data = $location_id; |
|
144 | 145 | { |
145 | 146 | $location_data = isset($location_data['username']) ? $location_data['username'] : |
146 | 147 | (isset($location_data['name']) ? $location_data['name'] : $location_id); |
147 | 148 | } |
149 | + } |
|
148 | 150 | } |
149 | 151 | $error_backtrace['cSN_queries'] = classSupernova::$queries; |
150 | 152 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Some helpers to sweeten dev's life |
|
4 | - */ |
|
3 | + * Some helpers to sweeten dev's life |
|
4 | + */ |
|
5 | 5 | |
6 | 6 | /* |
7 | 7 | * debug.class.php :: Clase Debug, maneja reporte de eventos |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | function log_file($message, $ident_change = 0) { |
51 | 51 | static $ident = 0; |
52 | 52 | |
53 | - if(!defined('SN_DEBUG_LOG')) { |
|
53 | + if (!defined('SN_DEBUG_LOG')) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if($this->log_file_handler === null) { |
|
57 | + if ($this->log_file_handler === null) { |
|
58 | 58 | $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
59 | 59 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
60 | 60 | } |
61 | 61 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
62 | - if($this->log_file_handler) { |
|
62 | + if ($this->log_file_handler) { |
|
63 | 63 | @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
64 | 64 | } |
65 | 65 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | $result = array(); |
91 | 91 | $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++; |
92 | 92 | $result[] = "tID {$transaction_id}"; |
93 | - foreach($backtrace as $a_trace) { |
|
94 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
93 | + foreach ($backtrace as $a_trace) { |
|
94 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | $function = |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | // $result[] = "{$function} ({$a_trace['line']})'{$file}'"; |
109 | 109 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
110 | 110 | |
111 | - if(!$long_comment) { |
|
111 | + if (!$long_comment) { |
|
112 | 112 | break; |
113 | 113 | } |
114 | 114 | } |
@@ -120,26 +120,26 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | function dump($dump = false, $force_base = false, $deadlock = false) { |
123 | - if($dump === false) { |
|
123 | + if ($dump === false) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | $error_backtrace = array(); |
128 | 128 | $base_dump = false; |
129 | 129 | |
130 | - if($force_base === true) { |
|
130 | + if ($force_base === true) { |
|
131 | 131 | $base_dump = true; |
132 | 132 | } |
133 | 133 | |
134 | - if($dump === true) { |
|
134 | + if ($dump === true) { |
|
135 | 135 | $base_dump = true; |
136 | 136 | } else { |
137 | - if(!is_array($dump)) { |
|
137 | + if (!is_array($dump)) { |
|
138 | 138 | $dump = array('var' => $dump); |
139 | 139 | } |
140 | 140 | |
141 | - foreach($dump as $dump_var_name => $dump_var) { |
|
142 | - if($dump_var_name == 'base_dump') { |
|
141 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
142 | + if ($dump_var_name == 'base_dump') { |
|
143 | 143 | $base_dump = $dump_var; |
144 | 144 | } else { |
145 | 145 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -148,26 +148,25 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | // if($deadlock && ($q = db_fetch(classSupernova::$db->__db_query('SHOW ENGINE INNODB STATUS')))) { |
151 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
151 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
152 | 152 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
153 | 153 | $error_backtrace['locks'] = classSupernova::$locks; |
154 | 154 | $error_backtrace['cSN_data'] = classSupernova::$data; |
155 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
156 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
155 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
156 | + foreach ($location as $location_id => &$location_data) // $location_data = $location_id; |
|
157 | 157 | { |
158 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
159 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
158 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
160 | 159 | } |
161 | 160 | } |
162 | 161 | $error_backtrace['cSN_queries'] = classSupernova::$queries; |
163 | 162 | } |
164 | 163 | |
165 | - if($base_dump) { |
|
166 | - if(is_array($this->log_array) && count($this->log_array) > 0) { |
|
164 | + if ($base_dump) { |
|
165 | + if (is_array($this->log_array) && count($this->log_array) > 0) { |
|
167 | 166 | // ; |
168 | 167 | // } |
169 | 168 | // { |
170 | - foreach($this->log_array as $log) { |
|
169 | + foreach ($this->log_array as $log) { |
|
171 | 170 | $error_backtrace['queries'][] = $log; |
172 | 171 | } |
173 | 172 | } |
@@ -198,14 +197,14 @@ discard block |
||
198 | 197 | function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
199 | 198 | global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user; |
200 | 199 | |
201 | - if(empty(classSupernova::$db->connected)) { |
|
200 | + if (empty(classSupernova::$db->connected)) { |
|
202 | 201 | // TODO - писать ошибку в файл |
203 | 202 | die('SQL server currently unavailable. Please contact Administration...'); |
204 | 203 | } |
205 | 204 | |
206 | 205 | sn_db_transaction_rollback(); |
207 | 206 | |
208 | - if($config->debug == 1) { |
|
207 | + if ($config->debug == 1) { |
|
209 | 208 | echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; |
210 | 209 | echo "<table>{$this->log}</table>"; |
211 | 210 | } |
@@ -215,7 +214,7 @@ discard block |
||
215 | 214 | $error_text = db_escape($message); |
216 | 215 | $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false); |
217 | 216 | |
218 | - if(!$sys_log_disabled) { |
|
217 | + if (!$sys_log_disabled) { |
|
219 | 218 | $query = "INSERT INTO `{{logs}}` SET |
220 | 219 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($user['id']) . "', |
221 | 220 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -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,14 +244,14 @@ discard block |
||
245 | 244 | function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
246 | 245 | global $user, $lang, $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 | } |
252 | 251 | |
253 | 252 | $error_backtrace = $this->dump($dump, false); |
254 | 253 | |
255 | - if(!$sys_log_disabled) { |
|
254 | + if (!$sys_log_disabled) { |
|
256 | 255 | $query = "INSERT INTO `{{logs}}` SET |
257 | 256 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($user['id']) . "', |
258 | 257 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -270,11 +269,11 @@ discard block |
||
270 | 269 | // Dump variables nicer then var_dump() |
271 | 270 | |
272 | 271 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
273 | - if(isset($varname)) { |
|
272 | + if (isset($varname)) { |
|
274 | 273 | $varname .= " = "; |
275 | 274 | } |
276 | 275 | |
277 | - if($level == -1) { |
|
276 | + if ($level == -1) { |
|
278 | 277 | $trans[' '] = '∴'; |
279 | 278 | $trans["\t"] = '⇒'; |
280 | 279 | $trans["\n"] = '¶;'; |
@@ -283,7 +282,7 @@ discard block |
||
283 | 282 | |
284 | 283 | return strtr(htmlspecialchars($value), $trans); |
285 | 284 | } |
286 | - if($level == 0) { |
|
285 | + if ($level == 0) { |
|
287 | 286 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
288 | 287 | $dumper = mt_rand(10, 99) . '|' . $varname; |
289 | 288 | } |
@@ -291,22 +290,22 @@ discard block |
||
291 | 290 | $type = gettype($value); |
292 | 291 | $dumper .= $type; |
293 | 292 | |
294 | - if($type == 'string') { |
|
293 | + if ($type == 'string') { |
|
295 | 294 | $dumper .= '(' . strlen($value) . ')'; |
296 | 295 | $value = dump($value, '', -1); |
297 | - } elseif($type == 'boolean') { |
|
296 | + } elseif ($type == 'boolean') { |
|
298 | 297 | $value = ($value ? 'true' : 'false'); |
299 | - } elseif($type == 'object') { |
|
298 | + } elseif ($type == 'object') { |
|
300 | 299 | $props = get_class_vars(get_class($value)); |
301 | 300 | $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
302 | - foreach($props as $key => $val) { |
|
301 | + foreach ($props as $key => $val) { |
|
303 | 302 | $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
304 | 303 | $dumper .= dump($value->$key, '', $level + 1); |
305 | 304 | } |
306 | 305 | $value = ''; |
307 | - } elseif($type == 'array') { |
|
306 | + } elseif ($type == 'array') { |
|
308 | 307 | $dumper .= '(' . count($value) . ')'; |
309 | - foreach($value as $key => $val) { |
|
308 | + foreach ($value as $key => $val) { |
|
310 | 309 | $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
311 | 310 | $dumper .= dump($val, '', $level + 1); |
312 | 311 | } |
@@ -326,7 +325,7 @@ discard block |
||
326 | 325 | // $backtrace = $backtrace[1]; |
327 | 326 | |
328 | 327 | $caller = ''; |
329 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
328 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
330 | 329 | $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
331 | 330 | (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
332 | 331 | $backtrace[1]['function'] . |
@@ -353,7 +352,7 @@ discard block |
||
353 | 352 | } |
354 | 353 | |
355 | 354 | function pr($prePrint = false) { |
356 | - if($prePrint) { |
|
355 | + if ($prePrint) { |
|
357 | 356 | print(__DEBUG_CRLF); |
358 | 357 | } |
359 | 358 | print(mt_rand() . __DEBUG_CRLF); |
@@ -363,7 +362,7 @@ discard block |
||
363 | 362 | global $_PRINT_COUNT_VALUE; |
364 | 363 | $_PRINT_COUNT_VALUE++; |
365 | 364 | |
366 | - if($prePrint) { |
|
365 | + if ($prePrint) { |
|
367 | 366 | print(__DEBUG_CRLF); |
368 | 367 | } |
369 | 368 | print($_PRINT_COUNT_VALUE . __DEBUG_CRLF); |
@@ -399,7 +399,9 @@ discard block |
||
399 | 399 | $units_levels = array(); |
400 | 400 | foreach($planet_unit_list as $unit_id) { |
401 | 401 | $unit_name = &$units_info[$unit_id][P_NAME]; |
402 | - if(!isset($row[$unit_name]) || !$row[$unit_name]) continue; |
|
402 | + if(!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
403 | + continue; |
|
404 | + } |
|
403 | 405 | $units_levels[$unit_id] = $row[$unit_name]; |
404 | 406 | $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
405 | 407 | if(count($unit_data) > 30) { |
@@ -413,7 +415,9 @@ discard block |
||
413 | 415 | if($row['que']) { |
414 | 416 | $que = explode(';', $row['que']); |
415 | 417 | foreach($que as $que_item) { |
416 | - if(!$que_item) continue; |
|
418 | + if(!$que_item) { |
|
419 | + continue; |
|
420 | + } |
|
417 | 421 | |
418 | 422 | $que_item = explode(',', $que_item); |
419 | 423 | |
@@ -445,9 +449,13 @@ discard block |
||
445 | 449 | $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0, ); |
446 | 450 | $hangar_units = sys_unit_str2arr($row['b_hangar_id']); |
447 | 451 | foreach($hangar_units as $unit_id => $unit_count) { |
448 | - if($unit_count <= 0) continue; |
|
452 | + if($unit_count <= 0) { |
|
453 | + continue; |
|
454 | + } |
|
449 | 455 | foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
450 | - if(!in_array($resource_id, $group_resource_loot)) continue; |
|
456 | + if(!in_array($resource_id, $group_resource_loot)) { |
|
457 | + continue; |
|
458 | + } |
|
451 | 459 | $return_resources[$resource_id] += $unit_count * $resource_amount; |
452 | 460 | } |
453 | 461 | } |
@@ -464,11 +472,13 @@ discard block |
||
464 | 472 | } |
465 | 473 | } |
466 | 474 | |
467 | - if(!empty($unit_data)) |
|
468 | - upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
475 | + if(!empty($unit_data)) { |
|
476 | + upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
477 | + } |
|
469 | 478 | |
470 | - if(!empty($que_data)) |
|
471 | - upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
|
479 | + if(!empty($que_data)) { |
|
480 | + upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
|
481 | + } |
|
472 | 482 | |
473 | 483 | upd_alter_table('planets', $drop, true); |
474 | 484 | } |
@@ -761,9 +771,11 @@ discard block |
||
761 | 771 | !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
762 | 772 | } |
763 | 773 | |
764 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
774 | + if(isset($update_tables['counter']['page'])) { |
|
775 | + // TODO REMOVE |
|
765 | 776 | { |
766 | 777 | update_security_url("SELECT DISTINCT `page` as url FROM {{counter}}"); |
778 | + } |
|
767 | 779 | update_security_url("SELECT DISTINCT `url` as url FROM {{counter}}"); |
768 | 780 | } |
769 | 781 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | [!] DB code updates |
22 | 22 | */ |
23 | 23 | |
24 | -if(!defined('INIT')) { |
|
24 | +if (!defined('INIT')) { |
|
25 | 25 | // include_once('init.php'); |
26 | 26 | die('Unauthorized access'); |
27 | 27 | } |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | |
42 | 42 | //$config->db_loadItem('db_version'); |
43 | -if($config->db_version == DB_VERSION) { |
|
44 | -} elseif($config->db_version > DB_VERSION) { |
|
43 | +if ($config->db_version == DB_VERSION) { |
|
44 | +} elseif ($config->db_version > DB_VERSION) { |
|
45 | 45 | $config->db_saveItem('var_db_update_end', SN_TIME_NOW); |
46 | 46 | die( |
47 | 47 | 'Internal error! Auotupdater detects DB version greater then can be handled!<br /> |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
53 | -if($config->db_version < 26) { |
|
53 | +if ($config->db_version < 26) { |
|
54 | 54 | $sys_log_disabled = true; |
55 | 55 | } |
56 | 56 | |
@@ -69,25 +69,25 @@ discard block |
||
69 | 69 | $update_tables = array(); |
70 | 70 | $update_indexes = array(); |
71 | 71 | $query = upd_do_query('SHOW TABLES;', true); |
72 | -while($row = db_fetch_row($query)) { |
|
72 | +while ($row = db_fetch_row($query)) { |
|
73 | 73 | upd_load_table_info($row[0]); |
74 | 74 | } |
75 | 75 | upd_log_message('Table info loaded. Now looking DB for upgrades...'); |
76 | 76 | |
77 | 77 | upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true); |
78 | 78 | |
79 | -if($new_version < 37) { |
|
79 | +if ($new_version < 37) { |
|
80 | 80 | require_once('update_old.php'); |
81 | 81 | } |
82 | 82 | |
83 | 83 | ini_set('memory_limit', '1024M'); |
84 | 84 | |
85 | -switch($new_version) { |
|
85 | +switch ($new_version) { |
|
86 | 86 | case 37: |
87 | 87 | upd_log_version_update(); |
88 | 88 | |
89 | 89 | upd_check_key('player_vacation_timeout', PERIOD_WEEK, $config->player_vacation_timeout != PERIOD_WEEK); |
90 | - upd_check_key('player_vacation_time', PERIOD_WEEK , $config->player_vacation_time != PERIOD_WEEK); |
|
90 | + upd_check_key('player_vacation_time', PERIOD_WEEK, $config->player_vacation_time != PERIOD_WEEK); |
|
91 | 91 | |
92 | 92 | upd_alter_table('users', "ADD `vacation_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next datetime when player can go on vacation'", !$update_tables['users']['vacation_next']); |
93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | upd_check_key('payment_currency_exchange_mm_', 2500, !$config->payment_currency_exchange_mm_); |
99 | 99 | |
100 | - if(!$update_tables['log_metamatter']) |
|
100 | + if (!$update_tables['log_metamatter']) |
|
101 | 101 | { |
102 | 102 | upd_create_table('log_metamatter', |
103 | 103 | "( |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
124 | 124 | ), !$update_tables['payment']['payment_test']); |
125 | 125 | |
126 | - if($update_tables['payment']['payment_test']['Default'] == 1) |
|
126 | + if ($update_tables['payment']['payment_test']['Default'] == 1) |
|
127 | 127 | { |
128 | 128 | upd_alter_table('payment', array( |
129 | 129 | "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | ), $update_tables['users']['metamatter']['Type'] == 'int(20)'); |
142 | 142 | |
143 | 143 | $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id in (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE"); |
144 | - while($row = db_fetch($query)) |
|
144 | + while ($row = db_fetch($query)) |
|
145 | 145 | { |
146 | 146 | $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']); |
147 | 147 | upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE"); |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | LEFT JOIN {{planets}} AS p ON p.id = u.id_planet |
161 | 161 | WHERE unit_snid in (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") |
162 | 162 | FOR UPDATE"); |
163 | - while($row = db_fetch($query)) |
|
163 | + while ($row = db_fetch($query)) |
|
164 | 164 | { |
165 | - if(!$row['id_planet']) |
|
165 | + if (!$row['id_planet']) |
|
166 | 166 | { |
167 | 167 | continue; |
168 | 168 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $unit_level = $row['unit_level']; |
172 | 172 | $price = get_unit_param($unit_id, P_COST); |
173 | 173 | $factor = $price['factor']; |
174 | - foreach($price as $resource_id => &$resource_amount) |
|
174 | + foreach ($price as $resource_id => &$resource_amount) |
|
175 | 175 | { |
176 | 176 | $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1); |
177 | 177 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | // Вернуть ресы за уже исследованную Экспедиционную технологию |
192 | 192 | upd_check_key('player_max_colonies', -1, $config->player_max_colonies >= 0); |
193 | 193 | |
194 | - if(!isset($update_tables['users']['player_rpg_explore_xp'])) |
|
194 | + if (!isset($update_tables['users']['player_rpg_explore_xp'])) |
|
195 | 195 | { |
196 | 196 | upd_alter_table('users', array( |
197 | 197 | "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | ), !isset($update_tables['users']['player_rpg_explore_xp'])); |
200 | 200 | } |
201 | 201 | |
202 | - if(!$update_tables['log_users_online']) |
|
202 | + if (!$update_tables['log_users_online']) |
|
203 | 203 | { |
204 | - upd_create_table('log_users_online',"( |
|
204 | + upd_create_table('log_users_online', "( |
|
205 | 205 | `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time', |
206 | 206 | `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online', |
207 | 207 | |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`", |
216 | 216 | ), !$update_tables['users']['user_time_measured']); |
217 | 217 | |
218 | - if($update_tables['rw']) |
|
218 | + if ($update_tables['rw']) |
|
219 | 219 | { |
220 | 220 | upd_do_query("DROP TABLE IF EXISTS {{rw}};"); |
221 | 221 | } |
222 | 222 | |
223 | - if(!$update_tables['player_award']) |
|
223 | + if (!$update_tables['player_award']) |
|
224 | 224 | { |
225 | 225 | upd_create_table('player_award', "( |
226 | 226 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | upd_log_version_update(); |
264 | 264 | |
265 | 265 | |
266 | - if(!isset($update_tables['planets']['que_processed'])) { |
|
266 | + if (!isset($update_tables['planets']['que_processed'])) { |
|
267 | 267 | upd_alter_table('planets', array( |
268 | 268 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`", |
269 | 269 | ), true); |
270 | 270 | upd_do_query("UPDATE {{planets}} SET que_processed = last_update;"); |
271 | 271 | } |
272 | 272 | |
273 | - if(!isset($update_tables['users']['que_processed'])) { |
|
273 | + if (!isset($update_tables['users']['que_processed'])) { |
|
274 | 274 | upd_alter_table('users', array( |
275 | 275 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`", |
276 | 276 | ), true); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | |
283 | 283 | |
284 | - if(isset($update_tables['planets']['que'])) { |
|
284 | + if (isset($update_tables['planets']['que'])) { |
|
285 | 285 | $sn_data_aux = array( |
286 | 286 | SHIP_SMALL_FIGHTER_WRATH => array( |
287 | 287 | 'name' => 'ship_fighter_wrath', |
@@ -366,20 +366,20 @@ discard block |
||
366 | 366 | $unit_data = array(); |
367 | 367 | $planets = array(); |
368 | 368 | |
369 | - foreach($planet_unit_list as $unit_id) { |
|
370 | - if(!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
369 | + foreach ($planet_unit_list as $unit_id) { |
|
370 | + if (!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
371 | 371 | $unit_name = $sn_data_aux[$unit_id][P_NAME]; |
372 | 372 | } |
373 | - if(isset($update_tables['planets'][$unit_name])) { |
|
373 | + if (isset($update_tables['planets'][$unit_name])) { |
|
374 | 374 | $drop[] = "DROP COLUMN `{$unit_name}`"; |
375 | 375 | |
376 | - if(isset($aux_group[$unit_id])) { |
|
376 | + if (isset($aux_group[$unit_id])) { |
|
377 | 377 | $units_info[$unit_id] = $sn_data_aux[$unit_id]; |
378 | 378 | $units_info[$unit_id]['que'] = QUE_HANGAR; |
379 | 379 | } else { |
380 | 380 | $units_info[$unit_id] = get_unit_param($unit_id); |
381 | - foreach($ques_info as $que_id => $que_data1) { |
|
382 | - if(in_array($unit_id, $que_data1['unit_list'])) { |
|
381 | + foreach ($ques_info as $que_id => $que_data1) { |
|
382 | + if (in_array($unit_id, $que_data1['unit_list'])) { |
|
383 | 383 | $units_info[$unit_id]['que'] = $que_id; |
384 | 384 | break; |
385 | 385 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | } |
390 | 390 | |
391 | 391 | $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE"); |
392 | - while($row = db_fetch($query)) { |
|
392 | + while ($row = db_fetch($query)) { |
|
393 | 393 | $user_id = $row['id_owner']; |
394 | 394 | $planet_id = $row['id']; |
395 | 395 | |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | |
398 | 398 | // Конвертируем юниты |
399 | 399 | $units_levels = array(); |
400 | - foreach($planet_unit_list as $unit_id) { |
|
400 | + foreach ($planet_unit_list as $unit_id) { |
|
401 | 401 | $unit_name = &$units_info[$unit_id][P_NAME]; |
402 | - if(!isset($row[$unit_name]) || !$row[$unit_name]) continue; |
|
402 | + if (!isset($row[$unit_name]) || !$row[$unit_name]) continue; |
|
403 | 403 | $units_levels[$unit_id] = $row[$unit_name]; |
404 | 404 | $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
405 | - if(count($unit_data) > 30) { |
|
405 | + if (count($unit_data) > 30) { |
|
406 | 406 | $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max; |
407 | 407 | upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
408 | 408 | $unit_data = array(); |
@@ -410,10 +410,10 @@ discard block |
||
410 | 410 | } |
411 | 411 | |
412 | 412 | // Конвертируем очередь построек |
413 | - if($row['que']) { |
|
413 | + if ($row['que']) { |
|
414 | 414 | $que = explode(';', $row['que']); |
415 | - foreach($que as $que_item) { |
|
416 | - if(!$que_item) continue; |
|
415 | + foreach ($que as $que_item) { |
|
416 | + if (!$que_item) continue; |
|
417 | 417 | |
418 | 418 | $que_item = explode(',', $que_item); |
419 | 419 | |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1; |
427 | 427 | $price_increase = pow($unit_factor, $unit_level); |
428 | 428 | // $unit_time = 0; |
429 | - foreach($unit_cost as $resource_id => &$resource_amount) { |
|
430 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
429 | + foreach ($unit_cost as $resource_id => &$resource_amount) { |
|
430 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
431 | 431 | unset($unit_cost[$resource_id]); |
432 | 432 | continue; |
433 | 433 | } |
@@ -441,33 +441,33 @@ discard block |
||
441 | 441 | } |
442 | 442 | |
443 | 443 | // Конвертируем очередь верфи |
444 | - if($row['b_hangar_id']) { |
|
445 | - $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0, ); |
|
444 | + if ($row['b_hangar_id']) { |
|
445 | + $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,); |
|
446 | 446 | $hangar_units = sys_unit_str2arr($row['b_hangar_id']); |
447 | - foreach($hangar_units as $unit_id => $unit_count) { |
|
448 | - if($unit_count <= 0) continue; |
|
449 | - foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
450 | - if(!in_array($resource_id, $group_resource_loot)) continue; |
|
447 | + foreach ($hangar_units as $unit_id => $unit_count) { |
|
448 | + if ($unit_count <= 0) continue; |
|
449 | + foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
450 | + if (!in_array($resource_id, $group_resource_loot)) continue; |
|
451 | 451 | $return_resources[$resource_id] += $unit_count * $resource_amount; |
452 | 452 | } |
453 | 453 | } |
454 | - if(array_sum($return_resources) > 0) { |
|
454 | + if (array_sum($return_resources) > 0) { |
|
455 | 455 | upd_do_query("UPDATE {{planets}} SET `metal` = `metal` + {$return_resources[RES_METAL]}, `crystal` = `crystal` + {$return_resources[RES_CRYSTAL]}, `deuterium` = `deuterium` + {$return_resources[RES_DEUTERIUM]} WHERE `id` = {$planet_id} LIMIT 1"); |
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | 459 | |
460 | - if(count($que_data) > 10) { |
|
460 | + if (count($que_data) > 10) { |
|
461 | 461 | $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max; |
462 | 462 | upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
463 | 463 | $que_data = array(); |
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | - if(!empty($unit_data)) |
|
467 | + if (!empty($unit_data)) |
|
468 | 468 | upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
469 | 469 | |
470 | - if(!empty($que_data)) |
|
470 | + if (!empty($que_data)) |
|
471 | 471 | upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';'); |
472 | 472 | |
473 | 473 | upd_alter_table('planets', $drop, true); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = '' |
478 | 478 | SET u.`username` = CONCAT('[', a.`ally_tag`, ']');"); |
479 | 479 | |
480 | - if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
480 | + if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
481 | 481 | upd_do_query("SET FOREIGN_KEY_CHECKS=0;"); |
482 | 482 | upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']); |
483 | 483 | upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']); |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{$config->db_prefix}security_browser` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE", |
574 | 574 | ), !isset($update_tables['users']['user_last_proxy'])); |
575 | 575 | |
576 | - if(!isset($update_tables['notes']['planet_type'])) { |
|
576 | + if (!isset($update_tables['notes']['planet_type'])) { |
|
577 | 577 | upd_alter_table('notes', array( |
578 | 578 | // "ADD COLUMN `planet_name` VARCHAR(64) NOT NULL DEFAULT '' AFTER `title`", |
579 | 579 | "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`", |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot'])); |
593 | 593 | upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']); |
594 | 594 | |
595 | - if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
595 | + if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
596 | 596 | upd_alter_table('users', array( |
597 | 597 | "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'", |
598 | 598 | ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint'); |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;"); |
601 | 601 | } |
602 | 602 | |
603 | - if(!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
603 | + if (!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
604 | 604 | upd_alter_table('log_users_online', "ADD COLUMN `online_aggregated` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['log_users_online']['online_aggregated'])); |
605 | 605 | upd_alter_table('log_users_online', array( |
606 | 606 | "DROP PRIMARY KEY", |
@@ -608,13 +608,13 @@ discard block |
||
608 | 608 | ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,'); |
609 | 609 | } |
610 | 610 | |
611 | - if(!isset($update_tables['users']['gender'])) { |
|
611 | + if (!isset($update_tables['users']['gender'])) { |
|
612 | 612 | upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
613 | - upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE. ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
|
613 | + upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
|
614 | 614 | } |
615 | 615 | upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex'])); |
616 | 616 | |
617 | - if(!$update_tables['users']['dark_matter_total']) { |
|
617 | + if (!$update_tables['users']['dark_matter_total']) { |
|
618 | 618 | upd_alter_table('users', "ADD `dark_matter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Dark Matter amount ever gained' AFTER `dark_matter`", !$update_tables['users']['dark_matter_total']); |
619 | 619 | upd_do_query( |
620 | 620 | "UPDATE `{{users}}` AS u |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | upd_check_key('player_metamatter_immortal', 100000, !isset($config->player_metamatter_immortal)); |
630 | - if(!$update_tables['users']['metamatter_total']) { |
|
630 | + if (!$update_tables['users']['metamatter_total']) { |
|
631 | 631 | upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']); |
632 | 632 | |
633 | 633 | upd_do_query( |
@@ -639,11 +639,11 @@ discard block |
||
639 | 639 | (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0) |
640 | 640 | );"); |
641 | 641 | } |
642 | - if(!isset($update_tables['users']['immortal'])) { |
|
642 | + if (!isset($update_tables['users']['immortal'])) { |
|
643 | 643 | upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal'])); |
644 | 644 | upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;"); |
645 | 645 | } |
646 | - if(isset($update_tables['player_award'])) { |
|
646 | + if (isset($update_tables['player_award'])) { |
|
647 | 647 | upd_do_query( |
648 | 648 | "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id |
649 | 649 | SET metamatter_total = 1, immortal = NOW() |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
671 | 671 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); |
672 | 672 | |
673 | - if(empty($update_tables['blitz_statpoints'])) { |
|
673 | + if (empty($update_tables['blitz_statpoints'])) { |
|
674 | 674 | upd_create_table('blitz_statpoints', " ( |
675 | 675 | `stat_date` int(11) NOT NULL DEFAULT '0', |
676 | 676 | `id_owner` bigint(20) unsigned DEFAULT NULL, |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE |
739 | 739 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
740 | 740 | |
741 | - if(empty($update_tables['security_url'])) { |
|
741 | + if (empty($update_tables['security_url'])) { |
|
742 | 742 | upd_create_table('security_url', " ( |
743 | 743 | `url_id` int unsigned NOT NULL AUTO_INCREMENT, |
744 | 744 | `url_string` VARCHAR(250) NOT NULL DEFAULT '', |
@@ -751,9 +751,9 @@ discard block |
||
751 | 751 | |
752 | 752 | $strings = array(); |
753 | 753 | $query = doquery($query); |
754 | - while($row = db_fetch($query)) { |
|
754 | + while ($row = db_fetch($query)) { |
|
755 | 755 | $strings[] = '("' . db_escape($row['url']) . '")'; |
756 | - if(count($strings) > 100) { |
|
756 | + if (count($strings) > 100) { |
|
757 | 757 | doquery($query_string . implode(',', $strings)); |
758 | 758 | $strings = array(); |
759 | 759 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
762 | 762 | } |
763 | 763 | |
764 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
764 | + if (isset($update_tables['counter']['page'])) // TODO REMOVE |
|
765 | 765 | { |
766 | 766 | update_security_url("SELECT DISTINCT `page` as url FROM {{counter}}"); |
767 | 767 | update_security_url("SELECT DISTINCT `url` as url FROM {{counter}}"); |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
787 | 787 | "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
788 | 788 | ), !isset($update_tables['counter']['device_id'])); |
789 | - if(isset($update_tables['counter']['ip'])) { |
|
789 | + if (isset($update_tables['counter']['ip'])) { |
|
790 | 790 | // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)'); |
791 | 791 | upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)'); |
792 | 792 | upd_do_query('UPDATE `{{counter}}` AS c JOIN {{security_url}} AS u ON u.url_string = c.page SET c.page_url_id = u.url_id'); |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | |
838 | 838 | upd_check_key('stats_history_days', 14, !$config->stats_history_days); |
839 | 839 | |
840 | - if($config->payment_currency_default != 'USD') { |
|
841 | - upd_check_key('payment_currency_default', 'USD', true); |
|
840 | + if ($config->payment_currency_default != 'USD') { |
|
841 | + upd_check_key('payment_currency_default', 'USD', true); |
|
842 | 842 | upd_check_key('payment_currency_exchange_dm_', 20000, true); |
843 | 843 | upd_check_key('payment_currency_exchange_mm_', 20000, true); |
844 | 844 | upd_check_key('payment_currency_exchange_usd', 1, true); |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | function propagade_player_options($old_option_name, $new_option_id) { |
921 | 921 | global $update_tables; |
922 | 922 | |
923 | - if(!empty($update_tables['users'][$old_option_name])) { |
|
923 | + if (!empty($update_tables['users'][$old_option_name])) { |
|
924 | 924 | upd_do_query( |
925 | 925 | "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) |
926 | 926 | SELECT `id`, {$new_option_id}, `{$old_option_name}` |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | |
955 | 955 | // 2015-08-03 15:05:26 40a6.0 |
956 | 956 | |
957 | - if(empty($update_tables['planets']['position_original'])) { |
|
957 | + if (empty($update_tables['planets']['position_original'])) { |
|
958 | 958 | upd_alter_table('planets', array( |
959 | 959 | "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0", |
960 | 960 | "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0", |
@@ -982,12 +982,12 @@ discard block |
||
982 | 982 | // 2015-08-27 19:14:05 40a10.0 |
983 | 983 | |
984 | 984 | // Старая версия таблицы |
985 | - if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
985 | + if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
986 | 986 | upd_drop_table('account'); |
987 | 987 | upd_drop_table('account_translate'); |
988 | 988 | } |
989 | 989 | |
990 | - if(empty($update_tables['account'])) { |
|
990 | + if (empty($update_tables['account'])) { |
|
991 | 991 | upd_create_table('account', " ( |
992 | 992 | `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
993 | 993 | `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '', |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | upd_alter_table('security_url', "MODIFY COLUMN `url_string` VARCHAR(250) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''", empty($update_tables['security_url']['ube_report_capture_result'])); |
1046 | 1046 | |
1047 | 1047 | // 2015-09-24 11:39:37 40a10.25 |
1048 | - if(empty($update_tables['log_metamatter']['provider_id'])) { |
|
1048 | + if (empty($update_tables['log_metamatter']['provider_id'])) { |
|
1049 | 1049 | upd_alter_table('log_metamatter', array( |
1050 | 1050 | "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'", |
1051 | 1051 | "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0", |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | upd_check_key('event_halloween_2015_code', '', !isset($config->event_halloween_2015_code)); |
1096 | 1096 | upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset($config->event_halloween_2015_timestamp)); |
1097 | 1097 | upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset($config->event_halloween_2015_units_used)); |
1098 | - if(empty($update_tables['log_halloween_2015'])) { |
|
1098 | + if (empty($update_tables['log_halloween_2015'])) { |
|
1099 | 1099 | upd_create_table('log_halloween_2015', " ( |
1100 | 1100 | `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1101 | 1101 | `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | // 2015-11-28 06:30:27 40a19.21 |
1112 | - if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1112 | + if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1113 | 1113 | upd_alter_table('ube_report', array( |
1114 | 1114 | "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'", |
1115 | 1115 | // "ADD KEY `I_ube_report_debris_id` (`ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | // 2015-12-06 15:10:58 40b1.0 |
1127 | - if(!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1127 | + if (!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1128 | 1128 | upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']); |
1129 | 1129 | upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']); |
1130 | 1130 | upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']); |
@@ -1189,7 +1189,7 @@ discard block |
||
1189 | 1189 | case 40: |
1190 | 1190 | upd_log_version_update(); |
1191 | 1191 | |
1192 | - if(empty($update_tables['festival'])) { |
|
1192 | + if (empty($update_tables['festival'])) { |
|
1193 | 1193 | upd_create_table('festival', " ( |
1194 | 1194 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
1195 | 1195 | `start` datetime NOT NULL COMMENT 'Festival start datetime', |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | ); |
1231 | 1231 | } |
1232 | 1232 | |
1233 | - if(empty($update_tables['festival_unit'])) { |
|
1233 | + if (empty($update_tables['festival_unit'])) { |
|
1234 | 1234 | upd_create_table('festival_unit', " ( |
1235 | 1235 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1236 | 1236 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | // 2015-12-21 06:06:09 41a0.12 |
1250 | - if(empty($update_tables['festival_unit_log'])) { |
|
1250 | + if (empty($update_tables['festival_unit_log'])) { |
|
1251 | 1251 | upd_create_table('festival_unit_log', " ( |
1252 | 1252 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1253 | 1253 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1275,18 +1275,18 @@ discard block |
||
1275 | 1275 | $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin' |
1276 | 1276 | ); |
1277 | 1277 | |
1278 | - if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1278 | + if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1279 | 1279 | // pdump($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type']); |
1280 | 1280 | upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true); |
1281 | 1281 | upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true); |
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | // #ctv№ |
1285 | - if(!empty($update_tables['fleets']['fleet_array'])) { |
|
1285 | + if (!empty($update_tables['fleets']['fleet_array'])) { |
|
1286 | 1286 | $query = upd_do_query("SELECT * FROM {{fleets}}"); |
1287 | - while($row = db_fetch($query)) { |
|
1287 | + while ($row = db_fetch($query)) { |
|
1288 | 1288 | $unit_list = sys_unit_str2arr($row['fleet_array']); |
1289 | - foreach($unit_list as $unit_id => $unit_count) { |
|
1289 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
1290 | 1290 | upd_do_query( |
1291 | 1291 | "REPLACE INTO {{unit}} (`unit_player_id`,`unit_location_type`,`unit_location_id`,`unit_type`,`unit_snid`,`unit_level`) VALUES |
1292 | 1292 | ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, " . get_unit_param($unit_id, P_UNIT_TYPE) . ", {$unit_id}, {$unit_count});", |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | |
1322 | 1322 | classSupernova::$cache->unset_by_prefix('lng_'); |
1323 | 1323 | |
1324 | -if($new_version) { |
|
1324 | +if ($new_version) { |
|
1325 | 1325 | $config->db_saveItem('db_version', $new_version); |
1326 | 1326 | upd_log_message("<font color=green>DB version is now {$new_version}</font>"); |
1327 | 1327 | } else { |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | 'factor' => 1.5, |
16 | 16 | ), |
17 | 17 | P_UNIT_PRODUCTION => array( |
18 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
19 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
18 | + RES_METAL => function($level, $production_factor, $user, $planet_row) {return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
19 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
20 | 20 | ), |
21 | 21 | P_MINING_IS_MANAGED => true, |
22 | 22 | ), |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | 'factor' => 1.6, |
34 | 34 | ), |
35 | 35 | P_UNIT_PRODUCTION => array( |
36 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
37 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
36 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) {return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
37 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
38 | 38 | ), |
39 | 39 | P_MINING_IS_MANAGED => true, |
40 | 40 | ), |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | 'factor' => 1.5, |
52 | 52 | ), |
53 | 53 | P_UNIT_PRODUCTION => array( |
54 | - 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);}, |
|
55 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
54 | + 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); }, |
|
55 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
56 | 56 | ), |
57 | 57 | P_MINING_IS_MANAGED => true, |
58 | 58 | ), |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'factor' => 1.5, |
70 | 70 | ), |
71 | 71 | P_UNIT_PRODUCTION => array( |
72 | - 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);}, |
|
72 | + 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 | 73 | ), |
74 | 74 | P_MINING_IS_MANAGED => true, |
75 | 75 | ), |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | 'factor' => 1.8, |
88 | 88 | ), |
89 | 89 | P_UNIT_PRODUCTION => array( |
90 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor);}, |
|
91 | - 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);}, |
|
90 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
91 | + 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); }, |
|
92 | 92 | ), |
93 | 93 | P_MINING_IS_MANAGED => true, |
94 | 94 | ), |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'factor' => 2, |
106 | 106 | ), |
107 | 107 | 'storage' => array( |
108 | - RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
108 | + RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
109 | 109 | ), |
110 | 110 | ), |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'factor' => 2, |
122 | 122 | ), |
123 | 123 | 'storage' => array( |
124 | - RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
124 | + RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
125 | 125 | ), |
126 | 126 | ), |
127 | 127 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'factor' => 2, |
138 | 138 | ), |
139 | 139 | 'storage' => array( |
140 | - RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);}, |
|
140 | + RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
141 | 141 | ), |
142 | 142 | ), |
143 | 143 |
@@ -2,25 +2,25 @@ discard block |
||
2 | 2 | |
3 | 3 | // ------------------------------------------------------------------------------------------------------------------------------ |
4 | 4 | function sn_sys_load_php_files($dir_name, $load_extension = 'php', $modules = false) { |
5 | - if(file_exists($dir_name)) { |
|
5 | + if (file_exists($dir_name)) { |
|
6 | 6 | $dir = opendir($dir_name); |
7 | - while(($file = readdir($dir)) !== false) { |
|
8 | - if($file == '..' || $file == '.') { |
|
7 | + while (($file = readdir($dir)) !== false) { |
|
8 | + if ($file == '..' || $file == '.') { |
|
9 | 9 | continue; |
10 | 10 | } |
11 | 11 | |
12 | 12 | $full_filename = $dir_name . $file; |
13 | - if($modules && is_dir($full_filename)) { |
|
14 | - if(file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
13 | + if ($modules && is_dir($full_filename)) { |
|
14 | + if (file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
15 | 15 | require_once($full_filename); |
16 | 16 | // Registering module |
17 | - if(class_exists($file)) { |
|
17 | + if (class_exists($file)) { |
|
18 | 18 | new $file($full_filename); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $extension = substr($full_filename, -strlen($load_extension)); |
23 | - if($extension == $load_extension) { |
|
23 | + if ($extension == $load_extension) { |
|
24 | 24 | require_once($full_filename); |
25 | 25 | } |
26 | 26 | } |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function init_update(&$config) { |
41 | 41 | $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX; |
42 | - if(file_exists($update_file)) { |
|
43 | - if(filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | - if(defined('IN_ADMIN')) { |
|
42 | + if (file_exists($update_file)) { |
|
43 | + if (filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) { |
|
44 | + if (defined('IN_ADMIN')) { |
|
45 | 45 | sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована |
46 | - if(SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) { |
|
46 | + if (SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) { |
|
47 | 47 | $config->db_saveItem('var_db_update_end', SN_TIME_NOW + ($config->upd_lock_time ? $config->upd_lock_time : 300)); |
48 | 48 | sn_db_transaction_commit(); |
49 | 49 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $current_time = time(); |
54 | 54 | $config->db_saveItem('var_db_update', $current_time); |
55 | 55 | $config->db_saveItem('var_db_update_end', $current_time); |
56 | - } elseif(filemtime($update_file) > $config->var_db_update) { |
|
56 | + } elseif (filemtime($update_file) > $config->var_db_update) { |
|
57 | 57 | $timeout = $config->var_db_update_end - SN_TIME_NOW; |
58 | 58 | die( |
59 | 59 | "Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br /> |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | |
15 | 15 | $no_data = array('user' => false, 'planet' => false, 'que' => false); |
16 | 16 | |
17 | - if(!$planet) { |
|
17 | + if (!$planet) { |
|
18 | 18 | return $no_data; |
19 | 19 | } |
20 | 20 | |
21 | - if(!$no_user_update) { |
|
21 | + if (!$no_user_update) { |
|
22 | 22 | $user = intval(is_array($user) && $user['id'] ? $user['id'] : $user); |
23 | - if(!$user) { |
|
23 | + if (!$user) { |
|
24 | 24 | // TODO - Убрать позже |
25 | 25 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sys_o_get_updated() - USER пустой!</h1>'); |
26 | 26 | $backtrace = debug_backtrace(); |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | $user = db_user_by_id($user, !$simulation, '*', true); |
33 | 33 | } |
34 | 34 | |
35 | - if(empty($user['id'])) { |
|
35 | + if (empty($user['id'])) { |
|
36 | 36 | return $no_data; |
37 | 37 | } |
38 | 38 | |
39 | - if(is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) { |
|
39 | + if (is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) { |
|
40 | 40 | $planet = db_planet_by_vector($planet, '', !$simulation); |
41 | 41 | } else { |
42 | 42 | $planet = intval(is_array($planet) && isset($planet['id']) ? $planet['id'] : $planet); |
43 | 43 | $planet = db_planet_by_id($planet, !$simulation); |
44 | 44 | } |
45 | - if(!is_array($planet) || !isset($planet['id'])) { |
|
45 | + if (!is_array($planet) || !isset($planet['id'])) { |
|
46 | 46 | return $no_data; |
47 | 47 | } |
48 | 48 | |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | RES_DEUTERIUM => 0, |
66 | 66 | ); |
67 | 67 | |
68 | - switch($planet['planet_type']) { |
|
68 | + switch ($planet['planet_type']) { |
|
69 | 69 | case PT_PLANET: |
70 | - foreach($resources_increase as $resource_id => &$increment) { |
|
70 | + foreach ($resources_increase as $resource_id => &$increment) { |
|
71 | 71 | $resource_name = pname_resource_name($resource_id); |
72 | 72 | $increment = $caps_real['total'][$resource_id] * $ProductionTime / 3600; |
73 | 73 | $store_free = $caps_real['total_storage'][$resource_id] - $planet[$resource_name]; |
74 | 74 | $increment = min($increment, max(0, $store_free)); |
75 | 75 | |
76 | - if($planet[$resource_name] + $increment < 0 && !$simulation) { |
|
76 | + if ($planet[$resource_name] + $increment < 0 && !$simulation) { |
|
77 | 77 | global $debug; |
78 | 78 | $debug->warning("Player ID {$user['id']} have negative resources on ID {$planet['id']}.{$planet['planet_type']} [{$planet['galaxy']}:{$planet['system']}:{$planet['planet']}]. Difference {$planet[$resource_name]} of {$resource_name}", 'Negative Resources', 501); |
79 | 79 | } |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | // TODO пересчитывать размер планеты только при постройке чего-нибудь и при покупке сектора |
96 | 96 | $planet['field_current'] = 0; |
97 | 97 | $sn_group_build_allow = sn_get_groups('build_allow'); |
98 | - if(is_array($sn_group_build_allow[$planet['planet_type']])) { |
|
99 | - foreach($sn_group_build_allow[$planet['planet_type']] as $building_id) { |
|
98 | + if (is_array($sn_group_build_allow[$planet['planet_type']])) { |
|
99 | + foreach ($sn_group_build_allow[$planet['planet_type']] as $building_id) { |
|
100 | 100 | $planet['field_current'] += mrc_get_level($user, $planet, $building_id, !$simulation, true); |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - if($simulation) { |
|
104 | + if ($simulation) { |
|
105 | 105 | return array('user' => $user, 'planet' => $planet, 'que' => $que); |
106 | 106 | } |
107 | 107 |
@@ -12,34 +12,34 @@ discard block |
||
12 | 12 | |
13 | 13 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
14 | 14 | |
15 | - if($in_admin) |
|
15 | + if ($in_admin) |
|
16 | 16 | { |
17 | 17 | $quest_id = sys_get_param_id('id'); |
18 | 18 | $quest_name = sys_get_param_str_unsafe('QUEST_NAME'); |
19 | - if(!empty($quest_name)) |
|
19 | + if (!empty($quest_name)) |
|
20 | 20 | { |
21 | 21 | $quest_description = sys_get_param_str_unsafe('QUEST_DESCRIPTION'); |
22 | 22 | try |
23 | 23 | { |
24 | 24 | $quest_rewards_list = sys_get_param('QUEST_REWARDS_LIST'); |
25 | 25 | $quest_rewards = array(); |
26 | - foreach($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) |
|
26 | + foreach ($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) |
|
27 | 27 | { |
28 | - if(!in_array($quest_rewards_id, $quest_reward_allowed)) |
|
28 | + if (!in_array($quest_rewards_id, $quest_reward_allowed)) |
|
29 | 29 | { |
30 | 30 | throw new Exception($lang['qst_adm_err_reward_type']); |
31 | 31 | } |
32 | 32 | |
33 | - if($quest_rewards_amount < 0) |
|
33 | + if ($quest_rewards_amount < 0) |
|
34 | 34 | { |
35 | 35 | throw new Exception($lang['qst_adm_err_reward_amount']); |
36 | 36 | } |
37 | - elseif($quest_rewards_amount > 0) |
|
37 | + elseif ($quest_rewards_amount > 0) |
|
38 | 38 | { |
39 | 39 | $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}"; |
40 | 40 | } |
41 | 41 | } |
42 | - if(empty($quest_rewards)) |
|
42 | + if (empty($quest_rewards)) |
|
43 | 43 | { |
44 | 44 | throw new Exception($lang['qst_adm_err_reward_empty']); |
45 | 45 | } |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | $quest_rewards = implode(';', $quest_rewards); |
48 | 48 | |
49 | 49 | $quest_unit_id = sys_get_param_int('QUEST_UNIT_ID'); |
50 | - if(!in_array($quest_unit_id, $quest_units_allowed)) |
|
50 | + if (!in_array($quest_unit_id, $quest_units_allowed)) |
|
51 | 51 | { |
52 | 52 | throw new Exception($lang['qst_adm_err_unit_id']); |
53 | 53 | } |
54 | 54 | |
55 | 55 | $quest_unit_amount = sys_get_param_float('QUEST_UNIT_AMOUNT'); |
56 | - if($quest_unit_amount <= 0) |
|
56 | + if ($quest_unit_amount <= 0) |
|
57 | 57 | { |
58 | 58 | throw new Exception($lang['qst_adm_err_unit_amount']); |
59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // TODO: Change quest type |
63 | 63 | $quest_type = 0; |
64 | 64 | |
65 | - if($mode == 'edit') |
|
65 | + if ($mode == 'edit') |
|
66 | 66 | { |
67 | 67 | $quest_name = db_escape($quest_name); |
68 | 68 | $quest_description = db_escape($quest_description); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $mode = ''; |
104 | 104 | }; |
105 | 105 | |
106 | - switch($mode) |
|
106 | + switch ($mode) |
|
107 | 107 | { |
108 | 108 | case 'del': |
109 | 109 | doquery("DELETE FROM {{quest}} WHERE `quest_id` = {$quest_id} LIMIT 1;"); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $query = doquery("SELECT count(*) AS count FROM {{quest}};", '', true); |
121 | 121 | $config->db_saveItem('quest_total', $query['count']); |
122 | 122 | } |
123 | - elseif(!$user_id) |
|
123 | + elseif (!$user_id) |
|
124 | 124 | { |
125 | 125 | $user_id = $user['id']; |
126 | 126 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | 'IN_ADMIN' => $in_admin, |
135 | 135 | )); |
136 | 136 | |
137 | - if($quest) |
|
137 | + if ($quest) |
|
138 | 138 | { |
139 | 139 | $quest_templatized = qst_templatize(qst_quest_parse($quest, false)); |
140 | 140 | } |
@@ -143,19 +143,19 @@ discard block |
||
143 | 143 | $quest_templatized['quest_rewards_list'] = array(); |
144 | 144 | } |
145 | 145 | |
146 | - foreach($quest_reward_allowed as $unit_id) |
|
146 | + foreach ($quest_reward_allowed as $unit_id) |
|
147 | 147 | { |
148 | 148 | $found = false; |
149 | - foreach($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) |
|
149 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) |
|
150 | 150 | { |
151 | - if($quest_templatized_reward['ID'] == $unit_id) |
|
151 | + if ($quest_templatized_reward['ID'] == $unit_id) |
|
152 | 152 | { |
153 | 153 | $found = true; |
154 | 154 | break; |
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | - if(!$found) |
|
158 | + if (!$found) |
|
159 | 159 | { |
160 | 160 | $quest_templatized['quest_rewards_list'][$unit_id] = array( |
161 | 161 | 'ID' => $unit_id, |
@@ -167,12 +167,12 @@ discard block |
||
167 | 167 | |
168 | 168 | qst_assign_to_template($template, $quest_templatized); |
169 | 169 | |
170 | - foreach($quest_list as $quest_data) |
|
170 | + foreach ($quest_list as $quest_data) |
|
171 | 171 | { |
172 | 172 | qst_assign_to_template($template, qst_templatize($quest_data, true), 'quest'); |
173 | 173 | } |
174 | 174 | |
175 | - foreach($quest_units_allowed as $unit_id) |
|
175 | + foreach ($quest_units_allowed as $unit_id) |
|
176 | 176 | { |
177 | 177 | $template->assign_block_vars('allowed_unit', array( |
178 | 178 | 'ID' => $unit_id, |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | { |
186 | 186 | $quest_list = array(); |
187 | 187 | |
188 | - if($user_id) |
|
188 | + if ($user_id) |
|
189 | 189 | { |
190 | - if($status !== false) |
|
190 | + if ($status !== false) |
|
191 | 191 | { |
192 | 192 | $query_add_where = "AND qs.quest_status_status "; |
193 | - if($status == null) |
|
193 | + if ($status == null) |
|
194 | 194 | { |
195 | 195 | $query_add_where .= "IS NULL"; |
196 | 196 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | ;" |
211 | 211 | ); |
212 | 212 | |
213 | - while($quest = db_fetch($query)) |
|
213 | + while ($quest = db_fetch($query)) |
|
214 | 214 | { |
215 | 215 | $quest_list[$quest['quest_id']] = qst_quest_parse($quest); |
216 | 216 | } |
@@ -220,16 +220,16 @@ discard block |
||
220 | 220 | |
221 | 221 | function qst_assign_to_template(&$template, $quest_templatized, $block_name = false) |
222 | 222 | { |
223 | - if($block_name) |
|
223 | + if ($block_name) |
|
224 | 224 | { |
225 | 225 | $template->assign_block_vars($block_name, $quest_templatized); |
226 | 226 | } |
227 | 227 | else |
228 | 228 | { |
229 | 229 | $template->assign_vars($quest_templatized); |
230 | - if(!empty($quest_templatized['quest_rewards_list'])) |
|
230 | + if (!empty($quest_templatized['quest_rewards_list'])) |
|
231 | 231 | { |
232 | - foreach($quest_templatized['quest_rewards_list'] as $quest_reward) |
|
232 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) |
|
233 | 233 | { |
234 | 234 | $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward); |
235 | 235 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | global $lang; |
252 | 252 | |
253 | 253 | $tmp = array(); |
254 | - foreach($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) |
|
254 | + foreach ($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) |
|
255 | 255 | { |
256 | 256 | $tmp[] = array( |
257 | 257 | 'ID' => $quest_reward_id, |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | function qst_active_triggers($quest_list) |
279 | 279 | { |
280 | 280 | $quest_triggers = array(); |
281 | - foreach($quest_list as $quest_id => $quest) |
|
281 | + foreach ($quest_list as $quest_id => $quest) |
|
282 | 282 | { |
283 | - if($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) |
|
283 | + if ($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) |
|
284 | 284 | { |
285 | 285 | list($quest_unit_id, $quest_unit_amount) = explode(',', $quest['quest_conditions']); |
286 | 286 | $quest_triggers[$quest_id] = $quest_unit_id; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | function qst_reward(&$user, &$rewards, &$quest_list) |
294 | 294 | { |
295 | - if(empty($rewards)) return; |
|
295 | + if (empty($rewards)) return; |
|
296 | 296 | |
297 | 297 | global $lang; |
298 | 298 | |
@@ -300,15 +300,15 @@ discard block |
||
300 | 300 | $total_rewards = array(); |
301 | 301 | $comment_dm = ''; |
302 | 302 | |
303 | - foreach($rewards as $quest_id => $user_data) |
|
304 | - foreach($user_data as $user_id => $planet_data) |
|
305 | - foreach($planet_data as $planet_id => $reward_list) |
|
303 | + foreach ($rewards as $quest_id => $user_data) |
|
304 | + foreach ($user_data as $user_id => $planet_data) |
|
305 | + foreach ($planet_data as $planet_id => $reward_list) |
|
306 | 306 | { |
307 | 307 | $comment = sprintf($lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']); |
308 | 308 | $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : ''; |
309 | 309 | |
310 | 310 | $comment_reward = array(); |
311 | - foreach($reward_list as $unit_id => $unit_amount) |
|
311 | + foreach ($reward_list as $unit_id => $unit_amount) |
|
312 | 312 | { |
313 | 313 | $comment_reward[] = $unit_amount . ' ' . $lang['tech'][$unit_id]; |
314 | 314 | $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount; |
@@ -326,23 +326,23 @@ discard block |
||
326 | 326 | |
327 | 327 | $group_resources = sn_get_groups('resources_loot'); |
328 | 328 | $quest_rewards_allowed = sn_get_groups('quest_rewards'); |
329 | - if(!empty($total_rewards)) |
|
329 | + if (!empty($total_rewards)) |
|
330 | 330 | { |
331 | - foreach($total_rewards as $user_id => $planet_data) |
|
331 | + foreach ($total_rewards as $user_id => $planet_data) |
|
332 | 332 | { |
333 | 333 | $user_row = classSupernova::db_get_record_by_id(LOC_USER, $user_id); |
334 | - foreach($planet_data as $planet_id => $unit_data) |
|
334 | + foreach ($planet_data as $planet_id => $unit_data) |
|
335 | 335 | { |
336 | 336 | $local_changeset = array(); |
337 | - foreach($unit_data as $unit_id => $unit_amount) |
|
337 | + foreach ($unit_data as $unit_id => $unit_amount) |
|
338 | 338 | { |
339 | - if(!isset($quest_rewards_allowed[$unit_id])) continue; |
|
339 | + if (!isset($quest_rewards_allowed[$unit_id])) continue; |
|
340 | 340 | |
341 | - if($unit_id == RES_DARK_MATTER) |
|
341 | + if ($unit_id == RES_DARK_MATTER) |
|
342 | 342 | { |
343 | 343 | rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm); |
344 | 344 | } |
345 | - elseif(isset($group_resources[$unit_id])) |
|
345 | + elseif (isset($group_resources[$unit_id])) |
|
346 | 346 | { |
347 | 347 | $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount); |
348 | 348 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | // unit |
354 | 354 | } |
355 | 355 | |
356 | - if(!empty($local_changeset)) |
|
356 | + if (!empty($local_changeset)) |
|
357 | 357 | { |
358 | 358 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
359 | 359 | $db_changeset[$planet_id ? 'planets' : 'users'][] = array( |
@@ -33,8 +33,7 @@ discard block |
||
33 | 33 | if($quest_rewards_amount < 0) |
34 | 34 | { |
35 | 35 | throw new Exception($lang['qst_adm_err_reward_amount']); |
36 | - } |
|
37 | - elseif($quest_rewards_amount > 0) |
|
36 | + } elseif($quest_rewards_amount > 0) |
|
38 | 37 | { |
39 | 38 | $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}"; |
40 | 39 | } |
@@ -75,8 +74,7 @@ discard block |
||
75 | 74 | `quest_rewards` = '{$quest_rewards}' |
76 | 75 | WHERE `quest_id` = {$quest_id} LIMIT 1;" |
77 | 76 | ); |
78 | - } |
|
79 | - else |
|
77 | + } else |
|
80 | 78 | { |
81 | 79 | sn_db_perform('{{quest}}', array( |
82 | 80 | 'quest_name' => $quest_name, |
@@ -94,8 +92,7 @@ discard block |
||
94 | 92 | msg_send_simple_message('*', 0, 0, MSG_TYPE_PLAYER, $lang['sys_administration'], $lang['news_title'], $text); |
95 | 93 | } |
96 | 94 | */ |
97 | - } |
|
98 | - catch (Exception $e) |
|
95 | + } catch (Exception $e) |
|
99 | 96 | { |
100 | 97 | message($e->getMessage(), $lang['sys_error']); |
101 | 98 | } |
@@ -119,8 +116,7 @@ discard block |
||
119 | 116 | } |
120 | 117 | $query = doquery("SELECT count(*) AS count FROM {{quest}};", '', true); |
121 | 118 | $config->db_saveItem('quest_total', $query['count']); |
122 | - } |
|
123 | - elseif(!$user_id) |
|
119 | + } elseif(!$user_id) |
|
124 | 120 | { |
125 | 121 | $user_id = $user['id']; |
126 | 122 | } |
@@ -137,8 +133,7 @@ discard block |
||
137 | 133 | if($quest) |
138 | 134 | { |
139 | 135 | $quest_templatized = qst_templatize(qst_quest_parse($quest, false)); |
140 | - } |
|
141 | - else |
|
136 | + } else |
|
142 | 137 | { |
143 | 138 | $quest_templatized['quest_rewards_list'] = array(); |
144 | 139 | } |
@@ -193,8 +188,7 @@ discard block |
||
193 | 188 | if($status == null) |
194 | 189 | { |
195 | 190 | $query_add_where .= "IS NULL"; |
196 | - } |
|
197 | - else |
|
191 | + } else |
|
198 | 192 | { |
199 | 193 | $query_add_where .= "= {$status}"; |
200 | 194 | } |
@@ -223,8 +217,7 @@ discard block |
||
223 | 217 | if($block_name) |
224 | 218 | { |
225 | 219 | $template->assign_block_vars($block_name, $quest_templatized); |
226 | - } |
|
227 | - else |
|
220 | + } else |
|
228 | 221 | { |
229 | 222 | $template->assign_vars($quest_templatized); |
230 | 223 | if(!empty($quest_templatized['quest_rewards_list'])) |
@@ -292,7 +285,9 @@ discard block |
||
292 | 285 | |
293 | 286 | function qst_reward(&$user, &$rewards, &$quest_list) |
294 | 287 | { |
295 | - if(empty($rewards)) return; |
|
288 | + if(empty($rewards)) { |
|
289 | + return; |
|
290 | + } |
|
296 | 291 | |
297 | 292 | global $lang; |
298 | 293 | |
@@ -300,11 +295,12 @@ discard block |
||
300 | 295 | $total_rewards = array(); |
301 | 296 | $comment_dm = ''; |
302 | 297 | |
303 | - foreach($rewards as $quest_id => $user_data) |
|
304 | - foreach($user_data as $user_id => $planet_data) |
|
298 | + foreach($rewards as $quest_id => $user_data) { |
|
299 | + foreach($user_data as $user_id => $planet_data) |
|
305 | 300 | foreach($planet_data as $planet_id => $reward_list) |
306 | 301 | { |
307 | 302 | $comment = sprintf($lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']); |
303 | + } |
|
308 | 304 | $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : ''; |
309 | 305 | |
310 | 306 | $comment_reward = array(); |
@@ -336,17 +332,17 @@ discard block |
||
336 | 332 | $local_changeset = array(); |
337 | 333 | foreach($unit_data as $unit_id => $unit_amount) |
338 | 334 | { |
339 | - if(!isset($quest_rewards_allowed[$unit_id])) continue; |
|
335 | + if(!isset($quest_rewards_allowed[$unit_id])) { |
|
336 | + continue; |
|
337 | + } |
|
340 | 338 | |
341 | 339 | if($unit_id == RES_DARK_MATTER) |
342 | 340 | { |
343 | 341 | rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm); |
344 | - } |
|
345 | - elseif(isset($group_resources[$unit_id])) |
|
342 | + } elseif(isset($group_resources[$unit_id])) |
|
346 | 343 | { |
347 | 344 | $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount); |
348 | - } |
|
349 | - else // Проверим на юниты |
|
345 | + } else // Проверим на юниты |
|
350 | 346 | { |
351 | 347 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, $unit_amount, $user_row, $planet_id); |
352 | 348 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | function eco_get_planet_caps_modify_production(&$item, $key, $data) { |
4 | 4 | static $modifiers; |
5 | 5 | |
6 | - if(!$modifiers) { |
|
6 | + if (!$modifiers) { |
|
7 | 7 | $modifiers = sn_get_groups('modifiers'); |
8 | 8 | } |
9 | 9 | $item = floor(mrc_modify_value($data['user'], $data['planet'], $modifiers[MODIFIER_RESOURCE_PRODUCTION], $item)); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | static $sn_group_modifiers, $config_resource_multiplier, $config_resource_multiplier_plain, $config_eco_scale_storage; |
17 | 17 | |
18 | - if(!$sn_group_modifiers) { |
|
18 | + if (!$sn_group_modifiers) { |
|
19 | 19 | $sn_group_modifiers = sn_get_groups('modifiers'); |
20 | 20 | $config_resource_multiplier = game_resource_multiplier(); |
21 | 21 | $config_resource_multiplier_plain = game_resource_multiplier(true); |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | $caps['storage'][RES_METAL][0] = $config->eco_planet_storage_metal; |
27 | 27 | $caps['storage'][RES_CRYSTAL][0] = $config->eco_planet_storage_crystal; |
28 | 28 | $caps['storage'][RES_DEUTERIUM][0] = $config->eco_planet_storage_deuterium; |
29 | - foreach(sn_get_groups('storages') as $unit_id) { |
|
30 | - foreach(get_unit_param($unit_id, P_STORAGE) as $resource_id => $function) { |
|
29 | + foreach (sn_get_groups('storages') as $unit_id) { |
|
30 | + foreach (get_unit_param($unit_id, P_STORAGE) as $resource_id => $function) { |
|
31 | 31 | $caps['storage'][$resource_id][$unit_id] = floor($config_eco_scale_storage * |
32 | 32 | mrc_modify_value($user, $planet_row, $sn_group_modifiers[MODIFIER_RESOURCE_CAPACITY], $function(mrc_get_level($user, $planet_row, $unit_id))) |
33 | 33 | ); |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | - if($planet_row['planet_type'] == PT_MOON) { |
|
37 | + if ($planet_row['planet_type'] == PT_MOON) { |
|
38 | 38 | return $caps; |
39 | 39 | } |
40 | 40 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | $caps['production_full'][RES_DEUTERIUM][0] = floor($config->deuterium_basic_income * $config_resource_multiplier * (isset($planet_density[RES_DEUTERIUM]) ? $planet_density[RES_DEUTERIUM] : 1)); |
47 | 47 | $caps['production_full'][RES_ENERGY][0] = floor($config->energy_basic_income * $config_resource_multiplier_plain * (isset($planet_density[RES_ENERGY]) ? $planet_density[RES_ENERGY] : 1)); |
48 | 48 | |
49 | - foreach(sn_get_groups('factories') as $unit_id) { |
|
49 | + foreach (sn_get_groups('factories') as $unit_id) { |
|
50 | 50 | $unit_data = get_unit_param($unit_id); |
51 | 51 | $unit_level = mrc_get_level($user, $planet_row, $unit_id); |
52 | 52 | $unit_load = $planet_row[pname_factory_production_field_name($unit_id)]; |
53 | 53 | |
54 | - foreach($unit_data[P_UNIT_PRODUCTION] as $resource_id => $function) { |
|
54 | + foreach ($unit_data[P_UNIT_PRODUCTION] as $resource_id => $function) { |
|
55 | 55 | $caps['production_full'][$resource_id][$unit_id] = $function($unit_level, $unit_load, $user, $planet_row) |
56 | 56 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
57 | 57 | * (isset($planet_density[$resource_id]) ? $planet_density[$resource_id] : 1); |
@@ -60,21 +60,21 @@ discard block |
||
60 | 60 | |
61 | 61 | array_walk_recursive($caps['production_full'], 'eco_get_planet_caps_modify_production', array('user' => $user, 'planet' => $planet_row)); |
62 | 62 | |
63 | - foreach($caps['production_full'] as $resource_id => $resource_data) { |
|
63 | + foreach ($caps['production_full'] as $resource_id => $resource_data) { |
|
64 | 64 | $caps['total_production_full'][$resource_id] = array_sum($resource_data); |
65 | 65 | } |
66 | 66 | |
67 | 67 | $caps['production'] = $caps['production_full']; |
68 | 68 | |
69 | - if($caps['production'][RES_ENERGY][STRUC_MINE_FUSION]) { |
|
69 | + if ($caps['production'][RES_ENERGY][STRUC_MINE_FUSION]) { |
|
70 | 70 | $deuterium_balance = array_sum($caps['production'][RES_DEUTERIUM]); |
71 | 71 | $energy_balance = array_sum($caps['production'][RES_ENERGY]); |
72 | - if($deuterium_balance < 0 || $energy_balance < 0) { |
|
72 | + if ($deuterium_balance < 0 || $energy_balance < 0) { |
|
73 | 73 | $caps['production'][RES_DEUTERIUM][STRUC_MINE_FUSION] = $caps['production'][RES_ENERGY][STRUC_MINE_FUSION] = 0; |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - foreach($caps['production'][RES_ENERGY] as $energy) { |
|
77 | + foreach ($caps['production'][RES_ENERGY] as $energy) { |
|
78 | 78 | $caps[RES_ENERGY][$energy >= 0 ? BUILD_CREATE : BUILD_DESTROY] += $energy; |
79 | 79 | } |
80 | 80 | |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | ? $caps[RES_ENERGY][BUILD_CREATE] / $caps[RES_ENERGY][BUILD_DESTROY] |
85 | 85 | : 1; |
86 | 86 | |
87 | - foreach($caps['production'] as $resource_id => &$resource_data) { |
|
88 | - if($caps['efficiency'] != 1) { |
|
89 | - foreach($resource_data as $unit_id => &$resource_production) { |
|
90 | - if(!($unit_id == STRUC_MINE_FUSION && $resource_id == RES_DEUTERIUM) && $unit_id != 0 && !($resource_id == RES_ENERGY && $resource_production >= 0)) { |
|
87 | + foreach ($caps['production'] as $resource_id => &$resource_data) { |
|
88 | + if ($caps['efficiency'] != 1) { |
|
89 | + foreach ($resource_data as $unit_id => &$resource_production) { |
|
90 | + if (!($unit_id == STRUC_MINE_FUSION && $resource_id == RES_DEUTERIUM) && $unit_id != 0 && !($resource_id == RES_ENERGY && $resource_production >= 0)) { |
|
91 | 91 | $resource_production = $resource_production * $caps['efficiency']; |
92 | 92 | } |
93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $caps['total'][$resource_id] = $caps['total'][$resource_id] >= 0 ? floor($caps['total'][$resource_id]) : ceil($caps['total'][$resource_id]); |
97 | 97 | } |
98 | 98 | |
99 | - foreach($caps['storage'] as $resource_id => &$resource_data) { |
|
99 | + foreach ($caps['storage'] as $resource_id => &$resource_data) { |
|
100 | 100 | $caps['total_storage'][$resource_id] = array_sum($resource_data); |
101 | 101 | } |
102 | 102 |