Completed
Push — trunk ( cc9b3e...f009e4 )
by SuperNova.WS
04:37
created
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/ube_attack_calculate.php 1 patch
Spacing   +128 added lines, -129 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 */
53 53
 
54
-if(BE_DEBUG === true)
54
+if (BE_DEBUG === true)
55 55
 {
56 56
   require_once('ube_zi_helpers.php');
57 57
 }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 {
84 84
   global $ube_convert_techs;
85 85
 
86
-  if(!isset($combat_data[UBE_PLAYERS][$player_id]))
86
+  if (!isset($combat_data[UBE_PLAYERS][$player_id]))
87 87
   {
88 88
     $combat_data[UBE_PLAYERS][$player_id] = array(UBE_ATTACKER => $is_attacker);
89 89
     $player_info = &$combat_data[UBE_PLAYERS][$player_id];
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     $player_info[UBE_PLAYER_DATA] = $player_data;
96 96
 
97 97
     $admiral_bonus = mrc_get_level($player_data, false, MRC_ADMIRAL) * get_unit_param(MRC_ADMIRAL, P_BONUS_VALUE) / 100;
98
-    foreach($ube_convert_techs as $unit_id => $ube_id)
98
+    foreach ($ube_convert_techs as $unit_id => $ube_id)
99 99
     {
100 100
       $player_info[UBE_BONUSES][$ube_id] += mrc_get_level($player_data, false, $unit_id) * get_unit_param($unit_id, P_BONUS_VALUE) / 100 + $admiral_bonus;
101 101
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
 // ------------------------------------------------------------------------------------------------
110 110
 // Заполняет данные по флоту
111
-function ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker){return sn_function_call('ube_attack_prepare_fleet', array(&$combat_data, &$fleet, $is_attacker));}
111
+function ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker) {return sn_function_call('ube_attack_prepare_fleet', array(&$combat_data, &$fleet, $is_attacker)); }
112 112
 function sn_ube_attack_prepare_fleet(&$combat_data, &$fleet, $is_attacker)
113 113
 {
114 114
   $fleet_owner_id = $fleet['fleet_owner'];
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
   $combat_data[UBE_FLEETS][$fleet_id][UBE_OWNER] = $fleet_owner_id;
122 122
   $fleet_info = &$combat_data[UBE_FLEETS][$fleet_id];
123 123
   $fleet_info[UBE_FLEET_GROUP] = $fleet['fleet_group'];
124
-  foreach($fleet_data as $unit_id => $unit_count)
124
+  foreach ($fleet_data as $unit_id => $unit_count)
125 125
   {
126
-    if(!$unit_count)
126
+    if (!$unit_count)
127 127
     {
128 128
       continue;
129 129
     }
130 130
 
131 131
     $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
132
-    if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE)
132
+    if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE)
133 133
     {
134 134
       $fleet_info[UBE_COUNT][$unit_id] = $unit_count;
135 135
     }
@@ -169,23 +169,23 @@  discard block
 block discarded – undo
169 169
   $combat_data[UBE_FLEETS][0] = array(UBE_OWNER => $player_id);
170 170
   $fleet_info = &$combat_data[UBE_FLEETS][0];
171 171
 
172
-  foreach(sn_get_groups('combat') as $unit_id)
172
+  foreach (sn_get_groups('combat') as $unit_id)
173 173
   {
174
-    if($unit_count = mrc_get_level($player, $planet, $unit_id))
174
+    if ($unit_count = mrc_get_level($player, $planet, $unit_id))
175 175
     {
176 176
       $fleet_info[UBE_COUNT][$unit_id] = $unit_count;
177 177
     }
178 178
   }
179 179
 
180
-  foreach(sn_get_groups('resources_loot') as $resource_id)
180
+  foreach (sn_get_groups('resources_loot') as $resource_id)
181 181
   {
182 182
     $fleet_info[UBE_RESOURCES][$resource_id] = floor(mrc_get_level($player, $planet, $resource_id));
183 183
   }
184 184
 
185
-  if($fortifier_level = mrc_get_level($player, $planet, MRC_FORTIFIER))
185
+  if ($fortifier_level = mrc_get_level($player, $planet, MRC_FORTIFIER))
186 186
   {
187 187
     $fortifier_bonus = $fortifier_level * get_unit_param(MRC_FORTIFIER, P_BONUS_VALUE) / 100;
188
-    foreach($ube_combat_bonus_list as $ube_id)
188
+    foreach ($ube_combat_bonus_list as $ube_id)
189 189
     {
190 190
       $fleet_info[UBE_BONUSES][$ube_id] += $fortifier_bonus;
191 191
     }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
     PLANET_SIZE   => $planet['diameter'],
202 202
   );
203 203
 
204
-  $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE] = $player['onlinetime'] >= $combat_data[UBE_TIME] - 60*60*24*7;
204
+  $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE] = $player['onlinetime'] >= $combat_data[UBE_TIME] - 60 * 60 * 24 * 7;
205 205
 }
206 206
 
207 207
 
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 //    ube_attack_prepare_fleet($combat_data, $fleet, false);
242 242
 //  }
243 243
   $fleet_list_on_hold = fleet_list_on_hold($fleet_row['fleet_end_galaxy'], $fleet_row['fleet_end_system'], $fleet_row['fleet_end_planet'], $fleet_row['fleet_end_type'], $ube_time);
244
-  foreach($fleet_list_on_hold as $fleet) {
244
+  foreach ($fleet_list_on_hold as $fleet) {
245 245
     ube_attack_prepare_fleet($combat_data, $fleet, false);
246 246
   }
247 247
 
248 248
   // Готовим инфу по атакующим
249
-  if($fleet_row['fleet_group'])
249
+  if ($fleet_row['fleet_group'])
250 250
   {
251 251
 //    $fleets = doquery("SELECT * FROM {{fleets}} WHERE fleet_group = {$fleet_row['fleet_group']} FOR UPDATE");
252 252
 //    while($fleet = db_fetch($fleets))
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 //      ube_attack_prepare_fleet($combat_data, $fleet, true);
255 255
 //    }
256 256
     $acs_fleet_list = fleet_list_by_group($fleet_row['fleet_group']);
257
-    foreach($acs_fleet_list as $fleet) {
257
+    foreach ($acs_fleet_list as $fleet) {
258 258
       ube_attack_prepare_fleet($combat_data, $fleet, true);
259 259
     }
260 260
   }
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
 
280 280
   // Готовим информацию для первого раунда - проводим все нужные вычисления из исходных данных
281 281
   $first_round_data = array();
282
-  foreach($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info)
282
+  foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info)
283 283
   {
284 284
     $fleet_info[UBE_COUNT] = is_array($fleet_info[UBE_COUNT]) ? $fleet_info[UBE_COUNT] : array();
285 285
     $player_data = &$combat_data[UBE_PLAYERS][$fleet_info[UBE_OWNER]];
286 286
     $fleet_info[UBE_FLEET_TYPE] = $player_data[UBE_ATTACKER] ? UBE_ATTACKERS : UBE_DEFENDERS;
287 287
 
288
-    foreach($ube_combat_bonus_list as $bonus_id => $bonus_value)
288
+    foreach ($ube_combat_bonus_list as $bonus_id => $bonus_value)
289 289
     {
290 290
       // Вычисляем бонус игрока
291 291
       $bonus_value = isset($player_data[UBE_BONUSES][$bonus_id]) ? $player_data[UBE_BONUSES][$bonus_id] : 0;
@@ -294,16 +294,16 @@  discard block
 block discarded – undo
294 294
     }
295 295
 
296 296
     $first_round_data[$fleet_id][UBE_COUNT] = $fleet_info[UBE_PRICE] = array();
297
-    foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
297
+    foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
298 298
     {
299
-      if($unit_count <= 0)
299
+      if ($unit_count <= 0)
300 300
       {
301 301
         continue;
302 302
       }
303 303
 
304 304
       $unit_info = get_unit_param($unit_id);
305 305
       // Заполняем информацию о кораблях в информации флота
306
-      foreach($ube_combat_bonus_list as $bonus_id => $bonus_value)
306
+      foreach ($ube_combat_bonus_list as $bonus_id => $bonus_value)
307 307
       {
308 308
         $fleet_info[$bonus_id][$unit_id] = floor($unit_info[$ube_convert_to_techs[$bonus_id]] * (1 + $fleet_info[UBE_BONUSES][$bonus_id]));
309 309
       }
@@ -346,16 +346,16 @@  discard block
 block discarded – undo
346 346
   $is_simulator = $combat_data[UBE_OPTIONS][UBE_SIMULATOR];
347 347
 
348 348
   $round_data = &$combat_data[UBE_ROUNDS][$round];
349
-  foreach($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data)
349
+  foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data)
350 350
   {
351 351
     // Кэшируем переменные для легкого доступа к подмассивам
352 352
     $fleet_info = &$combat_data[UBE_FLEETS][$fleet_id];
353 353
     $fleet_data[UBE_FLEET_INFO] = &$fleet_info;
354 354
     $fleet_type = $fleet_info[UBE_FLEET_TYPE];
355 355
 
356
-    foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
356
+    foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
357 357
     {
358
-      if($unit_count <= 0)
358
+      if ($unit_count <= 0)
359 359
       {
360 360
         continue;
361 361
       }
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
       // Для не-симулятора - рандомизируем каждый раунд значения атаки и щитов
366 366
       $fleet_data[UBE_ATTACK_BASE][$unit_id] = floor($fleet_info[UBE_ATTACK][$unit_id] * ($is_simulator ? 1 : mt_rand(80, 120) / 100));
367 367
       $fleet_data[UBE_SHIELD_BASE][$unit_id] = floor($fleet_info[UBE_SHIELD][$unit_id] * ($is_simulator ? 1 : mt_rand(80, 120) / 100));
368
-      $fleet_data[UBE_ARMOR_BASE][$unit_id]  = floor($fleet_info[UBE_ARMOR][$unit_id]);// * ($is_simulator ? 1 : mt_rand(80, 120) / 100));
368
+      $fleet_data[UBE_ARMOR_BASE][$unit_id]  = floor($fleet_info[UBE_ARMOR][$unit_id]); // * ($is_simulator ? 1 : mt_rand(80, 120) / 100));
369 369
 
370 370
       $fleet_data[UBE_ATTACK][$unit_id] = $fleet_data[UBE_ATTACK_BASE][$unit_id] * $unit_count;
371 371
       $fleet_data[UBE_SHIELD][$unit_id] = $fleet_data[UBE_SHIELD_BASE][$unit_id] * $unit_count;
@@ -375,24 +375,24 @@  discard block
 block discarded – undo
375 375
     }
376 376
 
377 377
     // Суммируем данные по флоту
378
-    foreach($ube_combat_bonus_list as $bonus_id)
378
+    foreach ($ube_combat_bonus_list as $bonus_id)
379 379
     {
380 380
       $round_data[$fleet_type][$bonus_id][$fleet_id] += is_array($fleet_data[$bonus_id]) ? array_sum($fleet_data[$bonus_id]) : 0;
381 381
     }
382 382
   }
383 383
 
384 384
   // Суммируем данные по атакующим и защитникам
385
-  foreach($ube_combat_bonus_list as $bonus_id)
385
+  foreach ($ube_combat_bonus_list as $bonus_id)
386 386
   {
387 387
     $round_data[UBE_TOTAL][UBE_DEFENDERS][$bonus_id] = array_sum($round_data[UBE_DEFENDERS][$bonus_id]);
388 388
     $round_data[UBE_TOTAL][UBE_ATTACKERS][$bonus_id] = array_sum($round_data[UBE_ATTACKERS][$bonus_id]);
389 389
   }
390 390
 
391 391
   // Высчитываем долю атаки, приходящейся на юнит равную отношению брони юнита к общей броне - крупные цели атакуют чаще
392
-  foreach($round_data[UBE_FLEETS] as &$fleet_data)
392
+  foreach ($round_data[UBE_FLEETS] as &$fleet_data)
393 393
   {
394 394
     $fleet_type = $fleet_data[UBE_FLEET_INFO][UBE_FLEET_TYPE];
395
-    foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
395
+    foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
396 396
     {
397 397
       $fleet_data[UBE_DAMAGE_PERCENT][$unit_id] = $fleet_data[UBE_ARMOR][$unit_id] / $round_data[UBE_TOTAL][$fleet_type][UBE_ARMOR];
398 398
     }
@@ -403,24 +403,24 @@  discard block
 block discarded – undo
403 403
 // Рассчитывает результат столкновения флотов ака раунд
404 404
 function sn_ube_combat_round_crossfire_fleet(&$combat_data, $round)
405 405
 {
406
-  if(BE_DEBUG === true)
406
+  if (BE_DEBUG === true)
407 407
   {
408 408
     // sn_ube_combat_helper_round_header($round);
409 409
   }
410 410
 
411 411
   $round_data = &$combat_data[UBE_ROUNDS][$round];
412 412
   // Проводим бой. Сталкиваем каждый корабль атакующего с каждым кораблем атакуемого
413
-  foreach($round_data[UBE_ATTACKERS][UBE_ATTACK] as $attack_fleet_id => $temp)
413
+  foreach ($round_data[UBE_ATTACKERS][UBE_ATTACK] as $attack_fleet_id => $temp)
414 414
   {
415 415
     $attack_fleet_data = &$round_data[UBE_FLEETS][$attack_fleet_id];
416
-    foreach($round_data[UBE_DEFENDERS][UBE_ATTACK] as $defend_fleet_id => $temp2)
416
+    foreach ($round_data[UBE_DEFENDERS][UBE_ATTACK] as $defend_fleet_id => $temp2)
417 417
     {
418 418
       $defend_fleet_data = &$round_data[UBE_FLEETS][$defend_fleet_id];
419 419
 
420
-      foreach($attack_fleet_data[UBE_COUNT] as $attack_unit_id => $attack_unit_count)
420
+      foreach ($attack_fleet_data[UBE_COUNT] as $attack_unit_id => $attack_unit_count)
421 421
       {
422 422
         // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..."
423
-        foreach($defend_fleet_data[UBE_COUNT] as $defend_unit_id => $defend_unit_count)
423
+        foreach ($defend_fleet_data[UBE_COUNT] as $defend_unit_id => $defend_unit_count)
424 424
         {
425 425
           sn_ube_combat_round_crossfire_unit2($attack_fleet_data, $defend_fleet_data, $attack_unit_id, $defend_unit_id, $combat_data[UBE_OPTIONS]);
426 426
           sn_ube_combat_round_crossfire_unit2($defend_fleet_data, $attack_fleet_data, $defend_unit_id, $attack_unit_id, $combat_data[UBE_OPTIONS]);
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
     }
430 430
   }
431 431
 
432
-  if(BE_DEBUG === true)
432
+  if (BE_DEBUG === true)
433 433
   {
434 434
     // sn_ube_combat_helper_round_footer();
435 435
   }
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
   $boom = 0;
478 478
   $boom_limit = 75;
479 479
   $random = $combat_options[UBE_SIMULATOR] ? $boom_limit / 2 : mt_rand(0, 100);
480
-  if($armor_damage && $units_left > 0 && $last_unit_percent <= $boom_limit && $last_unit_percent <= $random)
480
+  if ($armor_damage && $units_left > 0 && $last_unit_percent <= $boom_limit && $last_unit_percent <= $random)
481 481
   {
482 482
     $boom = 1;
483 483
     $units_left--;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 
488 488
   $defend_fleet_data[UBE_COUNT][$defend_unit_id] = $units_left;
489 489
 
490
-  if(BE_DEBUG === true)
490
+  if (BE_DEBUG === true)
491 491
   {
492 492
     $debug_unit_crossfire_result = array(
493 493
       'attack_unit_id' => $attack_unit_id,
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
   $units_lost = $units_lost ? $units_lost : 0;
527 527
 
528 528
   $boom_limit = 75; // Взрываемся на 75% прочности
529
-  if($defend_fleet_data[UBE_COUNT][$defend_unit_id] > 0 && $amplified_damage)
529
+  if ($defend_fleet_data[UBE_COUNT][$defend_unit_id] > 0 && $amplified_damage)
530 530
   {
531 531
     // $defend_fleet_info = &$defend_fleet_data[UBE_FLEET_INFO];
532 532
 
@@ -539,18 +539,18 @@  discard block
 block discarded – undo
539 539
     $defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] -= $damage_to_armor;
540 540
 
541 541
     // Если брони не осталось - юнит потерян
542
-    if($defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] <= 0)
542
+    if ($defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] <= 0)
543 543
     {
544 544
       $unit_is_lost = true;
545 545
     }
546 546
     // Если броня осталось, но не осталось щитов - прошел дамадж по броне и надо проверить - не взорвался ли корабль
547
-    elseif($defend_fleet_data[UBE_SHIELD_REST][$defend_unit_id] <= 0)
547
+    elseif ($defend_fleet_data[UBE_SHIELD_REST][$defend_unit_id] <= 0)
548 548
     {
549 549
       $last_unit_hp = $defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id];
550 550
       $last_unit_percent = $last_unit_hp / $defend_fleet_data[UBE_ARMOR_BASE][$defend_unit_id] * 100;
551 551
 
552 552
       $random = $combat_options[UBE_SIMULATOR] ? $boom_limit / 2 : mt_rand(0, 100);
553
-      if($last_unit_percent <= $boom_limit && $last_unit_percent <= $random)
553
+      if ($last_unit_percent <= $boom_limit && $last_unit_percent <= $random)
554 554
       {
555 555
         $unit_is_lost = true;
556 556
         $units_boomed++;
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
     $defend_fleet_data[UBE_ARMOR][$defend_unit_id] -= $damage_to_armor;
564 564
     $defend_fleet_data[UBE_SHIELD][$defend_unit_id] -= $damage_to_shield;
565 565
 
566
-    if($unit_is_lost)
566
+    if ($unit_is_lost)
567 567
     {
568 568
       $units_lost++;
569 569
       $defend_fleet_data[UBE_COUNT][$defend_unit_id]--;
570
-      if($defend_fleet_data[UBE_COUNT][$defend_unit_id])
570
+      if ($defend_fleet_data[UBE_COUNT][$defend_unit_id])
571 571
       {
572 572
         $defend_fleet_data[UBE_ARMOR_REST][$defend_unit_id] = $defend_fleet_data[UBE_ARMOR_BASE][$defend_unit_id];
573 573
         $defend_fleet_data[UBE_SHIELD_REST][$defend_unit_id] = $defend_fleet_data[UBE_SHIELD_BASE][$defend_unit_id];
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 // Рассчитывает результат столкновения двух юнитов ака ход
583 583
 function sn_ube_combat_round_crossfire_unit2(&$attack_fleet_data, &$defend_fleet_data, $attack_unit_id, $defend_unit_id, &$combat_options)
584 584
 {
585
-  if($defend_fleet_data[UBE_COUNT][$defend_unit_id] <= 0)
585
+  if ($defend_fleet_data[UBE_COUNT][$defend_unit_id] <= 0)
586 586
   {
587 587
     return;
588 588
   }
@@ -625,16 +625,16 @@  discard block
 block discarded – undo
625 625
 
626 626
   $outcome = array();
627 627
   $next_round_fleet = array();
628
-  foreach($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data)
628
+  foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data)
629 629
   {
630
-    if(array_sum($fleet_data[UBE_COUNT]) <= 0)
630
+    if (array_sum($fleet_data[UBE_COUNT]) <= 0)
631 631
     {
632 632
       continue;
633 633
     }
634 634
 
635
-    foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
635
+    foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
636 636
     {
637
-      if($unit_count <= 0)
637
+      if ($unit_count <= 0)
638 638
       {
639 639
         continue;
640 640
       }
@@ -646,17 +646,17 @@  discard block
 block discarded – undo
646 646
   }
647 647
 
648 648
   // Проверяем - если кого-то не осталось или не осталось обоих - заканчиваем цикл
649
-  if(count($outcome) == 0 || $round == 10)
649
+  if (count($outcome) == 0 || $round == 10)
650 650
   {
651 651
     $round_data[UBE_OUTCOME] = UBE_COMBAT_RESULT_DRAW_END;
652 652
   }
653
-  elseif(count($outcome) == 1)
653
+  elseif (count($outcome) == 1)
654 654
   {
655 655
     $round_data[UBE_OUTCOME] = isset($outcome[UBE_ATTACKERS]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS;
656 656
   }
657
-  elseif(count($outcome) == 2)
657
+  elseif (count($outcome) == 2)
658 658
   {
659
-    if($round < 10)
659
+    if ($round < 10)
660 660
     {
661 661
       $combat_data[UBE_ROUNDS][$round + 1][UBE_FLEETS] = $next_round_fleet;
662 662
     }
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
   $start = microtime(true);
675 675
   sn_ube_combat_prepare_first_round($combat_data);
676 676
 
677
-  for($round = 1; $round <= 10; $round++)
677
+  for ($round = 1; $round <= 10; $round++)
678 678
   {
679 679
     // Готовим данные для раунда
680 680
     sn_ube_combat_round_prepare($combat_data, $round);
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
     sn_ube_combat_round_crossfire_fleet($combat_data, $round);
684 684
 
685 685
     // Анализируем итоги текущего раунда и готовим данные для следующего
686
-    if(sn_ube_combat_round_analyze($combat_data, $round) != UBE_COMBAT_RESULT_DRAW)
686
+    if (sn_ube_combat_round_analyze($combat_data, $round) != UBE_COMBAT_RESULT_DRAW)
687 687
     {
688 688
       break;
689 689
     }
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
   $combat_data[UBE_OPTIONS][UBE_EXCHANGE] = array(RES_METAL => $config->rpg_exchange_metal);
705 705
 
706 706
   $exchange = &$combat_data[UBE_OPTIONS][UBE_EXCHANGE];
707
-  foreach(array(RES_CRYSTAL => 'rpg_exchange_crystal', RES_DEUTERIUM => 'rpg_exchange_deuterium', RES_DARK_MATTER => 'rpg_exchange_darkMatter') as $resource_id => $resource_name)
707
+  foreach (array(RES_CRYSTAL => 'rpg_exchange_crystal', RES_DEUTERIUM => 'rpg_exchange_deuterium', RES_DARK_MATTER => 'rpg_exchange_darkMatter') as $resource_id => $resource_name)
708 708
   {
709 709
     $exchange[$resource_id] = $config->$resource_name * $exchange[RES_METAL];
710 710
   }
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
   $outcome[UBE_DEBRIS] = array();
719 719
 
720 720
   // Генерируем результат боя
721
-  foreach($fleets_info as $fleet_id => &$fleet_info)
721
+  foreach ($fleets_info as $fleet_id => &$fleet_info)
722 722
   {
723 723
     $fleet_type = $fleet_info[UBE_FLEET_TYPE];
724 724
     // Инициализируем массив результатов для флота
@@ -729,32 +729,32 @@  discard block
 block discarded – undo
729 729
     $fleet_outcome = &$outcome[UBE_FLEETS][$fleet_id];
730 730
     $fleet_data = &$last_round_data[UBE_FLEETS][$fleet_id];
731 731
 
732
-    foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
732
+    foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
733 733
     {
734 734
       // Вычисляем сколько юнитов осталось и сколько потеряно
735 735
       $units_left = $fleet_data[UBE_COUNT][$unit_id];
736 736
 
737 737
       // Восстановление обороны - 75% от уничтоженной
738
-      if($fleet_info[UBE_TYPE][$unit_id] == UNIT_DEFENCE)
738
+      if ($fleet_info[UBE_TYPE][$unit_id] == UNIT_DEFENCE)
739 739
       {
740 740
         $giveback_chance = 75; // TODO Configure
741 741
         $units_lost = $unit_count - $units_left;
742
-        if($combat_data[UBE_OPTIONS][UBE_SIMULATOR])
742
+        if ($combat_data[UBE_OPTIONS][UBE_SIMULATOR])
743 743
         { // for simulation just return 75% of loss
744 744
           $units_giveback = round($units_lost * $giveback_chance / 100);
745 745
         }
746 746
         else
747 747
         {
748
-          if($unit_count > 10)
748
+          if ($unit_count > 10)
749 749
           { // if there were more then 10 defense elements - mass-calculating giveback
750 750
             $units_giveback = round($units_lost * mt_rand($giveback_chance * 0.8, $giveback_chance * 1.2) / 100);
751 751
           }
752 752
           else
753 753
           { //if there were less then 10 defense elements - calculating giveback per element
754 754
             $units_giveback = 0;
755
-            for($i = 1; $i <= $units_lost; $i++)
755
+            for ($i = 1; $i <= $units_lost; $i++)
756 756
             {
757
-              if(mt_rand(1,100) <= $giveback_chance)
757
+              if (mt_rand(1, 100) <= $giveback_chance)
758 758
               {
759 759
                 $units_giveback++;
760 760
               }
@@ -773,13 +773,13 @@  discard block
 block discarded – undo
773 773
       $outcome[$fleet_type][UBE_CAPACITY][$fleet_id] += $fleet_info[UBE_CAPACITY][$unit_id] * $units_left;
774 774
 
775 775
       // Вычисляем потери в ресурсах
776
-      if($units_lost)
776
+      if ($units_lost)
777 777
       {
778 778
         $fleet_outcome[UBE_UNITS_LOST][$unit_id] = $units_lost;
779 779
 
780
-        foreach($fleet_info[UBE_PRICE] as $resource_id => $unit_prices)
780
+        foreach ($fleet_info[UBE_PRICE] as $resource_id => $unit_prices)
781 781
         {
782
-          if(!$unit_prices[$unit_id])
782
+          if (!$unit_prices[$unit_id])
783 783
           {
784 784
             continue;
785 785
           }
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
           $fleet_outcome[UBE_RESOURCES_LOST][$resource_id] += $resources_lost;
790 790
 
791 791
           // Если это корабль - прибавляем потери к обломкам на орбите
792
-          if($fleet_info[UBE_TYPE][$unit_id] == UNIT_SHIPS)
792
+          if ($fleet_info[UBE_TYPE][$unit_id] == UNIT_SHIPS)
793 793
           {
794 794
             $outcome[UBE_DEBRIS][$resource_id] += floor($resources_lost * ($combat_data[UBE_OPTIONS][UBE_SIMULATOR] ? 30 : mt_rand(20, 40)) / 100); // TODO: Configurize
795 795
           }
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
     }
803 803
 
804 804
     // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются
805
-    if($fleet_id == 0)
805
+    if ($fleet_id == 0)
806 806
     {
807 807
       continue;
808 808
     }
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
     // Количество ресурсов флота
811 811
     $fleet_total_resources = empty($fleet_info[UBE_RESOURCES]) ? 0 : array_sum($fleet_info[UBE_RESOURCES]);
812 812
     // Если на борту нет ресурсов - зачем нам все это?
813
-    if($fleet_total_resources == 0)
813
+    if ($fleet_total_resources == 0)
814 814
     {
815 815
       continue;
816 816
     }
@@ -818,13 +818,13 @@  discard block
 block discarded – undo
818 818
     // Емкость трюмов флота
819 819
     $fleet_capacity = $outcome[$fleet_type][UBE_CAPACITY][$fleet_id];
820 820
     // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй
821
-    if($fleet_capacity < $fleet_total_resources)
821
+    if ($fleet_capacity < $fleet_total_resources)
822 822
     {
823 823
       $left_percent = $fleet_capacity / $fleet_total_resources; // Сколько ресурсов будет оставлено
824
-      foreach($fleet_info[UBE_RESOURCES] as $resource_id => $resource_amount)
824
+      foreach ($fleet_info[UBE_RESOURCES] as $resource_id => $resource_amount)
825 825
       {
826 826
         // Не просчитываем ресурсы, которых нет на борту кораблей флота
827
-        if(!$resource_amount)
827
+        if (!$resource_amount)
828 828
         {
829 829
           continue;
830 830
         }
@@ -847,9 +847,9 @@  discard block
 block discarded – undo
847 847
   // SFR - Small Fleet Reconnaissance ака РМФ
848 848
   $outcome[UBE_SFR] = count($combat_data[UBE_ROUNDS]) == 2 && $outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_LOSS;
849 849
 
850
-  if(!$combat_data[UBE_OPTIONS][UBE_LOADED])
850
+  if (!$combat_data[UBE_OPTIONS][UBE_LOADED])
851 851
   {
852
-    if($combat_data[UBE_OPTIONS][UBE_MOON_WAS])
852
+    if ($combat_data[UBE_OPTIONS][UBE_MOON_WAS])
853 853
     {
854 854
       $outcome[UBE_MOON] = UBE_MOON_WAS;
855 855
     }
@@ -859,10 +859,10 @@  discard block
 block discarded – undo
859 859
     }
860 860
 
861 861
     // Лутаем ресурсы - если аттакер выиграл
862
-    if($outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_WIN)
862
+    if ($outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_WIN)
863 863
     {
864 864
       sn_ube_combat_analyze_loot($combat_data);
865
-      if($combat_data[UBE_OPTIONS][UBE_MOON_WAS] && $combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY)
865
+      if ($combat_data[UBE_OPTIONS][UBE_MOON_WAS] && $combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY)
866 866
       {
867 867
         sn_ube_combat_analyze_moon_destroy($combat_data);
868 868
       }
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
   $planet_looted_in_metal = 0;
882 882
   $planet_resource_looted = array();
883 883
   $planet_resource_total = is_array($planet_resource_list) ? array_sum($planet_resource_list) : 0;
884
-  if($planet_resource_total && ($total_capacity = array_sum($outcome[UBE_ATTACKERS][UBE_CAPACITY])))
884
+  if ($planet_resource_total && ($total_capacity = array_sum($outcome[UBE_ATTACKERS][UBE_CAPACITY])))
885 885
   {
886 886
     // Можно вывести только половину ресурсов, но не больше, чем общая вместимость флотов атакующих
887 887
     $planet_lootable = min($planet_resource_total / 2, $total_capacity);
@@ -892,11 +892,11 @@  discard block
 block discarded – undo
892 892
     $total_lootable = min($planet_lootable, $total_capacity);
893 893
 
894 894
     // Вычисляем сколько ресурсов вывезено
895
-    foreach($outcome[UBE_ATTACKERS][UBE_CAPACITY] as $fleet_id => $fleet_capacity)
895
+    foreach ($outcome[UBE_ATTACKERS][UBE_CAPACITY] as $fleet_id => $fleet_capacity)
896 896
     {
897 897
       $looted_in_metal = 0;
898 898
       $fleet_loot_data = array();
899
-      foreach($planet_resource_list as $resource_id => $resource_amount)
899
+      foreach ($planet_resource_list as $resource_id => $resource_amount)
900 900
       {
901 901
         // TODO Восстанавливаем ошибку округления - придумать нормальный алгоритм - вроде round() должно быть достаточно. Проверить
902 902
         $fleet_lootable_percent = $fleet_capacity / $total_capacity;
@@ -919,25 +919,25 @@  discard block
 block discarded – undo
919 919
 function sn_ube_combat_analyze_moon(&$outcome, $is_simulator)
920 920
 {
921 921
   $outcome[UBE_DEBRIS_TOTAL] = 0;
922
-  foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array
922
+  foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array
923 923
   {
924 924
     $outcome[UBE_DEBRIS_TOTAL] += $outcome[UBE_DEBRIS][$resource_id];
925 925
   }
926 926
 
927
-  if($outcome[UBE_DEBRIS_TOTAL])
927
+  if ($outcome[UBE_DEBRIS_TOTAL])
928 928
   {
929 929
     // TODO uni_calculate_moon_chance
930 930
     $moon_chance = min($outcome[UBE_DEBRIS_TOTAL] / 1000000, 30); // TODO Configure
931 931
     $moon_chance = $moon_chance >= 1 ? $moon_chance : 0;
932 932
     $outcome[UBE_MOON_CHANCE] = $moon_chance;
933
-    if($moon_chance)
933
+    if ($moon_chance)
934 934
     {
935
-      if($is_simulator || mt_rand(1, 100) <= $moon_chance)
935
+      if ($is_simulator || mt_rand(1, 100) <= $moon_chance)
936 936
       {
937 937
         $outcome[UBE_MOON_SIZE] = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999));
938 938
         $outcome[UBE_MOON] = UBE_MOON_CREATE_SUCCESS;
939 939
 
940
-        if($outcome[UBE_DEBRIS_TOTAL] <= 30000000)
940
+        if ($outcome[UBE_DEBRIS_TOTAL] <= 30000000)
941 941
         {
942 942
           $outcome[UBE_DEBRIS_TOTAL] = 0;
943 943
           $outcome[UBE_DEBRIS] = array();
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
           $moon_debris_left_percent = ($outcome[UBE_DEBRIS_TOTAL] - $moon_debris_spent) / $outcome[UBE_DEBRIS_TOTAL];
949 949
 
950 950
           $outcome[UBE_DEBRIS_TOTAL] = 0;
951
-          foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array
951
+          foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) // TODO via array
952 952
           {
953 953
             $outcome[UBE_DEBRIS][$resource_id] = floor($outcome[UBE_DEBRIS][$resource_id] * $moon_debris_left_percent);
954 954
             $outcome[UBE_DEBRIS_TOTAL] += $outcome[UBE_DEBRIS][$resource_id];
@@ -972,11 +972,11 @@  discard block
 block discarded – undo
972 972
 {
973 973
   // TODO: $is_simulator
974 974
   $reapers = 0;
975
-  foreach($combat_data[UBE_ROUNDS][count($combat_data[UBE_ROUNDS])-1][UBE_FLEETS] as $fleet_data)
975
+  foreach ($combat_data[UBE_ROUNDS][count($combat_data[UBE_ROUNDS]) - 1][UBE_FLEETS] as $fleet_data)
976 976
   {
977
-    if($fleet_data[UBE_FLEET_INFO][UBE_FLEET_TYPE] == UBE_ATTACKERS)
977
+    if ($fleet_data[UBE_FLEET_INFO][UBE_FLEET_TYPE] == UBE_ATTACKERS)
978 978
     {
979
-      foreach($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
979
+      foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count)
980 980
       {
981 981
         // TODO: Работа по группам - группа "Уничтожители лун"
982 982
         $reapers += ($unit_id == SHIP_HUGE_DEATH_STAR) ? $unit_count : 0;
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
   }
986 986
 
987 987
   $moon_size = $combat_data[UBE_OUTCOME][UBE_PLANET][PLANET_SIZE];
988
-  if($reapers)
988
+  if ($reapers)
989 989
   {
990 990
     $random = mt_rand(1, 100);
991 991
     $combat_data[UBE_OUTCOME][UBE_MOON_DESTROY_CHANCE] = max(1, min(99, round((100 - sqrt($moon_size)) * sqrt($reapers))));
@@ -1019,38 +1019,37 @@  discard block
 block discarded – undo
1019 1019
     $planet_info[PLANET_SYSTEM],
1020 1020
     $planet_info[PLANET_PLANET],
1021 1021
     htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'),
1022
-    $lang[$outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' :
1023
-      ($outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')
1022
+    $lang[$outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')
1024 1023
     ]
1025 1024
   );
1026 1025
 
1027 1026
   $text_defender = '';
1028
-  foreach($outcome[UBE_DEBRIS] as $resource_id => $resource_amount)
1027
+  foreach ($outcome[UBE_DEBRIS] as $resource_id => $resource_amount)
1029 1028
   {
1030
-    if($resource_id == RES_DEUTERIUM)
1029
+    if ($resource_id == RES_DEUTERIUM)
1031 1030
     {
1032 1031
       continue;
1033 1032
     }
1034 1033
 
1035 1034
     $text_defender .= "{$lang['tech'][$resource_id]}: " . HelperString::numberFloorAndFormat($resource_amount) . '<br />';
1036 1035
   }
1037
-  if($text_defender)
1036
+  if ($text_defender)
1038 1037
   {
1039 1038
     $text_defender = "{$lang['ube_report_msg_body_debris']}{$text_defender}<br />";
1040 1039
   }
1041 1040
 
1042
-  if($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS)
1041
+  if ($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS)
1043 1042
   {
1044 1043
     $text_defender .= "{$lang['ube_report_moon_created']} {$outcome[UBE_MOON_SIZE]} {$lang['sys_kilometers_short']}<br /><br />";
1045 1044
   }
1046
-  elseif($outcome[UBE_MOON] == UBE_MOON_CREATE_FAILED)
1045
+  elseif ($outcome[UBE_MOON] == UBE_MOON_CREATE_FAILED)
1047 1046
   {
1048 1047
     $text_defender .= "{$lang['ube_report_moon_chance']} {$outcome[UBE_MOON_CHANCE]}%<br /><br />";
1049 1048
   }
1050 1049
 
1051
-  if($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY)
1050
+  if ($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_DESTROY)
1052 1051
   {
1053
-    if($outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_NONE)
1052
+    if ($outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_NONE)
1054 1053
     {
1055 1054
       $text_defender .= $lang['ube_report_moon_reapers_none'];
1056 1055
     }
@@ -1068,7 +1067,7 @@  discard block
 block discarded – undo
1068 1067
   $text_defender .= "{$lang['ube_report_info_link']}: <a href=\"index.php?page=battle_report&cypher={$combat_data[UBE_REPORT_CYPHER]}\">{$combat_data[UBE_REPORT_CYPHER]}</a>";
1069 1068
 
1070 1069
   // TODO: Оптимизировать отсылку сообщений - отсылать пакетами
1071
-  foreach($combat_data[UBE_PLAYERS] as $player_id => $player_info)
1070
+  foreach ($combat_data[UBE_PLAYERS] as $player_id => $player_info)
1072 1071
   {
1073 1072
     $message = $text_common . ($outcome[UBE_SFR] && $player_info[UBE_ATTACKER] ? $lang['ube_report_msg_body_sfr'] : $text_defender);
1074 1073
     msg_send_simple_message($player_id, '', $combat_data[UBE_TIME], MSG_TYPE_COMBAT, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $message);
@@ -1080,7 +1079,7 @@  discard block
 block discarded – undo
1080 1079
 // ------------------------------------------------------------------------------------------------
1081 1080
 // Записывает результат боя в БД
1082 1081
 /** @noinspection SpellCheckingInspection */
1083
-function ube_combat_result_apply(&$combat_data){return sn_function_call('ube_combat_result_apply', array(&$combat_data));}
1082
+function ube_combat_result_apply(&$combat_data) {return sn_function_call('ube_combat_result_apply', array(&$combat_data)); }
1084 1083
 function sn_ube_combat_result_apply(&$combat_data)
1085 1084
 {
1086 1085
 // TODO: Поменять все отладки на запросы
@@ -1090,7 +1089,7 @@  discard block
 block discarded – undo
1090 1089
   $planet_info = &$outcome[UBE_PLANET];
1091 1090
   $planet_id = $planet_info[PLANET_ID];
1092 1091
   // Обновляем поле обломков на планете
1093
-  if(!$combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] && !empty($outcome[UBE_DEBRIS]))
1092
+  if (!$combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] && !empty($outcome[UBE_DEBRIS]))
1094 1093
   {
1095 1094
     DBStaticPlanet::db_planet_set_by_gspt($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], PT_PLANET,
1096 1095
       "`debris_metal` = `debris_metal` + " . floor($outcome[UBE_DEBRIS][RES_METAL]) . ", `debris_crystal` = `debris_crystal` + " . floor($outcome[UBE_DEBRIS][RES_CRYSTAL])
@@ -1102,9 +1101,9 @@  discard block
 block discarded – undo
1102 1101
   );
1103 1102
 
1104 1103
   $fleets_outcome = &$outcome[UBE_FLEETS];
1105
-  foreach($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info)
1104
+  foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info)
1106 1105
   {
1107
-    if($fleet_info[UBE_FLEET_GROUP])
1106
+    if ($fleet_info[UBE_FLEET_GROUP])
1108 1107
     {
1109 1108
       $db_save[UBE_FLEET_GROUP][$fleet_info[UBE_FLEET_GROUP]] = $fleet_info[UBE_FLEET_GROUP];
1110 1109
     }
@@ -1117,28 +1116,28 @@  discard block
 block discarded – undo
1117 1116
     $old_fleet_count = array_sum($fleet_info[UBE_COUNT]);
1118 1117
     $new_fleet_count = $old_fleet_count - array_sum($fleets_outcome[$fleet_id][UBE_UNITS_LOST]);
1119 1118
     // Перебираем юниты если во время боя количество юнитов изменилось и при этом во флоту остались юниты или это планета
1120
-    if($new_fleet_count != $old_fleet_count && (!$fleet_id || $new_fleet_count))
1119
+    if ($new_fleet_count != $old_fleet_count && (!$fleet_id || $new_fleet_count))
1121 1120
     {
1122 1121
       // Просматриваем результаты изменения флотов
1123
-      foreach($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
1122
+      foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count)
1124 1123
       {
1125 1124
         // Перебираем аутком на случай восстановления юнитов
1126
-        $units_lost = (float)$fleets_outcome[$fleet_id][UBE_UNITS_LOST][$unit_id];
1125
+        $units_lost = (float) $fleets_outcome[$fleet_id][UBE_UNITS_LOST][$unit_id];
1127 1126
 
1128 1127
         $units_left = $unit_count - $units_lost;
1129
-        if($fleet_id)
1128
+        if ($fleet_id)
1130 1129
         {
1131 1130
           // Не планета - всегда сразу записываем строку итогов флота
1132 1131
           $fleet_query[$unit_id] = "{$unit_id},{$units_left}";
1133 1132
         }
1134
-        elseif($units_lost)
1133
+        elseif ($units_lost)
1135 1134
         {
1136 1135
           // Планета - записываем в ИД юнита его потери только если есть потери
1137 1136
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, -$units_lost, $combat_data[UBE_PLAYERS][$destination_user_id][UBE_PLAYER_DATA], $planet_id);
1138 1137
         }
1139 1138
       }
1140 1139
 
1141
-      if($fleet_id)
1140
+      if ($fleet_id)
1142 1141
       {
1143 1142
         // Для флотов перегенерируем массив как одно вхождение в SET SQL-запроса
1144 1143
         $fleet_query = array(
@@ -1149,12 +1148,12 @@  discard block
 block discarded – undo
1149 1148
 
1150 1149
     $fleet_delta = array();
1151 1150
     // Если во флоте остались юниты или это планета - генерируем изменение ресурсов
1152
-    if($new_fleet_count || !$fleet_id)
1151
+    if ($new_fleet_count || !$fleet_id)
1153 1152
     {
1154
-      foreach(sn_get_groups('resources_loot') as $resource_id)
1153
+      foreach (sn_get_groups('resources_loot') as $resource_id)
1155 1154
       {
1156
-        $resource_change = (float)$fleets_outcome[$fleet_id][UBE_RESOURCES_LOOTED][$resource_id] + (float)$fleets_outcome[$fleet_id][UBE_CARGO_DROPPED][$resource_id];
1157
-        if($resource_change)
1155
+        $resource_change = (float) $fleets_outcome[$fleet_id][UBE_RESOURCES_LOOTED][$resource_id] + (float) $fleets_outcome[$fleet_id][UBE_CARGO_DROPPED][$resource_id];
1156
+        if ($resource_change)
1158 1157
         {
1159 1158
           $resource_db_name = ($fleet_id ? 'fleet_resource_' : '') . pname_resource_name($resource_id);
1160 1159
 //          $fleet_query[] = "`{$resource_db_name}` = `{$resource_db_name}` - ({$resource_change})";
@@ -1168,10 +1167,10 @@  discard block
 block discarded – undo
1168 1167
           continue;
1169 1168
         }
1170 1169
     */
1171
-    if($fleet_id && $new_fleet_count)
1170
+    if ($fleet_id && $new_fleet_count)
1172 1171
     {
1173 1172
       // Если защитник и не РМФ - отправляем флот назад
1174
-      if(($fleet_info[UBE_FLEET_TYPE] == UBE_DEFENDERS && !$outcome[UBE_SFR]) || $fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS)
1173
+      if (($fleet_info[UBE_FLEET_TYPE] == UBE_DEFENDERS && !$outcome[UBE_SFR]) || $fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS)
1175 1174
       {
1176 1175
 //        $fleet_query[] = '`fleet_mess` = 1';
1177 1176
         $fleet_query['fleet_mess'] = 1;
@@ -1186,16 +1185,16 @@  discard block
 block discarded – undo
1186 1185
 
1187 1186
 //global $debug;
1188 1187
 //    $fleet_query = implode(',', $fleet_query);
1189
-    if($fleet_id) // Не планета
1188
+    if ($fleet_id) // Не планета
1190 1189
     {
1191
-      if($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED)
1190
+      if ($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED)
1192 1191
       {
1193 1192
         $new_fleet_count = 0;
1194 1193
       }
1195 1194
 
1196
-      if($new_fleet_count)
1195
+      if ($new_fleet_count)
1197 1196
       {
1198
-        if(!empty($fleet_query) || !empty($fleet_delta))
1197
+        if (!empty($fleet_query) || !empty($fleet_delta))
1199 1198
         {
1200 1199
 //          doquery("UPDATE {{fleets}} SET {$fleet_query}, `fleet_amount` = '{$new_fleet_count}' WHERE `fleet_id` = {$fleet_id} LIMIT 1");
1201 1200
 //          db_fleet_update_set_safe_string($fleet_id, "{$fleet_query}, `fleet_amount` = '{$new_fleet_count}'");
@@ -1214,15 +1213,15 @@  discard block
 block discarded – undo
1214 1213
     else // Планета
1215 1214
     {
1216 1215
       // Сохраняем изменения ресурсов - если они есть
1217
-      if(!empty($fleet_delta))
1216
+      if (!empty($fleet_delta))
1218 1217
       {
1219 1218
         $temp = array();
1220
-        foreach($fleet_delta as $resource_db_name => $resource_amount) {
1219
+        foreach ($fleet_delta as $resource_db_name => $resource_amount) {
1221 1220
           $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})";
1222 1221
         }
1223 1222
         DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $temp));
1224 1223
       }
1225
-      if(!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть
1224
+      if (!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть
1226 1225
       {
1227 1226
         OldDbChangeSet::db_changeset_apply($db_changeset);
1228 1227
       }
@@ -1231,34 +1230,34 @@  discard block
 block discarded – undo
1231 1230
 
1232 1231
   // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL
1233 1232
   // $db_save[UBE_FLEET_GROUP][$fleet_info[UBE_FLEET_GROUP]] = $fleet_info[UBE_FLEET_GROUP];
1234
-  if(!empty($db_save[UBE_FLEET_GROUP]))
1233
+  if (!empty($db_save[UBE_FLEET_GROUP]))
1235 1234
   {
1236 1235
     $db_save[UBE_FLEET_GROUP] = implode(',', $db_save[UBE_FLEET_GROUP]);
1237 1236
     doquery("DELETE FROM {{aks}} WHERE `id` IN ({$db_save[UBE_FLEET_GROUP]})");
1238 1237
   }
1239 1238
 
1240
-  if($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS)
1239
+  if ($outcome[UBE_MOON] == UBE_MOON_CREATE_SUCCESS)
1241 1240
   {
1242 1241
     $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $outcome[UBE_MOON_SIZE], '', false);
1243 1242
     $outcome[UBE_MOON_NAME] = $moon_row['name'];
1244 1243
     unset($moon_row);
1245 1244
   }
1246
-  elseif($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS)
1245
+  elseif ($outcome[UBE_MOON] == UBE_MOON_DESTROY_SUCCESS)
1247 1246
   {
1248 1247
     DBStaticPlanet::db_planet_delete_by_id($planet_id);
1249 1248
   }
1250 1249
 
1251 1250
   {
1252 1251
     $bashing_list = array();
1253
-    foreach($combat_data[UBE_PLAYERS] as $player_id => $player_info)
1252
+    foreach ($combat_data[UBE_PLAYERS] as $player_id => $player_info)
1254 1253
     {
1255
-      if($player_info[UBE_ATTACKER])
1254
+      if ($player_info[UBE_ATTACKER])
1256 1255
       {
1257
-        if($outcome[UBE_MOON] != UBE_MOON_DESTROY_SUCCESS)
1256
+        if ($outcome[UBE_MOON] != UBE_MOON_DESTROY_SUCCESS)
1258 1257
         {
1259 1258
           $bashing_list[] = "({$player_id}, {$planet_id}, {$combat_data[UBE_TIME]})";
1260 1259
         }
1261
-        if($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_ATTACK && $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE])
1260
+        if ($combat_data[UBE_OPTIONS][UBE_MISSION_TYPE] == MT_ATTACK && $combat_data[UBE_OPTIONS][UBE_DEFENDER_ACTIVE])
1262 1261
         {
1263 1262
           $str_loose_or_win = $outcome[UBE_COMBAT_RESULT] == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose';
1264 1263
           db_user_set_by_id($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1");
@@ -1266,7 +1265,7 @@  discard block
 block discarded – undo
1266 1265
       }
1267 1266
     }
1268 1267
     $bashing_list = implode(',', $bashing_list);
1269
-    if($bashing_list)
1268
+    if ($bashing_list)
1270 1269
     {
1271 1270
       doquery("INSERT INTO {{bashing}} (bashing_user_id, bashing_planet_id, bashing_time) VALUES {$bashing_list};");
1272 1271
     }
Please login to merge, or discard this patch.
includes/includes/art_artifact.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 {
5 5
   global $lang;
6 6
 
7
-  if(!in_array($unit_id, sn_get_groups('artifacts')))
7
+  if (!in_array($unit_id, sn_get_groups('artifacts')))
8 8
   {
9 9
     return;
10 10
   }
@@ -13,24 +13,24 @@  discard block
 block discarded – undo
13 13
   $user = db_user_by_id($user['id'], true);
14 14
 
15 15
   $unit_level = $artifact_level_old = mrc_get_level($user, array(), $unit_id, true);
16
-  if($unit_level > 0)
16
+  if ($unit_level > 0)
17 17
   {
18 18
     $db_changeset = array();
19
-    switch($unit_id)
19
+    switch ($unit_id)
20 20
     {
21 21
       case ART_LHC:
22 22
       case ART_HOOK_SMALL:
23 23
       case ART_HOOK_MEDIUM:
24 24
       case ART_HOOK_LARGE:
25 25
         $has_moon = DBStaticPlanet::db_planet_by_parent($planetrow['id'], true, '`id`');
26
-        if($planetrow['planet_type'] == PT_PLANET && !$has_moon['id'])
26
+        if ($planetrow['planet_type'] == PT_PLANET && !$has_moon['id'])
27 27
         {
28 28
           $unit_level--;
29 29
           $moon_chance = $unit_id == ART_LHC ? uni_calculate_moon_chance($planetrow['debris_metal'] + $planetrow['debris_crystal']) : (
30 30
             $unit_id == ART_HOOK_MEDIUM ? mt_rand(1100, 8999) : ($unit_id == ART_HOOK_SMALL ? 1100 : 8999)
31 31
           );
32 32
           $random = $unit_id == ART_LHC ? mt_rand(1, 100) : $moon_chance;
33
-          if($random <= $moon_chance)
33
+          if ($random <= $moon_chance)
34 34
           {
35 35
             $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moon_chance);
36 36
             $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moon_chance));
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
       case ART_RCD_MEDIUM:
52 52
       case ART_RCD_LARGE:
53 53
         $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
54
-        if($planetrow['planet_type'] != PT_PLANET)
54
+        if ($planetrow['planet_type'] != PT_PLANET)
55 55
         {
56 56
           $message = $lang['art_rcd_err_moon'];
57 57
           break;
58 58
         }
59 59
 
60 60
         $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, false);
61
-        if(!empty($que['items']))
61
+        if (!empty($que['items']))
62 62
         {
63 63
           $message = $lang['art_rcd_err_que'];
64 64
           break;
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
         $artifact_deploy = get_unit_param($unit_id, P_DEPLOY);
68 68
 
69 69
         $sectors_used = 0;
70
-        foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level)
70
+        foreach ($artifact_deploy as $deploy_unit_id => $deploy_unit_level)
71 71
         {
72
-          if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true))))
72
+          if (!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true))))
73 73
             continue;
74 74
           $sectors_used += $levels_deployed;
75 75
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']);
76 76
         }
77 77
 
78
-        if($sectors_used == 0)
78
+        if ($sectors_used == 0)
79 79
         {
80 80
           $message = $lang['art_rcd_err_no_sense'];
81 81
           break;
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
         $que_item = null;
91 91
         $que = que_get($user['id'], $planetrow['id'], QUE_RESEARCH, true);
92 92
         $current_que = &$que['ques'][QUE_RESEARCH][$user['id']][0];
93
-        if(!empty($current_que))
93
+        if (!empty($current_que))
94 94
         {
95 95
           reset($current_que);
96 96
           $que_item = &$que['ques'][QUE_RESEARCH][$user['id']][0][key($current_que)];
97 97
         }
98 98
 
99
-        if(!empty($que_item) && $que_item['que_time_left'] > 60)
99
+        if (!empty($que_item) && $que_item['que_time_left'] > 60)
100 100
         {
101 101
           $unit_level--;
102 102
           $old_time = $que_item['que_time_left'];
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
         $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, true);
118 118
         $current_que = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']];
119 119
         // $que_item = &$que['que'][QUE_STRUCTURES][0];
120
-        if(!empty($current_que))
120
+        if (!empty($current_que))
121 121
         {
122 122
           reset($current_que);
123 123
           $que_item = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']][key($current_que)];
124 124
         }
125 125
 
126
-        if(isset($que_item) && $que_item['que_time_left'] > 60)
126
+        if (isset($que_item) && $que_item['que_time_left'] > 60)
127 127
         {
128 128
           $unit_level--;
129 129
           $old_time = $que_item['que_time_left'];
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
       break;
142 142
 
143 143
     }
144
-    if($unit_level != $artifact_level_old)
144
+    if ($unit_level != $artifact_level_old)
145 145
     {
146 146
       $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user);
147 147
       OldDbChangeSet::db_changeset_apply($db_changeset);
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.
includes/includes/market_fleeter.inc 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
3
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
4 4
   $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
5 5
 }
6 6
 
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
   'rpg_cost' => $rpg_cost,
13 13
 ));
14 14
 
15
-if(is_array($shipList)) {
16
-  if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
15
+if (is_array($shipList)) {
16
+  if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
17 17
     $intError = MARKET_NO_DM;
18 18
   }
19 19
 
@@ -30,30 +30,30 @@  discard block
 block discarded – undo
30 30
   $qry = array();
31 31
   $total = array();
32 32
   $db_changeset = array();
33
-  foreach($shipList as $shipID => &$shipCount) {
33
+  foreach ($shipList as $shipID => &$shipCount) {
34 34
     $shipCount = ceil(floatval($shipCount));
35
-    if(!$shipCount) {
35
+    if (!$shipCount) {
36 36
       continue;
37 37
     }
38 38
 
39
-    if($shipCount < 0) {
39
+    if ($shipCount < 0) {
40 40
       $debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307);
41 41
       $intError = MARKET_NEGATIVE_SHIPS;
42 42
       break;
43 43
     }
44 44
 
45
-    if($mode == MARKET_SCRAPPER) {
45
+    if ($mode == MARKET_SCRAPPER) {
46 46
       $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)];
47
-    } elseif($mode == MARKET_STOCKMAN) {
47
+    } elseif ($mode == MARKET_STOCKMAN) {
48 48
       $amount = $stock[$shipID];
49 49
     }
50 50
 
51
-    if($amount < $shipCount) {
51
+    if ($amount < $shipCount) {
52 52
       $intError = $error_no_stock;
53 53
       break;
54 54
     }
55 55
 
56
-    if(!in_array($shipID, sn_get_groups('fleet'))) {
56
+    if (!in_array($shipID, sn_get_groups('fleet'))) {
57 57
       $debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306);
58 58
       $intError = MARKET_NOT_A_SHIP;
59 59
       break;
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
     $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier));
70 70
     $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier));
71 71
 
72
-    foreach($resTemp as $resID => $resCount) {
72
+    foreach ($resTemp as $resID => $resCount) {
73 73
       $total[$resID] += $resCount;
74 74
     }
75 75
 
76 76
     $message .= "<li>{$lang['tech'][$shipID]}: " . HelperString::numberFloorAndFormat($shipCount);
77 77
   }
78 78
 
79
-  if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
80
-    foreach($total as $resID => $resCount) {
81
-      if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
79
+  if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
80
+    foreach ($total as $resID => $resCount) {
81
+      if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
82 82
         $intError = MARKET_NO_RESOURCES;
83 83
         $debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301);
84 84
         break;
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 
89 89
   $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError;
90 90
 
91
-  if($intError == MARKET_DEAL) {
91
+  if ($intError == MARKET_DEAL) {
92 92
     $message .= '</ul>' . $lang["eco_mrk_{$submode}_res"] . '<ul>';
93
-    foreach($total as $resID => $resCount) {
94
-      if(!$resCount) {
93
+    foreach ($total as $resID => $resCount) {
94
+      if (!$resCount) {
95 95
         continue;
96 96
       }
97 97
 
@@ -125,38 +125,38 @@  discard block
 block discarded – undo
125 125
       'MESSAGE' => $lang['eco_mrk_errors'][$intError],
126 126
     ));
127 127
 
128
-    foreach($shipList as $shipID => $shipCount) {
128
+    foreach ($shipList as $shipID => $shipCount) {
129 129
       $data['ships'][$shipID] = max(0, intval($shipCount));
130 130
     }
131 131
   }
132 132
 }
133 133
 $message = '';
134 134
 
135
-if(!$config->eco_stockman_fleet && $config->eco_stockman_fleet_populate) {
136
-  $config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, sn_get_groups('fleet'))));
135
+if (!$config->eco_stockman_fleet && $config->eco_stockman_fleet_populate) {
136
+  $config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, sn_get_groups('fleet'))));
137 137
 }
138 138
 
139 139
 tpl_set_resource_info($template, $planetrow, array());
140 140
 
141
-if(!$array) {
141
+if (!$array) {
142 142
   $array = array();
143 143
 }
144 144
 
145 145
 $group_fleet = sn_get_groups('fleet');
146
-foreach($array as $key => $value) {
147
-  if($mode == MARKET_SCRAPPER) {
146
+foreach ($array as $key => $value) {
147
+  if ($mode == MARKET_SCRAPPER) {
148 148
     $shipID = $value;
149 149
     $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)];
150
-  } elseif($mode == MARKET_STOCKMAN) {
150
+  } elseif ($mode == MARKET_STOCKMAN) {
151 151
     $shipID = $key;
152 152
     $amount = $value;
153 153
   }
154 154
 
155
-  if(!in_array($shipID, $group_fleet)) {
155
+  if (!in_array($shipID, $group_fleet)) {
156 156
     continue;
157 157
   }
158 158
 
159
-  if($amount > 0) {
159
+  if ($amount > 0) {
160 160
     $build_data = eco_get_build_data($user, $planetrow, $shipID);
161 161
     $template->assign_block_vars('ships', array(
162 162
       'ID'        => $shipID,
Please login to merge, or discard this patch.
includes/includes/flt_page3.inc 1 patch
Spacing   +41 added lines, -42 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 // @version 1.0
4 4
 // @copyright 2008 by Chlorel for XNova
5 5
 
6
-if(SN_IN_FLEET !== true) {
6
+if (SN_IN_FLEET !== true) {
7 7
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
8 8
 }
9 9
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     $errorlist .= $lang['fl_limit_galaxy'];
23 23
   if (!$system || $system > $config->game_maxSystem || $system < 1)
24 24
     $errorlist .= $lang['fl_limit_system'];
25
-  if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE ))
25
+  if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE))
26 26
     $errorlist .= $lang['fl_limit_planet'];
27 27
   if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type)
28 28
     $errorlist .= $lang['fl_ownpl_err'];
@@ -49,35 +49,35 @@  discard block
 block discarded – undo
49 49
   $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
50 50
 
51 51
   if ($target_mission == MT_EXPLORE) {
52
-    if ($MaxExpeditions == 0 ) {
52
+    if ($MaxExpeditions == 0) {
53 53
       $errorlist .= $lang['fl_expe_notech'];
54
-    } elseif ($FlyingExpeditions >= $MaxExpeditions ) {
54
+    } elseif ($FlyingExpeditions >= $MaxExpeditions) {
55 55
       $errorlist .= $lang['fl_expe_max'];
56 56
     }
57 57
   } else {
58
-    if ($TargetPlanet['id_owner']){
58
+    if ($TargetPlanet['id_owner']) {
59 59
       if ($target_mission == MT_COLONIZE)
60 60
         $errorlist .= $lang['fl_colonized'];
61 61
 
62
-      if ($TargetPlanet['id_owner'] == $planetrow['id_owner']){
62
+      if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) {
63 63
         if ($target_mission == MT_ATTACK)
64 64
           $errorlist .= $lang['fl_no_self_attack'];
65 65
 
66 66
         if ($target_mission == MT_SPY)
67 67
           $errorlist .= $lang['fl_no_self_spy'];
68
-      }else{
68
+      } else {
69 69
         if ($target_mission == MT_RELOCATE)
70 70
           $errorlist .= $lang['fl_only_stay_at_home'];
71 71
       }
72
-    }else{
73
-      if ($target_mission < MT_COLONIZE){
72
+    } else {
73
+      if ($target_mission < MT_COLONIZE) {
74 74
         $errorlist .= $lang['fl_unknow_target'];
75
-      }else{
75
+      } else {
76 76
         if ($target_mission == MT_DESTROY)
77 77
           $errorlist .= $lang['fl_nomoon'];
78 78
 
79
-        if ($target_mission == MT_RECYCLE){
80
-          if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0)
79
+        if ($target_mission == MT_RECYCLE) {
80
+          if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0)
81 81
             $errorlist .= $lang['fl_nodebris'];
82 82
         }
83 83
       }
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
   }
86 86
 
87 87
 
88
-  if($sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) {
88
+  if ($sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) {
89 89
     $captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id']);
90 90
 //      mrc_get_level($user, $planetrow, UNIT_CAPTAIN, true);
91
-    if(!$captain) {
91
+    if (!$captain) {
92 92
       $errorlist .= $lang['module_unit_captain_error_no_captain'];
93
-    } elseif($captain['unit_location_type'] == LOC_PLANET) {
94
-      if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) {
93
+    } elseif ($captain['unit_location_type'] == LOC_PLANET) {
94
+      if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) {
95 95
         $errorlist .= $lang['module_unit_captain_error_captain_already_bound'];
96 96
       }
97 97
     } else {
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 
102 102
   if ($errorlist) {
103 103
     sn_db_transaction_rollback();
104
-    messageBox ("<span class='error'><ul>{$errorlist}</ul></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, false);
104
+    messageBox("<span class='error'><ul>{$errorlist}</ul></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, false);
105 105
   }
106 106
 
107 107
   // On verifie s'il y a assez de vaisseaux sur la planete !
108 108
   foreach ($fleetarray as $Ship => $Count) {
109 109
     if ($Count > mrc_get_level($user, $planetrow, $Ship)) {
110
-      messageBox ("<span class='error'><b>{$lang['fl_fleet_err']}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
110
+      messageBox("<span class='error'><b>{$lang['fl_fleet_err']}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
111 111
     }
112 112
   }
113 113
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
   $fleet_group = max(0, intval($_POST['fleet_group']));
116 116
   //But is it acs??
117 117
   //Well all acs fleets must have a fleet code.
118
-  if($fleet_group) {
118
+  if ($fleet_group) {
119 119
     //Also it must be mission type 2
120 120
     $target_mission = MT_AKS;
121 121
 
122 122
     //The co-ords must be the same as where the acs fleet is going.
123 123
     $target = "g{$galaxy}s{$system}p{$planet}t{$planet_type}";
124
-    if($_POST['acs_target_mr'] == $target) {
124
+    if ($_POST['acs_target_mr'] == $target) {
125 125
       //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!)
126 126
       $aks = doquery("SELECT * FROM {{aks}} WHERE id = '{$fleet_group}' LIMIT 1;", true);
127 127
       if (!$aks) {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     }
138 138
   }
139 139
   //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet.
140
-  if(!$fleet_group && $target_mission == MT_AKS) {
140
+  if (!$fleet_group && $target_mission == MT_AKS) {
141 141
     $target_mission = MT_ATTACK;
142 142
   }
143 143
 
@@ -147,22 +147,21 @@  discard block
 block discarded – undo
147 147
   $options = array('fleet_speed_percent' => $speed_percent, 'fleet_group' => $fleet_group, 'resources' => $StorageNeeded);
148 148
   $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options);
149 149
 
150
-  if($cant_attack !== ATTACK_ALLOWED) {
150
+  if ($cant_attack !== ATTACK_ALLOWED) {
151 151
     messageBox("<span class='error'><b>{$lang['fl_attack_error'][$cant_attack]}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 99);
152 152
   }
153 153
 
154 154
   $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
155 155
   if (!in_array($speed_percent, $speed_possible)) {
156
-    messageBox ("<span class='error'><b>". $lang['fl_cheat_speed'] ."</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
156
+    messageBox("<span class='error'><b>" . $lang['fl_cheat_speed'] . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
157 157
   }
158 158
 
159 159
   $fleet['start_time'] = $duration + SN_TIME_NOW;
160 160
 
161
-  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) :
162
-    ($target_mission == MT_HOLD ? 12 : 0);
163
-  if($max_duration) {
161
+  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0);
162
+  if ($max_duration) {
164 163
     $StayDuration = sys_get_param_id('missiontime');
165
-    if($StayDuration > $max_duration || $StayDuration < 1) {
164
+    if ($StayDuration > $max_duration || $StayDuration < 1) {
166 165
       $debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true));
167 166
       die();
168 167
     }
@@ -172,11 +171,11 @@  discard block
 block discarded – undo
172 171
     $StayDuration = 0;
173 172
     $StayTime     = 0;
174 173
   }
175
-  $fleet['end_time']   = $StayDuration + (2 * $duration) + SN_TIME_NOW;
174
+  $fleet['end_time'] = $StayDuration + (2 * $duration) + SN_TIME_NOW;
176 175
 
177
-  if($aks && $target_mission == MT_AKS) {
178
-    if ($fleet['start_time']>$aks['ankunft']) {
179
-      messageBox ($lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME,$fleet['start_time']) . " AKS arrival: " .date(FMT_DATE_TIME,$aks['ankunft']), $lang['fl_error']);
176
+  if ($aks && $target_mission == MT_AKS) {
177
+    if ($fleet['start_time'] > $aks['ankunft']) {
178
+      messageBox($lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $fleet['start_time']) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), $lang['fl_error']);
180 179
     }
181 180
     $fleet['start_time'] = $aks['ankunft'];
182 181
     $fleet['end_time'] = $aks['ankunft'] + $duration;
@@ -186,21 +185,21 @@  discard block
 block discarded – undo
186 185
   $FleetShipCount      = 0;
187 186
   $db_changeset = array();
188 187
   foreach ($fleetarray as $Ship => $Count) {
189
-    $FleetStorage    += get_unit_param($Ship, P_CAPACITY) * $Count;
188
+    $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count;
190 189
     $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($Ship, -$Count, $user, $planetrow['id']);
191 190
   }
192 191
   $fleet_array = sys_unit_arr2str($fleetarray);
193
-  $FleetShipCount  += array_sum($fleetarray);
194
-  $FleetStorage        -= $consumption;
192
+  $FleetShipCount += array_sum($fleetarray);
193
+  $FleetStorage -= $consumption;
195 194
 
196
-  if ( $StorageNeeded > $FleetStorage) {
197
-    messageBox ("<span class='error'><b>". $lang['fl_nostoragespa'] . HelperString::numberFloorAndFormat($StorageNeeded - $FleetStorage) ."</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
195
+  if ($StorageNeeded > $FleetStorage) {
196
+    messageBox("<span class='error'><b>" . $lang['fl_nostoragespa'] . HelperString::numberFloorAndFormat($StorageNeeded - $FleetStorage) . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
198 197
   }
199 198
   if ($planetrow['deuterium'] < $TransDeuterium + $consumption) {
200
-    messageBox ("<font color=\"red\"><b>". $lang['fl_no_deuterium'] . HelperString::numberFloorAndFormat($TransDeuterium + $consumption - $planetrow['deuterium']) ."</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
199
+    messageBox("<font color=\"red\"><b>" . $lang['fl_no_deuterium'] . HelperString::numberFloorAndFormat($TransDeuterium + $consumption - $planetrow['deuterium']) . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
201 200
   }
202 201
   if (($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) {
203
-    messageBox ("<font color=\"red\"><b>". $lang['fl_no_resources'] ."</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
202
+    messageBox("<font color=\"red\"><b>" . $lang['fl_no_resources'] . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
204 203
   }
205 204
 
206 205
   $fleet_set = array(
@@ -242,7 +241,7 @@  discard block
 block discarded – undo
242 241
 //    ));
243 242
 //  }
244 243
 
245
-  if(is_array($captain)) {
244
+  if (is_array($captain)) {
246 245
     DBStaticUnit::db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$fleet_id}");
247 246
   }
248 247
 
@@ -255,7 +254,7 @@  discard block
 block discarded – undo
255 254
     'START_LEFT'         => floor($fleet['end_time'] + 1 - SN_TIME_NOW),
256 255
   );
257 256
 
258
-  if(!empty($TargetPlanet)) {
257
+  if (!empty($TargetPlanet)) {
259 258
     $template_route += array(
260 259
       'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
261 260
       'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -268,8 +267,8 @@  discard block
 block discarded – undo
268 267
   $template->assign_block_vars('fleets', $template_route);
269 268
 
270 269
   $sn_groups_fleet = sn_get_groups('fleet');
271
-  foreach($fleetarray as $ship_id => $ship_count) {
272
-    if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
270
+  foreach ($fleetarray as $ship_id => $ship_count) {
271
+    if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
273 272
 //      $ship_base_data = get_ship_data($ship_id, $user);
274 273
       $template->assign_block_vars('fleets.ships', array(
275 274
         'ID'          => $ship_id,
Please login to merge, or discard this patch.