Completed
Push — work-fleets ( 7f5906...04acf9 )
by SuperNova.WS
06:14
created
jumpgate.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,34 +10,34 @@  discard block
 block discarded – undo
10 10
  * @copyright 2008 By Chlorel for XNova
11 11
  */
12 12
 
13
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
13
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
14 14
 
15 15
 lng_include('fleet');
16 16
 
17
-if($TargetPlanet = sys_get_param_id('jmpto'))
17
+if ($TargetPlanet = sys_get_param_id('jmpto'))
18 18
 {
19 19
   sn_db_transaction_start();
20 20
   DBStaticUser::db_user_by_id($user['id'], true, 'id');
21 21
   $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
22
-  if(!($NextJumpTime = uni_get_time_to_jump($planetrow)))
22
+  if (!($NextJumpTime = uni_get_time_to_jump($planetrow)))
23 23
   {
24 24
     $TargetGate = DBStaticPlanet::db_planet_by_id($TargetPlanet, true, '`id`, `last_jump_time`');
25
-    if(mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0)
25
+    if (mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0)
26 26
     {
27
-      $NextDestTime = uni_get_time_to_jump ( $TargetGate );
28
-      if(!$NextDestTime)
27
+      $NextDestTime = uni_get_time_to_jump($TargetGate);
28
+      if (!$NextDestTime)
29 29
       {
30 30
         $ship_list = sys_get_param('ships');
31 31
         $jumpMade = false;
32
-        foreach($ship_list as $ship_id => $ship_count)
32
+        foreach ($ship_list as $ship_id => $ship_count)
33 33
         {
34
-          if(!in_array($ship_id, Fleet::$snGroupFleet))
34
+          if (!in_array($ship_id, Fleet::$snGroupFleet))
35 35
           {
36 36
             continue;
37 37
           }
38 38
 
39 39
           $ship_count = max(0, min(floor($ship_count), mrc_get_level($user, $planetrow, $ship_id)));
40
-          if($ship_count)
40
+          if ($ship_count)
41 41
           {
42 42
             $jumpMade = true;
43 43
             DBStaticUnit::dbUpdateOrInsertUnit($ship_id, -$ship_count, $user, $planetrow['id']);
@@ -45,39 +45,39 @@  discard block
 block discarded – undo
45 45
           }
46 46
         }
47 47
         // Dit monsieur, y avait quelque chose a envoyer ???
48
-        if($jumpMade)
48
+        if ($jumpMade)
49 49
         {
50
-          DBStaticPlanet::db_planet_update_set_by_id($TargetGate['id'], "`last_jump_time` = " . SN_TIME_NOW . "");
51
-          DBStaticPlanet::db_planet_update_set_by_id($planetrow['id'], "`last_jump_time` = " . SN_TIME_NOW . "");
50
+          DBStaticPlanet::db_planet_update_set_by_id($TargetGate['id'], "`last_jump_time` = ".SN_TIME_NOW."");
51
+          DBStaticPlanet::db_planet_update_set_by_id($planetrow['id'], "`last_jump_time` = ".SN_TIME_NOW."");
52 52
 
53 53
           DBStaticUser::db_user_set_by_id($user['id'], "`current_planet` = '{$TargetGate['id']}'");
54 54
 
55 55
           $planetrow['last_jump_time'] = SN_TIME_NOW;
56
-          $RetMessage = classLocale::$lang['gate_jump_done'] ." - ". pretty_time(uni_get_time_to_jump($planetrow));
56
+          $RetMessage = classLocale::$lang['gate_jump_done']." - ".pretty_time(uni_get_time_to_jump($planetrow));
57 57
         } else {
58 58
           $RetMessage = classLocale::$lang['gate_wait_data'];
59 59
         }
60 60
       } else {
61
-        $RetMessage = classLocale::$lang['gate_wait_dest'] ." - ". pretty_time($NextDestTime);
61
+        $RetMessage = classLocale::$lang['gate_wait_dest']." - ".pretty_time($NextDestTime);
62 62
       }
63 63
     } else {
64 64
       $RetMessage = classLocale::$lang['gate_no_dest_g'];
65 65
     }
66 66
   } else {
67
-    $RetMessage = classLocale::$lang['gate_wait_star'] ." - ". pretty_time($NextJumpTime);
67
+    $RetMessage = classLocale::$lang['gate_wait_star']." - ".pretty_time($NextJumpTime);
68 68
   }
69 69
   sn_db_transaction_commit();
70 70
   message($RetMessage, classLocale::$lang['tech'][STRUC_MOON_GATE], "jumpgate.php", 10);
71 71
 } else {
72 72
   $template = gettemplate('jumpgate', true);
73
-  if(mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0)
73
+  if (mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0)
74 74
   {
75 75
     $Combo = '';
76 76
     $MoonList = DBStaticPlanet::db_planet_list_moon_other($user['id'], $planetrow['id']);
77 77
     // while($CurMoon = db_fetch($MoonList))
78
-    foreach($MoonList as $CurMoon)
78
+    foreach ($MoonList as $CurMoon)
79 79
     {
80
-      if(mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1)
80
+      if (mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1)
81 81
       {
82 82
         $NextJumpTime = uni_get_time_to_jump($CurMoon);
83 83
         $template->assign_block_vars('moon', array(
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
       }
92 92
     }
93 93
 
94
-    foreach(Fleet::$snGroupFleet as $Ship)
94
+    foreach (Fleet::$snGroupFleet as $Ship)
95 95
     {
96
-      if(($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0)
96
+      if (($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0)
97 97
       {
98 98
         continue;
99 99
       }
Please login to merge, or discard this patch.
includes/functions/qst_quest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     $template->assign_vars($quest_templatized);
180 180
     if (!empty($quest_templatized['quest_rewards_list'])) {
181 181
       foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) {
182
-        $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward);
182
+        $template->assign_block_vars(($block_name ? $block_name.'.' : '').'quest_rewards_list', $quest_reward);
183 183
       }
184 184
     }
185 185
   }
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
 
249 249
         $comment_reward = array();
250 250
         foreach ($reward_list as $unit_id => $unit_amount) {
251
-          $comment_reward[] = $unit_amount . ' ' . classLocale::$lang['tech'][$unit_id];
251
+          $comment_reward[] = $unit_amount.' '.classLocale::$lang['tech'][$unit_id];
252 252
           $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount;
253 253
         }
254
-        $comment .= " {$classLocale['qst_msg_your_reward']} " . implode(',', $comment_reward);
254
+        $comment .= " {$classLocale['qst_msg_your_reward']} ".implode(',', $comment_reward);
255 255
 
256 256
         DBStaticMessages::msg_send_simple_message($user['id'], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, classLocale::$lang['msg_from_admin'], classLocale::$lang['qst_msg_complete_subject'], $comment);
257 257
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
         if (!empty($resourcesChange)) {
291 291
           $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id;
292
-          if($planet_id) {
292
+          if ($planet_id) {
293 293
             // update planet
294 294
             DBStaticPlanet::db_planet_update_resources($resourcesChange, $planet_id);
295 295
           } else {
Please login to merge, or discard this patch.
includes/functions/eco_queue.php 1 patch
Spacing   +99 added lines, -99 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
     }
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
 
15 15
 
16 16
 function que_get_max_que_length($user, $planet, $que_id, $que_data = null) {
17
-  if(empty($que_data)) {
17
+  if (empty($que_data)) {
18 18
     $que_data = sn_get_groups('ques');
19 19
     $que_data = $que_data[$que_id];
20 20
   }
21 21
 
22 22
 
23 23
   $que_length = 1;
24
-  switch($que_id) {
24
+  switch ($que_id) {
25 25
     case QUE_RESEARCH:
26 26
       $que_length = classSupernova::$config->server_que_length_research + mrc_get_level($user, null, UNIT_PREMIUM); // TODO - вынести в модуль
27 27
     break;
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 
36 36
 function eco_que_str2arr($que_str) {
37 37
   $que_arr = explode(';', $que_str);
38
-  foreach($que_arr as $que_index => &$que_item) {
39
-    if($que_item) {
38
+  foreach ($que_arr as $que_index => &$que_item) {
39
+    if ($que_item) {
40 40
       $que_item = explode(',', $que_item);
41 41
     } else {
42 42
       unset($que_arr[$que_index]);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 }
48 48
 
49 49
 function eco_que_arr2str($que_arr) {
50
-  foreach($que_arr as &$que_item) {
50
+  foreach ($que_arr as &$que_item) {
51 51
     $que_item = implode(',', $que_item);
52 52
   }
53 53
 
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
   $classLocale = classLocale::$lang;
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,12 +94,12 @@  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])) {
102
-        throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION
101
+      if (!isset($que_data['unit_list'][$unit_id])) {
102
+        throw new exception('{Это здание нельзя строить на '.($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION
103 103
       }
104 104
     }
105 105
     /*
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     // Это нужно, что бы заблокировать пользователя и работу с очередями
120 120
     $user = DBStaticUser::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,12 +131,12 @@  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:
141 141
       break;
142 142
       case BUILD_UNIT_BUSY:
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
       break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading
145 145
       // case BUILD_REQUIRE_NOT_MEET:
146 146
       default:
147
-        if($build_mode == BUILD_CREATE) {
147
+        if ($build_mode == BUILD_CREATE) {
148 148
           throw new exception('{Требования не удовлетворены}', ERR_ERROR);
149 149
         }
150 150
       break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
     $unit_amount_qued = $unit_amount;
155 155
     $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0;
156 156
     $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued;
157
-    if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) {
158
-      if($unit_level >= $unit_max) {
157
+    if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) {
158
+      if ($unit_level >= $unit_max) {
159 159
         throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION
160 160
       }
161 161
       $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level));
162 162
     }
163 163
 
164
-    if($unit_amount < 1) {
164
+    if ($unit_amount < 1) {
165 165
       throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
166 166
     }
167 167
 
@@ -170,21 +170,21 @@  discard block
 block discarded – undo
170 170
     //  {
171 171
     //    die('Unit busy'); // TODO EXCEPTION
172 172
     //  }
173
-    if(get_unit_param($unit_id, P_STACKABLE)) {
173
+    if (get_unit_param($unit_id, P_STACKABLE)) {
174 174
       // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь
175
-      if(in_array($unit_id, $group_missile = sn_get_groups(GROUP_STR_MISSILES))) {
175
+      if (in_array($unit_id, $group_missile = sn_get_groups(GROUP_STR_MISSILES))) {
176 176
         // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита
177 177
         $used_silo = 0;
178
-        foreach($group_missile as $missile_id) {
178
+        foreach ($group_missile as $missile_id) {
179 179
           $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0;
180 180
           $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE);
181 181
         }
182 182
         $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo;
183
-        if($free_silo <= 0) {
183
+        if ($free_silo <= 0) {
184 184
           throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION
185 185
         }
186 186
         $unit_size = get_unit_param($unit_id, P_UNIT_SIZE);
187
-        if($free_silo < $unit_size) {
187
+        if ($free_silo < $unit_size) {
188 188
           throw new exception("{В ракетной шахте нет места для {$classLocale['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION
189 189
         }
190 190
         $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size)));
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
       $unit_level = $new_unit_level = 0;
193 193
     } else {
194 194
       $unit_amount = 1;
195
-      if($que_id == QUE_STRUCTURES) {
195
+      if ($que_id == QUE_STRUCTURES) {
196 196
         // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0)
197 197
         $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0;
198
-        if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) {
198
+        if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) {
199 199
           throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION
200 200
         }
201 201
         // И что это я такое написал? Зачем?
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 
213 213
     $exchange = array();
214 214
     $market_get_autoconvert_cost = market_get_autoconvert_cost();
215
-    if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) {
215
+    if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) {
216 216
       $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
217
-      if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) {
218
-        throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION
217
+      if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) {
218
+        throw new exception("{Нет хватает ".($market_get_autoconvert_cost - $dark_matter)."ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION
219 219
       }
220 220
 
221 221
       !get_unit_param($unit_id, P_STACKABLE) ? $unit_amount = 1 : false;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
       $resource_exchange_rates = array();
225 225
       $resource_diff = array();
226 226
       $all_positive = true;
227
-      foreach($resources_loot as $resource_id) {
227
+      foreach ($resources_loot as $resource_id) {
228 228
         $resource_db_name = pname_resource_name($resource_id);
229 229
         $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id));
230 230
         $resource_exchange_rates[$resource_id] = classSupernova::$config->__get("rpg_exchange_{$resource_db_name}");
@@ -232,15 +232,15 @@  discard block
 block discarded – undo
232 232
         $all_positive = $all_positive && ($resource_diff[$resource_id] > 0);
233 233
       }
234 234
       // Нужна автоконвертация
235
-      if($all_positive) {
235
+      if ($all_positive) {
236 236
         $is_autoconvert = false;
237 237
       } else {
238
-        foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) {
239
-          if($resource_diff_amount >= 0) {
238
+        foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) {
239
+          if ($resource_diff_amount >= 0) {
240 240
             continue;
241 241
           }
242
-          foreach($resource_diff as $resource_got_id => &$resource_got_amount) {
243
-            if($resource_got_amount <= 0) {
242
+          foreach ($resource_diff as $resource_got_id => &$resource_got_amount) {
243
+            if ($resource_got_amount <= 0) {
244 244
               continue;
245 245
             }
246 246
             $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id];
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
         }
257 257
 
258 258
         $is_autoconvert_ok = true;
259
-        foreach($resource_diff as $resource_diff_amount2) {
260
-          if($resource_diff_amount2 < 0) {
259
+        foreach ($resource_diff as $resource_diff_amount2) {
260
+          if ($resource_diff_amount2 < 0) {
261 261
             $is_autoconvert_ok = false;
262 262
             break;
263 263
           }
264 264
         }
265 265
 
266
-        if($is_autoconvert_ok) {
266
+        if ($is_autoconvert_ok) {
267 267
           $build_data['RESULT'][$build_mode] = BUILD_ALLOWED;
268 268
           $build_data['CAN'][$build_mode] = $unit_amount;
269 269
         } else {
@@ -272,19 +272,19 @@  discard block
 block discarded – undo
272 272
       }
273 273
     }
274 274
     $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount);
275
-    if($unit_amount <= 0) {
275
+    if ($unit_amount <= 0) {
276 276
       throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION
277 277
     }
278 278
 
279
-    if($new_unit_level < 0) {
279
+    if ($new_unit_level < 0) {
280 280
       throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION
281 281
     }
282 282
 
283
-    if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) {
283
+    if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) {
284 284
       throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION
285 285
     }
286 286
 
287
-    if($is_autoconvert) {
287
+    if ($is_autoconvert) {
288 288
       ksort($exchange);
289 289
       ksort($resource_got);
290 290
       db_change_units($user, $planet, array(
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
     }
300 300
 
301 301
     $unit_amount_qued = 0;
302
-    while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) {
302
+    while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) {
303 303
       $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW);
304 304
       que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode);
305 305
       $unit_amount -= $place;
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
 
310 310
     sn_db_transaction_commit();
311 311
 
312
-    if($redirect) {
313
-      sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id'));
312
+    if ($redirect) {
313
+      sys_redirect("{$_SERVER['PHP_SELF']}?mode=".sys_get_param_str('mode')."&ally_id=".sys_get_param_id('ally_id'));
314 314
       die();
315 315
     }
316 316
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
       'STATUS'  => ERR_NONE,
319 319
       'MESSAGE' => '{Строительство начато}',
320 320
     );
321
-  } catch(exception $e) {
321
+  } catch (exception $e) {
322 322
     sn_db_transaction_rollback();
323 323
     $operation_result = array(
324 324
       'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
     );
327 327
   }
328 328
 
329
-  if(!empty($operation_result['MESSAGE'])) {
330
-    $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . classLocale::$lang['tech'][$unit_id] . ']';
329
+  if (!empty($operation_result['MESSAGE'])) {
330
+    $operation_result['MESSAGE'] .= ' '.($unit_amount_qued ? $unit_amount_qued : $unit_amount).'x['.classLocale::$lang['tech'][$unit_id].']';
331 331
   }
332 332
 
333 333
   return $operation_result;
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 function que_recalculate($old_que) {
338 338
   $new_que = array();
339 339
 
340
-  if(!is_array($old_que['items'])) {
340
+  if (!is_array($old_que['items'])) {
341 341
     return $new_que;
342 342
   }
343
-  foreach($old_que['items'] as $row) {
344
-    if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) {
343
+  foreach ($old_que['items'] as $row) {
344
+    if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) {
345 345
       continue;
346 346
     }
347 347
 
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
 
353 353
     $last_id = count($new_que['items']) - 1;
354 354
 
355
-    if($row['que_planet_id']) {
355
+    if ($row['que_planet_id']) {
356 356
       $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id];
357
-    } elseif($row['que_type'] == QUE_RESEARCH) {
357
+    } elseif ($row['que_type'] == QUE_RESEARCH) {
358 358
       $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id];
359 359
     }
360 360
     $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id];
@@ -389,9 +389,9 @@  discard block
 block discarded – undo
389 389
   $que_type = que_get_unit_que($unit_id);
390 390
   $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL';
391 391
   $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin;
392
-  if(is_numeric($planet_id)) {
392
+  if (is_numeric($planet_id)) {
393 393
     DBStaticPlanet::db_planet_update_set_by_id($planet_id, "`que_processed` = UNIX_TIMESTAMP(NOW())");
394
-  } elseif(is_numeric($user['id'])) {
394
+  } elseif (is_numeric($user['id'])) {
395 395
     DBStaticUser::db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
396 396
   }
397 397
 
@@ -421,17 +421,17 @@  discard block
 block discarded – undo
421 421
   $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0;
422 422
   $global_que = que_get($user['id'], $planet['id'], $que_type, true);
423 423
 
424
-  if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) {
424
+  if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) {
425 425
     $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]);
426 426
 
427
-    foreach($que as $que_item) {
427
+    foreach ($que as $que_item) {
428 428
       DBStaticQue::db_que_delete_by_id($que_item['que_id']);
429 429
 
430
-      if($que_item['que_planet_id_origin']) {
430
+      if ($que_item['que_planet_id_origin']) {
431 431
         $planet['id'] = $que_item['que_planet_id_origin'];
432 432
       }
433 433
 
434
-      if(!isset($planets_locked[$planet['id']])) {
434
+      if (!isset($planets_locked[$planet['id']])) {
435 435
         $planets_locked[$planet['id']] = $planet['id'] ? DBStaticPlanet::db_planet_by_id($planet['id'], true) : $planet;
436 436
       }
437 437
 
@@ -443,14 +443,14 @@  discard block
 block discarded – undo
443 443
         RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount'],
444 444
       ));
445 445
 
446
-      if(!$clear) {
446
+      if (!$clear) {
447 447
         break;
448 448
       }
449 449
     }
450 450
 
451
-    if(is_numeric($planet['id'])) {
451
+    if (is_numeric($planet['id'])) {
452 452
       DBStaticPlanet::db_planet_update_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())");
453
-    } elseif(is_numeric($user['id'])) {
453
+    } elseif (is_numeric($user['id'])) {
454 454
       DBStaticUser::db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
455 455
     }
456 456
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
     sn_db_transaction_rollback();
460 460
   }
461 461
 //die();
462
-  header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}" . "&ally_id=" . sys_get_param_id('ally_id'));
462
+  header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}"."&ally_id=".sys_get_param_id('ally_id'));
463 463
 }
464 464
 
465 465
 
@@ -498,21 +498,21 @@  discard block
 block discarded – undo
498 498
   // TODO: Переделать для $que_type === false
499 499
   $planet['id'] = $planet['id'] ? $planet['id'] : 0;
500 500
 
501
-  if(!is_array($que)) {
501
+  if (!is_array($que)) {
502 502
     $que = que_get($user['id'], $planet['id'], $que_type);
503 503
   }
504 504
 
505
-  if(is_array($que) && isset($que['items'])) {
505
+  if (is_array($que) && isset($que['items'])) {
506 506
     $que = $que['ques'][$que_type][$user['id']][$planet['id']];
507 507
   }
508 508
 
509
-  if($que) {
510
-    foreach($que as $que_element) {
509
+  if ($que) {
510
+    foreach ($que as $que_element) {
511 511
       $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names));
512 512
     }
513 513
   }
514 514
 
515
-  if($que_type == QUE_RESEARCH) {
515
+  if ($que_type == QUE_RESEARCH) {
516 516
   }
517 517
 }
518 518
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
   $user = DBStaticUser::db_user_by_id($user['id'], true);
539 539
 
540 540
   $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']);
541
-  if($planet === null && !$time_left[$user['id']][0]) {
541
+  if ($planet === null && !$time_left[$user['id']][0]) {
542 542
     // TODO
543 543
     return $que;
544 544
   }
@@ -547,12 +547,12 @@  discard block
 block discarded – undo
547 547
   $que_type_id = $planet === null ? QUE_RESEARCH : false;
548 548
   $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false
549 549
   $que = que_get($user['id'], $planet, $que_type_id, true);
550
-  if(empty($que['items'])) {
550
+  if (empty($que['items'])) {
551 551
     return $que;
552 552
   }
553 553
 
554 554
   $planet_list = array();
555
-  if($planet !== null) {
555
+  if ($planet !== null) {
556 556
     // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них
557 557
     // TODO - от них не надо ничего, кроме ID и que_processed
558 558
     $planet_row = DBStaticPlanet::db_planet_list_by_user_or_planet($user['id'], $planet);
@@ -561,20 +561,20 @@  discard block
 block discarded – undo
561 561
   }
562 562
 
563 563
   // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты
564
-  if(array_sum($time_left[$user['id']]) == 0) {
564
+  if (array_sum($time_left[$user['id']]) == 0) {
565 565
     return $que;
566 566
   }
567 567
 
568 568
   $unit_changes = array();
569
-  foreach($que['items'] as &$que_item) {
569
+  foreach ($que['items'] as &$que_item) {
570 570
     $que_player_id = &$que_item['que_player_id'];
571 571
     $que_planet_id = intval($que_item['que_planet_id']);
572 572
 
573 573
     $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']];
574
-    if(!isset($que_time_left)) {
574
+    if (!isset($que_time_left)) {
575 575
       $que_time_left = $time_left[$que_player_id][$que_planet_id];
576 576
     }
577
-    if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) {
577
+    if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) {
578 578
       continue;
579 579
     }
580 580
     // Дальше мы идем, если только осталось время в очереди И юниты к постройке
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
     // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля
588 588
 
589 589
     // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит
590
-    if($que_time_left >= $que_item['que_time_left']) {
590
+    if ($que_time_left >= $que_item['que_time_left']) {
591 591
       // Увеличиваем количество отстроенных юнитов
592 592
       $unit_processed++;
593 593
       // Вычитаем из времени очереди потраченное на постройку время
@@ -600,12 +600,12 @@  discard block
 block discarded – undo
600 600
     $que_item['que_unit_amount'] -= $unit_processed;
601 601
 
602 602
     // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита
603
-    if($que_item['que_unit_amount'] > 0) {
603
+    if ($que_item['que_unit_amount'] > 0) {
604 604
       $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left;
605 605
       $que_time_left = 0;
606 606
     }
607 607
 
608
-    if($que_item['que_unit_amount'] <= 0) {
608
+    if ($que_item['que_unit_amount'] <= 0) {
609 609
       DBStaticQue::db_que_delete_by_id($que_item['que_id']);
610 610
     } else {
611 611
       classSupernova::db_upd_record_list(
@@ -615,15 +615,15 @@  discard block
 block discarded – undo
615 615
       );
616 616
     }
617 617
 
618
-    if($unit_processed) {
618
+    if ($unit_processed) {
619 619
       $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1);
620 620
       $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta;
621 621
     }
622 622
   }
623 623
 
624
-  foreach($time_left as $player_id => $planet_data) {
625
-    foreach($planet_data as $planet_id => $time_on_planet) {
626
-      if($planet_id) {
624
+  foreach ($time_left as $player_id => $planet_data) {
625
+    foreach ($planet_data as $planet_id => $time_on_planet) {
626
+      if ($planet_id) {
627 627
         // update planet
628 628
         classSupernova::db_upd_record_list(LOC_PLANET, "`que_processed` = {$on_time}", "id = {$planet_id}");
629 629
       } else {
@@ -631,8 +631,8 @@  discard block
 block discarded – undo
631 631
         classSupernova::db_upd_record_list(LOC_USER, "`que_processed` = {$on_time}", "id = {$player_id}");
632 632
       }
633 633
 
634
-      if(is_array($unit_changes[$player_id][$planet_id])) {
635
-        foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) {
634
+      if (is_array($unit_changes[$player_id][$planet_id])) {
635
+        foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) {
636 636
           DBStaticUnit::dbUpdateOrInsertUnit($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null);
637 637
         }
638 638
       }
@@ -642,38 +642,38 @@  discard block
 block discarded – undo
642 642
   $que = que_recalculate($que);
643 643
 
644 644
   // TODO: Re-enable quests for Alliances
645
-  if(!empty($unit_changes) && !$user['user_as_ally']) {
645
+  if (!empty($unit_changes) && !$user['user_as_ally']) {
646 646
     $quest_list = qst_get_quests($user['id']);
647 647
     $quest_triggers = qst_active_triggers($quest_list);
648 648
     $quest_rewards = array();
649 649
 
650 650
 
651 651
     $xp_incoming = array();
652
-    foreach($unit_changes as $user_id => $planet_changes) {
653
-      foreach($planet_changes as $planet_id => $changes) {
652
+    foreach ($unit_changes as $user_id => $planet_changes) {
653
+      foreach ($planet_changes as $planet_id => $changes) {
654 654
         $planet_this = $planet_id ? classSupernova::db_get_record_by_id(LOC_PLANET, $planet_id) : array();
655
-        foreach($changes as $unit_id => $unit_value) {
655
+        foreach ($changes as $unit_id => $unit_value) {
656 656
           $que_id = que_get_unit_que($unit_id);
657 657
           $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value;
658
-          if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) {
658
+          if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) {
659 659
             $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1);
660 660
             $build_data = $build_data[BUILD_CREATE];
661
-            foreach(sn_get_groups('resources_loot') as $resource_id) {
661
+            foreach (sn_get_groups('resources_loot') as $resource_id) {
662 662
               $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена
663 663
             }
664 664
           }
665 665
 
666
-          if(is_array($quest_triggers)) {
666
+          if (is_array($quest_triggers)) {
667 667
             // TODO: Check mutiply condition quests
668 668
             $quest_trigger_list = array_keys($quest_triggers, $unit_id);
669
-            if(is_array($quest_trigger_list)) {
670
-              foreach($quest_trigger_list as $quest_id) {
669
+            if (is_array($quest_trigger_list)) {
670
+              foreach ($quest_trigger_list as $quest_id) {
671 671
                 $quest_unit_level = $unit_level_new;
672
-                if(get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) {
672
+                if (get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) {
673 673
                   $quest_unit_level = DBStaticUnit::db_unit_count_by_user_and_type_and_snid($user_id, 0, $unit_id);
674 674
                   $quest_unit_level = $quest_unit_level[$unit_id]['qty'];
675 675
                 }
676
-                if($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) {
676
+                if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) {
677 677
                   $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list'];
678 678
                   $quest_list[$quest_id]['quest_status_status'] = QUEST_STATUS_COMPLETE;
679 679
                 }
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
     // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч
687 687
     qst_reward($user, $quest_rewards, $quest_list);
688 688
 
689
-    foreach($xp_incoming as $que_id => $xp) {
689
+    foreach ($xp_incoming as $que_id => $xp) {
690 690
       rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000);
691 691
     }
692 692
   }
Please login to merge, or discard this patch.
includes/classes/DBStaticQue.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
     if ($que_type == QUE_RESEARCH || $planet_id === null) {
39 39
       $query[] = "`que_planet_id` IS NULL";
40 40
     } elseif ($planet_id) {
41
-      $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")";
41
+      $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")";
42 42
     }
43 43
     if ($que_type) {
44 44
       $query[] = "`que_type` = {$que_type}";
Please login to merge, or discard this patch.
includes/classes/classSupernova.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false;
204 204
     if (@get_magic_quotes_gpc()) {
205 205
       $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
206
-      array_walk_recursive($gpcr, function (&$value, $key) {
206
+      array_walk_recursive($gpcr, function(&$value, $key) {
207 207
         $value = stripslashes($value);
208 208
       });
209 209
     }
@@ -219,43 +219,43 @@  discard block
 block discarded – undo
219 219
     $gc = static::$gc;
220 220
 
221 221
     // Default db
222
-    $gc->db = function ($c) {
222
+    $gc->db = function($c) {
223 223
       $db = new db_mysql($c);
224 224
       $db->sn_db_connect();
225 225
 
226 226
       return $db;
227 227
     };
228 228
 
229
-    $gc->debug = function ($c) {
229
+    $gc->debug = function($c) {
230 230
       return new debug();
231 231
     };
232 232
 
233
-    $gc->cache = function ($c) {
233
+    $gc->cache = function($c) {
234 234
       return new classCache(classSupernova::$cache_prefix);
235 235
     };
236 236
 
237
-    $gc->config = function ($c) {
237
+    $gc->config = function($c) {
238 238
       return new classConfig(classSupernova::$cache_prefix);
239 239
     };
240 240
 
241
-    $gc->localePlayer = function (GlobalContainer $c) {
241
+    $gc->localePlayer = function(GlobalContainer $c) {
242 242
       return new classLocale($c->config->server_locale_log_usage);
243 243
     };
244 244
 
245
-    $gc->dbRowOperator = function ($c) {
245
+    $gc->dbRowOperator = function($c) {
246 246
       return new DbRowDirectOperator($c);
247 247
     };
248 248
 
249 249
     $gc->buddyClass = 'Buddy\BuddyModel';
250
-    $gc->buddy = $gc->factory(function (GlobalContainer $c) {
250
+    $gc->buddy = $gc->factory(function(GlobalContainer $c) {
251 251
       return new $c->buddyClass($c);
252 252
     });
253 253
 
254
-    $gc->query = $gc->factory(function (GlobalContainer $c) {
254
+    $gc->query = $gc->factory(function(GlobalContainer $c) {
255 255
       return new DbQueryConstructor($c->db);
256 256
     });
257 257
 
258
-    $gc->unit = $gc->factory(function (GlobalContainer $c) {
258
+    $gc->unit = $gc->factory(function(GlobalContainer $c) {
259 259
       return new \V2Unit\V2UnitModel($c);
260 260
     });
261 261
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
   public static function init_3_load_config_file() {
269 269
     $dbsettings = array();
270 270
 
271
-    require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
271
+    require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
272 272
     self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix'];
273 273
     self::$db_name = $dbsettings['name'];
274 274
     self::$sn_secret_word = $dbsettings['secretword'];
Please login to merge, or discard this patch.
includes/includes/flt_page4.inc 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -2,28 +2,28 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(SN_IN_FLEET !== true) {
5
+if (SN_IN_FLEET !== true) {
6 6
   classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
7 7
 }
8 8
 
9 9
 $fleetid = sys_get_param_id('fleetid');
10 10
 
11
-if(!is_numeric($fleetid) || empty($fleetid)) {
11
+if (!is_numeric($fleetid) || empty($fleetid)) {
12 12
   header("Location: fleet.php");
13 13
   exit();
14 14
 }
15 15
 
16 16
 $objFleet = new Fleet();
17 17
 $objFleet->dbLoad($fleetid);
18
-if(!$objFleet->dbId) {
18
+if (!$objFleet->dbId) {
19 19
   message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']);
20 20
 }
21 21
 
22
-if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
22
+if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
23 23
   message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']);
24 24
 }
25 25
 
26
-if($objFleet->playerOwnerId != $user['id']) {
26
+if ($objFleet->playerOwnerId != $user['id']) {
27 27
   classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
28 28
   message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']);
29 29
 }
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 
35 35
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
36 36
 
37
-if($userToAdd_unsafe) {
37
+if ($userToAdd_unsafe) {
38 38
   $userToAdd = db_escape($userToAdd_unsafe);
39 39
   $userToAddID = DBStaticUser::db_user_by_username($userToAdd_unsafe, false, 'id', true, true);
40 40
   $userToAddID = $userToAddID['id'];
41 41
 
42
-  if($objFleet->target_owner_id == $userToAddID) {
42
+  if ($objFleet->target_owner_id == $userToAddID) {
43 43
     message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']);
44 44
   }
45 45
 
46
-  if($userToAddID) {
47
-    if(!$aks) {
46
+  if ($userToAddID) {
47
+    if (!$aks) {
48 48
       // No AСS exists - making one
49
-      if(!$objFleet->group_id) {
49
+      if (!$objFleet->group_id) {
50 50
         DBStaticFleetACS::db_acs_insert($fleetid, $user, $objFleet);
51 51
 
52 52
         $aks = DBStaticFleetACS::db_acs_get_by_fleet($fleetid);
@@ -61,22 +61,22 @@  discard block
 block discarded – undo
61 61
 
62 62
     $isUserExists = false;
63 63
     $invited_ar = explode(",", $aks['eingeladen']);
64
-    foreach($invited_ar as $inv) {
65
-      if($userToAddID == $inv) {
64
+    foreach ($invited_ar as $inv) {
65
+      if ($userToAddID == $inv) {
66 66
         $isUserExists = true;
67 67
       }
68 68
     }
69 69
 
70
-    if(count($invited_ar) >= 5) {
70
+    if (count($invited_ar) >= 5) {
71 71
       message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']);
72 72
     }
73 73
 
74
-    if($isUserExists) {
74
+    if ($isUserExists) {
75 75
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false;
76 76
     } else {
77 77
       $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd);
78 78
       !(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid)) ? die(sprintf(classLocale::$lang['fl_aks_adding_error'], classSupernova::$db->db_error())) : false;
79
-      $aks['eingeladen'] .= ',' . $userToAddID;
79
+      $aks['eingeladen'] .= ','.$userToAddID;
80 80
     }
81 81
     DBStaticMessages::msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
82 82
       classLocale::$lang['fl_aks_invite_message_header'], sprintf(classLocale::$lang['fl_aks_invite_message'], $user['username']));
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
   'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS],
94 94
 ));
95 95
 
96
-if($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
97
-  foreach($members as $row) {
96
+if ($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
97
+  foreach ($members as $row) {
98 98
     $template->assign_block_vars('invited', array(
99 99
       'NAME' => $row['username'],
100 100
     ));
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 $fleet_data = tplParseFleetObject($objFleet, $i, $user);
120 120
 
121 121
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
122
-foreach($fleet_data['ships'] as $ship_data) {
122
+foreach ($fleet_data['ships'] as $ship_data) {
123 123
   $template->assign_block_vars('fleets.ships', $ship_data);
124 124
 }
125 125
 
Please login to merge, or discard this patch.
includes/alliance/ali_external_create_ally.inc 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 // Pretty Safe
3 3
 // TODO: Add ally_tag to usertable
4 4
 
5
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
5
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
6 6
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
7 7
 }
8 8
 
@@ -11,21 +11,21 @@  discard block
 block discarded – undo
11 11
 $ally_name_raw = sys_get_param_str_unsafe('name');
12 12
 $ally_name = db_escape($ally_name_raw);
13 13
 
14
-if($ally_tag) {
15
-  if(!$ally_name_raw || !$ally_tag_raw) {
14
+if ($ally_tag) {
15
+  if (!$ally_name_raw || !$ally_tag_raw) {
16 16
     message(classLocale::$lang['have_not_name'], classLocale::$lang['make_alliance']);
17 17
   }
18 18
 
19 19
   $query = DBStaticAlly::db_ally_get_by_name_or_tag($ally_tag, $ally_name);
20
-  if($query) {
20
+  if ($query) {
21 21
     message(str_replace('%s', $query['ally_tag'] == $ally_tag_raw ? $ally_tag_raw : $ally_name_raw, classLocale::$lang['always_exist']), classLocale::$lang['make_alliance']);
22 22
   }
23 23
 
24 24
   DBStaticAlly::db_ally_insert($ally_name, $ally_tag, $user);
25 25
   $ally_id = classSupernova::$db->db_insert_id();
26
-  DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= " . SN_TIME_NOW . "");
26
+  DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= ".SN_TIME_NOW."");
27 27
 
28
-  $ally_user = classSupernova::$gc->cacheOperator->db_ins_record(LOC_USER, "`username` = '[{$ally_tag}]', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_id}");
28
+  $ally_user = classSupernova::$gc->cacheOperator->db_ins_record(LOC_USER, "`username` = '[{$ally_tag}]', `register_time` = ".SN_TIME_NOW.", `user_as_ally` = {$ally_id}");
29 29
   // $ally_user_id = db_insert_id();
30 30
   $ally_user_id = is_array($ally_user) ? $ally_user['id'] : 'NULL';
31 31
   DBStaticAlly::db_ally_update_ally_user($ally_user_id, $ally_id);
Please login to merge, or discard this patch.
includes/classes/DBStaticUser.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         ->where('`user_as_ally` IS NULL')
24 24
         ->orderBy(array('`id` DESC'));
25 25
 
26
-    return (string)$query->selectValue();
26
+    return (string) $query->selectValue();
27 27
   }
28 28
 
29 29
   /**
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
       static::buildDBQ()
49 49
         ->field('id')
50 50
         ->where("`user_as_ally` IS NULL")
51
-        ->where("`user_bot` = " . USER_BOT_PLAYER)
51
+        ->where("`user_bot` = ".USER_BOT_PLAYER)
52 52
         ->setForUpdate();
53 53
 
54 54
     return $query->selectIterator();
55 55
   }
56 56
 
57 57
   public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) {
58
-    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) .
59
-      (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '')
58
+    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']).
59
+      (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '')
60 60
       . " FOR UPDATE";
61 61
 
62 62
     static::getDb()->doSelect($query);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
       FROM `{{users}}` 
74 74
       WHERE 
75 75
         `user_as_ally` IS NULL" .
76
-        ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
76
+        ($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
77 77
     ));
78 78
   }
79 79
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
       ->fieldCount('r.id', 'referral_count')
96 96
       ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm')
97 97
       ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id')
98
-      ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
98
+      ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
99 99
       ->groupBy('u.id')
100 100
       ->orderBy("user_as_ally, {$sort} ASC");
101 101
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
       ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)')
114 114
       ->where('`user_as_ally` IS NULL')
115 115
       ->having('`days_after_birthday` >= 0')
116
-      ->having('`days_after_birthday` < ' . intval($config_user_birthday_range))
116
+      ->having('`days_after_birthday` < '.intval($config_user_birthday_range))
117 117
       ->setForUpdate();
118 118
 
119 119
     $result = $query->selectIterator();
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
208 208
 
209 209
       $user = classSupernova::$db->doSelectFetch(
210
-        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'"
210
+        "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'"
211 211
         . " FOR UPDATE"
212 212
       );
213 213
       SnCache::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
 
259 259
   public static function db_user_list_set_mass_mail(&$owners_list, $set) {
260
-    return classSupernova::$gc->cacheOperator->db_upd_record_list(LOC_USER, $set, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : '');
260
+    return classSupernova::$gc->cacheOperator->db_upd_record_list(LOC_USER, $set, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : '');
261 261
   }
262 262
 
263 263
   public static function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) {
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
    * @param array $playerArray
273 273
    */
274 274
   public static function renderNameAndCoordinates($playerArray) {
275
-    return "{$playerArray['username']} " . uni_render_coordinates($playerArray);
275
+    return "{$playerArray['username']} ".uni_render_coordinates($playerArray);
276 276
   }
277 277
 
278 278
   /**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
       $fieldName = pname_resource_name($resourceId);
304 304
       $value = "{$fieldName} = {$fieldName} + ('{$value}')";
305 305
     }
306
-    if($query = implode(',', $playerRowFieldChanges)) {
306
+    if ($query = implode(',', $playerRowFieldChanges)) {
307 307
       classSupernova::$gc->db->doUpdate("UPDATE `{{users}}` SET {$query} WHERE id = {$userId}");
308 308
     }
309 309
   }
Please login to merge, or discard this patch.
includes/classes/SnDbCachedOperator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
           $query = $this->db->doSelect(
183 183
             "SELECT
184 184
               distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id
185
-            FROM {{{$location_info[P_TABLE_NAME]}}}" .
186
-            ($filter ? ' WHERE ' . $filter : '') .
185
+            FROM {{{$location_info[P_TABLE_NAME]}}}".
186
+            ($filter ? ' WHERE '.$filter : '').
187 187
             ($fetch ? ' LIMIT 1' : ''));
188 188
           while ($row = db_fetch($query)) {
189 189
             // Исключаем из списка родительских ИД уже заблокированные записи
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
           if ($indexes_str = implode(',', $parent_id_list)) {
197 197
             $parent_id_field = static::$location_info[$owner_location_type][P_ID];
198 198
             classSupernova::$gc->cacheOperator->db_get_record_list($owner_location_type,
199
-              $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
199
+              $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
200 200
           }
201 201
         }
202 202
       }
203 203
 
204 204
       $query = $this->db->doSelect(
205
-        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" .
205
+        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}".
206 206
         (($filter = trim($filter)) ? " WHERE {$filter}" : '')
207 207
         . " FOR UPDATE"
208 208
       );
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
     $condition = trim($condition);
277 277
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
278 278
 
279
-    if ($result = $this->db->doUpdate("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
279
+    if ($result = $this->db->doUpdate("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) {
280 280
 
281 281
       if ($this->db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
282 282
         // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
   public function db_lock_tables($tables) {
347 347
     $tables = is_array($tables) ? $tables : array($tables => '');
348 348
     foreach ($tables as $table_name => $condition) {
349
-      $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : ''));
349
+      $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : ''));
350 350
     }
351 351
   }
352 352
 }
Please login to merge, or discard this patch.