@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | function pname_factory_production_field_name($factory_unit_id) |
6 | 6 | { |
7 | - return get_unit_param($factory_unit_id, P_NAME) . '_porcent'; |
|
7 | + return get_unit_param($factory_unit_id, P_NAME).'_porcent'; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | global $template_result; |
20 | 20 | $classLocale = classLocale::$lang; |
21 | 21 | |
22 | - if($ally_id = sys_get_param_id('ally_id')) { |
|
22 | + if ($ally_id = sys_get_param_id('ally_id')) { |
|
23 | 23 | define('SN_IN_ALLY', true); |
24 | 24 | $ranks = ally_get_ranks($auser['ally']); |
25 | - if($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
25 | + if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
26 | 26 | $user = &$auser['ally']['player']; |
27 | 27 | $planet = array( |
28 | 28 | 'metal' => $user['metal'], |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | - if(!$user) { |
|
35 | + if (!$user) { |
|
36 | 36 | $user = &$auser; |
37 | 37 | } |
38 | 38 | |
39 | - switch($action = sys_get_param_escaped('action')) { |
|
39 | + switch ($action = sys_get_param_escaped('action')) { |
|
40 | 40 | case 'create': // Add unit to que for build |
41 | 41 | case 'create_autoconvert': // Add unit to que for build |
42 | 42 | case 'destroy': // Add unit to que for remove |
@@ -53,28 +53,28 @@ discard block |
||
53 | 53 | |
54 | 54 | $group_missile = sn_get_groups('missile'); |
55 | 55 | $silo_capacity_free = 0; |
56 | - if($que_type == QUE_STRUCTURES) { |
|
56 | + if ($que_type == QUE_STRUCTURES) { |
|
57 | 57 | $build_unit_list = sn_get_groups('build_allow'); |
58 | 58 | $build_unit_list = $build_unit_list[$planet['planet_type']]; |
59 | 59 | $artifact_id = ART_NANO_BUILDER; |
60 | 60 | $page_header = classLocale::$lang['tech'][UNIT_STRUCTURES]; |
61 | - } elseif($que_type == QUE_RESEARCH) { |
|
62 | - if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
61 | + } elseif ($que_type == QUE_RESEARCH) { |
|
62 | + if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
63 | 63 | message(classLocale::$lang['no_laboratory'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]); |
64 | 64 | } |
65 | 65 | |
66 | - if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
66 | + if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
67 | 67 | message(classLocale::$lang['eco_bld_msg_err_laboratory_upgrading'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]); |
68 | 68 | } |
69 | 69 | $build_unit_list = sn_get_groups('tech'); |
70 | 70 | $artifact_id = ART_HEURISTIC_CHIP; |
71 | - $page_header = classLocale::$lang['tech'][UNIT_TECHNOLOGIES] . ($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
72 | - } elseif($que_type == QUE_MERCENARY) { |
|
71 | + $page_header = classLocale::$lang['tech'][UNIT_TECHNOLOGIES].($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
72 | + } elseif ($que_type == QUE_MERCENARY) { |
|
73 | 73 | $build_unit_list = sn_get_groups('mercenaries'); |
74 | 74 | $artifact_id = 0; |
75 | - $page_header = classLocale::$lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
75 | + $page_header = classLocale::$lang['tech'][UNIT_MERCENARIES].($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); |
|
76 | 76 | } else { |
77 | - if(mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
77 | + if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
78 | 78 | message(classLocale::$lang['need_hangar'], classLocale::$lang['tech'][STRUC_FACTORY_HANGAR]); |
79 | 79 | } |
80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $artifact_id = 0; |
84 | 84 | |
85 | 85 | $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY); |
86 | - foreach($group_missile as $unit_id) { |
|
86 | + foreach ($group_missile as $unit_id) { |
|
87 | 87 | $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); |
88 | 88 | } |
89 | 89 | $silo_capacity_free = max(0, $silo_capacity_free); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $config_resource_multiplier_plain = game_resource_multiplier(true); |
95 | 95 | |
96 | 96 | $template = gettemplate('buildings_builds', true); |
97 | - if(!empty($operation_result)) { |
|
97 | + if (!empty($operation_result)) { |
|
98 | 98 | $template_result['.']['result'][] = $operation_result; |
99 | 99 | } |
100 | 100 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $record_index = 0; |
126 | 126 | |
127 | - foreach($build_unit_list as $unit_id) { |
|
127 | + foreach ($build_unit_list as $unit_id) { |
|
128 | 128 | $level_base = mrc_get_level($user, $planet, $unit_id, false, true); |
129 | 129 | $level_effective = mrc_get_level($user, $planet, $unit_id); |
130 | 130 | $level_in_que = $in_que[$unit_id]; |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE]; |
148 | 148 | // Restricting $can_build by free silo capacity |
149 | 149 | $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; |
150 | - if(!$can_build) { |
|
151 | - if(!$build_data['CAN'][BUILD_CREATE]) { |
|
150 | + if (!$can_build) { |
|
151 | + if (!$build_data['CAN'][BUILD_CREATE]) { |
|
152 | 152 | $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES; |
153 | - } elseif($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
153 | + } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
154 | 154 | $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL; |
155 | - } elseif($unit_info[P_MAX_STACK]) { |
|
155 | + } elseif ($unit_info[P_MAX_STACK]) { |
|
156 | 156 | $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED; |
157 | 157 | } |
158 | 158 | } |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | 'MAP_IS_RESOURCE' => !empty($unit_info[P_UNIT_PRODUCTION]), |
220 | 220 | ); |
221 | 221 | |
222 | - if($unit_stackable) { |
|
222 | + if ($unit_stackable) { |
|
223 | 223 | $level_production_base = array( |
224 | 224 | 'ACTUAL_SHIELD' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])), |
225 | 225 | 'ACTUAL_ARMOR' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])), |
226 | 226 | 'ACTUAL_WEAPON' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])), |
227 | 227 | ); |
228 | 228 | |
229 | - if($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
229 | + if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
230 | 230 | $ship_data = get_ship_data($unit_id, $user); |
231 | 231 | |
232 | 232 | $level_production_base += array( |
@@ -236,23 +236,23 @@ discard block |
||
236 | 236 | ); |
237 | 237 | } |
238 | 238 | |
239 | - if($unit_info[P_UNIT_PRODUCTION]) { |
|
240 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
241 | - if($resource_income = |
|
239 | + if ($unit_info[P_UNIT_PRODUCTION]) { |
|
240 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
241 | + if ($resource_income = |
|
242 | 242 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet) |
243 | 243 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
244 | 244 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
245 | 245 | ) { |
246 | - $level_production_base['R' . $resource_id] = $resource_income; |
|
246 | + $level_production_base['R'.$resource_id] = $resource_income; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
250 | 250 | $production['.']['resource'][] = $level_production_base; |
251 | - } elseif($unit_info[P_UNIT_PRODUCTION]) { |
|
251 | + } elseif ($unit_info[P_UNIT_PRODUCTION]) { |
|
252 | 252 | $level_production_base = array(); |
253 | 253 | $element_level_start = $level_effective + $in_que[$unit_id]; |
254 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
255 | - if($resource_income = |
|
254 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
255 | + if ($resource_income = |
|
256 | 256 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet) |
257 | 257 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
258 | 258 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
@@ -262,21 +262,21 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
265 | - for($i = 0; $i < 6; $i++) { |
|
265 | + for ($i = 0; $i < 6; $i++) { |
|
266 | 266 | $level_production = array('LEVEL' => $level_start + $i); |
267 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | - if( |
|
267 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | + if ( |
|
269 | 269 | $resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 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))) |
272 | 272 | ) { |
273 | - $level_production['R' . $resource_id] = $resource_income; |
|
274 | - $level_production['D' . $resource_id] = $resource_income - $level_production_base[$resource_id]; |
|
273 | + $level_production['R'.$resource_id] = $resource_income; |
|
274 | + $level_production['D'.$resource_id] = $resource_income - $level_production_base[$resource_id]; |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | $production['.']['resource'][] = $level_production; |
278 | 278 | } |
279 | - } elseif($unit_id == TECH_ASTROTECH) { |
|
279 | + } elseif ($unit_id == TECH_ASTROTECH) { |
|
280 | 280 | $element_level_start = $level_effective + $in_que[$unit_id]; |
281 | 281 | $level_production_base = array( |
282 | 282 | UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start), |
@@ -284,17 +284,17 @@ discard block |
||
284 | 284 | ); |
285 | 285 | |
286 | 286 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
287 | - for($i = 0; $i < 6; $i++) { |
|
287 | + for ($i = 0; $i < 6; $i++) { |
|
288 | 288 | $level_production = array('LEVEL' => $level_start + $i); |
289 | - $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i); |
|
290 | - $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX]; |
|
291 | - $level_production['R' . UNIT_PLAYER_COLONIES_MAX] = get_player_max_colonies($user, $level_start + $i); |
|
292 | - $level_production['D' . UNIT_PLAYER_COLONIES_MAX] = $level_production['R' . UNIT_PLAYER_COLONIES_MAX] - $level_production_base[UNIT_PLAYER_COLONIES_MAX]; |
|
289 | + $level_production['R'.UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i); |
|
290 | + $level_production['D'.UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R'.UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX]; |
|
291 | + $level_production['R'.UNIT_PLAYER_COLONIES_MAX] = get_player_max_colonies($user, $level_start + $i); |
|
292 | + $level_production['D'.UNIT_PLAYER_COLONIES_MAX] = $level_production['R'.UNIT_PLAYER_COLONIES_MAX] - $level_production_base[UNIT_PLAYER_COLONIES_MAX]; |
|
293 | 293 | $production['.']['resource'][] = $level_production; |
294 | 294 | |
295 | 295 | $level_production_base = array( |
296 | - UNIT_PLAYER_EXPEDITIONS_MAX => $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX], |
|
297 | - UNIT_PLAYER_COLONIES_MAX => $level_production['R' . UNIT_PLAYER_COLONIES_MAX], |
|
296 | + UNIT_PLAYER_EXPEDITIONS_MAX => $level_production['R'.UNIT_PLAYER_EXPEDITIONS_MAX], |
|
297 | + UNIT_PLAYER_COLONIES_MAX => $level_production['R'.UNIT_PLAYER_COLONIES_MAX], |
|
298 | 298 | ); |
299 | 299 | } |
300 | 300 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $template_result['.']['production'][] = $production; |
306 | 306 | } |
307 | 307 | |
308 | - foreach(classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
308 | + foreach (classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
309 | 309 | $template->assign_block_vars('sort_values', array( |
310 | 310 | 'VALUE' => $sort_id, |
311 | 311 | 'TEXT' => $sort_text, |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | function art_use(&$user, &$planetrow, $unit_id) { |
4 | 4 | $classLocale = classLocale::$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, null, $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 | } |
@@ -133,6 +133,6 @@ discard block |
||
133 | 133 | |
134 | 134 | sn_db_transaction_commit(); |
135 | 135 | message($message, "{$classLocale['tech'][UNIT_ARTIFACTS]} - {$classLocale['tech'][$unit_id]}", |
136 | - ($request_uri = sys_get_param_str_unsafe('REQUEST_URI')) ? $request_uri : ('artifacts' . DOT_PHP_EX . '#' . $unit_id), |
|
136 | + ($request_uri = sys_get_param_str_unsafe('REQUEST_URI')) ? $request_uri : ('artifacts'.DOT_PHP_EX.'#'.$unit_id), |
|
137 | 137 | 5); |
138 | 138 | } |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | print($round); |
28 | 28 | print('<table border=1>'); |
29 | 29 | print('<tr align="left">'); |
30 | - foreach($header as $key => $value) |
|
30 | + foreach ($header as $key => $value) |
|
31 | 31 | { |
32 | - if(is_array($value)) |
|
32 | + if (is_array($value)) |
|
33 | 33 | { |
34 | 34 | continue; |
35 | 35 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | ); |
62 | 62 | |
63 | 63 | print('<tr align="right">'); |
64 | - foreach($unit_crossfire_result as $key => $value) |
|
64 | + foreach ($unit_crossfire_result as $key => $value) |
|
65 | 65 | { |
66 | - if(is_array($value)) |
|
66 | + if (is_array($value)) |
|
67 | 67 | { |
68 | 68 | continue; |
69 | 69 | } |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | $TargetAddress = sprintf(classLocale::$lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']); |
21 | 21 | |
22 | 22 | $TheMessage = classLocale::$lang['sys_colo_no_colonizer']; |
23 | - if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
23 | + if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
24 | 24 | $TheMessage = classLocale::$lang['sys_colo_notfree']; |
25 | - if(empty($mission_data->dst_planet)) { |
|
25 | + if (empty($mission_data->dst_planet)) { |
|
26 | 26 | $iPlanetCount = get_player_current_colonies($src_user_row); |
27 | 27 | |
28 | 28 | // Can we colonize more planets? |
29 | 29 | $TheMessage = classLocale::$lang['sys_colo_maxcolo']; |
30 | - if($iPlanetCount < get_player_max_colonies($src_user_row)) { |
|
30 | + if ($iPlanetCount < get_player_max_colonies($src_user_row)) { |
|
31 | 31 | // Yes, we can colonize |
32 | 32 | $TheMessage = classLocale::$lang['sys_colo_badpos']; |
33 | 33 | |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'], |
36 | 36 | $objFleet->playerOwnerId, "{$classLocale['sys_colo_defaultname']} {$iPlanetCount}", false, |
37 | 37 | array('user_row' => $src_user_row)); |
38 | - if($NewOwnerPlanet) { |
|
39 | - $TheMessage = classLocale::$lang['sys_colo_arrival'] . $TargetAddress . classLocale::$lang['sys_colo_allisok']; |
|
38 | + if ($NewOwnerPlanet) { |
|
39 | + $TheMessage = classLocale::$lang['sys_colo_arrival'].$TargetAddress.classLocale::$lang['sys_colo_allisok']; |
|
40 | 40 | msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_colo_mess_from'], classLocale::$lang['sys_colo_mess_report'], $TheMessage); |
41 | 41 | |
42 | 42 | $objFleet->shipAdjustCount(SHIP_COLONIZER, -1); |
@@ -2,28 +2,28 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(SN_IN_FLEET !== true) { |
|
5 | +if (SN_IN_FLEET !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | 9 | $fleetid = sys_get_param_id('fleetid'); |
10 | 10 | |
11 | -if(!is_numeric($fleetid) || empty($fleetid)) { |
|
11 | +if (!is_numeric($fleetid) || empty($fleetid)) { |
|
12 | 12 | header("Location: fleet.php"); |
13 | 13 | exit(); |
14 | 14 | } |
15 | 15 | |
16 | 16 | $objFleet = new Fleet(); |
17 | 17 | $objFleet->dbLoad($fleetid); |
18 | -if(!$objFleet->dbId) { |
|
18 | +if (!$objFleet->dbId) { |
|
19 | 19 | message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']); |
20 | 20 | } |
21 | 21 | |
22 | -if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
22 | +if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
23 | 23 | message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']); |
24 | 24 | } |
25 | 25 | |
26 | -if($objFleet->playerOwnerId != $user['id']) { |
|
26 | +if ($objFleet->playerOwnerId != $user['id']) { |
|
27 | 27 | classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301); |
28 | 28 | message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']); |
29 | 29 | } |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | |
35 | 35 | !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false; |
36 | 36 | |
37 | -if($userToAdd_unsafe) { |
|
37 | +if ($userToAdd_unsafe) { |
|
38 | 38 | $userToAdd = db_escape($userToAdd_unsafe); |
39 | 39 | $userToAddID = db_user_by_username($userToAdd_unsafe, false, 'id', true, true); |
40 | 40 | $userToAddID = $userToAddID['id']; |
41 | 41 | |
42 | - if($objFleet->target_owner_id == $userToAddID) { |
|
42 | + if ($objFleet->target_owner_id == $userToAddID) { |
|
43 | 43 | message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']); |
44 | 44 | } |
45 | 45 | |
46 | - if($userToAddID) { |
|
47 | - if(!$aks) { |
|
46 | + if ($userToAddID) { |
|
47 | + if (!$aks) { |
|
48 | 48 | // No AСS exists - making one |
49 | - if(!$objFleet->group_id) { |
|
49 | + if (!$objFleet->group_id) { |
|
50 | 50 | db_acs_insert($fleetid, $user, $objFleet); |
51 | 51 | |
52 | 52 | $aks = db_acs_get_by_fleet($fleetid); |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | |
62 | 62 | $isUserExists = false; |
63 | 63 | $invited_ar = explode(",", $aks['eingeladen']); |
64 | - foreach($invited_ar as $inv) { |
|
65 | - if($userToAddID == $inv) { |
|
64 | + foreach ($invited_ar as $inv) { |
|
65 | + if ($userToAddID == $inv) { |
|
66 | 66 | $isUserExists = true; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - if(count($invited_ar) >= 5) { |
|
70 | + if (count($invited_ar) >= 5) { |
|
71 | 71 | message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']); |
72 | 72 | } |
73 | 73 | |
74 | - if($isUserExists) { |
|
74 | + if ($isUserExists) { |
|
75 | 75 | $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false; |
76 | 76 | } else { |
77 | 77 | $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd); |
78 | 78 | !(db_acs_update($userToAddID, $fleetid)) ? die(sprintf(classLocale::$lang['fl_aks_adding_error'], db_error())) : false; |
79 | - $aks['eingeladen'] .= ',' . $userToAddID; |
|
79 | + $aks['eingeladen'] .= ','.$userToAddID; |
|
80 | 80 | } |
81 | 81 | msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'], |
82 | 82 | classLocale::$lang['fl_aks_invite_message_header'], sprintf(classLocale::$lang['fl_aks_invite_message'], $user['username'])); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | 'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS], |
94 | 94 | )); |
95 | 95 | |
96 | -if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | - foreach($members as $row) { |
|
96 | +if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | + foreach ($members as $row) { |
|
98 | 98 | $template->assign_block_vars('invited', array( |
99 | 99 | 'NAME' => $row['username'], |
100 | 100 | )); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $fleet_data = tplParseFleetObject($objFleet, $i, $user); |
120 | 120 | |
121 | 121 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
122 | -foreach($fleet_data['ships'] as $ship_data) { |
|
122 | +foreach ($fleet_data['ships'] as $ship_data) { |
|
123 | 123 | $template->assign_block_vars('fleets.ships', $ship_data); |
124 | 124 | } |
125 | 125 |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | |
40 | 40 | $sta_update_msg = db_escape($sta_update_msg); |
41 | 41 | |
42 | - if($next_step) { |
|
42 | + if ($next_step) { |
|
43 | 43 | $sta_update_step++; |
44 | 44 | } |
45 | 45 | $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}."; |
46 | 46 | |
47 | 47 | classSupernova::$config->db_saveItem('var_stat_update_msg', $sta_update_msg); |
48 | - if($next_step) { |
|
48 | + if ($next_step) { |
|
49 | 49 | classSupernova::$debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | 53 | function sys_stat_calculate_flush(&$data, $force = false) { |
54 | - if(count($data) < 25 && !$force) { |
|
54 | + if (count($data) < 25 && !$force) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - if(!empty($data)) { |
|
58 | + if (!empty($data)) { |
|
59 | 59 | doquery('REPLACE INTO {{statpoints}} |
60 | 60 | (`id_owner`, `id_ally`, `stat_type`, `stat_code`, `tech_points`, `tech_count`, `build_points`, `build_count`, |
61 | 61 | `defs_points`, `defs_count`, `fleet_points`, `fleet_count`, `res_points`, `res_count`, `total_points`, |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | $user_list = db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id'); |
96 | 96 | $row_num = count($user_list); |
97 | 97 | // while($player = db_fetch($query)) |
98 | - foreach($user_list as $player) { |
|
99 | - if($i++ % 100 == 0) { |
|
98 | + foreach ($user_list as $player) { |
|
99 | + if ($i++ % 100 == 0) { |
|
100 | 100 | sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false); |
101 | 101 | } |
102 | - if(array_key_exists($user_id = $player['id'], $user_skip_list)) { |
|
102 | + if (array_key_exists($user_id = $player['id'], $user_skip_list)) { |
|
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | // $points[$user_id][UNIT_RESOURCES] += $resources; |
110 | 110 | |
111 | 111 | // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что |
112 | - if(!isset($user_skip_list[$user_id])) { |
|
112 | + if (!isset($user_skip_list[$user_id])) { |
|
113 | 113 | $user_allies[$user_id] = $player['ally_id']; |
114 | 114 | } |
115 | 115 | } |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | $i = 0; |
124 | 124 | $query = db_planet_list_resources_by_owner(); |
125 | 125 | $row_num = db_num_rows($query); |
126 | - while($planet = db_fetch($query)) { |
|
127 | - if($i++ % 100 == 0) { |
|
126 | + while ($planet = db_fetch($query)) { |
|
127 | + if ($i++ % 100 == 0) { |
|
128 | 128 | sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false); |
129 | 129 | } |
130 | - if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) { |
|
130 | + if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) { |
|
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | $i = 0; |
143 | 143 | $query = FleetList::dbQueryAllId(); |
144 | 144 | $row_num = db_num_rows($query); |
145 | - while($fleet_row = db_fetch($query)) { |
|
146 | - if($i++ % 100 == 0) { |
|
145 | + while ($fleet_row = db_fetch($query)) { |
|
146 | + if ($i++ % 100 == 0) { |
|
147 | 147 | sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false); |
148 | 148 | } |
149 | 149 | $objFleet = new Fleet(); |
@@ -151,15 +151,15 @@ discard block |
||
151 | 151 | // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными |
152 | 152 | // $objFleet->_reset(); |
153 | 153 | $objFleet->dbRowParse($fleet_row); |
154 | - if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) { |
|
154 | + if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) { |
|
155 | 155 | continue; |
156 | 156 | } |
157 | 157 | |
158 | 158 | $fleet = $objFleet->shipsGetArray(); |
159 | - foreach($fleet as $unit_id => $unit_amount) { |
|
159 | + foreach ($fleet as $unit_id => $unit_amount) { |
|
160 | 160 | $counts[$user_id][UNIT_SHIPS] += $unit_amount; |
161 | 161 | |
162 | - if(!isset($unit_cost_cache[$unit_id][0])) { |
|
162 | + if (!isset($unit_cost_cache[$unit_id][0])) { |
|
163 | 163 | $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST); |
164 | 164 | } |
165 | 165 | $unit_cost_data = &$unit_cost_cache[$unit_id][0]; |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | $i = 0; |
180 | 180 | $query = db_unit_list_stat_calculate(); |
181 | 181 | $row_num = db_num_rows($query); |
182 | - while($unit = db_fetch($query)) { |
|
183 | - if($i++ % 100 == 0) { |
|
182 | + while ($unit = db_fetch($query)) { |
|
183 | + if ($i++ % 100 == 0) { |
|
184 | 184 | sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false); |
185 | 185 | } |
186 | - if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) { |
|
186 | + if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) { |
|
187 | 187 | continue; |
188 | 188 | } |
189 | 189 | |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | $i = 0; |
198 | 198 | $query = db_que_list_stat(); |
199 | 199 | $row_num = db_num_rows($query); |
200 | - while($que_item = db_fetch($query)) { |
|
201 | - if($i++ % 100 == 0) { |
|
200 | + while ($que_item = db_fetch($query)) { |
|
201 | + if ($i++ % 100 == 0) { |
|
202 | 202 | sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false); |
203 | 203 | } |
204 | - if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) { |
|
204 | + if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) { |
|
205 | 205 | continue; |
206 | 206 | } |
207 | 207 | $que_unit_amount = $que_item['que_unit_amount']; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | sta_set_time_limit('posting new user stats to DB'); |
222 | 222 | $data = array(); |
223 | - foreach($user_allies as $user_id => $ally_id) { |
|
223 | + foreach ($user_allies as $user_id => $ally_id) { |
|
224 | 224 | // $counts[UNIT_RESOURCES] дублирует $points[UNIT_RESOURCES], поэтому $points не заполняем, а берем $counts и делим на 1000 |
225 | 225 | $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000; |
226 | 226 | $points[$user_id] = array_map('floor', $points[$user_id]); |
@@ -232,10 +232,10 @@ discard block |
||
232 | 232 | $user_points = array_sum($points[$user_id]); |
233 | 233 | $user_counts = array_sum($counts[$user_id]); |
234 | 234 | |
235 | - $data[] = $q = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}'," . |
|
236 | - "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}'," . |
|
237 | - "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}'," . |
|
238 | - "{$user_points},{$user_counts}," . SN_TIME_NOW . ")"; |
|
235 | + $data[] = $q = "({$user_id},{$ally_id},1,1,'{$points[$user_id][UNIT_TECHNOLOGIES]}','{$counts[$user_id][UNIT_TECHNOLOGIES]}',". |
|
236 | + "'{$points[$user_id][UNIT_STRUCTURES]}','{$counts[$user_id][UNIT_STRUCTURES]}','{$user_defence_points}','{$user_defence_counts}',". |
|
237 | + "'{$points[$user_id][UNIT_SHIPS]}','{$counts[$user_id][UNIT_SHIPS]}','{$points[$user_id][UNIT_RESOURCES]}','{$counts[$user_id][UNIT_RESOURCES]}',". |
|
238 | + "{$user_points},{$user_counts},".SN_TIME_NOW.")"; |
|
239 | 239 | |
240 | 240 | sys_stat_calculate_flush($data); |
241 | 241 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | SUM(u.`tech_points`)+aus.`tech_points`, SUM(u.`tech_count`)+aus.`tech_count`, SUM(u.`build_points`)+aus.`build_points`, SUM(u.`build_count`)+aus.`build_count`, |
256 | 256 | SUM(u.`defs_points`)+aus.`defs_points`, SUM(u.`defs_count`)+aus.`defs_count`, SUM(u.`fleet_points`)+aus.`fleet_points`, SUM(u.`fleet_count`)+aus.`fleet_count`, |
257 | 257 | SUM(u.`res_points`)+aus.`res_points`, SUM(u.`res_count`)+aus.`res_count`, SUM(u.`total_points`)+aus.`total_points`, SUM(u.`total_count`)+aus.`total_count`, |
258 | - " . SN_TIME_NOW . ", NULL, u.`id_ally`, 2, 1, |
|
258 | + " . SN_TIME_NOW.", NULL, u.`id_ally`, 2, 1, |
|
259 | 259 | a.tech_rank, a.build_rank, a.defs_rank, a.fleet_rank, a.res_rank, a.total_rank |
260 | 260 | FROM {{statpoints}} AS u |
261 | 261 | JOIN {{alliance}} AS al ON al.id = u.id_ally |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | // Updating player's ranks |
278 | 278 | sta_set_time_limit("updating ranks for players"); |
279 | - foreach($rankNames as $rankName) { |
|
279 | + foreach ($rankNames as $rankName) { |
|
280 | 280 | sta_set_time_limit("updating player rank '{$rankName}'", false); |
281 | 281 | doquery($qryResetRowNum); |
282 | 282 | doquery(sprintf($qryFormat, $rankName, 1)); |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | sta_set_time_limit("updating ranks for Alliances"); |
286 | 286 | // --- Updating Allie's ranks |
287 | - foreach($rankNames as $rankName) { |
|
287 | + foreach ($rankNames as $rankName) { |
|
288 | 288 | sta_set_time_limit("updating Alliances rank '{$rankName}'", false); |
289 | 289 | doquery($qryResetRowNum); |
290 | 290 | doquery(sprintf($qryFormat, $rankName, 2)); |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
5 | +if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | -$page_title .= ' - ' . classLocale::$lang["eco_mrk_{$submode}"]; |
|
9 | +$page_title .= ' - '.classLocale::$lang["eco_mrk_{$submode}"]; |
|
10 | 10 | |
11 | 11 | $template = gettemplate('market_fleet', true); |
12 | 12 | $template->assign_vars(array( |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | 'rpg_cost' => $rpg_cost, |
15 | 15 | )); |
16 | 16 | |
17 | -if(is_array($shipList)) { |
|
18 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
17 | +if (is_array($shipList)) { |
|
18 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) { |
|
19 | 19 | $intError = MARKET_NO_DM; |
20 | 20 | } |
21 | 21 | |
@@ -28,34 +28,34 @@ discard block |
||
28 | 28 | // Блокируем запись о запасах кораблей у трейдера |
29 | 29 | db_config_get_stockman_fleet(); |
30 | 30 | |
31 | - $message .= classLocale::$lang["eco_mrk_{$submode}_ships"] . '<ul>'; |
|
31 | + $message .= classLocale::$lang["eco_mrk_{$submode}_ships"].'<ul>'; |
|
32 | 32 | $qry = array(); |
33 | 33 | $total = array(); |
34 | 34 | $db_changeset = array(); |
35 | - foreach($shipList as $shipID => &$shipCount) { |
|
35 | + foreach ($shipList as $shipID => &$shipCount) { |
|
36 | 36 | $shipCount = ceil(floatval($shipCount)); |
37 | - if(!$shipCount) { |
|
37 | + if (!$shipCount) { |
|
38 | 38 | continue; |
39 | 39 | } |
40 | 40 | |
41 | - if($shipCount < 0) { |
|
41 | + if ($shipCount < 0) { |
|
42 | 42 | classSupernova::$debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307); |
43 | 43 | $intError = MARKET_NEGATIVE_SHIPS; |
44 | 44 | break; |
45 | 45 | } |
46 | 46 | |
47 | - if($mode == MARKET_SCRAPPER) { |
|
47 | + if ($mode == MARKET_SCRAPPER) { |
|
48 | 48 | $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
49 | - } elseif($mode == MARKET_STOCKMAN) { |
|
49 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
50 | 50 | $amount = $stock[$shipID]; |
51 | 51 | } |
52 | 52 | |
53 | - if($amount < $shipCount) { |
|
53 | + if ($amount < $shipCount) { |
|
54 | 54 | $intError = $error_no_stock; |
55 | 55 | break; |
56 | 56 | } |
57 | 57 | |
58 | - if(!in_array($shipID, sn_get_groups('fleet'))) { |
|
58 | + if (!in_array($shipID, sn_get_groups('fleet'))) { |
|
59 | 59 | classSupernova::$debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306); |
60 | 60 | $intError = MARKET_NOT_A_SHIP; |
61 | 61 | break; |
@@ -71,16 +71,16 @@ discard block |
||
71 | 71 | $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier)); |
72 | 72 | $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier)); |
73 | 73 | |
74 | - foreach($resTemp as $resID => $resCount) { |
|
74 | + foreach ($resTemp as $resID => $resCount) { |
|
75 | 75 | $total[$resID] += $resCount; |
76 | 76 | } |
77 | 77 | |
78 | - $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount); |
|
78 | + $message .= "<li>{$classLocale['tech'][$shipID]}: ".pretty_number($shipCount); |
|
79 | 79 | } |
80 | 80 | |
81 | - if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
82 | - foreach($total as $resID => $resCount) { |
|
83 | - if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
81 | + if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) { |
|
82 | + foreach ($total as $resID => $resCount) { |
|
83 | + if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) { |
|
84 | 84 | $intError = MARKET_NO_RESOURCES; |
85 | 85 | classSupernova::$debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301); |
86 | 86 | break; |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | |
91 | 91 | $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError; |
92 | 92 | |
93 | - if($intError == MARKET_DEAL) { |
|
94 | - $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>'; |
|
95 | - foreach($total as $resID => $resCount) { |
|
96 | - if(!$resCount) { |
|
93 | + if ($intError == MARKET_DEAL) { |
|
94 | + $message .= '</ul>'.classLocale::$lang["eco_mrk_{$submode}_res"].'<ul>'; |
|
95 | + foreach ($total as $resID => $resCount) { |
|
96 | + if (!$resCount) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | // $newrow[$resID] = $planetrow[$resID] + $resCount * (-$multiplier); |
102 | 102 | $qry[] = "`{$resource_name}` = `{$resource_name}` + ({$resCount})"; |
103 | 103 | |
104 | - $message .= "<li>" . classLocale::$lang['sys_' . $resource_name] . ": " . pretty_number(abs($resCount)); |
|
104 | + $message .= "<li>".classLocale::$lang['sys_'.$resource_name].": ".pretty_number(abs($resCount)); |
|
105 | 105 | } |
106 | 106 | $message .= "</ul>"; |
107 | 107 | |
@@ -127,38 +127,38 @@ discard block |
||
127 | 127 | 'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError], |
128 | 128 | )); |
129 | 129 | |
130 | - foreach($shipList as $shipID => $shipCount) { |
|
130 | + foreach ($shipList as $shipID => $shipCount) { |
|
131 | 131 | $data['ships'][$shipID] = max(0, intval($shipCount)); |
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | $message = ''; |
136 | 136 | |
137 | -if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
138 | - classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, sn_get_groups('fleet')))); |
|
137 | +if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) { |
|
138 | + classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, sn_get_groups('fleet')))); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | tpl_set_resource_info($template, $planetrow, array()); |
142 | 142 | |
143 | -if(!$array) { |
|
143 | +if (!$array) { |
|
144 | 144 | $array = array(); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $group_fleet = sn_get_groups('fleet'); |
148 | -foreach($array as $key => $value) { |
|
149 | - if($mode == MARKET_SCRAPPER) { |
|
148 | +foreach ($array as $key => $value) { |
|
149 | + if ($mode == MARKET_SCRAPPER) { |
|
150 | 150 | $shipID = $value; |
151 | 151 | $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)]; |
152 | - } elseif($mode == MARKET_STOCKMAN) { |
|
152 | + } elseif ($mode == MARKET_STOCKMAN) { |
|
153 | 153 | $shipID = $key; |
154 | 154 | $amount = $value; |
155 | 155 | } |
156 | 156 | |
157 | - if(!in_array($shipID, $group_fleet)) { |
|
157 | + if (!in_array($shipID, $group_fleet)) { |
|
158 | 158 | continue; |
159 | 159 | } |
160 | 160 | |
161 | - if($amount > 0) { |
|
161 | + if ($amount > 0) { |
|
162 | 162 | $build_data = eco_get_build_data($user, $planetrow, $shipID); |
163 | 163 | $template->assign_block_vars('ships', array( |
164 | 164 | 'ID' => $shipID, |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | $destination_planet = &$mission_data->dst_planet; |
16 | 16 | |
17 | - if(empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
17 | + if (empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) { |
|
18 | 18 | $objFleet->markReturnedAndSave(); |
19 | 19 | |
20 | 20 | return CACHE_FLEET; |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | $fleet_resources[RES_METAL], classLocale::$lang['Metal'], |
28 | 28 | $fleet_resources[RES_CRYSTAL], classLocale::$lang['Crystal'], |
29 | 29 | $fleet_resources[RES_DEUTERIUM], classLocale::$lang['Deuterium'] |
30 | - ) . '<br />' . classLocale::$lang['sys_relocate_mess_user']; |
|
30 | + ).'<br />'.classLocale::$lang['sys_relocate_mess_user']; |
|
31 | 31 | $fleet_real_array = $objFleet->shipsGetArray(); |
32 | - foreach($fleet_real_array as $ship_id => $ship_count) { |
|
33 | - $Message .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />'; |
|
32 | + foreach ($fleet_real_array as $ship_id => $ship_count) { |
|
33 | + $Message .= classLocale::$lang['tech'][$ship_id].' - '.$ship_count.'<br />'; |
|
34 | 34 | } |
35 | 35 | msg_send_simple_message( |
36 | 36 | $objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, |