@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | function que_get_unit_que($unit_id) { |
| 9 | 9 | $que_type = false; |
| 10 | - foreach(sn_get_groups('ques') as $que_id => $que_data) { |
|
| 11 | - if(in_array($unit_id, $que_data['unit_list'])) { |
|
| 10 | + foreach (sn_get_groups('ques') as $que_id => $que_data) { |
|
| 11 | + if (in_array($unit_id, $que_data['unit_list'])) { |
|
| 12 | 12 | $que_type = $que_id; |
| 13 | 13 | break; |
| 14 | 14 | } |
@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | function que_get_max_que_length($user, $planet, $que_id, $que_data = null) { |
| 22 | 22 | global $config; |
| 23 | 23 | |
| 24 | - if(empty($que_data)) { |
|
| 24 | + if (empty($que_data)) { |
|
| 25 | 25 | $que_data = sn_get_groups('ques'); |
| 26 | 26 | $que_data = $que_data[$que_id]; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | $que_length = 1; |
| 31 | - switch($que_id) { |
|
| 31 | + switch ($que_id) { |
|
| 32 | 32 | case QUE_RESEARCH: |
| 33 | 33 | $que_length = $config->server_que_length_research + mrc_get_level($user, '', UNIT_PREMIUM); // TODO - вынести в модуль |
| 34 | 34 | break; |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | function eco_que_str2arr($que_str) { |
| 44 | 44 | $que_arr = explode(';', $que_str); |
| 45 | - foreach($que_arr as $que_index => &$que_item) { |
|
| 46 | - if($que_item) { |
|
| 45 | + foreach ($que_arr as $que_index => &$que_item) { |
|
| 46 | + if ($que_item) { |
|
| 47 | 47 | $que_item = explode(',', $que_item); |
| 48 | 48 | } else { |
| 49 | 49 | unset($que_arr[$que_index]); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | function eco_que_arr2str($que_arr) { |
| 56 | - foreach($que_arr as &$que_item) { |
|
| 56 | + foreach ($que_arr as &$que_item) { |
|
| 57 | 57 | $que_item = implode(',', $que_item); |
| 58 | 58 | } |
| 59 | 59 | return implode(';', $que_arr); |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | global $lang, $config; |
| 65 | 65 | |
| 66 | 66 | $is_autoconvert = false; |
| 67 | - if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
| 67 | + if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
| 68 | 68 | $build_mode = BUILD_CREATE; |
| 69 | 69 | $is_autoconvert = true; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $unit_amount_qued = 0; |
| 73 | 73 | try { |
| 74 | - if(!$user['id']) { |
|
| 74 | + if (!$user['id']) { |
|
| 75 | 75 | throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 76 | 76 | } |
| 77 | 77 | |
@@ -82,16 +82,16 @@ discard block |
||
| 82 | 82 | foreach($unit_list as $unit_id => $unit_amount) if($unit_amount) break; |
| 83 | 83 | } |
| 84 | 84 | */ |
| 85 | - if(!$unit_id) { |
|
| 85 | + if (!$unit_id) { |
|
| 86 | 86 | throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $que_id = que_get_unit_que($unit_id); |
| 90 | - if(!$que_id) { |
|
| 90 | + if (!$que_id) { |
|
| 91 | 91 | throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
| 94 | + if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
| 95 | 95 | throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION |
| 96 | 96 | } |
| 97 | 97 | |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | $que_data = $que_data[$que_id]; |
| 100 | 100 | |
| 101 | 101 | // TODO Переделать под подочереди |
| 102 | - if($que_id == QUE_STRUCTURES) { |
|
| 102 | + if ($que_id == QUE_STRUCTURES) { |
|
| 103 | 103 | $sn_groups_build_allow = sn_get_groups('build_allow'); |
| 104 | 104 | $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']]; |
| 105 | 105 | |
| 106 | - if(!isset($que_data['unit_list'][$unit_id])) { |
|
| 106 | + if (!isset($que_data['unit_list'][$unit_id])) { |
|
| 107 | 107 | throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | // Это нужно, что бы заблокировать пользователя и работу с очередями |
| 125 | 125 | $user = db_user_by_id($user['id']); |
| 126 | 126 | // Это нужно, что бы заблокировать планету от списания ресурсов |
| 127 | - if(isset($planet['id']) && $planet['id']) { |
|
| 127 | + if (isset($planet['id']) && $planet['id']) { |
|
| 128 | 128 | $planet = DBStaticPlanet::db_planet_by_id($planet['id'], true); |
| 129 | 129 | } else { |
| 130 | 130 | $planet['id'] = 0; |
@@ -136,17 +136,17 @@ discard block |
||
| 136 | 136 | $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id]; |
| 137 | 137 | $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data); |
| 138 | 138 | // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей |
| 139 | - if((empty($in_que) ? 0 : count($in_que)) >= $que_max_length) { |
|
| 139 | + if ((empty($in_que) ? 0 : count($in_que)) >= $que_max_length) { |
|
| 140 | 140 | throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов |
| 144 | - switch(eco_can_build_unit($user, $planet, $unit_id)) { |
|
| 144 | + switch (eco_can_build_unit($user, $planet, $unit_id)) { |
|
| 145 | 145 | case BUILD_ALLOWED: break; |
| 146 | 146 | case BUILD_UNIT_BUSY: throw new exception('{Строение занято}', ERR_ERROR); break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading |
| 147 | 147 | // case BUILD_REQUIRE_NOT_MEET: |
| 148 | 148 | default: |
| 149 | - if($build_mode == BUILD_CREATE) { |
|
| 149 | + if ($build_mode == BUILD_CREATE) { |
|
| 150 | 150 | throw new exception('{Требования не удовлетворены}', ERR_ERROR); |
| 151 | 151 | } |
| 152 | 152 | break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet |
@@ -156,14 +156,14 @@ discard block |
||
| 156 | 156 | $unit_amount_qued = $unit_amount; |
| 157 | 157 | $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0; |
| 158 | 158 | $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued; |
| 159 | - if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
| 160 | - if($unit_level >= $unit_max) { |
|
| 159 | + if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
| 160 | + if ($unit_level >= $unit_max) { |
|
| 161 | 161 | throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
| 162 | 162 | } |
| 163 | 163 | $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level)); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if($unit_amount < 1) { |
|
| 166 | + if ($unit_amount < 1) { |
|
| 167 | 167 | throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 168 | 168 | } |
| 169 | 169 | |
@@ -179,21 +179,21 @@ discard block |
||
| 179 | 179 | // { |
| 180 | 180 | // die('Unit busy'); // TODO EXCEPTION |
| 181 | 181 | // } |
| 182 | - if(get_unit_param($unit_id, P_STACKABLE)) { |
|
| 182 | + if (get_unit_param($unit_id, P_STACKABLE)) { |
|
| 183 | 183 | // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь |
| 184 | - if(in_array($unit_id, $group_missile = sn_get_groups('missile'))) { |
|
| 184 | + if (in_array($unit_id, $group_missile = sn_get_groups('missile'))) { |
|
| 185 | 185 | // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита |
| 186 | 186 | $used_silo = 0; |
| 187 | - foreach($group_missile as $missile_id) { |
|
| 187 | + foreach ($group_missile as $missile_id) { |
|
| 188 | 188 | $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0; |
| 189 | 189 | $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE); |
| 190 | 190 | } |
| 191 | 191 | $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo; |
| 192 | - if($free_silo <= 0) { |
|
| 192 | + if ($free_silo <= 0) { |
|
| 193 | 193 | throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
| 194 | 194 | } |
| 195 | 195 | $unit_size = get_unit_param($unit_id, P_UNIT_SIZE); |
| 196 | - if($free_silo < $unit_size) { |
|
| 196 | + if ($free_silo < $unit_size) { |
|
| 197 | 197 | throw new exception("{В ракетной шахте нет места для {$lang['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION |
| 198 | 198 | } |
| 199 | 199 | $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size))); |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | $unit_level = $new_unit_level = 0; |
| 202 | 202 | } else { |
| 203 | 203 | $unit_amount = 1; |
| 204 | - if($que_id == QUE_STRUCTURES) { |
|
| 204 | + if ($que_id == QUE_STRUCTURES) { |
|
| 205 | 205 | // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0) |
| 206 | 206 | $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0; |
| 207 | - if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) |
|
| 207 | + if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) |
|
| 208 | 208 | { |
| 209 | 209 | throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION |
| 210 | 210 | } |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | $exchange = array(); |
| 224 | 224 | $market_get_autoconvert_cost = market_get_autoconvert_cost(); |
| 225 | - if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
| 225 | + if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
| 226 | 226 | $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
| 227 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
| 227 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
| 228 | 228 | throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
| 229 | 229 | } |
| 230 | 230 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $resource_exchange_rates = array(); |
| 235 | 235 | $resource_diff = array(); |
| 236 | 236 | $all_positive = true; |
| 237 | - foreach($resources_loot as $resource_id) { |
|
| 237 | + foreach ($resources_loot as $resource_id) { |
|
| 238 | 238 | $resource_db_name = pname_resource_name($resource_id); |
| 239 | 239 | $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id)); |
| 240 | 240 | $resource_exchange_rates[$resource_id] = $config->__get("rpg_exchange_{$resource_db_name}"); |
@@ -242,15 +242,15 @@ discard block |
||
| 242 | 242 | $all_positive = $all_positive && ($resource_diff[$resource_id] > 0); |
| 243 | 243 | } |
| 244 | 244 | // Нужна автоконвертация |
| 245 | - if($all_positive) { |
|
| 245 | + if ($all_positive) { |
|
| 246 | 246 | $is_autoconvert = false; |
| 247 | 247 | } else { |
| 248 | - foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
| 249 | - if($resource_diff_amount >= 0) { |
|
| 248 | + foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
| 249 | + if ($resource_diff_amount >= 0) { |
|
| 250 | 250 | continue; |
| 251 | 251 | } |
| 252 | - foreach($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
| 253 | - if($resource_got_amount <= 0) { |
|
| 252 | + foreach ($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
| 253 | + if ($resource_got_amount <= 0) { |
|
| 254 | 254 | continue; |
| 255 | 255 | } |
| 256 | 256 | $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id]; |
@@ -266,14 +266,14 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | $is_autoconvert_ok = true; |
| 269 | - foreach($resource_diff as $resource_diff_amount2) { |
|
| 270 | - if($resource_diff_amount2 < 0) { |
|
| 269 | + foreach ($resource_diff as $resource_diff_amount2) { |
|
| 270 | + if ($resource_diff_amount2 < 0) { |
|
| 271 | 271 | $is_autoconvert_ok = false; |
| 272 | 272 | break; |
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - if($is_autoconvert_ok) { |
|
| 276 | + if ($is_autoconvert_ok) { |
|
| 277 | 277 | $build_data['RESULT'][$build_mode] = BUILD_ALLOWED; |
| 278 | 278 | $build_data['CAN'][$build_mode] = $unit_amount; |
| 279 | 279 | } else { |
@@ -282,19 +282,19 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount); |
| 285 | - if($unit_amount <= 0) { |
|
| 285 | + if ($unit_amount <= 0) { |
|
| 286 | 286 | throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if($new_unit_level < 0) { |
|
| 289 | + if ($new_unit_level < 0) { |
|
| 290 | 290 | throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
| 293 | + if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
| 294 | 294 | throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if($is_autoconvert) { |
|
| 297 | + if ($is_autoconvert) { |
|
| 298 | 298 | ksort($exchange); |
| 299 | 299 | ksort($resource_got); |
| 300 | 300 | db_change_units($user, $planet, array( |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | $unit_amount_qued = 0; |
| 312 | - while( |
|
| 312 | + while ( |
|
| 313 | 313 | $unit_amount > 0 |
| 314 | 314 | && |
| 315 | 315 | (empty($que['ques'][$que_id][$user['id']][$planet_id]) ? 0 : count($que['ques'][$que_id][$user['id']][$planet_id])) < $que_max_length |
@@ -318,8 +318,8 @@ discard block |
||
| 318 | 318 | // $sqlBlock = QueUnitStatic::que_unit_make_sql($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode); |
| 319 | 319 | $sqlBlock = SN::$gc->pimp->que_unit_make_sql($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode); |
| 320 | 320 | |
| 321 | - array_walk($sqlBlock, function (&$value, $field) { |
|
| 322 | - if($value === null) { |
|
| 321 | + array_walk($sqlBlock, function(&$value, $field) { |
|
| 322 | + if ($value === null) { |
|
| 323 | 323 | $value = 'NULL'; |
| 324 | 324 | } elseif (is_string($value)) { |
| 325 | 325 | $value = "'{$value}'"; |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | |
| 351 | 351 | SN::db_transaction_commit(); |
| 352 | 352 | |
| 353 | - if($redirect) { |
|
| 353 | + if ($redirect) { |
|
| 354 | 354 | sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id')); |
| 355 | 355 | } |
| 356 | 356 | |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | 'STATUS' => ERR_NONE, |
| 359 | 359 | 'MESSAGE' => '{Строительство начато}', |
| 360 | 360 | ); |
| 361 | - } catch(exception $e) { |
|
| 361 | + } catch (exception $e) { |
|
| 362 | 362 | SN::db_transaction_rollback(); |
| 363 | 363 | $operation_result = array( |
| 364 | 364 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | ); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if(!empty($operation_result['MESSAGE'])) { |
|
| 369 | + if (!empty($operation_result['MESSAGE'])) { |
|
| 370 | 370 | $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . $lang['tech'][$unit_id] . ']'; |
| 371 | 371 | } |
| 372 | 372 | |
@@ -380,11 +380,11 @@ discard block |
||
| 380 | 380 | function que_recalculate($old_que) { |
| 381 | 381 | $new_que = array(); |
| 382 | 382 | |
| 383 | - if(!is_array($old_que['items'])) { |
|
| 383 | + if (!is_array($old_que['items'])) { |
|
| 384 | 384 | return $new_que; |
| 385 | 385 | } |
| 386 | - foreach($old_que['items'] as $row) { |
|
| 387 | - if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
| 386 | + foreach ($old_que['items'] as $row) { |
|
| 387 | + if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
| 388 | 388 | continue; |
| 389 | 389 | } |
| 390 | 390 | |
@@ -395,9 +395,9 @@ discard block |
||
| 395 | 395 | |
| 396 | 396 | $last_id = count($new_que['items']) - 1; |
| 397 | 397 | |
| 398 | - if($row['que_planet_id']) { |
|
| 398 | + if ($row['que_planet_id']) { |
|
| 399 | 399 | $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
| 400 | - } elseif($row['que_type'] == QUE_RESEARCH) { |
|
| 400 | + } elseif ($row['que_type'] == QUE_RESEARCH) { |
|
| 401 | 401 | $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
| 402 | 402 | } |
| 403 | 403 | $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id]; |
@@ -422,17 +422,17 @@ discard block |
||
| 422 | 422 | $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0; |
| 423 | 423 | $global_que = que_get($user['id'], $planet['id'], $que_type, true); |
| 424 | 424 | |
| 425 | - if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
| 425 | + if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
| 426 | 426 | $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]); |
| 427 | 427 | |
| 428 | - foreach($que as $que_item) { |
|
| 428 | + foreach ($que as $que_item) { |
|
| 429 | 429 | DBStaticQue::db_que_delete_by_id($que_item['que_id']); |
| 430 | 430 | |
| 431 | - if($que_item['que_planet_id_origin']) { |
|
| 431 | + if ($que_item['que_planet_id_origin']) { |
|
| 432 | 432 | $planet['id'] = $que_item['que_planet_id_origin']; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - if(!isset($planets_locked[$planet['id']])) { |
|
| 435 | + if (!isset($planets_locked[$planet['id']])) { |
|
| 436 | 436 | $planets_locked[$planet['id']] = $planet['id'] ? DBStaticPlanet::db_planet_by_id($planet['id'], true) : $planet; |
| 437 | 437 | } |
| 438 | 438 | |
@@ -444,15 +444,15 @@ discard block |
||
| 444 | 444 | RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount'], |
| 445 | 445 | )); |
| 446 | 446 | |
| 447 | - if(!$clear) { |
|
| 447 | + if (!$clear) { |
|
| 448 | 448 | break; |
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - if(is_numeric($planet['id'])) { |
|
| 452 | + if (is_numeric($planet['id'])) { |
|
| 453 | 453 | DBStaticPlanet::db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
| 454 | 454 | } |
| 455 | - elseif(is_numeric($user['id'])) { |
|
| 455 | + elseif (is_numeric($user['id'])) { |
|
| 456 | 456 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
| 457 | 457 | } |
| 458 | 458 | |
@@ -497,21 +497,21 @@ discard block |
||
| 497 | 497 | // TODO: Переделать для $que_type === false |
| 498 | 498 | $planet['id'] = $planet['id'] ? $planet['id'] : 0; |
| 499 | 499 | |
| 500 | - if(!is_array($que)) { |
|
| 500 | + if (!is_array($que)) { |
|
| 501 | 501 | $que = que_get($user['id'], $planet['id'], $que_type); |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - if(is_array($que) && isset($que['items'])) { |
|
| 504 | + if (is_array($que) && isset($que['items'])) { |
|
| 505 | 505 | $que = $que['ques'][$que_type][$user['id']][$planet['id']]; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - if($que) { |
|
| 509 | - foreach($que as $que_element) { |
|
| 508 | + if ($que) { |
|
| 509 | + foreach ($que as $que_element) { |
|
| 510 | 510 | $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names)); |
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - if($que_type == QUE_RESEARCH) { |
|
| 514 | + if ($que_type == QUE_RESEARCH) { |
|
| 515 | 515 | // TODO Исправить |
| 516 | 516 | // $template->assign_var('RESEARCH_ONGOING', count($global_que[QUE_RESEARCH][0]) >= $config->server_que_length_research); |
| 517 | 517 | } |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | $user = db_user_by_id($user['id'], true); |
| 540 | 540 | |
| 541 | 541 | $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']); |
| 542 | - if($planet === null && !$time_left[$user['id']][0]) { |
|
| 542 | + if ($planet === null && !$time_left[$user['id']][0]) { |
|
| 543 | 543 | // TODO |
| 544 | 544 | return $que; |
| 545 | 545 | } |
@@ -548,12 +548,12 @@ discard block |
||
| 548 | 548 | $que_type_id = $planet === null ? QUE_RESEARCH : false; |
| 549 | 549 | $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false |
| 550 | 550 | $que = que_get($user['id'], $planet, $que_type_id, true); |
| 551 | - if(empty($que['items'])) { |
|
| 551 | + if (empty($que['items'])) { |
|
| 552 | 552 | return $que; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | $planet_list = array(); |
| 556 | - if($planet !== null) { |
|
| 556 | + if ($planet !== null) { |
|
| 557 | 557 | // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них |
| 558 | 558 | // TODO - от них не надо ничего, кроме ID и que_processed |
| 559 | 559 | $planet_row = DBStaticPlanet::db_planet_list_by_user_or_planet($user['id'], $planet); |
@@ -562,21 +562,21 @@ discard block |
||
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты |
| 565 | - if(array_sum($time_left[$user['id']]) == 0) { |
|
| 565 | + if (array_sum($time_left[$user['id']]) == 0) { |
|
| 566 | 566 | return $que; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | $db_changeset = array(); |
| 570 | 570 | $unit_changes = array(); |
| 571 | - foreach($que['items'] as &$que_item) { |
|
| 571 | + foreach ($que['items'] as &$que_item) { |
|
| 572 | 572 | $que_player_id = &$que_item['que_player_id']; |
| 573 | 573 | $que_planet_id = intval($que_item['que_planet_id']); |
| 574 | 574 | |
| 575 | 575 | $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']]; |
| 576 | - if(!isset($que_time_left)) { |
|
| 576 | + if (!isset($que_time_left)) { |
|
| 577 | 577 | $que_time_left = $time_left[$que_player_id][$que_planet_id]; |
| 578 | 578 | } |
| 579 | - if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
| 579 | + if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
| 580 | 580 | continue; |
| 581 | 581 | } |
| 582 | 582 | // Дальше мы идем, если только осталось время в очереди И юниты к постройке |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля |
| 590 | 590 | |
| 591 | 591 | // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит |
| 592 | - if($que_time_left >= $que_item['que_time_left']) { |
|
| 592 | + if ($que_time_left >= $que_item['que_time_left']) { |
|
| 593 | 593 | // Увеличиваем количество отстроенных юнитов |
| 594 | 594 | $unit_processed++; |
| 595 | 595 | // Вычитаем из времени очереди потраченное на постройку время |
@@ -602,12 +602,12 @@ discard block |
||
| 602 | 602 | $que_item['que_unit_amount'] -= $unit_processed; |
| 603 | 603 | |
| 604 | 604 | // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита |
| 605 | - if($que_item['que_unit_amount'] > 0) { |
|
| 605 | + if ($que_item['que_unit_amount'] > 0) { |
|
| 606 | 606 | $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left; |
| 607 | 607 | $que_time_left = 0; |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | - if($que_item['que_unit_amount'] <= 0) { |
|
| 610 | + if ($que_item['que_unit_amount'] <= 0) { |
|
| 611 | 611 | $db_changeset['que'][] = array( |
| 612 | 612 | 'action' => SQL_OP_DELETE, |
| 613 | 613 | P_VERSION => 1, |
@@ -633,14 +633,14 @@ discard block |
||
| 633 | 633 | ); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - if($unit_processed) { |
|
| 636 | + if ($unit_processed) { |
|
| 637 | 637 | $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1); |
| 638 | 638 | $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta; |
| 639 | 639 | } |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - foreach($time_left as $player_id => $planet_data) { |
|
| 643 | - foreach($planet_data as $planet_id => $time_on_planet) { |
|
| 642 | + foreach ($time_left as $player_id => $planet_data) { |
|
| 643 | + foreach ($planet_data as $planet_id => $time_on_planet) { |
|
| 644 | 644 | $table = $planet_id ? 'planets' : 'users'; |
| 645 | 645 | $id = $planet_id ? $planet_id : $player_id; |
| 646 | 646 | $db_changeset[$table][] = array( |
@@ -656,8 +656,8 @@ discard block |
||
| 656 | 656 | ), |
| 657 | 657 | ); |
| 658 | 658 | |
| 659 | - if(is_array($unit_changes[$player_id][$planet_id])) { |
|
| 660 | - foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
| 659 | + if (is_array($unit_changes[$player_id][$planet_id])) { |
|
| 660 | + foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
| 661 | 661 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null); |
| 662 | 662 | } |
| 663 | 663 | } |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | $que = que_recalculate($que); |
| 668 | 668 | |
| 669 | 669 | // TODO: Re-enable quests for Alliances |
| 670 | - if(!empty($unit_changes) && !$user['user_as_ally']) { |
|
| 670 | + if (!empty($unit_changes) && !$user['user_as_ally']) { |
|
| 671 | 671 | $quest_list = qst_get_quests($user['id'], QUEST_STATUS_ALL); |
| 672 | 672 | $quest_triggers = qst_active_triggers($quest_list); |
| 673 | 673 | $quest_rewards = array(); |
@@ -675,26 +675,26 @@ discard block |
||
| 675 | 675 | |
| 676 | 676 | |
| 677 | 677 | $xp_incoming = array(); |
| 678 | - foreach($unit_changes as $user_id => $planet_changes) { |
|
| 679 | - foreach($planet_changes as $planet_id => $changes) { |
|
| 678 | + foreach ($unit_changes as $user_id => $planet_changes) { |
|
| 679 | + foreach ($planet_changes as $planet_id => $changes) { |
|
| 680 | 680 | $planet_this = $planet_id ? SN::db_get_record_by_id(LOC_PLANET, $planet_id) : array(); |
| 681 | - foreach($changes as $unit_id => $unit_value) { |
|
| 681 | + foreach ($changes as $unit_id => $unit_value) { |
|
| 682 | 682 | $que_id = que_get_unit_que($unit_id); |
| 683 | 683 | $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value; |
| 684 | - if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
| 684 | + if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
| 685 | 685 | $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1); |
| 686 | 686 | $build_data = $build_data[BUILD_CREATE]; |
| 687 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
| 687 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
| 688 | 688 | $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена |
| 689 | 689 | } |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | - if(is_array($quest_triggers)) { |
|
| 692 | + if (is_array($quest_triggers)) { |
|
| 693 | 693 | // TODO: Check mutiply condition quests |
| 694 | 694 | $quest_trigger_list = array_keys($quest_triggers, $unit_id); |
| 695 | 695 | |
| 696 | - if(is_array($quest_trigger_list)) { |
|
| 697 | - foreach($quest_trigger_list as $quest_id) { |
|
| 696 | + if (is_array($quest_trigger_list)) { |
|
| 697 | + foreach ($quest_trigger_list as $quest_id) { |
|
| 698 | 698 | if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE) { |
| 699 | 699 | if ($quest_list[$quest_id]['quest_unit_amount'] <= $unit_level_new) { |
| 700 | 700 | $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list']; |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч |
| 713 | 713 | qst_reward($user, $quest_rewards, $quest_list, $quest_statuses); |
| 714 | 714 | |
| 715 | - foreach($xp_incoming as $que_id => $xp) { |
|
| 715 | + foreach ($xp_incoming as $que_id => $xp) { |
|
| 716 | 716 | rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000); |
| 717 | 717 | } |
| 718 | 718 | } |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @package phpBB3 |
| 39 | 39 | */ |
| 40 | -class template_compile |
|
| 41 | -{ |
|
| 40 | +class template_compile { |
|
| 42 | 41 | var $template; |
| 43 | 42 | |
| 44 | 43 | // Various storage arrays |
@@ -58,8 +57,7 @@ discard block |
||
| 58 | 57 | * Load template source from file |
| 59 | 58 | * @access private |
| 60 | 59 | */ |
| 61 | - function _tpl_load_file($handle, $store_in_db = false) |
|
| 62 | - { |
|
| 60 | + function _tpl_load_file($handle, $store_in_db = false) { |
|
| 63 | 61 | // Try and open template for read |
| 64 | 62 | if (!file_exists($this->template->files[$handle])) |
| 65 | 63 | { |
@@ -74,8 +72,7 @@ discard block |
||
| 74 | 72 | |
| 75 | 73 | return; |
| 76 | 74 | trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR); |
| 77 | - } |
|
| 78 | - else |
|
| 75 | + } else |
|
| 79 | 76 | { |
| 80 | 77 | $this->template->files[$handle] = $this->template->files_inherit[$handle]; |
| 81 | 78 | } |
@@ -111,8 +108,7 @@ discard block |
||
| 111 | 108 | * the ones that exist in zend_language_scanner.l |
| 112 | 109 | * @access private |
| 113 | 110 | */ |
| 114 | - function remove_php_tags(&$code) |
|
| 115 | - { |
|
| 111 | + function remove_php_tags(&$code) { |
|
| 116 | 112 | // This matches the information gathered from the internal PHP lexer |
| 117 | 113 | $match = array( |
| 118 | 114 | '#<([\?%])=?.*?\1>#s', |
@@ -127,8 +123,7 @@ discard block |
||
| 127 | 123 | * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
| 128 | 124 | * @access private |
| 129 | 125 | */ |
| 130 | - function compile($code, $no_echo = false, $echo_var = '') |
|
| 131 | - { |
|
| 126 | + function compile($code, $no_echo = false, $echo_var = '') { |
|
| 132 | 127 | if ($echo_var) |
| 133 | 128 | { |
| 134 | 129 | global $$echo_var; |
@@ -231,15 +226,13 @@ discard block |
||
| 231 | 226 | $var = substr($temp, 2, -1); |
| 232 | 227 | //$file = $this->template->_tpldata['DEFINE']['.'][$var]; |
| 233 | 228 | $temp = "\$this->_tpldata['DEFINE']['.']['$var']"; |
| 234 | - } |
|
| 235 | - else |
|
| 229 | + } else |
|
| 236 | 230 | { |
| 237 | 231 | $var = substr($temp, 1, -1); |
| 238 | 232 | //$file = $this->template->_rootref[$var]; |
| 239 | 233 | $temp = "\$this->_rootref['$var']"; |
| 240 | 234 | } |
| 241 | - } |
|
| 242 | - else |
|
| 235 | + } else |
|
| 243 | 236 | { |
| 244 | 237 | $file = $temp; |
| 245 | 238 | } |
@@ -298,8 +291,7 @@ discard block |
||
| 298 | 291 | * Compile variables |
| 299 | 292 | * @access private |
| 300 | 293 | */ |
| 301 | - function compile_var_tags(&$text_blocks) |
|
| 302 | - { |
|
| 294 | + function compile_var_tags(&$text_blocks) { |
|
| 303 | 295 | // including $lang variable |
| 304 | 296 | // global $lang, $config; // NOT NEDEED - $lang now is global! |
| 305 | 297 | |
@@ -373,8 +365,7 @@ discard block |
||
| 373 | 365 | * Compile blocks |
| 374 | 366 | * @access private |
| 375 | 367 | */ |
| 376 | - function compile_tag_block($tag_args) |
|
| 377 | - { |
|
| 368 | + function compile_tag_block($tag_args) { |
|
| 378 | 369 | $no_nesting = false; |
| 379 | 370 | |
| 380 | 371 | // Is the designer wanting to call another loop in a loop? |
@@ -397,8 +388,7 @@ discard block |
||
| 397 | 388 | if ($match[2] < 0) |
| 398 | 389 | { |
| 399 | 390 | $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
| 400 | - } |
|
| 401 | - else |
|
| 391 | + } else |
|
| 402 | 392 | { |
| 403 | 393 | $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
| 404 | 394 | } |
@@ -406,17 +396,14 @@ discard block |
||
| 406 | 396 | if (strlen($match[3]) < 1 || $match[3] == -1) |
| 407 | 397 | { |
| 408 | 398 | $loop_end = '$_' . $tag_args . '_count'; |
| 409 | - } |
|
| 410 | - else if ($match[3] >= 0) |
|
| 399 | + } else if ($match[3] >= 0) |
|
| 411 | 400 | { |
| 412 | 401 | $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
| 413 | - } |
|
| 414 | - else //if ($match[3] < -1) |
|
| 402 | + } else //if ($match[3] < -1) |
|
| 415 | 403 | { |
| 416 | 404 | $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
| 417 | 405 | } |
| 418 | - } |
|
| 419 | - else |
|
| 406 | + } else |
|
| 420 | 407 | { |
| 421 | 408 | $loop_start = 0; |
| 422 | 409 | $loop_end = '$_' . $tag_args . '_count'; |
@@ -429,8 +416,7 @@ discard block |
||
| 429 | 416 | { |
| 430 | 417 | // We need to implode $no_nesting times from the end... |
| 431 | 418 | $block = array_slice($this->block_names, -$no_nesting); |
| 432 | - } |
|
| 433 | - else |
|
| 419 | + } else |
|
| 434 | 420 | { |
| 435 | 421 | $block = $this->block_names; |
| 436 | 422 | } |
@@ -440,8 +426,7 @@ discard block |
||
| 440 | 426 | // Block is not nested. |
| 441 | 427 | $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
| 442 | 428 | $varref = "\$this->_tpldata['$tag_args']"; |
| 443 | - } |
|
| 444 | - else |
|
| 429 | + } else |
|
| 445 | 430 | { |
| 446 | 431 | // This block is nested. |
| 447 | 432 | // Generate a namespace string for this block. |
@@ -480,8 +465,7 @@ discard block |
||
| 480 | 465 | * some adaptions for our block level methods |
| 481 | 466 | * @access private |
| 482 | 467 | */ |
| 483 | - function compile_tag_if($tag_args, $elseif) |
|
| 484 | - { |
|
| 468 | + function compile_tag_if($tag_args, $elseif) { |
|
| 485 | 469 | // Tokenize args for 'if' tag. |
| 486 | 470 | preg_match_all('/(?: |
| 487 | 471 | "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | |
@@ -589,8 +573,7 @@ discard block |
||
| 589 | 573 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
| 590 | 574 | { |
| 591 | 575 | $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); |
| 592 | - } |
|
| 593 | - else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
| 576 | + } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
| 594 | 577 | { |
| 595 | 578 | // Allow checking if loops are set with .loopname |
| 596 | 579 | // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example |
@@ -606,8 +589,7 @@ discard block |
||
| 606 | 589 | |
| 607 | 590 | // Add the block reference for the last child. |
| 608 | 591 | $varref .= "['" . $block . "']"; |
| 609 | - } |
|
| 610 | - else |
|
| 592 | + } else |
|
| 611 | 593 | { |
| 612 | 594 | $varref = '$this->_tpldata'; |
| 613 | 595 | |
@@ -615,8 +597,7 @@ discard block |
||
| 615 | 597 | $varref .= "['" . $blocks[0] . "']"; |
| 616 | 598 | } |
| 617 | 599 | $token = "(empty($varref) ? 0 : sizeof($varref))"; |
| 618 | - } |
|
| 619 | - else if (!empty($token)) |
|
| 600 | + } else if (!empty($token)) |
|
| 620 | 601 | { |
| 621 | 602 | $token = '(' . $token . ')'; |
| 622 | 603 | } |
@@ -637,8 +618,7 @@ discard block |
||
| 637 | 618 | * Compile DEFINE tags |
| 638 | 619 | * @access private |
| 639 | 620 | */ |
| 640 | - function compile_tag_define($tag_args, $op) |
|
| 641 | - { |
|
| 621 | + function compile_tag_define($tag_args, $op) { |
|
| 642 | 622 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
| 643 | 623 | |
| 644 | 624 | if (empty($match[2]) || (!isset($match[4]) && $op)) |
@@ -661,8 +641,7 @@ discard block |
||
| 661 | 641 | |
| 662 | 642 | // Now replace the php code |
| 663 | 643 | $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
| 664 | - } |
|
| 665 | - else |
|
| 644 | + } else |
|
| 666 | 645 | { |
| 667 | 646 | preg_match('#true|false|\.#i', $match[4], $type); |
| 668 | 647 | |
@@ -690,8 +669,7 @@ discard block |
||
| 690 | 669 | * Compile INCLUDE tag |
| 691 | 670 | * @access private |
| 692 | 671 | */ |
| 693 | - function compile_tag_include($tag_args) |
|
| 694 | - { |
|
| 672 | + function compile_tag_include($tag_args) { |
|
| 695 | 673 | // Process dynamic includes |
| 696 | 674 | if ($tag_args[0] == '$') |
| 697 | 675 | { |
@@ -705,8 +683,7 @@ discard block |
||
| 705 | 683 | * Compile INCLUDE_PHP tag |
| 706 | 684 | * @access private |
| 707 | 685 | */ |
| 708 | - function compile_tag_include_php($tag_args) |
|
| 709 | - { |
|
| 686 | + function compile_tag_include_php($tag_args) { |
|
| 710 | 687 | return "\$this->_php_include('$tag_args');"; |
| 711 | 688 | } |
| 712 | 689 | |
@@ -715,8 +692,7 @@ discard block |
||
| 715 | 692 | * This is from Smarty |
| 716 | 693 | * @access private |
| 717 | 694 | */ |
| 718 | - function _parse_is_expr($is_arg, $tokens) |
|
| 719 | - { |
|
| 695 | + function _parse_is_expr($is_arg, $tokens) { |
|
| 720 | 696 | $expr_end = 0; |
| 721 | 697 | $negate_expr = false; |
| 722 | 698 | |
@@ -724,8 +700,7 @@ discard block |
||
| 724 | 700 | { |
| 725 | 701 | $negate_expr = true; |
| 726 | 702 | $expr_type = array_shift($tokens); |
| 727 | - } |
|
| 728 | - else |
|
| 703 | + } else |
|
| 729 | 704 | { |
| 730 | 705 | $expr_type = $first_token; |
| 731 | 706 | } |
@@ -738,8 +713,7 @@ discard block |
||
| 738 | 713 | $expr_end++; |
| 739 | 714 | $expr_arg = $tokens[$expr_end++]; |
| 740 | 715 | $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; |
| 741 | - } |
|
| 742 | - else |
|
| 716 | + } else |
|
| 743 | 717 | { |
| 744 | 718 | $expr = "!($is_arg & 1)"; |
| 745 | 719 | } |
@@ -751,8 +725,7 @@ discard block |
||
| 751 | 725 | $expr_end++; |
| 752 | 726 | $expr_arg = $tokens[$expr_end++]; |
| 753 | 727 | $expr = "(($is_arg / $expr_arg) % $expr_arg)"; |
| 754 | - } |
|
| 755 | - else |
|
| 728 | + } else |
|
| 756 | 729 | { |
| 757 | 730 | $expr = "($is_arg & 1)"; |
| 758 | 731 | } |
@@ -791,8 +764,7 @@ discard block |
||
| 791 | 764 | * |
| 792 | 765 | * @return string |
| 793 | 766 | */ |
| 794 | - private function generate_block_varref($namespace, $varname, $defop = false) |
|
| 795 | - { |
|
| 767 | + private function generate_block_varref($namespace, $varname, $defop = false) { |
|
| 796 | 768 | // Strip the trailing period. |
| 797 | 769 | $namespace = substr($namespace, 0, -1); |
| 798 | 770 | |
@@ -815,8 +787,7 @@ discard block |
||
| 815 | 787 | * NOTE: does not expect a trailing "." on the blockname. |
| 816 | 788 | * @access private |
| 817 | 789 | */ |
| 818 | - function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
|
| 819 | - { |
|
| 790 | + function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) { |
|
| 820 | 791 | // Get an array of the blocks involved. |
| 821 | 792 | $blocks = explode('.', $blockname); |
| 822 | 793 | $blockcount = sizeof($blocks) - 1; |
@@ -838,12 +809,10 @@ discard block |
||
| 838 | 809 | $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
| 839 | 810 | } |
| 840 | 811 | return $varref; |
| 841 | - } |
|
| 842 | - else if ($include_last_iterator) |
|
| 812 | + } else if ($include_last_iterator) |
|
| 843 | 813 | { |
| 844 | 814 | return '$_'. $blocks[$blockcount] . '_val'; |
| 845 | - } |
|
| 846 | - else |
|
| 815 | + } else |
|
| 847 | 816 | { |
| 848 | 817 | return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
| 849 | 818 | } |
@@ -853,8 +822,7 @@ discard block |
||
| 853 | 822 | * Write compiled file to cache directory |
| 854 | 823 | * @access private |
| 855 | 824 | */ |
| 856 | - function compile_write($handle, $data) |
|
| 857 | - { |
|
| 825 | + function compile_write($handle, $data) { |
|
| 858 | 826 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
| 859 | 827 | |
| 860 | 828 | $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data); |
@@ -878,8 +846,7 @@ discard block |
||
| 878 | 846 | * Minifies template w/i PHP code by removing extra spaces |
| 879 | 847 | * @access private |
| 880 | 848 | */ |
| 881 | - function minify($html) |
|
| 882 | - { |
|
| 849 | + function minify($html) { |
|
| 883 | 850 | if(!SN::$config->tpl_minifier) |
| 884 | 851 | { |
| 885 | 852 | return $html; |
@@ -238,9 +238,9 @@ discard block |
||
| 238 | 238 | 'advGoogleLeftMenuCode' => '(Place here code for banner)', |
| 239 | 239 | |
| 240 | 240 | // Alliance bonus calculations |
| 241 | - 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
| 241 | + 'ali_bonus_algorithm' => 0, // Bonus calculation algorithm |
|
| 242 | 242 | 'ali_bonus_brackets' => 10, // Brackets count for ALI_BONUS_BY_RANK |
| 243 | - 'ali_bonus_brackets_divisor' => 10,// Bonus divisor for ALI_BONUS_BY_RANK |
|
| 243 | + 'ali_bonus_brackets_divisor' => 10, // Bonus divisor for ALI_BONUS_BY_RANK |
|
| 244 | 244 | 'ali_bonus_divisor' => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS |
| 245 | 245 | 'ali_bonus_members' => 10, // Minimum alliance size to start using bonus |
| 246 | 246 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | 'eco_scale_storage' => 1, |
| 284 | 284 | 'eco_stockman_fleet' => '', // Black Market - Starting amount of s/h ship merchant to sell |
| 285 | - 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
| 285 | + 'eco_stockman_fleet_populate' => 1, // Populate empty Stockman fleet with ships or not |
|
| 286 | 286 | 'empire_mercenary_base_period' => PERIOD_MONTH, // Base |
| 287 | 287 | 'empire_mercenary_temporary' => 0, // Temporary empire-wide mercenaries |
| 288 | 288 | |
@@ -293,22 +293,22 @@ discard block |
||
| 293 | 293 | 'energy_basic_income' => 0, |
| 294 | 294 | |
| 295 | 295 | // Bashing protection settings |
| 296 | - 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
| 297 | - 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
| 298 | - 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
| 299 | - 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
| 300 | - 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
| 296 | + 'fleet_bashing_attacks' => 3, // Max amount of attack per wave - 3 by default |
|
| 297 | + 'fleet_bashing_interval' => 1800, // Maximum interval between attacks when they still count as one wave - 30m by default |
|
| 298 | + 'fleet_bashing_scope' => 86400, // Interval on which bashing waves counts - 24h by default |
|
| 299 | + 'fleet_bashing_war_delay' => 43200, // Delay before start bashing after declaring war to alliance - 12h by default |
|
| 300 | + 'fleet_bashing_waves' => 3, // Max amount of waves per day - 3 by default |
|
| 301 | 301 | |
| 302 | 302 | 'Fleet_Cdr' => 30, |
| 303 | 303 | 'fleet_speed' => 1, |
| 304 | 304 | |
| 305 | - 'fleet_update_dispatch_time' => 3, // (float) Maximum seconds fleet dispatch can run, Default 3s |
|
| 306 | - 'fleet_update_interval' => 4, // How often fleet dispatch worker should run |
|
| 305 | + 'fleet_update_dispatch_time' => 3, // (float) Maximum seconds fleet dispatch can run, Default 3s |
|
| 306 | + 'fleet_update_interval' => 4, // How often fleet dispatch worker should run |
|
| 307 | 307 | self::FLEET_UPDATE_MAX_RUN_TIME => 30, // (int) seconds. How long fleet dispatch worker can run. Should be 1 second or more |
| 308 | 308 | 'fleet_update_lock' => '', // SQL time when lock was acquired |
| 309 | 309 | |
| 310 | - 'game_adminEmail' => 'root@localhost', // Admin email to show to users |
|
| 311 | - 'game_counter' => 0, // Does built-in page hit counter is on? |
|
| 310 | + 'game_adminEmail' => 'root@localhost', // Admin email to show to users |
|
| 311 | + 'game_counter' => 0, // Does built-in page hit counter is on? |
|
| 312 | 312 | // Defaults |
| 313 | 313 | 'game_default_language' => 'ru', |
| 314 | 314 | 'game_default_skin' => 'skins/EpicBlue/', |
@@ -322,14 +322,14 @@ discard block |
||
| 322 | 322 | 'game_maxSystem' => 199, |
| 323 | 323 | 'game_maxPlanet' => 15, |
| 324 | 324 | // Game global settings |
| 325 | - 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
| 325 | + 'game_mode' => 0, // 0 - SuperNova, 1 - oGame |
|
| 326 | 326 | 'game_name' => 'SuperNova', // Server name (would be on banners and on top of left menu) |
| 327 | 327 | |
| 328 | 328 | 'game_news_actual' => PERIOD_DAY_3, // How long announcement would be marked as "New". In seconds. Default - 3 days |
| 329 | - 'game_news_overview' => 3, // How much last news to show in Overview page |
|
| 330 | - 'game_news_overview_show' => PERIOD_WEEK_2, // How long news will be shown in Overview page in seconds. Default - 2 weeks |
|
| 329 | + 'game_news_overview' => 3, // How much last news to show in Overview page |
|
| 330 | + 'game_news_overview_show' => PERIOD_WEEK_2, // How long news will be shown in Overview page in seconds. Default - 2 weeks |
|
| 331 | 331 | // Noob protection |
| 332 | - 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
| 332 | + 'game_noob_factor' => 5, // Multiplier to divide "stronger" and "weaker" users |
|
| 333 | 333 | 'game_noob_points' => 5000, // Below this point user treated as noob. 0 to disable |
| 334 | 334 | |
| 335 | 335 | 'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccount) |
@@ -384,12 +384,12 @@ discard block |
||
| 384 | 384 | 'payment_currency_exchange_wmz' => 1, |
| 385 | 385 | 'payment_currency_exchange_pln' => 3.86, |
| 386 | 386 | |
| 387 | - 'payment_lot_price' => 1, // Lot's price in default currency |
|
| 388 | - 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
| 387 | + 'payment_lot_price' => 1, // Lot's price in default currency |
|
| 388 | + 'payment_lot_size' => 2500, // Lot size. Also service as minimum amount of DM that could be bought with one transaction |
|
| 389 | 389 | |
| 390 | 390 | 'planet_capital_cost' => 25000, // Cost in DM to move Capital to current planet |
| 391 | - 'planet_capital_mining_rate' => 2.0, // Capital Mining rates |
|
| 392 | - 'planet_capital_building_rate' => 2.0, // Capital Building rates |
|
| 391 | + 'planet_capital_mining_rate' => 2.0, // Capital Mining rates |
|
| 392 | + 'planet_capital_building_rate' => 2.0, // Capital Building rates |
|
| 393 | 393 | 'planet_teleport_cost' => 50000, // Cost of planet teleportation |
| 394 | 394 | 'planet_teleport_timeout' => 86400, // Timeout for next teleportation |
| 395 | 395 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | 'resource_multiplier' => 1, |
| 412 | 412 | |
| 413 | 413 | //Role play system |
| 414 | - 'rpg_bonus_divisor' => 10, // Amount of DM referral should get for partner have 1 DM bonus |
|
| 414 | + 'rpg_bonus_divisor' => 10, // Amount of DM referral should get for partner have 1 DM bonus |
|
| 415 | 415 | 'rpg_bonus_minimum' => 10000, // Minimum DM amount for starting paying bonuses to affiliate |
| 416 | 416 | |
| 417 | 417 | // Black Market - General |
@@ -476,12 +476,12 @@ discard block |
||
| 476 | 476 | 'url_purchase_metamatter' => '', |
| 477 | 477 | 'url_rules' => '', |
| 478 | 478 | |
| 479 | - 'users_amount' => 1, // Total users count |
|
| 479 | + 'users_amount' => 1, // Total users count |
|
| 480 | 480 | 'game_users_online_timeout' => PERIOD_MINUTE_15, // Seconds, How long user should consider ONLINE for online counter |
| 481 | - 'game_users_update_online' => 30, // How often user online should be refreshed (seconds) |
|
| 482 | - 'var_online_user_time' => 0, // When last time user online was refreshed |
|
| 483 | - 'var_online_user_count' => 0, // Last calculated online user count |
|
| 484 | - 'server_log_online' => 0, // Log online user count |
|
| 481 | + 'game_users_update_online' => 30, // How often user online should be refreshed (seconds) |
|
| 482 | + 'var_online_user_time' => 0, // When last time user online was refreshed |
|
| 483 | + 'var_online_user_count' => 0, // Last calculated online user count |
|
| 484 | + 'server_log_online' => 0, // Log online user count |
|
| 485 | 485 | |
| 486 | 486 | 'user_birthday_celebrate' => 0, // When last time celebrations (i.e. gift-giving) was made - timestamp |
| 487 | 487 | 'user_birthday_gift' => 0, // User birthday gift - Dark Matter points |