@@ -56,8 +56,7 @@ discard block |
||
| 56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
| 57 | 57 | sn_db_transaction_commit(); |
| 58 | 58 | throw new exception('buddy_err_accept_none', ERR_NONE); |
| 59 | - } |
|
| 60 | - else |
|
| 59 | + } else |
|
| 61 | 60 | { |
| 62 | 61 | throw new exception('buddy_err_accept_internal', ERR_ERROR); |
| 63 | 62 | } |
@@ -69,9 +68,11 @@ discard block |
||
| 69 | 68 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
| 70 | 69 | } |
| 71 | 70 | |
| 72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
| 71 | + if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
| 72 | + // Existing friendship |
|
| 73 | 73 | { |
| 74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | msg_send_simple_message($ex_friend_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_unfriend_title'], |
| 77 | 78 | sprintf($lang['buddy_msg_unfriend_text'], $user['username'])); |
@@ -79,17 +80,19 @@ discard block |
||
| 79 | 80 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 80 | 81 | sn_db_transaction_commit(); |
| 81 | 82 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
| 82 | - } |
|
| 83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
| 83 | + } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
| 84 | + // Player's outcoming request - either denied or waiting |
|
| 84 | 85 | { |
| 85 | 86 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 87 | + } |
|
| 86 | 88 | sn_db_transaction_commit(); |
| 87 | 89 | throw new exception('buddy_err_delete_own', ERR_NONE); |
| 88 | - } |
|
| 89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
| 90 | + } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) { |
|
| 91 | + // Deny incoming request |
|
| 90 | 92 | { |
| 91 | 93 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
| 92 | 94 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
| 95 | + } |
|
| 93 | 96 | |
| 94 | 97 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_DENIED . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 95 | 98 | sn_db_transaction_commit(); |
@@ -104,8 +107,7 @@ discard block |
||
| 104 | 107 | if($new_friend_id = sys_get_param_id('request_user_id')) |
| 105 | 108 | { |
| 106 | 109 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
| 107 | - } |
|
| 108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 110 | + } elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 109 | 111 | { |
| 110 | 112 | $new_friend_row = db_user_by_username($new_friend_name); |
| 111 | 113 | $new_friend_name = db_escape($new_friend_name); |
@@ -138,8 +140,7 @@ discard block |
||
| 138 | 140 | sn_db_transaction_commit(); |
| 139 | 141 | throw new exception('buddy_err_adding_none', ERR_NONE); |
| 140 | 142 | } |
| 141 | -} |
|
| 142 | -catch(exception $e) |
|
| 143 | +} catch(exception $e) |
|
| 143 | 144 | { |
| 144 | 145 | $result[] = array( |
| 145 | 146 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -18,39 +18,39 @@ discard block |
||
| 18 | 18 | { |
| 19 | 19 | sn_db_transaction_start(); |
| 20 | 20 | |
| 21 | - if($buddy_id = sys_get_param_id('buddy_id')) |
|
| 21 | + if ($buddy_id = sys_get_param_id('buddy_id')) |
|
| 22 | 22 | { |
| 23 | 23 | $buddy_row = doquery("SELECT BUDDY_SENDER_ID, BUDDY_OWNER_ID, BUDDY_STATUS FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1 FOR UPDATE;", true); |
| 24 | - if(!is_array($buddy_row)) |
|
| 24 | + if (!is_array($buddy_row)) |
|
| 25 | 25 | { |
| 26 | 26 | throw new exception('buddy_err_not_exist', ERR_ERROR); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - switch($mode = sys_get_param_str('mode')) |
|
| 29 | + switch ($mode = sys_get_param_str('mode')) |
|
| 30 | 30 | { |
| 31 | 31 | case 'accept': |
| 32 | - if($buddy_row['BUDDY_SENDER_ID'] == $user['id']) |
|
| 32 | + if ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) |
|
| 33 | 33 | { |
| 34 | 34 | throw new exception('buddy_err_accept_own', ERR_ERROR); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if($buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 37 | + if ($buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 38 | 38 | { |
| 39 | 39 | throw new exception('buddy_err_accept_alien', ERR_ERROR); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) |
|
| 42 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) |
|
| 43 | 43 | { |
| 44 | 44 | throw new exception('buddy_err_accept_already', ERR_WARNING); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) |
|
| 47 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) |
|
| 48 | 48 | { |
| 49 | 49 | throw new exception('buddy_err_accept_denied', ERR_ERROR); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_ACTIVE . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 53 | - if(SN::$db->db_affected_rows()) |
|
| 53 | + if (SN::$db->db_affected_rows()) |
|
| 54 | 54 | { |
| 55 | 55 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_accept_title'], |
| 56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | break; |
| 65 | 65 | |
| 66 | 66 | case 'delete': |
| 67 | - if($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 67 | + if ($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
| 68 | 68 | { |
| 69 | 69 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
| 72 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
| 73 | 73 | { |
| 74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
| 75 | 75 | |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | sn_db_transaction_commit(); |
| 81 | 81 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
| 82 | 82 | } |
| 83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
| 83 | + elseif ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
| 84 | 84 | { |
| 85 | 85 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 86 | 86 | sn_db_transaction_commit(); |
| 87 | 87 | throw new exception('buddy_err_delete_own', ERR_NONE); |
| 88 | 88 | } |
| 89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
| 89 | + elseif ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
| 90 | 90 | { |
| 91 | 91 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
| 92 | 92 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
@@ -101,24 +101,24 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | // New request? |
| 103 | 103 | // Checking for user ID - in case if it was request from outside buddy system |
| 104 | - if($new_friend_id = sys_get_param_id('request_user_id')) |
|
| 104 | + if ($new_friend_id = sys_get_param_id('request_user_id')) |
|
| 105 | 105 | { |
| 106 | 106 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
| 107 | 107 | } |
| 108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 108 | + elseif ($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 109 | 109 | { |
| 110 | 110 | $new_friend_row = db_user_by_username($new_friend_name); |
| 111 | 111 | $new_friend_name = db_escape($new_friend_name); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if($new_friend_row['id'] == $user['id']) |
|
| 114 | + if ($new_friend_row['id'] == $user['id']) |
|
| 115 | 115 | { |
| 116 | 116 | unset($new_friend_row); |
| 117 | 117 | throw new exception('buddy_err_adding_self', ERR_ERROR); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Checking for user name & request text - in case if it was request to adding new request |
| 121 | - if(isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) |
|
| 121 | + if (isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) |
|
| 122 | 122 | { |
| 123 | 123 | $check_relation = doquery("SELECT `BUDDY_ID` FROM {{buddy}} WHERE |
| 124 | 124 | (`BUDDY_SENDER_ID` = {$user['id']} AND `BUDDY_OWNER_ID` = {$new_friend_row['id']}) |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | (`BUDDY_SENDER_ID` = {$new_friend_row['id']} AND `BUDDY_OWNER_ID` = {$user['id']}) |
| 127 | 127 | LIMIT 1 FOR UPDATE;" |
| 128 | 128 | , true); |
| 129 | - if(isset($check_relation['BUDDY_ID'])) |
|
| 129 | + if (isset($check_relation['BUDDY_ID'])) |
|
| 130 | 130 | { |
| 131 | 131 | throw new exception('buddy_err_adding_exists', ERR_WARNING); |
| 132 | 132 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | throw new exception('buddy_err_adding_none', ERR_NONE); |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | -catch(exception $e) |
|
| 142 | +catch (exception $e) |
|
| 143 | 143 | { |
| 144 | 144 | $result[] = array( |
| 145 | 145 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | sn_db_transaction_rollback(); |
| 151 | 151 | |
| 152 | 152 | $query = db_buddy_list_by_user($user['id']); |
| 153 | -while($row = db_fetch($query)) |
|
| 153 | +while ($row = db_fetch($query)) |
|
| 154 | 154 | { |
| 155 | 155 | $row['BUDDY_REQUEST'] = HelperString::nl2br($row['BUDDY_REQUEST']); |
| 156 | 156 | |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR); |
| 20 | 20 | |
| 21 | -$template = gettemplate('admin/adm_payment', true); |
|
| 21 | +$template = gettemplate('admin/adm_payment', true); |
|
| 22 | 22 | |
| 23 | 23 | $payer_list = array( |
| 24 | 24 | -1 => $lang['adm_pay_filter_all'], |
| 25 | 25 | ); |
| 26 | 26 | $query = doquery("SELECT payment_user_id, payment_user_name FROM `{{payment}}` GROUP BY payment_user_id ORDER BY payment_user_name"); |
| 27 | -while($row = db_fetch($query)) { |
|
| 27 | +while ($row = db_fetch($query)) { |
|
| 28 | 28 | $payer_list[$row['payment_user_id']] = '[' . $row['payment_user_id'] . '] ' . $row['payment_user_name']; |
| 29 | 29 | } |
| 30 | 30 | tpl_assign_select($template, 'payer', $payer_list); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | '' => $lang['adm_pay_filter_all'], |
| 34 | 34 | ); |
| 35 | 35 | $query = doquery("SELECT distinct payment_module_name FROM `{{payment}}` ORDER BY payment_module_name"); |
| 36 | -while($row = db_fetch($query)) { |
|
| 36 | +while ($row = db_fetch($query)) { |
|
| 37 | 37 | $module_list[$row['payment_module_name']] = $row['payment_module_name']; |
| 38 | 38 | } |
| 39 | 39 | tpl_assign_select($template, 'module', $module_list); |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | //while($row = db_fetch($query)) { |
| 72 | -foreach($query as $row) { |
|
| 72 | +foreach ($query as $row) { |
|
| 73 | 73 | $row2 = array(); |
| 74 | - foreach($row as $key => $value) { |
|
| 74 | + foreach ($row as $key => $value) { |
|
| 75 | 75 | $row2[strtoupper($key)] = $value; |
| 76 | 76 | } |
| 77 | 77 | $template->assign_block_vars('payment', $row2); |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | * @return bool |
| 47 | 47 | */ |
| 48 | 48 | public function changeTitle(AllianceTitle $title) { |
| 49 | - if(!$title instanceof AllianceTitle) { |
|
| 49 | + if (!$title instanceof AllianceTitle) { |
|
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | continue; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $result[] = (string)$title; |
|
| 48 | + $result[] = (string) $title; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return implode(';', $result); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * Updates title names and access rights with current ones |
| 68 | 68 | */ |
| 69 | 69 | public function updateTitles() { |
| 70 | - $this->alliance->titleList = (string)$this; |
|
| 70 | + $this->alliance->titleList = (string) $this; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | protected function extractTitles() { |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | * @return int |
| 59 | 59 | */ |
| 60 | 60 | public static function calcBonusPower($unitInfo) { |
| 61 | - return isset($unitInfo[P_BONUS_VALUE]) ? $unitInfo[P_BONUS_VALUE] : |
|
| 62 | - (static::calcBonusType($unitInfo) == BONUS_ABILITY ? 1 : 0); |
|
| 61 | + return isset($unitInfo[P_BONUS_VALUE]) ? $unitInfo[P_BONUS_VALUE] : (static::calcBonusType($unitInfo) == BONUS_ABILITY ? 1 : 0); |
|
| 63 | 62 | } |
| 64 | 63 | |
| 65 | 64 | /** |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | renderFooter(); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;; |
|
| 291 | + $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false; ; |
|
| 292 | 292 | |
| 293 | 293 | sn_db_disconnect(); |
| 294 | 294 | |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | 'QUE_ID' => QUE_RESEARCH, |
| 671 | 671 | 'QUE_HTML' => 'topnav', |
| 672 | 672 | |
| 673 | - 'RESEARCH_ONGOING' => (boolean)$user['que'], |
|
| 673 | + 'RESEARCH_ONGOING' => (boolean) $user['que'], |
|
| 674 | 674 | |
| 675 | 675 | 'TIME_TEXT' => sprintf($str_date_format, $time_now_parsed['year'], $lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'], |
| 676 | 676 | $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds'] |
@@ -963,7 +963,7 @@ discard block |
||
| 963 | 963 | 'LANG' => $language ? $language : '', |
| 964 | 964 | 'referral' => $id_ref ? '&id_ref=' . $id_ref : '', |
| 965 | 965 | |
| 966 | - 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
| 966 | + 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
| 967 | 967 | 'FILENAME' => basename($_SERVER['PHP_SELF']), |
| 968 | 968 | )); |
| 969 | 969 | |
@@ -284,7 +284,7 @@ |
||
| 284 | 284 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
| 285 | 285 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
| 286 | 286 | |
| 287 | - array_walk_recursive($result, function (&$value) use ($cost_left) { |
|
| 287 | + array_walk_recursive($result, function(&$value) use ($cost_left) { |
|
| 288 | 288 | $value -= $cost_left; |
| 289 | 289 | }); |
| 290 | 290 | } |
@@ -58,8 +58,8 @@ |
||
| 58 | 58 | protected function bonusSort(BonusAtom $a, BonusAtom $b) { |
| 59 | 59 | static $bonusOrder = [BonusAtom::class, BonusAtomAbility::class, BonusAtomAdd::class, BonusAtomPercent::class, BonusAtomMultiply::class]; |
| 60 | 60 | |
| 61 | - $indexA = (int)array_search(get_class($a), $bonusOrder); |
|
| 62 | - $indexB = (int)array_search(get_class($b), $bonusOrder); |
|
| 61 | + $indexA = (int) array_search(get_class($a), $bonusOrder); |
|
| 62 | + $indexB = (int) array_search(get_class($b), $bonusOrder); |
|
| 63 | 63 | |
| 64 | 64 | return $indexA == $indexB ? 0 : ($indexA > $indexB ? +1 : -1); |
| 65 | 65 | } |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | $fleet_left = 1 - mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000; |
| 16 | 16 | $fleet_lost = array(); |
| 17 | - foreach($fleet as $unit_id => &$unit_amount) { |
|
| 17 | + foreach ($fleet as $unit_id => &$unit_amount) { |
|
| 18 | 18 | $ships_left = floor($unit_amount * $fleet_left); |
| 19 | 19 | $fleet_lost[$unit_id] = $unit_amount - $ships_left; |
| 20 | 20 | $unit_amount = $ships_left; |
| 21 | - if(!$unit_amount) { |
|
| 21 | + if (!$unit_amount) { |
|
| 22 | 22 | unset($fleet[$unit_id]); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -31,14 +31,14 @@ discard block |
||
| 31 | 31 | // $fleet = array(); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -function flt_mission_explore_addon(&$result){return sn_function_call('flt_mission_explore_addon', array(&$result));} |
|
| 34 | +function flt_mission_explore_addon(&$result) {return sn_function_call('flt_mission_explore_addon', array(&$result)); } |
|
| 35 | 35 | function sn_flt_mission_explore_addon(&$result) { |
| 36 | 36 | return $result; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | function flt_mission_explore(&$mission_data) { |
| 41 | - if(!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) { |
|
| 41 | + if (!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) { |
|
| 42 | 42 | return CACHE_NONE; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | $outcome_list = &$result['$outcome_list']; |
| 72 | 72 | $fleet_metal_points = &$result['$fleet_metal_points']; |
| 73 | 73 | |
| 74 | - if(!$ship_data) { |
|
| 75 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
| 74 | + if (!$ship_data) { |
|
| 75 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
| 76 | 76 | $unit_info = get_unit_param($unit_id); |
| 77 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
| 77 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $fleet = sys_unit_str2arr($fleet_row['fleet_array']); |
| 87 | 87 | $fleet_capacity = 0; |
| 88 | 88 | $fleet_metal_points = 0; |
| 89 | - foreach($fleet as $ship_id => $ship_amount) { |
|
| 89 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
| 90 | 90 | $unit_info = get_unit_param($ship_id); |
| 91 | 91 | $fleet_capacity += $ship_amount * $unit_info[P_CAPACITY]; |
| 92 | 92 | $fleet_metal_points += $ship_amount * $ship_data[$ship_id][P_COST_METAL]; |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | $flt_stay_hours = ($fleet_row['fleet_end_stay'] - $fleet_row['fleet_start_time']) / 3600 * ($config->game_speed_expedition ? $config->game_speed_expedition : 1); |
| 97 | 97 | |
| 98 | 98 | $outcome_list = sn_get_groups(GROUP_MISSION_EXPLORE_OUTCOMES); |
| 99 | - $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1/1.7)); |
|
| 99 | + $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
|
| 100 | 100 | |
| 101 | 101 | $chance_max = 0; |
| 102 | - foreach($outcome_list as $key => &$value) { |
|
| 103 | - if(!$value['chance']) { |
|
| 102 | + foreach ($outcome_list as $key => &$value) { |
|
| 103 | + if (!$value['chance']) { |
|
| 104 | 104 | unset($outcome_list[$key]); |
| 105 | 105 | continue; |
| 106 | 106 | } |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | $outcome_value = mt_rand(0, $chance_max); |
| 110 | 110 | // $outcome_value = 409; |
| 111 | 111 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
| 112 | - foreach($outcome_list as $key => &$value) { |
|
| 113 | - if(!$value['chance']) { |
|
| 112 | + foreach ($outcome_list as $key => &$value) { |
|
| 113 | + if (!$value['chance']) { |
|
| 114 | 114 | continue; |
| 115 | 115 | } |
| 116 | 116 | $mission_outcome = $key; |
| 117 | 117 | $outcome_description = $value; |
| 118 | - if($outcome_value <= $outcome_description['value']) { |
|
| 118 | + if ($outcome_value <= $outcome_description['value']) { |
|
| 119 | 119 | break; |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $found_dark_matter = 0; |
| 132 | 132 | // $outcome_mission_sub = -1; |
| 133 | 133 | |
| 134 | - switch($mission_outcome) { |
|
| 134 | + switch ($mission_outcome) { |
|
| 135 | 135 | // switch(FLT_EXPEDITION_OUTCOME_LOST_FLEET) { // TODO DEBUG! |
| 136 | 136 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
| 137 | 137 | flt_mission_explore_outcome_lost_fleet($result); |
@@ -166,14 +166,14 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | // Рассчитываем стоимость самого дорого корабля в металле |
| 168 | 168 | $max_metal_cost = 0; |
| 169 | - foreach($fleet as $ship_id => $ship_amount) { |
|
| 169 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
| 170 | 170 | $max_metal_cost = max($max_metal_cost, $ship_data[$ship_id]['metal_cost']); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
| 174 | 174 | $can_be_found = array(); |
| 175 | - foreach($ship_data as $ship_id => $ship_info) { |
|
| 176 | - if($ship_info['metal_cost'] < $max_metal_cost) { |
|
| 175 | + foreach ($ship_data as $ship_id => $ship_info) { |
|
| 176 | + if ($ship_info['metal_cost'] < $max_metal_cost) { |
|
| 177 | 177 | $can_be_found[$ship_id] = $ship_info['metal_cost']; |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | unset($can_be_found[SHIP_SPY]); |
| 183 | 183 | |
| 184 | 184 | $fleet_found = array(); |
| 185 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
| 185 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
| 186 | 186 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
| 187 | 187 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
| 188 | 188 | $found_ship_cost = reset($found_ship); |
| 189 | 189 | $found_ship_id = key($found_ship); |
| 190 | 190 | |
| 191 | - if($found_ship_cost > $found_in_metal) { |
|
| 191 | + if ($found_ship_cost > $found_in_metal) { |
|
| 192 | 192 | unset($can_be_found[$found_ship_id]); |
| 193 | 193 | } else { |
| 194 | 194 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if(empty($fleet_found)) { |
|
| 200 | + if (empty($fleet_found)) { |
|
| 201 | 201 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 202 | 202 | } else { |
| 203 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
| 203 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
| 204 | 204 | $fleet[$unit_id] += $unit_amount; |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $fleet_row['fleet_resource_crystal'] += $resources_found[RES_CRYSTAL]; |
| 227 | 227 | $fleet_row['fleet_resource_deuterium'] += $resources_found[RES_DEUTERIUM]; |
| 228 | 228 | |
| 229 | - if(array_sum($resources_found) == 0) { |
|
| 229 | + if (array_sum($resources_found) == 0) { |
|
| 230 | 230 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 231 | 231 | } |
| 232 | 232 | break; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | // Рассчитываем количество найденной ТМ |
| 238 | 238 | $found_dark_matter = floor(min($outcome_percent * $fleet_metal_points / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
| 239 | 239 | |
| 240 | - if(!$found_dark_matter) { |
|
| 240 | + if (!$found_dark_matter) { |
|
| 241 | 241 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
| 242 | 242 | } |
| 243 | 243 | break; |
@@ -251,31 +251,31 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | flt_mission_explore_addon($result); |
| 253 | 253 | |
| 254 | - if($found_dark_matter) { |
|
| 254 | + if ($found_dark_matter) { |
|
| 255 | 255 | rpg_points_change($fleet_row['fleet_owner'], RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
| 256 | 256 | $msg_text_addon = sprintf($lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if(!empty($fleet_lost)) { |
|
| 259 | + if (!empty($fleet_lost)) { |
|
| 260 | 260 | $msg_text_addon = $lang['flt_mission_expedition']['lost_fleet']; |
| 261 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
| 261 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
| 262 | 262 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | $fleet_row['fleet_amount'] = array_sum($fleet); |
| 267 | - if(!empty($fleet) && $fleet_row['fleet_amount']) { |
|
| 268 | - if(!empty($fleet_found)) { |
|
| 267 | + if (!empty($fleet) && $fleet_row['fleet_amount']) { |
|
| 268 | + if (!empty($fleet_found)) { |
|
| 269 | 269 | $msg_text_addon = $lang['flt_mission_expedition']['found_fleet']; |
| 270 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
| 270 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
| 271 | 271 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | $query_delta = array(); |
| 276 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
| 276 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
| 277 | 277 | $msg_text_addon = $lang['flt_mission_expedition']['found_resources']; |
| 278 | - foreach($resources_found as $ship_id => $ship_amount) { |
|
| 278 | + foreach ($resources_found as $ship_id => $ship_amount) { |
|
| 279 | 279 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
| 280 | 280 | } |
| 281 | 281 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | $query_data = array(); |
| 291 | - if(!empty($fleet_lost) || !empty($fleet_found)) { |
|
| 291 | + if (!empty($fleet_lost) || !empty($fleet_found)) { |
|
| 292 | 292 | $fleet_row['fleet_array'] = sys_unit_arr2str($fleet); |
| 293 | 293 | |
| 294 | 294 | // $query_data[] = "`fleet_amount` = {$fleet_row['fleet_amount']}"; |
@@ -316,17 +316,16 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | db_user_set_by_id($fleet_row['fleet_owner'], "`player_rpg_explore_xp` = `player_rpg_explore_xp` + 1"); |
| 318 | 318 | |
| 319 | - if(!$msg_text) { |
|
| 319 | + if (!$msg_text) { |
|
| 320 | 320 | $messages = &$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
| 321 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
| 321 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
| 322 | 322 | $messages = &$messages[$outcome_mission_sub]; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - $msg_text = is_string($messages) ? $messages : |
|
| 326 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
| 325 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
| 327 | 326 | } |
| 328 | 327 | $msg_text = sprintf($msg_text, $fleet_row['fleet_id'], uni_render_coordinates($fleet_row, 'fleet_end_')) . |
| 329 | - ($msg_text_addon ? "\r\n" . $msg_text_addon: ''); |
|
| 328 | + ($msg_text_addon ? "\r\n" . $msg_text_addon : ''); |
|
| 330 | 329 | |
| 331 | 330 | msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_stay'], MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text); |
| 332 | 331 | |