@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function report_render_rounds(&$template_result, UBE $ube) { |
27 | 27 | $round_count = $this->count(); |
28 | - for($round = 1; $round <= $round_count - 1; $round++) { |
|
28 | + for ($round = 1; $round <= $round_count - 1; $round++) { |
|
29 | 29 | $template_result['.']['round'][] = array( |
30 | 30 | 'NUMBER' => $round, |
31 | 31 | '.' => array( |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function sql_generate_unit_array(array &$sql_perform_ube_report_unit, $ube_report_id, UBEFleetList $UBEFleetList) { |
50 | 50 | $unit_sort_order = 1; |
51 | - foreach($this->_container as $round_number => $UBERound) { |
|
51 | + foreach ($this->_container as $round_number => $UBERound) { |
|
52 | 52 | $outer_prefix = array( |
53 | 53 | $ube_report_id, |
54 | 54 | $round_number, |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function db_load_round_list_from_report_row($report_row, UBE $ube) { |
68 | 68 | $query = doquery("SELECT * FROM {{ube_report_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_unit_id`"); |
69 | - while($report_unit_row = db_fetch($query)) { |
|
69 | + while ($report_unit_row = db_fetch($query)) { |
|
70 | 70 | $round_number = $report_unit_row['ube_report_unit_round']; |
71 | - if(!isset($this[$round_number])) { |
|
71 | + if (!isset($this[$round_number])) { |
|
72 | 72 | $this[$round_number] = new UBERound(); |
73 | 73 | $this[$round_number]->init_round_from_report_unit_row($report_unit_row); |
74 | 74 | } |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | * @version 2016-02-25 23:42:45 41a4.68 |
37 | 37 | */ |
38 | 38 | public function make_snapshot(UBEFleetList $UBEFleetList) { |
39 | - foreach($UBEFleetList->_container as $fleet_id => $UBEFleet) { |
|
40 | - foreach($UBEFleet->unit_list->_container as $UBEUnit) { |
|
39 | + foreach ($UBEFleetList->_container as $fleet_id => $UBEFleet) { |
|
40 | + foreach ($UBEFleet->unit_list->_container as $UBEUnit) { |
|
41 | 41 | $this->snapshot[$fleet_id][$UBEUnit->unitId] = new UBESnapshotUnit(); |
42 | 42 | $this->snapshot[$fleet_id][$UBEUnit->unitId]->init_from_UBEUnit($UBEUnit); |
43 | 43 | } |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @version 2016-02-25 23:42:45 41a4.68 |
54 | 54 | */ |
55 | 55 | public function sql_generate_unit_array(array &$sql_perform_ube_report_unit, &$unit_sort_order, UBEFleetList $UBEFleetList, array $outer_prefix) { |
56 | - foreach($this->snapshot as $fleet_id => $fleet_snapshot) { |
|
56 | + foreach ($this->snapshot as $fleet_id => $fleet_snapshot) { |
|
57 | 57 | $inner_prefix = array( |
58 | 58 | $UBEFleetList[$fleet_id]->owner_id, |
59 | 59 | $fleet_id, |
60 | 60 | ); |
61 | - foreach($fleet_snapshot as $unit_id => $unit_snapshot) { |
|
61 | + foreach ($fleet_snapshot as $unit_id => $unit_snapshot) { |
|
62 | 62 | $sql_perform_ube_report_unit[] = array_merge( |
63 | 63 | $outer_prefix, |
64 | 64 | $inner_prefix, |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | UBE_PLAYER_IS_DEFENDER => array(), |
102 | 102 | ); |
103 | 103 | |
104 | - foreach($this->snapshot as $fleet_id => $fleet_snapshot) { |
|
104 | + foreach ($this->snapshot as $fleet_id => $fleet_snapshot) { |
|
105 | 105 | $fleet_owner_id = $ube->fleet_list[$fleet_id]->owner_id; |
106 | 106 | $planet_ube_row = $ube->fleet_list[$fleet_id]->UBE_PLANET; |
107 | 107 | |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | 'PLAYER_NAME' => htmlentities($ube->players[$fleet_owner_id]->name, ENT_COMPAT, 'UTF-8'), |
112 | 112 | ); |
113 | 113 | |
114 | - if(is_array($planet_ube_row)) { |
|
114 | + if (is_array($planet_ube_row)) { |
|
115 | 115 | $template_fleet += $planet_ube_row; |
116 | 116 | $template_fleet[PLANET_NAME] = $template_fleet[PLANET_NAME] ? htmlentities($template_fleet[PLANET_NAME], ENT_COMPAT, 'UTF-8') : ''; |
117 | 117 | $template_fleet['PLANET_TYPE_TEXT'] = $lang['sys_planet_type_sh'][$template_fleet['PLANET_TYPE']]; |
118 | 118 | } |
119 | 119 | |
120 | - foreach($fleet_snapshot as $unit_id => $unit_snapshot) { |
|
120 | + foreach ($fleet_snapshot as $unit_id => $unit_snapshot) { |
|
121 | 121 | $template_fleet['.']['ship'][] = $unit_snapshot->report_render_unit($prevSnapshot[$fleet_id][$unit_id]); |
122 | 122 | } |
123 | 123 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * @version 41a6.16 |
24 | 24 | */ |
25 | 25 | protected function db_load_player_by_id($player_id) { |
26 | - if(isset($this[$player_id])) { |
|
26 | + if (isset($this[$player_id])) { |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 |
@@ -154,15 +154,15 @@ discard block |
||
154 | 154 | * @param string $group_name |
155 | 155 | */ |
156 | 156 | public static function _init($group_name = '') { |
157 | - if(static::$_is_static_init) { |
|
157 | + if (static::$_is_static_init) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | - if($group_name) { |
|
161 | + if ($group_name) { |
|
162 | 162 | static::$_sn_group_name = $group_name; |
163 | 163 | } |
164 | 164 | |
165 | - if(static::$_sn_group_name) { |
|
165 | + if (static::$_sn_group_name) { |
|
166 | 166 | static::$_group_unit_id_list = sn_get_groups(static::$_sn_group_name); |
167 | 167 | empty(static::$_group_unit_id_list) ? static::$_group_unit_id_list = array() : false; |
168 | 168 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | // TODO - Reset combat stats?? |
188 | 188 | $this->_unitId = $unitId; |
189 | 189 | |
190 | - if($this->_unitId) { |
|
190 | + if ($this->_unitId) { |
|
191 | 191 | $this->info = get_unit_param($this->_unitId); |
192 | 192 | $this->_type = $this->info[P_UNIT_TYPE]; |
193 | 193 | } else { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | protected function setCount($value) { |
200 | 200 | // TODO - Reset combat stats?? |
201 | - if($value < 0) { |
|
201 | + if ($value < 0) { |
|
202 | 202 | classSupernova::$debug->error('Can not set Unit::$count to negative value'); |
203 | 203 | } |
204 | 204 | $this->_count = $value; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | - * @param $ube_report_id |
|
153 | + * @param integer $ube_report_id |
|
154 | 154 | * |
155 | 155 | * @return array |
156 | 156 | * |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | |
290 | 290 | /** |
291 | - * @param $ube_report_id |
|
291 | + * @param integer $ube_report_id |
|
292 | 292 | * |
293 | 293 | * @return array |
294 | 294 | */ |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | // Рендерит таблицу общего результата боя |
337 | 337 | /** |
338 | 338 | * @param $array |
339 | - * @param $lang_header_index |
|
339 | + * @param string $lang_header_index |
|
340 | 340 | * |
341 | 341 | * @return array |
342 | 342 | */ |
@@ -362,6 +362,9 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | |
365 | + /** |
|
366 | + * @param integer $ube_report_id |
|
367 | + */ |
|
365 | 368 | public function sql_generate_outcome_unit_array(&$sql_perform_report_unit, $ube_report_id) { |
366 | 369 | $fleet_id = $this->db_id; |
367 | 370 | |
@@ -468,6 +471,10 @@ discard block |
||
468 | 471 | $this->fleet_capacity -= $fleet_total_resources; |
469 | 472 | } |
470 | 473 | |
474 | + /** |
|
475 | + * @param integer $is_small_fleet_recce |
|
476 | + * @param integer $reapers_status |
|
477 | + */ |
|
471 | 478 | public function db_save_combat_result_fleet($is_small_fleet_recce, $reapers_status) { |
472 | 479 | $ship_count_initial = $this->unit_list->unitsCount(); |
473 | 480 | $ship_count_lost = $this->unit_list->unitCountLost(); |
@@ -535,7 +542,7 @@ discard block |
||
535 | 542 | |
536 | 543 | /** |
537 | 544 | * @param UBEFleetList $fleet_list |
538 | - * @param $is_simulator |
|
545 | + * @param boolean $is_simulator |
|
539 | 546 | * |
540 | 547 | * @version 2016-02-25 23:42:45 41a4.68 |
541 | 548 | */ |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | $this->owner_id, |
163 | 163 | $this->db_id, |
164 | 164 | |
165 | - (float)$this->UBE_PLANET[PLANET_ID], |
|
166 | - "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'", |
|
167 | - (int)$this->UBE_PLANET[PLANET_GALAXY], |
|
168 | - (int)$this->UBE_PLANET[PLANET_SYSTEM], |
|
169 | - (int)$this->UBE_PLANET[PLANET_PLANET], |
|
170 | - (int)$this->UBE_PLANET[PLANET_TYPE], |
|
171 | - |
|
172 | - (float)$this->resource_list[RES_METAL], |
|
173 | - (float)$this->resource_list[RES_CRYSTAL], |
|
174 | - (float)$this->resource_list[RES_DEUTERIUM], |
|
175 | - |
|
176 | - (float)$this->fleet_bonus->calcBonus(P_ATTACK), |
|
177 | - (float)$this->fleet_bonus->calcBonus(P_SHIELD), |
|
178 | - (float)$this->fleet_bonus->calcBonus(P_ARMOR), |
|
165 | + (float) $this->UBE_PLANET[PLANET_ID], |
|
166 | + "'".db_escape($this->UBE_PLANET[PLANET_NAME])."'", |
|
167 | + (int) $this->UBE_PLANET[PLANET_GALAXY], |
|
168 | + (int) $this->UBE_PLANET[PLANET_SYSTEM], |
|
169 | + (int) $this->UBE_PLANET[PLANET_PLANET], |
|
170 | + (int) $this->UBE_PLANET[PLANET_TYPE], |
|
171 | + |
|
172 | + (float) $this->resource_list[RES_METAL], |
|
173 | + (float) $this->resource_list[RES_CRYSTAL], |
|
174 | + (float) $this->resource_list[RES_DEUTERIUM], |
|
175 | + |
|
176 | + (float) $this->fleet_bonus->calcBonus(P_ATTACK), |
|
177 | + (float) $this->fleet_bonus->calcBonus(P_SHIELD), |
|
178 | + (float) $this->fleet_bonus->calcBonus(P_ARMOR), |
|
179 | 179 | ); |
180 | 180 | } |
181 | 181 | |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | $this->owner_id = $objFleet->playerOwnerId; |
190 | 190 | $this->group_id = $objFleet->group_id; |
191 | 191 | |
192 | - foreach($objFleet->shipsIterator() as $unit_id => $unit) { |
|
193 | - if(!$unit->count) { |
|
192 | + foreach ($objFleet->shipsIterator() as $unit_id => $unit) { |
|
193 | + if (!$unit->count) { |
|
194 | 194 | continue; |
195 | 195 | } |
196 | 196 | |
197 | 197 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
198 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
198 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
199 | 199 | $this->unit_list->unitAdjustCount($unit_id, $unit->count); |
200 | 200 | } |
201 | 201 | } |
@@ -231,13 +231,13 @@ discard block |
||
231 | 231 | // } |
232 | 232 | // } |
233 | 233 | |
234 | - foreach($sn_group_combat as $unit_id) { |
|
235 | - if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
234 | + foreach ($sn_group_combat as $unit_id) { |
|
235 | + if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
236 | 236 | $this->unit_list->unitAdjustCount($unit_id, $unit_count); |
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
240 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
241 | 241 | $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id)); |
242 | 242 | } |
243 | 243 | |
@@ -296,27 +296,27 @@ discard block |
||
296 | 296 | $ube_report_id, |
297 | 297 | $this->db_id, |
298 | 298 | |
299 | - (float)$this->resources_lost_on_units[RES_METAL], |
|
300 | - (float)$this->resources_lost_on_units[RES_CRYSTAL], |
|
301 | - (float)$this->resources_lost_on_units[RES_DEUTERIUM], |
|
302 | - (float)$this->cargo_dropped[RES_METAL], |
|
303 | - (float)$this->cargo_dropped[RES_CRYSTAL], |
|
304 | - (float)$this->cargo_dropped[RES_DEUTERIUM], |
|
305 | - (float)$this->resources_looted[RES_METAL], |
|
306 | - (float)$this->resources_looted[RES_CRYSTAL], |
|
307 | - (float)$this->resources_looted[RES_DEUTERIUM], |
|
308 | - (float)$this->resources_lost_in_metal[RES_METAL], |
|
299 | + (float) $this->resources_lost_on_units[RES_METAL], |
|
300 | + (float) $this->resources_lost_on_units[RES_CRYSTAL], |
|
301 | + (float) $this->resources_lost_on_units[RES_DEUTERIUM], |
|
302 | + (float) $this->cargo_dropped[RES_METAL], |
|
303 | + (float) $this->cargo_dropped[RES_CRYSTAL], |
|
304 | + (float) $this->cargo_dropped[RES_DEUTERIUM], |
|
305 | + (float) $this->resources_looted[RES_METAL], |
|
306 | + (float) $this->resources_looted[RES_CRYSTAL], |
|
307 | + (float) $this->resources_looted[RES_DEUTERIUM], |
|
308 | + (float) $this->resources_lost_in_metal[RES_METAL], |
|
309 | 309 | ); |
310 | 310 | } |
311 | 311 | |
312 | 312 | public function report_render_outcome_side_fleet() { |
313 | 313 | $UBE_DEFENCE_RESTORE = array(); |
314 | 314 | $UBE_UNITS_LOST = array(); |
315 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
316 | - if($UBEUnit->units_restored) { |
|
315 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
316 | + if ($UBEUnit->units_restored) { |
|
317 | 317 | $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored; |
318 | 318 | } |
319 | - if($UBEUnit->units_lost) { |
|
319 | + if ($UBEUnit->units_lost) { |
|
320 | 320 | $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost; |
321 | 321 | } |
322 | 322 | } |
@@ -341,16 +341,16 @@ discard block |
||
341 | 341 | */ |
342 | 342 | protected function report_render_outcome_side_fleet_line(&$array, $lang_header_index) { |
343 | 343 | $result = array(); |
344 | - if(!empty($array)) { |
|
345 | - foreach($array as $unit_id => $unit_count) { |
|
346 | - if($unit_count) { |
|
344 | + if (!empty($array)) { |
|
345 | + foreach ($array as $unit_id => $unit_count) { |
|
346 | + if ($unit_count) { |
|
347 | 347 | $result[] = array( |
348 | 348 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
349 | 349 | 'LOSS' => pretty_number($unit_count), |
350 | 350 | ); |
351 | 351 | } |
352 | 352 | } |
353 | - if($lang_header_index && count($result)) { |
|
353 | + if ($lang_header_index && count($result)) { |
|
354 | 354 | array_unshift($result, array('NAME' => classLocale::$lang[$lang_header_index])); |
355 | 355 | } |
356 | 356 | } |
@@ -363,16 +363,16 @@ discard block |
||
363 | 363 | $fleet_id = $this->db_id; |
364 | 364 | |
365 | 365 | $unit_sort_order = 0; |
366 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
367 | - if($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
366 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
367 | + if ($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
368 | 368 | $unit_sort_order++; |
369 | 369 | $sql_perform_report_unit[] = array( |
370 | 370 | $ube_report_id, |
371 | 371 | $fleet_id, |
372 | 372 | |
373 | 373 | $UBEUnit->unitId, |
374 | - (float)$UBEUnit->units_restored, |
|
375 | - (float)$UBEUnit->units_lost, |
|
374 | + (float) $UBEUnit->units_restored, |
|
375 | + (float) $UBEUnit->units_lost, |
|
376 | 376 | |
377 | 377 | $unit_sort_order, |
378 | 378 | ); |
@@ -388,9 +388,9 @@ discard block |
||
388 | 388 | function ube_combat_result_calculate_resources() { |
389 | 389 | $resource_delta_fleet = array(); |
390 | 390 | // Если во флоте остались юниты или это планета - генерируем изменение ресурсов |
391 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
392 | - $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id]; |
|
393 | - if($resource_change) { |
|
391 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
392 | + $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id]; |
|
393 | + if ($resource_change) { |
|
394 | 394 | $resource_delta_fleet[$resource_id] = -($resource_change); |
395 | 395 | } |
396 | 396 | } |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | ); |
424 | 424 | |
425 | 425 | $this->fleet_capacity = 0; |
426 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
426 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
427 | 427 | $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount(); |
428 | 428 | |
429 | - if($UBEUnit->units_lost) { |
|
430 | - foreach($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
431 | - if(!$unit_resource_price) { |
|
429 | + if ($UBEUnit->units_lost) { |
|
430 | + foreach ($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
431 | + if (!$unit_resource_price) { |
|
432 | 432 | continue; |
433 | 433 | } |
434 | 434 | |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $this->resources_lost_on_units[$resource_id] += $resources_lost; |
437 | 437 | // Если это корабль - прибавляем потери к обломкам на орбите |
438 | 438 | // TODO - опция выбрасывания обороны в обломки |
439 | - if($UBEUnit->getType() == UNIT_SHIPS) { |
|
439 | + if ($UBEUnit->getType() == UNIT_SHIPS) { |
|
440 | 440 | $this->resources_lost_on_ships[$resource_id] += $resources_lost; |
441 | 441 | } |
442 | 442 | } |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | |
449 | 449 | // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй |
450 | 450 | // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются |
451 | - if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
451 | + if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
452 | 452 | $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена |
453 | - foreach($this->resource_list as $resource_id => &$resource_amount) { |
|
453 | + foreach ($this->resource_list as $resource_id => &$resource_amount) { |
|
454 | 454 | // Не просчитываем ресурсы, которых нет на борту кораблей флота |
455 | - if(!$resource_amount) { |
|
455 | + if (!$resource_amount) { |
|
456 | 456 | continue; |
457 | 457 | } |
458 | 458 | |
@@ -473,19 +473,19 @@ discard block |
||
473 | 473 | $objFleet2->setDbId($this->db_id); |
474 | 474 | |
475 | 475 | // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли |
476 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
476 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
477 | 477 | $objFleet2->dbDelete(); |
478 | - } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
478 | + } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
479 | 479 | $objFleet2->dbDelete(); |
480 | 480 | } else { |
481 | - if($ship_count_lost) { |
|
481 | + if ($ship_count_lost) { |
|
482 | 482 | // Просматриваем результаты изменения флотов |
483 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
483 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
484 | 484 | // Перебираем аутком на случай восстановления юнитов |
485 | 485 | // if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) { |
486 | 486 | // $fleet_real_array[$UBEUnit->unitId] = $units_left; |
487 | 487 | // }; |
488 | - if(floatval($UBEUnit->units_lost) != 0) { |
|
488 | + if (floatval($UBEUnit->units_lost) != 0) { |
|
489 | 489 | $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost)); |
490 | 490 | }; |
491 | 491 | } |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | $objFleet2->resourcesAdjust($resource_delta_fleet); |
496 | 496 | |
497 | 497 | // Если защитник и не РМФ - отправляем флот назад |
498 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
498 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
499 | 499 | $objFleet2->markReturned(); |
500 | 500 | } |
501 | 501 | $objFleet2->dbSave(); |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | public function calculate_unit_partial_data(UBEASA $side_ASA) { |
526 | 526 | $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor(); |
527 | 527 | |
528 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
528 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
529 | 529 | $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor(); |
530 | 530 | } |
531 | 531 | } |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | * @version 2016-02-25 23:42:45 41a4.68 |
538 | 538 | */ |
539 | 539 | public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) { |
540 | - foreach($fleet_list->_container as $defending_fleet) { |
|
540 | + foreach ($fleet_list->_container as $defending_fleet) { |
|
541 | 541 | // Не атакуются флоты на своей стороне |
542 | - if($this->is_attacker == $defending_fleet->is_attacker) { |
|
542 | + if ($this->is_attacker == $defending_fleet->is_attacker) { |
|
543 | 543 | continue; |
544 | 544 | } |
545 | 545 | $this->attack_fleet($defending_fleet, $is_simulator); |
@@ -555,12 +555,12 @@ discard block |
||
555 | 555 | public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) { |
556 | 556 | UBEDebug::unit_dump_header(); |
557 | 557 | |
558 | - foreach($this->unit_list->_container as $attacking_unit_pool) { |
|
558 | + foreach ($this->unit_list->_container as $attacking_unit_pool) { |
|
559 | 559 | UBEDebug::unit_dump($attacking_unit_pool, 'attacker'); |
560 | 560 | |
561 | 561 | // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..." |
562 | - foreach($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
563 | - if($defending_unit_pool->isEmpty()) { |
|
562 | + foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
563 | + if ($defending_unit_pool->isEmpty()) { |
|
564 | 564 | continue; |
565 | 565 | } |
566 | 566 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * |
11 | 11 | * @param Fleet $objFleet |
12 | 12 | * @param bool $start |
13 | - * @param null $result |
|
13 | + * @param integer $result |
|
14 | 14 | * |
15 | 15 | * @return mixed |
16 | 16 | */ |
@@ -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('Обработка миссий'); |
@@ -286,7 +286,6 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * Функция пытается залогиниться по всем известным провайдерам |
288 | 288 | * |
289 | - * @param null $result |
|
290 | 289 | */ |
291 | 290 | public function login() { |
292 | 291 | if(empty(sn_module::$sn_module_list['auth'])) { |
@@ -823,10 +822,17 @@ discard block |
||
823 | 822 | |
824 | 823 | // OK v4.5 |
825 | 824 | // TODO - REMEMBER_ME |
825 | + |
|
826 | + /** |
|
827 | + * @param integer $period |
|
828 | + */ |
|
826 | 829 | protected static function cookie_set($value, $impersonate = false, $period = null) { |
827 | 830 | sn_setcookie($impersonate ? SN_COOKIE_U_I : SN_COOKIE_U, $value, $period === null ? SN_TIME_NOW + PERIOD_YEAR : $period, SN_ROOT_RELATIVE); |
828 | 831 | } |
829 | 832 | |
833 | + /** |
|
834 | + * @param string $message |
|
835 | + */ |
|
830 | 836 | protected static function flog($message, $die = false) { |
831 | 837 | if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
832 | 838 | return; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | // Проверить наличие такого имени в истории имён |
225 | 225 | do { |
226 | 226 | sn_db_transaction_rollback(); |
227 | - $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
227 | + $this->player_suggested_name = 'Emperor '.mt_rand($max_user_id + 1, $max_user_id + 1000); |
|
228 | 228 | sn_db_transaction_start(); |
229 | 229 | } while (db_player_name_exists($this->player_suggested_name)); |
230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | if ($player_name_submitted) { |
234 | 234 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
235 | 235 | if ($this->register_status == LOGIN_SUCCESS) { |
236 | - sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
|
236 | + sys_redirect(SN_ROOT_VIRTUAL.'overview.php'); |
|
237 | 237 | } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
238 | 238 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
239 | 239 | } |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | ); |
260 | 260 | |
261 | 261 | if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
262 | - $prohibited_characters = array_map(function ($value) { |
|
263 | - return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
|
262 | + $prohibited_characters = array_map(function($value) { |
|
263 | + return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'"; |
|
264 | 264 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
265 | 265 | $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters); |
266 | 266 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | foreach ($this->providers as $provider_id => $provider) { |
309 | 309 | $login_status = $provider->login(); // OK v4.5 |
310 | - self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
310 | + self::flog(($provider->manifest['name'].'->'.'login_try - ').(empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
|
311 | 311 | if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
312 | 312 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
313 | 313 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | if (!$this->is_player_register) { |
348 | 348 | // Нет - отправляем на процесс регистрации |
349 | 349 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
350 | - sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
|
350 | + sys_redirect(SN_ROOT_VIRTUAL.'index.php?page=player_register&player_register=1'.($partner_id ? '&id_ref='.$partner_id : '')); |
|
351 | 351 | } |
352 | 352 | } else { |
353 | 353 | // Да, есть доступные игроки, которые так же прописаны в базе |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | |
409 | 409 | if ($redirect === true) { |
410 | - sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
410 | + sys_redirect(SN_ROOT_RELATIVE.(empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
|
411 | 411 | } elseif ($redirect !== false) { |
412 | 412 | sys_redirect($redirect); |
413 | 413 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | $user['vacation'] = SN_TIME_NOW; |
703 | 703 | } |
704 | 704 | |
705 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
705 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
706 | 706 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
707 | 707 | |
708 | 708 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -710,9 +710,9 @@ discard block |
||
710 | 710 | |
711 | 711 | $proxy_safe = static::$db->db_escape(self::$device->ip_v4_proxy_chain); |
712 | 712 | |
713 | - DBStaticUser::db_user_set_by_id($user['id'], "`onlinetime` = " . SN_TIME_NOW . ", |
|
714 | - `banaday` = " . static::$db->db_escape($user['banaday']) . ", `vacation` = " . static::$db->db_escape($user['vacation']) . ", |
|
715 | - `user_lastip` = '" . static::$db->db_escape($user['user_lastip']) . "', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = " . self::$device->browser_id |
|
713 | + DBStaticUser::db_user_set_by_id($user['id'], "`onlinetime` = ".SN_TIME_NOW.", |
|
714 | + `banaday` = " . static::$db->db_escape($user['banaday']).", `vacation` = ".static::$db->db_escape($user['vacation']).", |
|
715 | + `user_lastip` = '" . static::$db->db_escape($user['user_lastip'])."', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = ".self::$device->browser_id |
|
716 | 716 | ); |
717 | 717 | } |
718 | 718 | |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | */ |
806 | 806 | // OK v4 |
807 | 807 | public static function password_encode($password, $salt) { |
808 | - return md5($password . $salt); |
|
808 | + return md5($password.$salt); |
|
809 | 809 | } |
810 | 810 | /** |
811 | 811 | * Генерирует соль |
@@ -831,10 +831,10 @@ discard block |
||
831 | 831 | } |
832 | 832 | list($called, $caller) = debug_backtrace(false); |
833 | 833 | $caller_name = |
834 | - (!empty($caller['class']) ? $caller['class'] : '') . |
|
835 | - (!empty($caller['type']) ? $caller['type'] : '') . |
|
836 | - (!empty($caller['function']) ? $caller['function'] : '') . |
|
837 | - (!empty($called['line']) ? ':' . $called['line'] : ''); |
|
834 | + (!empty($caller['class']) ? $caller['class'] : ''). |
|
835 | + (!empty($caller['type']) ? $caller['type'] : ''). |
|
836 | + (!empty($caller['function']) ? $caller['function'] : ''). |
|
837 | + (!empty($called['line']) ? ':'.$called['line'] : ''); |
|
838 | 838 | |
839 | 839 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
840 | 840 | |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | if ($die) { |
843 | 843 | // pdump($caller); |
844 | 844 | // pdump(debug_backtrace(false)); |
845 | - $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
845 | + $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
|
846 | 846 | } |
847 | 847 | } |
848 | 848 |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | |
22 | 22 | function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) { |
23 | 23 | $unit_list = sn_get_groups($mode); |
24 | - if(empty($unit_list)) { |
|
24 | + if (empty($unit_list)) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | $name_list = classLocale::$lang['tech']; |
28 | 28 | |
29 | - foreach($unit_list as $unit_id) { |
|
29 | + foreach ($unit_list as $unit_id) { |
|
30 | 30 | $template->assign_block_vars('unit', array( |
31 | 31 | 'ID' => $unit_id, |
32 | 32 | 'NAME' => $name_list[$unit_id], |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { return sn_function_call(__FUNCTION__, array($unit_id, $unit_amount, $mode)); } |
40 | 40 | |
41 | 41 | function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { |
42 | - if($unit_amount && in_array($unit_id, sn_get_groups($mode))) { |
|
42 | + if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) { |
|
43 | 43 | $unit_amount = round($unit_amount); |
44 | 44 | $unit_name = get_unit_param($unit_id, P_NAME); |
45 | 45 | $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))"; |
@@ -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'); |
@@ -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(), |