@@ -1,8 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) |
|
| 5 | -{ |
|
| 4 | +function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) { |
|
| 6 | 5 | global $config, $user, $fleet_number, $lang; |
| 7 | 6 | |
| 8 | 7 | $fleet_events = array(); |
@@ -23,12 +22,10 @@ discard block |
||
| 23 | 22 | if($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
| 24 | 23 | { |
| 25 | 24 | $fleet['fleet_end_name'] = $lang['ov_fleet_exploration']; |
| 26 | - } |
|
| 27 | - elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 25 | + } elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 28 | 26 | { |
| 29 | 27 | $fleet['fleet_end_name'] = $lang['ov_fleet_colonization']; |
| 30 | - } |
|
| 31 | - else |
|
| 28 | + } else |
|
| 32 | 29 | { |
| 33 | 30 | $planet_end = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_end_galaxy'], $fleet['fleet_end_system'], $fleet['fleet_end_planet'], $planet_end_type, false, 'name'); |
| 34 | 31 | $fleet['fleet_end_name'] = $planet_end['name']; |
@@ -80,8 +77,7 @@ discard block |
||
| 80 | 77 | return $fleet_events; |
| 81 | 78 | } |
| 82 | 79 | |
| 83 | -function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) |
|
| 84 | -{ |
|
| 80 | +function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) { |
|
| 85 | 81 | global $user, $planetrow, $fleet_number; |
| 86 | 82 | |
| 87 | 83 | switch($fleet['ov_label'] = $ov_label) |
@@ -121,8 +117,7 @@ discard block |
||
| 121 | 117 | if($fleet['fleet_owner'] == $user['id']) |
| 122 | 118 | { |
| 123 | 119 | $user_data = $user; |
| 124 | - } |
|
| 125 | - else |
|
| 120 | + } else |
|
| 126 | 121 | { |
| 127 | 122 | $user_data = db_user_by_id($fleet['fleet_owner']); |
| 128 | 123 | } |
@@ -130,8 +125,7 @@ discard block |
||
| 130 | 125 | return tpl_parse_fleet_db($fleet, ++$fleet_number, $user_data); |
| 131 | 126 | } |
| 132 | 127 | |
| 133 | -function int_planet_pretemplate($planetrow, &$template) |
|
| 134 | -{ |
|
| 128 | +function int_planet_pretemplate($planetrow, &$template) { |
|
| 135 | 129 | global $lang, $user; |
| 136 | 130 | |
| 137 | 131 | $governor_id = $planetrow['PLANET_GOVERNOR_ID']; |
@@ -1,7 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function ali_rank_list_save($ranks) |
|
| 4 | -{ |
|
| 3 | +function ali_rank_list_save($ranks) { |
|
| 5 | 4 | global $user; |
| 6 | 5 | |
| 7 | 6 | if(!empty($ranks)) |
@@ -17,8 +16,7 @@ discard block |
||
| 17 | 16 | return $ranklist; |
| 18 | 17 | } |
| 19 | 18 | |
| 20 | -function ali_relations($ally_from, $ally_to = 0) |
|
| 21 | -{ |
|
| 19 | +function ali_relations($ally_from, $ally_to = 0) { |
|
| 22 | 20 | $ally_to = intval($ally_to); |
| 23 | 21 | $ally_to = $ally_to ? " AND alliance_diplomacy_contr_ally_id = {$ally_to}" : ''; |
| 24 | 22 | |
@@ -45,8 +43,7 @@ discard block |
||
| 45 | 43 | return $temp_array; |
| 46 | 44 | } |
| 47 | 45 | |
| 48 | -function ali_relation($ally_from, $ally_to) |
|
| 49 | -{ |
|
| 46 | +function ali_relation($ally_from, $ally_to) { |
|
| 50 | 47 | $relation = ali_relations($ally_from, $ally_to); |
| 51 | 48 | return empty($relation) ? ALLY_DIPLOMACY_NEUTRAL : $relation[$ally_to]['alliance_diplomacy_relation']; |
| 52 | 49 | } |
@@ -242,24 +242,24 @@ discard block |
||
| 242 | 242 | * 1 - copyright 2008 By Chlorel for XNova |
| 243 | 243 | * |
| 244 | 244 | */ |
| 245 | -function SetSelectedPlanet(&$user) |
|
| 246 | -{ |
|
| 245 | +function SetSelectedPlanet(&$user) { |
|
| 247 | 246 | $planet_row['id'] = $user['current_planet']; |
| 248 | 247 | |
| 249 | 248 | // Пытаемся переключить на новую планету |
| 250 | 249 | if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
| 251 | 250 | { |
| 252 | 251 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
| 253 | - } |
|
| 254 | - else |
|
| 252 | + } else |
|
| 255 | 253 | { |
| 256 | 254 | $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']); |
| 257 | 255 | } |
| 258 | 256 | |
| 259 | 257 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
| 260 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
| 258 | + if(!isset($planet_row['id'])) { |
|
| 259 | + // || $planet_row['id'] != $user['current_planet'] |
|
| 261 | 260 | { |
| 262 | 261 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
| 262 | + } |
|
| 263 | 263 | // Если текущей планеты не существует - выставляем Столицу |
| 264 | 264 | if(!isset($planet_row['id'])) |
| 265 | 265 | { |
@@ -284,25 +284,21 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // ---------------------------------------------------------------------------------------------------------------- |
| 287 | -function uni_render_coordinates($from, $prefix = '') |
|
| 288 | -{ |
|
| 287 | +function uni_render_coordinates($from, $prefix = '') { |
|
| 289 | 288 | return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]"; |
| 290 | 289 | } |
| 291 | 290 | |
| 292 | -function uni_render_planet($from) |
|
| 293 | -{ |
|
| 291 | +function uni_render_planet($from) { |
|
| 294 | 292 | return "{$from['name']} [{$from['galaxy']}:{$from['system']}:{$from['planet']}]"; |
| 295 | 293 | } |
| 296 | 294 | |
| 297 | -function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) |
|
| 298 | -{ |
|
| 295 | +function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) { |
|
| 299 | 296 | global $lang; |
| 300 | 297 | |
| 301 | 298 | if(!$from['id']) |
| 302 | 299 | { |
| 303 | 300 | $result = $lang['sys_planet_expedition']; |
| 304 | - } |
|
| 305 | - else |
|
| 301 | + } else |
|
| 306 | 302 | { |
| 307 | 303 | $from_planet_id = $include_id ? ( |
| 308 | 304 | 'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} ' |
@@ -318,30 +314,25 @@ discard block |
||
| 318 | 314 | return $result; |
| 319 | 315 | } |
| 320 | 316 | |
| 321 | -function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') |
|
| 322 | -{ |
|
| 317 | +function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') { |
|
| 323 | 318 | return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}"; |
| 324 | 319 | } |
| 325 | 320 | |
| 326 | -function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') |
|
| 327 | -{ |
|
| 321 | +function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') { |
|
| 328 | 322 | return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>'; |
| 329 | 323 | } |
| 330 | 324 | |
| 331 | -function uni_get_time_to_jump($moon_row) |
|
| 332 | -{ |
|
| 325 | +function uni_get_time_to_jump($moon_row) { |
|
| 333 | 326 | $jump_gate_level = mrc_get_level($user, $moon_row, STRUC_MOON_GATE); |
| 334 | 327 | return $jump_gate_level ? max(0, $moon_row['last_jump_time'] + abs(60 * 60 / $jump_gate_level) - SN_TIME_NOW) : 0; |
| 335 | 328 | } |
| 336 | 329 | |
| 337 | -function uni_calculate_moon_chance($FleetDebris) |
|
| 338 | -{ |
|
| 330 | +function uni_calculate_moon_chance($FleetDebris) { |
|
| 339 | 331 | $MoonChance = $FleetDebris / 1000000; |
| 340 | 332 | return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance); |
| 341 | 333 | } |
| 342 | 334 | |
| 343 | -function uni_coordinates_valid($coordinates, $prefix = '') |
|
| 344 | -{ |
|
| 335 | +function uni_coordinates_valid($coordinates, $prefix = '') { |
|
| 345 | 336 | global $config; |
| 346 | 337 | |
| 347 | 338 | // array_walk($coordinates, 'intval'); |
@@ -4,8 +4,7 @@ discard block |
||
| 4 | 4 | // Open Source |
| 5 | 5 | // V1 |
| 6 | 6 | // |
| 7 | -function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') |
|
| 8 | -{ |
|
| 7 | +function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') { |
|
| 9 | 8 | // Here we select which part of defense should take damage: structure or shield |
| 10 | 9 | // $damageTo = P_SHIELD; |
| 11 | 10 | // $damageTo = P_STRUCTURE; |
@@ -34,8 +33,7 @@ discard block |
||
| 34 | 33 | $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] ); |
| 35 | 34 | $structures[$targetedStructure][0] -= $structsDestroyed; |
| 36 | 35 | $MIPDamage -= $structsDestroyed*$damageDone; |
| 37 | - } |
|
| 38 | - else |
|
| 36 | + } else |
|
| 39 | 37 | { |
| 40 | 38 | // REALLY random attack |
| 41 | 39 | $can_be_damaged = sn_get_groups('defense_active'); |
@@ -161,8 +161,7 @@ discard block |
||
| 161 | 161 | return $rows_affected; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | -function rpg_level_up(&$user, $type, $xp_to_add = 0) |
|
| 165 | -{ |
|
| 164 | +function rpg_level_up(&$user, $type, $xp_to_add = 0) { |
|
| 166 | 165 | $q = 1.03; |
| 167 | 166 | |
| 168 | 167 | switch($type) |
@@ -223,27 +222,22 @@ discard block |
||
| 223 | 222 | } |
| 224 | 223 | } |
| 225 | 224 | |
| 226 | -function rpg_xp_for_level($level, $b1, $q) |
|
| 227 | -{ |
|
| 225 | +function rpg_xp_for_level($level, $b1, $q) { |
|
| 228 | 226 | return floor($b1 * (pow($q, $level) - 1)/($q - 1)); |
| 229 | 227 | } |
| 230 | 228 | |
| 231 | -function rpg_get_miner_xp($level) |
|
| 232 | -{ |
|
| 229 | +function rpg_get_miner_xp($level) { |
|
| 233 | 230 | return rpg_xp_for_level($level, 50, 1.03); |
| 234 | 231 | } |
| 235 | 232 | |
| 236 | -function RPG_get_raider_xp($level) |
|
| 237 | -{ |
|
| 233 | +function RPG_get_raider_xp($level) { |
|
| 238 | 234 | return rpg_xp_for_level($level, 10, 1.03); |
| 239 | 235 | } |
| 240 | 236 | |
| 241 | -function rpg_get_tech_xp($level) |
|
| 242 | -{ |
|
| 237 | +function rpg_get_tech_xp($level) { |
|
| 243 | 238 | return rpg_xp_for_level($level, 50, 1.03); |
| 244 | 239 | } |
| 245 | 240 | |
| 246 | -function rpg_get_explore_xp($level) |
|
| 247 | -{ |
|
| 241 | +function rpg_get_explore_xp($level) { |
|
| 248 | 242 | return rpg_xp_for_level($level, 10, 1.05); |
| 249 | 243 | } |
@@ -458,8 +458,7 @@ |
||
| 458 | 458 | |
| 459 | 459 | if(is_numeric($planet['id'])) { |
| 460 | 460 | DBStaticPlanet::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 | |
@@ -1,7 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function sys_maintenance() |
|
| 4 | -{ |
|
| 3 | +function sys_maintenance() { |
|
| 5 | 4 | global $config; |
| 6 | 5 | |
| 7 | 6 | $bashing_time_limit = SN_TIME_NOW - $config->fleet_bashing_scope; |
@@ -42,8 +41,7 @@ discard block |
||
| 42 | 41 | * TODO: 2. [<m|w|d|h|m|s>@]<time> |
| 43 | 42 | */ |
| 44 | 43 | |
| 45 | -function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false) |
|
| 46 | -{ |
|
| 44 | +function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false) { |
|
| 47 | 45 | static $date_part_names_reverse = array('seconds', 'minutes', 'hours', 'days', 'months', 'years',); |
| 48 | 46 | |
| 49 | 47 | $possible_schedules = array(); |
@@ -1,14 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // ---------------------------------------------------------------------------------------------------------------- |
| 4 | -function lng_try_filepath($path, $file_path_relative) |
|
| 5 | -{ |
|
| 4 | +function lng_try_filepath($path, $file_path_relative) { |
|
| 6 | 5 | $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative; |
| 7 | 6 | return file_exists($file_path) ? $file_path : false; |
| 8 | 7 | } |
| 9 | 8 | |
| 10 | -function lng_die_not_an_object() |
|
| 11 | -{ |
|
| 9 | +function lng_die_not_an_object() { |
|
| 12 | 10 | print('Ошибка - $lang не объект! Сообщите Администратору сервера и приложите содержимое страницы'); |
| 13 | 11 | $trace = debug_backtrace(); |
| 14 | 12 | unset($trace[0]); |
@@ -17,32 +15,27 @@ discard block |
||
| 17 | 15 | } |
| 18 | 16 | |
| 19 | 17 | // ---------------------------------------------------------------------------------------------------------------- |
| 20 | -function lng_include($filename, $path = '', $ext = '.mo.php') |
|
| 21 | -{ |
|
| 18 | +function lng_include($filename, $path = '', $ext = '.mo.php') { |
|
| 22 | 19 | global $lang; |
| 23 | 20 | return is_object($lang) ? $lang->lng_include($filename, $path, $ext) : lng_die_not_an_object(); |
| 24 | 21 | } |
| 25 | 22 | |
| 26 | -function lng_get_list() |
|
| 27 | -{ |
|
| 23 | +function lng_get_list() { |
|
| 28 | 24 | global $lang; |
| 29 | 25 | return is_object($lang) ? $lang->lng_get_list() : lng_die_not_an_object(); |
| 30 | 26 | } |
| 31 | 27 | |
| 32 | -function lng_get_info($entry) |
|
| 33 | -{ |
|
| 28 | +function lng_get_info($entry) { |
|
| 34 | 29 | global $lang; |
| 35 | 30 | return is_object($lang) ? $lang->lng_get_info($entry) : lng_die_not_an_object(); |
| 36 | 31 | } |
| 37 | 32 | |
| 38 | -function lng_switch($language_new) |
|
| 39 | -{ |
|
| 33 | +function lng_switch($language_new) { |
|
| 40 | 34 | global $lang; |
| 41 | 35 | return is_object($lang) ? $lang->lng_switch($language_new) : lng_die_not_an_object(); |
| 42 | 36 | } |
| 43 | 37 | |
| 44 | -function lng_load_i18n($i18n) |
|
| 45 | -{ |
|
| 38 | +function lng_load_i18n($i18n) { |
|
| 46 | 39 | global $lang; |
| 47 | 40 | return is_object($lang) ? $lang->lng_load_i18n($i18n) : lng_die_not_an_object(); |
| 48 | 41 | } |
@@ -11,8 +11,7 @@ discard block |
||
| 11 | 11 | * @version 1.0 copyright 2008 By e-Zobar for XNova |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -function int_banner_create($id, $type = 'userbar', $format = 'png') |
|
| 15 | -{ |
|
| 14 | +function int_banner_create($id, $type = 'userbar', $format = 'png') { |
|
| 16 | 15 | // banner.php?id=<userid>&type=<banner|userbar>&format=<png> |
| 17 | 16 | global $config, $lang; |
| 18 | 17 | |
@@ -64,8 +63,7 @@ discard block |
||
| 64 | 63 | $b_planet = $planet_row['name']; |
| 65 | 64 | $b_xyz = "[".$planet_row['galaxy'].":".$planet_row['system'].":".$planet_row['planet']."]"; |
| 66 | 65 | $b_lvl = ($user['total_rank'] ? $user['total_rank'] : $config->users_amount) ."/{$config->users_amount}"; |
| 67 | - } |
|
| 68 | - else |
|
| 66 | + } else |
|
| 69 | 67 | { |
| 70 | 68 | $b_user = $lang['ov_banner_empty_id']; |
| 71 | 69 | } |