Completed
Push — trunk ( 09520e...7ac6b6 )
by SuperNova.WS
03:48
created
includes/functions/msg_send_simple_message.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
27 27
     false, 'id, username');
28 28
   // while ($u = db_fetch($query))
29
-  foreach($query as $u)
29
+  foreach ($query as $u)
30 30
   {
31 31
     $sendList[] = $u['id'];
32 32
     $list .= "<br>{$u['username']} ";
@@ -53,19 +53,19 @@  discard block
 block discarded – undo
53 53
 {
54 54
   global $config, $user, $sn_message_class_list;
55 55
 
56
-  if(!$owners)
56
+  if (!$owners)
57 57
   {
58 58
     return;
59 59
   }
60 60
 
61 61
   $timestamp = $timestamp ? $timestamp : SN_TIME_NOW;
62 62
   $sender = intval($sender);
63
-  if(!is_array($owners))
63
+  if (!is_array($owners))
64 64
   {
65 65
     $owners = array($owners);
66 66
   }
67 67
 
68
-  if($escaped == STRING_NEED_ESCAPING)
68
+  if ($escaped == STRING_NEED_ESCAPING)
69 69
   {
70 70
     $from = db_escape($from);
71 71
     $subject = db_escape($subject);
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 
82 82
   $message_class_name_total = $sn_message_class_list[MSG_TYPE_NEW]['name'];
83 83
 
84
-  if($owners[0] == '*')
84
+  if ($owners[0] == '*')
85 85
   {
86
-    if($user['authlevel'] < 3)
86
+    if ($user['authlevel'] < 3)
87 87
     {
88 88
       return false;
89 89
     }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
     foreach ($owners as $owner)
101 101
     {
102
-      if($user['id'] != $owner)
102
+      if ($user['id'] != $owner)
103 103
       {
104 104
         $owner_row = db_user_by_id($owner);
105 105
       }
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
       }
110 110
       sys_user_options_unpack($owner_row);
111 111
 
112
-      if($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"])
112
+      if ($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"])
113 113
       {
114 114
         $insert_values[] = sprintf($insert_template, $owner);
115 115
       }
116 116
 
117
-      if($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"])
117
+      if ($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"])
118 118
       {
119
-        if($message_type == MSG_TYPE_SPY) {
119
+        if ($message_type == MSG_TYPE_SPY) {
120 120
           @$result = mymail($owner_row['email'], $subject, SN::$lang['sys_spy_activity'], '', true);
121 121
         } else {
122 122
           @$result = mymail($owner_row['email'], $subject, $text_unescaped, '', true);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
       }
125 125
     }
126 126
 
127
-    if(empty($insert_values))
127
+    if (empty($insert_values))
128 128
     {
129 129
       return;
130 130
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
   }
135 135
   db_user_list_set_mass_mail($owners, "`{$message_class_name}` = `{$message_class_name}` + 1, `{$message_class_name_total}` = `{$message_class_name_total}` + 1");
136 136
 
137
-  if(in_array($user['id'], $owners) || $owners[0] == '*')
137
+  if (in_array($user['id'], $owners) || $owners[0] == '*')
138 138
   {
139 139
     $user[$message_class_name]++;
140 140
     $user[$message_class_name_total]++;
Please login to merge, or discard this patch.
includes/functions/eco_queue.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 function que_get_unit_que($unit_id) {
4 4
   $que_type = false;
5
-  foreach(sn_get_groups('ques') as $que_id => $que_data) {
6
-    if(in_array($unit_id, $que_data['unit_list'])) {
5
+  foreach (sn_get_groups('ques') as $que_id => $que_data) {
6
+    if (in_array($unit_id, $que_data['unit_list'])) {
7 7
       $que_type = $que_id;
8 8
       break;
9 9
     }
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
 function que_get_max_que_length($user, $planet, $que_id, $que_data = null) {
17 17
   global $config;
18 18
 
19
-  if(empty($que_data)) {
19
+  if (empty($que_data)) {
20 20
     $que_data = sn_get_groups('ques');
21 21
     $que_data = $que_data[$que_id];
22 22
   }
23 23
 
24 24
 
25 25
   $que_length = 1;
26
-  switch($que_id) {
26
+  switch ($que_id) {
27 27
     case QUE_RESEARCH:
28 28
       $que_length = $config->server_que_length_research + mrc_get_level($user, '', UNIT_PREMIUM); // TODO - вынести в модуль
29 29
     break;
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 
38 38
 function eco_que_str2arr($que_str) {
39 39
   $que_arr = explode(';', $que_str);
40
-  foreach($que_arr as $que_index => &$que_item) {
41
-    if($que_item) {
40
+  foreach ($que_arr as $que_index => &$que_item) {
41
+    if ($que_item) {
42 42
       $que_item = explode(',', $que_item);
43 43
     } else {
44 44
       unset($que_arr[$que_index]);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 }
49 49
 
50 50
 function eco_que_arr2str($que_arr) {
51
-  foreach($que_arr as &$que_item) {
51
+  foreach ($que_arr as &$que_item) {
52 52
     $que_item = implode(',', $que_item);
53 53
   }
54 54
   return implode(';', $que_arr);
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
   global $lang, $config;
60 60
 
61 61
   $is_autoconvert = false;
62
-  if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) {
62
+  if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) {
63 63
     $build_mode = BUILD_CREATE;
64 64
     $is_autoconvert = true;
65 65
   }
66 66
 
67 67
   $unit_amount_qued = 0;
68 68
   try {
69
-    if(!$user['id']) {
69
+    if (!$user['id']) {
70 70
       throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
71 71
     }
72 72
 
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
       foreach($unit_list as $unit_id => $unit_amount) if($unit_amount) break;
78 78
     }
79 79
     */
80
-    if(!$unit_id) {
80
+    if (!$unit_id) {
81 81
       throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
82 82
     }
83 83
 
84 84
     $que_id = que_get_unit_que($unit_id);
85
-    if(!$que_id) {
85
+    if (!$que_id) {
86 86
       throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
87 87
     }
88 88
 
89
-    if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) {
89
+    if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) {
90 90
       throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION
91 91
     }
92 92
 
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
     $que_data = $que_data[$que_id];
95 95
 
96 96
     // TODO Переделать под подочереди
97
-    if($que_id == QUE_STRUCTURES) {
97
+    if ($que_id == QUE_STRUCTURES) {
98 98
       $sn_groups_build_allow = sn_get_groups('build_allow');
99 99
       $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']];
100 100
 
101
-      if(!isset($que_data['unit_list'][$unit_id])) {
101
+      if (!isset($que_data['unit_list'][$unit_id])) {
102 102
         throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION
103 103
       }
104 104
     }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     // Это нужно, что бы заблокировать пользователя и работу с очередями
120 120
     $user = db_user_by_id($user['id']);
121 121
     // Это нужно, что бы заблокировать планету от списания ресурсов
122
-    if(isset($planet['id']) && $planet['id']) {
122
+    if (isset($planet['id']) && $planet['id']) {
123 123
       $planet = DBStaticPlanet::db_planet_by_id($planet['id'], true);
124 124
     } else {
125 125
       $planet['id'] = 0;
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
     $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id];
132 132
     $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data);
133 133
     // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей
134
-    if(count($in_que) >= $que_max_length) {
134
+    if (count($in_que) >= $que_max_length) {
135 135
       throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION
136 136
     }
137 137
 
138 138
     // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов
139
-    switch(eco_can_build_unit($user, $planet, $unit_id)) {
139
+    switch (eco_can_build_unit($user, $planet, $unit_id)) {
140 140
       case BUILD_ALLOWED: break;
141 141
       case BUILD_UNIT_BUSY: throw new exception('{Строение занято}', ERR_ERROR); break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading
142 142
       // case BUILD_REQUIRE_NOT_MEET:
143 143
       default:
144
-        if($build_mode == BUILD_CREATE) {
144
+        if ($build_mode == BUILD_CREATE) {
145 145
           throw new exception('{Требования не удовлетворены}', ERR_ERROR);
146 146
         }
147 147
         break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
     $unit_amount_qued = $unit_amount;
152 152
     $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0;
153 153
     $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued;
154
-    if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) {
155
-      if($unit_level >= $unit_max) {
154
+    if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) {
155
+      if ($unit_level >= $unit_max) {
156 156
         throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION
157 157
       }
158 158
       $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level));
159 159
     }
160 160
 
161
-    if($unit_amount < 1) {
161
+    if ($unit_amount < 1) {
162 162
       throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
163 163
     }
164 164
 
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
     //  {
175 175
     //    die('Unit busy'); // TODO EXCEPTION
176 176
     //  }
177
-    if(get_unit_param($unit_id, P_STACKABLE)) {
177
+    if (get_unit_param($unit_id, P_STACKABLE)) {
178 178
       // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь
179
-      if(in_array($unit_id, $group_missile = sn_get_groups('missile'))) {
179
+      if (in_array($unit_id, $group_missile = sn_get_groups('missile'))) {
180 180
         // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита
181 181
         $used_silo = 0;
182
-        foreach($group_missile as $missile_id) {
182
+        foreach ($group_missile as $missile_id) {
183 183
           $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0;
184 184
           $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE);
185 185
         }
186 186
         $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo;
187
-        if($free_silo <= 0) {
187
+        if ($free_silo <= 0) {
188 188
           throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION
189 189
         }
190 190
         $unit_size = get_unit_param($unit_id, P_UNIT_SIZE);
191
-        if($free_silo < $unit_size) {
191
+        if ($free_silo < $unit_size) {
192 192
           throw new exception("{В ракетной шахте нет места для {$lang['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION
193 193
         }
194 194
         $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size)));
@@ -196,10 +196,10 @@  discard block
 block discarded – undo
196 196
       $unit_level = $new_unit_level = 0;
197 197
     } else {
198 198
       $unit_amount = 1;
199
-      if($que_id == QUE_STRUCTURES) {
199
+      if ($que_id == QUE_STRUCTURES) {
200 200
         // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0)
201 201
         $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0;
202
-        if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0)
202
+        if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0)
203 203
         {
204 204
           throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION
205 205
         }
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 
218 218
     $exchange = array();
219 219
     $market_get_autoconvert_cost = market_get_autoconvert_cost();
220
-    if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) {
220
+    if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) {
221 221
       $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
222
-      if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) {
222
+      if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) {
223 223
         throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION
224 224
       }
225 225
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
       $resource_exchange_rates = array();
230 230
       $resource_diff = array();
231 231
       $all_positive = true;
232
-      foreach($resources_loot as $resource_id) {
232
+      foreach ($resources_loot as $resource_id) {
233 233
         $resource_db_name = pname_resource_name($resource_id);
234 234
         $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id));
235 235
         $resource_exchange_rates[$resource_id] = $config->__get("rpg_exchange_{$resource_db_name}");
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
         $all_positive = $all_positive && ($resource_diff[$resource_id] > 0);
238 238
       }
239 239
       // Нужна автоконвертация
240
-      if($all_positive) {
240
+      if ($all_positive) {
241 241
         $is_autoconvert = false;
242 242
       } else {
243
-        foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) {
244
-          if($resource_diff_amount >= 0) {
243
+        foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) {
244
+          if ($resource_diff_amount >= 0) {
245 245
             continue;
246 246
           }
247
-          foreach($resource_diff as $resource_got_id => &$resource_got_amount) {
248
-            if($resource_got_amount <= 0) {
247
+          foreach ($resource_diff as $resource_got_id => &$resource_got_amount) {
248
+            if ($resource_got_amount <= 0) {
249 249
               continue;
250 250
             }
251 251
             $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id];
@@ -261,14 +261,14 @@  discard block
 block discarded – undo
261 261
         }
262 262
 
263 263
         $is_autoconvert_ok = true;
264
-        foreach($resource_diff as $resource_diff_amount2) {
265
-          if($resource_diff_amount2 < 0) {
264
+        foreach ($resource_diff as $resource_diff_amount2) {
265
+          if ($resource_diff_amount2 < 0) {
266 266
             $is_autoconvert_ok = false;
267 267
             break;
268 268
           }
269 269
         }
270 270
 
271
-        if($is_autoconvert_ok) {
271
+        if ($is_autoconvert_ok) {
272 272
           $build_data['RESULT'][$build_mode] = BUILD_ALLOWED;
273 273
           $build_data['CAN'][$build_mode] = $unit_amount;
274 274
         } else {
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
       }
278 278
     }
279 279
     $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount);
280
-    if($unit_amount <= 0) {
280
+    if ($unit_amount <= 0) {
281 281
       throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION
282 282
     }
283 283
 
284
-    if($new_unit_level < 0) {
284
+    if ($new_unit_level < 0) {
285 285
       throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION
286 286
     }
287 287
 
288
-    if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) {
288
+    if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) {
289 289
       throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION
290 290
     }
291 291
 
292
-    if($is_autoconvert) {
292
+    if ($is_autoconvert) {
293 293
       ksort($exchange);
294 294
       ksort($resource_got);
295 295
       db_change_units($user, $planet, array(
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
     }
305 305
 
306 306
     $unit_amount_qued = 0;
307
-    while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) {
307
+    while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) {
308 308
       $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW);
309 309
       que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode);
310 310
       $unit_amount -= $place;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
     sn_db_transaction_commit();
316 316
 
317
-    if($redirect) {
317
+    if ($redirect) {
318 318
       sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id'));
319 319
     }
320 320
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
       'STATUS'  => ERR_NONE,
323 323
       'MESSAGE' => '{Строительство начато}',
324 324
     );
325
-  } catch(exception $e) {
325
+  } catch (exception $e) {
326 326
     sn_db_transaction_rollback();
327 327
     $operation_result = array(
328 328
       'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
     );
331 331
   }
332 332
 
333
-  if(!empty($operation_result['MESSAGE'])) {
333
+  if (!empty($operation_result['MESSAGE'])) {
334 334
     $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . $lang['tech'][$unit_id] . ']';
335 335
   }
336 336
 
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 function que_recalculate($old_que) {
345 345
   $new_que = array();
346 346
 
347
-  if(!is_array($old_que['items'])) {
347
+  if (!is_array($old_que['items'])) {
348 348
     return $new_que;
349 349
   }
350
-  foreach($old_que['items'] as $row) {
351
-    if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) {
350
+  foreach ($old_que['items'] as $row) {
351
+    if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) {
352 352
       continue;
353 353
     }
354 354
 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 
360 360
     $last_id = count($new_que['items']) - 1;
361 361
 
362
-    if($row['que_planet_id']) {
362
+    if ($row['que_planet_id']) {
363 363
       $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id];
364
-    } elseif($row['que_type'] == QUE_RESEARCH) {
364
+    } elseif ($row['que_type'] == QUE_RESEARCH) {
365 365
       $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id];
366 366
     }
367 367
     $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id];
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
   $que_type = que_get_unit_que($unit_id);
397 397
   $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL';
398 398
   $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin;
399
-  if(is_numeric($planet_id)) {
399
+  if (is_numeric($planet_id)) {
400 400
     DBStaticPlanet::db_planet_set_by_id($planet_id, "`que_processed` = UNIX_TIMESTAMP(NOW())");
401
-  } elseif(is_numeric($user['id'])) {
401
+  } elseif (is_numeric($user['id'])) {
402 402
     db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
403 403
   }
404 404
 
@@ -428,17 +428,17 @@  discard block
 block discarded – undo
428 428
   $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0;
429 429
   $global_que = que_get($user['id'], $planet['id'], $que_type, true);
430 430
 
431
-  if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) {
431
+  if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) {
432 432
     $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]);
433 433
 
434
-    foreach($que as $que_item) {
434
+    foreach ($que as $que_item) {
435 435
       DBStaticQue::db_que_delete_by_id($que_item['que_id']);
436 436
 
437
-      if($que_item['que_planet_id_origin']) {
437
+      if ($que_item['que_planet_id_origin']) {
438 438
         $planet['id'] = $que_item['que_planet_id_origin'];
439 439
       }
440 440
 
441
-      if(!isset($planets_locked[$planet['id']])) {
441
+      if (!isset($planets_locked[$planet['id']])) {
442 442
         $planets_locked[$planet['id']] = $planet['id'] ? DBStaticPlanet::db_planet_by_id($planet['id'], true) : $planet;
443 443
       }
444 444
 
@@ -450,15 +450,15 @@  discard block
 block discarded – undo
450 450
         RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount'],
451 451
       ));
452 452
 
453
-      if(!$clear) {
453
+      if (!$clear) {
454 454
         break;
455 455
       }
456 456
     }
457 457
 
458
-    if(is_numeric($planet['id'])) {
458
+    if (is_numeric($planet['id'])) {
459 459
       DBStaticPlanet::db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())");
460 460
     }
461
-    elseif(is_numeric($user['id'])) {
461
+    elseif (is_numeric($user['id'])) {
462 462
       db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
463 463
     }
464 464
 
@@ -503,21 +503,21 @@  discard block
 block discarded – undo
503 503
   // TODO: Переделать для $que_type === false
504 504
   $planet['id'] = $planet['id'] ? $planet['id'] : 0;
505 505
 
506
-  if(!is_array($que)) {
506
+  if (!is_array($que)) {
507 507
     $que = que_get($user['id'], $planet['id'], $que_type);
508 508
   }
509 509
 
510
-  if(is_array($que) && isset($que['items'])) {
510
+  if (is_array($que) && isset($que['items'])) {
511 511
     $que = $que['ques'][$que_type][$user['id']][$planet['id']];
512 512
   }
513 513
 
514
-  if($que) {
515
-    foreach($que as $que_element) {
514
+  if ($que) {
515
+    foreach ($que as $que_element) {
516 516
       $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names));
517 517
     }
518 518
   }
519 519
 
520
-  if($que_type == QUE_RESEARCH) {
520
+  if ($que_type == QUE_RESEARCH) {
521 521
     // TODO Исправить
522 522
 //    $template->assign_var('RESEARCH_ONGOING', count($global_que[QUE_RESEARCH][0]) >= $config->server_que_length_research);
523 523
   }
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
   $user = db_user_by_id($user['id'], true);
546 546
 
547 547
   $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']);
548
-  if($planet === null && !$time_left[$user['id']][0]) {
548
+  if ($planet === null && !$time_left[$user['id']][0]) {
549 549
     // TODO
550 550
     return $que;
551 551
   }
@@ -554,12 +554,12 @@  discard block
 block discarded – undo
554 554
   $que_type_id = $planet === null ? QUE_RESEARCH : false;
555 555
   $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false
556 556
   $que = que_get($user['id'], $planet, $que_type_id, true);
557
-  if(empty($que['items'])) {
557
+  if (empty($que['items'])) {
558 558
     return $que;
559 559
   }
560 560
 
561 561
   $planet_list = array();
562
-  if($planet !== null) {
562
+  if ($planet !== null) {
563 563
     // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них
564 564
     // TODO - от них не надо ничего, кроме ID и que_processed
565 565
     $planet_row = DBStaticPlanet::db_planet_list_by_user_or_planet($user['id'], $planet);
@@ -568,21 +568,21 @@  discard block
 block discarded – undo
568 568
   }
569 569
 
570 570
   // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты
571
-  if(array_sum($time_left[$user['id']]) == 0) {
571
+  if (array_sum($time_left[$user['id']]) == 0) {
572 572
     return $que;
573 573
   }
574 574
 
575 575
   $db_changeset = array();
576 576
   $unit_changes = array();
577
-  foreach($que['items'] as &$que_item) {
577
+  foreach ($que['items'] as &$que_item) {
578 578
     $que_player_id = &$que_item['que_player_id'];
579 579
     $que_planet_id = intval($que_item['que_planet_id']);
580 580
 
581 581
     $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']];
582
-    if(!isset($que_time_left)) {
582
+    if (!isset($que_time_left)) {
583 583
       $que_time_left = $time_left[$que_player_id][$que_planet_id];
584 584
     }
585
-    if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) {
585
+    if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) {
586 586
       continue;
587 587
     }
588 588
     // Дальше мы идем, если только осталось время в очереди И юниты к постройке
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
     // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля
596 596
 
597 597
     // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит
598
-    if($que_time_left >= $que_item['que_time_left']) {
598
+    if ($que_time_left >= $que_item['que_time_left']) {
599 599
       // Увеличиваем количество отстроенных юнитов
600 600
       $unit_processed++;
601 601
       // Вычитаем из времени очереди потраченное на постройку время
@@ -608,12 +608,12 @@  discard block
 block discarded – undo
608 608
     $que_item['que_unit_amount'] -= $unit_processed;
609 609
 
610 610
     // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита
611
-    if($que_item['que_unit_amount'] > 0) {
611
+    if ($que_item['que_unit_amount'] > 0) {
612 612
       $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left;
613 613
       $que_time_left = 0;
614 614
     }
615 615
 
616
-    if($que_item['que_unit_amount'] <= 0) {
616
+    if ($que_item['que_unit_amount'] <= 0) {
617 617
       $db_changeset['que'][] = array(
618 618
         'action' => SQL_OP_DELETE,
619 619
         P_VERSION => 1,
@@ -639,14 +639,14 @@  discard block
 block discarded – undo
639 639
       );
640 640
     }
641 641
 
642
-    if($unit_processed) {
642
+    if ($unit_processed) {
643 643
       $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1);
644 644
       $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta;
645 645
     }
646 646
   }
647 647
 
648
-  foreach($time_left as $player_id => $planet_data) {
649
-    foreach($planet_data as $planet_id => $time_on_planet) {
648
+  foreach ($time_left as $player_id => $planet_data) {
649
+    foreach ($planet_data as $planet_id => $time_on_planet) {
650 650
       $table = $planet_id ? 'planets' : 'users';
651 651
       $id = $planet_id ? $planet_id : $player_id;
652 652
       $db_changeset[$table][] = array(
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
         ),
663 663
       );
664 664
 
665
-      if(is_array($unit_changes[$player_id][$planet_id])) {
666
-        foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) {
665
+      if (is_array($unit_changes[$player_id][$planet_id])) {
666
+        foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) {
667 667
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null);
668 668
         }
669 669
       }
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
   $que = que_recalculate($que);
674 674
 
675 675
   // TODO: Re-enable quests for Alliances
676
-  if(!empty($unit_changes) && !$user['user_as_ally']) {
676
+  if (!empty($unit_changes) && !$user['user_as_ally']) {
677 677
     $quest_list = qst_get_quests($user['id'], QUEST_STATUS_ALL);
678 678
     $quest_triggers = qst_active_triggers($quest_list);
679 679
     $quest_rewards = array();
@@ -681,26 +681,26 @@  discard block
 block discarded – undo
681 681
 
682 682
 
683 683
     $xp_incoming = array();
684
-    foreach($unit_changes as $user_id => $planet_changes) {
685
-      foreach($planet_changes as $planet_id => $changes) {
684
+    foreach ($unit_changes as $user_id => $planet_changes) {
685
+      foreach ($planet_changes as $planet_id => $changes) {
686 686
         $planet_this = $planet_id ? SN::db_get_record_by_id(LOC_PLANET, $planet_id) : array();
687
-        foreach($changes as $unit_id => $unit_value) {
687
+        foreach ($changes as $unit_id => $unit_value) {
688 688
           $que_id = que_get_unit_que($unit_id);
689 689
           $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value;
690
-          if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) {
690
+          if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) {
691 691
             $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1);
692 692
             $build_data = $build_data[BUILD_CREATE];
693
-            foreach(sn_get_groups('resources_loot') as $resource_id) {
693
+            foreach (sn_get_groups('resources_loot') as $resource_id) {
694 694
               $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена
695 695
             }
696 696
           }
697 697
 
698
-          if(is_array($quest_triggers)) {
698
+          if (is_array($quest_triggers)) {
699 699
             // TODO: Check mutiply condition quests
700 700
             $quest_trigger_list = array_keys($quest_triggers, $unit_id);
701 701
 
702
-            if(is_array($quest_trigger_list)) {
703
-              foreach($quest_trigger_list as $quest_id) {
702
+            if (is_array($quest_trigger_list)) {
703
+              foreach ($quest_trigger_list as $quest_id) {
704 704
                 if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE) {
705 705
                   if ($quest_list[$quest_id]['quest_unit_amount'] <= $unit_level_new) {
706 706
                     $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list'];
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч
719 719
     qst_reward($user, $quest_rewards, $quest_list, $quest_statuses);
720 720
 
721
-    foreach($xp_incoming as $que_id => $xp) {
721
+    foreach ($xp_incoming as $que_id => $xp) {
722 722
       rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000);
723 723
     }
724 724
   }
Please login to merge, or discard this patch.
includes/functions/sys_user.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 function sys_user_vacation($user) {
10 10
   global $config;
11 11
 
12
-  if(sys_get_param_str('vacation') == 'leave') {
12
+  if (sys_get_param_str('vacation') == 'leave') {
13 13
     if ($user['vacation'] < SN_TIME_NOW) {
14 14
       $user['vacation'] = 0;
15 15
       $user['vacation_next'] = SN_TIME_NOW + $config->player_vacation_timeout;
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     }
18 18
   }
19 19
 
20
-  if($user['vacation']) {
20
+  if ($user['vacation']) {
21 21
     // sn_sys_logout(false, true);
22 22
     // core_auth::logout(false, true);
23 23
 
@@ -52,33 +52,33 @@  discard block
 block discarded – undo
52 52
   // TODO: Full rewrite
53 53
   sn_db_transaction_start();
54 54
   $TheUser = db_user_by_id($UserID);
55
-  if ( $TheUser['ally_id'] != 0 ) {
56
-    $TheAlly = doquery ( "SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';", '', true );
55
+  if ($TheUser['ally_id'] != 0) {
56
+    $TheAlly = doquery("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';", '', true);
57 57
     $TheAlly['ally_members'] -= 1;
58
-    if ( $TheAlly['ally_members'] > 0 ) {
59
-      doquery ( "UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';");
58
+    if ($TheAlly['ally_members'] > 0) {
59
+      doquery("UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';");
60 60
     } else {
61
-      doquery ( "DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';");
62
-      doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';");
61
+      doquery("DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';");
62
+      doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';");
63 63
     }
64 64
   }
65
-  doquery ( "DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';");
65
+  doquery("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';");
66 66
 
67 67
   DBStaticPlanet::db_planet_list_delete_by_owner($UserID);
68 68
 
69
-  doquery ( "DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';");
70
-  doquery ( "DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';");
71
-  doquery ( "DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';");
69
+  doquery("DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';");
70
+  doquery("DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';");
71
+  doquery("DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';");
72 72
   db_fleet_list_delete_by_owner($UserID);
73 73
 //  doquery ( "DELETE FROM `{{rw}}` WHERE `id_owner1` = '" . $UserID . "';");
74 74
 //  doquery ( "DELETE FROM `{{rw}}` WHERE `id_owner2` = '" . $UserID . "';");
75
-  doquery ( "DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';");
76
-  doquery ( "DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';");
77
-  doquery ( "DELETE FROM `{{annonce}}` WHERE `user` = '" . $UserID . "';");
75
+  doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';");
76
+  doquery("DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';");
77
+  doquery("DELETE FROM `{{annonce}}` WHERE `user` = '" . $UserID . "';");
78 78
 
79 79
 
80 80
   SN::db_del_record_by_id(LOC_USER, $UserID);
81
-  doquery ( "DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');");
81
+  doquery("DELETE FROM `{{referrals}}` WHERE (`id` = '{$UserID}') OR (`id_partner` = '{$UserID}');");
82 82
   global $config;
83 83
   $config->db_saveItem('users_amount', $config->db_loadItem('users_amount') - 1);
84 84
   sn_db_transaction_commit();
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
   \DBAL\DbQuery::build()->setTable('users')->setValues($field_set)->doInsert();
181 181
   $user_new = db_user_by_id(db_insert_id());
182 182
 
183
-  if(!($options['galaxy'] && $options['system'] && $options['planet'])) {
183
+  if (!($options['galaxy'] && $options['system'] && $options['planet'])) {
184 184
     $options['galaxy'] = $config->LastSettedGalaxyPos;
185 185
     $options['system'] = $config->LastSettedSystemPos;
186 186
     $segment_size = floor($config->game_maxPlanet / 3);
@@ -188,19 +188,19 @@  discard block
 block discarded – undo
188 188
     $segment++;
189 189
     $options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size);
190 190
 
191
-    while(true) {
192
-      if($options['planet'] > $config->game_maxPlanet) {
191
+    while (true) {
192
+      if ($options['planet'] > $config->game_maxPlanet) {
193 193
         $options['planet'] = mt_rand(0, $segment_size - 1) + 1;
194 194
         $options['system']++;
195 195
       }
196
-      if($options['system'] > $config->game_maxSystem) {
196
+      if ($options['system'] > $config->game_maxSystem) {
197 197
         $options['system'] = 1;
198 198
         $options['galaxy']++;
199 199
       }
200 200
       $options['galaxy'] > $config->game_maxGalaxy ? $options['galaxy'] = 1 : false;
201 201
 
202 202
       $galaxy_row = DBStaticPlanet::db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id');
203
-      if(!$galaxy_row['id']) {
203
+      if (!$galaxy_row['id']) {
204 204
         $config->db_saveItem(array(
205 205
           'LastSettedGalaxyPos' => $options['galaxy'],
206 206
           'LastSettedSystemPos' => $options['system'],
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
   $username_safe = db_escape($username_unsafe);
224 224
   doquery("REPLACE INTO {{player_name_history}} SET `player_id` = {$user_new['id']}, `player_name` = '{$username_safe}'");
225 225
 
226
-  if(!empty($options['partner_id']) && ($referral_row = db_user_by_id($options['partner_id'], true))) {
226
+  if (!empty($options['partner_id']) && ($referral_row = db_user_by_id($options['partner_id'], true))) {
227 227
     doquery("INSERT INTO {{referrals}} SET `id` = {$user_new['id']}, `id_partner` = {$options['partner_id']}");
228 228
   }
229 229
 
Please login to merge, or discard this patch.
includes/functions/rpg_points.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -22,28 +22,28 @@  discard block
 block discarded – undo
22 22
 function rpg_points_change($user_id, $change_type, $dark_matter, $comment = false, $already_changed = false) {
23 23
   global $debug, $config, $dm_change_legit, $user;
24 24
 
25
-  if(!$user_id) {
25
+  if (!$user_id) {
26 26
     return false;
27 27
   }
28 28
 
29 29
   $dm_change_legit = true;
30 30
   $sn_data_dark_matter_db_name = pname_resource_name(RES_DARK_MATTER);
31 31
 
32
-  if($already_changed) {
32
+  if ($already_changed) {
33 33
     $rows_affected = 1;
34 34
   } else {
35 35
     $changeset = array();
36 36
     $a_user = db_user_by_id($user_id, true);
37
-    if($dark_matter < 0) {
37
+    if ($dark_matter < 0) {
38 38
       $dark_matter_exists = mrc_get_level($a_user, null, RES_DARK_MATTER, false, true);
39 39
       $dark_matter_exists < 0 ? $dark_matter_exists = 0 : false;
40 40
       $metamatter_to_reduce = -$dark_matter - $dark_matter_exists;
41
-      if($metamatter_to_reduce > 0) {
41
+      if ($metamatter_to_reduce > 0) {
42 42
         $metamatter_exists = mrc_get_level($a_user, null, RES_METAMATTER);
43
-        if($metamatter_exists < $metamatter_to_reduce) {
43
+        if ($metamatter_exists < $metamatter_to_reduce) {
44 44
           $debug->error('Ошибка снятия ТМ - ММ+ТМ меньше, чем сумма для снятия!', 'Ошибка снятия ТМ', LOG_ERR_INT_NOT_ENOUGH_DARK_MATTER);
45 45
         }
46
-        if(is_array($comment)) {
46
+        if (is_array($comment)) {
47 47
           $comment = call_user_func_array('sprintf', $comment);
48 48
         }
49 49
 //        mm_points_change($user_id, $change_type, -$metamatter_to_reduce, 'ММ в ТМ: ' . (-$dark_matter) . ' ТМ = ' . $dark_matter_exists . ' ТМ + ' . $metamatter_to_reduce . ' ММ. ' . $comment);
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     $rows_affected = SN::$db->db_affected_rows();
59 59
   }
60 60
 
61
-  if($rows_affected || !$dark_matter) {
61
+  if ($rows_affected || !$dark_matter) {
62 62
     $page_url = db_escape($_SERVER['SCRIPT_NAME']);
63
-    if(is_array($comment)) {
63
+    if (is_array($comment)) {
64 64
       $comment = call_user_func_array('sprintf', $comment);
65 65
     }
66 66
     $comment = db_escape($comment);
@@ -74,18 +74,18 @@  discard block
 block discarded – undo
74 74
         {$dark_matter}, '{$comment}', '{$page_url}', {$user_id}
75 75
       );");
76 76
 
77
-    if($user['id'] == $user_id) {
77
+    if ($user['id'] == $user_id) {
78 78
       $user['dark_matter'] += $dark_matter;
79 79
     }
80 80
 
81
-    if($dark_matter > 0) {
81
+    if ($dark_matter > 0) {
82 82
       $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1 FOR UPDATE;", '', true);
83
-      if($old_referral['id']) {
83
+      if ($old_referral['id']) {
84 84
         doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter}' WHERE `id` = {$user_id} LIMIT 1;");
85 85
         $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1;", '', true);
86 86
 
87 87
         $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0);
88
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
88
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
89 89
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL, $partner_bonus, "Incoming From Referral ID {$user_id}");
90 90
         }
91 91
       }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 {
103 103
   $q = 1.03;
104 104
 
105
-  switch($type)
105
+  switch ($type)
106 106
   {
107 107
     case RPG_STRUCTURE:
108 108
       $field_level = 'lvl_minier';
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
 
141 141
   $xp = &$user[$field_xp];
142 142
 
143
-  if($xp_to_add)
143
+  if ($xp_to_add)
144 144
   {
145 145
     $xp += $xp_to_add;
146 146
     db_user_set_by_id($user['id'], "`{$field_xp}` = `{$field_xp}` + '{$xp_to_add}'");
147 147
   }
148 148
 
149 149
   $level = $user[$field_level];
150
-  while($xp > rpg_xp_for_level($level + 1, $b1, $q))
150
+  while ($xp > rpg_xp_for_level($level + 1, $b1, $q))
151 151
   {
152 152
     $level++;
153 153
   }
154 154
   $level -= $user[$field_level];
155
-  if($level > 0)
155
+  if ($level > 0)
156 156
   {
157 157
     db_user_set_by_id($user['id'], "`{$field_level}` = `{$field_level}` + '{$level}'");
158 158
     rpg_points_change($user['id'], $type, $level * 1000, $comment);
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
 function rpg_xp_for_level($level, $b1, $q)
164 164
 {
165
-  return floor($b1 * (pow($q, $level) - 1)/($q - 1));
165
+  return floor($b1 * (pow($q, $level) - 1) / ($q - 1));
166 166
 }
167 167
 
168 168
 function rpg_get_miner_xp($level)
Please login to merge, or discard this patch.
includes/functions/_news.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,8 +46,7 @@
 block discarded – undo
46 46
       'ANNOUNCE'        => SN::$gc->bbCodeParser->expandBbCode($announce['strAnnounce'], intval($announce['authlevel'])),
47 47
       'DETAIL_URL'      => $announce['detail_url'],
48 48
       'USER_NAME'       =>
49
-        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) :
50
-          js_safe_string($announce['user_name']),
49
+        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']),
51 50
       'NEW'             => $announce['unix_time'] + $config->game_news_actual >= SN_TIME_NOW,
52 51
       'FUTURE'          => $announce['unix_time'] > SN_TIME_NOW,
53 52
       'SURVEY_ID'       => $announce['survey_id'],
Please login to merge, or discard this patch.
includes/functions/eco_get_build_data.php 1 patch
Spacing   +37 added lines, -37 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,19 +157,19 @@  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(
172
+  if (
173 173
     // If planet is capital
174 174
     $user['id_planet'] == $planet['id']
175 175
     &&
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
     $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_CREATE] / SN::$gc->config->planet_capital_building_rate;
181 181
   }
182 182
 
183
-  if($mercenary) {
183
+  if ($mercenary) {
184 184
     $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_CREATE] / mrc_modify_value($user, $planet, $mercenary, 1);
185 185
   }
186 186
 
187
-  if(in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) {
187
+  if (in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) {
188 188
     $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_DESTROY] = 0;
189 189
   } else {
190 190
     $cost[RES_TIME][BUILD_CREATE]  = $cost[RES_TIME][BUILD_CREATE] > 1 ? round($cost[RES_TIME][BUILD_CREATE]) : 1;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
   return $cost;
195 195
 }
196 196
 
197
-function eco_can_build_unit($user, $planet, $unit_id){$result = null;return sn_function_call('eco_can_build_unit', array($user, $planet, $unit_id, &$result));}
197
+function eco_can_build_unit($user, $planet, $unit_id) {$result = null; return sn_function_call('eco_can_build_unit', array($user, $planet, $unit_id, &$result)); }
198 198
 function sn_eco_can_build_unit($user, $planet, $unit_id, &$result) {
199 199
   global $config;
200 200
 
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
   $result = $result == BUILD_ALLOWED && eco_unit_busy($user, $planet, $unit_id) ? BUILD_UNIT_BUSY : $result;
203 203
 
204 204
   $unit_param = get_unit_param($unit_id);
205
-  if($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) {
205
+  if ($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) {
206 206
     $requirement = &$unit_param[P_REQUIRE];
207
-    if($result == BUILD_ALLOWED && $requirement) {
208
-      foreach($requirement as $require_id => $require_level) {
209
-        if(mrc_get_level($user, $planet, $require_id) < $require_level) {
207
+    if ($result == BUILD_ALLOWED && $requirement) {
208
+      foreach ($requirement as $require_id => $require_level) {
209
+        if (mrc_get_level($user, $planet, $require_id) < $require_level) {
210 210
           $result = BUILD_REQUIRE_NOT_MEET;
211 211
           break;
212 212
         }
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
 
224 224
   $unit_list = is_array($unit_list) ? $unit_list : array($unit_list => $unit_list);
225 225
   $planet_que = explode(';', $planet_que);
226
-  foreach($planet_que as $planet_que_item)
226
+  foreach ($planet_que as $planet_que_item)
227 227
   {
228
-    if($planet_que_item)
228
+    if ($planet_que_item)
229 229
     {
230 230
       list($planet_que_item) = explode(',', $planet_que_item);
231
-      if(in_array($planet_que_item, $unit_list))
231
+      if (in_array($planet_que_item, $unit_list))
232 232
       {
233 233
         $eco_is_builds_in_que = true;
234 234
         break;
@@ -239,21 +239,21 @@  discard block
 block discarded – undo
239 239
   return $eco_is_builds_in_que;
240 240
 }
241 241
 
242
-function eco_unit_busy(&$user, &$planet, $unit_id){$result = null;return sn_function_call('eco_unit_busy', [&$user, &$planet, $unit_id, &$result]);}
242
+function eco_unit_busy(&$user, &$planet, $unit_id) {$result = null; return sn_function_call('eco_unit_busy', [&$user, &$planet, $unit_id, &$result]); }
243 243
 function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result)
244 244
 {
245 245
   global $config;
246 246
 
247 247
   $result = isset($result) ? $result : false;
248
-  if(!$result)
248
+  if (!$result)
249 249
   {
250
-    if(($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !$config->BuildLabWhileRun)
250
+    if (($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !$config->BuildLabWhileRun)
251 251
     {
252 252
       $global_que = que_get($user['id'], $planet['id'], QUE_RESEARCH, false);
253
-      if(is_array($global_que['ques'][QUE_RESEARCH][$user['id']]))
253
+      if (is_array($global_que['ques'][QUE_RESEARCH][$user['id']]))
254 254
       {
255 255
         $first_element = reset($global_que['ques'][QUE_RESEARCH][$user['id']]);
256
-        if(is_array($first_element))
256
+        if (is_array($first_element))
257 257
         {
258 258
           $result = true;
259 259
         }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
       //  $result = true;
264 264
       //}
265 265
     }
266
-    elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que'])
266
+    elseif (($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que'])
267 267
     {
268 268
       $result = eco_is_builds_in_que($planet['que'], array(STRUC_LABORATORY, STRUC_LABORATORY_NANO));
269 269
     }
Please login to merge, or discard this patch.
includes/general/nickRender.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 
272 272
 
273 273
   if (($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) {
274
-    if(!empty($render_user['user_birthday'])) {
274
+    if (!empty($render_user['user_birthday'])) {
275 275
       $result[NICK_BIRTHDAY] = '';
276 276
     }
277 277
   }
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
   }
284 284
 
285 285
   if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) {
286
-    if(isset($render_user['vacation'])) {
286
+    if (isset($render_user['vacation'])) {
287 287
       $result[NICK_VACATION] = $render_user['vacation'];
288 288
     }
289 289
   }
290 290
 
291 291
   if ($options === true || !empty($options['icons']) || !empty($options['player_rank'])) {
292
-    if(isset($render_user['total_points'])) {
292
+    if (isset($render_user['total_points'])) {
293 293
       $result[NICK_RANK] = SN::$gc->playerLevelHelper->getPointLevel($render_user['total_points'], $render_user['authlevel']);
294 294
     }
295 295
   }
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
   }
314 314
 
315 315
   if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) {
316
-    if(isset($render_user['ally_tag'])) {
316
+    if (isset($render_user['ally_tag'])) {
317 317
       $result[NICK_ALLY] = $render_user['ally_tag'];
318 318
     }
319 319
   }
Please login to merge, or discard this patch.
blitz_register.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 
3 3
 include('common.' . substr(strrchr(__FILE__, '.'), 1));
4 4
 
5
-if($user['authlevel'] < AUTH_LEVEL_DEVELOPER) {
5
+if ($user['authlevel'] < AUTH_LEVEL_DEVELOPER) {
6 6
   $error_message = SN::$config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : (
7 7
     !SN::$config->game_blitz_register ? 'sys_blitz_registration_disabled' : ''
8 8
   );
9 9
 
10
-  if($error_message) {
10
+  if ($error_message) {
11 11
     messageBox($lang[$error_message], $lang['sys_error'], 'overview.php', 10);
12 12
     die();
13 13
   }
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 $current_round = intval(SN::$config->db_loadItem('game_blitz_register_round'));
18 18
 $current_price = intval(SN::$config->db_loadItem('game_blitz_register_price'));
19 19
 
20
-if(SN::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
20
+if (SN::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
21 21
   sn_db_transaction_start();
22 22
   $user = db_user_by_id($user['id'], true);
23 23
   $is_registered = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `user_id` = {$user['id']} AND `round_number` = {$current_round} FOR UPDATE;", true);
24
-  if(sys_get_param_str('register_me')) {
25
-    if(empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
24
+  if (sys_get_param_str('register_me')) {
25
+    if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
26 26
       doquery("INSERT IGNORE INTO {{blitz_registrations}} SET `user_id` = {$user['id']}, `round_number` = {$current_round};");
27 27
       //mm_points_change($user['id'], RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица");
28 28
       SN::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица");
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
 $blitz_players = 0;
44 44
 $blitz_prize_dark_matter = 0;
45 45
 $blitz_prize_places = 0;
46
-if($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
47
-  if(sys_get_param_str('generate')) {
46
+if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
47
+  if (sys_get_param_str('generate')) {
48 48
     $next_id = 0;
49 49
     $query = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY RAND();");
50
-    while($row = db_fetch($query)) {
50
+    while ($row = db_fetch($query)) {
51 51
       $next_id++;
52 52
       $blitz_name = 'Игрок' . $next_id;
53 53
       $blitz_password = sys_random_string(8);
54 54
       doquery("UPDATE {{blitz_registrations}} SET blitz_name = '{$blitz_name}', blitz_password = '{$blitz_password}' WHERE `id` = {$row['id']} AND `round_number` = {$current_round};");
55 55
     }
56
-  } elseif(sys_get_param_str('import_generated')) {
56
+  } elseif (sys_get_param_str('import_generated')) {
57 57
     // ЭТО НА БЛИЦЕ!!!
58 58
     doquery("DELETE FROM {{users}} WHERE username like 'Игрок%';");
59 59
     doquery("DELETE FROM {{planets}} WHERE id_owner not in (SELECT `id` FROM {{users}});");
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     $system = $system_step;
76 76
     $planet = round(SN::$config->game_maxPlanet / 2);
77 77
 
78
-    foreach($imported_string as &$string_data) {
78
+    foreach ($imported_string as &$string_data) {
79 79
       $string_data = explode(',', $string_data);
80 80
       $username_safe = $string_data[0];
81 81
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
       $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], Universe::MOON_MAX_SIZE, false);
91 91
 
92
-      if(($system += $system_step) >= SN::$config->game_maxSystem) {
92
+      if (($system += $system_step) >= SN::$config->game_maxSystem) {
93 93
         $galaxy++;
94 94
         $system = $system_step;
95 95
       }
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 
99 99
     SN::$config->db_saveItem('users_amount', SN::$config->users_amount + $new_players);
100 100
     // generated_string
101
-  } elseif(sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
101
+  } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
102 102
     $blitz_result = explode(';', $blitz_result_string);
103 103
     $blitz_last_update = $blitz_result[0]; // Пока не используется
104 104
     unset($blitz_result[0]);
105
-    foreach($blitz_result as $blitz_result_data) {
105
+    foreach ($blitz_result as $blitz_result_data) {
106 106
       $blitz_result_data = explode(',', $blitz_result_data);
107
-      if(count($blitz_result_data) == 5) {
107
+      if (count($blitz_result_data) == 5) {
108 108
         $blitz_result_data[1] = db_escape($blitz_result_data[1]);
109 109
         doquery(
110 110
           "UPDATE `{{blitz_registrations}}` SET
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
     $blitz_result = array();
119 119
   }
120 120
 
121
-  if(SN::$config->game_mode == GAME_BLITZ) {
121
+  if (SN::$config->game_mode == GAME_BLITZ) {
122 122
     $blitz_result = array(SN::$config->db_loadItem('var_stat_update'));
123 123
     $query = doquery("SELECT id, username, total_rank, total_points, onlinetime FROM {{users}} ORDER BY `id`;");
124
-    while($row = db_fetch($query)) {
124
+    while ($row = db_fetch($query)) {
125 125
       $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}";
126 126
     }
127 127
   } else {
128 128
     $query = doquery("SELECT blitz_name, blitz_password, blitz_online FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `id`;");
129
-    while($row = db_fetch($query)) {
129
+    while ($row = db_fetch($query)) {
130 130
       $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}";
131 131
       $row['blitz_online'] ? $blitz_prize_players_active++ : false;
132 132
       $blitz_players++;
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
     'Игрок40'
142 142
     */
143 143
 
144
-    if(sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
144
+    if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
145 145
       // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter');
146 146
       $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places');
147 147
       sn_db_transaction_start();
148 148
       $query = doquery("SELECT * FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `blitz_place` FOR UPDATE;");
149
-      while($row = db_fetch($query)) {
150
-        if(!$row['blitz_place']) {
149
+      while ($row = db_fetch($query)) {
150
+        if (!$row['blitz_place']) {
151 151
           continue;
152 152
         }
153 153
 
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
         $blitz_prize_places_actual--;
156 156
 
157 157
         $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter'];
158
-pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}",$row['id']);
159
-        if($reward) {
158
+pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']);
159
+        if ($reward) {
160 160
           rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf(
161 161
             $lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name']
162 162
           ));
163 163
           doquery("UPDATE {{blitz_registrations}} SET blitz_reward_dark_matter = blitz_reward_dark_matter + ($reward) WHERE id = {$row['id']} AND `round_number` = {$current_round};");
164 164
         }
165 165
 
166
-        if(!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
166
+        if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
167 167
           break;
168 168
         }
169 169
       }
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
     JOIN {{users}} AS u ON u.id = br.user_id
184 184
   WHERE br.`round_number` = {$current_round}
185 185
   order by `blitz_place`, `timestamp`;");
186
-while($row = db_fetch($query)) {
186
+while ($row = db_fetch($query)) {
187 187
   $tpl_player_data = array(
188 188
     'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)),
189 189
   );
190 190
 
191
-  if(SN::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
191
+  if (SN::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
192 192
     // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда
193 193
     $tpl_player_data = array_merge($tpl_player_data, array(
194 194
       'ID' => $row['id'],
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
   }
202 202
 
203 203
   $template->assign_block_vars('registrations', $tpl_player_data);
204
-  if($row['id'] == $user['id']) {
204
+  if ($row['id'] == $user['id']) {
205 205
     $player_registered = $row;
206 206
   }
207 207
 }
Please login to merge, or discard this patch.