@@ -34,69 +34,69 @@ |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | switch($mode) { |
37 | - case ADM_TOOL_CONFIG_RELOAD: |
|
38 | - classSupernova::$config->db_loadAll(); |
|
39 | - sys_refresh_tablelist(); |
|
40 | - |
|
41 | - classSupernova::$config->db_loadItem('game_watchlist'); |
|
42 | - if(classSupernova::$config->game_watchlist) { |
|
43 | - classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist); |
|
44 | - } else { |
|
45 | - unset(classSupernova::$config->game_watchlist_array); |
|
46 | - } |
|
47 | - break; |
|
48 | - |
|
49 | - case ADM_TOOL_MD5: |
|
50 | - $template = gettemplate("admin/md5enc", true); |
|
51 | - $password_seed = sys_get_param_str_unsafe('seed', SN_SYS_SEC_CHARS_ALLOWED); |
|
52 | - $password_length = sys_get_param_int('length', 16); |
|
53 | - $string = ($string = sys_get_param_str_unsafe('string')) ? $string : sys_random_string($password_length, $password_seed); |
|
54 | - |
|
55 | - $template->assign_vars(array( |
|
56 | - 'SEED' => $password_seed, |
|
57 | - 'LENGTH' => $password_length, |
|
58 | - 'STRING' => htmlentities($string), |
|
59 | - 'MD5' => md5($string), |
|
60 | - )); |
|
61 | - display($template, classLocale::$lang['adm_tools_md5_header'], false, '', true); |
|
62 | - break; |
|
63 | - |
|
64 | - case ADM_TOOL_FORCE_ALL: |
|
65 | - classSupernova::$config->db_saveItem('db_version', 0); |
|
66 | - require_once('../includes/update.php'); |
|
67 | - break; |
|
68 | - |
|
69 | - case ADM_TOOL_FORCE_LAST: |
|
70 | - classSupernova::$config->db_saveItem('db_version', floor(classSupernova::$config->db_version - 1)); |
|
71 | - require_once('../includes/update.php'); |
|
72 | - break; |
|
73 | - |
|
74 | - case ADM_TOOL_INFO_PHP: |
|
75 | - phpinfo(); |
|
76 | - break; |
|
77 | - |
|
78 | - case ADM_TOOL_INFO_SQL: |
|
79 | - $template = gettemplate("simple_table", true); |
|
80 | - |
|
81 | - $status = array( |
|
82 | - classLocale::$lang['adm_tool_sql_server_version'] => classSupernova::$db->db_get_server_info(), |
|
83 | - classLocale::$lang['adm_tool_sql_client_version'] => classSupernova::$db->db_get_client_info(), |
|
84 | - classLocale::$lang['adm_tool_sql_host_info'] => classSupernova::$db->db_get_host_info(), |
|
85 | - ); |
|
86 | - templateAssignTable($template, 'server', $status); |
|
87 | - |
|
88 | - templateAssignTable($template, 'status', classSupernova::$db->db_get_server_stat()); |
|
89 | - templateAssignTable($template, 'params', classSupernova::$db->db_core_show_status()); |
|
90 | - |
|
91 | - $template->assign_vars(array( |
|
92 | - 'PAGE_HEADER' => classLocale::$lang['adm_tool_sql_page_header'], |
|
93 | - 'COLUMN_NAME_1' => classLocale::$lang['adm_tool_sql_param_name'], |
|
94 | - 'COLUMN_NAME_2' => classLocale::$lang['adm_tool_sql_param_value'], |
|
95 | - 'TABLE_FOOTER' => 'test', |
|
96 | - )); |
|
97 | - |
|
98 | - display($template, classLocale::$lang['adm_bn_ttle'], false, '', true); |
|
99 | - break; |
|
37 | + case ADM_TOOL_CONFIG_RELOAD: |
|
38 | + classSupernova::$config->db_loadAll(); |
|
39 | + sys_refresh_tablelist(); |
|
40 | + |
|
41 | + classSupernova::$config->db_loadItem('game_watchlist'); |
|
42 | + if(classSupernova::$config->game_watchlist) { |
|
43 | + classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist); |
|
44 | + } else { |
|
45 | + unset(classSupernova::$config->game_watchlist_array); |
|
46 | + } |
|
47 | + break; |
|
48 | + |
|
49 | + case ADM_TOOL_MD5: |
|
50 | + $template = gettemplate("admin/md5enc", true); |
|
51 | + $password_seed = sys_get_param_str_unsafe('seed', SN_SYS_SEC_CHARS_ALLOWED); |
|
52 | + $password_length = sys_get_param_int('length', 16); |
|
53 | + $string = ($string = sys_get_param_str_unsafe('string')) ? $string : sys_random_string($password_length, $password_seed); |
|
54 | + |
|
55 | + $template->assign_vars(array( |
|
56 | + 'SEED' => $password_seed, |
|
57 | + 'LENGTH' => $password_length, |
|
58 | + 'STRING' => htmlentities($string), |
|
59 | + 'MD5' => md5($string), |
|
60 | + )); |
|
61 | + display($template, classLocale::$lang['adm_tools_md5_header'], false, '', true); |
|
62 | + break; |
|
63 | + |
|
64 | + case ADM_TOOL_FORCE_ALL: |
|
65 | + classSupernova::$config->db_saveItem('db_version', 0); |
|
66 | + require_once('../includes/update.php'); |
|
67 | + break; |
|
68 | + |
|
69 | + case ADM_TOOL_FORCE_LAST: |
|
70 | + classSupernova::$config->db_saveItem('db_version', floor(classSupernova::$config->db_version - 1)); |
|
71 | + require_once('../includes/update.php'); |
|
72 | + break; |
|
73 | + |
|
74 | + case ADM_TOOL_INFO_PHP: |
|
75 | + phpinfo(); |
|
76 | + break; |
|
77 | + |
|
78 | + case ADM_TOOL_INFO_SQL: |
|
79 | + $template = gettemplate("simple_table", true); |
|
80 | + |
|
81 | + $status = array( |
|
82 | + classLocale::$lang['adm_tool_sql_server_version'] => classSupernova::$db->db_get_server_info(), |
|
83 | + classLocale::$lang['adm_tool_sql_client_version'] => classSupernova::$db->db_get_client_info(), |
|
84 | + classLocale::$lang['adm_tool_sql_host_info'] => classSupernova::$db->db_get_host_info(), |
|
85 | + ); |
|
86 | + templateAssignTable($template, 'server', $status); |
|
87 | + |
|
88 | + templateAssignTable($template, 'status', classSupernova::$db->db_get_server_stat()); |
|
89 | + templateAssignTable($template, 'params', classSupernova::$db->db_core_show_status()); |
|
90 | + |
|
91 | + $template->assign_vars(array( |
|
92 | + 'PAGE_HEADER' => classLocale::$lang['adm_tool_sql_page_header'], |
|
93 | + 'COLUMN_NAME_1' => classLocale::$lang['adm_tool_sql_param_name'], |
|
94 | + 'COLUMN_NAME_2' => classLocale::$lang['adm_tool_sql_param_value'], |
|
95 | + 'TABLE_FOOTER' => 'test', |
|
96 | + )); |
|
97 | + |
|
98 | + display($template, classLocale::$lang['adm_bn_ttle'], false, '', true); |
|
99 | + break; |
|
100 | 100 | |
101 | 101 | } |
102 | 102 |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | define('INSIDE', true); |
10 | 10 | define('INSTALL', false); |
11 | 11 | define('IN_ADMIN', true); |
12 | -require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
12 | +require('../common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
13 | 13 | |
14 | 14 | // if($user['authlevel'] < 1) |
15 | -if($user['authlevel'] < 3) { |
|
15 | +if ($user['authlevel'] < 3) { |
|
16 | 16 | AdminMessage(classLocale::$lang['adm_err_denied']); |
17 | 17 | } |
18 | 18 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function templateAssignTable($template, $str, $status) { |
27 | 27 | $template->assign_block_vars('table', classLocale::$lang['adm_tool_sql_table'][$str]); |
28 | - foreach($status as $key => $value) { |
|
28 | + foreach ($status as $key => $value) { |
|
29 | 29 | $template->assign_block_vars('table.row', array( |
30 | 30 | 'VALUE_1' => $key, |
31 | 31 | 'VALUE_2' => $value, |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
36 | -switch($mode) { |
|
36 | +switch ($mode) { |
|
37 | 37 | case ADM_TOOL_CONFIG_RELOAD: |
38 | 38 | classSupernova::$config->db_loadAll(); |
39 | 39 | sys_refresh_tablelist(); |
40 | 40 | |
41 | 41 | classSupernova::$config->db_loadItem('game_watchlist'); |
42 | - if(classSupernova::$config->game_watchlist) { |
|
42 | + if (classSupernova::$config->game_watchlist) { |
|
43 | 43 | classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist); |
44 | 44 | } else { |
45 | 45 | unset(classSupernova::$config->game_watchlist_array); |
@@ -10,8 +10,8 @@ |
||
10 | 10 | /** |
11 | 11 | * UniverseVector constructor. |
12 | 12 | * |
13 | - * @param int|string $galaxy |
|
14 | - * @param int|Vector|array $system |
|
13 | + * @param integer $galaxy |
|
14 | + * @param integer $system |
|
15 | 15 | * @param int $planet |
16 | 16 | * @param int $type |
17 | 17 | */ |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | public $type = PT_NONE; |
14 | 14 | |
15 | 15 | public static function _staticInit() { |
16 | - if(static::$_isStaticInit) { |
|
16 | + if (static::$_isStaticInit) { |
|
17 | 17 | return; |
18 | 18 | } |
19 | 19 | static::$knownGalaxies = intval(classSupernova::$config->game_maxGalaxy); |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | public function __construct($galaxy = 0, $system = 0, $planet = 0, $type = PT_NONE) { |
34 | 34 | // static::_staticInit(); |
35 | 35 | |
36 | - if(is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) { |
|
36 | + if (is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) { |
|
37 | 37 | $this->readFromVector($system); |
38 | - } elseif(is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) { |
|
38 | + } elseif (is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) { |
|
39 | 39 | $this->readFromParamFleets($system); |
40 | 40 | } else { |
41 | 41 | $this->galaxy = intval($galaxy); |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | * @param Vector $vector |
75 | 75 | */ |
76 | 76 | public function distance($vector) { |
77 | - if($this->galaxy != $vector->galaxy) { |
|
77 | + if ($this->galaxy != $vector->galaxy) { |
|
78 | 78 | $distance = abs($this->galaxy - $vector->galaxy) * classSupernova::$config->uni_galaxy_distance; |
79 | - } elseif($this->system != $vector->system) { |
|
79 | + } elseif ($this->system != $vector->system) { |
|
80 | 80 | $distance = abs($this->system - $vector->system) * 5 * 19 + 2700; |
81 | - } elseif($this->planet != $vector->planet) { |
|
81 | + } elseif ($this->planet != $vector->planet) { |
|
82 | 82 | $distance = abs($this->planet - $vector->planet) * 5 + 1000; |
83 | 83 | // TODO - uncomment |
84 | 84 | // } elseif($this->type != PT_NONE && $vector->type != PT_NONE && $this->type == $vector->type) { |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | * @param array $coordinates |
102 | 102 | */ |
103 | 103 | public static function convertToVector($coordinates, $prefix = '') { |
104 | - $galaxy = !empty($coordinates[$prefix . 'galaxy']) ? intval($coordinates[$prefix . 'galaxy']) : 0; |
|
105 | - $system = !empty($coordinates[$prefix . 'system']) ? intval($coordinates[$prefix . 'system']) : 0; |
|
106 | - $planet = !empty($coordinates[$prefix . 'planet']) ? intval($coordinates[$prefix . 'planet']) : 0; |
|
107 | - $type = !empty($coordinates[$prefix . 'type']) |
|
108 | - ? intval($coordinates[$prefix . 'type']) |
|
109 | - : (!empty($coordinates[$prefix . 'planet_type']) ? intval($coordinates[$prefix . 'planet_type']) : 0); |
|
104 | + $galaxy = !empty($coordinates[$prefix.'galaxy']) ? intval($coordinates[$prefix.'galaxy']) : 0; |
|
105 | + $system = !empty($coordinates[$prefix.'system']) ? intval($coordinates[$prefix.'system']) : 0; |
|
106 | + $planet = !empty($coordinates[$prefix.'planet']) ? intval($coordinates[$prefix.'planet']) : 0; |
|
107 | + $type = !empty($coordinates[$prefix.'type']) |
|
108 | + ? intval($coordinates[$prefix.'type']) |
|
109 | + : (!empty($coordinates[$prefix.'planet_type']) ? intval($coordinates[$prefix.'planet_type']) : 0); |
|
110 | 110 | |
111 | 111 | return new static($galaxy, $system, $planet, $type); |
112 | 112 | } |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | * @return int|mixed |
229 | 229 | */ |
230 | 230 | public function calcColonyMaxCount($astrotech = -1) { |
231 | - if($astrotech == -1) { |
|
232 | - if(!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) { |
|
231 | + if ($astrotech == -1) { |
|
232 | + if (!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) { |
|
233 | 233 | |
234 | 234 | $expeditions = get_player_max_expeditons($this->_dbRow); |
235 | 235 | $astrotech = mrc_get_level($this->_dbRow, null, TECH_ASTROTECH); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | |
304 | 304 | public function expeditionsMax() { |
305 | - if($this->expeditionsMax === null) { |
|
305 | + if ($this->expeditionsMax === null) { |
|
306 | 306 | $this->expeditionsMax = get_player_max_expeditons($this->_dbRow); |
307 | 307 | } |
308 | 308 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | } |
311 | 311 | |
312 | 312 | public function expeditionsFlying() { |
313 | - if($this->expeditionsFlying === null) { |
|
313 | + if ($this->expeditionsFlying === null) { |
|
314 | 314 | $this->expeditionsFlying = FleetList::fleet_count_flying($this->_dbId, MT_EXPLORE); |
315 | 315 | } |
316 | 316 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | |
321 | 321 | public function fleetsMax() { |
322 | - if($this->fleetMax === null) { |
|
322 | + if ($this->fleetMax === null) { |
|
323 | 323 | $this->fleetMax = GetMaxFleets($this->_dbRow); |
324 | 324 | } |
325 | 325 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | } |
328 | 328 | |
329 | 329 | public function fleetsFlying() { |
330 | - if($this->fleetFlying === null) { |
|
330 | + if ($this->fleetFlying === null) { |
|
331 | 331 | $this->fleetFlying = FleetList::fleet_count_flying($this->_dbId); |
332 | 332 | } |
333 | 333 | |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | |
337 | 337 | |
338 | 338 | public function coloniesMax() { |
339 | - if($this->coloniesMax === null) { |
|
339 | + if ($this->coloniesMax === null) { |
|
340 | 340 | $this->coloniesMax = get_player_max_colonies($this->_dbRow); |
341 | 341 | } |
342 | 342 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | public function coloniesCurrent() { |
347 | - if($this->coloniesCurrent === null) { |
|
347 | + if ($this->coloniesCurrent === null) { |
|
348 | 348 | $this->coloniesCurrent = get_player_current_colonies($this->_dbRow); |
349 | 349 | } |
350 | 350 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * |
13 | 13 | **/ |
14 | 14 | |
15 | -if(SN_IN_FLEET !== true) { |
|
15 | +if (SN_IN_FLEET !== true) { |
|
16 | 16 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
17 | 17 | } |
18 | 18 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $planet_list = array(); |
27 | 27 | |
28 | - if(is_array($resources_taken)) |
|
28 | + if (is_array($resources_taken)) |
|
29 | 29 | { |
30 | 30 | $query = implode(',', array_keys($resources_taken)); |
31 | 31 | $query = " AND `destruyed` = 0 AND `id` IN ({$query})"; |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | $query = ''; |
34 | 34 | } |
35 | 35 | |
36 | - foreach(sn_get_groups('flt_transports') as $transport_id) { |
|
36 | + foreach (sn_get_groups('flt_transports') as $transport_id) { |
|
37 | 37 | $transports[$transport_id] = get_unit_param($transport_id, P_CAPACITY); |
38 | 38 | } |
39 | 39 | arsort($transports); |
40 | 40 | |
41 | 41 | $planets_db_list = db_planet_list_sorted($user, $planetrow['id'], '*', $query); |
42 | 42 | !is_array($planets_db_list) ? $planets_db_list = array() : false; |
43 | - foreach($planets_db_list as $planet_db_data) { |
|
43 | + foreach ($planets_db_list as $planet_db_data) { |
|
44 | 44 | // begin planet loop |
45 | - if(!$query) { |
|
45 | + if (!$query) { |
|
46 | 46 | $resources_taken[$planet_db_data['id']] = 1; |
47 | 47 | } |
48 | 48 | sn_db_transaction_start(); |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | $planet_id = $planet_db_data['id']; |
55 | 55 | |
56 | 56 | $planet_resources = 0; |
57 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
58 | - if($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) { |
|
57 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
58 | + if ($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) { |
|
59 | 59 | $planet_resources += floor(mrc_get_level($user, $planet_db_data, $resource_id, true, true)); // $planet_db_data[get_unit_param($resource_id, P_NAME)]); |
60 | 60 | } |
61 | 61 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | $fleet_capacity = 0; |
87 | 87 | $ship_loadout = array(); |
88 | 88 | $fleet = array(); |
89 | - foreach($transports as $ship_id => $ship_capacity) { |
|
90 | - if($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) { |
|
89 | + foreach ($transports as $ship_id => $ship_capacity) { |
|
90 | + if ($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) { |
|
91 | 91 | $ship_loadout[$ship_id]['capacity'] = $ship_count * $ship_capacity; |
92 | 92 | $ship_loadout[$ship_id]['taken'] = 0; |
93 | 93 | $fleet_capacity += $ship_loadout[$ship_id]['capacity']; |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | |
99 | 99 | $will_take = min($planet_resources, $fleet_capacity); |
100 | 100 | |
101 | - foreach($ship_loadout as $ship_id => &$planet_ship) { |
|
101 | + foreach ($ship_loadout as $ship_id => &$planet_ship) { |
|
102 | 102 | $can_take = min($will_take, $planet_ship['capacity']); |
103 | - if($can_take <= 0) { |
|
103 | + if ($can_take <= 0) { |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | $planet_ship['capacity'] -= $can_take; |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | $fleet[$ship_id] = ceil($planet_ship['taken'] / $transports[$ship_id]); |
109 | 109 | |
110 | 110 | $will_take -= $can_take; |
111 | - if($will_take <= 0) { |
|
111 | + if ($will_take <= 0) { |
|
112 | 112 | break; |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | - if(!empty($fleet)) { |
|
116 | + if (!empty($fleet)) { |
|
117 | 117 | $travel_data = flt_travel_data($user, $planetrow, $planet_db_data, $fleet, 10); |
118 | 118 | $planet_data['FLEET_SPEED'] = $travel_data['fleet_speed']; |
119 | 119 | $planet_data['DISTANCE'] = $travel_data['distance']; |
120 | 120 | $planet_data['DURATION'] = $travel_data['duration']; |
121 | 121 | $planet_data['CONSUMPTION'] = $travel_data['consumption']; |
122 | 122 | |
123 | - if(floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) { |
|
123 | + if (floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) { |
|
124 | 124 | $will_take = min($planet_resources, $fleet_capacity) - $planet_data['CONSUMPTION']; |
125 | 125 | |
126 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
127 | - if($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) { |
|
126 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
127 | + if ($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) { |
|
128 | 128 | continue; |
129 | 129 | } |
130 | 130 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $fleet[$resource_id] = min($will_take, $resource_amount); |
134 | 134 | $will_take -= $resource_amount; |
135 | 135 | |
136 | - if($will_take <= 0) { |
|
136 | + if ($will_take <= 0) { |
|
137 | 137 | break; |
138 | 138 | } |
139 | 139 | } |
@@ -157,19 +157,19 @@ discard block |
||
157 | 157 | |
158 | 158 | $resources_taken = sys_get_param('resources'); |
159 | 159 | |
160 | -if(!empty($resources_taken)) { // begin processing parameters |
|
160 | +if (!empty($resources_taken)) { // begin processing parameters |
|
161 | 161 | $planet_list = flt_build_gathering($resources_taken); |
162 | 162 | |
163 | - foreach($planet_list as $planet_id => $planet_data) { |
|
164 | - if($planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
163 | + foreach ($planet_list as $planet_id => $planet_data) { |
|
164 | + if ($planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
165 | 165 | $planet_data['RESULT'] = flt_t_send_fleet($user, $planet_data['PLANET_DB_DATA'], $planetrow, $planet_data['FLEET'], MT_TRANSPORT); |
166 | 166 | } |
167 | 167 | |
168 | 168 | $planet_data['MESSAGE'] = classLocale::$lang['fl_attack_error'][$planet_data['RESULT']]; |
169 | 169 | |
170 | 170 | $template->assign_block_vars('results', $planet_data); |
171 | - if(!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
172 | - foreach($planet_data['FLEET'] as $unit_id => $amount) { |
|
171 | + if (!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_ALLOWED) { |
|
172 | + foreach ($planet_data['FLEET'] as $unit_id => $amount) { |
|
173 | 173 | $template->assign_block_vars('results.units', array( |
174 | 174 | 'ID' => $unit_id, |
175 | 175 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | // Building list of own planets & moons |
184 | 184 | $planet_list = flt_build_gathering(); |
185 | -foreach($planet_list as $planet_data) { |
|
185 | +foreach ($planet_list as $planet_data) { |
|
186 | 186 | $planet_data['DURATION'] = $planet_data['DURATION'] ? pretty_time($planet_data['DURATION']) : classLocale::$lang['flt_no_fuel']; |
187 | 187 | $template->assign_block_vars('colonies', $planet_data); |
188 | 188 | } |
@@ -324,6 +324,10 @@ |
||
324 | 324 | * @return int|mixed |
325 | 325 | */ |
326 | 326 | // TODO - REDO!!!! |
327 | + |
|
328 | + /** |
|
329 | + * @return double |
|
330 | + */ |
|
327 | 331 | function flt_fleet_speed($user) { |
328 | 332 | $speeds = array(); |
329 | 333 | if(!empty($this->mapUnitIdToDb)) { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function offsetSet($offset, $value) { |
91 | 91 | if (isset($this->mapUnitIdToDb[$value->unitId])) { |
92 | - classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists'); |
|
92 | + classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId '.$value->unitId.' already exists'); |
|
93 | 93 | } |
94 | 94 | $this->mapUnitIdToDb[$value->unitId] = $value; |
95 | 95 | parent::offsetSet($offset, $value); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | public function unitGetCount($unit_id) { |
204 | 204 | if (empty($this->mapUnitIdToDb[$unit_id])) { |
205 | - throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList'); |
|
205 | + throw new Exception('Unit ['.$unit_id.'] is not exists in UnitList'); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | return $this->mapUnitIdToDb[$unit_id]->count; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | */ |
322 | 322 | $objFleet = $this->getLocatedAt(); |
323 | 323 | if (empty($objFleet)) { |
324 | - throw new Exception('No fleet owner on UnitList::unitsRender() in ' . __FILE__ . '@' . __LINE__); |
|
324 | + throw new Exception('No fleet owner on UnitList::unitsRender() in '.__FILE__.'@'.__LINE__); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | $tplShips = array(); |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | |
465 | 465 | // TODO - DEBUG - REMOVE ============================================================================================= |
466 | 466 | public function _dump() { |
467 | - print(__FILE__ . ':' . __LINE__ . "<br />"); |
|
468 | - print("Located at " . $this->getLocationDbId() . " type " . $this->getLocationType() . "<br />"); |
|
467 | + print(__FILE__.':'.__LINE__."<br />"); |
|
468 | + print("Located at ".$this->getLocationDbId()." type ".$this->getLocationType()."<br />"); |
|
469 | 469 | |
470 | 470 | print('<table border="1">'); |
471 | 471 | print('<tr>'); |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | |
522 | 522 | print('<td>'); |
523 | 523 | $type = $unit->getType(); |
524 | - print("[{$type}] " . classLocale::$lang['tech'][$type]); |
|
524 | + print("[{$type}] ".classLocale::$lang['tech'][$type]); |
|
525 | 525 | print('</td>'); |
526 | 526 | |
527 | 527 | print('<td>'); |
528 | - print("[{$unit->unitId}] " . classLocale::$lang['tech'][$unit->unitId]); |
|
528 | + print("[{$unit->unitId}] ".classLocale::$lang['tech'][$unit->unitId]); |
|
529 | 529 | print('</td>'); |
530 | 530 | |
531 | 531 | print('<td>'); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | require_once('general_pname.php'); |
13 | 13 | |
14 | 14 | /** |
15 | - * @param $func_name |
|
15 | + * @param string $func_name |
|
16 | 16 | * @param array $func_arg |
17 | 17 | * |
18 | 18 | * @return mixed |
@@ -63,6 +63,9 @@ discard block |
||
63 | 63 | |
64 | 64 | // ---------------------------------------------------------------------------------------------------------------- |
65 | 65 | // Fonction de lecture / ecriture / exploitation de templates |
66 | +/** |
|
67 | + * @param string $filename |
|
68 | + */ |
|
66 | 69 | function sys_file_read($filename) { |
67 | 70 | return @file_get_contents($filename); |
68 | 71 | } |
@@ -105,7 +108,7 @@ discard block |
||
105 | 108 | /** |
106 | 109 | * Получение курса обмены валюты в серверную валюту |
107 | 110 | * |
108 | - * @param $currency_symbol |
|
111 | + * @param string $currency_symbol |
|
109 | 112 | * |
110 | 113 | * @return float |
111 | 114 | */ |
@@ -146,7 +149,7 @@ discard block |
||
146 | 149 | * @param float $n |
147 | 150 | * @param int|bool $floor |
148 | 151 | * @param int|bool $color |
149 | - * @param int|bool $limit |
|
152 | + * @param boolean $limit |
|
150 | 153 | * @param bool|null $style |
151 | 154 | * |
152 | 155 | * @return array|float|string |
@@ -247,6 +250,9 @@ discard block |
||
247 | 250 | return preg_replace($ListCensure, '*', $String); |
248 | 251 | } |
249 | 252 | |
253 | +/** |
|
254 | + * @param string $email |
|
255 | + */ |
|
250 | 256 | function is_email($email) { |
251 | 257 | return (preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)); |
252 | 258 | } |
@@ -283,6 +289,9 @@ discard block |
||
283 | 289 | return floatval(sys_get_param($param_name, $default)); |
284 | 290 | } |
285 | 291 | |
292 | +/** |
|
293 | + * @param string $param_name |
|
294 | + */ |
|
286 | 295 | function sys_get_param_escaped($param_name, $default = '') { |
287 | 296 | return db_escape(sys_get_param($param_name, $default)); |
288 | 297 | } |
@@ -515,6 +524,9 @@ discard block |
||
515 | 524 | } |
516 | 525 | |
517 | 526 | // Generates random string of $length symbols from $allowed_chars charset |
527 | +/** |
|
528 | + * @param string $allowed_chars |
|
529 | + */ |
|
518 | 530 | function sys_random_string($length = 16, $allowed_chars = SN_SYS_SEC_CHARS_ALLOWED) { |
519 | 531 | $allowed_length = strlen($allowed_chars); |
520 | 532 | |
@@ -619,6 +631,9 @@ discard block |
||
619 | 631 | return implode(';', $fleet_string); |
620 | 632 | } |
621 | 633 | |
634 | +/** |
|
635 | + * @param string $body |
|
636 | + */ |
|
622 | 637 | function mymail($email_unsafe, $title, $body, $from = '', $html = false) { |
623 | 638 | $from = trim($from ? $from : classSupernova::$config->game_adminEmail); |
624 | 639 | |
@@ -873,6 +888,9 @@ discard block |
||
873 | 888 | return serialize($nick_array); |
874 | 889 | } |
875 | 890 | |
891 | +/** |
|
892 | + * @param string $nick_string |
|
893 | + */ |
|
876 | 894 | function player_nick_uncompact($nick_string) { |
877 | 895 | try { |
878 | 896 | $result = unserialize($nick_string); |
@@ -1120,6 +1138,9 @@ discard block |
||
1120 | 1138 | return $ranks; |
1121 | 1139 | } |
1122 | 1140 | |
1141 | +/** |
|
1142 | + * @param boolean $planet_id |
|
1143 | + */ |
|
1123 | 1144 | function sys_player_new_adjust($user_id, $planet_id) { return sn_function_call(__FUNCTION__, array($user_id, $planet_id, &$result)); } |
1124 | 1145 | |
1125 | 1146 | function sn_sys_player_new_adjust($user_id, $planet_id, &$result) { |
@@ -1430,6 +1451,9 @@ discard block |
||
1430 | 1451 | return version_compare(sn_version_compare_extra($ver1), sn_version_compare_extra($ver2)); |
1431 | 1452 | } |
1432 | 1453 | |
1454 | +/** |
|
1455 | + * @param string $name |
|
1456 | + */ |
|
1433 | 1457 | function sn_setcookie($name, $value = null, $expire = null, $path = SN_ROOT_RELATIVE, $domain = null, $secure = null, $httponly = null) { |
1434 | 1458 | $_COOKIE[$name] = $value; |
1435 | 1459 |
@@ -20,24 +20,24 @@ discard block |
||
20 | 20 | function sn_function_call($func_name, $func_arg = array()) { |
21 | 21 | // All data in classSupernova::$functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
22 | 22 | |
23 | - if(is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { |
|
23 | + if (is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { |
|
24 | 24 | // Chain-callable functions should be made as following: |
25 | 25 | // 1. Never use incomplete calls with parameters "by default" |
26 | 26 | // 2. Reserve last parameter for cumulative result |
27 | 27 | // 3. Use same format for original value and cumulative result (if there is original value) |
28 | 28 | // 4. Honor cumulative result |
29 | 29 | // 5. Return cumulative result |
30 | - foreach(classSupernova::$functions[$func_name] as $func_chain_name) { |
|
30 | + foreach (classSupernova::$functions[$func_name] as $func_chain_name) { |
|
31 | 31 | // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту |
32 | 32 | // Но для старых модулей... |
33 | - if(is_callable($func_chain_name)) { |
|
33 | + if (is_callable($func_chain_name)) { |
|
34 | 34 | $result = call_user_func_array($func_chain_name, $func_arg); |
35 | 35 | } |
36 | 36 | } |
37 | 37 | } else { |
38 | 38 | // TODO: This is left for backward compatibility. Appropriate code should be rewrote! |
39 | - $func_name = isset(classSupernova::$functions[$func_name]) && is_callable(classSupernova::$functions[$func_name]) ? classSupernova::$functions[$func_name] : ('sn_' . $func_name); |
|
40 | - if(is_callable($func_name)) { |
|
39 | + $func_name = isset(classSupernova::$functions[$func_name]) && is_callable(classSupernova::$functions[$func_name]) ? classSupernova::$functions[$func_name] : ('sn_'.$func_name); |
|
40 | + if (is_callable($func_name)) { |
|
41 | 41 | $result = call_user_func_array($func_name, $func_arg); |
42 | 42 | } |
43 | 43 | } |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @param string $page_name - имя страницы, для которого должен был быть выполнен хук |
53 | 53 | */ |
54 | 54 | function execute_hooks(&$hook_list, &$template, $hook_type = null, $page_name = null) { |
55 | - if(!empty($hook_list)) { |
|
56 | - foreach($hook_list as $hook) { |
|
57 | - if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
55 | + if (!empty($hook_list)) { |
|
56 | + foreach ($hook_list as $hook) { |
|
57 | + if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
58 | 58 | $template = call_user_func($hook_call, $template, $hook_type, $page_name); |
59 | 59 | } |
60 | 60 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function get_exchange_rate($currency_symbol) { |
113 | 113 | $currency_symbol = strtolower($currency_symbol); |
114 | - $config_field = 'payment_currency_exchange_' . $currency_symbol; |
|
114 | + $config_field = 'payment_currency_exchange_'.$currency_symbol; |
|
115 | 115 | |
116 | 116 | // Заворачиваем получение стоимости ММ через перекрываемую процедуру |
117 | 117 | $exchange_rate = floatval($currency_symbol == 'mm_' ? get_mm_cost() : classSupernova::$config->$config_field); |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | */ |
154 | 154 | function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) { |
155 | 155 | $n = floatval($n); |
156 | - if(is_int($floor)) { |
|
156 | + if (is_int($floor)) { |
|
157 | 157 | $n = round($n, $floor); // , PHP_ROUND_HALF_DOWN |
158 | - } elseif($floor === true) { |
|
158 | + } elseif ($floor === true) { |
|
159 | 159 | $n = floor($n); |
160 | 160 | $floor = 0; |
161 | 161 | } else { |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | $ret = $n; |
166 | 166 | |
167 | 167 | $suffix = ''; |
168 | - if($limit) { |
|
169 | - if($ret > 0) { |
|
170 | - while($ret > $limit) { |
|
168 | + if ($limit) { |
|
169 | + if ($ret > 0) { |
|
170 | + while ($ret > $limit) { |
|
171 | 171 | $suffix .= 'k'; |
172 | 172 | $ret = round($ret / 1000); |
173 | 173 | } |
174 | 174 | } else { |
175 | - while($ret < -$limit) { |
|
175 | + while ($ret < -$limit) { |
|
176 | 176 | $suffix .= 'k'; |
177 | 177 | $ret = round($ret / 1000); |
178 | 178 | } |
@@ -182,16 +182,16 @@ discard block |
||
182 | 182 | $ret = number_format($ret, $floor, ',', '.'); |
183 | 183 | $ret .= $suffix; |
184 | 184 | |
185 | - if($color !== false) { |
|
186 | - if($color === true) { |
|
185 | + if ($color !== false) { |
|
186 | + if ($color === true) { |
|
187 | 187 | $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative'); |
188 | - } elseif($color >= 0) { |
|
188 | + } elseif ($color >= 0) { |
|
189 | 189 | $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative'); |
190 | 190 | } else { |
191 | 191 | $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive'); |
192 | 192 | } |
193 | 193 | |
194 | - if(!isset($style)) { |
|
194 | + if (!isset($style)) { |
|
195 | 195 | $ret = "<span class='{$class}'>{$ret}</span>"; |
196 | 196 | } else { |
197 | 197 | $ret = $style ? $ret = $class : $ret = array('text' => $ret, 'class' => $class); |
@@ -320,11 +320,11 @@ discard block |
||
320 | 320 | |
321 | 321 | function sys_get_param_phone($param_name, $default = '') { |
322 | 322 | $phone_raw = sys_get_param_str_unsafe($param_name, $default = ''); |
323 | - if($phone_raw) { |
|
323 | + if ($phone_raw) { |
|
324 | 324 | $phone = $phone_raw[0] == '+' ? '+' : ''; |
325 | - for($i = 0; $i < strlen($phone_raw); $i++) { |
|
325 | + for ($i = 0; $i < strlen($phone_raw); $i++) { |
|
326 | 326 | $ord = ord($phone_raw[$i]); |
327 | - if($ord >= 48 && $ord <= 57) { |
|
327 | + if ($ord >= 48 && $ord <= 57) { |
|
328 | 328 | $phone .= $phone_raw[$i]; |
329 | 329 | } |
330 | 330 | } |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | } |
342 | 342 | |
343 | 343 | function CheckAbandonPlanetState(&$planet) { |
344 | - if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { |
|
344 | + if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { |
|
345 | 345 | db_planet_delete_by_id($planet['id']); |
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | 349 | function eco_get_total_cost($unit_id, $unit_level) { |
350 | 350 | static $rate, $sn_group_resources_all, $sn_group_resources_loot; |
351 | - if(!$rate) { |
|
351 | + if (!$rate) { |
|
352 | 352 | $sn_group_resources_all = sn_get_groups('resources_all'); |
353 | 353 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
354 | 354 | |
@@ -358,19 +358,19 @@ discard block |
||
358 | 358 | } |
359 | 359 | |
360 | 360 | $unit_cost_data = get_unit_param($unit_id, 'cost'); |
361 | - if(!is_array($unit_cost_data)) { |
|
361 | + if (!is_array($unit_cost_data)) { |
|
362 | 362 | return array('total' => 0); |
363 | 363 | } |
364 | 364 | $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1; |
365 | 365 | $cost_array = array(BUILD_CREATE => array(), 'total' => 0); |
366 | 366 | $unit_level = $unit_level > 0 ? $unit_level : 0; |
367 | - foreach($unit_cost_data as $resource_id => $resource_amount) { |
|
368 | - if(!in_array($resource_id, $sn_group_resources_all)) { |
|
367 | + foreach ($unit_cost_data as $resource_id => $resource_amount) { |
|
368 | + if (!in_array($resource_id, $sn_group_resources_all)) { |
|
369 | 369 | continue; |
370 | 370 | } |
371 | 371 | // $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1))); |
372 | 372 | $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor)))); |
373 | - if(in_array($resource_id, $sn_group_resources_loot)) { |
|
373 | + if (in_array($resource_id, $sn_group_resources_loot)) { |
|
374 | 374 | $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id]; |
375 | 375 | } |
376 | 376 | } |
@@ -454,19 +454,19 @@ discard block |
||
454 | 454 | $mercenary_level = 0; |
455 | 455 | $unit_db_name = pname_resource_name($unit_id); |
456 | 456 | |
457 | - if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
457 | + if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
458 | 458 | $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id); |
459 | 459 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
460 | - } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
460 | + } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
461 | 461 | $unit = classSupernova::db_get_unit_by_location(isset($user['id']) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id); |
462 | 462 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
463 | - } elseif(in_array($unit_id, sn_get_groups('governors'))) { |
|
463 | + } elseif (in_array($unit_id, sn_get_groups('governors'))) { |
|
464 | 464 | $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0; |
465 | - } elseif($unit_id == RES_DARK_MATTER) { |
|
465 | + } elseif ($unit_id == RES_DARK_MATTER) { |
|
466 | 466 | $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter); |
467 | - } elseif($unit_id == RES_METAMATTER) { |
|
467 | + } elseif ($unit_id == RES_METAMATTER) { |
|
468 | 468 | $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name]; |
469 | - } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
469 | + } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
470 | 470 | $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name]; |
471 | 471 | } |
472 | 472 | |
@@ -476,19 +476,19 @@ discard block |
||
476 | 476 | function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) { return sn_function_call(__FUNCTION__, array(&$user, $planet, $mercenaries, $value)); } |
477 | 477 | |
478 | 478 | function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) { |
479 | - if(!is_array($mercenaries)) { |
|
479 | + if (!is_array($mercenaries)) { |
|
480 | 480 | $mercenaries = array($mercenaries); |
481 | 481 | } |
482 | 482 | |
483 | 483 | $base_value = isset($base_value) ? $base_value : $value; |
484 | 484 | |
485 | - foreach($mercenaries as $mercenary_id) { |
|
485 | + foreach ($mercenaries as $mercenary_id) { |
|
486 | 486 | $mercenary_level = mrc_get_level($user, $planet, $mercenary_id); |
487 | 487 | |
488 | 488 | $mercenary = get_unit_param($mercenary_id); |
489 | 489 | $mercenary_bonus = $mercenary['bonus']; |
490 | 490 | |
491 | - switch($mercenary['bonus_type']) { |
|
491 | + switch ($mercenary['bonus_type']) { |
|
492 | 492 | case BONUS_PERCENT_CUMULATIVE: |
493 | 493 | $value *= 1 + $mercenary_level * $mercenary_bonus / 100; |
494 | 494 | break; |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | $allowed_length = strlen($allowed_chars); |
520 | 520 | |
521 | 521 | $random_string = ''; |
522 | - for($i = 0; $i < $length; $i++) { |
|
522 | + for ($i = 0; $i < $length; $i++) { |
|
523 | 523 | $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)]; |
524 | 524 | } |
525 | 525 | |
@@ -539,12 +539,12 @@ discard block |
||
539 | 539 | |
540 | 540 | $options = ''; |
541 | 541 | $option_list = array(); |
542 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
542 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
543 | 543 | $option_list[$option_group_id] = array(); |
544 | - foreach($option_group as $option_name => $option_value) { |
|
545 | - if(!isset($user[$option_name])) { |
|
544 | + foreach ($option_group as $option_name => $option_value) { |
|
545 | + if (!isset($user[$option_name])) { |
|
546 | 546 | $user[$option_name] = $option_value; |
547 | - } elseif($user[$option_name] == '') { |
|
547 | + } elseif ($user[$option_name] == '') { |
|
548 | 548 | $user[$option_name] = 0; |
549 | 549 | } |
550 | 550 | $options .= "{$option_name}^{$user[$option_name]}|"; |
@@ -564,16 +564,16 @@ discard block |
||
564 | 564 | $option_list = array(); |
565 | 565 | $option_string_list = explode('|', $user['options']); |
566 | 566 | |
567 | - foreach($option_string_list as $option_string) { |
|
567 | + foreach ($option_string_list as $option_string) { |
|
568 | 568 | list($option_name, $option_value) = explode('^', $option_string); |
569 | 569 | $option_list[$option_name] = $option_value; |
570 | 570 | } |
571 | 571 | |
572 | 572 | $final_list = array(); |
573 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
573 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
574 | 574 | $final_list[$option_group_id] = array(); |
575 | - foreach($option_group as $option_name => $option_value) { |
|
576 | - if(!isset($option_list[$option_name])) { |
|
575 | + foreach ($option_group as $option_name => $option_value) { |
|
576 | + if (!isset($option_list[$option_name])) { |
|
577 | 577 | $option_list[$option_name] = $option_value; |
578 | 578 | } |
579 | 579 | $user[$option_name] = $final_list[$option_group_id][$option_name] = $option_list[$option_name]; |
@@ -587,12 +587,12 @@ discard block |
||
587 | 587 | |
588 | 588 | function sys_unit_str2arr($fleet_string) { |
589 | 589 | $fleet_array = array(); |
590 | - if(!empty($fleet_string)) { |
|
590 | + if (!empty($fleet_string)) { |
|
591 | 591 | $arrTemp = explode(';', $fleet_string); |
592 | - foreach($arrTemp as $temp) { |
|
593 | - if($temp) { |
|
592 | + foreach ($arrTemp as $temp) { |
|
593 | + if ($temp) { |
|
594 | 594 | $temp = explode(',', $temp); |
595 | - if(!empty($temp[0]) && !empty($temp[1])) { |
|
595 | + if (!empty($temp[0]) && !empty($temp[1])) { |
|
596 | 596 | $fleet_array[$temp[0]] += $temp[1]; |
597 | 597 | } |
598 | 598 | } |
@@ -604,13 +604,13 @@ discard block |
||
604 | 604 | |
605 | 605 | function sys_unit_arr2str($unit_list) { |
606 | 606 | $fleet_string = array(); |
607 | - if(isset($unit_list)) { |
|
608 | - if(!is_array($unit_list)) { |
|
607 | + if (isset($unit_list)) { |
|
608 | + if (!is_array($unit_list)) { |
|
609 | 609 | $unit_list = array($unit_list => 1); |
610 | 610 | } |
611 | 611 | |
612 | - foreach($unit_list as $unit_id => $unit_count) { |
|
613 | - if($unit_id && $unit_count) { |
|
612 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
613 | + if ($unit_id && $unit_count) { |
|
614 | 614 | $fleet_string[] = "{$unit_id},{$unit_count}"; |
615 | 615 | } |
616 | 616 | } |
@@ -623,8 +623,8 @@ discard block |
||
623 | 623 | $from = trim($from ? $from : classSupernova::$config->game_adminEmail); |
624 | 624 | |
625 | 625 | $head = ''; |
626 | - $head .= "Content-Type: text/" . ($html ? 'html' : 'plain') . "; charset=utf-8 \r\n"; |
|
627 | - $head .= "Date: " . date('r') . " \r\n"; |
|
626 | + $head .= "Content-Type: text/".($html ? 'html' : 'plain')."; charset=utf-8 \r\n"; |
|
627 | + $head .= "Date: ".date('r')." \r\n"; |
|
628 | 628 | $classConfig = classSupernova::$config; |
629 | 629 | $head .= "Return-Path: {$classConfig->game_adminEmail} \r\n"; |
630 | 630 | $head .= "From: {$from} \r\n"; |
@@ -636,11 +636,11 @@ discard block |
||
636 | 636 | $body = str_replace("\r\n", "\n", $body); |
637 | 637 | $body = str_replace("\n", "\r\n", $body); |
638 | 638 | |
639 | - if($html) { |
|
640 | - $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>'; |
|
639 | + if ($html) { |
|
640 | + $body = '<html><head><base href="'.SN_ROOT_VIRTUAL.'"></head><body>'.nl2br($body).'</body></html>'; |
|
641 | 641 | } |
642 | 642 | |
643 | - $title = '=?UTF-8?B?' . base64_encode($title) . '?='; |
|
643 | + $title = '=?UTF-8?B?'.base64_encode($title).'?='; |
|
644 | 644 | |
645 | 645 | return @mail($email_unsafe, $title, $body, $head); |
646 | 646 | } |
@@ -656,14 +656,14 @@ discard block |
||
656 | 656 | $classLocale = classLocale::$lang; |
657 | 657 | |
658 | 658 | return |
659 | - ($full || $time ? "{$time} {$classLocale['sys_day']} " : '') . |
|
660 | - ($full || $hours ? "{$hours} {$classLocale['sys_hrs']} " : '') . |
|
661 | - ($full || $minutes ? "{$minutes} {$classLocale['sys_min']} " : '') . |
|
659 | + ($full || $time ? "{$time} {$classLocale['sys_day']} " : ''). |
|
660 | + ($full || $hours ? "{$hours} {$classLocale['sys_hrs']} " : ''). |
|
661 | + ($full || $minutes ? "{$minutes} {$classLocale['sys_min']} " : ''). |
|
662 | 662 | ($full || !$time || $seconds ? "{$seconds} {$classLocale['sys_sec']}" : ''); |
663 | 663 | } |
664 | 664 | |
665 | 665 | function sys_time_human_system($time) { |
666 | - return $time ? date(FMT_DATE_TIME_SQL, $time) . " ({$time}), " . sys_time_human(SN_TIME_NOW - $time) : '{NEVER}'; |
|
666 | + return $time ? date(FMT_DATE_TIME_SQL, $time)." ({$time}), ".sys_time_human(SN_TIME_NOW - $time) : '{NEVER}'; |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | function sys_redirect($url) { |
@@ -680,21 +680,21 @@ discard block |
||
680 | 680 | } |
681 | 681 | |
682 | 682 | function sn_ali_fill_user_ally(&$user) { |
683 | - if(!$user['ally_id']) { |
|
683 | + if (!$user['ally_id']) { |
|
684 | 684 | return; |
685 | 685 | } |
686 | 686 | |
687 | - if(!isset($user['ally'])) { |
|
687 | + if (!isset($user['ally'])) { |
|
688 | 688 | $user['ally'] = db_ally_get_by_id($user['ally_id']); |
689 | 689 | } |
690 | 690 | |
691 | - if(!isset($user['ally']['player'])) { |
|
691 | + if (!isset($user['ally']['player'])) { |
|
692 | 692 | $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false); |
693 | 693 | } |
694 | 694 | } |
695 | 695 | |
696 | 696 | function sn_get_url_contents($url) { |
697 | - if(function_exists('curl_init')) { |
|
697 | + if (function_exists('curl_init')) { |
|
698 | 698 | $crl = curl_init(); |
699 | 699 | $timeout = 5; |
700 | 700 | curl_setopt($crl, CURLOPT_URL, $url); |
@@ -729,10 +729,10 @@ discard block |
||
729 | 729 | |
730 | 730 | function get_ship_data($ship_id, $user) { |
731 | 731 | $ship_data = array(); |
732 | - if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
733 | - foreach(get_unit_param($ship_id, 'engine') as $engine_info) { |
|
732 | + if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
733 | + foreach (get_unit_param($ship_id, 'engine') as $engine_info) { |
|
734 | 734 | $tech_level = intval(mrc_get_level($user, null, $engine_info['tech'])); |
735 | - if(empty($ship_data) || $tech_level >= $engine_info['min_level']) { |
|
735 | + if (empty($ship_data) || $tech_level >= $engine_info['min_level']) { |
|
736 | 736 | $ship_data = $engine_info; |
737 | 737 | $ship_data['tech_level'] = $tech_level; |
738 | 738 | } |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | return $ship_data; |
745 | 745 | } |
746 | 746 | |
747 | -if(!function_exists('strptime')) { |
|
747 | +if (!function_exists('strptime')) { |
|
748 | 748 | function strptime($date, $format) { |
749 | 749 | $masks = array( |
750 | 750 | '%d' => '(?P<d>[0-9]{2})', |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | // usw.. |
757 | 757 | ); |
758 | 758 | |
759 | - $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
|
760 | - if(preg_match($rexep, $date, $out)) { |
|
759 | + $rexep = "#".strtr(preg_quote($format), $masks)."#"; |
|
760 | + if (preg_match($rexep, $date, $out)) { |
|
761 | 761 | $ret = array( |
762 | - "tm_sec" => (int)$out['S'], |
|
763 | - "tm_min" => (int)$out['M'], |
|
764 | - "tm_hour" => (int)$out['H'], |
|
765 | - "tm_mday" => (int)$out['d'], |
|
762 | + "tm_sec" => (int) $out['S'], |
|
763 | + "tm_min" => (int) $out['M'], |
|
764 | + "tm_hour" => (int) $out['H'], |
|
765 | + "tm_mday" => (int) $out['d'], |
|
766 | 766 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
767 | 767 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
768 | 768 | ); |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | function sn_sys_sector_buy($redirect = 'overview.php') { |
778 | 778 | global $user, $planetrow; |
779 | 779 | |
780 | - if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
780 | + if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
781 | 781 | return; |
782 | 782 | } |
783 | 783 | |
@@ -790,9 +790,9 @@ discard block |
||
790 | 790 | // $planetrow = $planetrow['planet']; |
791 | 791 | $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true); |
792 | 792 | $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER]; |
793 | - if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
793 | + if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
794 | 794 | $planet_name_text = uni_render_planet($planetrow); |
795 | - if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'], |
|
795 | + if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'], |
|
796 | 796 | $user['username'], $user['id'], $planet_name_text, classLocale::$lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost) |
797 | 797 | )) { |
798 | 798 | $sector_db_name = pname_resource_name(UNIT_SECTOR); |
@@ -807,32 +807,32 @@ discard block |
||
807 | 807 | } |
808 | 808 | |
809 | 809 | function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') { |
810 | - if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { |
|
811 | - foreach($handler_list as $function_name => $function_data) { |
|
812 | - if(is_string($function_data)) { |
|
810 | + if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { |
|
811 | + foreach ($handler_list as $function_name => $function_data) { |
|
812 | + if (is_string($function_data)) { |
|
813 | 813 | $override_with = &$function_data; |
814 | - } elseif(isset($function_data['callable'])) { |
|
814 | + } elseif (isset($function_data['callable'])) { |
|
815 | 815 | $override_with = &$function_data['callable']; |
816 | 816 | } |
817 | 817 | |
818 | 818 | $overwrite = $override_with[0] == '*'; |
819 | - if($overwrite) { |
|
819 | + if ($overwrite) { |
|
820 | 820 | $override_with = substr($override_with, 1); |
821 | 821 | } |
822 | 822 | |
823 | - if(($point_position = strpos($override_with, '.')) === false && $class_module_name) { |
|
823 | + if (($point_position = strpos($override_with, '.')) === false && $class_module_name) { |
|
824 | 824 | $override_with = array($class_module_name, $override_with); |
825 | - } elseif($point_position == 0) { |
|
825 | + } elseif ($point_position == 0) { |
|
826 | 826 | $override_with = substr($override_with, 1); |
827 | - } elseif($point_position > 0) { |
|
827 | + } elseif ($point_position > 0) { |
|
828 | 828 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
829 | 829 | } |
830 | 830 | |
831 | - if($overwrite) { |
|
831 | + if ($overwrite) { |
|
832 | 832 | $functions[$function_name] = array(); |
833 | - } elseif(!isset($functions[$function_name])) { |
|
833 | + } elseif (!isset($functions[$function_name])) { |
|
834 | 834 | $functions[$function_name] = array(); |
835 | - $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
|
835 | + $sn_function_name = 'sn_'.$function_name.($sub_type ? '_'.$sub_type : ''); |
|
836 | 836 | $functions[$function_name][] = $sn_function_name; |
837 | 837 | } |
838 | 838 | |
@@ -846,15 +846,15 @@ discard block |
||
846 | 846 | function player_nick_render_to_html($result, $options = false) { |
847 | 847 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string |
848 | 848 | |
849 | - if(is_string($result) && strpos($result, ':{i:')) { |
|
849 | + if (is_string($result) && strpos($result, ':{i:')) { |
|
850 | 850 | $result = player_nick_uncompact($result); |
851 | 851 | } |
852 | 852 | |
853 | - if(is_array($result)) { |
|
854 | - if(isset($result['id'])) { |
|
853 | + if (is_array($result)) { |
|
854 | + if (isset($result['id'])) { |
|
855 | 855 | $result = player_nick_render_current_to_array($result, $options); |
856 | 856 | } |
857 | - if(!isset($result[NICK_HTML])) { |
|
857 | + if (!isset($result[NICK_HTML])) { |
|
858 | 858 | $result = player_nick_render_array_to_html($result); |
859 | 859 | } |
860 | 860 | unset($result[NICK_HTML]); |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | try { |
878 | 878 | $result = unserialize($nick_string); |
879 | 879 | // ksort($result); // Всегда ksort-ый в player_nick_compact() |
880 | - } catch(exception $e) { |
|
880 | + } catch (exception $e) { |
|
881 | 881 | $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example |
882 | 882 | } |
883 | 883 | |
@@ -890,20 +890,20 @@ discard block |
||
890 | 890 | global $user; |
891 | 891 | |
892 | 892 | // ALL STRING ARE UNSAFE!!! |
893 | - if(isset($nick_array[NICK_BIRTHSDAY])) { |
|
893 | + if (isset($nick_array[NICK_BIRTHSDAY])) { |
|
894 | 894 | $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />'; |
895 | 895 | } |
896 | 896 | |
897 | - if(isset($nick_array[NICK_VACATION])) { |
|
897 | + if (isset($nick_array[NICK_VACATION])) { |
|
898 | 898 | $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />'; |
899 | 899 | } |
900 | 900 | |
901 | - if(isset($nick_array[NICK_GENDER])) { |
|
902 | - $result[NICK_GENDER] = '<img src="' . ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />'; |
|
901 | + if (isset($nick_array[NICK_GENDER])) { |
|
902 | + $result[NICK_GENDER] = '<img src="'.($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH).'images/gender_'.$nick_array[NICK_GENDER].'.png" />'; |
|
903 | 903 | } |
904 | 904 | |
905 | - if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
906 | - switch($nick_array[NICK_AUTH_LEVEL]) { |
|
905 | + if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
906 | + switch ($nick_array[NICK_AUTH_LEVEL]) { |
|
907 | 907 | case 4: |
908 | 908 | $highlight = classSupernova::$config->chat_highlight_developer; |
909 | 909 | break; |
@@ -924,21 +924,21 @@ discard block |
||
924 | 924 | $highlight = isset($nick_array[NICK_PREMIUM]) ? classSupernova::$config->chat_highlight_premium : ''; |
925 | 925 | } |
926 | 926 | |
927 | - if($highlight) { |
|
927 | + if ($highlight) { |
|
928 | 928 | list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight); |
929 | 929 | } |
930 | 930 | // $result = preg_replace("#(.+)#", $highlight, $result); |
931 | 931 | } |
932 | 932 | |
933 | - if(isset($nick_array[NICK_CLASS])) { |
|
934 | - $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>'; |
|
933 | + if (isset($nick_array[NICK_CLASS])) { |
|
934 | + $result[NICK_CLASS] = '<span '.$nick_array[NICK_CLASS].'>'; |
|
935 | 935 | $result[NICK_CLASS_END] = '</span>'; |
936 | 936 | } |
937 | 937 | |
938 | 938 | $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]); |
939 | 939 | |
940 | - if(isset($nick_array[NICK_ALLY])) { |
|
941 | - $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']'; |
|
940 | + if (isset($nick_array[NICK_ALLY])) { |
|
941 | + $result[NICK_ALLY] = '['.sys_safe_output($nick_array[NICK_ALLY]).']'; |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | $result[NICK_HTML] = true; |
@@ -961,32 +961,32 @@ discard block |
||
961 | 961 | */ |
962 | 962 | |
963 | 963 | |
964 | - if($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
|
964 | + if ($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW).date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
|
965 | 965 | $result[NICK_BIRTHSDAY] = ''; |
966 | 966 | } |
967 | 967 | |
968 | - if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
968 | + if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
969 | 969 | $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male'); |
970 | 970 | } |
971 | 971 | |
972 | - if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
972 | + if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
973 | 973 | $result[NICK_VACATION] = $render_user['vacation']; |
974 | 974 | } |
975 | 975 | |
976 | - if($options === true || (isset($options['color']) && $options['color'])) { |
|
977 | - if($user_auth_level = $render_user['authlevel']) { |
|
976 | + if ($options === true || (isset($options['color']) && $options['color'])) { |
|
977 | + if ($user_auth_level = $render_user['authlevel']) { |
|
978 | 978 | $result[NICK_AUTH_LEVEL] = $user_auth_level; |
979 | 979 | } |
980 | - if($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) { |
|
980 | + if ($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) { |
|
981 | 981 | $result[NICK_PREMIUM] = $user_premium; |
982 | 982 | } |
983 | 983 | } |
984 | 984 | |
985 | - if((isset($options['class']) && $options['class'])) { |
|
986 | - $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class']; |
|
985 | + if ((isset($options['class']) && $options['class'])) { |
|
986 | + $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' '.$result_options[NICK_CLASS] : '').$options['class']; |
|
987 | 987 | } |
988 | 988 | |
989 | - if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
989 | + if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
990 | 990 | $result[NICK_ALLY] = $render_user['ally_tag']; |
991 | 991 | } |
992 | 992 | |
@@ -1002,25 +1002,25 @@ discard block |
||
1002 | 1002 | |
1003 | 1003 | $user_skip_list = array(); |
1004 | 1004 | |
1005 | - if(classSupernova::$config->stats_hide_admins) { |
|
1005 | + if (classSupernova::$config->stats_hide_admins) { |
|
1006 | 1006 | $user_skip_list[] = '`authlevel` > 0'; |
1007 | 1007 | } |
1008 | 1008 | |
1009 | - if(classSupernova::$config->stats_hide_player_list) { |
|
1009 | + if (classSupernova::$config->stats_hide_player_list) { |
|
1010 | 1010 | $temp = explode(',', classSupernova::$config->stats_hide_player_list); |
1011 | - foreach($temp as $user_id) { |
|
1011 | + foreach ($temp as $user_id) { |
|
1012 | 1012 | $user_id = floatval($user_id); |
1013 | - if($user_id) { |
|
1014 | - $user_skip_list[] = '`id` = ' . $user_id; |
|
1013 | + if ($user_id) { |
|
1014 | + $user_skip_list[] = '`id` = '.$user_id; |
|
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | } |
1018 | 1018 | |
1019 | - if(!empty($user_skip_list)) { |
|
1019 | + if (!empty($user_skip_list)) { |
|
1020 | 1020 | $user_skip_list = implode(' OR ', $user_skip_list); |
1021 | 1021 | $user_skip_query = db_user_list($user_skip_list); |
1022 | - if(!empty($user_skip_query)) { |
|
1023 | - foreach($user_skip_query as $user_skip_row) { |
|
1022 | + if (!empty($user_skip_query)) { |
|
1023 | + foreach ($user_skip_query as $user_skip_row) { |
|
1024 | 1024 | $result[$user_skip_row['id']] = $user_skip_row['id']; |
1025 | 1025 | } |
1026 | 1026 | } |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | */ |
1063 | 1063 | function sn_sn_get_groups($groups, &$result) { |
1064 | 1064 | $result = is_array($result) ? $result : array(); |
1065 | - foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) { |
|
1065 | + foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) { |
|
1066 | 1066 | $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array(); |
1067 | 1067 | } |
1068 | 1068 | |
@@ -1088,8 +1088,8 @@ discard block |
||
1088 | 1088 | $sn_data_unit = get_unit_param($unit_id); |
1089 | 1089 | |
1090 | 1090 | $result = is_array($result) ? $result : array(); |
1091 | - if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) { |
|
1092 | - foreach($sn_data_unit[$field] as $require_id => $require_level) { |
|
1091 | + if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) { |
|
1092 | + foreach ($sn_data_unit[$field] as $require_id => $require_level) { |
|
1093 | 1093 | $level_got = mrc_get_level($user, $planetrow, $require_id); |
1094 | 1094 | $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true); |
1095 | 1095 | $result[] = array( |
@@ -1113,16 +1113,16 @@ discard block |
||
1113 | 1113 | |
1114 | 1114 | $ranks = array(); |
1115 | 1115 | |
1116 | - if($ally['ranklist']) { |
|
1116 | + if ($ally['ranklist']) { |
|
1117 | 1117 | $str_ranks = explode(';', $ally['ranklist']); |
1118 | - foreach($str_ranks as $str_rank) { |
|
1119 | - if(!$str_rank) { |
|
1118 | + foreach ($str_ranks as $str_rank) { |
|
1119 | + if (!$str_rank) { |
|
1120 | 1120 | continue; |
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | $tmp = explode(',', $str_rank); |
1124 | 1124 | $rank_id = count($ranks); |
1125 | - foreach($ally_rights as $key => $value) { |
|
1125 | + foreach ($ally_rights as $key => $value) { |
|
1126 | 1126 | $ranks[$rank_id][$value] = $tmp[$key]; |
1127 | 1127 | } |
1128 | 1128 | } |
@@ -1138,8 +1138,8 @@ discard block |
||
1138 | 1138 | } |
1139 | 1139 | |
1140 | 1140 | function array_merge_recursive_numeric($array1, $array2) { |
1141 | - if(!empty($array2) && is_array($array2)) { |
|
1142 | - foreach($array2 as $key => $value) { |
|
1141 | + if (!empty($array2) && is_array($array2)) { |
|
1142 | + foreach ($array2 as $key => $value) { |
|
1143 | 1143 | // if(!isset($array1[$key]) || !is_array($array1[$key])) { |
1144 | 1144 | // $array1[$key] = $value; |
1145 | 1145 | // } else { |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | |
1155 | 1155 | function sn_sys_array_cumulative_sum(&$array) { |
1156 | 1156 | $accum = 0; |
1157 | - foreach($array as &$value) { |
|
1157 | + foreach ($array as &$value) { |
|
1158 | 1158 | $accum += $value; |
1159 | 1159 | $value = $accum; |
1160 | 1160 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | $sn_data_density = sn_get_groups('planet_density'); |
1165 | 1165 | $density_price_chart = array(); |
1166 | 1166 | |
1167 | - foreach($sn_data_density as $density_id => $density_data) { |
|
1167 | + foreach ($sn_data_density as $density_id => $density_data) { |
|
1168 | 1168 | // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра |
1169 | 1169 | $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false; |
1170 | 1170 | } |
@@ -1172,7 +1172,7 @@ discard block |
||
1172 | 1172 | |
1173 | 1173 | $total_rarity = array_sum($density_price_chart); |
1174 | 1174 | |
1175 | - foreach($density_price_chart as &$density_data) { |
|
1175 | + foreach ($density_price_chart as &$density_data) { |
|
1176 | 1176 | $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE); |
1177 | 1177 | } |
1178 | 1178 | |
@@ -1180,16 +1180,16 @@ discard block |
||
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | function sn_sys_planet_core_transmute(&$user, &$planetrow) { |
1183 | - if(!sys_get_param_str('transmute')) { |
|
1183 | + if (!sys_get_param_str('transmute')) { |
|
1184 | 1184 | return array(); |
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | try { |
1188 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
1188 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
1189 | 1189 | throw new exception(classLocale::$lang['ov_core_err_not_a_planet'], ERR_ERROR); |
1190 | 1190 | } |
1191 | 1191 | |
1192 | - if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
1192 | + if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
1193 | 1193 | throw new exception(classLocale::$lang['ov_core_err_same_density'], ERR_WARNING); |
1194 | 1194 | } |
1195 | 1195 | |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | $planet_density_index = $planetrow['density_index']; |
1204 | 1204 | |
1205 | 1205 | $density_price_chart = planet_density_price_chart($planetrow); |
1206 | - if(!isset($density_price_chart[$new_density_index])) { |
|
1206 | + if (!isset($density_price_chart[$new_density_index])) { |
|
1207 | 1207 | // Hack attempt |
1208 | 1208 | throw new exception(classLocale::$lang['ov_core_err_denisty_type_wrong'], ERR_ERROR); |
1209 | 1209 | } |
@@ -1212,13 +1212,13 @@ discard block |
||
1212 | 1212 | // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost'); |
1213 | 1213 | // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index]; |
1214 | 1214 | $transmute_cost = $density_price_chart[$new_density_index]; |
1215 | - if($user_dark_matter < $transmute_cost) { |
|
1215 | + if ($user_dark_matter < $transmute_cost) { |
|
1216 | 1216 | throw new exception(classLocale::$lang['ov_core_err_no_dark_matter'], ERR_ERROR); |
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | $sn_data_planet_density = sn_get_groups('planet_density'); |
1220 | - foreach($sn_data_planet_density as $key => $value) { |
|
1221 | - if($key == $new_density_index) { |
|
1220 | + foreach ($sn_data_planet_density as $key => $value) { |
|
1221 | + if ($key == $new_density_index) { |
|
1222 | 1222 | break; |
1223 | 1223 | } |
1224 | 1224 | $prev_density_index = $key; |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | 'STATUS' => ERR_NONE, |
1250 | 1250 | 'MESSAGE' => sprintf(classLocale::$lang['ov_core_err_none'], classLocale::$lang['uni_planet_density_types'][$planet_density_index], classLocale::$lang['uni_planet_density_types'][$new_density_index], $new_density), |
1251 | 1251 | ); |
1252 | - } catch(exception $e) { |
|
1252 | + } catch (exception $e) { |
|
1253 | 1253 | sn_db_transaction_rollback(); |
1254 | 1254 | $result = array( |
1255 | 1255 | 'STATUS' => $e->getCode(), |
@@ -1262,8 +1262,8 @@ discard block |
||
1262 | 1262 | |
1263 | 1263 | function sn_module_get_active_count($group = '*') { |
1264 | 1264 | $active_modules = 0; |
1265 | - if(isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { |
|
1266 | - foreach(sn_module::$sn_module_list[$group] as $payment_module) { |
|
1265 | + if (isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { |
|
1266 | + foreach (sn_module::$sn_module_list[$group] as $payment_module) { |
|
1267 | 1267 | $active_modules += $payment_module->manifest['active']; |
1268 | 1268 | } |
1269 | 1269 | } |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | function get_resource_exchange() { |
1275 | 1275 | static $rates; |
1276 | 1276 | |
1277 | - if(!$rates) { |
|
1277 | + if (!$rates) { |
|
1278 | 1278 | $rates = array( |
1279 | 1279 | RES_METAL => 'rpg_exchange_metal', |
1280 | 1280 | RES_CRYSTAL => 'rpg_exchange_crystal', |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | RES_DARK_MATTER => 'rpg_exchange_darkMatter', |
1283 | 1283 | ); |
1284 | 1284 | |
1285 | - foreach($rates as &$rate) { |
|
1285 | + foreach ($rates as &$rate) { |
|
1286 | 1286 | $rate = classSupernova::$config->$rate; |
1287 | 1287 | } |
1288 | 1288 | } |
@@ -1293,12 +1293,12 @@ discard block |
||
1293 | 1293 | function get_unit_cost_in(&$cost, $in_resource = RES_METAL) { |
1294 | 1294 | static $rates; |
1295 | 1295 | |
1296 | - if(!$rates) { |
|
1296 | + if (!$rates) { |
|
1297 | 1297 | $rates = get_resource_exchange(); |
1298 | 1298 | } |
1299 | 1299 | |
1300 | 1300 | $metal_cost = 0; |
1301 | - foreach($cost as $resource_id => $resource_value) { |
|
1301 | + foreach ($cost as $resource_id => $resource_value) { |
|
1302 | 1302 | $metal_cost += $rates[$resource_id] * $resource_value; |
1303 | 1303 | } |
1304 | 1304 | |
@@ -1321,8 +1321,8 @@ discard block |
||
1321 | 1321 | * @return float|int |
1322 | 1322 | */ |
1323 | 1323 | function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) { |
1324 | - if($astrotech == -1) { |
|
1325 | - if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { |
|
1324 | + if ($astrotech == -1) { |
|
1325 | + if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { |
|
1326 | 1326 | $astrotech = mrc_get_level($user, null, TECH_ASTROTECH); |
1327 | 1327 | $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0; |
1328 | 1328 | } |
@@ -1338,8 +1338,8 @@ discard block |
||
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | function get_player_max_colonies(&$user, $astrotech = -1) { |
1341 | - if($astrotech == -1) { |
|
1342 | - if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
1341 | + if ($astrotech == -1) { |
|
1342 | + if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
1343 | 1343 | |
1344 | 1344 | $expeditions = get_player_max_expeditons($user); |
1345 | 1345 | $astrotech = mrc_get_level($user, null, TECH_ASTROTECH); |
@@ -1384,10 +1384,10 @@ discard block |
||
1384 | 1384 | |
1385 | 1385 | // pdump($powerup_unit, '$powerup_unit'); |
1386 | 1386 | $level_current = $term_original = $time_left = 0; |
1387 | - if($is_upgrade) { |
|
1387 | + if ($is_upgrade) { |
|
1388 | 1388 | $time_finish = strtotime($powerup_unit['unit_time_finish']); |
1389 | 1389 | $time_left = max(0, $time_finish - SN_TIME_NOW); |
1390 | - if($time_left > 0) { |
|
1390 | + if ($time_left > 0) { |
|
1391 | 1391 | $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']); |
1392 | 1392 | $level_current = $powerup_unit['unit_level']; |
1393 | 1393 | } |
@@ -1395,22 +1395,22 @@ discard block |
||
1395 | 1395 | |
1396 | 1396 | $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK]; |
1397 | 1397 | $original_cost = 0; |
1398 | - for($i = 1; $i <= $level_max; $i++) { |
|
1398 | + for ($i = 1; $i <= $level_max; $i++) { |
|
1399 | 1399 | $base_cost = eco_get_total_cost($powerup_id, $i); |
1400 | 1400 | $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER]; |
1401 | - foreach($sn_powerup_buy_discounts as $period => $discount) { |
|
1401 | + foreach ($sn_powerup_buy_discounts as $period => $discount) { |
|
1402 | 1402 | $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH); |
1403 | 1403 | $result[$i][$period] = $upgrade_price; |
1404 | 1404 | $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost; |
1405 | 1405 | } |
1406 | 1406 | } |
1407 | 1407 | |
1408 | - if($is_upgrade && $time_left) { |
|
1408 | + if ($is_upgrade && $time_left) { |
|
1409 | 1409 | $term_original = round($term_original / PERIOD_DAY); |
1410 | 1410 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
1411 | 1411 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
1412 | 1412 | |
1413 | - array_walk_recursive($result, function (&$value) use ($cost_left) { |
|
1413 | + array_walk_recursive($result, function(&$value) use ($cost_left) { |
|
1414 | 1414 | $value -= $cost_left; |
1415 | 1415 | }); |
1416 | 1416 | } |
@@ -1465,8 +1465,8 @@ discard block |
||
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | function print_rr($var, $capture = false) { |
1468 | - $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>'; |
|
1469 | - if($capture) { |
|
1468 | + $print = '<pre>'.htmlspecialchars(print_r($var, true)).'</pre>'; |
|
1469 | + if ($capture) { |
|
1470 | 1470 | return $print; |
1471 | 1471 | } else { |
1472 | 1472 | print($print); |
@@ -1545,8 +1545,8 @@ discard block |
||
1545 | 1545 | * @return mixed |
1546 | 1546 | */ |
1547 | 1547 | function sortUnitRenderedList(&$ListToSort, $sort_option, $sort_option_inverse) { |
1548 | - if($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
1549 | - switch($sort_option) { |
|
1548 | + if ($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
1549 | + switch ($sort_option) { |
|
1550 | 1550 | case PLAYER_OPTION_SORT_NAME: |
1551 | 1551 | $sort_option_field = 'NAME'; |
1552 | 1552 | break; |
@@ -1567,7 +1567,7 @@ discard block |
||
1567 | 1567 | break; |
1568 | 1568 | } |
1569 | 1569 | $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1; |
1570 | - usort($ListToSort, function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
1570 | + usort($ListToSort, function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
1571 | 1571 | return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : ( |
1572 | 1572 | $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0 |
1573 | 1573 | ); |
@@ -333,26 +333,26 @@ discard block |
||
333 | 333 | // Each mission will filter only necessary checks and do it in this order |
334 | 334 | 'mission_checks' => array( |
335 | 335 | // Cheap checks - class Fleet already have all this info internally |
336 | - 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, //+ |
|
337 | - 'checkTargetNoVacation' => FLIGHT_PLAYER_VACATION, //+ |
|
338 | - 'checkFleetNotEmpty' => FLIGHT_SHIPS_NO_SHIPS, //+ |
|
336 | + 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, //+ |
|
337 | + 'checkTargetNoVacation' => FLIGHT_PLAYER_VACATION, //+ |
|
338 | + 'checkFleetNotEmpty' => FLIGHT_SHIPS_NO_SHIPS, //+ |
|
339 | 339 | // FLIGHT_MISSION_UNKNOWN |
340 | 340 | // FLIGHT_RESOURCES_FORBIDDEN |
341 | - 'checkSpeedPercentOld' => FLIGHT_FLEET_SPEED_WRONG, //+ |
|
342 | - 'checkTargetNotSource' => FLIGHT_VECTOR_SAME_SOURCE, //+ |
|
341 | + 'checkSpeedPercentOld' => FLIGHT_FLEET_SPEED_WRONG, //+ |
|
342 | + 'checkTargetNotSource' => FLIGHT_VECTOR_SAME_SOURCE, //+ |
|
343 | 343 | 'checkTargetInUniverse' => FLIGHT_VECTOR_BEYOND_UNIVERSE, |
344 | - 'checkUnitsPositive' => FLIGHT_SHIPS_NEGATIVE, //+ |
|
344 | + 'checkUnitsPositive' => FLIGHT_SHIPS_NEGATIVE, //+ |
|
345 | 345 | 'checkOnlyFleetUnits' => FLIGHT_SHIPS_UNIT_WRONG, |
346 | - 'checkOnlyFlyingUnits' => FLIGHT_SHIPS_UNMOVABLE, //+ |
|
347 | - 'checkResourcesPositive' => FLIGHT_RESOURCES_NEGATIVE, //+ |
|
348 | - 'checkNotTooFar' => FLIGHT_FLEET_TOO_FAR, //+ |
|
349 | - 'checkEnoughCapacity' => FLIGHT_FLEET_OVERLOAD, //+ |
|
346 | + 'checkOnlyFlyingUnits' => FLIGHT_SHIPS_UNMOVABLE, //+ |
|
347 | + 'checkResourcesPositive' => FLIGHT_RESOURCES_NEGATIVE, //+ |
|
348 | + 'checkNotTooFar' => FLIGHT_FLEET_TOO_FAR, //+ |
|
349 | + 'checkEnoughCapacity' => FLIGHT_FLEET_OVERLOAD, //+ |
|
350 | 350 | // Medium checks - currently requires access to DB but potentially doesn't |
351 | - 'checkSourceEnoughShips' => FLIGHT_SHIPS_NOT_ENOUGH, //+ |
|
352 | - 'checkSourceEnoughFuel' => FLIGHT_RESOURCES_FUEL_NOT_ENOUGH, //+ |
|
353 | - 'checkSourceEnoughResources' => FLIGHT_RESOURCES_NOT_ENOUGH, //+ |
|
351 | + 'checkSourceEnoughShips' => FLIGHT_SHIPS_NOT_ENOUGH, //+ |
|
352 | + 'checkSourceEnoughFuel' => FLIGHT_RESOURCES_FUEL_NOT_ENOUGH, //+ |
|
353 | + 'checkSourceEnoughResources' => FLIGHT_RESOURCES_NOT_ENOUGH, //+ |
|
354 | 354 | // Heavy checks - will absolutely require DB access |
355 | - 'checkEnoughFleetSlots' => FLIGHT_FLEET_NO_SLOTS, //+ |
|
355 | + 'checkEnoughFleetSlots' => FLIGHT_FLEET_NO_SLOTS, //+ |
|
356 | 356 | |
357 | 357 | // Vector targeting space beyond MaxPlanet forces MT_EXPLORE mission |
358 | 358 | 'checkKnownSpace' => array( |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | 'checkNotOnlySpies' => FLIGHT_SHIPS_NOT_ONLY_SPIES, |
363 | 363 | 'checkNoMissiles' => FLIGHT_SHIPS_NO_MISSILES, |
364 | 364 | 'forceMissionExplore' => array( |
365 | - true => FLIGHT_ALLOWED, //+ |
|
365 | + true => FLIGHT_ALLOWED, //+ |
|
366 | 366 | false => FLIGHT_VECTOR_BEYOND_SYSTEM, |
367 | 367 | ), |
368 | 368 | ), |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | 'checkNoMissiles' => FLIGHT_SHIPS_NO_MISSILES, |
378 | 378 | 'checkTargetIsPlanet' => FLIGHT_MISSION_COLONIZE_NOT_PLANET, |
379 | 379 | 'forceMissionColonize' => array( |
380 | - true => FLIGHT_ALLOWED, //+ |
|
380 | + true => FLIGHT_ALLOWED, //+ |
|
381 | 381 | false => FLIGHT_VECTOR_NO_TARGET, |
382 | 382 | ), |
383 | 383 | ), |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | 'checkTargetIsDebris' => array( |
389 | 389 | true => array( |
390 | 390 | // Recycle mission checks |
391 | - 'checkHaveRecyclers' => FLIGHT_SHIPS_NO_RECYCLERS, //+ |
|
391 | + 'checkHaveRecyclers' => FLIGHT_SHIPS_NO_RECYCLERS, //+ |
|
392 | 392 | 'checkNoMissiles' => FLIGHT_SHIPS_NO_MISSILES, |
393 | - 'checkDebrisExists' => FLIGHT_MISSION_RECYCLE_NO_DEBRIS, //+ |
|
393 | + 'checkDebrisExists' => FLIGHT_MISSION_RECYCLE_NO_DEBRIS, //+ |
|
394 | 394 | 'forceMissionRecycle' => array( |
395 | - true => FLIGHT_ALLOWED, //+ |
|
395 | + true => FLIGHT_ALLOWED, //+ |
|
396 | 396 | false => FLIGHT_VECTOR_TARGET_DEBRIS, |
397 | 397 | ), |
398 | 398 | ), |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | |
489 | 489 | |
490 | 490 | // Check for multiaccount |
491 | - 'checkMultiAccount' => FLIGHT_PLAYER_SAME_IP, //+ |
|
491 | + 'checkMultiAccount' => FLIGHT_PLAYER_SAME_IP, //+ |
|
492 | 492 | // TODO - check for moratorium |
493 | 493 | |
494 | 494 |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | /** |
973 | 973 | * Set current resource list from array of units |
974 | 974 | * |
975 | - * @param array $resource_list |
|
975 | + * @param integer[] $resource_list |
|
976 | 976 | */ |
977 | 977 | public function resourcesSet($resource_list) { |
978 | 978 | if (!empty($this->propertiesAdjusted['resource_list'])) { |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | /** |
1023 | - * @param array $rate |
|
1023 | + * @param integer[] $rate |
|
1024 | 1024 | * |
1025 | 1025 | * @return float |
1026 | 1026 | */ |
@@ -1051,7 +1051,6 @@ discard block |
||
1051 | 1051 | * Restores fleet or resources to planet |
1052 | 1052 | * |
1053 | 1053 | * @param bool $start |
1054 | - * @param bool $only_resources |
|
1055 | 1054 | * @param int $result |
1056 | 1055 | * |
1057 | 1056 | * @return int |
@@ -1205,6 +1204,9 @@ discard block |
||
1205 | 1204 | } |
1206 | 1205 | |
1207 | 1206 | |
1207 | + /** |
|
1208 | + * @param integer $missionStartTimeStamp |
|
1209 | + */ |
|
1208 | 1210 | protected function renderFleetCoordinates($missionStartTimeStamp = SN_TIME_NOW, $timeMissionJob = 0) { |
1209 | 1211 | $timeToReturn = $this->travelData['duration'] * 2 + $timeMissionJob; |
1210 | 1212 |
@@ -397,31 +397,31 @@ discard block |
||
397 | 397 | |
398 | 398 | return doquery( |
399 | 399 | // Блокировка самого флота |
400 | - "SELECT 1 FROM {{fleets}} AS f " . |
|
400 | + "SELECT 1 FROM {{fleets}} AS f ". |
|
401 | 401 | |
402 | 402 | // Блокировка всех юнитов, принадлежащих этому флоту |
403 | - "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " . |
|
403 | + "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ". |
|
404 | 404 | |
405 | 405 | // Блокировка всех прилетающих и улетающих флотов, если нужно |
406 | 406 | // TODO - lock fleets by COORDINATES |
407 | - ($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 " : '') . |
|
407 | + ($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 | 408 | // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination |
409 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') . |
|
409 | + ($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 | 410 | |
411 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') . |
|
411 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : ''). |
|
412 | 412 | // Блокировка всех юнитов, принадлежащих владельцу планеты-цели |
413 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') . |
|
413 | + ($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 | 414 | // Блокировка планеты-цели |
415 | - ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') . |
|
415 | + ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : ''). |
|
416 | 416 | // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели |
417 | 417 | // ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') . |
418 | 418 | |
419 | 419 | |
420 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') . |
|
420 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : ''). |
|
421 | 421 | // Блокировка всех юнитов, принадлежащих владельцу флота |
422 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') . |
|
422 | + ($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 | 423 | // Блокировка планеты отправления |
424 | - ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') . |
|
424 | + ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : ''). |
|
425 | 425 | // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота |
426 | 426 | // ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') . |
427 | 427 | |
@@ -438,11 +438,11 @@ discard block |
||
438 | 438 | public function dbGetLockById($dbId) { |
439 | 439 | doquery( |
440 | 440 | // Блокировка самого флота |
441 | - "SELECT 1 FROM {{fleets}} AS FLEET0 " . |
|
441 | + "SELECT 1 FROM {{fleets}} AS FLEET0 ". |
|
442 | 442 | // Lock fleet owner |
443 | - "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " . |
|
443 | + "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ". |
|
444 | 444 | // Блокировка всех юнитов, принадлежащих этому флоту |
445 | - "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " . |
|
445 | + "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ". |
|
446 | 446 | |
447 | 447 | // Без предварительной выборки неизвестно - куда летит этот флот. |
448 | 448 | // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота. |
@@ -458,9 +458,9 @@ discard block |
||
458 | 458 | FLEET1.fleet_end_planet = FLEET0.fleet_end_planet |
459 | 459 | " . |
460 | 460 | // Блокировка всех юнитов, принадлежащих этим флотам |
461 | - "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " . |
|
461 | + "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ". |
|
462 | 462 | // Lock fleet owner |
463 | - "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " . |
|
463 | + "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ". |
|
464 | 464 | |
465 | 465 | "LEFT JOIN {{fleets}} AS FLEET2 ON |
466 | 466 | FLEET2.fleet_mess = 1 AND FLEET0.fleet_mess = 0 AND |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | " . |
471 | 471 | // Блокировка всех юнитов, принадлежащих этим флотам |
472 | 472 | "LEFT JOIN {{unit}} as UNIT2 ON |
473 | - UNIT2.unit_location_type = " . LOC_FLEET . " AND |
|
473 | + UNIT2.unit_location_type = " . LOC_FLEET." AND |
|
474 | 474 | UNIT2.unit_location_id = FLEET2.fleet_id |
475 | 475 | " . |
476 | 476 | // Lock fleet owner |
@@ -487,11 +487,11 @@ discard block |
||
487 | 487 | " . |
488 | 488 | // Блокировка всех юнитов, принадлежащих этим флотам |
489 | 489 | "LEFT JOIN {{unit}} as UNIT3 ON |
490 | - UNIT3.unit_location_type = " . LOC_FLEET . " AND |
|
490 | + UNIT3.unit_location_type = " . LOC_FLEET." AND |
|
491 | 491 | UNIT3.unit_location_id = FLEET3.fleet_id |
492 | 492 | " . |
493 | 493 | // Lock fleet owner |
494 | - "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " . |
|
494 | + "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ". |
|
495 | 495 | |
496 | 496 | "LEFT JOIN {{fleets}} AS FLEET4 ON |
497 | 497 | FLEET4.fleet_mess = 1 AND FLEET0.fleet_mess = 1 AND |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | " . |
502 | 502 | // Блокировка всех юнитов, принадлежащих этим флотам |
503 | 503 | "LEFT JOIN {{unit}} as UNIT4 ON |
504 | - UNIT4.unit_location_type = " . LOC_FLEET . " AND |
|
504 | + UNIT4.unit_location_type = " . LOC_FLEET." AND |
|
505 | 505 | UNIT4.unit_location_id = FLEET4.fleet_id |
506 | 506 | " . |
507 | 507 | // Lock fleet owner |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | " . |
524 | 524 | // Блокировка всех юнитов, принадлежащих этой планете |
525 | 525 | "LEFT JOIN {{unit}} as UNIT5 ON |
526 | - UNIT5.unit_location_type = " . LOC_PLANET . " AND |
|
526 | + UNIT5.unit_location_type = " . LOC_PLANET." AND |
|
527 | 527 | UNIT5.unit_location_id = PLANETS5.id |
528 | 528 | " . |
529 | 529 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | " . |
542 | 542 | // Блокировка всех юнитов, принадлежащих этой планете |
543 | 543 | "LEFT JOIN {{unit}} as UNIT6 ON |
544 | - UNIT6.unit_location_type = " . LOC_PLANET . " AND |
|
544 | + UNIT6.unit_location_type = " . LOC_PLANET." AND |
|
545 | 545 | UNIT6.unit_location_id = PLANETS6.id |
546 | 546 | " . |
547 | 547 | "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE" |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | } elseif ($this->isResource($unit_id)) { |
661 | 661 | $this->resource_list[$unit_id] = $unit_count; |
662 | 662 | } else { |
663 | - throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR); |
|
663 | + throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), ERR_ERROR); |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | } |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | */ |
986 | 986 | public function resourcesSet($resource_list) { |
987 | 987 | if (!empty($this->propertiesAdjusted['resource_list'])) { |
988 | - throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR); |
|
988 | + throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR); |
|
989 | 989 | } |
990 | 990 | $this->resourcesAdjust($resource_list, true); |
991 | 991 | } |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | // Check for negative unit value |
1020 | 1020 | if ($this->resource_list[$resource_id] < 0) { |
1021 | 1021 | // TODO |
1022 | - throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR); |
|
1022 | + throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR); |
|
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | } |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | |
1191 | 1191 | protected function printErrorIfNoShips() { |
1192 | 1192 | if ($this->unitList->unitsCount() <= 0) { |
1193 | - message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5); |
|
1193 | + message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5); |
|
1194 | 1194 | } |
1195 | 1195 | } |
1196 | 1196 | |
@@ -1637,7 +1637,7 @@ discard block |
||
1637 | 1637 | |
1638 | 1638 | if ($errorlist) { |
1639 | 1639 | sn_db_transaction_rollback(); |
1640 | - message("<span class='error'><ul>{$errorlist}</ul></span>", classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, false); |
|
1640 | + message("<span class='error'><ul>{$errorlist}</ul></span>", classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, false); |
|
1641 | 1641 | } |
1642 | 1642 | |
1643 | 1643 | //Normally... unless its acs... |
@@ -1669,7 +1669,7 @@ discard block |
||
1669 | 1669 | if ($this->_mission_type == MT_ACS && $aks) { |
1670 | 1670 | $acsTimeToArrive = $aks['ankunft'] - SN_TIME_NOW; |
1671 | 1671 | if ($acsTimeToArrive < $this->travelData['duration']) { |
1672 | - message(classLocale::$lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, SN_TIME_NOW + $this->travelData['duration']) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), classLocale::$lang['fl_error']); |
|
1672 | + message(classLocale::$lang['fl_aks_too_slow'].'Fleet arrival: '.date(FMT_DATE_TIME, SN_TIME_NOW + $this->travelData['duration'])." AKS arrival: ".date(FMT_DATE_TIME, $aks['ankunft']), classLocale::$lang['fl_error']); |
|
1673 | 1673 | } |
1674 | 1674 | // Set time to travel to ACS' TTT |
1675 | 1675 | $this->travelData['duration'] = $acsTimeToArrive; |
@@ -1711,14 +1711,14 @@ discard block |
||
1711 | 1711 | |
1712 | 1712 | |
1713 | 1713 | if (!empty($captain['unit_id'])) { |
1714 | - db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$this->_dbId}"); |
|
1714 | + db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = ".LOC_FLEET.", `unit_location_id` = {$this->_dbId}"); |
|
1715 | 1715 | } |
1716 | 1716 | |
1717 | 1717 | |
1718 | 1718 | $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob); |
1719 | 1719 | |
1720 | 1720 | $template_result += array( |
1721 | - 'mission' => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''), |
|
1721 | + 'mission' => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''), |
|
1722 | 1722 | 'dist' => pretty_number($this->travelData['distance']), |
1723 | 1723 | 'speed' => pretty_number($this->travelData['fleet_speed']), |
1724 | 1724 | 'deute_need' => pretty_number($this->travelData['consumption']), |
@@ -190,8 +190,8 @@ |
||
190 | 190 | |
191 | 191 | |
192 | 192 | /** |
193 | - * @return bool |
|
194 | - */ |
|
193 | + * @return bool |
|
194 | + */ |
|
195 | 195 | protected function checkEnoughCapacity($includeResources = true) { |
196 | 196 | $checkVia = $this->fleet->travelData['consumption']; |
197 | 197 | $checkVia = ceil(($includeResources ? array_sum($this->fleet->resource_list) : 0) + $checkVia); |
@@ -802,7 +802,7 @@ |
||
802 | 802 | * @return bool |
803 | 803 | */ |
804 | 804 | protected function checkCaptainNotRelocating() { |
805 | - if($this->fleet->mission_type == MT_RELOCATE) { |
|
805 | + if ($this->fleet->mission_type == MT_RELOCATE) { |
|
806 | 806 | $arriving_captain = mrc_get_level($this->fleet->dbOwnerRow, $this->fleet->dbTargetRow, UNIT_CAPTAIN, true); |
807 | 807 | } else { |
808 | 808 | $arriving_captain = false; |