@@ -1,32 +1,32 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * index.php - overview.php |
|
4 | - * |
|
5 | - * 2.4 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
6 | - * [-] Removed News frame |
|
7 | - * [-] Time & Usersonline moved to Top-Frame |
|
8 | - * 2.3 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
9 | - * [*] Complying with PCG |
|
10 | - * 2.2 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
11 | - * [+] Redo flying fleet list |
|
12 | - * 2.1 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
13 | - * [+] Planets on planet list now have indication of planet fill |
|
14 | - * [+] Planets on planet list now have indication when there is enemy fleet flying to planet |
|
15 | - * 2.0 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
16 | - * [+] Now there is full planet list on right side of screen a-la oGame |
|
17 | - * [+] Planet list now include icons for buildings/tech/fleet on progress |
|
18 | - * 1.5 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
19 | - * [*] Subplanet timers now use sn_timer.js library |
|
20 | - * 1.4 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
21 | - * [*] All mainplanet timers now use new sn_timer.js library |
|
22 | - * 1.3 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
23 | - * [*] Adjusted layouts of player infos |
|
24 | - * 1.2 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
25 | - * [*] Adjusted layouts of planet infos |
|
26 | - * 1.1 - Security checks by Gorlum for http://supernova.ws |
|
27 | - * @version 1 |
|
28 | - * @copyright 2008 By Chlorel for XNova |
|
29 | - */ |
|
3 | + * index.php - overview.php |
|
4 | + * |
|
5 | + * 2.4 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
6 | + * [-] Removed News frame |
|
7 | + * [-] Time & Usersonline moved to Top-Frame |
|
8 | + * 2.3 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
9 | + * [*] Complying with PCG |
|
10 | + * 2.2 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
11 | + * [+] Redo flying fleet list |
|
12 | + * 2.1 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
13 | + * [+] Planets on planet list now have indication of planet fill |
|
14 | + * [+] Planets on planet list now have indication when there is enemy fleet flying to planet |
|
15 | + * 2.0 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
16 | + * [+] Now there is full planet list on right side of screen a-la oGame |
|
17 | + * [+] Planet list now include icons for buildings/tech/fleet on progress |
|
18 | + * 1.5 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
19 | + * [*] Subplanet timers now use sn_timer.js library |
|
20 | + * 1.4 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
21 | + * [*] All mainplanet timers now use new sn_timer.js library |
|
22 | + * 1.3 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
23 | + * [*] Adjusted layouts of player infos |
|
24 | + * 1.2 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
25 | + * [*] Adjusted layouts of planet infos |
|
26 | + * 1.1 - Security checks by Gorlum for http://supernova.ws |
|
27 | + * @version 1 |
|
28 | + * @copyright 2008 By Chlorel for XNova |
|
29 | + */ |
|
30 | 30 | |
31 | 31 | //define('SN_RENDER_NAVBAR_PLANET', false); |
32 | 32 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | function art_use(&$user, &$planetrow, $unit_id) { |
4 | 4 | global $lang; |
5 | 5 | |
6 | - if(!in_array($unit_id, sn_get_groups('artifacts'))) { |
|
6 | + if (!in_array($unit_id, sn_get_groups('artifacts'))) { |
|
7 | 7 | return; |
8 | 8 | } |
9 | 9 | |
@@ -11,21 +11,21 @@ discard block |
||
11 | 11 | $user = db_user_by_id($user['id'], true); |
12 | 12 | |
13 | 13 | $unit_level = $artifact_level_old = mrc_get_level($user, array(), $unit_id, true); |
14 | - if($unit_level > 0) { |
|
14 | + if ($unit_level > 0) { |
|
15 | 15 | $db_changeset = array(); |
16 | - switch($unit_id) { |
|
16 | + switch ($unit_id) { |
|
17 | 17 | case ART_LHC: |
18 | 18 | case ART_HOOK_SMALL: |
19 | 19 | case ART_HOOK_MEDIUM: |
20 | 20 | case ART_HOOK_LARGE: |
21 | 21 | $has_moon = db_planet_by_parent($planetrow['id'], true, '`id`'); |
22 | - if($planetrow['planet_type'] == PT_PLANET && !$has_moon['id']) { |
|
22 | + if ($planetrow['planet_type'] == PT_PLANET && !$has_moon['id']) { |
|
23 | 23 | $unit_level--; |
24 | 24 | $moon_chance = $unit_id == ART_LHC ? uni_calculate_moon_chance($planetrow['debris_metal'] + $planetrow['debris_crystal']) : ( |
25 | 25 | $unit_id == ART_HOOK_MEDIUM ? mt_rand(1100, 8999) : ($unit_id == ART_HOOK_SMALL ? 1100 : 8999) |
26 | 26 | ); |
27 | 27 | $random = $unit_id == ART_LHC ? mt_rand(1, 100) : $moon_chance; |
28 | - if($random <= $moon_chance) { |
|
28 | + if ($random <= $moon_chance) { |
|
29 | 29 | $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moon_chance); |
30 | 30 | $message = sprintf(classLocale::$lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), pretty_number($moon_chance)); |
31 | 31 | } else { |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | case ART_RCD_MEDIUM: |
42 | 42 | case ART_RCD_LARGE: |
43 | 43 | $planetrow = db_planet_by_id($planetrow['id'], true); |
44 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
44 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
45 | 45 | $message = classLocale::$lang['art_rcd_err_moon']; |
46 | 46 | break; |
47 | 47 | } |
48 | 48 | |
49 | 49 | $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, false); |
50 | - if(!empty($que['items'])) { |
|
50 | + if (!empty($que['items'])) { |
|
51 | 51 | $message = classLocale::$lang['art_rcd_err_que']; |
52 | 52 | break; |
53 | 53 | } |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | |
57 | 57 | // $deployment_str = ''; |
58 | 58 | $sectors_used = 0; |
59 | - foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level) { |
|
60 | - if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) { |
|
59 | + foreach ($artifact_deploy as $deploy_unit_id => $deploy_unit_level) { |
|
60 | + if (!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) { |
|
61 | 61 | continue; |
62 | 62 | } |
63 | 63 | $sectors_used += $levels_deployed; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | //$deployment_str .= ",`{$deploy_unit_name}` = GREATEST(`{$deploy_unit_name}`, {$deploy_unit_level})"; |
67 | 67 | } |
68 | 68 | |
69 | - if($sectors_used == 0) { |
|
69 | + if ($sectors_used == 0) { |
|
70 | 70 | $message = classLocale::$lang['art_rcd_err_no_sense']; |
71 | 71 | break; |
72 | 72 | } |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | $que_item = null; |
81 | 81 | $que = que_get($user['id'], $planetrow['id'], QUE_RESEARCH, true); |
82 | 82 | $current_que = &$que['ques'][QUE_RESEARCH][$user['id']][0]; |
83 | - if(!empty($current_que)) { |
|
83 | + if (!empty($current_que)) { |
|
84 | 84 | reset($current_que); |
85 | 85 | $que_item = &$que['ques'][QUE_RESEARCH][$user['id']][0][key($current_que)]; |
86 | 86 | } |
87 | 87 | |
88 | - if(!empty($que_item) && $que_item['que_time_left'] > 60) { |
|
88 | + if (!empty($que_item) && $que_item['que_time_left'] > 60) { |
|
89 | 89 | $unit_level--; |
90 | 90 | $old_time = $que_item['que_time_left']; |
91 | 91 | $que_item['que_time_left'] = $que_item['que_time_left'] > PERIOD_HOUR ? ceil($que_item['que_time_left'] / 2) : 0; |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, true); |
104 | 104 | $current_que = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']]; |
105 | 105 | // $que_item = &$que['que'][QUE_STRUCTURES][0]; |
106 | - if(!empty($current_que)) { |
|
106 | + if (!empty($current_que)) { |
|
107 | 107 | reset($current_que); |
108 | 108 | $que_item = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']][key($current_que)]; |
109 | 109 | } |
110 | 110 | |
111 | - if(isset($que_item) && $que_item['que_time_left'] > 60) { |
|
111 | + if (isset($que_item) && $que_item['que_time_left'] > 60) { |
|
112 | 112 | $unit_level--; |
113 | 113 | $old_time = $que_item['que_time_left']; |
114 | 114 | $que_item['que_time_left'] = $que_item['que_time_left'] > PERIOD_HOUR ? ceil($que_item['que_time_left'] / 2) : 0; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | break; |
124 | 124 | |
125 | 125 | } |
126 | - if($unit_level != $artifact_level_old) { |
|
126 | + if ($unit_level != $artifact_level_old) { |
|
127 | 127 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, $unit_level - $artifact_level_old, $user); |
128 | 128 | db_changeset_apply($db_changeset); |
129 | 129 | } |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | // @version 1.0 |
6 | 6 | // @copyright 2008 by Chlorel for XNova |
7 | 7 | |
8 | -if($fleet_ship_sort = sys_get_param_id('sort_elements')) { |
|
8 | +if ($fleet_ship_sort = sys_get_param_id('sort_elements')) { |
|
9 | 9 | define('IN_AJAX', true); |
10 | - if(!empty(classLocale::$lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) { |
|
10 | + if (!empty(classLocale::$lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) { |
|
11 | 11 | // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT, $fleet_ship_sort); |
12 | 12 | // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE, sys_get_param_id('fleet_ship_sort_inverse', 0)); |
13 | 13 | classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT] = $fleet_ship_sort; |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | die(); |
17 | 17 | } |
18 | 18 | |
19 | -if(SN_IN_FLEET !== true) { |
|
19 | +if (SN_IN_FLEET !== true) { |
|
20 | 20 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
21 | 21 | } |
22 | 22 | |
23 | 23 | lng_include('overview'); |
24 | 24 | |
25 | -if(!$planetrow) { |
|
25 | +if (!$planetrow) { |
|
26 | 26 | message(classLocale::$lang['fl_noplanetrow'], classLocale::$lang['fl_error']); |
27 | 27 | } |
28 | 28 | |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | $record_index = 0; |
32 | 32 | $ship_list = array(); |
33 | -foreach(sn_get_groups('fleet') as $n => $unit_id) { |
|
33 | +foreach (sn_get_groups('fleet') as $n => $unit_id) { |
|
34 | 34 | $unit_level = mrc_get_level($user, $planetrow, $unit_id, false, true); |
35 | - if($unit_level > 0) { |
|
35 | + if ($unit_level > 0) { |
|
36 | 36 | $ship_data = get_ship_data($unit_id, $user); |
37 | 37 | $ship_list[$unit_id] = array( |
38 | 38 | '__INDEX' => $record_index++, |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | |
53 | 53 | $fleet_ship_sort = classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT]; |
54 | 54 | $fleet_ship_sort_inverse = classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE]; |
55 | -if($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
56 | - switch($fleet_ship_sort) { |
|
55 | +if ($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
56 | + switch ($fleet_ship_sort) { |
|
57 | 57 | case PLAYER_OPTION_SORT_NAME: $fleet_ship_sort_field = 'NAME'; break; |
58 | 58 | case PLAYER_OPTION_SORT_SPEED: $fleet_ship_sort_field = 'SPEED'; break; |
59 | 59 | case PLAYER_OPTION_SORT_COUNT: $fleet_ship_sort_field = 'AMOUNT'; break; |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | }); |
69 | 69 | } |
70 | 70 | |
71 | -foreach($ship_list as $ship_data) { |
|
71 | +foreach ($ship_list as $ship_data) { |
|
72 | 72 | $template->assign_block_vars('ships', $ship_data); |
73 | 73 | } |
74 | 74 | |
75 | -foreach(classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
75 | +foreach (classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
76 | 76 | $template->assign_block_vars('ship_sort_list', array( |
77 | 77 | 'VALUE' => $sort_id, |
78 | 78 | 'TEXT' => $sort_text, |
@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(SN_IN_FLEET !== true) { |
|
3 | +if (SN_IN_FLEET !== true) { |
|
4 | 4 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | 7 | $fleetid = sys_get_param_id('fleetid'); |
8 | 8 | |
9 | -if(!is_numeric($fleetid) || empty($fleetid)) { |
|
9 | +if (!is_numeric($fleetid) || empty($fleetid)) { |
|
10 | 10 | header("Location: fleet.php"); |
11 | 11 | exit(); |
12 | 12 | } |
13 | 13 | |
14 | 14 | $objFleet = new Fleet(); |
15 | 15 | $objFleet->dbLoad($fleetid); |
16 | -if(!$objFleet->dbId) { |
|
16 | +if (!$objFleet->dbId) { |
|
17 | 17 | message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']); |
18 | 18 | } |
19 | 19 | |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']); |
22 | 22 | } |
23 | 23 | |
24 | -if($objFleet->playerOwnerId != $user['id']) { |
|
25 | - $debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'],'Wrong Fleet Owner',301); |
|
24 | +if ($objFleet->playerOwnerId != $user['id']) { |
|
25 | + $debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301); |
|
26 | 26 | message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']); |
27 | 27 | } |
28 | 28 | |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | |
33 | 33 | !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false; |
34 | 34 | |
35 | -if($userToAdd_unsafe) { |
|
35 | +if ($userToAdd_unsafe) { |
|
36 | 36 | $userToAdd = db_escape($userToAdd_unsafe); |
37 | 37 | $userToAddID = db_user_by_username($userToAdd_unsafe, false, 'id', true, true); |
38 | 38 | $userToAddID = $userToAddID['id']; |
39 | 39 | |
40 | - if($objFleet->target_owner_id == $userToAddID) { |
|
40 | + if ($objFleet->target_owner_id == $userToAddID) { |
|
41 | 41 | message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']); |
42 | 42 | } |
43 | 43 | |
44 | - if($userToAddID) { |
|
45 | - if(!$aks) { |
|
44 | + if ($userToAddID) { |
|
45 | + if (!$aks) { |
|
46 | 46 | // No AСS exists - making one |
47 | - if(!$objFleet->group_id) { |
|
47 | + if (!$objFleet->group_id) { |
|
48 | 48 | db_acs_insert(classLocale::$lang, $fleetid, $user, $objFleet); |
49 | 49 | |
50 | 50 | $aks = db_acs_get_by_fleet($fleetid); |
@@ -59,26 +59,26 @@ discard block |
||
59 | 59 | |
60 | 60 | $isUserExists = false; |
61 | 61 | $invited_ar = explode(",", $aks['eingeladen']); |
62 | - foreach($invited_ar as $inv) { |
|
62 | + foreach ($invited_ar as $inv) { |
|
63 | 63 | if ($userToAddID == $inv) { |
64 | 64 | $isUserExists = true; |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - if(count($invited_ar) >= 5) { |
|
68 | + if (count($invited_ar) >= 5) { |
|
69 | 69 | message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']); |
70 | 70 | } |
71 | 71 | |
72 | - if($isUserExists) { |
|
72 | + if ($isUserExists) { |
|
73 | 73 | $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false; |
74 | 74 | } else { |
75 | 75 | $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd); |
76 | 76 | db_acs_update($userToAddID, $fleetid) |
77 | - or die(sprintf(classLocale::$lang['fl_aks_adding_error'],db_error())); |
|
77 | + or die(sprintf(classLocale::$lang['fl_aks_adding_error'], db_error())); |
|
78 | 78 | $aks['eingeladen'] .= ',' . $userToAddID; |
79 | 79 | } |
80 | - msg_send_simple_message ( $userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'], |
|
81 | - classLocale::$lang['fl_aks_invite_message_header'], sprintf( classLocale::$lang['fl_aks_invite_message'], $user['username'])); |
|
80 | + msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'], |
|
81 | + classLocale::$lang['fl_aks_invite_message_header'], sprintf(classLocale::$lang['fl_aks_invite_message'], $user['username'])); |
|
82 | 82 | } else { |
83 | 83 | $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_error'], $userToAdd); |
84 | 84 | } |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | 'MISSION_NAME' => classLocale::$lang['type_mission'][MT_AKS], |
93 | 93 | )); |
94 | 94 | |
95 | -if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
96 | - foreach($members as $row) { |
|
95 | +if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
96 | + foreach ($members as $row) { |
|
97 | 97 | $template->assign_block_vars('invited', array( |
98 | 98 | 'NAME' => $row['username'], |
99 | 99 | )); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $fleet_data = tplParseFleetObject($objFleet, $i, $user); |
119 | 119 | |
120 | 120 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
121 | -foreach($fleet_data['ships'] as $ship_data) { |
|
121 | +foreach ($fleet_data['ships'] as $ship_data) { |
|
122 | 122 | $template->assign_block_vars('fleets.ships', $ship_data); |
123 | 123 | } |
124 | 124 |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | function sn_eco_build($que_type, &$auser, &$planet) { |
19 | 19 | global $lang, $config, $template_result; |
20 | 20 | |
21 | - if($ally_id = sys_get_param_id('ally_id')) { |
|
21 | + if ($ally_id = sys_get_param_id('ally_id')) { |
|
22 | 22 | define('SN_IN_ALLY', true); |
23 | 23 | $ranks = ally_get_ranks($auser['ally']); |
24 | - if($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
24 | + if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
25 | 25 | $user = &$auser['ally']['player']; |
26 | 26 | $planet = array( |
27 | 27 | 'metal' => $user['metal'], |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | - if(!$user) { |
|
34 | + if (!$user) { |
|
35 | 35 | $user = &$auser; |
36 | 36 | } |
37 | 37 | |
38 | - switch($action = sys_get_param_escaped('action')) { |
|
38 | + switch ($action = sys_get_param_escaped('action')) { |
|
39 | 39 | case 'create': // Add unit to que for build |
40 | 40 | case 'create_autoconvert': // Add unit to que for build |
41 | 41 | case 'destroy': // Add unit to que for remove |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | |
53 | 53 | $group_missile = sn_get_groups('missile'); |
54 | 54 | $silo_capacity_free = 0; |
55 | - if($que_type == QUE_STRUCTURES) { |
|
55 | + if ($que_type == QUE_STRUCTURES) { |
|
56 | 56 | $build_unit_list = sn_get_groups('build_allow'); |
57 | 57 | $build_unit_list = $build_unit_list[$planet['planet_type']]; |
58 | 58 | $artifact_id = ART_NANO_BUILDER; |
59 | 59 | $page_header = classLocale::$lang['tech'][UNIT_STRUCTURES]; |
60 | - } elseif($que_type == QUE_RESEARCH) { |
|
61 | - if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
60 | + } elseif ($que_type == QUE_RESEARCH) { |
|
61 | + if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
62 | 62 | message(classLocale::$lang['no_laboratory'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]); |
63 | 63 | } |
64 | 64 | |
65 | - if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
65 | + if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
66 | 66 | message(classLocale::$lang['eco_bld_msg_err_laboratory_upgrading'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]); |
67 | 67 | } |
68 | 68 | $build_unit_list = sn_get_groups('tech'); |
69 | 69 | $artifact_id = ART_HEURISTIC_CHIP; |
70 | 70 | $page_header = classLocale::$lang['tech'][UNIT_TECHNOLOGIES] . ($user['user_as_ally'] ? " {$lang['sys_of_ally']} {$user['username']}" : ''); |
71 | - } elseif($que_type == QUE_MERCENARY) { |
|
71 | + } elseif ($que_type == QUE_MERCENARY) { |
|
72 | 72 | // if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
73 | 73 | // message($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]); |
74 | 74 | // } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $artifact_id = 0; |
81 | 81 | $page_header = classLocale::$lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? " {$lang['sys_of_ally']} {$user['username']}" : ''); |
82 | 82 | } else { |
83 | - if(mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
83 | + if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
84 | 84 | message(classLocale::$lang['need_hangar'], classLocale::$lang['tech'][STRUC_FACTORY_HANGAR]); |
85 | 85 | } |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $artifact_id = 0; |
90 | 90 | |
91 | 91 | $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY); |
92 | - foreach($group_missile as $unit_id) { |
|
92 | + foreach ($group_missile as $unit_id) { |
|
93 | 93 | $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE); |
94 | 94 | } |
95 | 95 | $silo_capacity_free = max(0, $silo_capacity_free); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | |
108 | 108 | $template = gettemplate('buildings_builds', true); |
109 | - if(!empty($operation_result)) { |
|
109 | + if (!empty($operation_result)) { |
|
110 | 110 | $template_result['.']['result'][] = $operation_result; |
111 | 111 | } |
112 | 112 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | $record_index = 0; |
139 | 139 | |
140 | - foreach($build_unit_list as $unit_id) { |
|
140 | + foreach ($build_unit_list as $unit_id) { |
|
141 | 141 | $level_base = mrc_get_level($user, $planet, $unit_id, false, true); |
142 | 142 | $level_effective = mrc_get_level($user, $planet, $unit_id); |
143 | 143 | $level_in_que = $in_que[$unit_id]; |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE]; |
161 | 161 | // Restricting $can_build by free silo capacity |
162 | 162 | $can_build = ($unit_is_missile = in_array($unit_id, $group_missile)) ? min($can_build, floor($silo_capacity_free / $unit_info[P_UNIT_SIZE])) : $can_build; |
163 | - if(!$can_build) { |
|
164 | - if(!$build_data['CAN'][BUILD_CREATE]) { |
|
163 | + if (!$can_build) { |
|
164 | + if (!$build_data['CAN'][BUILD_CREATE]) { |
|
165 | 165 | $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES; |
166 | - } elseif($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
166 | + } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
167 | 167 | $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL; |
168 | - } elseif($unit_info[P_MAX_STACK]) { |
|
168 | + } elseif ($unit_info[P_MAX_STACK]) { |
|
169 | 169 | $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED; |
170 | 170 | } |
171 | 171 | } |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | 'MAP_IS_RESOURCE' => !empty($unit_info[P_UNIT_PRODUCTION]), |
233 | 233 | ); |
234 | 234 | |
235 | - if($unit_stackable) { |
|
235 | + if ($unit_stackable) { |
|
236 | 236 | $level_production_base = array( |
237 | 237 | 'ACTUAL_SHIELD' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])), |
238 | 238 | 'ACTUAL_ARMOR' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])), |
239 | 239 | 'ACTUAL_WEAPON' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])), |
240 | 240 | ); |
241 | 241 | |
242 | - if($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
242 | + if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
243 | 243 | $ship_data = get_ship_data($unit_id, $user); |
244 | 244 | |
245 | 245 | $level_production_base += array( |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | ); |
250 | 250 | } |
251 | 251 | |
252 | - if($unit_info[P_UNIT_PRODUCTION]) { |
|
253 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
254 | - if($resource_income = |
|
252 | + if ($unit_info[P_UNIT_PRODUCTION]) { |
|
253 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
254 | + if ($resource_income = |
|
255 | 255 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet) |
256 | 256 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
257 | 257 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | } |
262 | 262 | } |
263 | 263 | $production['.']['resource'][] = $level_production_base; |
264 | - } elseif($unit_info[P_UNIT_PRODUCTION]) { |
|
264 | + } elseif ($unit_info[P_UNIT_PRODUCTION]) { |
|
265 | 265 | $level_production_base = array(); |
266 | 266 | $element_level_start = $level_effective + $in_que[$unit_id]; |
267 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | - if($resource_income = |
|
267 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | + if ($resource_income = |
|
269 | 269 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet) |
270 | 270 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
271 | 271 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | } |
276 | 276 | |
277 | 277 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
278 | - for($i = 0; $i < 6; $i++) { |
|
278 | + for ($i = 0; $i < 6; $i++) { |
|
279 | 279 | $level_production = array('LEVEL' => $level_start + $i); |
280 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
281 | - if( |
|
280 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
281 | + if ( |
|
282 | 282 | $resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet) |
283 | 283 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
284 | 284 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | } |
290 | 290 | $production['.']['resource'][] = $level_production; |
291 | 291 | } |
292 | - } elseif($unit_id == TECH_ASTROTECH) { |
|
292 | + } elseif ($unit_id == TECH_ASTROTECH) { |
|
293 | 293 | $element_level_start = $level_effective + $in_que[$unit_id]; |
294 | 294 | $level_production_base = array( |
295 | 295 | UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start), |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | ); |
298 | 298 | |
299 | 299 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
300 | - for($i = 0; $i < 6; $i++) { |
|
300 | + for ($i = 0; $i < 6; $i++) { |
|
301 | 301 | $level_production = array('LEVEL' => $level_start + $i); |
302 | 302 | $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i); |
303 | 303 | $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX]; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | $template_result['.']['production'][] = $production; |
319 | 319 | } |
320 | 320 | |
321 | - foreach(classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
321 | + foreach (classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
322 | 322 | $template->assign_block_vars('sort_values', array( |
323 | 323 | 'VALUE' => $sort_id, |
324 | 324 | 'TEXT' => $sort_text, |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | |
328 | 328 | $sort_option = classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT, $que_type)]; |
329 | 329 | $sort_option_inverse = classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT_INVERSE, $que_type)]; |
330 | - if($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
331 | - switch($sort_option) { |
|
330 | + if ($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
331 | + switch ($sort_option) { |
|
332 | 332 | case PLAYER_OPTION_SORT_NAME: |
333 | 333 | $sort_option_field = 'NAME'; |
334 | 334 | break; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | break; |
344 | 344 | } |
345 | 345 | $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1; |
346 | - usort($template_result['.']['production'], function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
346 | + usort($template_result['.']['production'], function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
347 | 347 | return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : ( |
348 | 348 | $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0 |
349 | 349 | ); |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | |
8 | 8 | $possible_cores = array(); |
9 | 9 | $probability = 0; |
10 | - foreach($density_list as $possible_core_id => $core_data) { |
|
11 | - if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
10 | + foreach ($density_list as $possible_core_id => $core_data) { |
|
11 | + if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
12 | 12 | continue; |
13 | 13 | } |
14 | 14 | |
15 | - if( |
|
15 | + if ( |
|
16 | 16 | // Core type exists |
17 | 17 | in_array($possible_core_id, $position_data['core_types']) |
18 | 18 | // Limit core type with planet sector count |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | $random = mt_rand(1, $probability); |
35 | 35 | $selected_core = null; |
36 | - foreach($possible_cores as $core_type => $core_info) { |
|
37 | - if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
36 | + foreach ($possible_cores as $core_type => $core_info) { |
|
37 | + if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
38 | 38 | $selected_core = $core_info; |
39 | 39 | break; |
40 | 40 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | $Position = intval($Position); |
61 | 61 | |
62 | - if(!isset($options['skip_check']) && db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
62 | + if (!isset($options['skip_check']) && db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | |
69 | 69 | $planet_generator = sn_get_groups('planet_generator'); |
70 | 70 | |
71 | - if($HomeWorld) { |
|
71 | + if ($HomeWorld) { |
|
72 | 72 | $position_data = $planet_generator[0]; |
73 | 73 | } else { |
74 | 74 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
75 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
75 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
76 | 76 | // Корректируем температуру для планеты-странника |
77 | 77 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
78 | 78 | } |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | $moon_name = ''; |
173 | 173 | $moon_row = array(); |
174 | 174 | $moon = db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
175 | - if(!$moon['id']) { |
|
175 | + if (!$moon['id']) { |
|
176 | 176 | $moon_planet = db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`'); |
177 | 177 | |
178 | - if($moon_planet['id']) { |
|
178 | + if ($moon_planet['id']) { |
|
179 | 179 | $base_storage_size = BASE_STORAGE_SIZE; |
180 | 180 | |
181 | - if(!$moon_chance) { |
|
181 | + if (!$moon_chance) { |
|
182 | 182 | $size = mt_rand(1100, 8999); |
183 | - } elseif($moon_chance <= 100) { |
|
183 | + } elseif ($moon_chance <= 100) { |
|
184 | 184 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
185 | 185 | } else { |
186 | 186 | $size = $moon_chance; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $field_max = ceil($size / 1000); |
198 | 198 | |
199 | - if(isset($options['image']) && $options['image']) { |
|
199 | + if (isset($options['image']) && $options['image']) { |
|
200 | 200 | $moon_image = $options['image']; |
201 | 201 | } else { |
202 | 202 | $moon_image = 'mond'; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'" |
212 | 212 | ); |
213 | 213 | |
214 | - if($update_debris) { |
|
214 | + if ($update_debris) { |
|
215 | 215 | $debris_spent = $moon_chance * 1000000; |
216 | 216 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
217 | 217 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -246,21 +246,21 @@ discard block |
||
246 | 246 | $planet_row['id'] = $user['current_planet']; |
247 | 247 | |
248 | 248 | // Пытаемся переключить на новую планету |
249 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
249 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
250 | 250 | $planet_row = db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
251 | 251 | } else { |
252 | 252 | $planet_row = db_planet_by_id($planet_row['id']); |
253 | 253 | } |
254 | 254 | |
255 | 255 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
256 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
256 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
257 | 257 | { |
258 | 258 | $planet_row = db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
259 | 259 | // Если текущей планеты не существует - выставляем Столицу |
260 | - if(!isset($planet_row['id'])) { |
|
260 | + if (!isset($planet_row['id'])) { |
|
261 | 261 | $planet_row = db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
262 | 262 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
263 | - if(!isset($planet_row['id'])) { |
|
263 | + if (!isset($planet_row['id'])) { |
|
264 | 264 | global $debug; |
265 | 265 | $debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
266 | 266 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | // Если производилось переключение планеты - делаем запись в юзере |
271 | - if($user['current_planet'] != $planet_row['id']) { |
|
271 | + if ($user['current_planet'] != $planet_row['id']) { |
|
272 | 272 | db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'"); |
273 | 273 | $user['current_planet'] = $planet_row['id']; |
274 | 274 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) { |
289 | 289 | global $lang; |
290 | 290 | |
291 | - if(!$from['id']) { |
|
291 | + if (!$from['id']) { |
|
292 | 292 | $result = classLocale::$lang['sys_planet_expedition']; |
293 | 293 | } else { |
294 | 294 | $from_planet_id = $include_id ? ( |
@@ -343,23 +343,23 @@ discard block |
||
343 | 343 | global $lang, $config; |
344 | 344 | |
345 | 345 | try { |
346 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
346 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
347 | 347 | throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR); |
348 | 348 | } |
349 | 349 | |
350 | - if(mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
350 | + if (mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
351 | 351 | throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
352 | 352 | } |
353 | 353 | |
354 | 354 | // TODO: Replace quick-check with using gathered flying fleet data |
355 | - if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
355 | + if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
356 | 356 | throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR); |
357 | 357 | } |
358 | 358 | |
359 | - if(is_array($new_coordinates)) { |
|
359 | + if (is_array($new_coordinates)) { |
|
360 | 360 | $new_coordinates['planet_type'] = PT_PLANET; |
361 | 361 | $incoming = db_planet_by_vector($new_coordinates, '', true, 'id'); |
362 | - if($incoming['id']) { |
|
362 | + if ($incoming['id']) { |
|
363 | 363 | throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
364 | 364 | } |
365 | 365 | } |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | 'result' => ERR_NONE, |
369 | 369 | 'message' => '', |
370 | 370 | ); |
371 | - } catch(exception $e) { |
|
371 | + } catch (exception $e) { |
|
372 | 372 | $response = array( |
373 | 373 | 'result' => $e->getCode(), |
374 | 374 | 'message' => $e->getMessage(), |
@@ -253,9 +253,11 @@ |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
256 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
256 | + if(!isset($planet_row['id'])) { |
|
257 | + // || $planet_row['id'] != $user['current_planet'] |
|
257 | 258 | { |
258 | 259 | $planet_row = db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
260 | + } |
|
259 | 261 | // Если текущей планеты не существует - выставляем Столицу |
260 | 262 | if(!isset($planet_row['id'])) { |
261 | 263 | $planet_row = db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | $language_new = sys_get_param_str('langer', $user['lang']); |
14 | 14 | |
15 | - if($language_new != $user['lang']) { |
|
15 | + if ($language_new != $user['lang']) { |
|
16 | 16 | classLocale::$lang->lng_switch($language_new); |
17 | 17 | } |
18 | 18 | |
@@ -21,35 +21,35 @@ discard block |
||
21 | 21 | |
22 | 22 | $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE); |
23 | 23 | |
24 | - if(sys_get_param_str('mode') == 'change') { |
|
25 | - if($user['authlevel'] > 0) { |
|
24 | + if (sys_get_param_str('mode') == 'change') { |
|
25 | + if ($user['authlevel'] > 0) { |
|
26 | 26 | $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0; |
27 | 27 | db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'"); |
28 | 28 | db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'"); |
29 | 29 | $user['admin_protection'] = $planet_protection; |
30 | 30 | } |
31 | 31 | |
32 | - if(sys_get_param_int('vacation') && !$config->user_vacation_disable) { |
|
32 | + if (sys_get_param_int('vacation') && !$config->user_vacation_disable) { |
|
33 | 33 | sn_db_transaction_start(); |
34 | - if($user['authlevel'] < 3) { |
|
35 | - if($user['vacation_next'] > SN_TIME_NOW) { |
|
34 | + if ($user['authlevel'] < 3) { |
|
35 | + if ($user['vacation_next'] > SN_TIME_NOW) { |
|
36 | 36 | message(classLocale::$lang['opt_vacation_err_timeout'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
37 | 37 | die(); |
38 | 38 | } |
39 | 39 | |
40 | - if(FleetList::fleet_count_flying($user['id'])) { |
|
40 | + if (FleetList::fleet_count_flying($user['id'])) { |
|
41 | 41 | message(classLocale::$lang['opt_vacation_err_your_fleet'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
42 | 42 | die(); |
43 | 43 | } |
44 | 44 | |
45 | 45 | $que = que_get($user['id'], false); |
46 | - if(!empty($que)) { |
|
46 | + if (!empty($que)) { |
|
47 | 47 | message(classLocale::$lang['opt_vacation_err_que'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
48 | 48 | die(); |
49 | 49 | } |
50 | 50 | |
51 | 51 | $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}"); |
52 | - foreach($query as $planet) { |
|
52 | + foreach ($query as $planet) { |
|
53 | 53 | // $planet = sys_o_get_updated($user, $planet, SN_TIME_NOW); |
54 | 54 | // $planet = $planet['planet']; |
55 | 55 | |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | sn_db_transaction_commit(); |
68 | 68 | } |
69 | 69 | |
70 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
71 | - foreach($option_group as $option_name => $option_value) { |
|
72 | - if($user[$option_name] !== null) { |
|
70 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
71 | + foreach ($option_group as $option_name => $option_value) { |
|
72 | + if ($user[$option_name] !== null) { |
|
73 | 73 | $user[$option_name] = sys_get_param_str($option_name); |
74 | 74 | } else { |
75 | 75 | $user[$option_name] = $option_value; |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | |
81 | 81 | |
82 | 82 | $player_options = sys_get_param('options'); |
83 | - if(!empty($player_options)) { |
|
84 | - array_walk($player_options, function (&$value) { |
|
83 | + if (!empty($player_options)) { |
|
84 | + array_walk($player_options, function(&$value) { |
|
85 | 85 | // TODO - Когда будет больше параметров - сделать больше проверок |
86 | 86 | $value = intval($value); |
87 | 87 | }); |
@@ -92,15 +92,15 @@ discard block |
||
92 | 92 | |
93 | 93 | $username = substr(sys_get_param_str_unsafe('username'), 0, 32); |
94 | 94 | $username_safe = db_escape($username); |
95 | - if($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
95 | + if ($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
96 | 96 | // проверка на корректность |
97 | 97 | sn_db_transaction_start(); |
98 | 98 | $name_check = db_player_name_history_get_name_by_name($username_safe); |
99 | - if(!$name_check || $name_check['player_id'] == $user['id']) { |
|
99 | + if (!$name_check || $name_check['player_id'] == $user['id']) { |
|
100 | 100 | $user = db_user_by_id($user['id'], true); |
101 | - switch($config->game_user_changename) { |
|
101 | + switch ($config->game_user_changename) { |
|
102 | 102 | case SERVER_PLAYER_NAME_CHANGE_PAY: |
103 | - if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < $config->game_user_changename_cost) { |
|
103 | + if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < $config->game_user_changename_cost) { |
|
104 | 104 | $template_result['.']['result'][] = array( |
105 | 105 | 'STATUS' => ERR_ERROR, |
106 | 106 | 'MESSAGE' => classLocale::$lang['opt_msg_name_change_err_no_dm'], |
@@ -130,18 +130,18 @@ discard block |
||
130 | 130 | sn_db_transaction_commit(); |
131 | 131 | } |
132 | 132 | |
133 | - if($new_password = sys_get_param('newpass1')) { |
|
133 | + if ($new_password = sys_get_param('newpass1')) { |
|
134 | 134 | try { |
135 | - if($new_password != sys_get_param('newpass2')) { |
|
135 | + if ($new_password != sys_get_param('newpass2')) { |
|
136 | 136 | throw new Exception(classLocale::$lang['opt_err_pass_unmatched'], ERR_WARNING); |
137 | 137 | } |
138 | 138 | |
139 | - if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
139 | + if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
140 | 140 | throw new Exception(classLocale::$lang['opt_err_pass_wrong'], ERR_WARNING); |
141 | 141 | } |
142 | 142 | |
143 | 143 | throw new Exception(classLocale::$lang['opt_msg_pass_changed'], ERR_NONE); |
144 | - } catch(Exception $e) { |
|
144 | + } catch (Exception $e) { |
|
145 | 145 | $template_result['.']['result'][] = array( |
146 | 146 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
147 | 147 | 'MESSAGE' => $e->getMessage() |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender']; |
183 | 183 | |
184 | 184 | try { |
185 | - if($user['birthday']) { |
|
185 | + if ($user['birthday']) { |
|
186 | 186 | throw new exception(); |
187 | 187 | } |
188 | 188 | |
189 | 189 | $user_birthday = sys_get_param_str_unsafe('user_birthday'); |
190 | - if(!$user_birthday || $user_birthday == $FMT_DATE) { |
|
190 | + if (!$user_birthday || $user_birthday == $FMT_DATE) { |
|
191 | 191 | throw new exception(); |
192 | 192 | } |
193 | 193 | |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | $pos['Y'] = strpos(FMT_DATE, 'Y'); |
198 | 198 | asort($pos); |
199 | 199 | $i = 0; |
200 | - foreach($pos as &$position) { |
|
200 | + foreach ($pos as &$position) { |
|
201 | 201 | $position = ++$i; |
202 | 202 | } |
203 | 203 | |
204 | 204 | $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/"; |
205 | - if(!preg_match($regexp, $user_birthday, $match)) { |
|
205 | + if (!preg_match($regexp, $user_birthday, $match)) { |
|
206 | 206 | throw new exception(); |
207 | 207 | } |
208 | 208 | |
209 | - if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
209 | + if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
210 | 210 | throw new exception(); |
211 | 211 | } |
212 | 212 | |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format |
215 | 215 | |
216 | 216 | $year = date('Y', SN_TIME_NOW); |
217 | - if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
217 | + if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
218 | 218 | $year--; |
219 | 219 | } |
220 | 220 | $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}"); |
221 | 221 | |
222 | 222 | $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'"; |
223 | - } catch(exception $e) { |
|
223 | + } catch (exception $e) { |
|
224 | 224 | $user_birthday = ''; |
225 | 225 | } |
226 | 226 | |
@@ -230,14 +230,14 @@ discard block |
||
230 | 230 | $template_result['.']['result'][] = $avatar_upload_result; |
231 | 231 | |
232 | 232 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
233 | - if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
233 | + if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
234 | 234 | playerTimeDiff::user_time_diff_set(array( |
235 | 235 | PLAYER_OPTION_TIME_DIFF => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'), |
236 | 236 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
237 | 237 | PLAYER_OPTION_TIME_DIFF_FORCED => 1, |
238 | 238 | PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL, |
239 | 239 | )); |
240 | - } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
240 | + } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
241 | 241 | playerTimeDiff::user_time_diff_set(array( |
242 | 242 | PLAYER_OPTION_TIME_DIFF => '', |
243 | 243 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | 'STATUS' => ERR_NONE, |
258 | 258 | 'MESSAGE' => classLocale::$lang['opt_msg_saved'] |
259 | 259 | ); |
260 | - } elseif(sys_get_param_str('result') == 'ok') { |
|
260 | + } elseif (sys_get_param_str('result') == 'ok') { |
|
261 | 261 | $template_result['.']['result'][] = array( |
262 | 262 | 'STATUS' => ERR_NONE, |
263 | 263 | 'MESSAGE' => classLocale::$lang['opt_msg_saved'] |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | // ); |
286 | 286 | |
287 | 287 | $dir = dir(SN_ROOT_PHYSICAL . 'skins'); |
288 | - while(($entry = $dir->read()) !== false) { |
|
289 | - if(is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
288 | + while (($entry = $dir->read()) !== false) { |
|
289 | + if (is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
290 | 290 | $template_result['.']['skin_list'][] = array( |
291 | 291 | 'VALUE' => $entry, |
292 | 292 | 'NAME' => $entry, |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | } |
297 | 297 | $dir->close(); |
298 | 298 | |
299 | - foreach(classLocale::$lang['opt_planet_sort_options'] as $key => &$value) { |
|
299 | + foreach (classLocale::$lang['opt_planet_sort_options'] as $key => &$value) { |
|
300 | 300 | $template_result['.']['planet_sort_options'][] = array( |
301 | 301 | 'VALUE' => $key, |
302 | 302 | 'NAME' => $value, |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | ); |
313 | 313 | } |
314 | 314 | */ |
315 | - foreach(classLocale::$lang['sys_gender_list'] as $key => $value) { |
|
315 | + foreach (classLocale::$lang['sys_gender_list'] as $key => $value) { |
|
316 | 316 | $template_result['.']['gender_list'][] = array( |
317 | 317 | 'VALUE' => $key, |
318 | 318 | 'NAME' => $value, |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | $lang_list = lng_get_list(); |
324 | - foreach($lang_list as $lang_id => $lang_data) { |
|
324 | + foreach ($lang_list as $lang_id => $lang_data) { |
|
325 | 325 | $template_result['.']['languages'][] = array( |
326 | 326 | 'VALUE' => $lang_id, |
327 | 327 | 'NAME' => $lang_data['LANG_NAME_NATIVE'], |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | } |
331 | 331 | |
332 | 332 | |
333 | - if(isset(classLocale::$lang['menu_customize_show_hide_button_state'])) { |
|
334 | - foreach(classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
333 | + if (isset(classLocale::$lang['menu_customize_show_hide_button_state'])) { |
|
334 | + foreach (classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
335 | 335 | $template->assign_block_vars('menu_customize_show_hide_button_state', array( |
336 | 336 | 'ID' => $key, |
337 | 337 | 'NAME' => $value, |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | 'PAGE_HEADER' => classLocale::$lang['opt_header'], |
442 | 442 | )); |
443 | 443 | |
444 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
445 | - if($option_group_id == OPT_MESSAGE) { |
|
446 | - foreach($sn_message_class_list as $message_class_id => $message_class_data) { |
|
447 | - if($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) { |
|
444 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
445 | + if ($option_group_id == OPT_MESSAGE) { |
|
446 | + foreach ($sn_message_class_list as $message_class_id => $message_class_data) { |
|
447 | + if ($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) { |
|
448 | 448 | $option_name = $message_class_data['name']; |
449 | 449 | |
450 | 450 | $template->assign_block_vars("options_{$option_group_id}", array( |
@@ -456,8 +456,8 @@ discard block |
||
456 | 456 | } |
457 | 457 | } |
458 | 458 | } else { |
459 | - foreach($option_group as $option_name => $option_value) { |
|
460 | - if(array_key_exists($option_name, $user_option_types)) { |
|
459 | + foreach ($option_group as $option_name => $option_value) { |
|
460 | + if (array_key_exists($option_name, $user_option_types)) { |
|
461 | 461 | $option_type = $user_option_types[$option_name]; |
462 | 462 | } else { |
463 | 463 | $option_type = 'switch'; |