Completed
Push — work-fleets ( ff9274...a405f7 )
by SuperNova.WS
06:32
created
includes/db/db_helpers.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@
 block discarded – undo
27 27
  */
28 28
 function db_set_make_safe_string($set, $delta = false) {
29 29
   $set_safe = array();
30
-  foreach($set as $field => $value) {
31
-    if(empty($field)) {
30
+  foreach ($set as $field => $value) {
31
+    if (empty($field)) {
32 32
       continue;
33 33
     }
34 34
 
35 35
     $field = '`' . db_escape($field) . '`';
36 36
     $new_value = $value;
37
-    if($value === null) {
37
+    if ($value === null) {
38 38
       $new_value = 'NULL';
39
-    } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) {
39
+    } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) {
40 40
       // non-float
41 41
       $new_value = '"' . db_escape($value) . '"';
42
-    } elseif($delta) {
42
+    } elseif ($delta) {
43 43
       // float and DELTA-set
44 44
       $new_value = "{$field} + ({$new_value})";
45 45
     }
Please login to merge, or discard this patch.
includes/includes/flt_mission_hold.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
  * @copyright 2008 by Gorlum for Project "SuperNova.WS"
11 11
  */
12 12
 function flt_mission_hold($mission_data) {
13
-  if($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) {
13
+  if ($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) {
14 14
     $mission_data->fleet->mark_fleet_as_returned_and_save();
15 15
 
16 16
     return CACHE_FLEET;
Please login to merge, or discard this patch.
includes/includes/flt_mission_colonize.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
   $TargetAddress = sprintf($lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']);
21 21
 
22 22
   $TheMessage = $lang['sys_colo_no_colonizer'];
23
-  if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) {
23
+  if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) {
24 24
     $TheMessage = $lang['sys_colo_notfree'];
25
-    if(empty($mission_data->dst_planet)) {
25
+    if (empty($mission_data->dst_planet)) {
26 26
       $iPlanetCount = get_player_current_colonies($src_user_row);
27 27
 
28 28
       // Can we colonize more planets?
29 29
       $TheMessage = $lang['sys_colo_maxcolo'];
30
-      if($iPlanetCount < get_player_max_colonies($src_user_row)) {
30
+      if ($iPlanetCount < get_player_max_colonies($src_user_row)) {
31 31
         // Yes, we can colonize
32 32
         $TheMessage = $lang['sys_colo_badpos'];
33 33
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
           $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'],
36 36
           $objFleet->playerOwnerId, "{$lang['sys_colo_defaultname']} {$iPlanetCount}", false,
37 37
           array('user_row' => $src_user_row));
38
-        if($NewOwnerPlanet) {
38
+        if ($NewOwnerPlanet) {
39 39
           $TheMessage = $lang['sys_colo_arrival'] . $TargetAddress . $lang['sys_colo_allisok'];
40 40
           msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage);
41 41
 
Please login to merge, or discard this patch.
includes/includes/flt_mission_attack.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@
 block discarded – undo
17 17
 function flt_mission_attack($objMission) {
18 18
   $objFleet = $objMission->fleet;
19 19
 
20
-  if($objFleet->shipsGetTotal() <= 0) {
20
+  if ($objFleet->shipsGetTotal() <= 0) {
21 21
     return null;
22 22
   }
23 23
 
24 24
   $destination_user = $objMission->dst_user;
25 25
   $destination_planet = $objMission->dst_planet;
26 26
 
27
-  if(
27
+  if (
28 28
     // Нет данных о планете назначения или её владельце
29 29
     empty($destination_user) || empty($destination_planet) || !is_array($destination_user) || !is_array($destination_planet)
30 30
     ||
Please login to merge, or discard this patch.
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 
10 10
 /**
11 11
  * @param Mission $objMission
12
- * @param array   $mission_data
13 12
  */
14 13
 function flt_mission_attack($objMission) {
15 14
   $objFleet = $objMission->fleet;
Please login to merge, or discard this patch.
admin/adm_planet_list.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-define('INSIDE'  , true);
4
-define('INSTALL' , false);
3
+define('INSIDE', true);
4
+define('INSTALL', false);
5 5
 define('IN_ADMIN', true);
6 6
 
7 7
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 global $config, $lang, $user;
10 10
 
11 11
 // if($user['authlevel'] < 1)
12
-if($user['authlevel'] < 3) {
12
+if ($user['authlevel'] < 3) {
13 13
   AdminMessage(classLocale::$lang['adm_err_denied']);
14 14
 }
15 15
 
16 16
 $planet_active = sys_get_param_int('planet_active');
17
-if(!$planet_active) {
17
+if (!$planet_active) {
18 18
   $planet_type = sys_get_param_int('planet_type', 1);
19 19
   $planet_type = $planet_type == 3 ? 3 : 1;
20 20
 } else {
@@ -43,8 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 $page_title =
45 45
   classLocale::$lang['adm_planet_list_title'] . ': ' .
46
-  ($planet_active ? classLocale::$lang['adm_planet_active'] :
47
-    ($planet_type ? ($planet_type == 3 ? classLocale::$lang['sys_moons'] : classLocale::$lang['sys_planets']) : '')
46
+  ($planet_active ? classLocale::$lang['adm_planet_active'] : ($planet_type ? ($planet_type == 3 ? classLocale::$lang['sys_moons'] : classLocale::$lang['sys_planets']) : '')
48 47
   );
49 48
 $template->assign_vars(array(
50 49
   'PAGE_TITLE' => $page_title,
Please login to merge, or discard this patch.
metamatter.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 include_once('common.' . substr(strrchr(__FILE__, '.'), 1));
10 10
 
11
-if(!sn_module_get_active_count('payment')) {
11
+if (!sn_module_get_active_count('payment')) {
12 12
   sys_redirect('dark_matter.php');
13 13
   die();
14 14
 }
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 
66 66
 // Таблица скидок
67 67
 $prev_discount = 0;
68
-if(isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
69
-  foreach(sn_module_payment::$bonus_table as $sum => $discount) {
70
-    if($discount && $discount != $prev_discount) {
68
+if (isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
69
+  foreach (sn_module_payment::$bonus_table as $sum => $discount) {
70
+    if ($discount && $discount != $prev_discount) {
71 71
       $template->assign_block_vars('discount', array(
72 72
         'SUM'          => $sum,
73 73
         'DISCOUNT'     => $discount * 100,
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 }
81 81
 
82 82
 // Результат платежа
83
-if($payment_id = sys_get_param_id('payment_id')) {
83
+if ($payment_id = sys_get_param_id('payment_id')) {
84 84
   $payment = db_payment_get($payment_id);
85
-  if($payment && $payment['payment_user_id'] == $user['id']) {
86
-    if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
85
+  if ($payment && $payment['payment_user_id'] == $user['id']) {
86
+    if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
87 87
       $template->assign_block_vars('result', array('MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained'])));
88 88
     }
89
-    if($payment['payment_status'] == PAYMENT_STATUS_NONE) {
89
+    if ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
90 90
       $template->assign_block_vars('result', array(
91 91
         'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']),
92 92
         'STATUS'  => 1,
93 93
       ));
94 94
     }
95
-    if($payment['payment_test']) {
95
+    if ($payment['payment_test']) {
96 96
       $template->assign_block_vars('result', array(
97 97
         'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_test']),
98 98
         'STATUS'  => -1,
@@ -107,28 +107,28 @@  discard block
 block discarded – undo
107 107
   'metamatter' => sys_get_param_float('metamatter'),
108 108
 );
109 109
 
110
-if(!$request['metamatter']) {
110
+if (!$request['metamatter']) {
111 111
   unset($_POST);
112 112
 }
113 113
 
114 114
 $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null));
115
-array_walk($payment_methods_available, function (&$value, $index) {
115
+array_walk($payment_methods_available, function(&$value, $index) {
116 116
   $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value;
117 117
 });
118 118
 
119 119
 // pdump($payment_methods_available);
120 120
 $payment_module_valid = false;
121 121
 $payment_module = sys_get_param_str('payment_module');
122
-foreach(sn_module::$sn_module_list['payment'] as $module_name => $module) {
123
-  if(!is_object($module) || !$module->manifest['active']) {
122
+foreach (sn_module::$sn_module_list['payment'] as $module_name => $module) {
123
+  if (!is_object($module) || !$module->manifest['active']) {
124 124
     continue;
125 125
   }
126 126
 
127 127
   lng_include($module_name, $module->manifest['root_relative']);
128 128
 
129
-  foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) {
130
-    foreach($available_methods as $payment_method => $payment_currency) {
131
-      if(isset($module->manifest['payment_method'][$payment_method])) {
129
+  foreach (sn_module_payment::$payment_methods as $payment_type_id => $available_methods) {
130
+    foreach ($available_methods as $payment_method => $payment_currency) {
131
+      if (isset($module->manifest['payment_method'][$payment_method])) {
132 132
         $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method];
133 133
       }
134 134
     }
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 
140 140
 global $template_result;
141 141
 // Доступные платежные методы
142
-foreach($payment_methods_available as $payment_type_id => $payment_methods) {
143
-  if(empty($payment_methods)) {
142
+foreach ($payment_methods_available as $payment_type_id => $payment_methods) {
143
+  if (empty($payment_methods)) {
144 144
     continue;
145 145
   }
146 146
 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
     'ID'   => $payment_type_id,
149 149
     'NAME' => classLocale::$lang['pay_methods'][$payment_type_id],
150 150
   );
151
-  foreach($payment_methods as $payment_method_id => $module_list) {
152
-    if(empty($module_list)) {
151
+  foreach ($payment_methods as $payment_method_id => $module_list) {
152
+    if (empty($module_list)) {
153 153
       continue;
154 154
     }
155 155
     $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array(
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
       'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']),
161 161
       'BUTTON'     => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']),
162 162
     );
163
-    foreach($module_list as $payment_module_name => $payment_module_method_details) {
163
+    foreach ($module_list as $payment_module_name => $payment_module_method_details) {
164 164
       $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array(
165 165
         'MODULE' => $payment_module_name,
166 166
       );
167 167
     }
168 168
   }
169 169
 
170
-  if(empty($template_result['.']['payment'][$payment_type_id]['.'])) {
170
+  if (empty($template_result['.']['payment'][$payment_type_id]['.'])) {
171 171
     unset($template_result['.']['payment'][$payment_type_id]);
172 172
   }
173 173
 }
@@ -180,19 +180,19 @@  discard block
 block discarded – undo
180 180
 $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name]));
181 181
 
182 182
 // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it
183
-if($payment_module_valid) {
183
+if ($payment_module_valid) {
184 184
   // $payment_module = $payment_module; // Really - do nothing
185
-} elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
185
+} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
186 186
   reset($payment_methods_available[$payment_type_selected][$payment_method_selected]);
187 187
   $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]);
188
-} elseif(count(sn_module::$sn_module_list['payment']) == 1) {
188
+} elseif (count(sn_module::$sn_module_list['payment']) == 1) {
189 189
   $payment_module = $module_name;
190 190
 } else {
191 191
   $payment_module = '';
192 192
 }
193 193
 
194
-if($payment_type_selected && $payment_method_selected) {
195
-  foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
194
+if ($payment_type_selected && $payment_method_selected) {
195
+  foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
196 196
     $template->assign_block_vars('payment_module', array(
197 197
       'ID'          => $module_name,
198 198
       'NAME'        => classLocale::$lang["module_{$module_name}_name"],
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
   }
202 202
 }
203 203
 
204
-foreach(classLocale::$lang['pay_currency_list'] as $key => $value) {
204
+foreach (classLocale::$lang['pay_currency_list'] as $key => $value) {
205 205
   $course = get_exchange_rate($key);
206 206
 //  if(!$course || $key == $config->payment_currency_default) {
207
-  if(!$course) {
207
+  if (!$course) {
208 208
     continue;
209 209
   }
210 210
   $template->assign_block_vars('exchange', array(
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
   ));
220 220
 }
221 221
 
222
-if($request['metamatter'] && $payment_module) {
222
+if ($request['metamatter'] && $payment_module) {
223 223
   try {
224 224
     // Any possible errors about generating paylink should be raised in module!
225 225
     $pay_link = sn_module::$sn_module[$payment_module]->compile_request($request);
226 226
 
227 227
     // Поддержка дополнительной информации
228
-    if(is_array($pay_link['RENDER'])) {
229
-      foreach($pay_link['RENDER'] as $html_data) {
228
+    if (is_array($pay_link['RENDER'])) {
229
+      foreach ($pay_link['RENDER'] as $html_data) {
230 230
         $template->assign_block_vars('render', $html_data);
231
-        if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
232
-          foreach($html_data['VALUE'] as $value_id => $value_value) {
231
+        if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
232
+          foreach ($html_data['VALUE'] as $value_id => $value_value) {
233 233
             $template->assign_block_vars('render.value', array(
234 234
               'FIELD' => $value_id,
235 235
               'VALUE' => $value_value,
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
     }
241 241
 
242 242
     // Поддержка передачи данных для многошаговых платежных систем
243
-    if(is_array($pay_link['DATA'])) {
244
-      foreach($pay_link['DATA'] as $key => $value) {
243
+    if (is_array($pay_link['DATA'])) {
244
+      foreach ($pay_link['DATA'] as $key => $value) {
245 245
         $template->assign_block_vars('pay_link_data', array(
246 246
           'FIELD' => $key,
247 247
           'VALUE' => $value,
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
       }
250 250
     }
251 251
 
252
-    if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) {
252
+    if (is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) {
253 253
       // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте
254 254
       $template->assign_vars(array(
255 255
         'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'],
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     } else {
259 259
       throw new exception(classLocale::$lang['pay_msg_request_paylink_unsupported'], ERR_ERROR);
260 260
     }
261
-  } catch(exception $e) {
261
+  } catch (exception $e) {
262 262
     $template->assign_block_vars('result', $response = array(
263 263
       'STATUS'  => $e->getCode(),
264 264
       'MESSAGE' => $e->getMessage(),
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 }
269 269
 
270 270
 // Прегенерированные пакеты
271
-foreach($unit_available_amount_list as $unit_amount => $discount) {
271
+foreach ($unit_available_amount_list as $unit_amount => $discount) {
272 272
   $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency);
273 273
   $template->assign_block_vars('mm_amount', array(
274 274
     'VALUE'            => $unit_amount,
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
   'PLAYER_CURRENCY'              => $player_currency,
304 304
   'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10),
305 305
 
306
-  'UNIT_AMOUNT'                 => (float)$request['metamatter'],
306
+  'UNIT_AMOUNT'                 => (float) $request['metamatter'],
307 307
   'UNIT_AMOUNT_TEXT'            => pretty_number($request['metamatter']),
308 308
   'UNIT_AMOUNT_BONUS_PERCENT'   => $bonus_percent,
309 309
   'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text,
Please login to merge, or discard this patch.
buildings.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@
 block discarded – undo
21 21
 $mode = sys_get_param_escaped('mode');
22 22
 $mode = (!$mode || $mode == 'buildings') ? QUE_STRUCTURES : ($mode == 'fleet' ? SUBQUE_FLEET : ($mode == 'defense' ? SUBQUE_DEFENSE : ($mode == 'research' ? QUE_RESEARCH : $mode)));
23 23
 
24
-if($building_sort = sys_get_param_id('sort_elements')) {
25
-  if(!empty(classLocale::$lang['player_option_building_sort'][$building_sort])) {
24
+if ($building_sort = sys_get_param_id('sort_elements')) {
25
+  if (!empty(classLocale::$lang['player_option_building_sort'][$building_sort])) {
26 26
     classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT, $mode)] = $building_sort;
27 27
     classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT_INVERSE, $mode)] = sys_get_param_id('sort_elements_inverse', 0);
28 28
   }
Please login to merge, or discard this patch.
admin/includes/admin_planet_edit.inc.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 
22 22
 function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) {
23 23
   $unit_list = sn_get_groups($mode);
24
-  if(empty($unit_list)) {
24
+  if (empty($unit_list)) {
25 25
     return;
26 26
   }
27 27
   $name_list = classLocale::$lang['tech'];
28 28
 
29
-  foreach($unit_list as $unit_id) {
29
+  foreach ($unit_list as $unit_id) {
30 30
     $template->assign_block_vars('unit', array(
31 31
       'ID'    => $unit_id,
32 32
       'NAME'  => $name_list[$unit_id],
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { return sn_function_call(__FUNCTION__, array($unit_id, $unit_amount, $mode)); }
40 40
 
41 41
 function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) {
42
-  if($unit_amount && in_array($unit_id, sn_get_groups($mode))) {
42
+  if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) {
43 43
     $unit_amount = round($unit_amount);
44 44
     $unit_name = get_unit_param($unit_id, P_NAME);
45 45
     $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))";
Please login to merge, or discard this patch.
includes/functions/uni_functions.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -253,9 +253,11 @@
 block discarded – undo
253 253
   }
254 254
 
255 255
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
256
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
256
+  if(!isset($planet_row['id'])) {
257
+    // || $planet_row['id'] != $user['current_planet']
257 258
   {
258 259
     $planet_row = db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
260
+  }
259 261
     // Если текущей планеты не существует - выставляем Столицу
260 262
     if(!isset($planet_row['id'])) {
261 263
       $planet_row = db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id');
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 
12 12
   $possible_cores = array();
13 13
   $probability = 0;
14
-  foreach($density_list as $possible_core_id => $core_data) {
15
-    if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
14
+  foreach ($density_list as $possible_core_id => $core_data) {
15
+    if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
16 16
       continue;
17 17
     }
18 18
 
19
-    if(
19
+    if (
20 20
       // Core type exists
21 21
       in_array($possible_core_id, $position_data['core_types'])
22 22
       // Limit core type with planet sector count
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 
38 38
   $random = mt_rand(1, $probability);
39 39
   $selected_core = null;
40
-  foreach($possible_cores as $core_type => $core_info) {
41
-    if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
40
+  foreach ($possible_cores as $core_type => $core_info) {
41
+    if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
42 42
       $selected_core = $core_info;
43 43
       break;
44 44
     }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 function uni_create_planet($Galaxy, $System, $Position, $PlanetOwnerID, $planet_name_unsafe = '', $HomeWorld = false, $options = array()) {
62 62
   $Position = intval($Position);
63 63
 
64
-  if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
64
+  if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
65 65
     return false;
66 66
   }
67 67
 
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
 
71 71
   $planet_generator = sn_get_groups('planet_generator');
72 72
 
73
-  if($HomeWorld) {
73
+  if ($HomeWorld) {
74 74
     $position_data = $planet_generator[0];
75 75
   } else {
76 76
     $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position];
77
-    if($Position >= UNIVERSE_RANDOM_PLANET_START) {
77
+    if ($Position >= UNIVERSE_RANDOM_PLANET_START) {
78 78
       // Корректируем температуру для планеты-странника
79 79
       $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START);
80 80
     }
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
   $moon_name = '';
166 166
   $moon_row = array();
167 167
   $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id');
168
-  if(!$moon['id']) {
168
+  if (!$moon['id']) {
169 169
     $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`');
170 170
 
171
-    if($moon_planet['id']) {
171
+    if ($moon_planet['id']) {
172 172
       $base_storage_size = BASE_STORAGE_SIZE;
173 173
 
174
-      if(!$moon_chance) {
174
+      if (!$moon_chance) {
175 175
         $size = mt_rand(1100, 8999);
176
-      } elseif($moon_chance <= 100) {
176
+      } elseif ($moon_chance <= 100) {
177 177
         $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999);
178 178
       } else {
179 179
         $size = $moon_chance;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
       $field_max = ceil($size / 1000);
190 190
 
191
-      if(isset($options['image']) && $options['image']) {
191
+      if (isset($options['image']) && $options['image']) {
192 192
         $moon_image = $options['image'];
193 193
       } else {
194 194
         $moon_image = 'mond';
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
         'deuterium_max'     => $base_storage_size,
222 222
       ));
223 223
 
224
-      if($update_debris) {
224
+      if ($update_debris) {
225 225
         $debris_spent = $moon_chance * 1000000;
226 226
         $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100));
227 227
         $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent);
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
         DBStaticPlanet::db_planet_update_adjust_by_id(
230 230
           $moon_planet['id'],
231 231
           array(
232
-            'debris_metal'   => -$metal_spent,    // `debris_metal` = GREATEST(0, `debris_metal` - {$metal_spent})
233
-            'debris_crystal' => -$crystal_spent,  // `debris_crystal` = GREATEST(0, `debris_crystal` - {$crystal_spent})
232
+            'debris_metal'   => -$metal_spent, // `debris_metal` = GREATEST(0, `debris_metal` - {$metal_spent})
233
+            'debris_crystal' => -$crystal_spent, // `debris_crystal` = GREATEST(0, `debris_crystal` - {$crystal_spent})
234 234
           )
235 235
         );
236 236
       }
@@ -262,28 +262,28 @@  discard block
 block discarded – undo
262 262
   $planet_row['id'] = $user['current_planet'];
263 263
 
264 264
   // Пытаемся переключить на новую планету
265
-  if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) {
265
+  if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) {
266 266
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
267 267
   } else {
268 268
     $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']);
269 269
   }
270 270
 
271 271
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
272
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
272
+  if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
273 273
   {
274 274
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
275 275
     // Если текущей планеты не существует - выставляем Столицу
276
-    if(!isset($planet_row['id'])) {
276
+    if (!isset($planet_row['id'])) {
277 277
       $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id');
278 278
       // Если и столицы не существует - значит что-то очень не так с записью пользователя
279
-      if(!isset($planet_row['id'])) {
279
+      if (!isset($planet_row['id'])) {
280 280
         classSupernova::$debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502);
281 281
       }
282 282
     }
283 283
   }
284 284
 
285 285
   // Если производилось переключение планеты - делаем запись в юзере
286
-  if($user['current_planet'] != $planet_row['id']) {
286
+  if ($user['current_planet'] != $planet_row['id']) {
287 287
     $user['current_planet'] = $planet_row['id'];
288 288
     DBStaticUser::db_user_set_by_id(
289 289
       $user['id'],
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 }
314 314
 
315 315
 function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) {
316
-  if(!$from['id']) {
316
+  if (!$from['id']) {
317 317
     $result = classLocale::$lang['sys_planet_expedition'];
318 318
   } else {
319 319
     $from_planet_id = $include_id ? (
@@ -363,30 +363,30 @@  discard block
 block discarded – undo
363 363
   $coordinates["{$prefix}planet"] = intval($coordinates["{$prefix}planet"]);
364 364
 
365 365
   return
366
-    isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies&&
367
-    isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems&&
366
+    isset($coordinates["{$prefix}galaxy"]) && $coordinates["{$prefix}galaxy"] > 0 && $coordinates["{$prefix}galaxy"] <= Vector::$knownGalaxies &&
367
+    isset($coordinates["{$prefix}system"]) && $coordinates["{$prefix}system"] > 0 && $coordinates["{$prefix}system"] <= Vector::$knownSystems &&
368 368
     isset($coordinates["{$prefix}planet"]) && $coordinates["{$prefix}planet"] > 0 && $coordinates["{$prefix}planet"] <= Vector::$knownPlanets;
369 369
 }
370 370
 
371 371
 function uni_planet_teleport_check($user, $planetrow, $new_coordinates = null) {
372 372
   try {
373
-    if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
373
+    if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
374 374
       throw new exception(classLocale::$lang['ov_teleport_err_cooldown'], ERR_ERROR);
375 375
     }
376 376
 
377
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) {
377
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->planet_teleport_cost) {
378 378
       throw new exception(classLocale::$lang['ov_teleport_err_no_dark_matter'], ERR_ERROR);
379 379
     }
380 380
 
381 381
     // TODO: Replace quick-check with using gathered flying fleet data
382
-    if(FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
382
+    if (FleetList::fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
383 383
       throw new exception(classLocale::$lang['ov_teleport_err_fleet'], ERR_ERROR);
384 384
     }
385 385
 
386
-    if(is_array($new_coordinates)) {
386
+    if (is_array($new_coordinates)) {
387 387
       $new_coordinates['planet_type'] = PT_PLANET;
388 388
       $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id');
389
-      if($incoming['id']) {
389
+      if ($incoming['id']) {
390 390
         throw new exception(classLocale::$lang['ov_teleport_err_destination_busy'], ERR_ERROR);
391 391
       }
392 392
     }
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
       'result'  => ERR_NONE,
396 396
       'message' => '',
397 397
     );
398
-  } catch(exception $e) {
398
+  } catch (exception $e) {
399 399
     $response = array(
400 400
       'result'  => $e->getCode(),
401 401
       'message' => $e->getMessage(),
Please login to merge, or discard this patch.