@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -define('INSIDE' , true); |
|
3 | -define('INSTALL' , false); |
|
2 | +define('INSIDE', true); |
|
3 | +define('INSTALL', false); |
|
4 | 4 | define('IN_ADMIN', true); |
5 | 5 | |
6 | 6 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
7 | 7 | |
8 | -if($user['authlevel'] < 3) |
|
8 | +if ($user['authlevel'] < 3) |
|
9 | 9 | { |
10 | 10 | AdminMessage($lang['adm_err_denied']); |
11 | 11 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $username_unsafe = sys_get_param_str_unsafe('username'); |
26 | 26 | $username = sys_get_param_escaped('username'); |
27 | 27 | |
28 | -if($galaxy_src) |
|
28 | +if ($galaxy_src) |
|
29 | 29 | { |
30 | 30 | sn_db_transaction_start(); |
31 | 31 | $errors = array(); |
@@ -35,41 +35,41 @@ discard block |
||
35 | 35 | $planet = sys_o_get_updated($owner, array('galaxy' => $galaxy_src, 'system' => $system_src, 'planet' => $planet_src, 'planet_type' => 1), SN_TIME_NOW); |
36 | 36 | $que = $planet['que']; |
37 | 37 | $planet = $planet['planet']; |
38 | - if(!$planet) |
|
38 | + if (!$planet) |
|
39 | 39 | { |
40 | 40 | $errors[] = $lang['adm_pl_comp_err_0']; |
41 | 41 | } |
42 | 42 | |
43 | - if($planet['destruyed']) |
|
43 | + if ($planet['destruyed']) |
|
44 | 44 | { |
45 | 45 | $errors[] = $lang['adm_pl_comp_err_1']; |
46 | 46 | } |
47 | 47 | |
48 | - if($planet['id_owner'] != $owner['id'] || !$username) |
|
48 | + if ($planet['id_owner'] != $owner['id'] || !$username) |
|
49 | 49 | { |
50 | 50 | $errors[] = $lang['adm_pl_comp_err_4']; |
51 | 51 | } |
52 | 52 | |
53 | 53 | $destination = sys_o_get_updated($owner, array('galaxy' => $galaxy_dst, 'system' => $system_dst, 'planet' => $planet_dst, 'planet_type' => 1), SN_TIME_NOW); |
54 | 54 | $destination = $destination['planet']; |
55 | - if(!$destination) |
|
55 | + if (!$destination) |
|
56 | 56 | { |
57 | 57 | $errors[] = $lang['adm_pl_comp_err_2']; |
58 | 58 | } |
59 | 59 | |
60 | - if($planet['id'] == $destination['id']) |
|
60 | + if ($planet['id'] == $destination['id']) |
|
61 | 61 | { |
62 | 62 | $errors[] = $lang['adm_pl_comp_err_5']; |
63 | 63 | } |
64 | 64 | |
65 | - if($planet['id_owner'] != $destination['id_owner']) |
|
65 | + if ($planet['id_owner'] != $destination['id_owner']) |
|
66 | 66 | { |
67 | 67 | $errors[] = $lang['adm_pl_comp_err_3']; |
68 | 68 | } |
69 | 69 | |
70 | - if(!empty($errors)) |
|
70 | + if (!empty($errors)) |
|
71 | 71 | { |
72 | - foreach($errors as $error) |
|
72 | + foreach ($errors as $error) |
|
73 | 73 | { |
74 | 74 | $template->assign_block_vars('error', array( |
75 | 75 | 'TEXT' => $error, |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | killer_add_planet($planet); |
84 | 84 | |
85 | 85 | $moon = DBStaticPlanet::db_planet_by_gspt($galaxy_src, $system_src, $planet_src, PT_MOON, true); |
86 | - if($moon) |
|
86 | + if ($moon) |
|
87 | 87 | { |
88 | 88 | $moon = sys_o_get_updated($owner, $moon, SN_TIME_NOW); |
89 | 89 | $moon = $moon['planet']; |
90 | 90 | killer_add_planet($moon); |
91 | 91 | } |
92 | 92 | |
93 | - foreach(sn_get_groups('resources_loot') as $resource_id) |
|
93 | + foreach (sn_get_groups('resources_loot') as $resource_id) |
|
94 | 94 | { |
95 | 95 | $resource_name = pname_resource_name($resource_id); |
96 | 96 | $template->assign_var("{$resource_name}_cost", $final_cost[$resource_id]); |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | $template->assign_var("{$resource_name}_bonus", $final_cost[$resource_id]); |
99 | 99 | } |
100 | 100 | |
101 | - if($_GET['btn_confirm']) |
|
101 | + if ($_GET['btn_confirm']) |
|
102 | 102 | { |
103 | 103 | $time = SN_TIME_NOW + PERIOD_DAY; |
104 | 104 | |
105 | 105 | DBStaticUnit::db_unit_list_delete($planet['id_owner'], LOC_PLANET, $planet['id']); |
106 | 106 | DBStaticPlanet::db_planet_set_by_id($planet['id'], "id_owner = 0, destruyed = {$time}"); |
107 | - if($moon) |
|
107 | + if ($moon) |
|
108 | 108 | { |
109 | 109 | DBStaticUnit::db_unit_list_delete($planet['id_owner'], LOC_PLANET, $moon['id']); |
110 | 110 | DBStaticPlanet::db_planet_set_by_id($moon['id'], "id_owner = 0, destruyed = {$time}"); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | 'username' => $username, |
132 | 132 | )); |
133 | 133 | |
134 | -display(parsetemplate($template, $parse), $lang['adm_pl_comp_title'], false, '', true ); |
|
134 | +display(parsetemplate($template, $parse), $lang['adm_pl_comp_title'], false, '', true); |
|
135 | 135 | |
136 | 136 | function killer_add_planet($planet) |
137 | 137 | { |
@@ -146,34 +146,34 @@ discard block |
||
146 | 146 | } |
147 | 147 | */ |
148 | 148 | |
149 | - foreach(sn_get_groups('structures') as $unit_id) |
|
149 | + foreach (sn_get_groups('structures') as $unit_id) |
|
150 | 150 | { |
151 | 151 | $build_level = mrc_get_level($user, $planet, $unit_id, true, true); |
152 | - if($build_level > 0) |
|
152 | + if ($build_level > 0) |
|
153 | 153 | { |
154 | 154 | $unit_cost = get_unit_param($unit_id, 'cost'); |
155 | 155 | $build_factor = $unit_cost['factor'] != 1 ? (1 - pow($unit_cost['factor'], $build_level)) / (1 - $unit_cost['factor']) : $unit_cost['factor']; |
156 | - foreach($sn_group_resources_loot as $resource_id) |
|
156 | + foreach ($sn_group_resources_loot as $resource_id) |
|
157 | 157 | { |
158 | 158 | $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $build_factor) : 0; |
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - foreach(sn_get_groups(array('defense', 'fleet')) as $unit_id) |
|
163 | + foreach (sn_get_groups(array('defense', 'fleet')) as $unit_id) |
|
164 | 164 | { |
165 | 165 | $unit_count = mrc_get_level($user, $planet, $unit_id, true, true); |
166 | - if($unit_count > 0) |
|
166 | + if ($unit_count > 0) |
|
167 | 167 | { |
168 | 168 | $unit_cost = get_unit_param($unit_id, 'cost'); |
169 | - foreach($sn_group_resources_loot as $resource_id) |
|
169 | + foreach ($sn_group_resources_loot as $resource_id) |
|
170 | 170 | { |
171 | 171 | $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $unit_count) : 0; |
172 | 172 | } |
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - foreach($sn_group_resources_loot as $resource_id) |
|
176 | + foreach ($sn_group_resources_loot as $resource_id) |
|
177 | 177 | { |
178 | 178 | $final_cost[$resource_id] += floor(mrc_get_level($user, $planet, $resource_id, true, true)); |
179 | 179 | } |
@@ -75,8 +75,7 @@ discard block |
||
75 | 75 | 'TEXT' => $error, |
76 | 76 | )); |
77 | 77 | } |
78 | - } |
|
79 | - else |
|
78 | + } else |
|
80 | 79 | { |
81 | 80 | $template->assign_var('CHECK', 1); |
82 | 81 | |
@@ -133,8 +132,7 @@ discard block |
||
133 | 132 | |
134 | 133 | display(parsetemplate($template, $parse), $lang['adm_pl_comp_title'], false, '', true ); |
135 | 134 | |
136 | -function killer_add_planet($planet) |
|
137 | -{ |
|
135 | +function killer_add_planet($planet) { |
|
138 | 136 | global $final_cost; |
139 | 137 | |
140 | 138 | $final_cost = array(); |