@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | public static function cache_clear($location_type, $hard = true) { |
237 | 237 | if ($hard && !empty(static::$data[$location_type])) { |
238 | 238 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
239 | - array_walk(static::$data[$location_type], function (&$item) { $item = null; }); |
|
239 | + array_walk(static::$data[$location_type], function(&$item) { $item = null; }); |
|
240 | 240 | } |
241 | 241 | static::$locator[$location_type] = array(); |
242 | 242 | static::$queries[$location_type] = array(); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | |
355 | 355 | if (!empty($error_msg)) { |
356 | 356 | // TODO - Убрать позже |
357 | - print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
|
357 | + print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>'); |
|
358 | 358 | $backtrace = debug_backtrace(); |
359 | 359 | array_shift($backtrace); |
360 | 360 | pdump($backtrace); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | public static function db_transaction_start($level = '') { |
368 | 368 | static::db_transaction_check(null); |
369 | 369 | |
370 | - $level ? doquery('SET TRANSACTION ISOLATION LEVEL ' . $level) : false; |
|
370 | + $level ? doquery('SET TRANSACTION ISOLATION LEVEL '.$level) : false; |
|
371 | 371 | |
372 | 372 | static::$transaction_id++; |
373 | 373 | doquery('START TRANSACTION'); |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | public static function db_lock_tables($tables) { |
428 | 428 | $tables = is_array($tables) ? $tables : array($tables => ''); |
429 | 429 | foreach ($tables as $table_name => $condition) { |
430 | - self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
430 | + self::$db->doquery("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | $query = static::db_query( |
482 | 482 | "SELECT |
483 | 483 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
484 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
485 | - ($filter ? ' WHERE ' . $filter : '') . |
|
484 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
485 | + ($filter ? ' WHERE '.$filter : ''). |
|
486 | 486 | ($fetch ? ' LIMIT 1' : ''), false, true); |
487 | 487 | |
488 | 488 | while ($row = db_fetch($query)) { |
@@ -495,13 +495,13 @@ discard block |
||
495 | 495 | if ($indexes_str = implode(',', $parent_id_list)) { |
496 | 496 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
497 | 497 | static::db_get_record_list($owner_location_type, |
498 | - $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
498 | + $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
503 | 503 | $query = static::db_query( |
504 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
504 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
505 | 505 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
506 | 506 | ); |
507 | 507 | while ($row = db_fetch($query)) { |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | $condition = trim($condition); |
568 | 568 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
569 | 569 | |
570 | - if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
570 | + if ($result = static::db_query("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) { |
|
571 | 571 | |
572 | 572 | if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
573 | 573 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | |
729 | 729 | // TODO переписать |
730 | 730 | $user = static::db_query( |
731 | - "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
731 | + "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'" |
|
732 | 732 | , true); |
733 | 733 | static::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы |
734 | 734 | } |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | |
818 | 818 | $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id]; |
819 | 819 | if (!isset($query_cache)) { |
820 | - $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions()); |
|
820 | + $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".static::db_unit_time_restrictions()); |
|
821 | 821 | if (is_array($got_data)) { |
822 | 822 | foreach ($got_data as $unit_id => $unit_data) { |
823 | 823 | $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | if ($que_type == QUE_RESEARCH || $planet_id === null) { |
879 | 879 | $query[] = "`que_planet_id` IS NULL"; |
880 | 880 | } elseif ($planet_id) { |
881 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
881 | + $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
882 | 882 | } |
883 | 883 | if ($que_type) { |
884 | 884 | $query[] = "`que_type` = {$que_type}"; |
@@ -999,13 +999,13 @@ discard block |
||
999 | 999 | $condition = "`{$field_name}` = "; |
1000 | 1000 | $value = ''; |
1001 | 1001 | if ($field_data['delta']) { |
1002 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
1002 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
1003 | 1003 | } elseif ($field_data['set']) { |
1004 | 1004 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | if ($value) { |
1008 | - $fields[] = $condition . $value; |
|
1008 | + $fields[] = $condition.$value; |
|
1009 | 1009 | } |
1010 | 1010 | } |
1011 | 1011 | $conditions[P_FIELDS_STR] = implode(',', $fields); |
@@ -1019,9 +1019,7 @@ discard block |
||
1019 | 1019 | // Простое условие - $field_id = $field_value |
1020 | 1020 | if (is_string($field_id)) { |
1021 | 1021 | $field_value = |
1022 | - $field_value === null ? 'NULL' : |
|
1023 | - (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
1024 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
1022 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
1025 | 1023 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
1026 | 1024 | } else { |
1027 | 1025 | die('Неподдерживаемый тип условия'); |
@@ -1048,7 +1046,7 @@ discard block |
||
1048 | 1046 | die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile'); |
1049 | 1047 | } |
1050 | 1048 | |
1051 | - $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]); |
|
1049 | + $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]); |
|
1052 | 1050 | } |
1053 | 1051 | |
1054 | 1052 | public static function db_changeset_apply($db_changeset, $flush_delayed = false) { |
@@ -1146,7 +1144,7 @@ discard block |
||
1146 | 1144 | ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
1147 | 1145 | if (@get_magic_quotes_gpc()) { |
1148 | 1146 | $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
1149 | - array_walk_recursive($gpcr, function (&$value, $key) { |
|
1147 | + array_walk_recursive($gpcr, function(&$value, $key) { |
|
1150 | 1148 | $value = stripslashes($value); |
1151 | 1149 | }); |
1152 | 1150 | } |
@@ -1160,7 +1158,7 @@ discard block |
||
1160 | 1158 | public static function init_3_load_config_file() { |
1161 | 1159 | $dbsettings = array(); |
1162 | 1160 | |
1163 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
1161 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
1164 | 1162 | self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix']; |
1165 | 1163 | self::$db_name = $dbsettings['name']; |
1166 | 1164 | self::$sn_secret_word = $dbsettings['secretword']; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | //pdump($checkResult, $condition); |
60 | 60 | |
61 | 61 | if (is_array($action)) { |
62 | - if(!empty($action[$checkResult])) { |
|
62 | + if (!empty($action[$checkResult])) { |
|
63 | 63 | $action = $action[$checkResult]; |
64 | 64 | } else { |
65 | 65 | continue; |
@@ -882,8 +882,8 @@ discard block |
||
882 | 882 | */ |
883 | 883 | protected function checkACSInvited() { |
884 | 884 | $playersInvited = !empty($this->fleet->acs['eingeladen']) ? explode(',', $this->fleet->acs['eingeladen']) : array(); |
885 | - foreach($playersInvited as $playerId) { |
|
886 | - if(intval($playerId) == $this->fleet->dbOwnerRow['id']) { |
|
885 | + foreach ($playersInvited as $playerId) { |
|
886 | + if (intval($playerId) == $this->fleet->dbOwnerRow['id']) { |
|
887 | 887 | return true; |
888 | 888 | } |
889 | 889 | } |
@@ -970,9 +970,9 @@ discard block |
||
970 | 970 | |
971 | 971 | // Retrieving flying fleets |
972 | 972 | $objFleetsBashing = FleetList::dbGetFleetListBashing($user['id'], $this->fleet->dbTargetRow); |
973 | - foreach($objFleetsBashing->_container as $fleetBashing) { |
|
973 | + foreach ($objFleetsBashing->_container as $fleetBashing) { |
|
974 | 974 | // Checking for ACS - each ACS count only once |
975 | - if($fleetBashing->group_id) { |
|
975 | + if ($fleetBashing->group_id) { |
|
976 | 976 | $bashing_list["{$user['id']}_{$fleetBashing->group_id}"] = $fleetBashing->time_arrive_to_target; |
977 | 977 | } else { |
978 | 978 | $bashing_list[] = $fleetBashing->time_arrive_to_target; |
@@ -980,12 +980,12 @@ discard block |
||
980 | 980 | } |
981 | 981 | |
982 | 982 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done |
983 | - if($this->fleet->mission_type == MT_ACS && $bashing_list["{$user['id']}_{$this->fleet->group_id}"]) { |
|
983 | + if ($this->fleet->mission_type == MT_ACS && $bashing_list["{$user['id']}_{$this->fleet->group_id}"]) { |
|
984 | 984 | return true; |
985 | 985 | } |
986 | 986 | |
987 | 987 | $query = db_bashing_list_get($user, $this->fleet->dbTargetRow, $time_limit); |
988 | - while($bashing_row = db_fetch($query)) { |
|
988 | + while ($bashing_row = db_fetch($query)) { |
|
989 | 989 | $bashing_list[] = $bashing_row['bashing_time']; |
990 | 990 | } |
991 | 991 | |
@@ -994,9 +994,9 @@ discard block |
||
994 | 994 | $last_attack = 0; |
995 | 995 | $wave = 0; |
996 | 996 | $attack = 1; |
997 | - foreach($bashing_list as &$bash_time) { |
|
997 | + foreach ($bashing_list as &$bash_time) { |
|
998 | 998 | $attack++; |
999 | - if( |
|
999 | + if ( |
|
1000 | 1000 | $bash_time - $last_attack > classSupernova::$config->fleet_bashing_interval |
1001 | 1001 | || |
1002 | 1002 | $attack > classSupernova::$config->fleet_bashing_attacks |
@@ -10,76 +10,76 @@ discard block |
||
10 | 10 | * @copyright 2008 By Chlorel for XNova |
11 | 11 | */ |
12 | 12 | |
13 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
13 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
14 | 14 | |
15 | 15 | lng_include('fleet'); |
16 | 16 | |
17 | -if($TargetPlanet = sys_get_param_id('jmpto')) |
|
17 | +if ($TargetPlanet = sys_get_param_id('jmpto')) |
|
18 | 18 | { |
19 | 19 | sn_db_transaction_start(); |
20 | 20 | DBStaticUser::db_user_by_id($user['id'], true, 'id'); |
21 | 21 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
22 | - if(!($NextJumpTime = uni_get_time_to_jump($planetrow))) |
|
22 | + if (!($NextJumpTime = uni_get_time_to_jump($planetrow))) |
|
23 | 23 | { |
24 | 24 | $TargetGate = DBStaticPlanet::db_planet_by_id($TargetPlanet, true, '`id`, `last_jump_time`'); |
25 | - if(mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0) |
|
25 | + if (mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0) |
|
26 | 26 | { |
27 | - $NextDestTime = uni_get_time_to_jump ( $TargetGate ); |
|
28 | - if(!$NextDestTime) |
|
27 | + $NextDestTime = uni_get_time_to_jump($TargetGate); |
|
28 | + if (!$NextDestTime) |
|
29 | 29 | { |
30 | 30 | // $SubQueryOri = ""; |
31 | 31 | // $SubQueryDes = ""; |
32 | 32 | $ship_list = sys_get_param('ships'); |
33 | 33 | $db_changeset = array(); |
34 | - foreach($ship_list as $ship_id => $ship_count) |
|
34 | + foreach ($ship_list as $ship_id => $ship_count) |
|
35 | 35 | { |
36 | - if(!in_array($ship_id, sn_get_groups('fleet'))) |
|
36 | + if (!in_array($ship_id, sn_get_groups('fleet'))) |
|
37 | 37 | { |
38 | 38 | continue; |
39 | 39 | } |
40 | 40 | |
41 | 41 | $ship_count = max(0, min(floor($ship_count), mrc_get_level($user, $planetrow, $ship_id))); |
42 | - if($ship_count) |
|
42 | + if ($ship_count) |
|
43 | 43 | { |
44 | 44 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, -$ship_count, $user, $planetrow['id']); |
45 | 45 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $TargetGate['id']); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | // Dit monsieur, y avait quelque chose a envoyer ??? |
49 | - if(!empty($db_changeset)) |
|
49 | + if (!empty($db_changeset)) |
|
50 | 50 | { |
51 | - DBStaticPlanet::db_planet_set_by_id($TargetGate['id'], "`last_jump_time` = " . SN_TIME_NOW . ""); |
|
52 | - DBStaticPlanet::db_planet_set_by_id($planetrow['id'], "`last_jump_time` = " . SN_TIME_NOW . ""); |
|
51 | + DBStaticPlanet::db_planet_set_by_id($TargetGate['id'], "`last_jump_time` = ".SN_TIME_NOW.""); |
|
52 | + DBStaticPlanet::db_planet_set_by_id($planetrow['id'], "`last_jump_time` = ".SN_TIME_NOW.""); |
|
53 | 53 | db_changeset_apply($db_changeset); |
54 | 54 | |
55 | 55 | DBStaticUser::db_user_set_by_id($user['id'], "`current_planet` = '{$TargetGate['id']}'"); |
56 | 56 | |
57 | 57 | $planetrow['last_jump_time'] = SN_TIME_NOW; |
58 | - $RetMessage = classLocale::$lang['gate_jump_done'] ." - ". pretty_time(uni_get_time_to_jump($planetrow)); |
|
58 | + $RetMessage = classLocale::$lang['gate_jump_done']." - ".pretty_time(uni_get_time_to_jump($planetrow)); |
|
59 | 59 | } else { |
60 | 60 | $RetMessage = classLocale::$lang['gate_wait_data']; |
61 | 61 | } |
62 | 62 | } else { |
63 | - $RetMessage = classLocale::$lang['gate_wait_dest'] ." - ". pretty_time($NextDestTime); |
|
63 | + $RetMessage = classLocale::$lang['gate_wait_dest']." - ".pretty_time($NextDestTime); |
|
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | $RetMessage = classLocale::$lang['gate_no_dest_g']; |
67 | 67 | } |
68 | 68 | } else { |
69 | - $RetMessage = classLocale::$lang['gate_wait_star'] ." - ". pretty_time($NextJumpTime); |
|
69 | + $RetMessage = classLocale::$lang['gate_wait_star']." - ".pretty_time($NextJumpTime); |
|
70 | 70 | } |
71 | 71 | sn_db_transaction_commit(); |
72 | 72 | message($RetMessage, classLocale::$lang['tech'][STRUC_MOON_GATE], "jumpgate.php", 10); |
73 | 73 | } else { |
74 | 74 | $template = gettemplate('jumpgate', true); |
75 | - if(mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0) |
|
75 | + if (mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0) |
|
76 | 76 | { |
77 | 77 | $Combo = ''; |
78 | 78 | $MoonList = DBStaticPlanet::db_planet_list_moon_other($user['id'], $planetrow['id']); |
79 | 79 | // while($CurMoon = db_fetch($MoonList)) |
80 | - foreach($MoonList as $CurMoon) |
|
80 | + foreach ($MoonList as $CurMoon) |
|
81 | 81 | { |
82 | - if(mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1) |
|
82 | + if (mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1) |
|
83 | 83 | { |
84 | 84 | $NextJumpTime = uni_get_time_to_jump($CurMoon); |
85 | 85 | $template->assign_block_vars('moon', array( |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | - foreach(sn_get_groups('fleet') as $Ship) |
|
96 | + foreach (sn_get_groups('fleet') as $Ship) |
|
97 | 97 | { |
98 | - if(($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0) |
|
98 | + if (($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0) |
|
99 | 99 | { |
100 | 100 | continue; |
101 | 101 | } |
@@ -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; |
@@ -398,31 +398,31 @@ discard block |
||
398 | 398 | |
399 | 399 | return doquery( |
400 | 400 | // Блокировка самого флота |
401 | - "SELECT 1 FROM {{fleets}} AS f " . |
|
401 | + "SELECT 1 FROM {{fleets}} AS f ". |
|
402 | 402 | |
403 | 403 | // Блокировка всех юнитов, принадлежащих этому флоту |
404 | - "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " . |
|
404 | + "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ". |
|
405 | 405 | |
406 | 406 | // Блокировка всех прилетающих и улетающих флотов, если нужно |
407 | 407 | // TODO - lock fleets by COORDINATES |
408 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') . |
|
408 | + ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : ''). |
|
409 | 409 | // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination |
410 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') . |
|
410 | + ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : ''). |
|
411 | 411 | |
412 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') . |
|
412 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : ''). |
|
413 | 413 | // Блокировка всех юнитов, принадлежащих владельцу планеты-цели |
414 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') . |
|
414 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : ''). |
|
415 | 415 | // Блокировка планеты-цели |
416 | - ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') . |
|
416 | + ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : ''). |
|
417 | 417 | // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели |
418 | 418 | // ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') . |
419 | 419 | |
420 | 420 | |
421 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') . |
|
421 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : ''). |
|
422 | 422 | // Блокировка всех юнитов, принадлежащих владельцу флота |
423 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') . |
|
423 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : ''). |
|
424 | 424 | // Блокировка планеты отправления |
425 | - ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') . |
|
425 | + ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : ''). |
|
426 | 426 | // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота |
427 | 427 | // ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') . |
428 | 428 | |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | public function dbGetLockById($dbId) { |
440 | 440 | doquery( |
441 | 441 | // Блокировка самого флота |
442 | - "SELECT 1 FROM {{fleets}} AS FLEET0 " . |
|
442 | + "SELECT 1 FROM {{fleets}} AS FLEET0 ". |
|
443 | 443 | // Lock fleet owner |
444 | - "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " . |
|
444 | + "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ". |
|
445 | 445 | // Блокировка всех юнитов, принадлежащих этому флоту |
446 | - "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " . |
|
446 | + "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ". |
|
447 | 447 | |
448 | 448 | // Без предварительной выборки неизвестно - куда летит этот флот. |
449 | 449 | // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота. |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | FLEET1.fleet_end_planet = FLEET0.fleet_end_planet |
460 | 460 | " . |
461 | 461 | // Блокировка всех юнитов, принадлежащих этим флотам |
462 | - "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " . |
|
462 | + "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ". |
|
463 | 463 | // Lock fleet owner |
464 | - "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " . |
|
464 | + "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ". |
|
465 | 465 | |
466 | 466 | "LEFT JOIN {{fleets}} AS FLEET2 ON |
467 | 467 | FLEET2.fleet_mess = 1 AND FLEET0.fleet_mess = 0 AND |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | " . |
472 | 472 | // Блокировка всех юнитов, принадлежащих этим флотам |
473 | 473 | "LEFT JOIN {{unit}} as UNIT2 ON |
474 | - UNIT2.unit_location_type = " . LOC_FLEET . " AND |
|
474 | + UNIT2.unit_location_type = " . LOC_FLEET." AND |
|
475 | 475 | UNIT2.unit_location_id = FLEET2.fleet_id |
476 | 476 | " . |
477 | 477 | // Lock fleet owner |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | " . |
489 | 489 | // Блокировка всех юнитов, принадлежащих этим флотам |
490 | 490 | "LEFT JOIN {{unit}} as UNIT3 ON |
491 | - UNIT3.unit_location_type = " . LOC_FLEET . " AND |
|
491 | + UNIT3.unit_location_type = " . LOC_FLEET." AND |
|
492 | 492 | UNIT3.unit_location_id = FLEET3.fleet_id |
493 | 493 | " . |
494 | 494 | // Lock fleet owner |
495 | - "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " . |
|
495 | + "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ". |
|
496 | 496 | |
497 | 497 | "LEFT JOIN {{fleets}} AS FLEET4 ON |
498 | 498 | FLEET4.fleet_mess = 1 AND FLEET0.fleet_mess = 1 AND |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | " . |
503 | 503 | // Блокировка всех юнитов, принадлежащих этим флотам |
504 | 504 | "LEFT JOIN {{unit}} as UNIT4 ON |
505 | - UNIT4.unit_location_type = " . LOC_FLEET . " AND |
|
505 | + UNIT4.unit_location_type = " . LOC_FLEET." AND |
|
506 | 506 | UNIT4.unit_location_id = FLEET4.fleet_id |
507 | 507 | " . |
508 | 508 | // Lock fleet owner |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | " . |
525 | 525 | // Блокировка всех юнитов, принадлежащих этой планете |
526 | 526 | "LEFT JOIN {{unit}} as UNIT5 ON |
527 | - UNIT5.unit_location_type = " . LOC_PLANET . " AND |
|
527 | + UNIT5.unit_location_type = " . LOC_PLANET." AND |
|
528 | 528 | UNIT5.unit_location_id = PLANETS5.id |
529 | 529 | " . |
530 | 530 | |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | " . |
543 | 543 | // Блокировка всех юнитов, принадлежащих этой планете |
544 | 544 | "LEFT JOIN {{unit}} as UNIT6 ON |
545 | - UNIT6.unit_location_type = " . LOC_PLANET . " AND |
|
545 | + UNIT6.unit_location_type = " . LOC_PLANET." AND |
|
546 | 546 | UNIT6.unit_location_id = PLANETS6.id |
547 | 547 | " . |
548 | 548 | "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE" |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | } elseif ($this->isResource($unit_id)) { |
662 | 662 | $this->resource_list[$unit_id] = $unit_count; |
663 | 663 | } else { |
664 | - throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR); |
|
664 | + throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), ERR_ERROR); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | } |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | */ |
987 | 987 | public function resourcesSet($resource_list) { |
988 | 988 | if (!empty($this->propertiesAdjusted['resource_list'])) { |
989 | - throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR); |
|
989 | + throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR); |
|
990 | 990 | } |
991 | 991 | $this->resourcesAdjust($resource_list, true); |
992 | 992 | } |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | // Check for negative unit value |
1021 | 1021 | if ($this->resource_list[$resource_id] < 0) { |
1022 | 1022 | // TODO |
1023 | - throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR); |
|
1023 | + throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR); |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | } |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | |
1194 | 1194 | protected function printErrorIfNoShips() { |
1195 | 1195 | if ($this->unitList->unitsCount() <= 0) { |
1196 | - message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5); |
|
1196 | + message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5); |
|
1197 | 1197 | } |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1540,7 +1540,7 @@ discard block |
||
1540 | 1540 | } catch (Exception $e) { |
1541 | 1541 | |
1542 | 1542 | // TODO - MESSAGE BOX |
1543 | - if($e instanceof ExceptionFleetInvalid) { |
|
1543 | + if ($e instanceof ExceptionFleetInvalid) { |
|
1544 | 1544 | sn_db_transaction_rollback(); |
1545 | 1545 | pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]); |
1546 | 1546 | } else { |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | $validator->validate(); |
1630 | 1630 | } catch (Exception $e) { |
1631 | 1631 | // TODO - MESSAGE BOX |
1632 | - if($e instanceof ExceptionFleetInvalid) { |
|
1632 | + if ($e instanceof ExceptionFleetInvalid) { |
|
1633 | 1633 | sn_db_transaction_rollback(); |
1634 | 1634 | pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]); |
1635 | 1635 | } else { |
@@ -1690,7 +1690,7 @@ discard block |
||
1690 | 1690 | |
1691 | 1691 | |
1692 | 1692 | if (!empty($captain['unit_id'])) { |
1693 | - DBStaticUnit::db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$this->_dbId}"); |
|
1693 | + DBStaticUnit::db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = ".LOC_FLEET.", `unit_location_id` = {$this->_dbId}"); |
|
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | // return $this->fleet->acs['ankunft'] - $this->fleet->time_launch >= $this->fleet->travelData['duration']; |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob); |
1703 | 1703 | |
1704 | 1704 | $template_result += array( |
1705 | - 'mission' => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''), |
|
1705 | + 'mission' => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''), |
|
1706 | 1706 | 'dist' => pretty_number($this->travelData['distance']), |
1707 | 1707 | 'speed' => pretty_number($this->travelData['fleet_speed']), |
1708 | 1708 | 'deute_need' => pretty_number($this->travelData['consumption']), |
@@ -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(), |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | // classSupernova::$db->sn_db_connect(); |
16 | 16 | if (!(strpos($query, '{{') === false)) { |
17 | 17 | foreach ($update_tables as $tableName => $cork) { |
18 | - $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
|
18 | + $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix.$tableName, $query); |
|
19 | 19 | } |
20 | 20 | } |
21 | - !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for ' . $query . ': ' . db_error()) : false; |
|
21 | + !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for '.$query.': '.db_error()) : false; |
|
22 | 22 | |
23 | 23 | return $result; |
24 | 24 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | global $update_tables, $update_indexes, $update_indexes_full, $update_foreigns; |
86 | 86 | |
87 | 87 | $tableName = $prefixed ? str_replace(classSupernova::$config->db_prefix, '', $prefix_table_name) : $prefix_table_name; |
88 | - $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix . $prefix_table_name; |
|
88 | + $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix.$prefix_table_name; |
|
89 | 89 | |
90 | 90 | upd_unset_table_info($tableName); |
91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
101 | 101 | } |
102 | 102 | |
103 | - $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
103 | + $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '".db_escape(classSupernova::$db_name)."' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
104 | 104 | while ($r1 = db_fetch($q1)) { |
105 | 105 | $table_referenced = str_replace(classSupernova::$config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
106 | 106 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}"); |
161 | 161 | $error = db_error(); |
162 | 162 | if ($error) { |
163 | - die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
|
163 | + die("Creating error for table `{$table_name}`: {$error}<br />".dump($declaration)); |
|
164 | 164 | } |
165 | 165 | upd_do_query('set foreign_key_checks = 1;', true); |
166 | 166 | upd_load_table_info($table_name, false); |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | "SELECT {$fields} |
176 | 176 | FROM {{unit}} |
177 | 177 | WHERE |
178 | - `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions() . |
|
179 | - ($user_id = intval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . |
|
180 | - ($unit_snid = intval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '') . |
|
181 | - " LIMIT 1" . |
|
178 | + `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions(). |
|
179 | + ($user_id = intval($user_id) ? " AND `unit_player_id` = {$user_id}" : ''). |
|
180 | + ($unit_snid = intval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : ''). |
|
181 | + " LIMIT 1". |
|
182 | 182 | ($for_update ? ' FOR UPDATE' : '') |
183 | 183 | )); |
184 | 184 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | foreach ($table_data as $record_id => $conditions) { |
260 | 260 | $where = ''; |
261 | 261 | if (!empty($conditions['where'])) { |
262 | - $where = 'WHERE ' . implode(' AND ', $conditions['where']); |
|
262 | + $where = 'WHERE '.implode(' AND ', $conditions['where']); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | $fields = array(); |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | $condition = "`{$field_name}` = "; |
269 | 269 | $value = ''; |
270 | 270 | if ($field_data['delta']) { |
271 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
271 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
272 | 272 | } elseif ($field_data['set']) { |
273 | 273 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
274 | 274 | } |
275 | 275 | if ($value) { |
276 | - $fields[] = $condition . $value; |
|
276 | + $fields[] = $condition.$value; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -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 | } |
@@ -36,11 +36,10 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | public static function db_planet_by_vector($vector, $prefix = '', $for_update = false, $fields = '*') { |
39 | - $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0; |
|
40 | - $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0; |
|
41 | - $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0; |
|
42 | - $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : |
|
43 | - (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
39 | + $galaxy = isset($vector[$prefix.'galaxy']) ? intval($vector[$prefix.'galaxy']) : 0; |
|
40 | + $system = isset($vector[$prefix.'system']) ? intval($vector[$prefix.'system']) : 0; |
|
41 | + $planet = isset($vector[$prefix.'planet']) ? intval($vector[$prefix.'planet']) : 0; |
|
42 | + $planet_type = isset($vector[$prefix.'planet_type']) ? intval($vector[$prefix.'planet_type']) : (isset($vector[$prefix.'type']) ? intval($vector[$prefix.'type']) : 0); |
|
44 | 43 | $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type; |
45 | 44 | |
46 | 45 | return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields); |
@@ -61,17 +60,17 @@ discard block |
||
61 | 60 | } |
62 | 61 | |
63 | 62 | public static function db_planet_by_parent($parent_id, $for_update = false, $fields = '*') { |
64 | - if(!($parent_id = idval($parent_id))) { |
|
63 | + if (!($parent_id = idval($parent_id))) { |
|
65 | 64 | return false; |
66 | 65 | } |
67 | 66 | |
68 | 67 | return classSupernova::db_get_record_list(LOC_PLANET, |
69 | - "`parent_planet` = {$parent_id} AND `planet_type` = " . PT_MOON, true); |
|
68 | + "`parent_planet` = {$parent_id} AND `planet_type` = ".PT_MOON, true); |
|
70 | 69 | } |
71 | 70 | |
72 | 71 | public static function db_planet_by_id_and_owner($planet_id, $owner_id, $for_update = false, $fields = '*') { |
73 | 72 | //if(!($planet_id = intval($planet_id)) || !($owner_id = intval($owner_id))) return false; |
74 | - if(!($planet_id = idval($planet_id)) || !($owner_id = idval($owner_id))) { |
|
73 | + if (!($planet_id = idval($planet_id)) || !($owner_id = idval($owner_id))) { |
|
75 | 74 | return false; |
76 | 75 | } |
77 | 76 | |
@@ -82,12 +81,12 @@ discard block |
||
82 | 81 | |
83 | 82 | public static function db_planet_list_moon_other($user_id, $this_moon_id) { |
84 | 83 | // if(!($user_id = intval($user_id)) || !($this_moon_id = intval($this_moon_id))) return false; |
85 | - if(!($user_id = idval($user_id)) || !($this_moon_id = idval($this_moon_id))) { |
|
84 | + if (!($user_id = idval($user_id)) || !($this_moon_id = idval($this_moon_id))) { |
|
86 | 85 | return false; |
87 | 86 | } |
88 | 87 | |
89 | 88 | return classSupernova::db_get_record_list(LOC_PLANET, |
90 | - "`planet_type` = " . PT_MOON . " AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}"); |
|
89 | + "`planet_type` = ".PT_MOON." AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}"); |
|
91 | 90 | } |
92 | 91 | |
93 | 92 | public static function db_planet_list_in_system($galaxy, $system) { |
@@ -99,7 +98,7 @@ discard block |
||
99 | 98 | } |
100 | 99 | |
101 | 100 | public static function db_planet_list_sorted($user_row, $skip_planet_id = false, $field_list = '', $conditions = '') { |
102 | - if(!is_array($user_row)) { |
|
101 | + if (!is_array($user_row)) { |
|
103 | 102 | return false; |
104 | 103 | } |
105 | 104 | // $field_list = $field_list != '*' ? "{{planets}}.`id`, `name`, `image`, {{planets}}.`galaxy`, {{planets}}.`system`, {{planets}}.`planet`, `planet_type`{$field_list}" : $field_list; |
@@ -113,7 +112,7 @@ discard block |
||
113 | 112 | ); |
114 | 113 | $order_by = classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT]; |
115 | 114 | empty($sort_orders[$order_by]) ? $order_by = SORT_ID : false; |
116 | - $order_by = $sort_orders[$order_by] . ' ' . (classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC'); |
|
115 | + $order_by = $sort_orders[$order_by].' '.(classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC'); |
|
117 | 116 | |
118 | 117 | // Compilating query |
119 | 118 | return classSupernova::db_get_record_list(LOC_PLANET, |
@@ -121,7 +120,7 @@ discard block |
||
121 | 120 | } |
122 | 121 | |
123 | 122 | public static function db_planet_list_by_user_or_planet($user_id, $planet_id) { |
124 | - if(!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) { |
|
123 | + if (!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) { |
|
125 | 124 | return false; |
126 | 125 | } |
127 | 126 | |
@@ -131,7 +130,7 @@ discard block |
||
131 | 130 | |
132 | 131 | public static function db_planet_set_by_id($planet_id, $set) { |
133 | 132 | // if(!($planet_id = intval($planet_id))) return false; |
134 | - if(!($planet_id = idval($planet_id))) { |
|
133 | + if (!($planet_id = idval($planet_id))) { |
|
135 | 134 | return false; |
136 | 135 | } |
137 | 136 | |
@@ -139,7 +138,7 @@ discard block |
||
139 | 138 | } |
140 | 139 | |
141 | 140 | public static function db_planet_set_by_gspt($ui_galaxy, $ui_system, $ui_planet, $ui_planet_type = PT_ALL, $set) { |
142 | - if(!($set = trim($set))) { |
|
141 | + if (!($set = trim($set))) { |
|
143 | 142 | return false; |
144 | 143 | } |
145 | 144 | |
@@ -153,7 +152,7 @@ discard block |
||
153 | 152 | |
154 | 153 | public static function db_planet_set_by_parent($ui_parent_id, $ss_set) { |
155 | 154 | //if(!($si_parent_id = intval($ui_parent_id)) || !($ss_set = trim($ss_set))) return false; |
156 | - if(!($si_parent_id = idval($ui_parent_id)) || !($ss_set = trim($ss_set))) { |
|
155 | + if (!($si_parent_id = idval($ui_parent_id)) || !($ss_set = trim($ss_set))) { |
|
157 | 156 | return false; |
158 | 157 | } |
159 | 158 | |
@@ -162,7 +161,7 @@ discard block |
||
162 | 161 | |
163 | 162 | public static function db_planet_set_by_owner($ui_owner_id, $ss_set) { |
164 | 163 | //if(!($si_owner_id = intval($ui_owner_id)) || !($ss_set = trim($ss_set))) return false; |
165 | - if(!($si_owner_id = idval($ui_owner_id)) || !($ss_set = trim($ss_set))) { |
|
164 | + if (!($si_owner_id = idval($ui_owner_id)) || !($ss_set = trim($ss_set))) { |
|
166 | 165 | return false; |
167 | 166 | } |
168 | 167 | |
@@ -172,11 +171,11 @@ discard block |
||
172 | 171 | |
173 | 172 | public static function db_planet_delete_by_id($planet_id) { |
174 | 173 | // if(!($planet_id = intval($planet_id))) return false; |
175 | - if(!($planet_id = idval($planet_id))) { |
|
174 | + if (!($planet_id = idval($planet_id))) { |
|
176 | 175 | return false; |
177 | 176 | } |
178 | 177 | classSupernova::db_del_record_by_id(LOC_PLANET, $planet_id); |
179 | - classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_location_id` = " . $planet_id); |
|
178 | + classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_location_id` = ".$planet_id); |
|
180 | 179 | |
181 | 180 | // Очереди очистятся автоматически по FOREIGN KEY |
182 | 181 | return true; |
@@ -184,11 +183,11 @@ discard block |
||
184 | 183 | |
185 | 184 | public static function db_planet_list_delete_by_owner($ui_owner_id) { |
186 | 185 | // if(!($si_owner_id = intval($ui_owner_id))) return false; |
187 | - if(!($si_owner_id = idval($ui_owner_id))) { |
|
186 | + if (!($si_owner_id = idval($ui_owner_id))) { |
|
188 | 187 | return false; |
189 | 188 | } |
190 | 189 | classSupernova::db_del_record_list(LOC_PLANET, "`id_owner` = {$si_owner_id}"); |
191 | - classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_player_id` = " . $si_owner_id); |
|
190 | + classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_player_id` = ".$si_owner_id); |
|
192 | 191 | |
193 | 192 | // Очереди очистятся автоматически по FOREIGN KEY |
194 | 193 | return true; |