@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $debris_for_moon = $debris->debris_total(); |
72 | 72 | |
73 | - if(!$debris_for_moon) { |
|
73 | + if (!$debris_for_moon) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure |
79 | 79 | $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0; |
80 | 80 | $this->create_chance = $moon_chance; |
81 | - if($moon_chance) { |
|
82 | - if($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
81 | + if ($moon_chance) { |
|
82 | + if ($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
83 | 83 | $this->status = UBE_MOON_CREATE_SUCCESS; |
84 | 84 | $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999)); |
85 | 85 | |
86 | - if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
86 | + if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
87 | 87 | $debris->_reset(); |
88 | 88 | } else { |
89 | 89 | $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | protected function moon_destroy_try($reapers) { |
104 | 104 | // TODO: $is_simulator |
105 | - if($reapers <= 0) { |
|
105 | + if ($reapers <= 0) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @version 2016-02-25 23:42:45 41a4.68 |
121 | 121 | */ |
122 | 122 | public function calculate_moon(UBE $ube) { |
123 | - if(UBE_MOON_EXISTS == $this->status) { |
|
124 | - if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
123 | + if (UBE_MOON_EXISTS == $this->status) { |
|
124 | + if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
125 | 125 | $reapers = $ube->fleet_list->ube_calculate_attack_reapers(); |
126 | 126 | $this->moon_destroy_try($reapers); |
127 | 127 | } |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | public function report_generate_sql() { |
134 | - return "`ube_report_moon` = " . (int)$this->status . ", |
|
135 | - `ube_report_moon_chance` = " . (int)$this->create_chance . ", |
|
136 | - `ube_report_moon_size` = " . (float)$this->moon_diameter . ", |
|
137 | - `ube_report_moon_reapers` = " . (int)$this->reapers_status . ", |
|
138 | - `ube_report_moon_destroy_chance` = " . (int)$this->destroy_chance . ", |
|
139 | - `ube_report_moon_reapers_die_chance` = " . (int)$this->reaper_die_chance; |
|
134 | + return "`ube_report_moon` = ".(int) $this->status.", |
|
135 | + `ube_report_moon_chance` = " . (int) $this->create_chance.", |
|
136 | + `ube_report_moon_size` = " . (float) $this->moon_diameter.", |
|
137 | + `ube_report_moon_reapers` = " . (int) $this->reapers_status.", |
|
138 | + `ube_report_moon_destroy_chance` = " . (int) $this->destroy_chance.", |
|
139 | + `ube_report_moon_reapers_die_chance` = " . (int) $this->reaper_die_chance; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | public function report_render_moon() { |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | * @param $planet_id |
167 | 167 | */ |
168 | 168 | public function db_apply_result($planet_info, $destination_user_id) { |
169 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
169 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
170 | 170 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false); |
171 | 171 | $this->moon_name = $moon_row['name']; |
172 | 172 | unset($moon_row); |
173 | - } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
173 | + } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
174 | 174 | DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]); |
175 | 175 | } |
176 | 176 | } |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | $classLocale = classLocale::$lang; |
180 | 180 | |
181 | 181 | $text_defender = ''; |
182 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
182 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
183 | 183 | $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />"; |
184 | - } elseif($this->status == UBE_MOON_CREATE_FAILED) { |
|
184 | + } elseif ($this->status == UBE_MOON_CREATE_FAILED) { |
|
185 | 185 | $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />"; |
186 | 186 | } |
187 | 187 | |
188 | - if($ube->mission_type_id == MT_DESTROY) { |
|
189 | - if($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
188 | + if ($ube->mission_type_id == MT_DESTROY) { |
|
189 | + if ($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
190 | 190 | $text_defender .= classLocale::$lang['ube_report_moon_reapers_none']; |
191 | 191 | } else { |
192 | 192 | $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. "; |
193 | - $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />"; |
|
193 | + $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure']."<br />"; |
|
194 | 194 | |
195 | 195 | $text_defender .= "{$classLocale['ube_report_moon_reapers_outcome']} {$this->reaper_die_chance}%. "; |
196 | 196 | $text_defender .= classLocale::$lang[$this->reapers_status == UBE_MOON_REAPERS_RETURNED ? 'ube_report_moon_reapers_survive' : 'ube_report_moon_reapers_died']; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @version 2016-02-25 23:42:45 41a4.68 |
216 | 216 | */ |
217 | 217 | public function ubeInitLoadStatis($destination_planet) { |
218 | - if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
218 | + if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
219 | 219 | $this->status = UBE_MOON_EXISTS; |
220 | 220 | $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter']; |
221 | 221 | $this->reapers_status = UBE_MOON_REAPERS_NONE; |
@@ -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 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array()) { |
58 | 58 | $Position = intval($Position); |
59 | 59 | |
60 | - if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
60 | + if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | |
67 | 67 | $planet_generator = sn_get_groups('planet_generator'); |
68 | 68 | |
69 | - if($HomeWorld) { |
|
69 | + if ($HomeWorld) { |
|
70 | 70 | $position_data = $planet_generator[0]; |
71 | 71 | } else { |
72 | 72 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
73 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
73 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
74 | 74 | // Корректируем температуру для планеты-странника |
75 | 75 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
76 | 76 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $planet_images = sn_get_groups('planet_images'); |
80 | 80 | $planet_image = $position_data['planet_images'][mt_rand(0, count($position_data['planet_images']) - 1)]; |
81 | - $planet_image .= 'planet' . $planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)]; |
|
81 | + $planet_image .= 'planet'.$planet_images[$planet_image][mt_rand(0, count($planet_images[$planet_image]) - 1)]; |
|
82 | 82 | |
83 | 83 | $t_max = sn_rand_gauss_range($position_data['t_max_min'], $position_data['t_max_max'], true, 1.3, true); |
84 | 84 | $t_min = $t_max - sn_rand_gauss_range($position_data['t_delta_min'], $position_data['t_delta_max'], true, 1.3, true); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $core_info = uni_create_planet_get_density($position_data, $user_row, $planet_sectors); |
91 | 91 | |
92 | - $planet_name_unsafe = $user_row['username'] . ' ' . ($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']); |
|
92 | + $planet_name_unsafe = $user_row['username'].' '.($planet_name_unsafe ? $planet_name_unsafe : classLocale::$lang['sys_colo_defaultname']); |
|
93 | 93 | |
94 | 94 | $planet['name'] = db_escape(strip_tags(trim($planet_name_unsafe))); |
95 | 95 | $planet['id_owner'] = $PlanetOwnerID; |
@@ -170,15 +170,15 @@ discard block |
||
170 | 170 | $moon_name = ''; |
171 | 171 | $moon_row = array(); |
172 | 172 | $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
173 | - if(!$moon['id']) { |
|
173 | + if (!$moon['id']) { |
|
174 | 174 | $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`'); |
175 | 175 | |
176 | - if($moon_planet['id']) { |
|
176 | + if ($moon_planet['id']) { |
|
177 | 177 | $base_storage_size = BASE_STORAGE_SIZE; |
178 | 178 | |
179 | - if(!$moon_chance) { |
|
179 | + if (!$moon_chance) { |
|
180 | 180 | $size = mt_rand(1100, 8999); |
181 | - } elseif($moon_chance <= 100) { |
|
181 | + } elseif ($moon_chance <= 100) { |
|
182 | 182 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
183 | 183 | } else { |
184 | 184 | $size = $moon_chance; |
@@ -194,22 +194,22 @@ discard block |
||
194 | 194 | |
195 | 195 | $field_max = ceil($size / 1000); |
196 | 196 | |
197 | - if(isset($options['image']) && $options['image']) { |
|
197 | + if (isset($options['image']) && $options['image']) { |
|
198 | 198 | $moon_image = $options['image']; |
199 | 199 | } else { |
200 | 200 | $moon_image = 'mond'; |
201 | 201 | } |
202 | 202 | |
203 | 203 | $moon_row = classSupernova::db_ins_record(LOC_PLANET, |
204 | - "`id_owner` = '{$user_id}', `parent_planet` = '{$moon_planet['id']}', `name` = '{$moon_name_safe}', `last_update` = " . SN_TIME_NOW . ", `image` = '{$moon_image}', |
|
205 | - `galaxy` = '{$pos_galaxy}', `system` = '{$pos_system}', `planet` = '{$pos_planet}', `planet_type` = " . PT_MOON . ", |
|
204 | + "`id_owner` = '{$user_id}', `parent_planet` = '{$moon_planet['id']}', `name` = '{$moon_name_safe}', `last_update` = ".SN_TIME_NOW.", `image` = '{$moon_image}', |
|
205 | + `galaxy` = '{$pos_galaxy}', `system` = '{$pos_system}', `planet` = '{$pos_planet}', `planet_type` = ".PT_MOON.", |
|
206 | 206 | `diameter` = '{$size}', `field_max` = '{$field_max}', `density` = 2500, `density_index` = 2, `temp_min` = '{$temp_min}', `temp_max` = '{$temp_max}', |
207 | 207 | `metal` = '0', `metal_perhour` = '0', `metal_max` = '{$base_storage_size}', |
208 | 208 | `crystal` = '0', `crystal_perhour` = '0', `crystal_max` = '{$base_storage_size}', |
209 | 209 | `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'" |
210 | 210 | ); |
211 | 211 | |
212 | - if($update_debris) { |
|
212 | + if ($update_debris) { |
|
213 | 213 | $debris_spent = $moon_chance * 1000000; |
214 | 214 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
215 | 215 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -244,28 +244,28 @@ discard block |
||
244 | 244 | $planet_row['id'] = $user['current_planet']; |
245 | 245 | |
246 | 246 | // Пытаемся переключить на новую планету |
247 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
247 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) { |
|
248 | 248 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
249 | 249 | } else { |
250 | 250 | $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']); |
251 | 251 | } |
252 | 252 | |
253 | 253 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
254 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
254 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
255 | 255 | { |
256 | 256 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
257 | 257 | // Если текущей планеты не существует - выставляем Столицу |
258 | - if(!isset($planet_row['id'])) { |
|
258 | + if (!isset($planet_row['id'])) { |
|
259 | 259 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
260 | 260 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
261 | - if(!isset($planet_row['id'])) { |
|
261 | + if (!isset($planet_row['id'])) { |
|
262 | 262 | classSupernova::$debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
263 | 263 | } |
264 | 264 | } |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Если производилось переключение планеты - делаем запись в юзере |
268 | - if($user['current_planet'] != $planet_row['id']) { |
|
268 | + if ($user['current_planet'] != $planet_row['id']) { |
|
269 | 269 | DBStaticUser::db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'"); |
270 | 270 | $user['current_planet'] = $planet_row['id']; |
271 | 271 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | // ---------------------------------------------------------------------------------------------------------------- |
284 | 284 | function uni_render_coordinates($from, $prefix = '') { |
285 | - return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]"; |
|
285 | + return "[{$from[$prefix.'galaxy']}:{$from[$prefix.'system']}:{$from[$prefix.'planet']}]"; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | function uni_render_planet($from) { |
@@ -290,17 +290,17 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) { |
293 | - if(!$from['id']) { |
|
293 | + if (!$from['id']) { |
|
294 | 294 | $result = classLocale::$lang['sys_planet_expedition']; |
295 | 295 | } else { |
296 | 296 | $from_planet_id = $include_id ? ( |
297 | - 'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} ' |
|
297 | + 'ID {'.($from['id'] ? $from['id'] : ($from[$prefix.'planet_id'] ? $from[$prefix.'planet_id'] : 0)).'} ' |
|
298 | 298 | ) : ''; |
299 | 299 | |
300 | - $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix . 'type'] ? $from[$prefix . 'type'] : 0); |
|
301 | - $from_planet_type = ($from_planet_type ? ' ' . classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : ''); |
|
300 | + $from_planet_type = $from['planet_type'] ? $from['planet_type'] : ($from[$prefix.'type'] ? $from[$prefix.'type'] : 0); |
|
301 | + $from_planet_type = ($from_planet_type ? ' '.classLocale::$lang['sys_planet_type_sh'][$from_planet_type] : ''); |
|
302 | 302 | |
303 | - $result = $from_planet_id . uni_render_coordinates($from, $prefix) . $from_planet_type . ($from['name'] ? ' ' . $from['name'] : ''); |
|
303 | + $result = $from_planet_id.uni_render_coordinates($from, $prefix).$from_planet_type.($from['name'] ? ' '.$from['name'] : ''); |
|
304 | 304 | $result = $html_safe ? str_replace(' ', ' ', htmlentities($result, ENT_COMPAT, 'UTF-8')) : $result; |
305 | 305 | } |
306 | 306 | |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') { |
311 | - return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}"; |
|
311 | + return $page.(strpos($page, '?') === false ? '?' : '&')."galaxy={$from[$prefix.'galaxy']}&system={$from[$prefix.'system']}&planet={$from[$prefix.'planet']}"; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') { |
315 | - return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>'; |
|
315 | + return '<a href="'.uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}").'"'.($fleet_type ? " {$fleet_type}" : '').'>'.uni_render_coordinates($from, $prefix).'</a>'; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | function uni_get_time_to_jump($moon_row) { |
@@ -340,30 +340,30 @@ discard block |
||
340 | 340 | $coordinates["{$prefix}planet"] = intval($coordinates["{$prefix}planet"]); |
341 | 341 | |
342 | 342 | return |
343 | - isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies&& |
|
344 | - isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems&& |
|
343 | + isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies && |
|
344 | + isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems && |
|
345 | 345 | isset($coordinates["{$prefix}planet"]) && $coordinates["{$prefix}planet"] > 0 && $coordinates["{$prefix}planet"] <= Vector::$knownPlanets; |
346 | 346 | } |
347 | 347 | |
348 | 348 | function uni_planet_teleport_check($user, $planetrow, $new_coordinates = null) { |
349 | 349 | try { |
350 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
350 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
351 | 351 | throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR); |
352 | 352 | } |
353 | 353 | |
354 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
354 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) { |
|
355 | 355 | throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
356 | 356 | } |
357 | 357 | |
358 | 358 | // TODO: Replace quick-check with using gathered flying fleet data |
359 | - if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
359 | + if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
360 | 360 | throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR); |
361 | 361 | } |
362 | 362 | |
363 | - if(is_array($new_coordinates)) { |
|
363 | + if (is_array($new_coordinates)) { |
|
364 | 364 | $new_coordinates['planet_type'] = PT_PLANET; |
365 | 365 | $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id'); |
366 | - if($incoming['id']) { |
|
366 | + if ($incoming['id']) { |
|
367 | 367 | throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
368 | 368 | } |
369 | 369 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | 'result' => ERR_NONE, |
373 | 373 | 'message' => '', |
374 | 374 | ); |
375 | - } catch(exception $e) { |
|
375 | + } catch (exception $e) { |
|
376 | 376 | $response = array( |
377 | 377 | 'result' => $e->getCode(), |
378 | 378 | 'message' => $e->getMessage(), |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | $unit_level = $artifact_level_old = mrc_get_level($user, null, $unit_id, true); |
14 | 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: |
@@ -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 | } |
@@ -51,16 +51,16 @@ |
||
51 | 51 | */ |
52 | 52 | public static function db_acs_insert($fleetid, $user, $objFleet) { |
53 | 53 | doquery("INSERT INTO {{aks}} SET |
54 | - `name` = '" . db_escape(classLocale::$lang['flt_acs_prefix'] . $fleetid) . "', |
|
55 | - `teilnehmer` = '" . $user['id'] . "', |
|
56 | - `flotten` = '" . $fleetid . "', |
|
57 | - `ankunft` = '" . $objFleet->time_arrive_to_target . "', |
|
58 | - `galaxy` = '" . $objFleet->fleet_end_galaxy . "', |
|
59 | - `system` = '" . $objFleet->fleet_end_system . "', |
|
60 | - `planet` = '" . $objFleet->fleet_end_planet . "', |
|
61 | - `planet_type` = '" . $objFleet->fleet_end_type . "', |
|
62 | - `eingeladen` = '" . $user['id'] . "', |
|
63 | - `fleet_end_time` = '" . $objFleet->time_return_to_source . "'"); |
|
54 | + `name` = '" . db_escape(classLocale::$lang['flt_acs_prefix'].$fleetid)."', |
|
55 | + `teilnehmer` = '" . $user['id']."', |
|
56 | + `flotten` = '" . $fleetid."', |
|
57 | + `ankunft` = '" . $objFleet->time_arrive_to_target."', |
|
58 | + `galaxy` = '" . $objFleet->fleet_end_galaxy."', |
|
59 | + `system` = '" . $objFleet->fleet_end_system."', |
|
60 | + `planet` = '" . $objFleet->fleet_end_planet."', |
|
61 | + `planet_type` = '" . $objFleet->fleet_end_type."', |
|
62 | + `eingeladen` = '" . $user['id']."', |
|
63 | + `fleet_end_time` = '" . $objFleet->time_return_to_source."'"); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | function db_news_insert_set($announce_time, $text, $detail_url, $user) { |
13 | 13 | doquery("INSERT INTO {{announce}} |
14 | 14 | SET `tsTimeStamp` = FROM_UNIXTIME({$announce_time}), `strAnnounce`='{$text}', detail_url = '{$detail_url}', |
15 | - `user_id` = {$user['id']}, `user_name` = '" . db_escape($user['username']) . "'"); |
|
15 | + `user_id` = {$user['id']}, `user_name` = '".db_escape($user['username'])."'"); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | function db_survey_insert($announce_id, $survey_question, $survey_until) { |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce |
94 | 94 | LEFT JOIN {{users}} AS u ON u.id = a.user_id |
95 | 95 | {$query_where} |
96 | - ORDER BY `tsTimeStamp` DESC, idAnnounce" . |
|
96 | + ORDER BY `tsTimeStamp` DESC, idAnnounce". |
|
97 | 97 | ($query_limit ? " LIMIT {$query_limit}" : '')); |
98 | 98 | |
99 | 99 | $template->assign_var('NEWS_COUNT', db_num_rows($announce_list)); |
@@ -19,15 +19,11 @@ discard block |
||
19 | 19 | // ------------------------------------------------------------------ |
20 | 20 | function flt_flyingFleetsSort($a, $b) { |
21 | 21 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
22 | - return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : |
|
23 | - // Если время - одинаковое, сравниваем события флотов |
|
22 | + return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
24 | 23 | // Если события - одинаковые, то флоты равны |
25 | - ($a['fleet_event'] == $b['fleet_event'] ? 0 : |
|
26 | - // Если события разные - первыми считаем прибывающие флоты |
|
27 | - ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : |
|
28 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
29 | - ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : |
|
30 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
24 | + ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
25 | + ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
26 | + ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
31 | 27 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
32 | 28 | ( |
33 | 29 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -45,13 +41,13 @@ discard block |
||
45 | 41 | $handler = fopen('event.log', 'a+'); |
46 | 42 | } |
47 | 43 | |
48 | - fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n"); |
|
44 | + fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n"); |
|
49 | 45 | } |
50 | 46 | |
51 | 47 | // ------------------------------------------------------------------ |
52 | 48 | function flt_flying_fleet_handler($skip_fleet_update = false) { |
53 | 49 | if (true) { |
54 | - if(!defined('IN_AJAX')) { |
|
50 | + if (!defined('IN_AJAX')) { |
|
55 | 51 | print('<div style="color: red; font-size: 300%">Fleet handler is disabled</div>'); |
56 | 52 | pdump('Fleet handler is disabled'); |
57 | 53 | } |
@@ -177,7 +173,7 @@ discard block |
||
177 | 173 | MT_EXPLORE => 'flt_mission_explore', |
178 | 174 | ); |
179 | 175 | foreach ($missions_used as $mission_id => $cork) { |
180 | - require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX); |
|
176 | + require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX); |
|
181 | 177 | } |
182 | 178 | |
183 | 179 | //log_file('Обработка миссий'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | define('INSTALL', false); |
11 | 11 | define('IN_ADMIN', true); |
12 | 12 | |
13 | -require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
13 | +require('../common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
14 | 14 | |
15 | 15 | if ($user['authlevel'] < 3) { |
16 | 16 | AdminMessage(classLocale::$lang['adm_err_denied']); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | foreach ($value as $interval_data) { |
112 | 112 | print("<tr>"); |
113 | 113 | print("<td>{$user_id}</td><td>{$user_record['username']}</td><td>{$interval_data[0]}</td><td>{$interval_data[1]}</td><td>{$interval_data[2]}</td>"); |
114 | - print("<td>" . date(FMT_DATE_TIME_SQL, $user_record['onlinetime']) . "</td>"); |
|
114 | + print("<td>".date(FMT_DATE_TIME_SQL, $user_record['onlinetime'])."</td>"); |
|
115 | 115 | print("</tr>"); |
116 | 116 | } |
117 | 117 | } |
@@ -45,8 +45,8 @@ |
||
45 | 45 | */ |
46 | 46 | protected function quoteStringAsFieldByRef(&$string) { |
47 | 47 | $string = $this->stringEscape($string); |
48 | - if ((string)$string && '*' != $string) { |
|
49 | - $string = '`' . $string . '`'; |
|
48 | + if ((string) $string && '*' != $string) { |
|
49 | + $string = '`'.$string.'`'; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return $this |
32 | 32 | */ |
33 | 33 | public function literal($value) { |
34 | - $this->literal = (string)$value; |
|
34 | + $this->literal = (string) $value; |
|
35 | 35 | |
36 | 36 | return $this; |
37 | 37 | } |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | $alias = $this->aliasFromField($functionName, $field); |
65 | 65 | } |
66 | 66 | |
67 | - $this->literal = strtoupper($functionName) . '(' . $this->quoteField($field) . ')'; |
|
67 | + $this->literal = strtoupper($functionName).'('.$this->quoteField($field).')'; |
|
68 | 68 | |
69 | 69 | if (self::SQL_LITERAL_ALIAS_NONE !== $alias && !empty($alias)) { |
70 | - $this->literal .= ' AS `' . $alias . '`'; |
|
70 | + $this->literal .= ' AS `'.$alias.'`'; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $this; |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | $alias = $this->aliasFromField($functionName, $field); |
125 | 125 | } |
126 | 126 | |
127 | - $this->literal = $this->quoteField($field) . ' IS NULL'; |
|
127 | + $this->literal = $this->quoteField($field).' IS NULL'; |
|
128 | 128 | |
129 | 129 | if (!empty($alias)) { |
130 | - $this->literal .= ' AS `' . $alias . '`'; |
|
130 | + $this->literal .= ' AS `'.$alias.'`'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | return $this; |