@@ -55,6 +55,9 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
| 58 | +/** |
|
| 59 | + * @param integer $build_mode |
|
| 60 | + */ |
|
| 58 | 61 | function que_build($user, $planet, $build_mode = BUILD_CREATE, $redirect = true) { |
| 59 | 62 | global $lang, $config; |
| 60 | 63 | |
@@ -378,6 +381,9 @@ discard block |
||
| 378 | 381 | return classSupernova::db_que_list_by_type_location($user_id, $planet_id, $que_type, $for_update); |
| 379 | 382 | } |
| 380 | 383 | |
| 384 | +/** |
|
| 385 | + * @param integer $unit_id |
|
| 386 | + */ |
|
| 381 | 387 | function que_add_unit($unit_id, $user = array(), $planet = array(), $build_data, $unit_level = 0, $unit_amount = 1, $build_mode = BUILD_CREATE) { |
| 382 | 388 | // TODO Унифицировать проверки |
| 383 | 389 | |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | function que_get_unit_que($unit_id) { |
| 4 | 4 | $que_type = false; |
| 5 | - foreach(sn_get_groups('ques') as $que_id => $que_data) { |
|
| 6 | - if(in_array($unit_id, $que_data['unit_list'])) { |
|
| 5 | + foreach (sn_get_groups('ques') as $que_id => $que_data) { |
|
| 6 | + if (in_array($unit_id, $que_data['unit_list'])) { |
|
| 7 | 7 | $que_type = $que_id; |
| 8 | 8 | break; |
| 9 | 9 | } |
@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | function que_get_max_que_length($user, $planet, $que_id, $que_data = null) { |
| 17 | 17 | global $config; |
| 18 | 18 | |
| 19 | - if(empty($que_data)) { |
|
| 19 | + if (empty($que_data)) { |
|
| 20 | 20 | $que_data = sn_get_groups('ques'); |
| 21 | 21 | $que_data = $que_data[$que_id]; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | $que_length = 1; |
| 26 | - switch($que_id) { |
|
| 26 | + switch ($que_id) { |
|
| 27 | 27 | case QUE_RESEARCH: |
| 28 | 28 | $que_length = $config->server_que_length_research + mrc_get_level($user, '', UNIT_PREMIUM); // TODO - вынести в модуль |
| 29 | 29 | break; |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | function eco_que_str2arr($que_str) { |
| 39 | 39 | $que_arr = explode(';', $que_str); |
| 40 | - foreach($que_arr as $que_index => &$que_item) { |
|
| 41 | - if($que_item) { |
|
| 40 | + foreach ($que_arr as $que_index => &$que_item) { |
|
| 41 | + if ($que_item) { |
|
| 42 | 42 | $que_item = explode(',', $que_item); |
| 43 | 43 | } else { |
| 44 | 44 | unset($que_arr[$que_index]); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | function eco_que_arr2str($que_arr) { |
| 51 | - foreach($que_arr as &$que_item) { |
|
| 51 | + foreach ($que_arr as &$que_item) { |
|
| 52 | 52 | $que_item = implode(',', $que_item); |
| 53 | 53 | } |
| 54 | 54 | return implode(';', $que_arr); |
@@ -59,14 +59,14 @@ discard block |
||
| 59 | 59 | global $lang, $config; |
| 60 | 60 | |
| 61 | 61 | $is_autoconvert = false; |
| 62 | - if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
| 62 | + if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
| 63 | 63 | $build_mode = BUILD_CREATE; |
| 64 | 64 | $is_autoconvert = true; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $unit_amount_qued = 0; |
| 68 | 68 | try { |
| 69 | - if(!$user['id']) { |
|
| 69 | + if (!$user['id']) { |
|
| 70 | 70 | throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 71 | 71 | } |
| 72 | 72 | |
@@ -77,16 +77,16 @@ discard block |
||
| 77 | 77 | foreach($unit_list as $unit_id => $unit_amount) if($unit_amount) break; |
| 78 | 78 | } |
| 79 | 79 | */ |
| 80 | - if(!$unit_id) { |
|
| 80 | + if (!$unit_id) { |
|
| 81 | 81 | throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $que_id = que_get_unit_que($unit_id); |
| 85 | - if(!$que_id) { |
|
| 85 | + if (!$que_id) { |
|
| 86 | 86 | throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
| 89 | + if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
| 90 | 90 | throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION |
| 91 | 91 | } |
| 92 | 92 | |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | $que_data = $que_data[$que_id]; |
| 95 | 95 | |
| 96 | 96 | // TODO Переделать под подочереди |
| 97 | - if($que_id == QUE_STRUCTURES) { |
|
| 97 | + if ($que_id == QUE_STRUCTURES) { |
|
| 98 | 98 | $sn_groups_build_allow = sn_get_groups('build_allow'); |
| 99 | 99 | $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']]; |
| 100 | 100 | |
| 101 | - if(!isset($que_data['unit_list'][$unit_id])) { |
|
| 101 | + if (!isset($que_data['unit_list'][$unit_id])) { |
|
| 102 | 102 | throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | // Это нужно, что бы заблокировать пользователя и работу с очередями |
| 120 | 120 | $user = db_user_by_id($user['id']); |
| 121 | 121 | // Это нужно, что бы заблокировать планету от списания ресурсов |
| 122 | - if(isset($planet['id']) && $planet['id']) { |
|
| 122 | + if (isset($planet['id']) && $planet['id']) { |
|
| 123 | 123 | $planet = db_planet_by_id($planet['id'], true); |
| 124 | 124 | } else { |
| 125 | 125 | $planet['id'] = 0; |
@@ -131,17 +131,17 @@ discard block |
||
| 131 | 131 | $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id]; |
| 132 | 132 | $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data); |
| 133 | 133 | // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей |
| 134 | - if(count($in_que) >= $que_max_length) { |
|
| 134 | + if (count($in_que) >= $que_max_length) { |
|
| 135 | 135 | throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов |
| 139 | - switch(eco_can_build_unit($user, $planet, $unit_id)) { |
|
| 139 | + switch (eco_can_build_unit($user, $planet, $unit_id)) { |
|
| 140 | 140 | case BUILD_ALLOWED: break; |
| 141 | 141 | case BUILD_UNIT_BUSY: throw new exception('{Строение занято}', ERR_ERROR); break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading |
| 142 | 142 | // case BUILD_REQUIRE_NOT_MEET: |
| 143 | 143 | default: |
| 144 | - if($build_mode == BUILD_CREATE) { |
|
| 144 | + if ($build_mode == BUILD_CREATE) { |
|
| 145 | 145 | throw new exception('{Требования не удовлетворены}', ERR_ERROR); |
| 146 | 146 | } |
| 147 | 147 | break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | $unit_amount_qued = $unit_amount; |
| 152 | 152 | $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0; |
| 153 | 153 | $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued; |
| 154 | - if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
| 155 | - if($unit_level >= $unit_max) { |
|
| 154 | + if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
| 155 | + if ($unit_level >= $unit_max) { |
|
| 156 | 156 | throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
| 157 | 157 | } |
| 158 | 158 | $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level)); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if($unit_amount < 1) { |
|
| 161 | + if ($unit_amount < 1) { |
|
| 162 | 162 | throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 163 | 163 | } |
| 164 | 164 | |
@@ -174,21 +174,21 @@ discard block |
||
| 174 | 174 | // { |
| 175 | 175 | // die('Unit busy'); // TODO EXCEPTION |
| 176 | 176 | // } |
| 177 | - if(get_unit_param($unit_id, P_STACKABLE)) { |
|
| 177 | + if (get_unit_param($unit_id, P_STACKABLE)) { |
|
| 178 | 178 | // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь |
| 179 | - if(in_array($unit_id, $group_missile = sn_get_groups('missile'))) { |
|
| 179 | + if (in_array($unit_id, $group_missile = sn_get_groups('missile'))) { |
|
| 180 | 180 | // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита |
| 181 | 181 | $used_silo = 0; |
| 182 | - foreach($group_missile as $missile_id) { |
|
| 182 | + foreach ($group_missile as $missile_id) { |
|
| 183 | 183 | $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0; |
| 184 | 184 | $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE); |
| 185 | 185 | } |
| 186 | 186 | $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo; |
| 187 | - if($free_silo <= 0) { |
|
| 187 | + if ($free_silo <= 0) { |
|
| 188 | 188 | throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
| 189 | 189 | } |
| 190 | 190 | $unit_size = get_unit_param($unit_id, P_UNIT_SIZE); |
| 191 | - if($free_silo < $unit_size) { |
|
| 191 | + if ($free_silo < $unit_size) { |
|
| 192 | 192 | throw new exception("{В ракетной шахте нет места для {$lang['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION |
| 193 | 193 | } |
| 194 | 194 | $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size))); |
@@ -196,10 +196,10 @@ discard block |
||
| 196 | 196 | $unit_level = $new_unit_level = 0; |
| 197 | 197 | } else { |
| 198 | 198 | $unit_amount = 1; |
| 199 | - if($que_id == QUE_STRUCTURES) { |
|
| 199 | + if ($que_id == QUE_STRUCTURES) { |
|
| 200 | 200 | // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0) |
| 201 | 201 | $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0; |
| 202 | - if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) |
|
| 202 | + if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) |
|
| 203 | 203 | { |
| 204 | 204 | throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION |
| 205 | 205 | } |
@@ -217,9 +217,9 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | $exchange = array(); |
| 219 | 219 | $market_get_autoconvert_cost = market_get_autoconvert_cost(); |
| 220 | - if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
| 220 | + if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
| 221 | 221 | $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
| 222 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
| 222 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
| 223 | 223 | throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
| 224 | 224 | } |
| 225 | 225 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $resource_exchange_rates = array(); |
| 230 | 230 | $resource_diff = array(); |
| 231 | 231 | $all_positive = true; |
| 232 | - foreach($resources_loot as $resource_id) { |
|
| 232 | + foreach ($resources_loot as $resource_id) { |
|
| 233 | 233 | $resource_db_name = pname_resource_name($resource_id); |
| 234 | 234 | $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id)); |
| 235 | 235 | $resource_exchange_rates[$resource_id] = $config->__get("rpg_exchange_{$resource_db_name}"); |
@@ -237,15 +237,15 @@ discard block |
||
| 237 | 237 | $all_positive = $all_positive && ($resource_diff[$resource_id] > 0); |
| 238 | 238 | } |
| 239 | 239 | // Нужна автоконвертация |
| 240 | - if($all_positive) { |
|
| 240 | + if ($all_positive) { |
|
| 241 | 241 | $is_autoconvert = false; |
| 242 | 242 | } else { |
| 243 | - foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
| 244 | - if($resource_diff_amount >= 0) { |
|
| 243 | + foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
| 244 | + if ($resource_diff_amount >= 0) { |
|
| 245 | 245 | continue; |
| 246 | 246 | } |
| 247 | - foreach($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
| 248 | - if($resource_got_amount <= 0) { |
|
| 247 | + foreach ($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
| 248 | + if ($resource_got_amount <= 0) { |
|
| 249 | 249 | continue; |
| 250 | 250 | } |
| 251 | 251 | $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id]; |
@@ -261,14 +261,14 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $is_autoconvert_ok = true; |
| 264 | - foreach($resource_diff as $resource_diff_amount2) { |
|
| 265 | - if($resource_diff_amount2 < 0) { |
|
| 264 | + foreach ($resource_diff as $resource_diff_amount2) { |
|
| 265 | + if ($resource_diff_amount2 < 0) { |
|
| 266 | 266 | $is_autoconvert_ok = false; |
| 267 | 267 | break; |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if($is_autoconvert_ok) { |
|
| 271 | + if ($is_autoconvert_ok) { |
|
| 272 | 272 | $build_data['RESULT'][$build_mode] = BUILD_ALLOWED; |
| 273 | 273 | $build_data['CAN'][$build_mode] = $unit_amount; |
| 274 | 274 | } else { |
@@ -277,19 +277,19 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount); |
| 280 | - if($unit_amount <= 0) { |
|
| 280 | + if ($unit_amount <= 0) { |
|
| 281 | 281 | throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if($new_unit_level < 0) { |
|
| 284 | + if ($new_unit_level < 0) { |
|
| 285 | 285 | throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
| 288 | + if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
| 289 | 289 | throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if($is_autoconvert) { |
|
| 292 | + if ($is_autoconvert) { |
|
| 293 | 293 | ksort($exchange); |
| 294 | 294 | ksort($resource_got); |
| 295 | 295 | db_change_units($user, $planet, array( |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $unit_amount_qued = 0; |
| 307 | - while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
| 307 | + while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
| 308 | 308 | $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW); |
| 309 | 309 | que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode); |
| 310 | 310 | $unit_amount -= $place; |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | sn_db_transaction_commit(); |
| 316 | 316 | |
| 317 | - if($redirect) { |
|
| 317 | + if ($redirect) { |
|
| 318 | 318 | sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id')); |
| 319 | 319 | die(); |
| 320 | 320 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | 'STATUS' => ERR_NONE, |
| 324 | 324 | 'MESSAGE' => '{Строительство начато}', |
| 325 | 325 | ); |
| 326 | - } catch(exception $e) { |
|
| 326 | + } catch (exception $e) { |
|
| 327 | 327 | sn_db_transaction_rollback(); |
| 328 | 328 | $operation_result = array( |
| 329 | 329 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | ); |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if(!empty($operation_result['MESSAGE'])) { |
|
| 334 | + if (!empty($operation_result['MESSAGE'])) { |
|
| 335 | 335 | $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . $lang['tech'][$unit_id] . ']'; |
| 336 | 336 | } |
| 337 | 337 | |
@@ -345,11 +345,11 @@ discard block |
||
| 345 | 345 | function que_recalculate($old_que) { |
| 346 | 346 | $new_que = array(); |
| 347 | 347 | |
| 348 | - if(!is_array($old_que['items'])) { |
|
| 348 | + if (!is_array($old_que['items'])) { |
|
| 349 | 349 | return $new_que; |
| 350 | 350 | } |
| 351 | - foreach($old_que['items'] as $row) { |
|
| 352 | - if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
| 351 | + foreach ($old_que['items'] as $row) { |
|
| 352 | + if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
| 353 | 353 | continue; |
| 354 | 354 | } |
| 355 | 355 | |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | $last_id = count($new_que['items']) - 1; |
| 362 | 362 | |
| 363 | - if($row['que_planet_id']) { |
|
| 363 | + if ($row['que_planet_id']) { |
|
| 364 | 364 | $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
| 365 | - } elseif($row['que_type'] == QUE_RESEARCH) { |
|
| 365 | + } elseif ($row['que_type'] == QUE_RESEARCH) { |
|
| 366 | 366 | $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
| 367 | 367 | } |
| 368 | 368 | $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id]; |
@@ -397,9 +397,9 @@ discard block |
||
| 397 | 397 | $que_type = que_get_unit_que($unit_id); |
| 398 | 398 | $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL'; |
| 399 | 399 | $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin; |
| 400 | - if(is_numeric($planet_id)) { |
|
| 400 | + if (is_numeric($planet_id)) { |
|
| 401 | 401 | db_planet_set_by_id($planet_id, "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
| 402 | - } elseif(is_numeric($user['id'])) { |
|
| 402 | + } elseif (is_numeric($user['id'])) { |
|
| 403 | 403 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
| 404 | 404 | } |
| 405 | 405 | |
@@ -429,17 +429,17 @@ discard block |
||
| 429 | 429 | $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0; |
| 430 | 430 | $global_que = que_get($user['id'], $planet['id'], $que_type, true); |
| 431 | 431 | |
| 432 | - if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
| 432 | + if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
| 433 | 433 | $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]); |
| 434 | 434 | |
| 435 | - foreach($que as $que_item) { |
|
| 435 | + foreach ($que as $que_item) { |
|
| 436 | 436 | db_que_delete_by_id($que_item['que_id']); |
| 437 | 437 | |
| 438 | - if($que_item['que_planet_id_origin']) { |
|
| 438 | + if ($que_item['que_planet_id_origin']) { |
|
| 439 | 439 | $planet['id'] = $que_item['que_planet_id_origin']; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - if(!isset($planets_locked[$planet['id']])) { |
|
| 442 | + if (!isset($planets_locked[$planet['id']])) { |
|
| 443 | 443 | $planets_locked[$planet['id']] = $planet['id'] ? db_planet_by_id($planet['id'], true) : $planet; |
| 444 | 444 | } |
| 445 | 445 | |
@@ -451,15 +451,15 @@ discard block |
||
| 451 | 451 | RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount'], |
| 452 | 452 | )); |
| 453 | 453 | |
| 454 | - if(!$clear) { |
|
| 454 | + if (!$clear) { |
|
| 455 | 455 | break; |
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - if(is_numeric($planet['id'])) { |
|
| 459 | + if (is_numeric($planet['id'])) { |
|
| 460 | 460 | db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
| 461 | 461 | } |
| 462 | - elseif(is_numeric($user['id'])) { |
|
| 462 | + elseif (is_numeric($user['id'])) { |
|
| 463 | 463 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
| 464 | 464 | } |
| 465 | 465 | |
@@ -504,21 +504,21 @@ discard block |
||
| 504 | 504 | // TODO: Переделать для $que_type === false |
| 505 | 505 | $planet['id'] = $planet['id'] ? $planet['id'] : 0; |
| 506 | 506 | |
| 507 | - if(!is_array($que)) { |
|
| 507 | + if (!is_array($que)) { |
|
| 508 | 508 | $que = que_get($user['id'], $planet['id'], $que_type); |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - if(is_array($que) && isset($que['items'])) { |
|
| 511 | + if (is_array($que) && isset($que['items'])) { |
|
| 512 | 512 | $que = $que['ques'][$que_type][$user['id']][$planet['id']]; |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - if($que) { |
|
| 516 | - foreach($que as $que_element) { |
|
| 515 | + if ($que) { |
|
| 516 | + foreach ($que as $que_element) { |
|
| 517 | 517 | $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names)); |
| 518 | 518 | } |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - if($que_type == QUE_RESEARCH) { |
|
| 521 | + if ($que_type == QUE_RESEARCH) { |
|
| 522 | 522 | // TODO Исправить |
| 523 | 523 | // $template->assign_var('RESEARCH_ONGOING', count($global_que[QUE_RESEARCH][0]) >= $config->server_que_length_research); |
| 524 | 524 | } |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | $user = db_user_by_id($user['id'], true); |
| 547 | 547 | |
| 548 | 548 | $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']); |
| 549 | - if($planet === null && !$time_left[$user['id']][0]) { |
|
| 549 | + if ($planet === null && !$time_left[$user['id']][0]) { |
|
| 550 | 550 | // TODO |
| 551 | 551 | return $que; |
| 552 | 552 | } |
@@ -555,12 +555,12 @@ discard block |
||
| 555 | 555 | $que_type_id = $planet === null ? QUE_RESEARCH : false; |
| 556 | 556 | $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false |
| 557 | 557 | $que = que_get($user['id'], $planet, $que_type_id, true); |
| 558 | - if(empty($que['items'])) { |
|
| 558 | + if (empty($que['items'])) { |
|
| 559 | 559 | return $que; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | $planet_list = array(); |
| 563 | - if($planet !== null) { |
|
| 563 | + if ($planet !== null) { |
|
| 564 | 564 | // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них |
| 565 | 565 | // TODO - от них не надо ничего, кроме ID и que_processed |
| 566 | 566 | $planet_row = db_planet_list_by_user_or_planet($user['id'], $planet); |
@@ -569,21 +569,21 @@ discard block |
||
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты |
| 572 | - if(array_sum($time_left[$user['id']]) == 0) { |
|
| 572 | + if (array_sum($time_left[$user['id']]) == 0) { |
|
| 573 | 573 | return $que; |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | $db_changeset = array(); |
| 577 | 577 | $unit_changes = array(); |
| 578 | - foreach($que['items'] as &$que_item) { |
|
| 578 | + foreach ($que['items'] as &$que_item) { |
|
| 579 | 579 | $que_player_id = &$que_item['que_player_id']; |
| 580 | 580 | $que_planet_id = intval($que_item['que_planet_id']); |
| 581 | 581 | |
| 582 | 582 | $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']]; |
| 583 | - if(!isset($que_time_left)) { |
|
| 583 | + if (!isset($que_time_left)) { |
|
| 584 | 584 | $que_time_left = $time_left[$que_player_id][$que_planet_id]; |
| 585 | 585 | } |
| 586 | - if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
| 586 | + if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
| 587 | 587 | continue; |
| 588 | 588 | } |
| 589 | 589 | // Дальше мы идем, если только осталось время в очереди И юниты к постройке |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля |
| 597 | 597 | |
| 598 | 598 | // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит |
| 599 | - if($que_time_left >= $que_item['que_time_left']) { |
|
| 599 | + if ($que_time_left >= $que_item['que_time_left']) { |
|
| 600 | 600 | // Увеличиваем количество отстроенных юнитов |
| 601 | 601 | $unit_processed++; |
| 602 | 602 | // Вычитаем из времени очереди потраченное на постройку время |
@@ -609,12 +609,12 @@ discard block |
||
| 609 | 609 | $que_item['que_unit_amount'] -= $unit_processed; |
| 610 | 610 | |
| 611 | 611 | // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита |
| 612 | - if($que_item['que_unit_amount'] > 0) { |
|
| 612 | + if ($que_item['que_unit_amount'] > 0) { |
|
| 613 | 613 | $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left; |
| 614 | 614 | $que_time_left = 0; |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - if($que_item['que_unit_amount'] <= 0) { |
|
| 617 | + if ($que_item['que_unit_amount'] <= 0) { |
|
| 618 | 618 | $db_changeset['que'][] = array( |
| 619 | 619 | 'action' => SQL_OP_DELETE, |
| 620 | 620 | P_VERSION => 1, |
@@ -640,14 +640,14 @@ discard block |
||
| 640 | 640 | ); |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | - if($unit_processed) { |
|
| 643 | + if ($unit_processed) { |
|
| 644 | 644 | $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1); |
| 645 | 645 | $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta; |
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - foreach($time_left as $player_id => $planet_data) { |
|
| 650 | - foreach($planet_data as $planet_id => $time_on_planet) { |
|
| 649 | + foreach ($time_left as $player_id => $planet_data) { |
|
| 650 | + foreach ($planet_data as $planet_id => $time_on_planet) { |
|
| 651 | 651 | $table = $planet_id ? 'planets' : 'users'; |
| 652 | 652 | $id = $planet_id ? $planet_id : $player_id; |
| 653 | 653 | $db_changeset[$table][] = array( |
@@ -663,8 +663,8 @@ discard block |
||
| 663 | 663 | ), |
| 664 | 664 | ); |
| 665 | 665 | |
| 666 | - if(is_array($unit_changes[$player_id][$planet_id])) { |
|
| 667 | - foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
| 666 | + if (is_array($unit_changes[$player_id][$planet_id])) { |
|
| 667 | + foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
| 668 | 668 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null); |
| 669 | 669 | } |
| 670 | 670 | } |
@@ -674,33 +674,33 @@ discard block |
||
| 674 | 674 | $que = que_recalculate($que); |
| 675 | 675 | |
| 676 | 676 | // TODO: Re-enable quests for Alliances |
| 677 | - if(!empty($unit_changes) && !$user['user_as_ally']) { |
|
| 677 | + if (!empty($unit_changes) && !$user['user_as_ally']) { |
|
| 678 | 678 | $quest_list = qst_get_quests($user['id']); |
| 679 | 679 | $quest_triggers = qst_active_triggers($quest_list); |
| 680 | 680 | $quest_rewards = array(); |
| 681 | 681 | |
| 682 | 682 | |
| 683 | 683 | $xp_incoming = array(); |
| 684 | - foreach($unit_changes as $user_id => $planet_changes) { |
|
| 685 | - foreach($planet_changes as $planet_id => $changes) { |
|
| 684 | + foreach ($unit_changes as $user_id => $planet_changes) { |
|
| 685 | + foreach ($planet_changes as $planet_id => $changes) { |
|
| 686 | 686 | $planet_this = $planet_id ? classSupernova::db_get_record_by_id(LOC_PLANET, $planet_id) : array(); |
| 687 | - foreach($changes as $unit_id => $unit_value) { |
|
| 687 | + foreach ($changes as $unit_id => $unit_value) { |
|
| 688 | 688 | $que_id = que_get_unit_que($unit_id); |
| 689 | 689 | $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value; |
| 690 | - if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
| 690 | + if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
| 691 | 691 | $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1); |
| 692 | 692 | $build_data = $build_data[BUILD_CREATE]; |
| 693 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
| 693 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
| 694 | 694 | $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена |
| 695 | 695 | } |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - if(is_array($quest_triggers)) { |
|
| 698 | + if (is_array($quest_triggers)) { |
|
| 699 | 699 | // TODO: Check mutiply condition quests |
| 700 | 700 | $quest_trigger_list = array_keys($quest_triggers, $unit_id); |
| 701 | - if(is_array($quest_trigger_list)) { |
|
| 702 | - foreach($quest_trigger_list as $quest_id) { |
|
| 703 | - if($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $unit_level_new) { |
|
| 701 | + if (is_array($quest_trigger_list)) { |
|
| 702 | + foreach ($quest_trigger_list as $quest_id) { |
|
| 703 | + if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $unit_level_new) { |
|
| 704 | 704 | $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list']; |
| 705 | 705 | $quest_list[$quest_id]['quest_status_status'] = QUEST_STATUS_COMPLETE; |
| 706 | 706 | } |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч |
| 714 | 714 | qst_reward($user, $quest_rewards, $quest_list); |
| 715 | 715 | |
| 716 | - foreach($xp_incoming as $que_id => $xp) { |
|
| 716 | + foreach ($xp_incoming as $que_id => $xp) { |
|
| 717 | 717 | rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000); |
| 718 | 718 | } |
| 719 | 719 | } |
@@ -458,8 +458,7 @@ |
||
| 458 | 458 | |
| 459 | 459 | if(is_numeric($planet['id'])) { |
| 460 | 460 | db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
| 461 | - } |
|
| 462 | - elseif(is_numeric($user['id'])) { |
|
| 461 | + } elseif(is_numeric($user['id'])) { |
|
| 463 | 462 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
| 464 | 463 | } |
| 465 | 464 | |
@@ -135,6 +135,10 @@ |
||
| 135 | 135 | return $fleet_events; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | +/** |
|
| 139 | + * @param integer $ov_label |
|
| 140 | + * @param integer $planet_end_type |
|
| 141 | + */ |
|
| 138 | 142 | function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) |
| 139 | 143 | { |
| 140 | 144 | global $user, $planetrow, $fleet_number; |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | function flt_get_fleets($condition, $phalanx = false) { |
| 11 | 11 | $fleet_db_list = array(); |
| 12 | 12 | |
| 13 | - if(!$condition) |
|
| 13 | + if (!$condition) |
|
| 14 | 14 | { |
| 15 | 15 | $missile_query = $condition = 1; |
| 16 | 16 | } |
| 17 | - elseif(is_array($condition)) |
|
| 17 | + elseif (is_array($condition)) |
|
| 18 | 18 | { |
| 19 | 19 | $missile_query = " |
| 20 | 20 | (fleet_start_galaxy = {$condition['galaxy']} AND fleet_start_system = {$condition['system']} AND fleet_start_planet = {$condition['planet']} AND fleet_start_type = {$condition['planet_type']}) |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $sql_fleets = doquery("SELECT * FROM `{{iraks}}` WHERE {$missile_query};"); |
| 42 | 42 | while ($irak = db_fetch($sql_fleets)) |
| 43 | 43 | { |
| 44 | - if($irak['fleet_end_time'] >= SN_TIME_NOW) |
|
| 44 | + if ($irak['fleet_end_time'] >= SN_TIME_NOW) |
|
| 45 | 45 | { |
| 46 | 46 | $irak['fleet_start_type'] = PT_PLANET; |
| 47 | 47 | $planet_start = db_planet_by_vector($irak, 'fleet_start_', false, 'name'); |
@@ -63,23 +63,23 @@ discard block |
||
| 63 | 63 | $fleet_events = array(); |
| 64 | 64 | $fleet_number = 0; |
| 65 | 65 | |
| 66 | - if(empty($fleet_list)) |
|
| 66 | + if (empty($fleet_list)) |
|
| 67 | 67 | { |
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - foreach($fleet_list as $fleet) |
|
| 71 | + foreach ($fleet_list as $fleet) |
|
| 72 | 72 | { |
| 73 | 73 | $planet_start_type = $fleet['fleet_start_type'] == PT_MOON ? PT_MOON : PT_PLANET; |
| 74 | 74 | $planet_start = db_planet_by_gspt($fleet['fleet_start_galaxy'], $fleet['fleet_start_system'], $fleet['fleet_start_planet'], $planet_start_type, false, 'name'); |
| 75 | 75 | $fleet['fleet_start_name'] = $planet_start['name']; |
| 76 | 76 | |
| 77 | 77 | $planet_end_type = $fleet['fleet_end_type'] == PT_MOON ? PT_MOON : PT_PLANET; |
| 78 | - if($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
|
| 78 | + if ($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
|
| 79 | 79 | { |
| 80 | 80 | $fleet['fleet_end_name'] = $lang['ov_fleet_exploration']; |
| 81 | 81 | } |
| 82 | - elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 82 | + elseif ($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 83 | 83 | { |
| 84 | 84 | $fleet['fleet_end_name'] = $lang['ov_fleet_colonization']; |
| 85 | 85 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $fleet['fleet_end_name'] = $planet_end['name']; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if($fleet['fleet_start_time'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] != MT_MISSILE && |
|
| 92 | + if ($fleet['fleet_start_time'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] != MT_MISSILE && |
|
| 93 | 93 | ($planet_scanned === false |
| 94 | 94 | || |
| 95 | 95 | ( |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | $fleet_events[] = flt_register_fleet_event($fleet, 0, $planet_end_type); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if($fleet['fleet_end_stay'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $planet_scanned === false && $fleet['fleet_mission'] != MT_MISSILE) |
|
| 107 | + if ($fleet['fleet_end_stay'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $planet_scanned === false && $fleet['fleet_mission'] != MT_MISSILE) |
|
| 108 | 108 | { |
| 109 | 109 | $fleet_events[] = flt_register_fleet_event($fleet, 1, $planet_end_type); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if( |
|
| 112 | + if ( |
|
| 113 | 113 | $fleet['fleet_end_time'] > SN_TIME_NOW && $fleet['fleet_mission'] != MT_MISSILE && ($fleet['fleet_mess'] == 1 || ($fleet['fleet_mission'] != MT_RELOCATE && $fleet['fleet_mission'] != MT_COLONIZE)) && |
| 114 | 114 | ( |
| 115 | 115 | ($planet_scanned === false && $fleet['fleet_owner'] == $user['id']) |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $fleet_events[] = flt_register_fleet_event($fleet, 2, $planet_end_type); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if($fleet['fleet_mission'] == MT_MISSILE) |
|
| 129 | + if ($fleet['fleet_mission'] == MT_MISSILE) |
|
| 130 | 130 | { |
| 131 | 131 | $fleet_events[] = flt_register_fleet_event($fleet, 3, $planet_end_type); |
| 132 | 132 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | global $user, $planetrow, $fleet_number; |
| 141 | 141 | |
| 142 | - switch($fleet['ov_label'] = $ov_label) |
|
| 142 | + switch ($fleet['ov_label'] = $ov_label) |
|
| 143 | 143 | { |
| 144 | 144 | case 0: |
| 145 | 145 | $fleet['event_time'] = $fleet['fleet_start_time']; |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - $fleet['ov_this_planet'] = $is_this_planet;// || $planet_scanned != false; |
|
| 174 | + $fleet['ov_this_planet'] = $is_this_planet; // || $planet_scanned != false; |
|
| 175 | 175 | |
| 176 | - if($fleet['fleet_owner'] == $user['id']) |
|
| 176 | + if ($fleet['fleet_owner'] == $user['id']) |
|
| 177 | 177 | { |
| 178 | 178 | $user_data = $user; |
| 179 | 179 | } |
@@ -13,8 +13,7 @@ discard block |
||
| 13 | 13 | if(!$condition) |
| 14 | 14 | { |
| 15 | 15 | $missile_query = $condition = 1; |
| 16 | - } |
|
| 17 | - elseif(is_array($condition)) |
|
| 16 | + } elseif(is_array($condition)) |
|
| 18 | 17 | { |
| 19 | 18 | $missile_query = " |
| 20 | 19 | (fleet_start_galaxy = {$condition['galaxy']} AND fleet_start_system = {$condition['system']} AND fleet_start_planet = {$condition['planet']} AND fleet_start_type = {$condition['planet_type']}) |
@@ -24,8 +23,7 @@ discard block |
||
| 24 | 23 | (fleet_start_galaxy = {$condition['galaxy']} AND fleet_start_system = {$condition['system']} AND fleet_start_planet = {$condition['planet']} AND fleet_start_type = {$condition['planet_type']}" . ($phalanx ? '' : ' AND fleet_mess = 1') . ") |
| 25 | 24 | OR |
| 26 | 25 | (fleet_end_galaxy = {$condition['galaxy']} AND fleet_end_system = {$condition['system']} AND fleet_end_planet = {$condition['planet']} AND fleet_end_type = {$condition['planet_type']}" . ($phalanx ? '' : ' AND fleet_mess = 0') . ")"; |
| 27 | - } |
|
| 28 | - else |
|
| 26 | + } else |
|
| 29 | 27 | { |
| 30 | 28 | $missile_query = "`fleet_owner` = '{$condition}' OR `fleet_target_owner` = '{$condition}'"; |
| 31 | 29 | $condition = $missile_query; |
@@ -78,12 +76,10 @@ discard block |
||
| 78 | 76 | if($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
| 79 | 77 | { |
| 80 | 78 | $fleet['fleet_end_name'] = $lang['ov_fleet_exploration']; |
| 81 | - } |
|
| 82 | - elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 79 | + } elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 83 | 80 | { |
| 84 | 81 | $fleet['fleet_end_name'] = $lang['ov_fleet_colonization']; |
| 85 | - } |
|
| 86 | - else |
|
| 82 | + } else |
|
| 87 | 83 | { |
| 88 | 84 | $planet_end = db_planet_by_gspt($fleet['fleet_end_galaxy'], $fleet['fleet_end_system'], $fleet['fleet_end_planet'], $planet_end_type, false, 'name'); |
| 89 | 85 | $fleet['fleet_end_name'] = $planet_end['name']; |
@@ -176,8 +172,7 @@ discard block |
||
| 176 | 172 | if($fleet['fleet_owner'] == $user['id']) |
| 177 | 173 | { |
| 178 | 174 | $user_data = $user; |
| 179 | - } |
|
| 180 | - else |
|
| 175 | + } else |
|
| 181 | 176 | { |
| 182 | 177 | $user_data = db_user_by_id($fleet['fleet_owner']); |
| 183 | 178 | } |
@@ -37,6 +37,9 @@ |
||
| 37 | 37 | return $list; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | +/** |
|
| 41 | + * @param integer $message_type |
|
| 42 | + */ |
|
| 40 | 43 | function msg_send_simple_message($owners, $sender, $timestamp, $message_type, $from, $subject, $text, $escaped = false, $force = false) |
| 41 | 44 | { |
| 42 | 45 | global $config, $user, $sn_message_class_list; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
| 27 | 27 | false, 'id, username'); |
| 28 | 28 | // while ($u = db_fetch($query)) |
| 29 | - foreach($query as $u) |
|
| 29 | + foreach ($query as $u) |
|
| 30 | 30 | { |
| 31 | 31 | $sendList[] = $u['id']; |
| 32 | 32 | $list .= "<br>{$u['username']} "; |
@@ -41,19 +41,19 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | global $config, $user, $sn_message_class_list; |
| 43 | 43 | |
| 44 | - if(!$owners) |
|
| 44 | + if (!$owners) |
|
| 45 | 45 | { |
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $timestamp = $timestamp ? $timestamp : SN_TIME_NOW; |
| 50 | 50 | $sender = intval($sender); |
| 51 | - if(!is_array($owners)) |
|
| 51 | + if (!is_array($owners)) |
|
| 52 | 52 | { |
| 53 | 53 | $owners = array($owners); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if(!$escaped) |
|
| 56 | + if (!$escaped) |
|
| 57 | 57 | { |
| 58 | 58 | $from = db_escape($from); |
| 59 | 59 | $subject = db_escape($subject); |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $message_class_name_total = $sn_message_class_list[MSG_TYPE_NEW]['name']; |
| 71 | 71 | |
| 72 | - if($owners[0] == '*') |
|
| 72 | + if ($owners[0] == '*') |
|
| 73 | 73 | { |
| 74 | - if($user['authlevel'] < 3) |
|
| 74 | + if ($user['authlevel'] < 3) |
|
| 75 | 75 | { |
| 76 | 76 | return false; |
| 77 | 77 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | foreach ($owners as $owner) |
| 89 | 89 | { |
| 90 | - if($user['id'] != $owner) |
|
| 90 | + if ($user['id'] != $owner) |
|
| 91 | 91 | { |
| 92 | 92 | $owner_row = db_user_by_id($owner); |
| 93 | 93 | } |
@@ -97,18 +97,18 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | sys_user_options_unpack($owner_row); |
| 99 | 99 | |
| 100 | - if($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) |
|
| 100 | + if ($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) |
|
| 101 | 101 | { |
| 102 | 102 | $insert_values[] = sprintf($insert_template, $owner); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) |
|
| 105 | + if ($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) |
|
| 106 | 106 | { |
| 107 | 107 | @$result = mymail($owner_row['email'], $subject, $text_unescaped, '', true); |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if(empty($insert_values)) |
|
| 111 | + if (empty($insert_values)) |
|
| 112 | 112 | { |
| 113 | 113 | return; |
| 114 | 114 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | db_user_list_set_mass_mail($owners, "`{$message_class_name}` = `{$message_class_name}` + 1, `{$message_class_name_total}` = `{$message_class_name_total}` + 1"); |
| 120 | 120 | |
| 121 | - if(in_array($user['id'], $owners) || $owners[0] == '*') |
|
| 121 | + if (in_array($user['id'], $owners) || $owners[0] == '*') |
|
| 122 | 122 | { |
| 123 | 123 | $user[$message_class_name]++; |
| 124 | 124 | $user[$message_class_name_total]++; |
@@ -79,8 +79,7 @@ discard block |
||
| 79 | 79 | // TODO Добавить $sender - рассылка может быть и от кого-то |
| 80 | 80 | db_message_insert_all($message_type, $from, $subject, $text); |
| 81 | 81 | $owners = array(); |
| 82 | - } |
|
| 83 | - else |
|
| 82 | + } else |
|
| 84 | 83 | { |
| 85 | 84 | $insert_values = array(); |
| 86 | 85 | $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
@@ -90,8 +89,7 @@ discard block |
||
| 90 | 89 | if($user['id'] != $owner) |
| 91 | 90 | { |
| 92 | 91 | $owner_row = db_user_by_id($owner); |
| 93 | - } |
|
| 94 | - else |
|
| 92 | + } else |
|
| 95 | 93 | { |
| 96 | 94 | $owner_row = $user; |
| 97 | 95 | } |
@@ -161,6 +161,9 @@ discard block |
||
| 161 | 161 | return $rows_affected; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | +/** |
|
| 165 | + * @param integer $type |
|
| 166 | + */ |
|
| 164 | 167 | function rpg_level_up(&$user, $type, $xp_to_add = 0) |
| 165 | 168 | { |
| 166 | 169 | $q = 1.03; |
@@ -223,6 +226,10 @@ discard block |
||
| 223 | 226 | } |
| 224 | 227 | } |
| 225 | 228 | |
| 229 | +/** |
|
| 230 | + * @param integer $b1 |
|
| 231 | + * @param double $q |
|
| 232 | + */ |
|
| 226 | 233 | function rpg_xp_for_level($level, $b1, $q) |
| 227 | 234 | { |
| 228 | 235 | return floor($b1 * (pow($q, $level) - 1)/($q - 1)); |
@@ -233,6 +240,9 @@ discard block |
||
| 233 | 240 | return rpg_xp_for_level($level, 50, 1.03); |
| 234 | 241 | } |
| 235 | 242 | |
| 243 | +/** |
|
| 244 | + * @param integer $level |
|
| 245 | + */ |
|
| 236 | 246 | function RPG_get_raider_xp($level) |
| 237 | 247 | { |
| 238 | 248 | return rpg_xp_for_level($level, 10, 1.03); |
@@ -85,28 +85,28 @@ discard block |
||
| 85 | 85 | function rpg_points_change($user_id, $change_type, $dark_matter, $comment = false, $already_changed = false) { |
| 86 | 86 | global $debug, $config, $dm_change_legit, $user; |
| 87 | 87 | |
| 88 | - if(!$user_id) { |
|
| 88 | + if (!$user_id) { |
|
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $dm_change_legit = true; |
| 93 | 93 | $sn_data_dark_matter_db_name = pname_resource_name(RES_DARK_MATTER); |
| 94 | 94 | |
| 95 | - if($already_changed) { |
|
| 95 | + if ($already_changed) { |
|
| 96 | 96 | $rows_affected = 1; |
| 97 | 97 | } else { |
| 98 | 98 | $changeset = array(); |
| 99 | 99 | $a_user = db_user_by_id($user_id, true); |
| 100 | - if($dark_matter < 0) { |
|
| 100 | + if ($dark_matter < 0) { |
|
| 101 | 101 | $dark_matter_exists = mrc_get_level($a_user, null, RES_DARK_MATTER, false, true); |
| 102 | 102 | $dark_matter_exists < 0 ? $dark_matter_exists = 0 : false; |
| 103 | 103 | $metamatter_to_reduce = -$dark_matter - $dark_matter_exists; |
| 104 | - if($metamatter_to_reduce > 0) { |
|
| 104 | + if ($metamatter_to_reduce > 0) { |
|
| 105 | 105 | $metamatter_exists = mrc_get_level($a_user, null, RES_METAMATTER); |
| 106 | - if($metamatter_exists < $metamatter_to_reduce) { |
|
| 106 | + if ($metamatter_exists < $metamatter_to_reduce) { |
|
| 107 | 107 | $debug->error('Ошибка снятия ТМ - ММ+ТМ меньше, чем сумма для снятия!', 'Ошибка снятия ТМ', LOG_ERR_INT_NOT_ENOUGH_DARK_MATTER); |
| 108 | 108 | } |
| 109 | - if(is_array($comment)) { |
|
| 109 | + if (is_array($comment)) { |
|
| 110 | 110 | $comment = call_user_func_array('sprintf', $comment); |
| 111 | 111 | } |
| 112 | 112 | // mm_points_change($user_id, $change_type, -$metamatter_to_reduce, 'ММ в ТМ: ' . (-$dark_matter) . ' ТМ = ' . $dark_matter_exists . ' ТМ + ' . $metamatter_to_reduce . ' ММ. ' . $comment); |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | $rows_affected = classSupernova::$db->db_affected_rows(); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if($rows_affected || !$dark_matter) { |
|
| 124 | + if ($rows_affected || !$dark_matter) { |
|
| 125 | 125 | $page_url = db_escape($_SERVER['SCRIPT_NAME']); |
| 126 | - if(is_array($comment)) { |
|
| 126 | + if (is_array($comment)) { |
|
| 127 | 127 | $comment = call_user_func_array('sprintf', $comment); |
| 128 | 128 | } |
| 129 | 129 | $comment = db_escape($comment); |
@@ -137,18 +137,18 @@ discard block |
||
| 137 | 137 | {$dark_matter}, '{$comment}', '{$page_url}', {$user_id} |
| 138 | 138 | );"); |
| 139 | 139 | |
| 140 | - if($user['id'] == $user_id) { |
|
| 140 | + if ($user['id'] == $user_id) { |
|
| 141 | 141 | $user['dark_matter'] += $dark_matter; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if($dark_matter > 0) { |
|
| 144 | + if ($dark_matter > 0) { |
|
| 145 | 145 | $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1 FOR UPDATE;", '', true); |
| 146 | - if($old_referral['id']) { |
|
| 146 | + if ($old_referral['id']) { |
|
| 147 | 147 | doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter}' WHERE `id` = {$user_id} LIMIT 1;"); |
| 148 | 148 | $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1;", '', true); |
| 149 | 149 | |
| 150 | 150 | $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0); |
| 151 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
| 151 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
| 152 | 152 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL, $partner_bonus, "Incoming From Referral ID {$user_id}"); |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | { |
| 166 | 166 | $q = 1.03; |
| 167 | 167 | |
| 168 | - switch($type) |
|
| 168 | + switch ($type) |
|
| 169 | 169 | { |
| 170 | 170 | case RPG_STRUCTURE: |
| 171 | 171 | $field_level = 'lvl_minier'; |
@@ -203,19 +203,19 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $xp = &$user[$field_xp]; |
| 205 | 205 | |
| 206 | - if($xp_to_add) |
|
| 206 | + if ($xp_to_add) |
|
| 207 | 207 | { |
| 208 | 208 | $xp += $xp_to_add; |
| 209 | 209 | db_user_set_by_id($user['id'], "`{$field_xp}` = `{$field_xp}` + '{$xp_to_add}'"); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | $level = $user[$field_level]; |
| 213 | - while($xp > rpg_xp_for_level($level + 1, $b1, $q)) |
|
| 213 | + while ($xp > rpg_xp_for_level($level + 1, $b1, $q)) |
|
| 214 | 214 | { |
| 215 | 215 | $level++; |
| 216 | 216 | } |
| 217 | 217 | $level -= $user[$field_level]; |
| 218 | - if($level > 0) |
|
| 218 | + if ($level > 0) |
|
| 219 | 219 | { |
| 220 | 220 | db_user_set_by_id($user['id'], "`{$field_level}` = `{$field_level}` + '{$level}'"); |
| 221 | 221 | rpg_points_change($user['id'], $type, $level * 1000, $comment); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | function rpg_xp_for_level($level, $b1, $q) |
| 227 | 227 | { |
| 228 | - return floor($b1 * (pow($q, $level) - 1)/($q - 1)); |
|
| 228 | + return floor($b1 * (pow($q, $level) - 1) / ($q - 1)); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | function rpg_get_miner_xp($level) |
@@ -141,6 +141,9 @@ |
||
| 141 | 141 | "); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | +/** |
|
| 145 | + * @param string $email_unsafe |
|
| 146 | + */ |
|
| 144 | 147 | function player_create($username_unsafe, $email_unsafe, $options) { |
| 145 | 148 | sn_db_transaction_check(true); |
| 146 | 149 | |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Created by PhpStorm. |
|
| 4 | - * User: Gorlum |
|
| 5 | - * Date: 17.04.2015 |
|
| 6 | - * Time: 6:37 |
|
| 7 | - */ |
|
| 3 | + * Created by PhpStorm. |
|
| 4 | + * User: Gorlum |
|
| 5 | + * Date: 17.04.2015 |
|
| 6 | + * Time: 6:37 |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | function sys_user_vacation($user) { |
| 10 | 10 | global $config; |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | function sys_user_vacation($user) { |
| 10 | 10 | global $config; |
| 11 | 11 | |
| 12 | - if(sys_get_param_str('vacation') == 'leave') { |
|
| 12 | + if (sys_get_param_str('vacation') == 'leave') { |
|
| 13 | 13 | if ($user['vacation'] < SN_TIME_NOW) { |
| 14 | 14 | $user['vacation'] = 0; |
| 15 | 15 | $user['vacation_next'] = SN_TIME_NOW + $config->player_vacation_timeout; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - if($user['vacation']) { |
|
| 20 | + if ($user['vacation']) { |
|
| 21 | 21 | // sn_sys_logout(false, true); |
| 22 | 22 | // core_auth::logout(false, true); |
| 23 | 23 | |
@@ -49,33 +49,33 @@ discard block |
||
| 49 | 49 | // TODO: Full rewrite |
| 50 | 50 | sn_db_transaction_start(); |
| 51 | 51 | $TheUser = db_user_by_id($UserID); |
| 52 | - if ( $TheUser['ally_id'] != 0 ) { |
|
| 53 | - $TheAlly = doquery ( "SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';", '', true ); |
|
| 52 | + if ($TheUser['ally_id'] != 0) { |
|
| 53 | + $TheAlly = doquery("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';", '', true); |
|
| 54 | 54 | $TheAlly['ally_members'] -= 1; |
| 55 | - if ( $TheAlly['ally_members'] > 0 ) { |
|
| 56 | - doquery ( "UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
| 55 | + if ($TheAlly['ally_members'] > 0) { |
|
| 56 | + doquery("UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
| 57 | 57 | } else { |
| 58 | - doquery ( "DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
| 59 | - doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';"); |
|
| 58 | + doquery("DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
| 59 | + doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';"); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | - doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';"); |
|
| 62 | + doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';"); |
|
| 63 | 63 | |
| 64 | 64 | db_planet_list_delete_by_owner($UserID); |
| 65 | 65 | |
| 66 | - doquery ( "DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';"); |
|
| 67 | - doquery ( "DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';"); |
|
| 68 | - doquery ( "DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';"); |
|
| 69 | - doquery ( "DELETE FROM `{{fleets}}` WHERE `fleet_owner` = '" . $UserID . "';"); |
|
| 66 | + doquery("DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';"); |
|
| 67 | + doquery("DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';"); |
|
| 68 | + doquery("DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';"); |
|
| 69 | + doquery("DELETE FROM `{{fleets}}` WHERE `fleet_owner` = '" . $UserID . "';"); |
|
| 70 | 70 | // doquery ( "DELETE FROM `{{rw}}` WHERE `id_owner1` = '" . $UserID . "';"); |
| 71 | 71 | // doquery ( "DELETE FROM `{{rw}}` WHERE `id_owner2` = '" . $UserID . "';"); |
| 72 | - doquery ( "DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';"); |
|
| 73 | - doquery ( "DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';"); |
|
| 74 | - doquery ( "DELETE FROM `{{annonce}}` WHERE `user` = '" . $UserID . "';"); |
|
| 72 | + doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';"); |
|
| 73 | + doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';"); |
|
| 74 | + doquery("DELETE FROM `{{annonce}}` WHERE `user` = '" . $UserID . "';"); |
|
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | classSupernova::db_del_record_by_id(LOC_USER, $UserID); |
| 78 | - doquery ( "DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');"); |
|
| 78 | + doquery("DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');"); |
|
| 79 | 79 | global $config; |
| 80 | 80 | $config->db_saveItem('users_amount', $config->db_loadItem('users_amount') - 1); |
| 81 | 81 | sn_db_transaction_commit(); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | !empty($options['password_encoded_unsafe']) ? $field_set['password'] = $options['password_encoded_unsafe'] : false; |
| 176 | 176 | |
| 177 | 177 | $user_new = classSupernova::db_ins_field_set(LOC_USER, $field_set); |
| 178 | - if(!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
| 178 | + if (!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
| 179 | 179 | $options['galaxy'] = $config->LastSettedGalaxyPos; |
| 180 | 180 | $options['system'] = $config->LastSettedSystemPos; |
| 181 | 181 | $segment_size = floor($config->game_maxPlanet / 3); |
@@ -184,19 +184,19 @@ discard block |
||
| 184 | 184 | $options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size); |
| 185 | 185 | |
| 186 | 186 | // $new_planet_id = 0; |
| 187 | - while(true) { |
|
| 188 | - if($options['planet'] > $config->game_maxPlanet) { |
|
| 187 | + while (true) { |
|
| 188 | + if ($options['planet'] > $config->game_maxPlanet) { |
|
| 189 | 189 | $options['planet'] = mt_rand(0, $segment_size - 1) + 1; |
| 190 | 190 | $options['system']++; |
| 191 | 191 | } |
| 192 | - if($options['system'] > $config->game_maxSystem) { |
|
| 192 | + if ($options['system'] > $config->game_maxSystem) { |
|
| 193 | 193 | $options['system'] = 1; |
| 194 | 194 | $options['galaxy']++; |
| 195 | 195 | } |
| 196 | 196 | $options['galaxy'] > $config->game_maxGalaxy ? $options['galaxy'] = 1 : false; |
| 197 | 197 | |
| 198 | 198 | $galaxy_row = db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id'); |
| 199 | - if(!$galaxy_row['id']) { |
|
| 199 | + if (!$galaxy_row['id']) { |
|
| 200 | 200 | $config->db_saveItem(array( |
| 201 | 201 | 'LastSettedGalaxyPos' => $options['galaxy'], |
| 202 | 202 | 'LastSettedSystemPos' => $options['system'], |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $username_safe = db_escape($username_unsafe); |
| 226 | 226 | doquery("REPLACE INTO {{player_name_history}} SET `player_id` = {$user_new['id']}, `player_name` = '{$username_safe}'"); |
| 227 | 227 | |
| 228 | - if(!empty($options['partner_id']) && ($referral_row = db_user_by_id($options['partner_id'], true))) { |
|
| 228 | + if (!empty($options['partner_id']) && ($referral_row = db_user_by_id($options['partner_id'], true))) { |
|
| 229 | 229 | doquery("INSERT INTO {{referrals}} SET `id` = {$user_new['id']}, `id_partner` = {$options['partner_id']}"); |
| 230 | 230 | } |
| 231 | 231 | |
@@ -17,6 +17,9 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | +/** |
|
| 21 | + * @param template $template |
|
| 22 | + */ |
|
| 20 | 23 | function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') |
| 21 | 24 | { |
| 22 | 25 | if(!$fleets) |
@@ -165,6 +168,9 @@ discard block |
||
| 165 | 168 | return $result; |
| 166 | 169 | } |
| 167 | 170 | |
| 171 | +/** |
|
| 172 | + * @param integer $que_id |
|
| 173 | + */ |
|
| 168 | 174 | function tpl_parse_planet_que($que, $planet, $que_id) |
| 169 | 175 | { |
| 170 | 176 | $hangar_que = array(); |
@@ -3,9 +3,9 @@ discard block |
||
| 3 | 3 | // Compare function to sort fleet in time order |
| 4 | 4 | function tpl_assign_fleet_compare($a, $b) |
| 5 | 5 | { |
| 6 | - if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) |
|
| 6 | + if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) |
|
| 7 | 7 | { |
| 8 | - if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) |
|
| 8 | + if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) |
|
| 9 | 9 | { |
| 10 | 10 | return 0; |
| 11 | 11 | } |
@@ -19,20 +19,20 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') |
| 21 | 21 | { |
| 22 | - if(!$fleets) |
|
| 22 | + if (!$fleets) |
|
| 23 | 23 | { |
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | usort($fleets, 'tpl_assign_fleet_compare'); |
| 28 | 28 | |
| 29 | - foreach($fleets as $fleet_data) |
|
| 29 | + foreach ($fleets as $fleet_data) |
|
| 30 | 30 | { |
| 31 | 31 | $template->assign_block_vars($js_name, $fleet_data['fleet']); |
| 32 | 32 | |
| 33 | - if($fleet_data['ships']) |
|
| 33 | + if ($fleet_data['ships']) |
|
| 34 | 34 | { |
| 35 | - foreach($fleet_data['ships'] as $ship_data) |
|
| 35 | + foreach ($fleet_data['ships'] as $ship_data) |
|
| 36 | 36 | { |
| 37 | 37 | $template->assign_block_vars("{$js_name}.ships", $ship_data); |
| 38 | 38 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | foreach ($fleet as $ship_id => $ship_amount) |
| 59 | 59 | { |
| 60 | - if(in_array($ship_id, sn_get_groups('fleet'))) |
|
| 60 | + if (in_array($ship_id, sn_get_groups('fleet'))) |
|
| 61 | 61 | { |
| 62 | 62 | $single_ship_data = get_ship_data($ship_id, $user_data); |
| 63 | 63 | $return['ships'][$ship_id] = array( |
@@ -74,15 +74,15 @@ discard block |
||
| 74 | 74 | return $return; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | -function tpl_parse_fleet_db($fleet, $index, $user_data = false){return sn_function_call('tpl_parse_fleet_db', array($fleet, $index, $user_data, &$result));} |
|
| 77 | +function tpl_parse_fleet_db($fleet, $index, $user_data = false) {return sn_function_call('tpl_parse_fleet_db', array($fleet, $index, $user_data, &$result)); } |
|
| 78 | 78 | function sn_tpl_parse_fleet_db($fleet, $index, $user_data = false, &$result) { |
| 79 | 79 | global $lang, $user; |
| 80 | 80 | |
| 81 | - if(!$user_data) { |
|
| 81 | + if (!$user_data) { |
|
| 82 | 82 | $user_data = $user; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_AKS) { |
|
| 85 | + if ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_AKS) { |
|
| 86 | 86 | $aks = doquery("SELECT * FROM {{aks}} WHERE id={$fleet['fleet_group']} LIMIT 1;", true); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $ship_list = explode(';', $fleet['fleet_array']); |
| 134 | 134 | |
| 135 | - if($spy_level >= 6) { |
|
| 136 | - foreach($ship_list as $ship_record) { |
|
| 137 | - if($ship_record) { |
|
| 135 | + if ($spy_level >= 6) { |
|
| 136 | + foreach ($ship_list as $ship_record) { |
|
| 137 | + if ($ship_record) { |
|
| 138 | 138 | $ship_data = explode(',', $ship_record); |
| 139 | - if($spy_level >= 10) { |
|
| 139 | + if ($spy_level >= 10) { |
|
| 140 | 140 | $single_ship_data = get_ship_data($ship_data[0], $user_data); |
| 141 | 141 | $result['ships'][$ship_data[0]] = array( |
| 142 | 142 | 'ID' => $ship_data[0], |
@@ -169,9 +169,9 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | $hangar_que = array(); |
| 171 | 171 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
| 172 | - if(!empty($que_hangar)) |
|
| 172 | + if (!empty($que_hangar)) |
|
| 173 | 173 | { |
| 174 | - foreach($que_hangar as $que_item) |
|
| 174 | + foreach ($que_hangar as $que_item) |
|
| 175 | 175 | { |
| 176 | 176 | $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']); |
| 177 | 177 | $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount']; |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | 'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK), |
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | - if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) |
|
| 240 | + if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) |
|
| 241 | 241 | { |
| 242 | 242 | $result['building_que'] = array(); |
| 243 | 243 | $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]; |
| 244 | - foreach($building_que as $que_element) |
|
| 244 | + foreach ($building_que as $que_element) |
|
| 245 | 245 | { |
| 246 | 246 | $result['building_que'][] = que_tpl_parse_element($que_element); |
| 247 | 247 | } |
@@ -252,23 +252,23 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | function flt_get_fleets_to_planet($planet, $fleet_db_list = 0) |
| 254 | 254 | { |
| 255 | - if(!($planet && $planet['id']) && !$fleet_db_list) |
|
| 255 | + if (!($planet && $planet['id']) && !$fleet_db_list) |
|
| 256 | 256 | { |
| 257 | 257 | return $planet; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | global $user; |
| 261 | 261 | |
| 262 | - if($fleet_db_list === 0) |
|
| 262 | + if ($fleet_db_list === 0) |
|
| 263 | 263 | { |
| 264 | 264 | $fleet_db_list = flt_get_fleets($planet); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - foreach($fleet_db_list as $fleet) |
|
| 267 | + foreach ($fleet_db_list as $fleet) |
|
| 268 | 268 | { |
| 269 | - if($fleet['fleet_owner'] == $user['id']) |
|
| 269 | + if ($fleet['fleet_owner'] == $user['id']) |
|
| 270 | 270 | { |
| 271 | - if($fleet['fleet_mission'] == MT_MISSILE) |
|
| 271 | + if ($fleet['fleet_mission'] == MT_MISSILE) |
|
| 272 | 272 | { |
| 273 | 273 | continue; |
| 274 | 274 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | else |
| 278 | 278 | { |
| 279 | - switch($fleet['fleet_mission']) |
|
| 279 | + switch ($fleet['fleet_mission']) |
|
| 280 | 280 | { |
| 281 | 281 | case MT_ATTACK: |
| 282 | 282 | case MT_AKS: |
@@ -294,13 +294,13 @@ discard block |
||
| 294 | 294 | |
| 295 | 295 | $fleet_list[$fleet_ownage]['fleets'][$fleet['fleet_id']] = $fleet; |
| 296 | 296 | |
| 297 | - if($fleet['fleet_mess'] == 1 || ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_RELOCATE) || ($fleet['fleet_target_owner'] != $user['id'])) |
|
| 297 | + if ($fleet['fleet_mess'] == 1 || ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_RELOCATE) || ($fleet['fleet_target_owner'] != $user['id'])) |
|
| 298 | 298 | { |
| 299 | 299 | // $fleet_sn = flt_expand($fleet); |
| 300 | 300 | $fleet_sn = sys_unit_str2arr($fleet['fleet_array']); |
| 301 | - foreach($fleet_sn as $ship_id => $ship_amount) |
|
| 301 | + foreach ($fleet_sn as $ship_id => $ship_amount) |
|
| 302 | 302 | { |
| 303 | - if(in_array($ship_id, sn_get_groups('fleet'))) |
|
| 303 | + if (in_array($ship_id, sn_get_groups('fleet'))) |
|
| 304 | 304 | { |
| 305 | 305 | $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship_amount; |
| 306 | 306 | } |
@@ -324,13 +324,13 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | 'ENERGY_BALANCE' => pretty_number($planetrow['energy_max'] - $planetrow['energy_used'], true, true), |
| 326 | 326 | 'ENERGY_MAX' => pretty_number($planetrow['energy_max'], true, -$planetrow['energy_used']), |
| 327 | - 'ENERGY_FILL' => round(($planetrow["energy_used"]/($planetrow["energy_max"]+1))*100,0), |
|
| 327 | + 'ENERGY_FILL' => round(($planetrow["energy_used"] / ($planetrow["energy_max"] + 1)) * 100, 0), |
|
| 328 | 328 | |
| 329 | 329 | 'PLANET_METAL' => round($planetrow["metal"], $round), |
| 330 | 330 | 'PLANET_METAL_TEXT' => pretty_number($planetrow["metal"], $round, $planetrow["metal_max"]), |
| 331 | 331 | 'PLANET_METAL_MAX' => round($planetrow["metal_max"], $round), |
| 332 | 332 | 'PLANET_METAL_MAX_TEXT' => pretty_number($planetrow["metal_max"], $round, -$planetrow["metal"]), |
| 333 | - 'PLANET_METAL_FILL' => round(($planetrow["metal"]/($planetrow["metal_max"]+1))*100,0), |
|
| 333 | + 'PLANET_METAL_FILL' => round(($planetrow["metal"] / ($planetrow["metal_max"] + 1)) * 100, 0), |
|
| 334 | 334 | 'PLANET_METAL_PERHOUR' => round($planetrow["metal_perhour"], 5), |
| 335 | 335 | 'PLANET_METAL_FLEET_TEXT' => pretty_number($fleets_to_planet[$planetrow['id']]['fleet']['METAL'], $round, true), |
| 336 | 336 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | 'PLANET_CRYSTAL_TEXT' => pretty_number($planetrow["crystal"], $round, $planetrow["crystal_max"]), |
| 339 | 339 | 'PLANET_CRYSTAL_MAX' => round($planetrow["crystal_max"], $round), |
| 340 | 340 | 'PLANET_CRYSTAL_MAX_TEXT' => pretty_number($planetrow["crystal_max"], $round, -$planetrow["crystal"]), |
| 341 | - 'PLANET_CRYSTAL_FILL' => round(($planetrow["crystal"]/($planetrow["crystal_max"]+1))*100,0), |
|
| 341 | + 'PLANET_CRYSTAL_FILL' => round(($planetrow["crystal"] / ($planetrow["crystal_max"] + 1)) * 100, 0), |
|
| 342 | 342 | 'PLANET_CRYSTAL_PERHOUR' => round($planetrow["crystal_perhour"], 5), |
| 343 | 343 | 'PLANET_CRYSTAL_FLEET_TEXT' => pretty_number($fleets_to_planet[$planetrow['id']]['fleet']['CRYSTAL'], $round, true), |
| 344 | 344 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | 'PLANET_DEUTERIUM_TEXT' => pretty_number($planetrow["deuterium"], $round, $planetrow["deuterium_max"]), |
| 347 | 347 | 'PLANET_DEUTERIUM_MAX' => round($planetrow["deuterium_max"], $round), |
| 348 | 348 | 'PLANET_DEUTERIUM_MAX_TEXT' => pretty_number($planetrow["deuterium_max"], $round, -$planetrow["deuterium"]), |
| 349 | - 'PLANET_DEUTERIUM_FILL' => round(($planetrow["deuterium"]/($planetrow["deuterium_max"]+1))*100,0), |
|
| 349 | + 'PLANET_DEUTERIUM_FILL' => round(($planetrow["deuterium"] / ($planetrow["deuterium_max"] + 1)) * 100, 0), |
|
| 350 | 350 | 'PLANET_DEUTERIUM_PERHOUR' => round($planetrow["deuterium_perhour"], 5), |
| 351 | 351 | 'PLANET_DEUTERIUM_FLEET_TEXT' => pretty_number($fleets_to_planet[$planetrow['id']]['fleet']['DEUTERIUM'], $round, true), |
| 352 | 352 | )); |
@@ -10,8 +10,7 @@ discard block |
||
| 10 | 10 | return 0; |
| 11 | 11 | } |
| 12 | 12 | return ($a['fleet']['OV_LEFT'] < $b['fleet']['OV_LEFT']) ? -1 : 1; |
| 13 | - } |
|
| 14 | - else |
|
| 13 | + } else |
|
| 15 | 14 | { |
| 16 | 15 | return $a['fleet']['OV_THIS_PLANET'] ? -1 : 1; |
| 17 | 16 | } |
@@ -273,8 +272,7 @@ discard block |
||
| 273 | 272 | continue; |
| 274 | 273 | } |
| 275 | 274 | $fleet_ownage = 'own'; |
| 276 | - } |
|
| 277 | - else |
|
| 275 | + } else |
|
| 278 | 276 | { |
| 279 | 277 | switch($fleet['fleet_mission']) |
| 280 | 278 | { |
@@ -1,5 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +/** |
|
| 4 | + * @param double $planet_sectors |
|
| 5 | + */ |
|
| 3 | 6 | function uni_create_planet_get_density($position_data, $user_row, $planet_sectors) { |
| 4 | 7 | $density_list = sn_get_groups('planet_density'); |
| 5 | 8 | $density_min = reset($density_list); |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | $possible_cores = array(); |
| 9 | 9 | $probability = 0; |
| 10 | - foreach($density_list as $possible_core_id => $core_data) { |
|
| 11 | - if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
| 10 | + foreach ($density_list as $possible_core_id => $core_data) { |
|
| 11 | + if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
| 12 | 12 | continue; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if( |
|
| 15 | + if ( |
|
| 16 | 16 | // Core type exists |
| 17 | 17 | in_array($possible_core_id, $position_data['core_types']) |
| 18 | 18 | // Limit core type with planet sector count |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $random = mt_rand(1, $probability); |
| 35 | 35 | $selected_core = null; |
| 36 | - foreach($possible_cores as $core_type => $core_info) { |
|
| 37 | - if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
| 36 | + foreach ($possible_cores as $core_type => $core_info) { |
|
| 37 | + if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
| 38 | 38 | $selected_core = $core_info; |
| 39 | 39 | break; |
| 40 | 40 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $Position = intval($Position); |
| 61 | 61 | |
| 62 | - if(!isset($options['skip_check']) && db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
| 62 | + if (!isset($options['skip_check']) && db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
| 63 | 63 | return false; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $planet_generator = sn_get_groups('planet_generator'); |
| 70 | 70 | |
| 71 | - if($HomeWorld) { |
|
| 71 | + if ($HomeWorld) { |
|
| 72 | 72 | $position_data = $planet_generator[0]; |
| 73 | 73 | } else { |
| 74 | 74 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
| 75 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
| 75 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
| 76 | 76 | // Корректируем температуру для планеты-странника |
| 77 | 77 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
| 78 | 78 | } |
@@ -172,15 +172,15 @@ discard block |
||
| 172 | 172 | $moon_name = ''; |
| 173 | 173 | $moon_row = array(); |
| 174 | 174 | $moon = db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
| 175 | - if(!$moon['id']) { |
|
| 175 | + if (!$moon['id']) { |
|
| 176 | 176 | $moon_planet = db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`'); |
| 177 | 177 | |
| 178 | - if($moon_planet['id']) { |
|
| 178 | + if ($moon_planet['id']) { |
|
| 179 | 179 | $base_storage_size = BASE_STORAGE_SIZE; |
| 180 | 180 | |
| 181 | - if(!$moon_chance) { |
|
| 181 | + if (!$moon_chance) { |
|
| 182 | 182 | $size = mt_rand(1100, 8999); |
| 183 | - } elseif($moon_chance <= 100) { |
|
| 183 | + } elseif ($moon_chance <= 100) { |
|
| 184 | 184 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
| 185 | 185 | } else { |
| 186 | 186 | $size = $moon_chance; |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | $field_max = ceil($size / 1000); |
| 198 | 198 | |
| 199 | - if(isset($options['image']) && $options['image']) { |
|
| 199 | + if (isset($options['image']) && $options['image']) { |
|
| 200 | 200 | $moon_image = $options['image']; |
| 201 | 201 | } else { |
| 202 | 202 | $moon_image = 'mond'; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'" |
| 212 | 212 | ); |
| 213 | 213 | |
| 214 | - if($update_debris) { |
|
| 214 | + if ($update_debris) { |
|
| 215 | 215 | $debris_spent = $moon_chance * 1000000; |
| 216 | 216 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
| 217 | 217 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $planet_row['id'] = $user['current_planet']; |
| 248 | 248 | |
| 249 | 249 | // Пытаемся переключить на новую планету |
| 250 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
|
| 250 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
|
| 251 | 251 | { |
| 252 | 252 | $planet_row = db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
| 253 | 253 | } |
@@ -257,15 +257,15 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
| 260 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
| 260 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
| 261 | 261 | { |
| 262 | 262 | $planet_row = db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
| 263 | 263 | // Если текущей планеты не существует - выставляем Столицу |
| 264 | - if(!isset($planet_row['id'])) |
|
| 264 | + if (!isset($planet_row['id'])) |
|
| 265 | 265 | { |
| 266 | 266 | $planet_row = db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
| 267 | 267 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
| 268 | - if(!isset($planet_row['id'])) |
|
| 268 | + if (!isset($planet_row['id'])) |
|
| 269 | 269 | { |
| 270 | 270 | global $debug; |
| 271 | 271 | $debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Если производилось переключение планеты - делаем запись в юзере |
| 277 | - if($user['current_planet'] != $planet_row['id']) |
|
| 277 | + if ($user['current_planet'] != $planet_row['id']) |
|
| 278 | 278 | { |
| 279 | 279 | db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'"); |
| 280 | 280 | $user['current_planet'] = $planet_row['id']; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | { |
| 299 | 299 | global $lang; |
| 300 | 300 | |
| 301 | - if(!$from['id']) |
|
| 301 | + if (!$from['id']) |
|
| 302 | 302 | { |
| 303 | 303 | $result = $lang['sys_planet_expedition']; |
| 304 | 304 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | function uni_calculate_moon_chance($FleetDebris) |
| 338 | 338 | { |
| 339 | 339 | $MoonChance = $FleetDebris / 1000000; |
| 340 | - return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance); |
|
| 340 | + return ($MoonChance < 1) ? 0 : ($MoonChance > 30 ? 30 : $MoonChance); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | function uni_coordinates_valid($coordinates, $prefix = '') |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | global $lang, $config; |
| 360 | 360 | |
| 361 | 361 | try { |
| 362 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
| 362 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
| 363 | 363 | throw new exception($lang['ov_teleport_err_cooldown'], ERR_ERROR); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if(mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
| 366 | + if (mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
| 367 | 367 | throw new exception($lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
| 368 | 368 | } |
| 369 | 369 | |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | (fleet_start_galaxy = {$planetrow['galaxy']} and fleet_start_system = {$planetrow['system']} and fleet_start_planet = {$planetrow['planet']}) |
| 373 | 373 | or |
| 374 | 374 | (fleet_end_galaxy = {$planetrow['galaxy']} and fleet_end_system = {$planetrow['system']} and fleet_end_planet = {$planetrow['planet']})", true); |
| 375 | - if(!empty($incoming['incoming'])) { |
|
| 375 | + if (!empty($incoming['incoming'])) { |
|
| 376 | 376 | throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
| 377 | 377 | } |
| 378 | 378 | |
@@ -381,10 +381,10 @@ discard block |
||
| 381 | 381 | // throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
| 382 | 382 | //} |
| 383 | 383 | |
| 384 | - if(is_array($new_coordinates)) { |
|
| 384 | + if (is_array($new_coordinates)) { |
|
| 385 | 385 | $new_coordinates['planet_type'] = PT_PLANET; |
| 386 | 386 | $incoming = db_planet_by_vector($new_coordinates, '', true, 'id'); |
| 387 | - if($incoming['id']) { |
|
| 387 | + if ($incoming['id']) { |
|
| 388 | 388 | throw new exception($lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
| 389 | 389 | } |
| 390 | 390 | } |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | 'result' => ERR_NONE, |
| 394 | 394 | 'message' => '', |
| 395 | 395 | ); |
| 396 | - } catch(exception $e) { |
|
| 396 | + } catch (exception $e) { |
|
| 397 | 397 | $response = array( |
| 398 | 398 | 'result' => $e->getCode(), |
| 399 | 399 | 'message' => $e->getMessage(), |
@@ -250,16 +250,17 @@ discard block |
||
| 250 | 250 | if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
| 251 | 251 | { |
| 252 | 252 | $planet_row = db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
| 253 | - } |
|
| 254 | - else |
|
| 253 | + } else |
|
| 255 | 254 | { |
| 256 | 255 | $planet_row = db_planet_by_id($planet_row['id']); |
| 257 | 256 | } |
| 258 | 257 | |
| 259 | 258 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
| 260 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
| 259 | + if(!isset($planet_row['id'])) { |
|
| 260 | + // || $planet_row['id'] != $user['current_planet'] |
|
| 261 | 261 | { |
| 262 | 262 | $planet_row = db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
| 263 | + } |
|
| 263 | 264 | // Если текущей планеты не существует - выставляем Столицу |
| 264 | 265 | if(!isset($planet_row['id'])) |
| 265 | 266 | { |
@@ -301,8 +302,7 @@ discard block |
||
| 301 | 302 | if(!$from['id']) |
| 302 | 303 | { |
| 303 | 304 | $result = $lang['sys_planet_expedition']; |
| 304 | - } |
|
| 305 | - else |
|
| 305 | + } else |
|
| 306 | 306 | { |
| 307 | 307 | $from_planet_id = $include_id ? ( |
| 308 | 308 | 'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} ' |
@@ -11,6 +11,9 @@ discard block |
||
| 11 | 11 | require_once('general/math.php'); |
| 12 | 12 | require_once('general_pname.php'); |
| 13 | 13 | |
| 14 | +/** |
|
| 15 | + * @param string $func_name |
|
| 16 | + */ |
|
| 14 | 17 | function sn_function_call($func_name, $func_arg = array()) |
| 15 | 18 | { |
| 16 | 19 | global $functions; // All data in $functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
@@ -58,6 +61,9 @@ discard block |
||
| 58 | 61 | |
| 59 | 62 | // ---------------------------------------------------------------------------------------------------------------- |
| 60 | 63 | // Fonction de lecture / ecriture / exploitation de templates |
| 64 | +/** |
|
| 65 | + * @param string $filename |
|
| 66 | + */ |
|
| 61 | 67 | function sys_file_read($filename) |
| 62 | 68 | { |
| 63 | 69 | return @file_get_contents($filename); |
@@ -106,7 +112,7 @@ discard block |
||
| 106 | 112 | /** |
| 107 | 113 | * Получение курса обмены валюты в серверную валюту |
| 108 | 114 | * |
| 109 | - * @param $currency_symbol |
|
| 115 | + * @param string $currency_symbol |
|
| 110 | 116 | * |
| 111 | 117 | * @return float |
| 112 | 118 | */ |
@@ -143,6 +149,7 @@ discard block |
||
| 143 | 149 | null - standard result |
| 144 | 150 | true - return only style class for current params |
| 145 | 151 | false - return array('text' => $ret, 'class' => $class), where $ret - unstyled |
| 152 | + * @param boolean $style |
|
| 146 | 153 | */ |
| 147 | 154 | |
| 148 | 155 | function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) |
@@ -262,6 +269,9 @@ discard block |
||
| 262 | 269 | return preg_replace($ListCensure, '*', $String); |
| 263 | 270 | } |
| 264 | 271 | |
| 272 | +/** |
|
| 273 | + * @param string $email |
|
| 274 | + */ |
|
| 265 | 275 | function is_email($email) { |
| 266 | 276 | return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)); |
| 267 | 277 | } |
@@ -298,6 +308,9 @@ discard block |
||
| 298 | 308 | return floatval(sys_get_param($param_name, $default)); |
| 299 | 309 | } |
| 300 | 310 | |
| 311 | +/** |
|
| 312 | + * @param string $param_name |
|
| 313 | + */ |
|
| 301 | 314 | function sys_get_param_escaped($param_name, $default = '') |
| 302 | 315 | { |
| 303 | 316 | return db_escape(sys_get_param($param_name, $default)); |
@@ -542,6 +555,9 @@ discard block |
||
| 542 | 555 | } |
| 543 | 556 | |
| 544 | 557 | // Generates random string of $length symbols from $allowed_chars charset |
| 558 | +/** |
|
| 559 | + * @param string $allowed_chars |
|
| 560 | + */ |
|
| 545 | 561 | function sys_random_string($length = 16, $allowed_chars = SN_SYS_SEC_CHARS_ALLOWED) { |
| 546 | 562 | $allowed_length = strlen($allowed_chars); |
| 547 | 563 | |
@@ -667,6 +683,9 @@ discard block |
||
| 667 | 683 | return implode(';', $fleet_string); |
| 668 | 684 | } |
| 669 | 685 | |
| 686 | +/** |
|
| 687 | + * @param string $body |
|
| 688 | + */ |
|
| 670 | 689 | function mymail($email_unsafe, $title, $body, $from = '', $html = false) { |
| 671 | 690 | global $config, $lang; |
| 672 | 691 | |
@@ -954,6 +973,9 @@ discard block |
||
| 954 | 973 | return serialize($nick_array); |
| 955 | 974 | } |
| 956 | 975 | |
| 976 | +/** |
|
| 977 | + * @param string $nick_string |
|
| 978 | + */ |
|
| 957 | 979 | function player_nick_uncompact($nick_string) { |
| 958 | 980 | try { |
| 959 | 981 | $result = unserialize($nick_string); |
@@ -1237,6 +1259,9 @@ discard block |
||
| 1237 | 1259 | return $ranks; |
| 1238 | 1260 | } |
| 1239 | 1261 | |
| 1262 | +/** |
|
| 1263 | + * @param boolean $planet_id |
|
| 1264 | + */ |
|
| 1240 | 1265 | function sys_player_new_adjust($user_id, $planet_id){return sn_function_call('sys_player_new_adjust', array($user_id, $planet_id, &$result));} |
| 1241 | 1266 | function sn_sys_player_new_adjust($user_id, $planet_id, &$result) { |
| 1242 | 1267 | return $result; |
@@ -1589,6 +1614,9 @@ discard block |
||
| 1589 | 1614 | return version_compare(sn_version_compare_extra($ver1), sn_version_compare_extra($ver2)); |
| 1590 | 1615 | } |
| 1591 | 1616 | |
| 1617 | +/** |
|
| 1618 | + * @param string $name |
|
| 1619 | + */ |
|
| 1592 | 1620 | function sn_setcookie($name, $value = null, $expire = null, $path = SN_ROOT_RELATIVE, $domain = null, $secure = null, $httponly = null) { |
| 1593 | 1621 | $_COOKIE[$name] = $value; |
| 1594 | 1622 | return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly); |
@@ -815,7 +815,7 @@ |
||
| 815 | 815 | '%H' => '(?P<H>[0-9]{2})', |
| 816 | 816 | '%M' => '(?P<M>[0-9]{2})', |
| 817 | 817 | '%S' => '(?P<S>[0-9]{2})', |
| 818 | - // usw.. |
|
| 818 | + // usw.. |
|
| 819 | 819 | ); |
| 820 | 820 | |
| 821 | 821 | $rexep = "#".strtr(preg_quote($format), $masks)."#"; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | global $functions; // All data in $functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
| 17 | 17 | |
| 18 | - if(is_array($functions[$func_name]) && !is_callable($functions[$func_name])) |
|
| 18 | + if (is_array($functions[$func_name]) && !is_callable($functions[$func_name])) |
|
| 19 | 19 | { |
| 20 | 20 | // Chain-callable functions should be made as following: |
| 21 | 21 | // 1. Never use incomplete calls with parameters "by default" |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | // 3. Use same format for original value and cumulative result (if there is original value) |
| 24 | 24 | // 4. Honor cumulative result |
| 25 | 25 | // 5. Return cumulative result |
| 26 | - foreach($functions[$func_name] as $func_chain_name) |
|
| 26 | + foreach ($functions[$func_name] as $func_chain_name) |
|
| 27 | 27 | { |
| 28 | 28 | // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту |
| 29 | 29 | // Но для старых модулей... |
| 30 | - if(is_callable($func_chain_name)) |
|
| 30 | + if (is_callable($func_chain_name)) |
|
| 31 | 31 | { |
| 32 | 32 | $result = call_user_func_array($func_chain_name, $func_arg); |
| 33 | 33 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | // TODO: This is left for backward compatibility. Appropriate code should be rewrote! |
| 39 | 39 | $func_name = isset($functions[$func_name]) && is_callable($functions[$func_name]) ? $functions[$func_name] : ('sn_' . $func_name); |
| 40 | - if(is_callable($func_name)) |
|
| 40 | + if (is_callable($func_name)) |
|
| 41 | 41 | { |
| 42 | 42 | $result = call_user_func_array($func_name, $func_arg); |
| 43 | 43 | } |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | function execute_hooks(&$hook_list, &$template) { |
| 50 | - if(!empty($hook_list)) { |
|
| 51 | - foreach($hook_list as $hook) { |
|
| 52 | - if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
| 50 | + if (!empty($hook_list)) { |
|
| 51 | + foreach ($hook_list as $hook) { |
|
| 52 | + if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
| 53 | 53 | $template = call_user_func($hook_call, $template); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -68,21 +68,21 @@ discard block |
||
| 68 | 68 | return @file_put_contents($filename, $content, FILE_APPEND); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | -function get_game_speed($plain = false){return sn_function_call('get_game_speed', array($plain, &$result));} |
|
| 71 | +function get_game_speed($plain = false) {return sn_function_call('get_game_speed', array($plain, &$result)); } |
|
| 72 | 72 | function sn_get_game_speed($plain = false, &$result) { |
| 73 | 73 | global $config; |
| 74 | 74 | |
| 75 | 75 | return $result = $config->game_speed ? $config->game_speed : 1; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | -function flt_server_flight_speed_multiplier($plain = false){return sn_function_call('flt_server_flight_speed_multiplier', array($plain, &$result));} |
|
| 78 | +function flt_server_flight_speed_multiplier($plain = false) {return sn_function_call('flt_server_flight_speed_multiplier', array($plain, &$result)); } |
|
| 79 | 79 | function sn_flt_server_flight_speed_multiplier($plain = false, &$result) { |
| 80 | 80 | global $config; |
| 81 | 81 | |
| 82 | 82 | return $result = $config->fleet_speed; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | -function game_resource_multiplier($plain = false){return sn_function_call('game_resource_multiplier', array($plain,&$result));} |
|
| 85 | +function game_resource_multiplier($plain = false) {return sn_function_call('game_resource_multiplier', array($plain, &$result)); } |
|
| 86 | 86 | function sn_game_resource_multiplier($plain = false, &$result) { |
| 87 | 87 | global $config; |
| 88 | 88 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @return mixed |
| 98 | 98 | */ |
| 99 | -function get_mm_cost($plain = false){return sn_function_call('get_mm_cost', array($plain, &$result));} |
|
| 99 | +function get_mm_cost($plain = false) {return sn_function_call('get_mm_cost', array($plain, &$result)); } |
|
| 100 | 100 | function sn_get_mm_cost($plain = false, &$result) { |
| 101 | 101 | global $config; |
| 102 | 102 | |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) |
| 149 | 149 | { |
| 150 | 150 | $n = floatval($n); |
| 151 | - if(is_int($floor)) |
|
| 151 | + if (is_int($floor)) |
|
| 152 | 152 | { |
| 153 | 153 | $n = round($n, $floor); // , PHP_ROUND_HALF_DOWN |
| 154 | 154 | } |
| 155 | - elseif($floor === true) |
|
| 155 | + elseif ($floor === true) |
|
| 156 | 156 | { |
| 157 | 157 | $n = floor($n); |
| 158 | 158 | $floor = 0; |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | $ret = $n; |
| 166 | 166 | |
| 167 | 167 | $suffix = ''; |
| 168 | - if($limit) |
|
| 168 | + if ($limit) |
|
| 169 | 169 | { |
| 170 | - if($ret > 0) |
|
| 170 | + if ($ret > 0) |
|
| 171 | 171 | { |
| 172 | - while($ret > $limit) |
|
| 172 | + while ($ret > $limit) |
|
| 173 | 173 | { |
| 174 | 174 | $suffix .= 'k'; |
| 175 | 175 | $ret = round($ret / 1000); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | else |
| 179 | 179 | { |
| 180 | - while($ret < -$limit) |
|
| 180 | + while ($ret < -$limit) |
|
| 181 | 181 | { |
| 182 | 182 | $suffix .= 'k'; |
| 183 | 183 | $ret = round($ret / 1000); |
@@ -188,13 +188,13 @@ discard block |
||
| 188 | 188 | $ret = number_format($ret, $floor, ',', '.'); |
| 189 | 189 | $ret .= $suffix; |
| 190 | 190 | |
| 191 | - if($color !== false) |
|
| 191 | + if ($color !== false) |
|
| 192 | 192 | { |
| 193 | - if($color === true) |
|
| 193 | + if ($color === true) |
|
| 194 | 194 | { |
| 195 | 195 | $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative'); |
| 196 | 196 | } |
| 197 | - elseif($color >= 0) |
|
| 197 | + elseif ($color >= 0) |
|
| 198 | 198 | { |
| 199 | 199 | $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative'); |
| 200 | 200 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive'); |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if(!isset($style)) |
|
| 206 | + if (!isset($style)) |
|
| 207 | 207 | { |
| 208 | 208 | $ret = "<span class='{$class}'>{$ret}</span>"; |
| 209 | 209 | } |
@@ -338,13 +338,13 @@ discard block |
||
| 338 | 338 | function sys_get_param_phone($param_name, $default = '') |
| 339 | 339 | { |
| 340 | 340 | $phone_raw = sys_get_param_str_unsafe($param_name, $default = ''); |
| 341 | - if($phone_raw) |
|
| 341 | + if ($phone_raw) |
|
| 342 | 342 | { |
| 343 | 343 | $phone = $phone_raw[0] == '+' ? '+' : ''; |
| 344 | - for($i = 0; $i < strlen($phone_raw); $i++) |
|
| 344 | + for ($i = 0; $i < strlen($phone_raw); $i++) |
|
| 345 | 345 | { |
| 346 | 346 | $ord = ord($phone_raw[$i]); |
| 347 | - if($ord >= 48 && $ord <= 57) |
|
| 347 | + if ($ord >= 48 && $ord <= 57) |
|
| 348 | 348 | { |
| 349 | 349 | $phone .= $phone_raw[$i]; |
| 350 | 350 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | function CheckAbandonPlanetState(&$planet) |
| 368 | 368 | { |
| 369 | - if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) |
|
| 369 | + if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) |
|
| 370 | 370 | { |
| 371 | 371 | db_planet_delete_by_id($planet['id']); |
| 372 | 372 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | global $config; |
| 378 | 378 | |
| 379 | 379 | static $rate, $sn_group_resources_all, $sn_group_resources_loot; |
| 380 | - if(!$rate) |
|
| 380 | + if (!$rate) |
|
| 381 | 381 | { |
| 382 | 382 | $sn_group_resources_all = sn_get_groups('resources_all'); |
| 383 | 383 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
@@ -388,22 +388,22 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | $unit_cost_data = get_unit_param($unit_id, 'cost'); |
| 391 | - if(!is_array($unit_cost_data)) |
|
| 391 | + if (!is_array($unit_cost_data)) |
|
| 392 | 392 | { |
| 393 | 393 | return array('total' => 0); |
| 394 | 394 | } |
| 395 | 395 | $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1; |
| 396 | 396 | $cost_array = array(BUILD_CREATE => array(), 'total' => 0); |
| 397 | 397 | $unit_level = $unit_level > 0 ? $unit_level : 0; |
| 398 | - foreach($unit_cost_data as $resource_id => $resource_amount) |
|
| 398 | + foreach ($unit_cost_data as $resource_id => $resource_amount) |
|
| 399 | 399 | { |
| 400 | - if(!in_array($resource_id, $sn_group_resources_all)) |
|
| 400 | + if (!in_array($resource_id, $sn_group_resources_all)) |
|
| 401 | 401 | { |
| 402 | 402 | continue; |
| 403 | 403 | } |
| 404 | 404 | // $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1))); |
| 405 | 405 | $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor)))); |
| 406 | - if(in_array($resource_id, $sn_group_resources_loot)) |
|
| 406 | + if (in_array($resource_id, $sn_group_resources_loot)) |
|
| 407 | 407 | { |
| 408 | 408 | $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id]; |
| 409 | 409 | } |
@@ -412,9 +412,9 @@ discard block |
||
| 412 | 412 | return $cost_array; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | -function sn_unit_purchase($unit_id){} |
|
| 415 | +function sn_unit_purchase($unit_id) {} |
|
| 416 | 416 | |
| 417 | -function sn_unit_relocate($unit_id, $from, $to){} |
|
| 417 | +function sn_unit_relocate($unit_id, $from, $to) {} |
|
| 418 | 418 | |
| 419 | 419 | /* |
| 420 | 420 | ЭТО ПРОСТОЙ ВРАППЕР ДЛЯ БД! Здесь НЕТ никаких проверок! ВСЕ проверки должны быть сделаны заранее! |
@@ -473,48 +473,48 @@ discard block |
||
| 473 | 473 | } |
| 474 | 474 | */ |
| 475 | 475 | |
| 476 | -function mrc_get_level(&$user, $planet = array(), $unit_id, $for_update = false, $plain = false){return sn_function_call(__FUNCTION__, array(&$user, $planet, $unit_id, $for_update, $plain, &$result));} |
|
| 476 | +function mrc_get_level(&$user, $planet = array(), $unit_id, $for_update = false, $plain = false) {return sn_function_call(__FUNCTION__, array(&$user, $planet, $unit_id, $for_update, $plain, &$result)); } |
|
| 477 | 477 | function sn_mrc_get_level(&$user, $planet = array(), $unit_id, $for_update = false, $plain = false, &$result) { |
| 478 | 478 | $mercenary_level = 0; |
| 479 | 479 | $unit_db_name = pname_resource_name($unit_id); |
| 480 | 480 | |
| 481 | - if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
| 481 | + if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
| 482 | 482 | $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id); |
| 483 | 483 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
| 484 | - } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
| 484 | + } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
| 485 | 485 | $unit = classSupernova::db_get_unit_by_location(is_array($user) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id); |
| 486 | 486 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
| 487 | - } elseif(in_array($unit_id, sn_get_groups('governors'))) { |
|
| 487 | + } elseif (in_array($unit_id, sn_get_groups('governors'))) { |
|
| 488 | 488 | $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0; |
| 489 | - } elseif($unit_id == RES_DARK_MATTER) { |
|
| 489 | + } elseif ($unit_id == RES_DARK_MATTER) { |
|
| 490 | 490 | $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter); |
| 491 | - } elseif($unit_id == RES_METAMATTER) { |
|
| 491 | + } elseif ($unit_id == RES_METAMATTER) { |
|
| 492 | 492 | $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name]; |
| 493 | - } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
| 493 | + } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
| 494 | 494 | $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name]; |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | return $result = $mercenary_level; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | -function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) {return sn_function_call('mrc_modify_value', array(&$user, $planet, $mercenaries, $value));} |
|
| 500 | +function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) {return sn_function_call('mrc_modify_value', array(&$user, $planet, $mercenaries, $value)); } |
|
| 501 | 501 | function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) |
| 502 | 502 | { |
| 503 | - if(!is_array($mercenaries)) |
|
| 503 | + if (!is_array($mercenaries)) |
|
| 504 | 504 | { |
| 505 | 505 | $mercenaries = array($mercenaries); |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | $base_value = isset($base_value) ? $base_value : $value; |
| 509 | 509 | |
| 510 | - foreach($mercenaries as $mercenary_id) |
|
| 510 | + foreach ($mercenaries as $mercenary_id) |
|
| 511 | 511 | { |
| 512 | 512 | $mercenary_level = mrc_get_level($user, $planet, $mercenary_id); |
| 513 | 513 | |
| 514 | 514 | $mercenary = get_unit_param($mercenary_id); |
| 515 | 515 | $mercenary_bonus = $mercenary['bonus']; |
| 516 | 516 | |
| 517 | - switch($mercenary['bonus_type']) |
|
| 517 | + switch ($mercenary['bonus_type']) |
|
| 518 | 518 | { |
| 519 | 519 | case BONUS_PERCENT_CUMULATIVE: |
| 520 | 520 | $value *= 1 + $mercenary_level * $mercenary_bonus / 100; |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | $allowed_length = strlen($allowed_chars); |
| 547 | 547 | |
| 548 | 548 | $random_string = ''; |
| 549 | - for($i = 0; $i < $length; $i++) { |
|
| 549 | + for ($i = 0; $i < $length; $i++) { |
|
| 550 | 550 | $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)]; |
| 551 | 551 | } |
| 552 | 552 | |
@@ -569,10 +569,10 @@ discard block |
||
| 569 | 569 | |
| 570 | 570 | $options = ''; |
| 571 | 571 | $option_list = array(); |
| 572 | - foreach($user_option_list as $option_group_id => $option_group) |
|
| 572 | + foreach ($user_option_list as $option_group_id => $option_group) |
|
| 573 | 573 | { |
| 574 | 574 | $option_list[$option_group_id] = array(); |
| 575 | - foreach($option_group as $option_name => $option_value) |
|
| 575 | + foreach ($option_group as $option_name => $option_value) |
|
| 576 | 576 | { |
| 577 | 577 | if (!isset($user[$option_name])) |
| 578 | 578 | { |
@@ -598,19 +598,19 @@ discard block |
||
| 598 | 598 | $option_list = array(); |
| 599 | 599 | $option_string_list = explode('|', $user['options']); |
| 600 | 600 | |
| 601 | - foreach($option_string_list as $option_string) |
|
| 601 | + foreach ($option_string_list as $option_string) |
|
| 602 | 602 | { |
| 603 | 603 | list($option_name, $option_value) = explode('^', $option_string); |
| 604 | 604 | $option_list[$option_name] = $option_value; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | $final_list = array(); |
| 608 | - foreach($user_option_list as $option_group_id => $option_group) |
|
| 608 | + foreach ($user_option_list as $option_group_id => $option_group) |
|
| 609 | 609 | { |
| 610 | 610 | $final_list[$option_group_id] = array(); |
| 611 | - foreach($option_group as $option_name => $option_value) |
|
| 611 | + foreach ($option_group as $option_name => $option_value) |
|
| 612 | 612 | { |
| 613 | - if(!isset($option_list[$option_name])) |
|
| 613 | + if (!isset($option_list[$option_name])) |
|
| 614 | 614 | { |
| 615 | 615 | $option_list[$option_name] = $option_value; |
| 616 | 616 | } |
@@ -626,15 +626,15 @@ discard block |
||
| 626 | 626 | function sys_unit_str2arr($fleet_string) |
| 627 | 627 | { |
| 628 | 628 | $fleet_array = array(); |
| 629 | - if(!empty($fleet_string)) |
|
| 629 | + if (!empty($fleet_string)) |
|
| 630 | 630 | { |
| 631 | 631 | $arrTemp = explode(';', $fleet_string); |
| 632 | - foreach($arrTemp as $temp) |
|
| 632 | + foreach ($arrTemp as $temp) |
|
| 633 | 633 | { |
| 634 | - if($temp) |
|
| 634 | + if ($temp) |
|
| 635 | 635 | { |
| 636 | 636 | $temp = explode(',', $temp); |
| 637 | - if(!empty($temp[0]) && !empty($temp[1])) |
|
| 637 | + if (!empty($temp[0]) && !empty($temp[1])) |
|
| 638 | 638 | { |
| 639 | 639 | $fleet_array[$temp[0]] += $temp[1]; |
| 640 | 640 | } |
@@ -648,16 +648,16 @@ discard block |
||
| 648 | 648 | function sys_unit_arr2str($unit_list) |
| 649 | 649 | { |
| 650 | 650 | $fleet_string = array(); |
| 651 | - if(isset($unit_list)) |
|
| 651 | + if (isset($unit_list)) |
|
| 652 | 652 | { |
| 653 | - if(!is_array($unit_list)) |
|
| 653 | + if (!is_array($unit_list)) |
|
| 654 | 654 | { |
| 655 | 655 | $unit_list = array($unit_list => 1); |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - foreach($unit_list as $unit_id => $unit_count) |
|
| 658 | + foreach ($unit_list as $unit_id => $unit_count) |
|
| 659 | 659 | { |
| 660 | - if($unit_id && $unit_count) |
|
| 660 | + if ($unit_id && $unit_count) |
|
| 661 | 661 | { |
| 662 | 662 | $fleet_string[] = "{$unit_id},{$unit_count}"; |
| 663 | 663 | } |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | $from = trim($from ? $from : $config->game_adminEmail); |
| 674 | 674 | |
| 675 | 675 | $head = ''; |
| 676 | - $head .= "Content-Type: text/" . ($html ? 'html' : 'plain'). "; charset=utf-8 \r\n"; |
|
| 676 | + $head .= "Content-Type: text/" . ($html ? 'html' : 'plain') . "; charset=utf-8 \r\n"; |
|
| 677 | 677 | $head .= "Date: " . date('r') . " \r\n"; |
| 678 | 678 | $head .= "Return-Path: {$config->game_adminEmail} \r\n"; |
| 679 | 679 | $head .= "From: {$from} \r\n"; |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | $body = str_replace("\r\n", "\n", $body); |
| 686 | 686 | $body = str_replace("\n", "\r\n", $body); |
| 687 | 687 | |
| 688 | - if($html) { |
|
| 688 | + if ($html) { |
|
| 689 | 689 | $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>'; |
| 690 | 690 | } |
| 691 | 691 | |
@@ -699,15 +699,15 @@ discard block |
||
| 699 | 699 | global $lang; |
| 700 | 700 | |
| 701 | 701 | $seconds = $time % 60; |
| 702 | - $time = floor($time/60); |
|
| 702 | + $time = floor($time / 60); |
|
| 703 | 703 | $minutes = $time % 60; |
| 704 | - $time = floor($time/60); |
|
| 704 | + $time = floor($time / 60); |
|
| 705 | 705 | $hours = $time % 24; |
| 706 | - $time = floor($time/24); |
|
| 706 | + $time = floor($time / 24); |
|
| 707 | 707 | |
| 708 | 708 | return |
| 709 | - ($full || $time ? "{$time} {$lang['sys_day']} " : '') . |
|
| 710 | - ($full || $hours ? "{$hours} {$lang['sys_hrs']} " : '') . |
|
| 709 | + ($full || $time ? "{$time} {$lang['sys_day']} " : '') . |
|
| 710 | + ($full || $hours ? "{$hours} {$lang['sys_hrs']} " : '') . |
|
| 711 | 711 | ($full || $minutes ? "{$minutes} {$lang['sys_min']} " : '') . |
| 712 | 712 | ($full || !$time || $seconds ? "{$seconds} {$lang['sys_sec']}" : ''); |
| 713 | 713 | } |
@@ -724,35 +724,35 @@ discard block |
||
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | // TODO Для полноценного функионирования апдейтера пакет функций, включая эту должен быть вынесен раньше - или грузить general.php до апдейтера |
| 727 | -function sys_get_unit_location($user, $planet, $unit_id){return sn_function_call('sys_get_unit_location', array($user, $planet, $unit_id));} |
|
| 727 | +function sys_get_unit_location($user, $planet, $unit_id) {return sn_function_call('sys_get_unit_location', array($user, $planet, $unit_id)); } |
|
| 728 | 728 | function sn_sys_get_unit_location($user, $planet, $unit_id) |
| 729 | 729 | { |
| 730 | 730 | return get_unit_param($unit_id, 'location'); |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | function sn_ali_fill_user_ally(&$user) { |
| 734 | - if(!$user['ally_id']) { |
|
| 734 | + if (!$user['ally_id']) { |
|
| 735 | 735 | return; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - if(!isset($user['ally'])) { |
|
| 738 | + if (!isset($user['ally'])) { |
|
| 739 | 739 | $user['ally'] = doquery("SELECT * FROM {{alliance}} WHERE `id` = {$user['ally_id']} LIMIT 1;", true); |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - if(!isset($user['ally']['player'])) { |
|
| 742 | + if (!isset($user['ally']['player'])) { |
|
| 743 | 743 | $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false); |
| 744 | 744 | } |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | function sn_get_url_contents($url) |
| 748 | 748 | { |
| 749 | - if(function_exists('curl_init')) |
|
| 749 | + if (function_exists('curl_init')) |
|
| 750 | 750 | { |
| 751 | 751 | $crl = curl_init(); |
| 752 | 752 | $timeout = 5; |
| 753 | - curl_setopt ($crl, CURLOPT_URL,$url); |
|
| 754 | - curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); |
|
| 755 | - curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 753 | + curl_setopt($crl, CURLOPT_URL, $url); |
|
| 754 | + curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); |
|
| 755 | + curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 756 | 756 | $return = curl_exec($crl); |
| 757 | 757 | curl_close($crl); |
| 758 | 758 | } |
@@ -786,12 +786,12 @@ discard block |
||
| 786 | 786 | function get_ship_data($ship_id, $user) |
| 787 | 787 | { |
| 788 | 788 | $ship_data = array(); |
| 789 | - if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
|
| 789 | + if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
|
| 790 | 790 | { |
| 791 | - foreach(get_unit_param($ship_id, 'engine') as $engine_info) |
|
| 791 | + foreach (get_unit_param($ship_id, 'engine') as $engine_info) |
|
| 792 | 792 | { |
| 793 | 793 | $tech_level = intval(mrc_get_level($user, false, $engine_info['tech'])); |
| 794 | - if(empty($ship_data) || $tech_level >= $engine_info['min_level']) |
|
| 794 | + if (empty($ship_data) || $tech_level >= $engine_info['min_level']) |
|
| 795 | 795 | { |
| 796 | 796 | $ship_data = $engine_info; |
| 797 | 797 | $ship_data['tech_level'] = $tech_level; |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | return $ship_data; |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | -if(!function_exists('strptime')) |
|
| 807 | +if (!function_exists('strptime')) |
|
| 808 | 808 | { |
| 809 | 809 | function strptime($date, $format) |
| 810 | 810 | { |
@@ -818,8 +818,8 @@ discard block |
||
| 818 | 818 | // usw.. |
| 819 | 819 | ); |
| 820 | 820 | |
| 821 | - $rexep = "#".strtr(preg_quote($format), $masks)."#"; |
|
| 822 | - if(preg_match($rexep, $date, $out)) |
|
| 821 | + $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
|
| 822 | + if (preg_match($rexep, $date, $out)) |
|
| 823 | 823 | { |
| 824 | 824 | $ret = array( |
| 825 | 825 | "tm_sec" => (int) $out['S'], |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | function sn_sys_sector_buy($redirect = 'overview.php') { |
| 842 | 842 | global $lang, $user, $planetrow; |
| 843 | 843 | |
| 844 | - if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
| 844 | + if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
| 845 | 845 | return; |
| 846 | 846 | } |
| 847 | 847 | |
@@ -854,9 +854,9 @@ discard block |
||
| 854 | 854 | // $planetrow = $planetrow['planet']; |
| 855 | 855 | $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true); |
| 856 | 856 | $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 857 | - if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
| 857 | + if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
| 858 | 858 | $planet_name_text = uni_render_planet($planetrow); |
| 859 | - if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf($lang['sys_sector_purchase_log'], |
|
| 859 | + if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf($lang['sys_sector_purchase_log'], |
|
| 860 | 860 | $user['username'], $user['id'], $planet_name_text, $lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost) |
| 861 | 861 | )) { |
| 862 | 862 | $sector_db_name = pname_resource_name(UNIT_SECTOR); |
@@ -872,43 +872,43 @@ discard block |
||
| 872 | 872 | |
| 873 | 873 | function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') |
| 874 | 874 | { |
| 875 | - if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) |
|
| 875 | + if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) |
|
| 876 | 876 | { |
| 877 | - foreach($handler_list as $function_name => $function_data) |
|
| 877 | + foreach ($handler_list as $function_name => $function_data) |
|
| 878 | 878 | { |
| 879 | - if(is_string($function_data)) |
|
| 879 | + if (is_string($function_data)) |
|
| 880 | 880 | { |
| 881 | 881 | $override_with = &$function_data; |
| 882 | 882 | } |
| 883 | - elseif(isset($function_data['callable'])) |
|
| 883 | + elseif (isset($function_data['callable'])) |
|
| 884 | 884 | { |
| 885 | 885 | $override_with = &$function_data['callable']; |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | $overwrite = $override_with[0] == '*'; |
| 889 | - if($overwrite) |
|
| 889 | + if ($overwrite) |
|
| 890 | 890 | { |
| 891 | 891 | $override_with = substr($override_with, 1); |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | - if(($point_position = strpos($override_with, '.')) === false && $class_module_name) |
|
| 894 | + if (($point_position = strpos($override_with, '.')) === false && $class_module_name) |
|
| 895 | 895 | { |
| 896 | 896 | $override_with = array($class_module_name, $override_with); |
| 897 | 897 | } |
| 898 | - elseif($point_position == 0) |
|
| 898 | + elseif ($point_position == 0) |
|
| 899 | 899 | { |
| 900 | 900 | $override_with = substr($override_with, 1); |
| 901 | 901 | } |
| 902 | - elseif($point_position > 0) |
|
| 902 | + elseif ($point_position > 0) |
|
| 903 | 903 | { |
| 904 | 904 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - if($overwrite) |
|
| 907 | + if ($overwrite) |
|
| 908 | 908 | { |
| 909 | 909 | $functions[$function_name] = array(); |
| 910 | 910 | } |
| 911 | - elseif(!isset($functions[$function_name])) |
|
| 911 | + elseif (!isset($functions[$function_name])) |
|
| 912 | 912 | { |
| 913 | 913 | $functions[$function_name] = array(); |
| 914 | 914 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
@@ -925,18 +925,18 @@ discard block |
||
| 925 | 925 | |
| 926 | 926 | // TODO - поменять название |
| 927 | 927 | // Может принимать: (array)$user, $nick_render_array, $nick_render_array_html, $nick_render_string_compact |
| 928 | -function player_nick_render_to_html($result, $options = false){ |
|
| 928 | +function player_nick_render_to_html($result, $options = false) { |
|
| 929 | 929 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string |
| 930 | 930 | |
| 931 | - if(is_string($result) && strpos($result, ':{i:')) { |
|
| 931 | + if (is_string($result) && strpos($result, ':{i:')) { |
|
| 932 | 932 | $result = player_nick_uncompact($result); |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - if(is_array($result)) { |
|
| 936 | - if(isset($result['id'])) { |
|
| 935 | + if (is_array($result)) { |
|
| 936 | + if (isset($result['id'])) { |
|
| 937 | 937 | $result = player_nick_render_current_to_array($result, $options); |
| 938 | 938 | } |
| 939 | - if(!isset($result[NICK_HTML])) { |
|
| 939 | + if (!isset($result[NICK_HTML])) { |
|
| 940 | 940 | $result = player_nick_render_array_to_html($result); |
| 941 | 941 | } |
| 942 | 942 | unset($result[NICK_HTML]); |
@@ -958,31 +958,31 @@ discard block |
||
| 958 | 958 | try { |
| 959 | 959 | $result = unserialize($nick_string); |
| 960 | 960 | // ksort($result); // Всегда ksort-ый в player_nick_compact() |
| 961 | - } catch(exception $e) { |
|
| 961 | + } catch (exception $e) { |
|
| 962 | 962 | $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example |
| 963 | 963 | } |
| 964 | 964 | return $result; |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | -function player_nick_render_array_to_html($nick_array){return sn_function_call('player_nick_render_array_to_html', array($nick_array, &$result));} |
|
| 967 | +function player_nick_render_array_to_html($nick_array) {return sn_function_call('player_nick_render_array_to_html', array($nick_array, &$result)); } |
|
| 968 | 968 | function sn_player_nick_render_array_to_html($nick_array, &$result) { |
| 969 | 969 | global $config, $user; |
| 970 | 970 | |
| 971 | 971 | // ALL STRING ARE UNSAFE!!! |
| 972 | - if(isset($nick_array[NICK_BIRTHSDAY])) { |
|
| 972 | + if (isset($nick_array[NICK_BIRTHSDAY])) { |
|
| 973 | 973 | $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />'; |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | - if(isset($nick_array[NICK_VACATION])) { |
|
| 976 | + if (isset($nick_array[NICK_VACATION])) { |
|
| 977 | 977 | $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />'; |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | - if(isset($nick_array[NICK_GENDER])) { |
|
| 980 | + if (isset($nick_array[NICK_GENDER])) { |
|
| 981 | 981 | $result[NICK_GENDER] = '<img src="' . ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />'; |
| 982 | 982 | } |
| 983 | 983 | |
| 984 | - if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
| 985 | - switch($nick_array[NICK_AUTH_LEVEL]) { |
|
| 984 | + if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
| 985 | + switch ($nick_array[NICK_AUTH_LEVEL]) { |
|
| 986 | 986 | case 4: |
| 987 | 987 | $highlight = $config->chat_highlight_developer; |
| 988 | 988 | break; |
@@ -1003,20 +1003,20 @@ discard block |
||
| 1003 | 1003 | $highlight = isset($nick_array[NICK_PREMIUM]) ? $config->chat_highlight_premium : ''; |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - if($highlight) { |
|
| 1006 | + if ($highlight) { |
|
| 1007 | 1007 | list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight); |
| 1008 | 1008 | } |
| 1009 | 1009 | // $result = preg_replace("#(.+)#", $highlight, $result); |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | - if(isset($nick_array[NICK_CLASS])) { |
|
| 1013 | - $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] .'>'; |
|
| 1012 | + if (isset($nick_array[NICK_CLASS])) { |
|
| 1013 | + $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>'; |
|
| 1014 | 1014 | $result[NICK_CLASS_END] = '</span>'; |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]); |
| 1018 | 1018 | |
| 1019 | - if(isset($nick_array[NICK_ALLY])) { |
|
| 1019 | + if (isset($nick_array[NICK_ALLY])) { |
|
| 1020 | 1020 | $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']'; |
| 1021 | 1021 | } |
| 1022 | 1022 | |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | return $result; |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | -function player_nick_render_current_to_array($render_user, $options = false){return sn_function_call('player_nick_render_current_to_array', array($render_user, $options, &$result));} |
|
| 1028 | +function player_nick_render_current_to_array($render_user, $options = false) {return sn_function_call('player_nick_render_current_to_array', array($render_user, $options, &$result)); } |
|
| 1029 | 1029 | function sn_player_nick_render_current_to_array($render_user, $options = false, &$result) { |
| 1030 | 1030 | /* |
| 1031 | 1031 | $options = $options !== true ? $options : |
@@ -1039,32 +1039,32 @@ discard block |
||
| 1039 | 1039 | */ |
| 1040 | 1040 | |
| 1041 | 1041 | |
| 1042 | - if($render_user['user_birthday'] && ($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))) { |
|
| 1042 | + if ($render_user['user_birthday'] && ($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))) { |
|
| 1043 | 1043 | $result[NICK_BIRTHSDAY] = ''; |
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | - if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
| 1046 | + if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
| 1047 | 1047 | $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male'); |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
| 1050 | + if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
| 1051 | 1051 | $result[NICK_VACATION] = $render_user['vacation']; |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | - if($options === true || (isset($options['color']) && $options['color'])) { |
|
| 1055 | - if($user_auth_level = $render_user['authlevel']) { |
|
| 1054 | + if ($options === true || (isset($options['color']) && $options['color'])) { |
|
| 1055 | + if ($user_auth_level = $render_user['authlevel']) { |
|
| 1056 | 1056 | $result[NICK_AUTH_LEVEL] = $user_auth_level; |
| 1057 | 1057 | } |
| 1058 | - if($user_premium = mrc_get_level($render_user, false, UNIT_PREMIUM)) { |
|
| 1058 | + if ($user_premium = mrc_get_level($render_user, false, UNIT_PREMIUM)) { |
|
| 1059 | 1059 | $result[NICK_PREMIUM] = $user_premium; |
| 1060 | 1060 | } |
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | - if((isset($options['class']) && $options['class'])) { |
|
| 1063 | + if ((isset($options['class']) && $options['class'])) { |
|
| 1064 | 1064 | $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class']; |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | - if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
| 1067 | + if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
| 1068 | 1068 | $result[NICK_ALLY] = $render_user['ally_tag']; |
| 1069 | 1069 | } |
| 1070 | 1070 | |
@@ -1115,25 +1115,25 @@ discard block |
||
| 1115 | 1115 | |
| 1116 | 1116 | $user_skip_list = array(); |
| 1117 | 1117 | |
| 1118 | - if($config->stats_hide_admins) { |
|
| 1118 | + if ($config->stats_hide_admins) { |
|
| 1119 | 1119 | $user_skip_list[] = '`authlevel` > 0'; |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | - if($config->stats_hide_player_list) { |
|
| 1122 | + if ($config->stats_hide_player_list) { |
|
| 1123 | 1123 | $temp = explode(',', $config->stats_hide_player_list); |
| 1124 | - foreach($temp as $user_id) { |
|
| 1124 | + foreach ($temp as $user_id) { |
|
| 1125 | 1125 | $user_id = floatval($user_id); |
| 1126 | - if($user_id) { |
|
| 1126 | + if ($user_id) { |
|
| 1127 | 1127 | $user_skip_list[] = '`id` = ' . $user_id; |
| 1128 | 1128 | } |
| 1129 | 1129 | } |
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | - if(!empty($user_skip_list)) { |
|
| 1132 | + if (!empty($user_skip_list)) { |
|
| 1133 | 1133 | $user_skip_list = implode(' OR ', $user_skip_list); |
| 1134 | 1134 | $user_skip_query = db_user_list($user_skip_list); |
| 1135 | - if(!empty($user_skip_query)) { |
|
| 1136 | - foreach($user_skip_query as $user_skip_row) { |
|
| 1135 | + if (!empty($user_skip_query)) { |
|
| 1136 | + foreach ($user_skip_query as $user_skip_row) { |
|
| 1137 | 1137 | $result[$user_skip_row['id']] = $user_skip_row['id']; |
| 1138 | 1138 | } |
| 1139 | 1139 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | // function player_nick_render_to_html($render_user, $options = false){return sn_function_call('player_nick_render_to_html', array($render_user, $options, &$result));} |
| 1146 | 1146 | // function sn_render_player_nick($render_user, $options = false, &$result) |
| 1147 | 1147 | |
| 1148 | -function get_unit_param($unit_id, $param_name = null, $user = null, $planet = null){return sn_function_call('get_unit_param', array($unit_id, $param_name, $user, $planet, &$result));} |
|
| 1148 | +function get_unit_param($unit_id, $param_name = null, $user = null, $planet = null) {return sn_function_call('get_unit_param', array($unit_id, $param_name, $user, $planet, &$result)); } |
|
| 1149 | 1149 | function sn_get_unit_param($unit_id, $param_name = null, $user = null, $planet = null, &$result) |
| 1150 | 1150 | { |
| 1151 | 1151 | global $sn_data; |
@@ -1160,11 +1160,11 @@ discard block |
||
| 1160 | 1160 | return $result; |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | -function sn_get_groups($groups){return sn_function_call('sn_get_groups', array($groups, &$result));} |
|
| 1163 | +function sn_get_groups($groups) {return sn_function_call('sn_get_groups', array($groups, &$result)); } |
|
| 1164 | 1164 | function sn_sn_get_groups($groups, &$result) |
| 1165 | 1165 | { |
| 1166 | 1166 | $result = is_array($result) ? $result : array(); |
| 1167 | - foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) |
|
| 1167 | + foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) |
|
| 1168 | 1168 | { |
| 1169 | 1169 | $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array(); |
| 1170 | 1170 | } |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | return preg_match('#^(\d*)#', $value, $matches) && $matches[1] ? floatval($matches[1]) : $default; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | -function unit_requirements_render($user, $planetrow, $unit_id, $field = 'require'){return sn_function_call('unit_requirements_render', array($user, $planetrow, $unit_id, $field, &$result));} |
|
| 1182 | +function unit_requirements_render($user, $planetrow, $unit_id, $field = 'require') {return sn_function_call('unit_requirements_render', array($user, $planetrow, $unit_id, $field, &$result)); } |
|
| 1183 | 1183 | function sn_unit_requirements_render($user, $planetrow, $unit_id, $field = 'require', &$result) |
| 1184 | 1184 | { |
| 1185 | 1185 | global $lang, $config; |
@@ -1187,9 +1187,9 @@ discard block |
||
| 1187 | 1187 | $sn_data_unit = get_unit_param($unit_id); |
| 1188 | 1188 | |
| 1189 | 1189 | $result = is_array($result) ? $result : array(); |
| 1190 | - if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && $config->empire_mercenary_temporary)) |
|
| 1190 | + if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && $config->empire_mercenary_temporary)) |
|
| 1191 | 1191 | { |
| 1192 | - foreach($sn_data_unit[$field] as $require_id => $require_level) |
|
| 1192 | + foreach ($sn_data_unit[$field] as $require_id => $require_level) |
|
| 1193 | 1193 | { |
| 1194 | 1194 | $level_got = mrc_get_level($user, $planetrow, $require_id); |
| 1195 | 1195 | $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true); |
@@ -1215,19 +1215,19 @@ discard block |
||
| 1215 | 1215 | |
| 1216 | 1216 | $ranks = array(); |
| 1217 | 1217 | |
| 1218 | - if($ally['ranklist']) |
|
| 1218 | + if ($ally['ranklist']) |
|
| 1219 | 1219 | { |
| 1220 | 1220 | $str_ranks = explode(';', $ally['ranklist']); |
| 1221 | - foreach($str_ranks as $str_rank) |
|
| 1221 | + foreach ($str_ranks as $str_rank) |
|
| 1222 | 1222 | { |
| 1223 | - if(!$str_rank) |
|
| 1223 | + if (!$str_rank) |
|
| 1224 | 1224 | { |
| 1225 | 1225 | continue; |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | $tmp = explode(',', $str_rank); |
| 1229 | 1229 | $rank_id = count($ranks); |
| 1230 | - foreach($ally_rights as $key => $value) |
|
| 1230 | + foreach ($ally_rights as $key => $value) |
|
| 1231 | 1231 | { |
| 1232 | 1232 | $ranks[$rank_id][$value] = $tmp[$key]; |
| 1233 | 1233 | } |
@@ -1237,13 +1237,13 @@ discard block |
||
| 1237 | 1237 | return $ranks; |
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | -function sys_player_new_adjust($user_id, $planet_id){return sn_function_call('sys_player_new_adjust', array($user_id, $planet_id, &$result));} |
|
| 1240 | +function sys_player_new_adjust($user_id, $planet_id) {return sn_function_call('sys_player_new_adjust', array($user_id, $planet_id, &$result)); } |
|
| 1241 | 1241 | function sn_sys_player_new_adjust($user_id, $planet_id, &$result) { |
| 1242 | 1242 | return $result; |
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | function array_merge_recursive_numeric($array1, $array2) { |
| 1246 | - foreach($array2 as $key => $value) { |
|
| 1246 | + foreach ($array2 as $key => $value) { |
|
| 1247 | 1247 | // if(!isset($array1[$key]) || !is_array($array1[$key])) { |
| 1248 | 1248 | // $array1[$key] = $value; |
| 1249 | 1249 | // } else { |
@@ -1258,7 +1258,7 @@ discard block |
||
| 1258 | 1258 | function sn_sys_array_cumulative_sum(&$array) |
| 1259 | 1259 | { |
| 1260 | 1260 | $accum = 0; |
| 1261 | - foreach($array as &$value) |
|
| 1261 | + foreach ($array as &$value) |
|
| 1262 | 1262 | { |
| 1263 | 1263 | $accum += $value; |
| 1264 | 1264 | $value = $accum; |
@@ -1269,7 +1269,7 @@ discard block |
||
| 1269 | 1269 | $sn_data_density = sn_get_groups('planet_density'); |
| 1270 | 1270 | $density_price_chart = array(); |
| 1271 | 1271 | |
| 1272 | - foreach($sn_data_density as $density_id => $density_data) { |
|
| 1272 | + foreach ($sn_data_density as $density_id => $density_data) { |
|
| 1273 | 1273 | // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра |
| 1274 | 1274 | $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false; |
| 1275 | 1275 | } |
@@ -1277,7 +1277,7 @@ discard block |
||
| 1277 | 1277 | |
| 1278 | 1278 | $total_rarity = array_sum($density_price_chart); |
| 1279 | 1279 | |
| 1280 | - foreach($density_price_chart as &$density_data) { |
|
| 1280 | + foreach ($density_price_chart as &$density_data) { |
|
| 1281 | 1281 | $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE); |
| 1282 | 1282 | } |
| 1283 | 1283 | |
@@ -1285,18 +1285,18 @@ discard block |
||
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | 1287 | function sn_sys_planet_core_transmute(&$user, &$planetrow) { |
| 1288 | - if(!sys_get_param_str('transmute')) { |
|
| 1288 | + if (!sys_get_param_str('transmute')) { |
|
| 1289 | 1289 | return array(); |
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | global $lang; |
| 1293 | 1293 | |
| 1294 | 1294 | try { |
| 1295 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
| 1295 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
| 1296 | 1296 | throw new exception($lang['ov_core_err_not_a_planet'], ERR_ERROR); |
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | - if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
| 1299 | + if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
| 1300 | 1300 | throw new exception($lang['ov_core_err_same_density'], ERR_WARNING); |
| 1301 | 1301 | } |
| 1302 | 1302 | |
@@ -1310,7 +1310,7 @@ discard block |
||
| 1310 | 1310 | $planet_density_index = $planetrow['density_index']; |
| 1311 | 1311 | |
| 1312 | 1312 | $density_price_chart = planet_density_price_chart($planetrow); |
| 1313 | - if(!isset($density_price_chart[$new_density_index])) { |
|
| 1313 | + if (!isset($density_price_chart[$new_density_index])) { |
|
| 1314 | 1314 | // Hack attempt |
| 1315 | 1315 | throw new exception($lang['ov_core_err_denisty_type_wrong'], ERR_ERROR); |
| 1316 | 1316 | } |
@@ -1319,13 +1319,13 @@ discard block |
||
| 1319 | 1319 | // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost'); |
| 1320 | 1320 | // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index]; |
| 1321 | 1321 | $transmute_cost = $density_price_chart[$new_density_index]; |
| 1322 | - if($user_dark_matter < $transmute_cost) { |
|
| 1322 | + if ($user_dark_matter < $transmute_cost) { |
|
| 1323 | 1323 | throw new exception($lang['ov_core_err_no_dark_matter'], ERR_ERROR); |
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | $sn_data_planet_density = sn_get_groups('planet_density'); |
| 1327 | - foreach($sn_data_planet_density as $key => $value) { |
|
| 1328 | - if($key == $new_density_index) { |
|
| 1327 | + foreach ($sn_data_planet_density as $key => $value) { |
|
| 1328 | + if ($key == $new_density_index) { |
|
| 1329 | 1329 | break; |
| 1330 | 1330 | } |
| 1331 | 1331 | $prev_density_index = $key; |
@@ -1356,7 +1356,7 @@ discard block |
||
| 1356 | 1356 | 'STATUS' => ERR_NONE, |
| 1357 | 1357 | 'MESSAGE' => sprintf($lang['ov_core_err_none'], $lang['uni_planet_density_types'][$planet_density_index], $lang['uni_planet_density_types'][$new_density_index], $new_density), |
| 1358 | 1358 | ); |
| 1359 | - } catch(exception $e) { |
|
| 1359 | + } catch (exception $e) { |
|
| 1360 | 1360 | sn_db_transaction_rollback(); |
| 1361 | 1361 | $result = array( |
| 1362 | 1362 | 'STATUS' => $e->getCode(), |
@@ -1372,9 +1372,9 @@ discard block |
||
| 1372 | 1372 | global $sn_module_list; |
| 1373 | 1373 | |
| 1374 | 1374 | $active_modules = 0; |
| 1375 | - if(isset($sn_module_list[$group]) && is_array($sn_module_list[$group])) |
|
| 1375 | + if (isset($sn_module_list[$group]) && is_array($sn_module_list[$group])) |
|
| 1376 | 1376 | { |
| 1377 | - foreach($sn_module_list[$group] as $payment_module) |
|
| 1377 | + foreach ($sn_module_list[$group] as $payment_module) |
|
| 1378 | 1378 | { |
| 1379 | 1379 | $active_modules += $payment_module->manifest['active']; |
| 1380 | 1380 | } |
@@ -1387,7 +1387,7 @@ discard block |
||
| 1387 | 1387 | { |
| 1388 | 1388 | static $rates; |
| 1389 | 1389 | |
| 1390 | - if(!$rates) |
|
| 1390 | + if (!$rates) |
|
| 1391 | 1391 | { |
| 1392 | 1392 | global $config; |
| 1393 | 1393 | |
@@ -1398,7 +1398,7 @@ discard block |
||
| 1398 | 1398 | RES_DARK_MATTER => 'rpg_exchange_darkMatter', |
| 1399 | 1399 | ); |
| 1400 | 1400 | |
| 1401 | - foreach($rates as &$rate) |
|
| 1401 | + foreach ($rates as &$rate) |
|
| 1402 | 1402 | { |
| 1403 | 1403 | $rate = $config->$rate; |
| 1404 | 1404 | } |
@@ -1411,13 +1411,13 @@ discard block |
||
| 1411 | 1411 | { |
| 1412 | 1412 | static $rates; |
| 1413 | 1413 | |
| 1414 | - if(!$rates) |
|
| 1414 | + if (!$rates) |
|
| 1415 | 1415 | { |
| 1416 | 1416 | $rates = get_resource_exchange(); |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | $metal_cost = 0; |
| 1420 | - foreach($cost as $resource_id => $resource_value) |
|
| 1420 | + foreach ($cost as $resource_id => $resource_value) |
|
| 1421 | 1421 | { |
| 1422 | 1422 | $metal_cost += $rates[$resource_id] * $resource_value; |
| 1423 | 1423 | } |
@@ -1426,15 +1426,15 @@ discard block |
||
| 1426 | 1426 | } |
| 1427 | 1427 | |
| 1428 | 1428 | function get_player_current_expeditions(&$user) { |
| 1429 | - $FlyingExpeditions = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{fleets}} WHERE `fleet_owner` = {$user['id']} AND `fleet_mission` = '" . MT_EXPLORE . "';", true); |
|
| 1429 | + $FlyingExpeditions = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{fleets}} WHERE `fleet_owner` = {$user['id']} AND `fleet_mission` = '" . MT_EXPLORE . "';", true); |
|
| 1430 | 1430 | return $FlyingExpeditions['expedi']; |
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | -function get_player_max_expeditons(&$user, $astrotech = -1){return sn_function_call('get_player_max_expeditons', array(&$user, $astrotech, &$result));} |
|
| 1433 | +function get_player_max_expeditons(&$user, $astrotech = -1) {return sn_function_call('get_player_max_expeditons', array(&$user, $astrotech, &$result)); } |
|
| 1434 | 1434 | function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) |
| 1435 | 1435 | { |
| 1436 | - if($astrotech == -1) { |
|
| 1437 | - if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) |
|
| 1436 | + if ($astrotech == -1) { |
|
| 1437 | + if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) |
|
| 1438 | 1438 | { |
| 1439 | 1439 | $astrotech = mrc_get_level($user, false, TECH_ASTROTECH); |
| 1440 | 1440 | $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0; |
@@ -1454,8 +1454,8 @@ discard block |
||
| 1454 | 1454 | function get_player_max_colonies(&$user, $astrotech = -1) { |
| 1455 | 1455 | global $config; |
| 1456 | 1456 | |
| 1457 | - if($astrotech == -1) { |
|
| 1458 | - if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 1457 | + if ($astrotech == -1) { |
|
| 1458 | + if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 1459 | 1459 | |
| 1460 | 1460 | $expeditions = get_player_max_expeditons($user); |
| 1461 | 1461 | $astrotech = mrc_get_level($user, false, TECH_ASTROTECH); |
@@ -1482,7 +1482,7 @@ discard block |
||
| 1482 | 1482 | function flt_send_back(&$fleet_row) |
| 1483 | 1483 | { |
| 1484 | 1484 | $fleet_id = round(isset($fleet_row['fleet_id']) && $fleet_row['fleet_id'] ? $fleet_row['fleet_id'] : $fleet_row); |
| 1485 | - if(!$fleet_id) |
|
| 1485 | + if (!$fleet_id) |
|
| 1486 | 1486 | { |
| 1487 | 1487 | return false; |
| 1488 | 1488 | } |
@@ -1492,7 +1492,7 @@ discard block |
||
| 1492 | 1492 | |
| 1493 | 1493 | function flt_destroy(&$fleet_row) { |
| 1494 | 1494 | $fleet_id = round(isset($fleet_row['fleet_id']) && $fleet_row['fleet_id'] ? $fleet_row['fleet_id'] : $fleet_row); |
| 1495 | - if(!$fleet_id) { |
|
| 1495 | + if (!$fleet_id) { |
|
| 1496 | 1496 | return false; |
| 1497 | 1497 | } |
| 1498 | 1498 | |
@@ -1508,7 +1508,7 @@ discard block |
||
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | 1510 | |
| 1511 | -function sn_powerup_get_price_matrix($powerup_id, $powerup_unit = false, $level_max = null, $plain = false){return sn_function_call('sn_powerup_get_price_matrix', array($powerup_id, $powerup_unit, $level_max, $plain, &$result));} |
|
| 1511 | +function sn_powerup_get_price_matrix($powerup_id, $powerup_unit = false, $level_max = null, $plain = false) {return sn_function_call('sn_powerup_get_price_matrix', array($powerup_id, $powerup_unit, $level_max, $plain, &$result)); } |
|
| 1512 | 1512 | function sn_sn_powerup_get_price_matrix($powerup_id, $powerup_unit = false, $level_max = null, $plain = false, &$result) { |
| 1513 | 1513 | global $sn_powerup_buy_discounts; |
| 1514 | 1514 | |
@@ -1520,10 +1520,10 @@ discard block |
||
| 1520 | 1520 | |
| 1521 | 1521 | // pdump($powerup_unit, '$powerup_unit'); |
| 1522 | 1522 | $level_current = $term_original = $time_left = 0; |
| 1523 | - if($is_upgrade) { |
|
| 1523 | + if ($is_upgrade) { |
|
| 1524 | 1524 | $time_finish = strtotime($powerup_unit['unit_time_finish']); |
| 1525 | 1525 | $time_left = max(0, $time_finish - SN_TIME_NOW); |
| 1526 | - if($time_left > 0) { |
|
| 1526 | + if ($time_left > 0) { |
|
| 1527 | 1527 | $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']); |
| 1528 | 1528 | $level_current = $powerup_unit['unit_level']; |
| 1529 | 1529 | } |
@@ -1531,17 +1531,17 @@ discard block |
||
| 1531 | 1531 | |
| 1532 | 1532 | $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK]; |
| 1533 | 1533 | $original_cost = 0; |
| 1534 | - for($i = 1; $i <= $level_max; $i++) { |
|
| 1534 | + for ($i = 1; $i <= $level_max; $i++) { |
|
| 1535 | 1535 | $base_cost = eco_get_total_cost($powerup_id, $i); |
| 1536 | 1536 | $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 1537 | - foreach($sn_powerup_buy_discounts as $period => $discount) { |
|
| 1537 | + foreach ($sn_powerup_buy_discounts as $period => $discount) { |
|
| 1538 | 1538 | $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH); |
| 1539 | 1539 | $result[$i][$period] = $upgrade_price; |
| 1540 | 1540 | $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost; |
| 1541 | 1541 | } |
| 1542 | 1542 | } |
| 1543 | 1543 | |
| 1544 | - if($is_upgrade && $time_left) { |
|
| 1544 | + if ($is_upgrade && $time_left) { |
|
| 1545 | 1545 | $term_original = round($term_original / PERIOD_DAY); |
| 1546 | 1546 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
| 1547 | 1547 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
@@ -1602,14 +1602,14 @@ discard block |
||
| 1602 | 1602 | |
| 1603 | 1603 | function print_rr($var, $capture = false) { |
| 1604 | 1604 | $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>'; |
| 1605 | - if($capture) { |
|
| 1605 | + if ($capture) { |
|
| 1606 | 1606 | return $print; |
| 1607 | 1607 | } else { |
| 1608 | 1608 | print($print); |
| 1609 | 1609 | } |
| 1610 | 1610 | } |
| 1611 | 1611 | |
| 1612 | -function can_capture_planet(){return sn_function_call('can_capture_planet', array(&$result));} |
|
| 1612 | +function can_capture_planet() {return sn_function_call('can_capture_planet', array(&$result)); } |
|
| 1613 | 1613 | function sn_can_capture_planet(&$result) { |
| 1614 | 1614 | return $result = false; |
| 1615 | 1615 | } |
@@ -32,8 +32,7 @@ discard block |
||
| 32 | 32 | $result = call_user_func_array($func_chain_name, $func_arg); |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | - } |
|
| 36 | - else |
|
| 35 | + } else |
|
| 37 | 36 | { |
| 38 | 37 | // TODO: This is left for backward compatibility. Appropriate code should be rewrote! |
| 39 | 38 | $func_name = isset($functions[$func_name]) && is_callable($functions[$func_name]) ? $functions[$func_name] : ('sn_' . $func_name); |
@@ -151,13 +150,11 @@ discard block |
||
| 151 | 150 | if(is_int($floor)) |
| 152 | 151 | { |
| 153 | 152 | $n = round($n, $floor); // , PHP_ROUND_HALF_DOWN |
| 154 | - } |
|
| 155 | - elseif($floor === true) |
|
| 153 | + } elseif($floor === true) |
|
| 156 | 154 | { |
| 157 | 155 | $n = floor($n); |
| 158 | 156 | $floor = 0; |
| 159 | - } |
|
| 160 | - else |
|
| 157 | + } else |
|
| 161 | 158 | { |
| 162 | 159 | $floor = 2; |
| 163 | 160 | } |
@@ -174,8 +171,7 @@ discard block |
||
| 174 | 171 | $suffix .= 'k'; |
| 175 | 172 | $ret = round($ret / 1000); |
| 176 | 173 | } |
| 177 | - } |
|
| 178 | - else |
|
| 174 | + } else |
|
| 179 | 175 | { |
| 180 | 176 | while($ret < -$limit) |
| 181 | 177 | { |
@@ -193,12 +189,10 @@ discard block |
||
| 193 | 189 | if($color === true) |
| 194 | 190 | { |
| 195 | 191 | $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative'); |
| 196 | - } |
|
| 197 | - elseif($color >= 0) |
|
| 192 | + } elseif($color >= 0) |
|
| 198 | 193 | { |
| 199 | 194 | $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative'); |
| 200 | - } |
|
| 201 | - else |
|
| 195 | + } else |
|
| 202 | 196 | { |
| 203 | 197 | $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive'); |
| 204 | 198 | } |
@@ -206,8 +200,7 @@ discard block |
||
| 206 | 200 | if(!isset($style)) |
| 207 | 201 | { |
| 208 | 202 | $ret = "<span class='{$class}'>{$ret}</span>"; |
| 209 | - } |
|
| 210 | - else |
|
| 203 | + } else |
|
| 211 | 204 | { |
| 212 | 205 | $ret = $style ? $ret = $class : $ret = array('text' => $ret, 'class' => $class); |
| 213 | 206 | } |
@@ -350,8 +343,7 @@ discard block |
||
| 350 | 343 | } |
| 351 | 344 | } |
| 352 | 345 | $phone = strlen($phone) < 11 ? '' : $phone; |
| 353 | - } |
|
| 354 | - else |
|
| 346 | + } else |
|
| 355 | 347 | { |
| 356 | 348 | $phone = ''; |
| 357 | 349 | } |
@@ -755,8 +747,7 @@ discard block |
||
| 755 | 747 | curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); |
| 756 | 748 | $return = curl_exec($crl); |
| 757 | 749 | curl_close($crl); |
| 758 | - } |
|
| 759 | - else |
|
| 750 | + } else |
|
| 760 | 751 | { |
| 761 | 752 | $return = @file_get_contents($url); |
| 762 | 753 | } |
@@ -829,8 +820,7 @@ discard block |
||
| 829 | 820 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
| 830 | 821 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
| 831 | 822 | ); |
| 832 | - } |
|
| 833 | - else |
|
| 823 | + } else |
|
| 834 | 824 | { |
| 835 | 825 | $ret = false; |
| 836 | 826 | } |
@@ -879,8 +869,7 @@ discard block |
||
| 879 | 869 | if(is_string($function_data)) |
| 880 | 870 | { |
| 881 | 871 | $override_with = &$function_data; |
| 882 | - } |
|
| 883 | - elseif(isset($function_data['callable'])) |
|
| 872 | + } elseif(isset($function_data['callable'])) |
|
| 884 | 873 | { |
| 885 | 874 | $override_with = &$function_data['callable']; |
| 886 | 875 | } |
@@ -894,12 +883,10 @@ discard block |
||
| 894 | 883 | if(($point_position = strpos($override_with, '.')) === false && $class_module_name) |
| 895 | 884 | { |
| 896 | 885 | $override_with = array($class_module_name, $override_with); |
| 897 | - } |
|
| 898 | - elseif($point_position == 0) |
|
| 886 | + } elseif($point_position == 0) |
|
| 899 | 887 | { |
| 900 | 888 | $override_with = substr($override_with, 1); |
| 901 | - } |
|
| 902 | - elseif($point_position > 0) |
|
| 889 | + } elseif($point_position > 0) |
|
| 903 | 890 | { |
| 904 | 891 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
| 905 | 892 | } |
@@ -907,8 +894,7 @@ discard block |
||
| 907 | 894 | if($overwrite) |
| 908 | 895 | { |
| 909 | 896 | $functions[$function_name] = array(); |
| 910 | - } |
|
| 911 | - elseif(!isset($functions[$function_name])) |
|
| 897 | + } elseif(!isset($functions[$function_name])) |
|
| 912 | 898 | { |
| 913 | 899 | $functions[$function_name] = array(); |
| 914 | 900 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
@@ -37,11 +37,11 @@ |
||
| 37 | 37 | /** |
| 38 | 38 | * @param float $range_start - Начало диапазона |
| 39 | 39 | * @param float $range_end - Конец диапазона |
| 40 | - * @param bool|int $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
| 40 | + * @param boolean $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
| 41 | 41 | * @param int $strict - В сколько сигм надо уложить результат |
| 42 | 42 | * @param bool|false $cut_extreme - надо ли обрезать крайние значения. Например, при $strict = 2 их слишком много |
| 43 | 43 | * |
| 44 | - * @return float|int |
|
| 44 | + * @return double |
|
| 45 | 45 | */ |
| 46 | 46 | function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
| 47 | 47 | if($cut_extreme) { |
@@ -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 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $args = func_get_args(); |
| 62 | 62 | |
| 63 | - switch(func_num_args()) |
|
| 63 | + switch (func_num_args()) |
|
| 64 | 64 | { |
| 65 | 65 | case 0: |
| 66 | 66 | // trigger_error('median() requires at least one parameter',E_USER_WARNING); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | // fallthrough |
| 73 | 73 | |
| 74 | 74 | default: |
| 75 | - if(!is_array($args)) |
|
| 75 | + if (!is_array($args)) |
|
| 76 | 76 | { |
| 77 | 77 | // trigger_error('median() requires a list of numbers to operate on or an array of numbers', E_USER_NOTICE); |
| 78 | 78 | return false; |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | $n = count($args); |
| 84 | 84 | $h = intval($n / 2); |
| 85 | 85 | |
| 86 | - if($n % 2 == 0) |
|
| 86 | + if ($n % 2 == 0) |
|
| 87 | 87 | { |
| 88 | - $median = ($args[$h] + $args[$h-1]) / 2; |
|
| 88 | + $median = ($args[$h] + $args[$h - 1]) / 2; |
|
| 89 | 89 | } |
| 90 | 90 | else |
| 91 | 91 | { |
@@ -103,47 +103,47 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | function linear_calc(&$linear, $from = 0, $debug = false) |
| 105 | 105 | { |
| 106 | - for($i = $from; $i < count($linear); $i++) |
|
| 106 | + for ($i = $from; $i < count($linear); $i++) |
|
| 107 | 107 | { |
| 108 | 108 | $eq = &$linear[$i]; |
| 109 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
| 109 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
| 110 | 110 | { |
| 111 | 111 | $eq[$j] /= $eq[$from]; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
| 114 | + if ($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
| 115 | 115 | |
| 116 | - for($i = $from + 1; $i < count($linear); $i++) |
|
| 116 | + for ($i = $from + 1; $i < count($linear); $i++) |
|
| 117 | 117 | { |
| 118 | 118 | $eq = &$linear[$i]; |
| 119 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
| 119 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
| 120 | 120 | { |
| 121 | 121 | $eq[$j] -= $linear[$from][$j]; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
| 124 | + if ($debug) pdump($linear, 'Подставили х' . $from); |
|
| 125 | 125 | |
| 126 | - if($from < count($linear) - 1) |
|
| 126 | + if ($from < count($linear) - 1) |
|
| 127 | 127 | { |
| 128 | 128 | linear_calc($linear, $from + 1, $debug); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if($from) |
|
| 131 | + if ($from) |
|
| 132 | 132 | { |
| 133 | - for($i = 0; $i < $from; $i++) |
|
| 133 | + for ($i = 0; $i < $from; $i++) |
|
| 134 | 134 | { |
| 135 | 135 | $eq = &$linear[$i]; |
| 136 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
| 136 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
| 137 | 137 | { |
| 138 | 138 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
| 141 | + if ($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
| 142 | 142 | } |
| 143 | 143 | else |
| 144 | 144 | { |
| 145 | - if($debug) pdump($linear, 'Результат' . $from); |
|
| 146 | - foreach($linear as $index => &$eq) |
|
| 145 | + if ($debug) pdump($linear, 'Результат' . $from); |
|
| 146 | + foreach ($linear as $index => &$eq) |
|
| 147 | 147 | { |
| 148 | 148 | pdump($eq[count($linear)], 'x' . $index); |
| 149 | 149 | } |
@@ -86,8 +86,7 @@ discard block |
||
| 86 | 86 | if($n % 2 == 0) |
| 87 | 87 | { |
| 88 | 88 | $median = ($args[$h] + $args[$h-1]) / 2; |
| 89 | - } |
|
| 90 | - else |
|
| 89 | + } else |
|
| 91 | 90 | { |
| 92 | 91 | $median = $args[$h]; |
| 93 | 92 | } |
@@ -111,7 +110,9 @@ discard block |
||
| 111 | 110 | $eq[$j] /= $eq[$from]; |
| 112 | 111 | } |
| 113 | 112 | } |
| 114 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
| 113 | + if($debug) { |
|
| 114 | + pdump($linear, 'Нормализовано по х' . $from); |
|
| 115 | + } |
|
| 115 | 116 | |
| 116 | 117 | for($i = $from + 1; $i < count($linear); $i++) |
| 117 | 118 | { |
@@ -121,7 +122,9 @@ discard block |
||
| 121 | 122 | $eq[$j] -= $linear[$from][$j]; |
| 122 | 123 | } |
| 123 | 124 | } |
| 124 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
| 125 | + if($debug) { |
|
| 126 | + pdump($linear, 'Подставили х' . $from); |
|
| 127 | + } |
|
| 125 | 128 | |
| 126 | 129 | if($from < count($linear) - 1) |
| 127 | 130 | { |
@@ -138,11 +141,14 @@ discard block |
||
| 138 | 141 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
| 139 | 142 | } |
| 140 | 143 | } |
| 141 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
| 142 | - } |
|
| 143 | - else |
|
| 144 | + if($debug) { |
|
| 145 | + pdump($linear, 'Подставили обратно х' . $from); |
|
| 146 | + } |
|
| 147 | + } else |
|
| 144 | 148 | { |
| 145 | - if($debug) pdump($linear, 'Результат' . $from); |
|
| 149 | + if($debug) { |
|
| 150 | + pdump($linear, 'Результат' . $from); |
|
| 151 | + } |
|
| 146 | 152 | foreach($linear as $index => &$eq) |
| 147 | 153 | { |
| 148 | 154 | pdump($eq[count($linear)], 'x' . $index); |