@@ -337,6 +337,11 @@ |
||
| 337 | 337 | */ |
| 338 | 338 | // OK v4 |
| 339 | 339 | // TODO - вынести в отдельный класс |
| 340 | +/** |
|
| 341 | + * @param string $db_id_field_name |
|
| 342 | + * @param string $db_table_name |
|
| 343 | + * @param string $db_value_field_name |
|
| 344 | + */ |
|
| 340 | 345 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
| 341 | 346 | $current_value_safe = db_escape($current_value_unsafe); |
| 342 | 347 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | require_once('db_queries_fleet.php'); |
| 8 | 8 | |
| 9 | 9 | |
| 10 | -function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) |
|
| 11 | -{ |
|
| 10 | +function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) { |
|
| 12 | 11 | return doquery( |
| 13 | 12 | "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') . |
| 14 | 13 | " FROM {{planets}} AS p |
@@ -17,8 +16,7 @@ discard block |
||
| 17 | 16 | " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
| 18 | 17 | } |
| 19 | 18 | |
| 20 | -function db_planet_list_search($searchtext) |
|
| 21 | -{ |
|
| 19 | +function db_planet_list_search($searchtext) { |
|
| 22 | 20 | return doquery( |
| 23 | 21 | "SELECT |
| 24 | 22 | p.galaxy, p.system, p.planet, p.planet_type, p.name as planet_name, |
@@ -38,8 +36,7 @@ discard block |
||
| 38 | 36 | |
| 39 | 37 | |
| 40 | 38 | |
| 41 | -function db_user_list_search($searchtext) |
|
| 42 | -{ |
|
| 39 | +function db_user_list_search($searchtext) { |
|
| 43 | 40 | return doquery( |
| 44 | 41 | "SELECT |
| 45 | 42 | pn.player_name, u.id as uid, u.username, u.ally_id, u.id_planet, u.total_points, u.total_rank, |
@@ -57,8 +54,7 @@ discard block |
||
| 57 | 54 | ); |
| 58 | 55 | } |
| 59 | 56 | |
| 60 | -function db_buddy_list_by_user($user_id) |
|
| 61 | -{ |
|
| 57 | +function db_buddy_list_by_user($user_id) { |
|
| 62 | 58 | // return ($user_id = intval($user_id)) ? doquery( |
| 63 | 59 | return ($user_id = idval($user_id)) ? doquery( |
| 64 | 60 | "SELECT |
@@ -84,8 +80,7 @@ discard block |
||
| 84 | 80 | |
| 85 | 81 | |
| 86 | 82 | |
| 87 | -function db_message_list_outbox_by_user_id($user_id) |
|
| 88 | -{ |
|
| 83 | +function db_message_list_outbox_by_user_id($user_id) { |
|
| 89 | 84 | // return ($user_id = intval($user_id)) |
| 90 | 85 | return ($user_id = idval($user_id)) |
| 91 | 86 | ? doquery("SELECT {{messages}}.message_id, {{messages}}.message_owner, {{users}}.id AS message_sender, {{messages}}.message_time, |
@@ -101,8 +96,7 @@ discard block |
||
| 101 | 96 | |
| 102 | 97 | |
| 103 | 98 | |
| 104 | -function db_unit_records_sum($unit_id, $user_skip_list_unit) |
|
| 105 | -{ |
|
| 99 | +function db_unit_records_sum($unit_id, $user_skip_list_unit) { |
|
| 106 | 100 | return doquery ( |
| 107 | 101 | "SELECT unit_player_id, username, sum(unit_level) as unit_level |
| 108 | 102 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
@@ -113,8 +107,7 @@ discard block |
||
| 113 | 107 | , true); |
| 114 | 108 | } |
| 115 | 109 | |
| 116 | -function db_unit_records_plain($unit_id, $user_skip_list_unit) |
|
| 117 | -{ |
|
| 110 | +function db_unit_records_plain($unit_id, $user_skip_list_unit) { |
|
| 118 | 111 | return doquery ( |
| 119 | 112 | "SELECT unit_player_id, username, unit_level |
| 120 | 113 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
@@ -198,15 +191,13 @@ discard block |
||
| 198 | 191 | } |
| 199 | 192 | |
| 200 | 193 | |
| 201 | -function db_stat_list_delete_ally_player() |
|
| 202 | -{ |
|
| 194 | +function db_stat_list_delete_ally_player() { |
|
| 203 | 195 | return doquery('DELETE s FROM {{statpoints}} AS s JOIN {{users}} AS u ON u.id = s.id_owner WHERE s.id_ally IS NULL AND u.user_as_ally IS NOT NULL'); |
| 204 | 196 | } |
| 205 | 197 | |
| 206 | 198 | |
| 207 | 199 | |
| 208 | -function db_chat_player_list_online($chat_refresh_rate, $ally_add) |
|
| 209 | -{ |
|
| 200 | +function db_chat_player_list_online($chat_refresh_rate, $ally_add) { |
|
| 210 | 201 | $sql_date = SN_TIME_NOW - $chat_refresh_rate * 2; |
| 211 | 202 | |
| 212 | 203 | return doquery( |
@@ -220,13 +211,11 @@ discard block |
||
| 220 | 211 | ORDER BY authlevel DESC, `username`"); |
| 221 | 212 | } |
| 222 | 213 | |
| 223 | -function db_referrals_list_by_id($user_id) |
|
| 224 | -{ |
|
| 214 | +function db_referrals_list_by_id($user_id) { |
|
| 225 | 215 | return doquery("SELECT r.*, u.username, u.register_time FROM {{referrals}} AS r LEFT JOIN {{users}} AS u ON u.id = r.id WHERE id_partner = {$user_id}"); |
| 226 | 216 | } |
| 227 | 217 | |
| 228 | -function db_message_list_admin_by_type($int_type_selected, $StartRec) |
|
| 229 | -{ |
|
| 218 | +function db_message_list_admin_by_type($int_type_selected, $StartRec) { |
|
| 230 | 219 | return doquery("SELECT |
| 231 | 220 | message_id as `ID`, |
| 232 | 221 | message_from as `FROM`, |
@@ -245,8 +234,7 @@ discard block |
||
| 245 | 234 | } |
| 246 | 235 | |
| 247 | 236 | |
| 248 | -function db_message_insert_all($message_type, $from, $subject, $text) |
|
| 249 | -{ |
|
| 237 | +function db_message_insert_all($message_type, $from, $subject, $text) { |
|
| 250 | 238 | return doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
| 251 | 239 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}"); |
| 252 | 240 | } |
@@ -10,6 +10,7 @@ discard block |
||
| 10 | 10 | * |
| 11 | 11 | * 1.0 - copyright (c) 2010 by Gorlum for http://supernova.ws |
| 12 | 12 | * @version 1.0 |
| 13 | + * @param integer $lab_require |
|
| 13 | 14 | */ |
| 14 | 15 | function eco_get_lab_max_effective_level(&$user, $lab_require) |
| 15 | 16 | { |
@@ -193,6 +194,9 @@ discard block |
||
| 193 | 194 | return $result; |
| 194 | 195 | } |
| 195 | 196 | |
| 197 | +/** |
|
| 198 | + * @param integer[] $unit_list |
|
| 199 | + */ |
|
| 196 | 200 | function eco_is_builds_in_que($planet_que, $unit_list) |
| 197 | 201 | { |
| 198 | 202 | $eco_is_builds_in_que = false; |
@@ -1,7 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function eco_lab_sort_effectivness($a, $b) |
|
| 4 | -{ |
|
| 3 | +function eco_lab_sort_effectivness($a, $b) { |
|
| 5 | 4 | return $a['laboratory_effective_level'] > $b['laboratory_effective_level'] ? -1 : ($a['laboratory_effective_level'] < $b['laboratory_effective_level'] ? 1 : 0); |
| 6 | 5 | } |
| 7 | 6 | |
@@ -11,8 +10,7 @@ discard block |
||
| 11 | 10 | * 1.0 - copyright (c) 2010 by Gorlum for http://supernova.ws |
| 12 | 11 | * @version 1.0 |
| 13 | 12 | */ |
| 14 | -function eco_get_lab_max_effective_level(&$user, $lab_require) |
|
| 15 | -{ |
|
| 13 | +function eco_get_lab_max_effective_level(&$user, $lab_require) { |
|
| 16 | 14 | if(!$user['user_as_ally'] && !isset($user['laboratories_active'])) |
| 17 | 15 | { |
| 18 | 16 | $user['laboratories_active'] = array(); |
@@ -38,8 +36,7 @@ discard block |
||
| 38 | 36 | if($user['user_as_ally']) |
| 39 | 37 | { |
| 40 | 38 | $lab_level = doquery("SELECT ally_members AS effective_level FROM {{alliance}} WHERE id = {$user['user_as_ally']} LIMIT 1", true); |
| 41 | - } |
|
| 42 | - else |
|
| 39 | + } else |
|
| 43 | 40 | { |
| 44 | 41 | $tech_intergalactic = mrc_get_level($user, false, TECH_RESEARCH) + 1; |
| 45 | 42 | $lab_level['effective_level'] = 0; |
@@ -193,8 +190,7 @@ discard block |
||
| 193 | 190 | return $result; |
| 194 | 191 | } |
| 195 | 192 | |
| 196 | -function eco_is_builds_in_que($planet_que, $unit_list) |
|
| 197 | -{ |
|
| 193 | +function eco_is_builds_in_que($planet_que, $unit_list) { |
|
| 198 | 194 | $eco_is_builds_in_que = false; |
| 199 | 195 | |
| 200 | 196 | $unit_list = is_array($unit_list) ? $unit_list : array($unit_list => $unit_list); |
@@ -216,8 +212,7 @@ discard block |
||
| 216 | 212 | } |
| 217 | 213 | |
| 218 | 214 | function eco_unit_busy(&$user, &$planet, $unit_id){return sn_function_call('eco_unit_busy', array(&$user, &$planet, $unit_id, &$result));} |
| 219 | -function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result) |
|
| 220 | -{ |
|
| 215 | +function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result) { |
|
| 221 | 216 | global $config; |
| 222 | 217 | |
| 223 | 218 | $result = isset($result) ? $result : false; |
@@ -238,8 +233,7 @@ discard block |
||
| 238 | 233 | //{ |
| 239 | 234 | // $result = true; |
| 240 | 235 | //} |
| 241 | - } |
|
| 242 | - elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que']) |
|
| 236 | + } elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que']) |
|
| 243 | 237 | { |
| 244 | 238 | $result = eco_is_builds_in_que($planet['que'], array(STRUC_LABORATORY, STRUC_LABORATORY_NANO)); |
| 245 | 239 | } |
@@ -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 | |
@@ -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 | |
@@ -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; |
@@ -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']; |
@@ -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; |
@@ -15,8 +15,7 @@ discard block |
||
| 15 | 15 | 1.5 - copyright (c) 2010-2011 by Gorlum for http://supernova.ws |
| 16 | 16 | [+] SuperMassMailing - authlevel=3 player can send messages to whole server ('*' as $owners) |
| 17 | 17 | */ |
| 18 | -function msg_ali_send($message, $subject, $ally_rank_id = 0, $ally_id = 0) |
|
| 19 | -{ |
|
| 18 | +function msg_ali_send($message, $subject, $ally_rank_id = 0, $ally_id = 0) { |
|
| 20 | 19 | global $user; |
| 21 | 20 | |
| 22 | 21 | $ally_id = $ally_id ? $ally_id : $user['ally_id']; |
@@ -37,8 +36,7 @@ discard block |
||
| 37 | 36 | return $list; |
| 38 | 37 | } |
| 39 | 38 | |
| 40 | -function msg_send_simple_message($owners, $sender, $timestamp, $message_type, $from, $subject, $text, $escaped = false, $force = false) |
|
| 41 | -{ |
|
| 39 | +function msg_send_simple_message($owners, $sender, $timestamp, $message_type, $from, $subject, $text, $escaped = false, $force = false) { |
|
| 42 | 40 | global $config, $user, $sn_message_class_list; |
| 43 | 41 | |
| 44 | 42 | if(!$owners) |
@@ -79,8 +77,7 @@ discard block |
||
| 79 | 77 | // TODO Добавить $sender - рассылка может быть и от кого-то |
| 80 | 78 | db_message_insert_all($message_type, $from, $subject, $text); |
| 81 | 79 | $owners = array(); |
| 82 | - } |
|
| 83 | - else |
|
| 80 | + } else |
|
| 84 | 81 | { |
| 85 | 82 | $insert_values = array(); |
| 86 | 83 | $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
@@ -90,8 +87,7 @@ discard block |
||
| 90 | 87 | if($user['id'] != $owner) |
| 91 | 88 | { |
| 92 | 89 | $owner_row = db_user_by_id($owner); |
| 93 | - } |
|
| 94 | - else |
|
| 90 | + } else |
|
| 95 | 91 | { |
| 96 | 92 | $owner_row = $user; |
| 97 | 93 | } |
@@ -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); |
@@ -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 | } |
@@ -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 | |
@@ -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(); |
@@ -1,8 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Compare function to sort fleet in time order |
| 4 | -function tpl_assign_fleet_compare($a, $b) |
|
| 5 | -{ |
|
| 4 | +function tpl_assign_fleet_compare($a, $b) { |
|
| 6 | 5 | if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) |
| 7 | 6 | { |
| 8 | 7 | if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) |
@@ -10,15 +9,13 @@ discard block |
||
| 10 | 9 | return 0; |
| 11 | 10 | } |
| 12 | 11 | return ($a['fleet']['OV_LEFT'] < $b['fleet']['OV_LEFT']) ? -1 : 1; |
| 13 | - } |
|
| 14 | - else |
|
| 12 | + } else |
|
| 15 | 13 | { |
| 16 | 14 | return $a['fleet']['OV_THIS_PLANET'] ? -1 : 1; |
| 17 | 15 | } |
| 18 | 16 | } |
| 19 | 17 | |
| 20 | -function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') |
|
| 21 | -{ |
|
| 18 | +function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') { |
|
| 22 | 19 | if(!$fleets) |
| 23 | 20 | { |
| 24 | 21 | return; |
@@ -41,8 +38,7 @@ discard block |
||
| 41 | 38 | } |
| 42 | 39 | |
| 43 | 40 | // function that parses internal fleet representation (as array(id => count)) |
| 44 | -function tpl_parse_fleet_sn($fleet, $fleet_id) |
|
| 45 | -{ |
|
| 41 | +function tpl_parse_fleet_sn($fleet, $fleet_id) { |
|
| 46 | 42 | global $lang, $user; |
| 47 | 43 | |
| 48 | 44 | $user_data = &$user; |
@@ -182,8 +178,7 @@ discard block |
||
| 182 | 178 | return $result; |
| 183 | 179 | } |
| 184 | 180 | |
| 185 | -function tpl_parse_planet_que($que, $planet, $que_id) |
|
| 186 | -{ |
|
| 181 | +function tpl_parse_planet_que($que, $planet, $que_id) { |
|
| 187 | 182 | $hangar_que = array(); |
| 188 | 183 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
| 189 | 184 | if(!empty($que_hangar)) |
@@ -198,8 +193,7 @@ discard block |
||
| 198 | 193 | return $hangar_que; |
| 199 | 194 | } |
| 200 | 195 | |
| 201 | -function tpl_parse_planet($planet, &$fleets) |
|
| 202 | -{ |
|
| 196 | +function tpl_parse_planet($planet, &$fleets) { |
|
| 203 | 197 | global $lang; |
| 204 | 198 | |
| 205 | 199 | $que = que_get($planet['id_owner'], $planet['id'], false); |
@@ -268,8 +262,7 @@ discard block |
||
| 268 | 262 | return $result; |
| 269 | 263 | } |
| 270 | 264 | |
| 271 | -function flt_get_fleets_to_planet($planet, $fleet_db_list = 0) |
|
| 272 | -{ |
|
| 265 | +function flt_get_fleets_to_planet($planet, $fleet_db_list = 0) { |
|
| 273 | 266 | if(!($planet && $planet['id']) && !$fleet_db_list) |
| 274 | 267 | { |
| 275 | 268 | return $planet; |
@@ -291,8 +284,7 @@ discard block |
||
| 291 | 284 | continue; |
| 292 | 285 | } |
| 293 | 286 | $fleet_ownage = 'own'; |
| 294 | - } |
|
| 295 | - else |
|
| 287 | + } else |
|
| 296 | 288 | { |
| 297 | 289 | switch($fleet['fleet_mission']) |
| 298 | 290 | { |
@@ -341,8 +333,7 @@ discard block |
||
| 341 | 333 | * @param array $fleets_to_planet |
| 342 | 334 | * @param int $round |
| 343 | 335 | */ |
| 344 | -function tpl_set_resource_info(&$template, $planetrow, $fleets_to_planet = array(), $round = 0) |
|
| 345 | -{ |
|
| 336 | +function tpl_set_resource_info(&$template, $planetrow, $fleets_to_planet = array(), $round = 0) { |
|
| 346 | 337 | $template->assign_vars(array( |
| 347 | 338 | 'RESOURCE_ROUNDING' => $round, |
| 348 | 339 | |
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +/** |
|
| 4 | + * @param string $type |
|
| 5 | + */ |
|
| 3 | 6 | function sn_ube_simulator_encode_replay($combat, $type) |
| 4 | 7 | { |
| 5 | 8 | $strPacked = "{$type}!"; |
@@ -58,6 +61,9 @@ discard block |
||
| 58 | 61 | |
| 59 | 62 | // ------------------------------------------------------------------------------------------------ |
| 60 | 63 | // Преобразовывает данные симулятора в данные для расчета боя |
| 64 | +/** |
|
| 65 | + * @param boolean $attacker |
|
| 66 | + */ |
|
| 61 | 67 | function sn_ube_simulator_fill_side(&$combat_data, $side_info, $attacker, $player_id = -1) |
| 62 | 68 | { |
| 63 | 69 | global $ube_convert_techs; |
@@ -1,7 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function sn_ube_simulator_encode_replay($combat, $type) |
|
| 4 | -{ |
|
| 3 | +function sn_ube_simulator_encode_replay($combat, $type) { |
|
| 5 | 4 | $strPacked = "{$type}!"; |
| 6 | 5 | |
| 7 | 6 | foreach($combat as $fleetID => $fleetCompress) |
@@ -17,8 +16,7 @@ discard block |
||
| 17 | 16 | return $strPacked; |
| 18 | 17 | } |
| 19 | 18 | |
| 20 | -function sn_ube_simulator_decode_replay($str_data) |
|
| 21 | -{ |
|
| 19 | +function sn_ube_simulator_decode_replay($str_data) { |
|
| 22 | 20 | $fleet_id = 0; |
| 23 | 21 | |
| 24 | 22 | $arr_data_unpacked = explode('!', $str_data); |
@@ -58,8 +56,7 @@ discard block |
||
| 58 | 56 | |
| 59 | 57 | // ------------------------------------------------------------------------------------------------ |
| 60 | 58 | // Преобразовывает данные симулятора в данные для расчета боя |
| 61 | -function sn_ube_simulator_fill_side(&$combat_data, $side_info, $attacker, $player_id = -1) |
|
| 62 | -{ |
|
| 59 | +function sn_ube_simulator_fill_side(&$combat_data, $side_info, $attacker, $player_id = -1) { |
|
| 63 | 60 | global $ube_convert_techs; |
| 64 | 61 | |
| 65 | 62 | $player_id = $player_id == -1 ? count($combat_data[UBE_PLAYERS]) : $player_id; |
@@ -82,16 +79,13 @@ discard block |
||
| 82 | 79 | if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) |
| 83 | 80 | { |
| 84 | 81 | $combat_data[UBE_FLEETS][$player_id][UBE_COUNT][$unit_id] = $unit_count; |
| 85 | - } |
|
| 86 | - elseif($unit_type == UNIT_RESOURCES) |
|
| 82 | + } elseif($unit_type == UNIT_RESOURCES) |
|
| 87 | 83 | { |
| 88 | 84 | $combat_data[UBE_FLEETS][$player_id][UBE_RESOURCES][$unit_id] = $unit_count; |
| 89 | - } |
|
| 90 | - elseif($unit_type == UNIT_TECHNOLOGIES) |
|
| 85 | + } elseif($unit_type == UNIT_TECHNOLOGIES) |
|
| 91 | 86 | { |
| 92 | 87 | $combat_data[UBE_PLAYERS][$player_id][UBE_BONUSES][$ube_convert_techs[$unit_id]] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100; |
| 93 | - } |
|
| 94 | - elseif($unit_type == UNIT_GOVERNORS) |
|
| 88 | + } elseif($unit_type == UNIT_GOVERNORS) |
|
| 95 | 89 | { |
| 96 | 90 | if($unit_id == MRC_FORTIFIER) |
| 97 | 91 | { |
@@ -100,8 +94,7 @@ discard block |
||
| 100 | 94 | $combat_data[UBE_FLEETS][$player_id][UBE_BONUSES][$ube_id] += $unit_count * get_unit_param($unit_id, P_BONUS_VALUE) / 100; |
| 101 | 95 | } |
| 102 | 96 | } |
| 103 | - } |
|
| 104 | - elseif($unit_type == UNIT_MERCENARIES) |
|
| 97 | + } elseif($unit_type == UNIT_MERCENARIES) |
|
| 105 | 98 | { |
| 106 | 99 | if($unit_id == MRC_ADMIRAL) |
| 107 | 100 | { |
@@ -115,8 +108,7 @@ discard block |
||
| 115 | 108 | } |
| 116 | 109 | } |
| 117 | 110 | |
| 118 | -function sn_ube_simulator_fleet_converter($sym_attacker, $sym_defender) |
|
| 119 | -{ |
|
| 111 | +function sn_ube_simulator_fleet_converter($sym_attacker, $sym_defender) { |
|
| 120 | 112 | $combat_data = array( |
| 121 | 113 | UBE_OPTIONS => array( |
| 122 | 114 | UBE_SIMULATOR => sys_get_param_int('simulator'), |