@@ -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 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) { |
289 | - if(!$from['id']) { |
|
289 | + if (!$from['id']) { |
|
290 | 290 | $result = classLocale::$lang['sys_planet_expedition']; |
291 | 291 | } else { |
292 | 292 | $from_planet_id = $include_id ? ( |
@@ -341,23 +341,23 @@ discard block |
||
341 | 341 | global $config; |
342 | 342 | |
343 | 343 | try { |
344 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
344 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
345 | 345 | throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR); |
346 | 346 | } |
347 | 347 | |
348 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
348 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
349 | 349 | throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
350 | 350 | } |
351 | 351 | |
352 | 352 | // TODO: Replace quick-check with using gathered flying fleet data |
353 | - if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
353 | + if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
354 | 354 | throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR); |
355 | 355 | } |
356 | 356 | |
357 | - if(is_array($new_coordinates)) { |
|
357 | + if (is_array($new_coordinates)) { |
|
358 | 358 | $new_coordinates['planet_type'] = PT_PLANET; |
359 | 359 | $incoming = db_planet_by_vector($new_coordinates, '', true, 'id'); |
360 | - if($incoming['id']) { |
|
360 | + if ($incoming['id']) { |
|
361 | 361 | throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
362 | 362 | } |
363 | 363 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | 'result' => ERR_NONE, |
367 | 367 | 'message' => '', |
368 | 368 | ); |
369 | - } catch(exception $e) { |
|
369 | + } catch (exception $e) { |
|
370 | 370 | $response = array( |
371 | 371 | 'result' => $e->getCode(), |
372 | 372 | 'message' => $e->getMessage(), |