Completed
Push — trunk ( 5a98ee...c2d255 )
by SuperNova.WS
04:09
created
includes/includes/flt_page2.inc 1 patch
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     'START_NAME'         => $planetrow['name'],
28 28
   );
29 29
 
30
-  if(!empty($TargetPlanet)) {
30
+  if (!empty($TargetPlanet)) {
31 31
     $template_route += array(
32 32
       'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
33 33
       'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
   $template->assign_block_vars('fleets', $template_route);
39 39
 
40 40
   $sn_groups_fleet = sn_get_groups('fleet');
41
-  foreach($fleetarray as $ship_id => $ship_count) {
42
-    if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
41
+  foreach ($fleetarray as $ship_id => $ship_count) {
42
+    if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
43 43
 //      $ship_base_data = get_ship_data($ship_id, $user);
44 44
       $template->assign_block_vars('fleets.ships', array(
45 45
         'ID'          => $ship_id,
@@ -57,11 +57,10 @@  discard block
 block discarded – undo
57 57
     $fleet_capacity += get_unit_param($Ship, P_CAPACITY) * $Count;
58 58
   }
59 59
 
60
-  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) :
61
-    (isset($missiontype[MT_HOLD]) ? 12 : 0);
62
-  if($max_duration) {
60
+  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : (isset($missiontype[MT_HOLD]) ? 12 : 0);
61
+  if ($max_duration) {
63 62
     $config_game_speed_expedition = ($target_mission == MT_EXPLORE && $config->game_speed_expedition ? $config->game_speed_expedition : 1);
64
-    for($i = 1; $i <= $max_duration; $i++) {
63
+    for ($i = 1; $i <= $max_duration; $i++) {
65 64
       $template->assign_block_vars('duration', array(
66 65
         'ID' => $i,
67 66
         'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)),
@@ -80,7 +79,7 @@  discard block
 block discarded – undo
80 79
   // $TableTitle = uni_render_planet_full($planetrow) . '&nbsp;=&gt;&nbsp;' . uni_render_planet_full($temp);
81 80
 
82 81
   $sn_group_resources = sn_get_groups('resources');
83
-  for($i = 0; $i<3; $i++) {
82
+  for ($i = 0; $i < 3; $i++) {
84 83
     $amount = $planetrow[$sn_group_resources[$i]] - ($i == 2 ? $consumption : 0);
85 84
     $template->assign_block_vars('resources', array(
86 85
       'ID' => $i,
@@ -90,7 +89,7 @@  discard block
 block discarded – undo
90 89
     ));
91 90
   }
92 91
 
93
-  if($sn_module['unit_captain']->manifest['active'] && ($captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
92
+  if ($sn_module['unit_captain']->manifest['active'] && ($captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
94 93
     $template->assign_vars(array(
95 94
       'CAPTAIN_ID' => $captain['unit_id'],
96 95
       'CAPTAIN_LEVEL' => $captain['captain_level'],
@@ -112,9 +111,9 @@  discard block
 block discarded – undo
112 111
 
113 112
 
114 113
     'speedallsmin' => sys_get_param_float('speedallsmin'),
115
-    'speed' => sys_get_param_int('speed') ,
114
+    'speed' => sys_get_param_int('speed'),
116 115
 
117
-    'fleet_group' => sys_get_param_id('fleet_group') ,
116
+    'fleet_group' => sys_get_param_id('fleet_group'),
118 117
     'acs_target_mr' => sys_get_param_str('acs_target_mr'),
119 118
 
120 119
     'MAX_DURATION' => $max_duration,
Please login to merge, or discard this patch.
fleet.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 $planet = sys_get_param_int('planet', $planetrow['planet']);
40 40
 
41 41
 $target_mission = sys_get_param_int('target_mission');
42
-if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
42
+if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
43 43
   $planet_type = PT_PLANET;
44
-} elseif($target_mission == MT_RECYCLE) {
44
+} elseif ($target_mission == MT_RECYCLE) {
45 45
   $planet_type = PT_DEBRIS;
46
-} elseif($target_mission == MT_DESTROY) {
46
+} elseif ($target_mission == MT_DESTROY) {
47 47
   $planet_type = PT_MOON;
48 48
 } else {
49 49
   $planet_type = sys_get_param_int('planet_type');
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
 //$FlyingFleets = doquery("SELECT COUNT(fleet_id) as Number FROM {{fleets}} WHERE `fleet_owner`='{$user['id']}'", true);
60 60
 //$FlyingFleets = $FlyingFleets['Number'];
61 61
 $FlyingFleets = fleet_count_flying($user['id']);
62
-if($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) {
62
+if ($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) {
63 63
   messageBox($lang['fl_noslotfree'], $lang['fl_error'], "fleet." . PHP_EX, 5);
64 64
 }
65 65
 
66 66
 $MaxExpeditions = get_player_max_expeditons($user);
67
-if($MaxExpeditions) {
67
+if ($MaxExpeditions) {
68 68
 //  $FlyingExpeditions  = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{fleets}} WHERE `fleet_owner` = {$user['id']} AND `fleet_mission` = '" . MT_EXPLORE . "';", '', true);
69 69
 //  $FlyingExpeditions  = $FlyingExpeditions['expedi'];
70
-  $FlyingExpeditions  = fleet_count_flying($user['id'], MT_EXPLORE);
70
+  $FlyingExpeditions = fleet_count_flying($user['id'], MT_EXPLORE);
71 71
 } else {
72 72
   $FlyingExpeditions = 0;
73 73
 }
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
     $fleetarray     = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true);
81 81
     $fleetarray = is_array($fleetarray) ? $fleetarray : array();
82 82
 
83
-    foreach($fleetarray as $ship_id => &$ship_amount) {
84
-      if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
83
+    foreach ($fleetarray as $ship_id => &$ship_amount) {
84
+      if (!in_array($ship_id, sn_get_groups('fleet')) || (string) floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
85 85
         $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
86 86
         die();
87 87
       }
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
           $target_mission = MT_COLONIZE;
113 113
           $planet_type = PT_PLANET;
114 114
         } else {
115
-          messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
115
+          messageBox("<font color=\"red\"><b>" . $lang['fl_no_planet_type'] . "</b></font>", $lang['fl_error']);
116 116
         }
117 117
       } else {
118 118
         $recyclers = 0;
119
-        foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
119
+        foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
120 120
           $recyclers += $fleetarray[$recycler_id];
121 121
         }
122 122
         if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
                 $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
143 143
 
144
-                if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
144
+                if ($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
145 145
                   $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
146 146
                 }
147 147
               }
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 );
202 202
 
203 203
 $is_transport_missions = false;
204
-if($missiontype) {
204
+if ($missiontype) {
205 205
   $sn_group_missions = sn_get_groups('missions');
206
-  foreach($missiontype as $mission_data_id => $mission_data) {
206
+  foreach ($missiontype as $mission_data_id => $mission_data) {
207 207
     $is_transport_missions = $is_transport_missions || (isset($sn_group_missions[$mission_data_id]['transport']) && $sn_group_missions[$mission_data_id]['transport']);
208 208
   }
209 209
 }
210 210
 
211
-switch($fleet_page) {
211
+switch ($fleet_page) {
212 212
   case 1:
213 213
     require('includes/includes/flt_page1.inc');
214 214
   break;
Please login to merge, or discard this patch.
galaxy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@
 block discarded – undo
123 123
     ||
124 124
     (!empty($uni_galaxyRowPlanet['destruyed']) && CheckAbandonPlanetState($uni_galaxyRowPlanet))
125 125
   ) {
126
-    $template->assign_block_vars('galaxyrow', ['PLANET_NUM' => $Planet,]);
126
+    $template->assign_block_vars('galaxyrow', ['PLANET_NUM' => $Planet, ]);
127 127
     continue;
128 128
   }
129 129
 
Please login to merge, or discard this patch.
classes/Meta/Economic/EconomicHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@
 block discarded – undo
75 75
    * @return float[] - [int resourceId] -> [float ratesNormalizedToResourceCost]
76 76
    */
77 77
   public function getResourceExchangeIn($resourceId) {
78
-    if(empty($this->resourceExchangeRates[$resourceId])) {
78
+    if (empty($this->resourceExchangeRates[$resourceId])) {
79 79
       $defaultRates = $this->getResourcesExchange();
80 80
 
81 81
       $this->resourceExchangeRates[$resourceId] = [];
82
-      foreach($defaultRates as $defaultResourceId => $defaultRate) {
82
+      foreach ($defaultRates as $defaultResourceId => $defaultRate) {
83 83
         $this->resourceExchangeRates[$resourceId][$defaultResourceId] = $defaultRate / $defaultRates[$resourceId];
84 84
       }
85 85
     }
Please login to merge, or discard this patch.
includes/init.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use \Core\SnBootstrap;
4 4
 
5 5
 // Защита от двойного инита
6
-if(defined('INIT')) {
6
+if (defined('INIT')) {
7 7
   return;
8 8
 }
9 9
 
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 // Но нужно, пока у нас есть не MVC-страницы
117 117
 $sn_page_data = $sn_mvc['pages'][$sn_page_name];
118 118
 $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX;
119
-if($sn_page_name) {
119
+if ($sn_page_name) {
120 120
   // Merging page options to global option pull
121
-  if(is_array($sn_page_data['options'])) {
121
+  if (is_array($sn_page_data['options'])) {
122 122
     classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']);
123 123
   }
124 124
 
125
-  if(isset($sn_page_data) && file_exists($sn_page_name_file)) {
125
+  if (isset($sn_page_data) && file_exists($sn_page_name_file)) {
126 126
     require_once($sn_page_name_file);
127 127
   }
128 128
 }
129 129
 
130
-if((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) {
130
+if ((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) {
131 131
   classSupernova::$options['fleet_update_skip'] = true;
132 132
 }
133 133
 
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 $load_order = array();
142 142
 $sn_req = array();
143 143
 
144
-foreach($sn_module as $loaded_module_name => $module_data) {
144
+foreach ($sn_module as $loaded_module_name => $module_data) {
145 145
   $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000;
146
-  if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
147
-    foreach($module_data->manifest['require'] as $require_name) {
146
+  if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
147
+    foreach ($module_data->manifest['require'] as $require_name) {
148 148
       $sn_req[$loaded_module_name][$require_name] = 0;
149 149
     }
150 150
   }
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 do {
156 156
   $prev_order = $load_order;
157 157
 
158
-  foreach($sn_req as $loaded_module_name => &$req_data) {
158
+  foreach ($sn_req as $loaded_module_name => &$req_data) {
159 159
     $level = 1;
160
-    foreach($req_data as $req_name => &$req_level) {
161
-      if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
160
+    foreach ($req_data as $req_name => &$req_level) {
161
+      if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
162 162
         $level = $req_level = -1;
163 163
         break;
164 164
       } else {
@@ -166,21 +166,21 @@  discard block
 block discarded – undo
166 166
       }
167 167
       $req_level = $load_order[$req_name];
168 168
     }
169
-    if($level > $load_order[$loaded_module_name] || $level == -1) {
169
+    if ($level > $load_order[$loaded_module_name] || $level == -1) {
170 170
       $load_order[$loaded_module_name] = $level;
171 171
     }
172 172
   }
173 173
 }
174
-while($prev_order != $load_order);
174
+while ($prev_order != $load_order);
175 175
 
176 176
 asort($load_order);
177 177
 
178 178
 // Инициализируем модули
179 179
 // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти
180
-foreach($load_order as $loaded_module_name => $load_order_order) {
181
-  if($load_order_order >= 0) {
180
+foreach ($load_order as $loaded_module_name => $load_order_order) {
181
+  if ($load_order_order >= 0) {
182 182
     $sn_module[$loaded_module_name]->check_status();
183
-    if(!$sn_module[$loaded_module_name]->manifest['active']) {
183
+    if (!$sn_module[$loaded_module_name]->manifest['active']) {
184 184
       unset($sn_module[$loaded_module_name]);
185 185
       continue;
186 186
     }
@@ -198,29 +198,29 @@  discard block
 block discarded – undo
198 198
 
199 199
 // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу
200 200
 // TODO - костыль, что бы работали старые модули. Убрать!
201
-if(is_array($sn_data['pages'])) {
201
+if (is_array($sn_data['pages'])) {
202 202
   $sn_mvc['pages'] = array_merge($sn_mvc['pages'], $sn_data['pages']);
203 203
 }
204
-if(!isset($sn_mvc['pages'][$sn_page_name])) {
204
+if (!isset($sn_mvc['pages'][$sn_page_name])) {
205 205
   $sn_page_name = '';
206 206
 }
207 207
 
208 208
 $lang->lng_switch(sys_get_param_str('lang'));
209 209
 
210 210
 
211
-if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
211
+if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
212 212
   \Tools\VersionCheckerDeprecated::performCheckVersion();
213 213
 }
214 214
 
215
-if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
215
+if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
216 216
   require_once(SN_ROOT_PHYSICAL . 'includes/includes/user_birthday_celebrate.php');
217 217
   sn_user_birthday_celebrate();
218 218
 }
219 219
 
220
-if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
220
+if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
221 221
   classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true));
222 222
   classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW);
223
-  if(classSupernova::$config->server_log_online) {
223
+  if (classSupernova::$config->server_log_online) {
224 224
     doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = " . classSupernova::$config->var_online_user_count . ";");
225 225
   }
226 226
 }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
245 245
 
246
-if(!empty($user['id'])) {
246
+if (!empty($user['id'])) {
247 247
   classSupernova::$user_options->user_change($user['id']);
248 248
 }
249 249
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         : false
257 257
       );
258 258
 
259
-if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
259
+if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
260 260
   $prohibited_characters = array_map(function($value) {
261 261
     return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
262 262
   }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 }
265 265
 
266 266
 
267
-if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
267
+if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
268 268
   pdump('Отключи отладку перед продакшном!');
269 269
 }
270 270
 
@@ -278,17 +278,17 @@  discard block
 block discarded – undo
278 278
 
279 279
 StatUpdateLauncher::unlock();
280 280
 
281
-if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
281
+if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
282 282
   $template_result[F_GAME_DISABLE_REASON] = HelperString::nl2br(
283 283
     classSupernova::$config->game_disable == GAME_DISABLE_REASON
284 284
       ? classSupernova::$config->game_disable_reason
285 285
       : $lang['sys_game_disable_reason'][classSupernova::$config->game_disable]
286 286
   );
287
-  if(defined('IN_API')) {
287
+  if (defined('IN_API')) {
288 288
     return;
289 289
   }
290 290
 
291
-  if(
291
+  if (
292 292
     ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN))
293 293
     &&
294 294
     !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT'))
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
 
302 302
 // TODO ban
303 303
 // TODO $skip_ban_check
304
-if($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
305
-  if(defined('IN_API')) {
304
+if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
305
+  if (defined('IN_API')) {
306 306
     return;
307 307
   }
308 308
 
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 $allow_anonymous = $allow_anonymous || (isset($sn_page_data['allow_anonymous']) && $sn_page_data['allow_anonymous']);
317 317
 
318 318
 
319
-if($sys_user_logged_in && INITIAL_PAGE == 'login') {
319
+if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
320 320
   sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
321
-} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
322
-} elseif(!$allow_anonymous && !$sys_user_logged_in) {
321
+} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
322
+} elseif (!$allow_anonymous && !$sys_user_logged_in) {
323 323
   sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
324 324
 }
325 325
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
   'fleet_update_last',
344 344
   classSupernova::$config->fleet_update_interval,
345 345
   // Promise
346
-  function () {classSupernova::$gc->fleetDispatcher->dispatch();},
346
+  function() {classSupernova::$gc->fleetDispatcher->dispatch(); },
347 347
   WATCHDOG_TIME_SQL,
348 348
   false
349 349
 );
Please login to merge, or discard this patch.
includes/functions/eco_get_build_data.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function eco_get_lab_max_effective_level(&$user, $lab_require)
15 15
 {
16
-  if(!$user['user_as_ally'] && !isset($user['laboratories_active']))
16
+  if (!$user['user_as_ally'] && !isset($user['laboratories_active']))
17 17
   {
18 18
     $user['laboratories_active'] = array();
19 19
     $query = DBStaticUnit::db_unit_list_laboratories($user['id']);
20
-    while($row = db_fetch($query))
20
+    while ($row = db_fetch($query))
21 21
     {
22
-      if(!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES))
22
+      if (!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES))
23 23
       {
24 24
         $row += array(
25 25
           STRUC_LABORATORY => $level_lab = mrc_get_level($user, $row, STRUC_LABORATORY),
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
     uasort($user['laboratories_active'], 'eco_lab_sort_effectivness');
34 34
   }
35 35
 
36
-  if(!isset($user['research_effective_level'][$lab_require]))
36
+  if (!isset($user['research_effective_level'][$lab_require]))
37 37
   {
38
-    if($user['user_as_ally'])
38
+    if ($user['user_as_ally'])
39 39
     {
40 40
       $lab_level = doquery("SELECT ally_members AS effective_level FROM {{alliance}} WHERE id = {$user['user_as_ally']} LIMIT 1", true);
41 41
     }
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
       $tech_intergalactic = mrc_get_level($user, false, TECH_RESEARCH) + 1;
45 45
       $lab_level['effective_level'] = 0;
46 46
 
47
-      foreach($user['laboratories_active'] as $data)
47
+      foreach ($user['laboratories_active'] as $data)
48 48
       {
49
-        if($tech_intergalactic <= 0)
49
+        if ($tech_intergalactic <= 0)
50 50
         {
51 51
           break;
52 52
         }
53
-        if($data[STRUC_LABORATORY] >= $lab_require)
53
+        if ($data[STRUC_LABORATORY] >= $lab_require)
54 54
         {
55 55
           $lab_level['effective_level'] += $data['laboratory_effective_level'];
56 56
           $tech_intergalactic--;
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
   $cost[P_OPTIONS][P_TIME_RAW] = 0;
91 91
   $only_dark_matter = 0;
92 92
   $cost_in_metal = 0;
93
-  foreach($unit_data[P_COST] as $resource_id => $resource_amount) {
94
-    if($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) {
93
+  foreach ($unit_data[P_COST] as $resource_id => $resource_amount) {
94
+    if ($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) {
95 95
       continue;
96 96
     }
97 97
 
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 
103 103
     $cost_in_metal += $cost[BUILD_CREATE][$resource_id] * $currentResourceExchange;
104 104
 
105
-    if(in_array($resource_id, $resources_loot)) {
105
+    if (in_array($resource_id, $resources_loot)) {
106 106
       $cost[P_OPTIONS][P_TIME_RAW] += $resource_cost * $currentResourceExchange / $rpg_exchange_deuterium;
107 107
       $resource_got = mrc_get_level($user, $planet, $resource_id);
108
-    } elseif($resource_id == RES_DARK_MATTER) {
108
+    } elseif ($resource_id == RES_DARK_MATTER) {
109 109
       $resource_got = mrc_get_level($user, null, $resource_id);
110
-    } elseif($resource_id == RES_ENERGY) {
110
+    } elseif ($resource_id == RES_ENERGY) {
111 111
       $resource_got = max(0, $planet['energy_max'] - $planet['energy_used']);
112 112
     } else {
113 113
       $resource_got = 0;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
   }
120 120
 
121 121
   $resources_normalized = 0;
122
-  foreach($resources_loot as $resource_id) {
122
+  foreach ($resources_loot as $resource_id) {
123 123
     $resources_normalized += floor(mrc_get_level($user, $planet, $resource_id)) * $config->__get('rpg_exchange_' . pname_resource_name($resource_id));
124 124
   }
125 125
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
   $cost[P_OPTIONS][P_TIME_RAW] = $cost[P_OPTIONS][P_TIME_RAW] * 60 * 60 / get_game_speed() / 2500;
136 136
 
137 137
   // TODO - Вынести в отдельную процедуру расчёт стоимости
138
-  if($only_cost) {
138
+  if ($only_cost) {
139 139
     return $cost;
140 140
   }
141 141
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
   $cost['RESULT'][BUILD_DESTROY] = BUILD_INDESTRUCTABLE;
148 148
 
149 149
   $mercenary = 0;
150
-  if(in_array($unit_id, sn_get_groups('structures'))) {
150
+  if (in_array($unit_id, sn_get_groups('structures'))) {
151 151
     $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_ROBOT) + 1);
152 152
     $cost['RESULT'][BUILD_DESTROY] =
153 153
       mrc_get_level($user, $planet, $unit_id, false, true)
@@ -157,23 +157,23 @@  discard block
 block discarded – undo
157 157
           )
158 158
         : BUILD_NO_UNITS;
159 159
     $mercenary = MRC_ENGINEER;
160
-  } elseif(in_array($unit_id, sn_get_groups('tech'))) {
160
+  } elseif (in_array($unit_id, sn_get_groups('tech'))) {
161 161
     $lab_level = eco_get_lab_max_effective_level($user, intval($unit_data['require'][STRUC_LABORATORY]));
162 162
     $cost[RES_TIME][BUILD_CREATE] /= $lab_level;
163 163
     $mercenary = MRC_ACADEMIC;
164
-  } elseif(in_array($unit_id, sn_get_groups('defense'))) {
165
-    $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1) ;
164
+  } elseif (in_array($unit_id, sn_get_groups('defense'))) {
165
+    $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1);
166 166
     $mercenary = MRC_FORTIFIER;
167
-  } elseif(in_array($unit_id, sn_get_groups('fleet'))) {
167
+  } elseif (in_array($unit_id, sn_get_groups('fleet'))) {
168 168
     $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1);
169 169
     $mercenary = MRC_ENGINEER;
170 170
   }
171 171
 
172
-  if($mercenary) {
172
+  if ($mercenary) {
173 173
     $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_CREATE] / mrc_modify_value($user, $planet, $mercenary, 1);
174 174
   }
175 175
 
176
-  if(in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) {
176
+  if (in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) {
177 177
     $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_DESTROY] = 0;
178 178
   } else {
179 179
     $cost[RES_TIME][BUILD_CREATE]  = round($cost[RES_TIME][BUILD_CREATE] > 1 ? $cost[RES_TIME][BUILD_CREATE] : 1);
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
   return $cost;
184 184
 }
185 185
 
186
-function eco_can_build_unit($user, $planet, $unit_id){return sn_function_call('eco_can_build_unit', array($user, $planet, $unit_id, &$result));}
186
+function eco_can_build_unit($user, $planet, $unit_id) {return sn_function_call('eco_can_build_unit', array($user, $planet, $unit_id, &$result)); }
187 187
 function sn_eco_can_build_unit($user, $planet, $unit_id, &$result) {
188 188
   global $config;
189 189
 
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
   $result = $result == BUILD_ALLOWED && eco_unit_busy($user, $planet, $unit_id) ? BUILD_UNIT_BUSY : $result;
192 192
 
193 193
   $unit_param = get_unit_param($unit_id);
194
-  if($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) {
194
+  if ($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) {
195 195
     $requirement = &$unit_param[P_REQUIRE];
196
-    if($result == BUILD_ALLOWED && $requirement) {
197
-      foreach($requirement as $require_id => $require_level) {
198
-        if(mrc_get_level($user, $planet, $require_id) < $require_level) {
196
+    if ($result == BUILD_ALLOWED && $requirement) {
197
+      foreach ($requirement as $require_id => $require_level) {
198
+        if (mrc_get_level($user, $planet, $require_id) < $require_level) {
199 199
           $result = BUILD_REQUIRE_NOT_MEET;
200 200
           break;
201 201
         }
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
 
213 213
   $unit_list = is_array($unit_list) ? $unit_list : array($unit_list => $unit_list);
214 214
   $planet_que = explode(';', $planet_que);
215
-  foreach($planet_que as $planet_que_item)
215
+  foreach ($planet_que as $planet_que_item)
216 216
   {
217
-    if($planet_que_item)
217
+    if ($planet_que_item)
218 218
     {
219 219
       list($planet_que_item) = explode(',', $planet_que_item);
220
-      if(in_array($planet_que_item, $unit_list))
220
+      if (in_array($planet_que_item, $unit_list))
221 221
       {
222 222
         $eco_is_builds_in_que = true;
223 223
         break;
@@ -228,21 +228,21 @@  discard block
 block discarded – undo
228 228
   return $eco_is_builds_in_que;
229 229
 }
230 230
 
231
-function eco_unit_busy(&$user, &$planet, $unit_id){return sn_function_call('eco_unit_busy', array(&$user, &$planet, $unit_id, &$result));}
231
+function eco_unit_busy(&$user, &$planet, $unit_id) {return sn_function_call('eco_unit_busy', array(&$user, &$planet, $unit_id, &$result)); }
232 232
 function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result)
233 233
 {
234 234
   global $config;
235 235
 
236 236
   $result = isset($result) ? $result : false;
237
-  if(!$result)
237
+  if (!$result)
238 238
   {
239
-    if(($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !$config->BuildLabWhileRun)
239
+    if (($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !$config->BuildLabWhileRun)
240 240
     {
241 241
       $global_que = que_get($user['id'], $planet['id'], QUE_RESEARCH, false);
242
-      if(is_array($global_que['ques'][QUE_RESEARCH][$user['id']]))
242
+      if (is_array($global_que['ques'][QUE_RESEARCH][$user['id']]))
243 243
       {
244 244
         $first_element = reset($global_que['ques'][QUE_RESEARCH][$user['id']]);
245
-        if(is_array($first_element))
245
+        if (is_array($first_element))
246 246
         {
247 247
           $result = true;
248 248
         }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
       //  $result = true;
253 253
       //}
254 254
     }
255
-    elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que'])
255
+    elseif (($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que'])
256 256
     {
257 257
       $result = eco_is_builds_in_que($planet['que'], array(STRUC_LABORATORY, STRUC_LABORATORY_NANO));
258 258
     }
Please login to merge, or discard this patch.
admin/admin_analyze_matter.php 1 patch
Spacing   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 
16 16
 $constants = get_defined_constants(true);
17 17
 $rpgConstants = array();
18
-foreach($constants['user'] as $constantName => $constantValue) {
19
-  if(substr($constantName, 0, 4) == 'RPG_') {
18
+foreach ($constants['user'] as $constantName => $constantValue) {
19
+  if (substr($constantName, 0, 4) == 'RPG_') {
20 20
     $rpgConstants[$constantValue] = $constantName;
21 21
   }
22 22
 }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 GROUP BY log_dark_matter_reason, IF(sign((log_dark_matter_amount)) > 0, 1, -1) ORDER BY sum(log_dark_matter_amount) DESC;
34 34
 ");
35 35
 
36
-while($row = classSupernova::$db->db_fetch($result)) {
36
+while ($row = classSupernova::$db->db_fetch($result)) {
37 37
   $row['CONSTANT'] = $rpgConstants[$row['REASON']];
38 38
 
39 39
   $row['DM_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['DM_AMOUNT']);
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 GROUP BY reason, if(sign((amount)) > 0, 1, -1) ORDER BY sum(amount) DESC;
56 56
 ");
57 57
 
58
-while($row = classSupernova::$db->db_fetch($result)) {
59
-  if(empty($spent[$row['BALANCE']])) {
58
+while ($row = classSupernova::$db->db_fetch($result)) {
59
+  if (empty($spent[$row['BALANCE']])) {
60 60
     $spent[$row['BALANCE']] = array();
61 61
   }
62 62
 
@@ -66,16 +66,15 @@  discard block
 block discarded – undo
66 66
   $spent[$row['BALANCE']] = array_merge_recursive_numeric($spent[$row['BALANCE']], $row);
67 67
 }
68 68
 
69
-foreach($spent as &$row) {
69
+foreach ($spent as &$row) {
70 70
   @$row['TOTAL_COUNT'] = $row['MM_COUNT'] + $row['DM_COUNT'];
71 71
   @$row['TOTAL_AMOUNT'] = $row['MM_AMOUNT'] + $row['DM_AMOUNT'];
72 72
   @$row['TOTAL_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_AMOUNT']);
73 73
   @$row['TOTAL_COUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_COUNT']);
74 74
 }
75 75
 
76
-usort($spent, function ($a, $b) {
77
-  return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 :
78
-    ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0);
76
+usort($spent, function($a, $b) {
77
+  return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 : ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0);
79 78
 });
80 79
 
81 80
 
Please login to merge, or discard this patch.
admin/includes/admin_planet_edit.inc.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list){return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list));}
3
+function admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list) {return sn_function_call('admin_planet_edit_mode', array(&$template, &$admin_planet_edit_mode_list)); }
4 4
 function sn_admin_planet_edit_mode(&$template, &$admin_planet_edit_mode_list)
5 5
 {
6 6
   global $lang;
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
   return $mode;
20 20
 }
21 21
 
22
-function admin_planet_edit_template(&$template, $edit_planet_row, $mode){return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode));}
22
+function admin_planet_edit_template(&$template, $edit_planet_row, $mode) {return sn_function_call('admin_planet_edit_template', array(&$template, $edit_planet_row, $mode)); }
23 23
 /**
24 24
  * @param template $template
25 25
  * @param $edit_planet_row
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
   global $lang;
31 31
 
32 32
   $unit_list = sn_get_groups($mode);
33
-  if(empty($unit_list))
33
+  if (empty($unit_list))
34 34
   {
35 35
     return;
36 36
   }
37 37
   $name_list = $lang['tech'];
38 38
 
39
-  foreach($unit_list as $unit_id)
39
+  foreach ($unit_list as $unit_id)
40 40
   {
41 41
     $template->assign_block_vars('unit', array(
42 42
       'ID'    => $unit_id,
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
   }
48 48
 }
49 49
 
50
-function admin_planet_edit_query_string($unit_id, $unit_amount, $mode){return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode));}
50
+function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) {return sn_function_call('admin_planet_edit_query_string', array($unit_id, $unit_amount, $mode)); }
51 51
 function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode)
52 52
 {
53
-  if($unit_amount && in_array($unit_id, sn_get_groups($mode)))
53
+  if ($unit_amount && in_array($unit_id, sn_get_groups($mode)))
54 54
   {
55 55
     $unit_amount = round($unit_amount);
56 56
     $unit_name = get_unit_param($unit_id, P_NAME);
Please login to merge, or discard this patch.
includes/includes/flt_mission_recycle.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
   $fleet_row          = &$mission_data['fleet'];
13 13
   $destination_planet = &$mission_data['dst_planet'];
14 14
 
15
-  if(!$fleet_row)
15
+  if (!$fleet_row)
16 16
   {
17 17
     return CACHE_NOTHING;
18 18
   }
19 19
 
20
-  if(!isset($destination_planet['id']))
20
+  if (!isset($destination_planet['id']))
21 21
   {
22 22
     // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;");
23 23
     fleet_send_back($mission_data['fleet']);
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
   $RecyclerCapacity    = 0;
30 30
   $OtherFleetCapacity  = 0;
31 31
   $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']);
32
-  foreach($fleet_array as $unit_id => $unit_count)
32
+  foreach ($fleet_array as $unit_id => $unit_count)
33 33
   {
34
-    if(in_array($unit_id, sn_get_groups('fleet')))
34
+    if (in_array($unit_id, sn_get_groups('fleet')))
35 35
     {
36 36
       $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count;
37
-      if(in_array($unit_id, sn_get_groups('flt_recyclers')))
37
+      if (in_array($unit_id, sn_get_groups('flt_recyclers')))
38 38
       {
39 39
         $RecyclerCapacity += $capacity;
40 40
       }
@@ -46,19 +46,19 @@  discard block
 block discarded – undo
46 46
   }
47 47
 
48 48
   $IncomingFleetGoods = $fleet_row["fleet_resource_metal"] + $fleet_row["fleet_resource_crystal"] + $fleet_row["fleet_resource_deuterium"];
49
-  if($IncomingFleetGoods > $OtherFleetCapacity)
49
+  if ($IncomingFleetGoods > $OtherFleetCapacity)
50 50
   {
51 51
     $RecyclerCapacity -= ($IncomingFleetGoods - $OtherFleetCapacity);
52 52
   }
53 53
 
54
-  if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity)
54
+  if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity)
55 55
   {
56 56
     $RecycledGoods["metal"]   = $destination_planet["debris_metal"];
57 57
     $RecycledGoods["crystal"] = $destination_planet["debris_crystal"];
58 58
   }
59 59
   else
60 60
   {
61
-    if (($destination_planet["debris_metal"]   > $RecyclerCapacity / 2) AND
61
+    if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND
62 62
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2))
63 63
       {
64 64
       $RecycledGoods["metal"]   = $RecyclerCapacity / 2;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
       }
93 93
     }
94 94
   }
95
-  $NewCargo['Metal']     = $fleet_row["fleet_resource_metal"]   + $RecycledGoods["metal"];
95
+  $NewCargo['Metal']     = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"];
96 96
   $NewCargo['Crystal']   = $fleet_row["fleet_resource_crystal"] + $RecycledGoods["crystal"];
97 97
   $NewCargo['Deuterium'] = $fleet_row["fleet_resource_deuterium"];
98 98
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     HelperString::numberFloorAndFormat($RecycledGoods["metal"]), $lang['Metal'],
106 106
     HelperString::numberFloorAndFormat($RecycledGoods["crystal"]), $lang['Crystal']
107 107
   );
108
-  msg_send_simple_message ( $fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message);
108
+  msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message);
109 109
 
110 110
 //  $QryUpdateFleet  = "UPDATE {{fleets}} SET `fleet_mess` = 1,`fleet_resource_metal` = '{$NewCargo['Metal']}',`fleet_resource_crystal` = '{$NewCargo['Crystal']}',`fleet_resource_deuterium` = '{$NewCargo['Deuterium']}' ";
111 111
 //  $QryUpdateFleet .= "WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;";
Please login to merge, or discard this patch.