@@ -7,9 +7,9 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -define('INSIDE' , true); |
|
11 | -define('INSTALL' , false); |
|
12 | -define('IN_ADMIN' , true); |
|
10 | +define('INSIDE', true); |
|
11 | +define('INSTALL', false); |
|
12 | +define('IN_ADMIN', true); |
|
13 | 13 | |
14 | 14 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
15 | 15 | |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | function adm_lng_assign_string($lang_id, $locale_string_name, $value) { |
21 | 21 | global $locale_string_template, $languages_info, $languages, $domain; |
22 | 22 | |
23 | - if(is_array($value)) { |
|
24 | - foreach($value as $sub_key => $sub_value) { |
|
23 | + if (is_array($value)) { |
|
24 | + foreach ($value as $sub_key => $sub_value) { |
|
25 | 25 | adm_lng_assign_string($lang_id, "{$locale_string_name}[{$sub_key}]", $sub_value); |
26 | 26 | } |
27 | - } elseif($value) { |
|
28 | - if(!isset($locale_string_template[$locale_string_name])) { |
|
27 | + } elseif ($value) { |
|
28 | + if (!isset($locale_string_template[$locale_string_name])) { |
|
29 | 29 | $locale_string_template[$locale_string_name] = array(); |
30 | 30 | } |
31 | 31 | $locale_string_template[$locale_string_name] = array_merge($locale_string_template[$locale_string_name], array("[{$lang_id}]" => htmlentities($value, ENT_COMPAT, 'utf-8'))); |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | global $domain, $lang_id; |
47 | 47 | |
48 | 48 | $return = "{$ident}'{$string_name}' => "; |
49 | - if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
49 | + if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
50 | 50 | $return .= "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',"; |
51 | 51 | } else { |
52 | 52 | $return .= "array(\r\n"; |
53 | - foreach($string_value as $arr_name => $arr_data) { |
|
53 | + foreach ($string_value as $arr_name => $arr_data) { |
|
54 | 54 | $return .= adm_lng_parse_string($arr_name, $arr_data, $ident . ' '); |
55 | 55 | } |
56 | 56 | $return .= "{$ident}),\r\n"; |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | |
104 | 104 | $string_name_new = false; |
105 | 105 | |
106 | - if(isset($honor_constants[$domain][$string_name_prefix])) { |
|
106 | + if (isset($honor_constants[$domain][$string_name_prefix])) { |
|
107 | 107 | $found_constants = array_keys($constants, $string_name); |
108 | - foreach($found_constants as $constant_name) { |
|
108 | + foreach ($found_constants as $constant_name) { |
|
109 | 109 | $honor_prefix_list = is_array($honor_constants[$domain][$string_name_prefix]) ? $honor_constants[$domain][$string_name_prefix] : array($honor_constants[$domain][$string_name_prefix]); |
110 | - foreach($honor_prefix_list as $honor_prefix) { |
|
111 | - if(strpos($constant_name, $honor_prefix) === 0) { |
|
110 | + foreach ($honor_prefix_list as $honor_prefix) { |
|
111 | + if (strpos($constant_name, $honor_prefix) === 0) { |
|
112 | 112 | $string_name_new = $constant_name; |
113 | 113 | break; |
114 | 114 | } |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | |
119 | 119 | $string_name_new = $string_name_new ? $string_name_new : "'{$string_name}'"; |
120 | 120 | fwrite($file_handler, "{$ident}{$string_name_new} => "); |
121 | - if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
121 | + if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
122 | 122 | fwrite($file_handler, "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',"); |
123 | 123 | // fwrite($file_handler, "'" . addslashes($string_value[$lang_id]) . "',"); |
124 | 124 | } else { |
125 | 125 | $string_name_prefix = $string_name_prefix . "[{$string_name}]"; |
126 | 126 | fwrite($file_handler, "array(\r\n"); |
127 | - foreach($string_value as $arr_name => $arr_data) { |
|
127 | + foreach ($string_value as $arr_name => $arr_data) { |
|
128 | 128 | adm_lng_write_string($arr_name, $arr_data, $ident . ' ', $string_name_prefix); |
129 | 129 | } |
130 | 130 | fwrite($file_handler, "{$ident}),\r\n"); |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | $languages_info = lng_get_list(); |
145 | 145 | $domain = sys_get_param_str('domain'); |
146 | 146 | |
147 | -if($domain) { |
|
147 | +if ($domain) { |
|
148 | 148 | $lang_new = sys_get_param('lang_new'); |
149 | - if(!empty($lang_new) && is_array($lang_new)) { |
|
149 | + if (!empty($lang_new) && is_array($lang_new)) { |
|
150 | 150 | $constants = get_defined_constants(true); |
151 | 151 | $constants = $constants['user']; |
152 | 152 | ksort($constants); |
153 | - foreach($languages_info as $lang_id => $land_data) { |
|
153 | + foreach ($languages_info as $lang_id => $land_data) { |
|
154 | 154 | $file_handler = fopen(SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php.new", 'w'); |
155 | 155 | fwrite($file_handler, "<?php\r\n\r\n/*\r\n############################################################################# |
156 | 156 | # Filename: {$domain}.mo.php |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | # Website: http://www.supernova.ws |
159 | 159 | # Description: Massive Multiplayer Online Browser Space Strategy Game\r\n#\r\n"); |
160 | 160 | |
161 | - foreach($land_data['LANG_COPYRIGHT'] as $lang_copyright) { |
|
161 | + foreach ($land_data['LANG_COPYRIGHT'] as $lang_copyright) { |
|
162 | 162 | $lang_copyright = str_replace(array('©', '"', '<', '>'), array('©', '"', '<', '>'), $lang_copyright); |
163 | 163 | fwrite($file_handler, "# {$lang_copyright}\r\n"); |
164 | 164 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | /**\r\n*\r\n* @package language\r\n* @system [{$land_data['LANG_NAME_ENGLISH']}]\r\n* @version " . SN_VERSION . "\r\n*\r\n*/\r\n |
167 | 167 | /**\r\n* DO NOT CHANGE\r\n*/\r\n\r\nif (!defined('INSIDE')) die();\r\n |
168 | 168 | \$a_lang_array = array(\r\n"); |
169 | - foreach($lang_new as $string_name => $string_value) { |
|
169 | + foreach ($lang_new as $string_name => $string_value) { |
|
170 | 170 | adm_lng_write_string($string_name, $string_value); |
171 | 171 | } |
172 | 172 | fwrite($file_handler, ");\r\n"); |
@@ -176,21 +176,21 @@ discard block |
||
176 | 176 | sys_redirect("admin_locale.php?domain={$domain}"); |
177 | 177 | } |
178 | 178 | |
179 | - foreach($languages_info as $lang_id => $lang_data) { |
|
179 | + foreach ($languages_info as $lang_id => $lang_data) { |
|
180 | 180 | $template->assign_block_vars('language', $lang_data); |
181 | 181 | $full_filename = SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php"; |
182 | 182 | $languages[$lang_id] = adm_lng_load($full_filename . (file_exists($full_filename . '.new') ? '.new' : '')); |
183 | - foreach($languages[$lang_id] as $locale_string_name => $cork) { |
|
183 | + foreach ($languages[$lang_id] as $locale_string_name => $cork) { |
|
184 | 184 | adm_lng_assign_string($lang_id, "[{$locale_string_name}]", $languages[$lang_id][$locale_string_name]); |
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - foreach($locale_string_template as $locale_string_name => $locale_string_list) { |
|
188 | + foreach ($locale_string_template as $locale_string_name => $locale_string_list) { |
|
189 | 189 | $template->assign_block_vars('string', array( |
190 | 190 | 'NAME' => $locale_string_name, |
191 | 191 | )); |
192 | 192 | |
193 | - foreach($languages_info as $lang_id => $cork2) { |
|
193 | + foreach ($languages_info as $lang_id => $cork2) { |
|
194 | 194 | $template->assign_block_vars('string.locale', array( |
195 | 195 | 'LANG' => $lang_id, |
196 | 196 | 'VALUE' => $locale_string_list["[{$lang_id}]"], |
@@ -206,17 +206,17 @@ discard block |
||
206 | 206 | $dir = dir($path); |
207 | 207 | while (false !== ($lang_id = $dir->read())) { |
208 | 208 | $full_path = $path . $lang_id; |
209 | - if($lang_id[0] != "." && is_dir($full_path)) { |
|
209 | + if ($lang_id[0] != "." && is_dir($full_path)) { |
|
210 | 210 | $lang_file_list = dir($full_path); |
211 | 211 | while (false !== ($filename = $lang_file_list->read())) { |
212 | 212 | $lang_domain = strtolower(substr($filename, 0, strpos($filename, '.'))); |
213 | - if(!$lang_domain) { |
|
213 | + if (!$lang_domain) { |
|
214 | 214 | continue; |
215 | 215 | } |
216 | 216 | |
217 | 217 | $file_ext = strtolower(substr($filename, strpos($filename, '.'))); |
218 | - if($lang_domain != 'language') { |
|
219 | - if($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) { |
|
218 | + if ($lang_domain != 'language') { |
|
219 | + if ($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) { |
|
220 | 220 | $language_domains[$lang_domain] = $lang_domain; |
221 | 221 | $languages[$lang_id][$lang_domain] = $lang_domain; |
222 | 222 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | $dir->close(); |
228 | 228 | |
229 | - foreach($language_domains as $lang_domain) { |
|
229 | + foreach ($language_domains as $lang_domain) { |
|
230 | 230 | $template->assign_block_vars('domain', array( |
231 | 231 | 'NAME' => $lang_domain, |
232 | 232 | )); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | define('SN_PAYMENT_REQUEST_OK', 0); |
16 | 16 | define('SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT', 1); |
17 | 17 | define('SN_PAYMENT_REQUEST_ERROR_PAYLINK_UNSUPPORTED', 2); |
18 | -define('SN_PAYMENT_REQUEST_IP_WRONG', 3); // Неправильный IP входящей системы - обычно хак |
|
18 | +define('SN_PAYMENT_REQUEST_IP_WRONG', 3); // Неправильный IP входящей системы - обычно хак |
|
19 | 19 | define('SN_PAYMENT_REQUEST_COMMAND_UNSUPPORTED', 4); // Неподдерживаемая команда - обычно хак |
20 | 20 | define('SN_PAYMENT_REQUEST_SIGNATURE_INVALID', 5); // Неправильная подпись или не сошлась контрольная сумма - обычно хак |
21 | 21 | define('SN_MODULE_DISABLED', 6); // Модуль отключен // УНИВЕРСАЛЬНЫЙ ОТВЕТ! |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function geometry_progression_sum($n, $b1, $q) { |
4 | - return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
|
4 | + return $q != 1 ? ($b1 * (pow($q, $n) - 1) / ($q - 1)) : ($n * $b1); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function sn_floor($value) |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return float|int |
45 | 45 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | - if($cut_extreme) { |
|
46 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | + if ($cut_extreme) { |
|
48 | 48 | $range_start--; |
49 | 49 | $range_end++; |
50 | 50 | } |
@@ -104,47 +104,47 @@ discard block |
||
104 | 104 | } |
105 | 105 | function linear_calc(&$linear, $from = 0, $debug = false) |
106 | 106 | { |
107 | - for($i = $from; $i < count($linear); $i++) |
|
107 | + for ($i = $from; $i < count($linear); $i++) |
|
108 | 108 | { |
109 | 109 | $eq = &$linear[$i]; |
110 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
110 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
111 | 111 | { |
112 | 112 | $eq[$j] /= $eq[$from]; |
113 | 113 | } |
114 | 114 | } |
115 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
115 | + if ($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
116 | 116 | |
117 | - for($i = $from + 1; $i < count($linear); $i++) |
|
117 | + for ($i = $from + 1; $i < count($linear); $i++) |
|
118 | 118 | { |
119 | 119 | $eq = &$linear[$i]; |
120 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
120 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
121 | 121 | { |
122 | 122 | $eq[$j] -= $linear[$from][$j]; |
123 | 123 | } |
124 | 124 | } |
125 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
125 | + if ($debug) pdump($linear, 'Подставили х' . $from); |
|
126 | 126 | |
127 | - if($from < count($linear) - 1) |
|
127 | + if ($from < count($linear) - 1) |
|
128 | 128 | { |
129 | 129 | linear_calc($linear, $from + 1, $debug); |
130 | 130 | } |
131 | 131 | |
132 | - if($from) |
|
132 | + if ($from) |
|
133 | 133 | { |
134 | - for($i = 0; $i < $from; $i++) |
|
134 | + for ($i = 0; $i < $from; $i++) |
|
135 | 135 | { |
136 | 136 | $eq = &$linear[$i]; |
137 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
137 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
138 | 138 | { |
139 | 139 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
140 | 140 | } |
141 | 141 | } |
142 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
142 | + if ($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
143 | 143 | } |
144 | 144 | else |
145 | 145 | { |
146 | - if($debug) pdump($linear, 'Результат' . $from); |
|
147 | - foreach($linear as $index => &$eq) |
|
146 | + if ($debug) pdump($linear, 'Результат' . $from); |
|
147 | + foreach ($linear as $index => &$eq) |
|
148 | 148 | { |
149 | 149 | pdump($eq[count($linear)], 'x' . $index); |
150 | 150 | } |
@@ -4,16 +4,14 @@ discard block |
||
4 | 4 | return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
5 | 5 | } |
6 | 6 | |
7 | -function sn_floor($value) |
|
8 | -{ |
|
7 | +function sn_floor($value) { |
|
9 | 8 | return $value >= 0 ? floor($value) : ceil($value); |
10 | 9 | } |
11 | 10 | |
12 | 11 | // Эта функция выдает нормально распределенное случайное число с матожиднием $mu и стандартным отклонением $sigma |
13 | 12 | // $strict - количество $sigma, по которым идет округление функции. Т.е. $strict = 3 означает, что диапазон значений обрезается по +-3 * $sigma |
14 | 13 | // Используется http://ru.wikipedia.org/wiki/Преобразование_Бокса_—_Мюллера |
15 | -function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) |
|
16 | -{ |
|
14 | +function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) { |
|
17 | 15 | // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение |
18 | 16 | // При $mu = 0 (график симметричный, цифры только для половины графика) |
19 | 17 | // От 0 до $sigma ~ 34.1% |
@@ -43,7 +41,7 @@ discard block |
||
43 | 41 | * |
44 | 42 | * @return float|int |
45 | 43 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
44 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | 45 | if($cut_extreme) { |
48 | 46 | $range_start--; |
49 | 47 | $range_end++; |
@@ -98,12 +96,10 @@ discard block |
||
98 | 96 | * |
99 | 97 | * @return float |
100 | 98 | */ |
101 | -function avg($array) |
|
102 | -{ |
|
99 | +function avg($array) { |
|
103 | 100 | return is_array($array) && count($array) ? array_sum($array) / count($array) : 0; |
104 | 101 | } |
105 | -function linear_calc(&$linear, $from = 0, $debug = false) |
|
106 | -{ |
|
102 | +function linear_calc(&$linear, $from = 0, $debug = false) { |
|
107 | 103 | for($i = $from; $i < count($linear); $i++) |
108 | 104 | { |
109 | 105 | $eq = &$linear[$i]; |
@@ -112,7 +108,9 @@ discard block |
||
112 | 108 | $eq[$j] /= $eq[$from]; |
113 | 109 | } |
114 | 110 | } |
115 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
111 | + if($debug) { |
|
112 | + pdump($linear, 'Нормализовано по х' . $from); |
|
113 | + } |
|
116 | 114 | |
117 | 115 | for($i = $from + 1; $i < count($linear); $i++) |
118 | 116 | { |
@@ -122,7 +120,9 @@ discard block |
||
122 | 120 | $eq[$j] -= $linear[$from][$j]; |
123 | 121 | } |
124 | 122 | } |
125 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
123 | + if($debug) { |
|
124 | + pdump($linear, 'Подставили х' . $from); |
|
125 | + } |
|
126 | 126 | |
127 | 127 | if($from < count($linear) - 1) |
128 | 128 | { |
@@ -139,11 +139,14 @@ discard block |
||
139 | 139 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
140 | 140 | } |
141 | 141 | } |
142 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
143 | - } |
|
144 | - else |
|
142 | + if($debug) { |
|
143 | + pdump($linear, 'Подставили обратно х' . $from); |
|
144 | + } |
|
145 | + } else |
|
145 | 146 | { |
146 | - if($debug) pdump($linear, 'Результат' . $from); |
|
147 | + if($debug) { |
|
148 | + pdump($linear, 'Результат' . $from); |
|
149 | + } |
|
147 | 150 | foreach($linear as $index => &$eq) |
148 | 151 | { |
149 | 152 | pdump($eq[count($linear)], 'x' . $index); |
@@ -2,12 +2,10 @@ |
||
2 | 2 | |
3 | 3 | // Эти функции будут переписаны по добавлению инфы в БД |
4 | 4 | |
5 | -function pname_factory_production_field_name($factory_unit_id) |
|
6 | -{ |
|
5 | +function pname_factory_production_field_name($factory_unit_id) { |
|
7 | 6 | return get_unit_param($factory_unit_id, P_NAME) . '_porcent'; |
8 | 7 | } |
9 | 8 | |
10 | -function pname_resource_name($resource_id) |
|
11 | -{ |
|
9 | +function pname_resource_name($resource_id) { |
|
12 | 10 | return get_unit_param($resource_id, P_NAME); |
13 | 11 | } |
14 | 12 | \ No newline at end of file |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | |
272 | 272 | |
273 | 273 | if (($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
274 | - if(!empty($render_user['user_birthday'])) { |
|
274 | + if (!empty($render_user['user_birthday'])) { |
|
275 | 275 | $result[NICK_BIRTHDAY] = ''; |
276 | 276 | } |
277 | 277 | } |
@@ -283,13 +283,13 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
286 | - if(isset($render_user['vacation'])) { |
|
286 | + if (isset($render_user['vacation'])) { |
|
287 | 287 | $result[NICK_VACATION] = $render_user['vacation']; |
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
291 | 291 | if ($options === true || !empty($options['icons']) || !empty($options['player_rank'])) { |
292 | - if(isset($render_user['total_points'])) { |
|
292 | + if (isset($render_user['total_points'])) { |
|
293 | 293 | $result[NICK_RANK] = SN::$gc->playerLevelHelper->getPointLevel($render_user['total_points'], $render_user['authlevel']); |
294 | 294 | } |
295 | 295 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
316 | - if(isset($render_user['ally_tag'])) { |
|
316 | + if (isset($render_user['ally_tag'])) { |
|
317 | 317 | $result[NICK_ALLY] = $render_user['ally_tag']; |
318 | 318 | } |
319 | 319 | } |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
113 | 113 | if (preg_match($rexep, $date, $out)) { |
114 | 114 | $ret = array( |
115 | - "tm_sec" => (int)$out['S'], |
|
116 | - "tm_min" => (int)$out['M'], |
|
117 | - "tm_hour" => (int)$out['H'], |
|
118 | - "tm_mday" => (int)$out['d'], |
|
115 | + "tm_sec" => (int) $out['S'], |
|
116 | + "tm_min" => (int) $out['M'], |
|
117 | + "tm_hour" => (int) $out['H'], |
|
118 | + "tm_mday" => (int) $out['d'], |
|
119 | 119 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
120 | 120 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
121 | 121 | ); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return int |
151 | 151 | */ |
152 | 152 | function datePart($fullDate) { |
153 | - return (int)strtotime(date('Y-m-d', $fullDate)); |
|
153 | + return (int) strtotime(date('Y-m-d', $fullDate)); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @return bool |
179 | 179 | * @throws ErrorException |
180 | 180 | */ |
181 | - function ($errno, $errstr, $errfile, $errline) { |
|
181 | + function($errno, $errstr, $errfile, $errline) { |
|
182 | 182 | throw new ErrorException($errstr, 0, $errno, $errfile, $errline); |
183 | 183 | } |
184 | 184 | ); |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | |
15 | 15 | $fleet_left = 1 - mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000; |
16 | 16 | $fleet_lost = array(); |
17 | - foreach($fleet as $unit_id => &$unit_amount) { |
|
17 | + foreach ($fleet as $unit_id => &$unit_amount) { |
|
18 | 18 | $ships_left = floor($unit_amount * $fleet_left); |
19 | 19 | $fleet_lost[$unit_id] = $unit_amount - $ships_left; |
20 | 20 | $unit_amount = $ships_left; |
21 | - if(!$unit_amount) { |
|
21 | + if (!$unit_amount) { |
|
22 | 22 | unset($fleet[$unit_id]); |
23 | 23 | } |
24 | 24 | } |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | // $fleet = array(); |
32 | 32 | } |
33 | 33 | |
34 | -function flt_mission_explore_addon(&$result){return sn_function_call('flt_mission_explore_addon', array(&$result));} |
|
34 | +function flt_mission_explore_addon(&$result) {return sn_function_call('flt_mission_explore_addon', array(&$result)); } |
|
35 | 35 | function sn_flt_mission_explore_addon(&$result) { |
36 | 36 | return $result; |
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | function flt_mission_explore(&$mission_data) { |
41 | - if(!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) { |
|
41 | + if (!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) { |
|
42 | 42 | return CACHE_NONE; |
43 | 43 | } |
44 | 44 | |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | $outcome_list = &$result['$outcome_list']; |
72 | 72 | $fleet_metal_points = &$result['$fleet_metal_points']; |
73 | 73 | |
74 | - if(!$ship_data) { |
|
75 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
74 | + if (!$ship_data) { |
|
75 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
76 | 76 | $unit_info = get_unit_param($unit_id); |
77 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
77 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
78 | 78 | continue; |
79 | 79 | } |
80 | 80 | $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $fleet = sys_unit_str2arr($fleet_row['fleet_array']); |
87 | 87 | $fleet_capacity = 0; |
88 | 88 | $fleet_metal_points = 0; |
89 | - foreach($fleet as $ship_id => $ship_amount) { |
|
89 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
90 | 90 | $unit_info = get_unit_param($ship_id); |
91 | 91 | $fleet_capacity += $ship_amount * $unit_info[P_CAPACITY]; |
92 | 92 | $fleet_metal_points += $ship_amount * $ship_data[$ship_id][P_COST_METAL]; |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | $flt_stay_hours = ($fleet_row['fleet_end_stay'] - $fleet_row['fleet_start_time']) / 3600 * ($config->game_speed_expedition ? $config->game_speed_expedition : 1); |
97 | 97 | |
98 | 98 | $outcome_list = sn_get_groups(GROUP_MISSION_EXPLORE_OUTCOMES); |
99 | - $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1/1.7)); |
|
99 | + $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
|
100 | 100 | |
101 | 101 | $chance_max = 0; |
102 | - foreach($outcome_list as $key => &$value) { |
|
103 | - if(!$value['chance']) { |
|
102 | + foreach ($outcome_list as $key => &$value) { |
|
103 | + if (!$value['chance']) { |
|
104 | 104 | unset($outcome_list[$key]); |
105 | 105 | continue; |
106 | 106 | } |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | $outcome_value = mt_rand(0, $chance_max); |
110 | 110 | // $outcome_value = 409; |
111 | 111 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
112 | - foreach($outcome_list as $key => &$value) { |
|
113 | - if(!$value['chance']) { |
|
112 | + foreach ($outcome_list as $key => &$value) { |
|
113 | + if (!$value['chance']) { |
|
114 | 114 | continue; |
115 | 115 | } |
116 | 116 | $mission_outcome = $key; |
117 | 117 | $outcome_description = $value; |
118 | - if($outcome_value <= $outcome_description['value']) { |
|
118 | + if ($outcome_value <= $outcome_description['value']) { |
|
119 | 119 | break; |
120 | 120 | } |
121 | 121 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $found_dark_matter = 0; |
132 | 132 | // $outcome_mission_sub = -1; |
133 | 133 | |
134 | - switch($mission_outcome) { |
|
134 | + switch ($mission_outcome) { |
|
135 | 135 | // switch(FLT_EXPEDITION_OUTCOME_LOST_FLEET) { // TODO DEBUG! |
136 | 136 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
137 | 137 | flt_mission_explore_outcome_lost_fleet($result); |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | |
167 | 167 | // Рассчитываем стоимость самого дорого корабля в металле |
168 | 168 | $max_metal_cost = 0; |
169 | - foreach($fleet as $ship_id => $ship_amount) { |
|
169 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
170 | 170 | $max_metal_cost = max($max_metal_cost, $ship_data[$ship_id]['metal_cost']); |
171 | 171 | } |
172 | 172 | |
173 | 173 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
174 | 174 | $can_be_found = array(); |
175 | - foreach($ship_data as $ship_id => $ship_info) { |
|
176 | - if( |
|
175 | + foreach ($ship_data as $ship_id => $ship_info) { |
|
176 | + if ( |
|
177 | 177 | $ship_info['metal_cost'] < $max_metal_cost |
178 | 178 | // and not race ship |
179 | 179 | && empty(get_unit_param($ship_id, 'player_race')) |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | unset($can_be_found[SHIP_SPY]); |
189 | 189 | |
190 | 190 | $fleet_found = array(); |
191 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
191 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
192 | 192 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
193 | 193 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
194 | 194 | $found_ship_cost = reset($found_ship); |
195 | 195 | $found_ship_id = key($found_ship); |
196 | 196 | |
197 | - if($found_ship_cost > $found_in_metal) { |
|
197 | + if ($found_ship_cost > $found_in_metal) { |
|
198 | 198 | unset($can_be_found[$found_ship_id]); |
199 | 199 | } else { |
200 | 200 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - if(empty($fleet_found)) { |
|
206 | + if (empty($fleet_found)) { |
|
207 | 207 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
208 | 208 | } else { |
209 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
209 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
210 | 210 | $fleet[$unit_id] += $unit_amount; |
211 | 211 | } |
212 | 212 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $fleet_row['fleet_resource_crystal'] += $resources_found[RES_CRYSTAL]; |
233 | 233 | $fleet_row['fleet_resource_deuterium'] += $resources_found[RES_DEUTERIUM]; |
234 | 234 | |
235 | - if(array_sum($resources_found) == 0) { |
|
235 | + if (array_sum($resources_found) == 0) { |
|
236 | 236 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
237 | 237 | } |
238 | 238 | break; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | // Рассчитываем количество найденной ТМ |
244 | 244 | $found_dark_matter = floor(min($outcome_percent * $fleet_metal_points / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
245 | 245 | |
246 | - if(!$found_dark_matter) { |
|
246 | + if (!$found_dark_matter) { |
|
247 | 247 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
248 | 248 | } |
249 | 249 | break; |
@@ -257,31 +257,31 @@ discard block |
||
257 | 257 | |
258 | 258 | flt_mission_explore_addon($result); |
259 | 259 | |
260 | - if($found_dark_matter) { |
|
260 | + if ($found_dark_matter) { |
|
261 | 261 | rpg_points_change($fleet_row['fleet_owner'], RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
262 | 262 | $msg_text_addon = sprintf($lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
263 | 263 | } |
264 | 264 | |
265 | - if(!empty($fleet_lost)) { |
|
265 | + if (!empty($fleet_lost)) { |
|
266 | 266 | $msg_text_addon = $lang['flt_mission_expedition']['lost_fleet']; |
267 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
267 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
268 | 268 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | 272 | $fleet_row['fleet_amount'] = array_sum($fleet); |
273 | - if(!empty($fleet) && $fleet_row['fleet_amount']) { |
|
274 | - if(!empty($fleet_found)) { |
|
273 | + if (!empty($fleet) && $fleet_row['fleet_amount']) { |
|
274 | + if (!empty($fleet_found)) { |
|
275 | 275 | $msg_text_addon = $lang['flt_mission_expedition']['found_fleet']; |
276 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
276 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
277 | 277 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | 281 | $query_delta = array(); |
282 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
282 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
283 | 283 | $msg_text_addon = $lang['flt_mission_expedition']['found_resources']; |
284 | - foreach($resources_found as $ship_id => $ship_amount) { |
|
284 | + foreach ($resources_found as $ship_id => $ship_amount) { |
|
285 | 285 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
286 | 286 | } |
287 | 287 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | } |
295 | 295 | |
296 | 296 | $query_data = array(); |
297 | - if(!empty($fleet_lost) || !empty($fleet_found)) { |
|
297 | + if (!empty($fleet_lost) || !empty($fleet_found)) { |
|
298 | 298 | $fleet_row['fleet_array'] = sys_unit_arr2str($fleet); |
299 | 299 | |
300 | 300 | // $query_data[] = "`fleet_amount` = {$fleet_row['fleet_amount']}"; |
@@ -322,17 +322,16 @@ discard block |
||
322 | 322 | |
323 | 323 | db_user_set_by_id($fleet_row['fleet_owner'], "`player_rpg_explore_xp` = `player_rpg_explore_xp` + 1"); |
324 | 324 | |
325 | - if(!$msg_text) { |
|
325 | + if (!$msg_text) { |
|
326 | 326 | $messages = &$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
327 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
327 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
328 | 328 | $messages = &$messages[$outcome_mission_sub]; |
329 | 329 | } |
330 | 330 | |
331 | - $msg_text = is_string($messages) ? $messages : |
|
332 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
331 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
333 | 332 | } |
334 | 333 | $msg_text = sprintf($msg_text, $fleet_row['fleet_id'], uni_render_coordinates($fleet_row, 'fleet_end_')) . |
335 | - ($msg_text_addon ? "\r\n" . $msg_text_addon: ''); |
|
334 | + ($msg_text_addon ? "\r\n" . $msg_text_addon : ''); |
|
336 | 335 | |
337 | 336 | msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_stay'], MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text); |
338 | 337 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | //while($CurrentFleet = db_fetch($FlyingFleets)) |
24 | 24 | |
25 | 25 | $all_flying_fleets = DbFleetStatic::db_fleet_list('', DB_SELECT_PLAIN); |
26 | -foreach($all_flying_fleets as $fleet_id => $CurrentFleet) { |
|
26 | +foreach ($all_flying_fleets as $fleet_id => $CurrentFleet) { |
|
27 | 27 | $FleetOwner = db_user_by_id($CurrentFleet['fleet_owner']); |
28 | 28 | $TargetOwner = db_user_by_id($CurrentFleet['fleet_target_owner']); |
29 | 29 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $fleet_data['fleet']['STAY_TIME_INT'] = $CurrentFleet['fleet_end_stay']; |
35 | 35 | |
36 | 36 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
37 | - foreach($fleet_data['ships'] as $ship_data) { |
|
37 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
38 | 38 | $template->assign_block_vars('fleets.ships', $ship_data); |
39 | 39 | } |
40 | 40 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | function flt_mission_destroy($mission_data) { |
11 | 11 | $fleet_row = $mission_data['fleet']; |
12 | 12 | $destination_planet = $mission_data['dst_planet']; |
13 | - if(!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { |
|
13 | + if (!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { |
|
14 | 14 | DbFleetStatic::fleet_send_back($fleet_row); |
15 | 15 | |
16 | 16 | return CACHE_FLEET; |