Completed
Push — work-fleets ( 4d76fa...c97fe0 )
by SuperNova.WS
05:17
created
includes/functions/flt_mission_missile.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -115,8 +115,7 @@
 block discarded – undo
115 115
     ));
116 116
 
117 117
     display($template, $lang['tech'][STRUC_MOON_GATE]);
118
-  }
119
-  else
118
+  } else
120 119
   {
121 120
     message($lang['gate_no_src_ga'], $lang['tech'][STRUC_MOON_GATE], "overview.php", 10);
122 121
   }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
   $mip_data = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
15 15
   $MIPDamage = floor(mrc_modify_value($attackerTech, false, TECH_WEAPON, $MIPs * $mip_data[P_ATTACK] * mt_rand(80, 120) / 100));
16
-  foreach($structures as $key => $structure)
16
+  foreach ($structures as $key => $structure)
17 17
   {
18 18
     $unit_info = get_unit_param($key);
19 19
     $amplify = isset($mip_data[P_AMPLIFY][$key]) ? $mip_data[P_AMPLIFY][$key] : 1;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
   {
32 32
     //attacking only selected structure
33 33
     $damageDone = $structures[$targetedStructure][$damageTo];
34
-    $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
34
+    $structsDestroyed = min(floor($MIPDamage / $damageDone), $structures[$targetedStructure][0]);
35 35
     $structures[$targetedStructure][0] -= $structsDestroyed;
36
-    $MIPDamage -= $structsDestroyed*$damageDone;
36
+    $MIPDamage -= $structsDestroyed * $damageDone;
37 37
   }
38 38
   else
39 39
   {
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
     do
45 45
     {
46 46
       // finding is there any structure that can be damaged with leftovers of $MIPDamage
47
-      foreach($can_be_damaged as $key => $unit_id)
47
+      foreach ($can_be_damaged as $key => $unit_id)
48 48
       {
49 49
 //debug($structures[$unit_id][0]);
50 50
 //debug($structures[$unit_id][$damageTo], $MIPDamage);
51
-        if($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
51
+        if ($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
52 52
         {
53 53
           unset($can_be_damaged[$key]);
54 54
         }
55 55
       }
56
-      if(empty($can_be_damaged))
56
+      if (empty($can_be_damaged))
57 57
       {
58 58
         break;
59 59
       }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 //debug($destroyed, 'Actually destroyed');
73 73
 
74 74
 //print('<hr>');
75
-    } while($MIPDamage > 0 && !empty($can_be_damaged));
75
+    } while ($MIPDamage > 0 && !empty($can_be_damaged));
76 76
 //debug($MIPDamage, 'MIPDamage left');
77 77
   }
78 78
 //debug($structures);//die();
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
     $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4;
88 88
   }
89 89
 
90
-  $return['structures'] = $structures;     // Structures left after attack
91
-  $return['metal']      = floor($metal);   // Metal scraps
90
+  $return['structures'] = $structures; // Structures left after attack
91
+  $return['metal']      = floor($metal); // Metal scraps
92 92
   $return['crystal']    = floor($crystal); // Crystal scraps
93 93
 
94 94
   return $return;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
   $iraks = db_missile_list_by_arrival();
114 114
 
115
-  while($fleetRow = db_fetch($iraks)) {
115
+  while ($fleetRow = db_fetch($iraks)) {
116 116
     set_time_limit(15);
117 117
     $db_changeset = array();
118 118
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 
129 129
     $rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true);
130 130
 
131
-    if($target_planet_row['id']) {
131
+    if ($target_planet_row['id']) {
132 132
       $planetDefense = array();
133
-      foreach(sn_get_groups('defense_active') as $unit_id) {
133
+      foreach (sn_get_groups('defense_active') as $unit_id) {
134 134
         $planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true));
135 135
       }
136 136
 
@@ -141,24 +141,24 @@  discard block
 block discarded – undo
141 141
         $message = classLocale::$lang['mip_all_destroyed'];
142 142
         $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']);
143 143
       } else {
144
-        if($interceptors) {
144
+        if ($interceptors) {
145 145
           $message = sprintf(classLocale::$lang['mip_destroyed'], $interceptors);
146 146
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']);
147 147
         }
148 148
 
149 149
         $attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']);
150 150
 
151
-        foreach($attackResult['structures'] as $key => $structure) {
151
+        foreach ($attackResult['structures'] as $key => $structure) {
152 152
           $destroyed = $planetDefense[$key][0] - $structure[0];
153
-          if($destroyed) {
153
+          if ($destroyed) {
154 154
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($key, -$destroyed, $targetUser, $target_planet_row['id']);
155 155
 
156 156
             $message .= "&nbsp;&nbsp;{$classLocale['tech'][$key]} - {$destroyed} {$classLocale['quantity']}<br>";
157 157
           }
158 158
         }
159 159
 
160
-        if(!empty($message)) {
161
-          $message = classLocale::$lang['mip_defense_destroyed'] . $message . "{$classLocale['mip_recycled']}{$classLocale['Metal']}: {$attackResult['metal']}, {$classLocale['Crystal']}: {$attackResult['crystal']}<br>";
160
+        if (!empty($message)) {
161
+          $message = classLocale::$lang['mip_defense_destroyed'].$message."{$classLocale['mip_recycled']}{$classLocale['Metal']}: {$attackResult['metal']}, {$classLocale['Crystal']}: {$attackResult['crystal']}<br>";
162 162
 
163 163
           db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}");
164 164
         }
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 
176 176
       empty($message) ? $message = classLocale::$lang['mip_no_defense'] : false;
177 177
 
178
-      msg_send_simple_message ( $fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message );
179
-      msg_send_simple_message ( $fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message );
178
+      msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage.$message);
179
+      msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage.$message);
180 180
     }
181 181
     db_missile_delete($fleetRow);
182 182
   }
Please login to merge, or discard this patch.
includes/classes/Bonus.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
   /**
25 25
    * Добавляет юнит к списку бонусов
26 26
    *
27
-   * @param $unit_id
27
+   * @param integer $unit_id
28 28
    * @param $unit_level
29 29
    */
30 30
   public function add_unit_by_snid($unit_id, $unit_level) {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
    *
68 68
    * Выдает финальный бонус в виде множителя
69 69
    *
70
-   * @param string|int $param - ИД бонуса
70
+   * @param string $param - ИД бонуса
71 71
    *
72 72
    * @return float
73 73
    */
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
    * @param $unit_level
29 29
    */
30 30
   public function add_unit_by_snid($unit_id, $unit_level) {
31
-    if(!$unit_level) {
31
+    if (!$unit_level) {
32 32
       return;
33 33
     }
34 34
 
35
-    foreach(static::$_bonus_group as $param_name => $unit_list) {
36
-      if(!empty($unit_list[$unit_id])) {
35
+    foreach (static::$_bonus_group as $param_name => $unit_list) {
36
+      if (!empty($unit_list[$unit_id])) {
37 37
         // Простейший вариант - мультипликатор по базе
38 38
         // Общий мультипликатор добавляется в конец
39 39
         $this->grants[$param_name][$unit_id] = $unit_level;
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 //    $this->grants[$param_name][$unit_id] = $unit_level * get_unit_param($unit_id, P_BONUS_VALUE) / 100;;
83 83
     $value_add = floatval($base_value);
84 84
     $cumulative = 1.0; // Для случая BONUS_PERCENT
85
-    if(!empty($this->grants[$param]) && is_array($this->grants[$param])) {
86
-      foreach($this->grants[$param] as $unit_id => $unit_level) {
85
+    if (!empty($this->grants[$param]) && is_array($this->grants[$param])) {
86
+      foreach ($this->grants[$param] as $unit_id => $unit_level) {
87 87
         $unit_bonus = 0;
88
-        if($unit_id < 0) {
88
+        if ($unit_id < 0) {
89 89
           // Meta-unit - leave as is
90 90
         } else {
91 91
           // TODO - Подумать, что будет при смешивании разных бонусов и как этого избежать
92 92
           $bonus_value = get_unit_param($unit_id, P_BONUS_VALUE);
93 93
           $bonus_type = get_unit_param($unit_id, P_BONUS_TYPE);
94
-          switch($bonus_type) {
94
+          switch ($bonus_type) {
95 95
             case BONUS_PERCENT:
96 96
               $unit_bonus = $unit_level * $bonus_value / 100;
97 97
               $cumulative += $unit_bonus;
Please login to merge, or discard this patch.
includes/classes/supernova.php 3 patches
Doc Comments   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
    *   <p>null - транзакция НЕ должна быть запущена</p>
324 324
    *   <p>true - транзакция должна быть запущена - для совместимости с $for_update</p>
325 325
    *   <p>false - всё равно - для совместимости с $for_update</p>
326
-   * @return bool Текущий статус транзакции
326
+   * @return null|boolean Текущий статус транзакции
327 327
    */
328 328
   public static function db_transaction_check($status = null) {
329 329
     $error_msg = false;
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
   /**
400 400
    * Блокирует указанные таблицу/список таблиц
401 401
    *
402
-   * @param string|array $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов
402
+   * @param string $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов
403 403
    * <p>string - название таблицы для блокировки</p>
404 404
    * <p>array - массив, где ключ - имя таблицы, а значение - условия блокировки элементов</p>
405 405
    */
@@ -587,6 +587,9 @@  discard block
 block discarded – undo
587 587
     return $result;
588 588
   }
589 589
 
590
+  /**
591
+   * @param integer $location_type
592
+   */
590 593
   public static function db_ins_field_set($location_type, $field_set, $serialize = false) {
591 594
     // TODO multiinsert
592 595
     !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set, $serialize) : false;
@@ -809,7 +812,7 @@  discard block
 block discarded – undo
809 812
    * @param     $location_type
810 813
    * @param     $location_id
811 814
    *
812
-   * @return array|bool
815
+   * @return boolean
813 816
    */
814 817
   public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id)
815 818
   {
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -573,7 +573,8 @@  discard block
 block discarded – undo
573 573
     $location_info = &static::$location_info[$location_type];
574 574
     $id_field = $location_info[P_ID];
575 575
     $table_name = $location_info[P_TABLE_NAME];
576
-    if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
576
+    if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) {
577
+      // TODO Как-то вернуть может быть LIMIT 1 ?
577 578
     {
578 579
       if(static::$db->db_affected_rows()) {
579 580
         // Обновляем данные только если ряд был затронут
@@ -581,6 +582,7 @@  discard block
 block discarded – undo
581 582
 
582 583
         // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее
583 584
         static::$data[$location_type][$record_id] = null;
585
+    }
584 586
         // Вытаскиваем обновленную запись
585 587
         static::db_get_record_by_id($location_type, $record_id);
586 588
         static::cache_clear($location_type, false); // Мягкий сброс - только $queries
@@ -622,9 +624,11 @@  discard block
 block discarded – undo
622 624
     $set = trim($set);
623 625
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
624 626
     if($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
625
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
627
+      if(static::$db->db_affected_rows()) {
628
+        // Обновляем данные только если ряд был затронут
626 629
       {
627 630
         $record_id = db_insert_id();
631
+      }
628 632
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
629 633
         $result = static::db_get_record_by_id($location_type, $record_id);
630 634
         // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего
@@ -669,10 +673,12 @@  discard block
 block discarded – undo
669 673
     $id_field = $location_info[P_ID];
670 674
     $table_name = $location_info[P_TABLE_NAME];
671 675
     if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) {
672
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
676
+      if(static::$db->db_affected_rows()) {
677
+        // Обновляем данные только если ряд был затронут
673 678
       {
674 679
         static::cache_unset($location_type, $safe_record_id);
675 680
       }
681
+      }
676 682
     }
677 683
 
678 684
     return $result;
@@ -689,12 +695,14 @@  discard block
 block discarded – undo
689 695
 //static::db_get_record_list($location_type, $condition, false, true);
690 696
 
691 697
     if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) {
692
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
698
+      if(static::$db->db_affected_rows()) {
699
+        // Обновляем данные только если ряд был затронут
693 700
       {
694 701
         // Обнуление кэша, потому что непонятно, что поменялось
695 702
         // TODO - когда будет структурированный $condition можно будет делать только cache_unset по нужным записям
696 703
         static::cache_clear($location_type);
697 704
       }
705
+      }
698 706
     }
699 707
 
700 708
     return $result;
Please login to merge, or discard this patch.
Spacing   +118 added lines, -120 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
 
205 205
   public static function log_file($message, $spaces = 0) {
206
-    if(self::$debug) {
206
+    if (self::$debug) {
207 207
       self::$debug->log_file($message, $spaces);
208 208
     }
209 209
   }
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
   // Перепаковывает массив на заданную глубину, убирая поля с null
216 216
   public static function array_repack(&$array, $level = 0) {
217 217
     // TODO $lock_table не нужна тут
218
-    if(!is_array($array)) {
218
+    if (!is_array($array)) {
219 219
       return;
220 220
     }
221 221
 
222
-    foreach($array as $key => &$value) {
223
-      if($value === null) {
222
+    foreach ($array as $key => &$value) {
223
+      if ($value === null) {
224 224
         unset($array[$key]);
225
-      } elseif($level > 0 && is_array($value)) {
225
+      } elseif ($level > 0 && is_array($value)) {
226 226
         static::array_repack($value, $level - 1);
227
-        if(empty($value)) {
227
+        if (empty($value)) {
228 228
           unset($array[$key]);
229 229
         }
230 230
       }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
   // TODO Вынести в отдельный объект
236 236
   public static function cache_repack($location_type, $record_id = 0) {
237 237
     // Если есть $user_id - проверяем, а надо ли перепаковывать?
238
-    if($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) {
238
+    if ($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) {
239 239
       return;
240 240
     }
241 241
 
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 
247 247
   public static function cache_clear($location_type, $hard = true) {
248 248
     //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />");
249
-    if($hard && !empty(static::$data[$location_type])) {
249
+    if ($hard && !empty(static::$data[$location_type])) {
250 250
       // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях
251
-      array_walk(static::$data[$location_type], function (&$item) { $item = null; });
251
+      array_walk(static::$data[$location_type], function(&$item) { $item = null; });
252 252
     }
253 253
     static::$locator[$location_type] = array();
254 254
     static::$queries[$location_type] = array();
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
   public static function cache_clear_all($hard = true) {
259 259
     //print('<br />CACHE CLEAR ALL<br />');
260
-    if($hard) {
260
+    if ($hard) {
261 261
       static::$data = array();
262 262
       static::cache_lock_unset_all();
263 263
     }
@@ -286,12 +286,12 @@  discard block
 block discarded – undo
286 286
   */
287 287
   public static function cache_set($location_type, $record_id, $record, $force_overwrite = false, $skip_lock = false) {
288 288
     // нет идентификатора - выход
289
-    if(!($record_id = $record[static::$location_info[$location_type][P_ID]])) {
289
+    if (!($record_id = $record[static::$location_info[$location_type][P_ID]])) {
290 290
       return;
291 291
     }
292 292
 
293 293
     $in_transaction = static::db_transaction_check(false);
294
-    if(
294
+    if (
295 295
       $force_overwrite
296 296
       ||
297 297
       // Не заменяются заблокированные записи во время транзакции
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
       !static::cache_isset($location_type, $record_id)
302 302
     ) {
303 303
       static::$data[$location_type][$record_id] = $record;
304
-      if($in_transaction && !$skip_lock) {
304
+      if ($in_transaction && !$skip_lock) {
305 305
         static::cache_lock_set($location_type, $record_id);
306 306
       }
307 307
     }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
   public static function cache_unset($cache_id, $safe_record_id) {
311 311
     // $record_id должен быть проверен заранее !
312
-    if(isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) {
312
+    if (isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) {
313 313
       // Выставляем запись в null
314 314
       static::$data[$cache_id][$safe_record_id] = null;
315 315
       // Очищаем кэш мягко - что бы удалить очистить связанные данные - кэш локаций и кэш запоросов и всё, что потребуется впредь
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
   }
327 327
 
328 328
   public static function cache_lock_unset($location_type, $record_id) {
329
-    if(isset(static::$locks[$location_type][$record_id])) {
329
+    if (isset(static::$locks[$location_type][$record_id])) {
330 330
       unset(static::$locks[$location_type][$record_id]);
331 331
     }
332 332
 
@@ -360,15 +360,15 @@  discard block
 block discarded – undo
360 360
    */
361 361
   public static function db_transaction_check($status = null) {
362 362
     $error_msg = false;
363
-    if($status && !static::$db_in_transaction) {
363
+    if ($status && !static::$db_in_transaction) {
364 364
       $error_msg = 'No transaction started for current operation';
365
-    } elseif($status === null && static::$db_in_transaction) {
365
+    } elseif ($status === null && static::$db_in_transaction) {
366 366
       $error_msg = 'Transaction is already started';
367 367
     }
368 368
 
369
-    if($error_msg) {
369
+    if ($error_msg) {
370 370
       // TODO - Убрать позже
371
-      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>');
371
+      print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>');
372 372
       $backtrace = debug_backtrace();
373 373
       array_shift($backtrace);
374 374
       pdump($backtrace);
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
   public static function db_transaction_start($level = '') {
382 382
     static::db_transaction_check(null);
383 383
 
384
-    $level ? doquery('SET TRANSACTION ISOLATION LEVEL ' . $level) : false;
384
+    $level ? doquery('SET TRANSACTION ISOLATION LEVEL '.$level) : false;
385 385
 
386 386
     static::$transaction_id++;
387 387
     doquery('START TRANSACTION');
388 388
 
389
-    if(classSupernova::$config->db_manual_lock_enabled) {
389
+    if (classSupernova::$config->db_manual_lock_enabled) {
390 390
       classSupernova::$config->db_loadItem('var_db_manually_locked');
391 391
       classSupernova::$config->db_saveItem('var_db_manually_locked', SN_TIME_SQL);
392 392
     }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
   public static function db_transaction_commit() {
402 402
     static::db_transaction_check(true);
403 403
 
404
-    if(!empty(static::$delayed_changset)) {
404
+    if (!empty(static::$delayed_changset)) {
405 405
       static::db_changeset_apply(static::$delayed_changset, true);
406 406
       // pdump(static::$delayed_changset);
407 407
     }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
   public static function db_transaction_rollback() {
414 414
     // static::db_transaction_check(true); // TODO - вообще-то тут тоже надо проверять есть ли транзакция
415 415
 
416
-    if(!empty(static::$delayed_changset)) {
416
+    if (!empty(static::$delayed_changset)) {
417 417
       static::db_changeset_revert();
418 418
     }
419 419
     doquery('ROLLBACK');
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
    */
442 442
   public static function db_lock_tables($tables) {
443 443
     $tables = is_array($tables) ? $tables : array($tables => '');
444
-    foreach($tables as $table_name => $condition) {
445
-      self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : ''));
444
+    foreach ($tables as $table_name => $condition) {
445
+      self::$db->doquery("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : ''));
446 446
     }
447 447
   }
448 448
 
@@ -484,17 +484,17 @@  discard block
 block discarded – undo
484 484
     //pdump($filter, 'Выбираем ' . $location_type);
485 485
     $query_cache = &static::$queries[$location_type][$filter];
486 486
 
487
-    if(!isset($query_cache) || $query_cache === null) {
487
+    if (!isset($query_cache) || $query_cache === null) {
488 488
       // pdump($filter, 'Кэш пустой, начинаем возню');
489 489
       $location_info = &static::$location_info[$location_type];
490 490
       $id_field = $location_info[P_ID];
491 491
       $query_cache = array();
492 492
 
493
-      if(static::db_transaction_check(false)) {
493
+      if (static::db_transaction_check(false)) {
494 494
         //pdump($filter, 'Транзакция - блокируем ' . $location_type);
495 495
         // Проходим по всем родителям данной записи
496 496
         // foreach($location_info[P_OWNER_INFO] as $owner_location_type => $owner_data)
497
-        foreach($location_info[P_OWNER_INFO] as $owner_data) {
497
+        foreach ($location_info[P_OWNER_INFO] as $owner_data) {
498 498
           $owner_location_type = $owner_data[P_LOCATION];
499 499
           //pdump($filter, 'Транзакция - блокируем родителя ' . $owner_location_type);
500 500
           $parent_id_list = array();
@@ -502,24 +502,24 @@  discard block
 block discarded – undo
502 502
           $query = static::db_query(
503 503
             "SELECT
504 504
               distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id
505
-            FROM {{{$location_info[P_TABLE_NAME]}}}" .
506
-            ($filter ? ' WHERE ' . $filter : '') .
505
+            FROM {{{$location_info[P_TABLE_NAME]}}}".
506
+            ($filter ? ' WHERE '.$filter : '').
507 507
             ($fetch ? ' LIMIT 1' : ''), false, true);
508 508
 
509 509
           //pdump($q, 'Запрос блокировки');
510
-          while($row = db_fetch($query)) {
510
+          while ($row = db_fetch($query)) {
511 511
             // Исключаем из списка родительских ИД уже заблокированные записи
512
-            if(!static::cache_lock_get($owner_location_type, $row['parent_id'])) {
512
+            if (!static::cache_lock_get($owner_location_type, $row['parent_id'])) {
513 513
               $parent_id_list[$row['parent_id']] = $row['parent_id'];
514 514
             }
515 515
           }
516 516
           //pdump($parent_id_list, 'Выбраны родители');
517 517
           // Если все-таки какие-то записи еще не заблокированы - вынимаем текущие версии из базы
518
-          if($indexes_str = implode(',', $parent_id_list)) {
518
+          if ($indexes_str = implode(',', $parent_id_list)) {
519 519
             //pdump($indexes_str, '$indexes_str');
520 520
             $parent_id_field = static::$location_info[$owner_location_type][P_ID];
521 521
             static::db_get_record_list($owner_location_type,
522
-              $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
522
+              $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
523 523
           }
524 524
           //pdump($filter, 'Транзакция - родители заблокированы ' . $owner_location_type);
525 525
         }
@@ -527,10 +527,10 @@  discard block
 block discarded – undo
527 527
 
528 528
       //pdump($filter, 'Выбираем записи и заносим их в кыш-память ' . $owner_location_type);
529 529
       $query = static::db_query(
530
-        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" .
530
+        "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}".
531 531
         (($filter = trim($filter)) ? " WHERE {$filter}" : '')
532 532
       );
533
-      while($row = db_fetch($query)) {
533
+      while ($row = db_fetch($query)) {
534 534
         // static::db_get_record_by_id($location_type, $row[$id_field]);
535 535
         static::cache_set($location_type, $row[$id_field], $row);
536 536
         $query_cache[$row[$id_field]] = &static::$data[$location_type][$row[$id_field]];
@@ -538,14 +538,14 @@  discard block
 block discarded – undo
538 538
       }
539 539
     }
540 540
 
541
-    if($no_return) {
541
+    if ($no_return) {
542 542
       return true;
543 543
     } else {
544 544
       $result = false;
545
-      if(is_array($query_cache)) {
546
-        foreach($query_cache as $key => $value) {
545
+      if (is_array($query_cache)) {
546
+        foreach ($query_cache as $key => $value) {
547 547
           $result[$key] = $value;
548
-          if($fetch) {
548
+          if ($fetch) {
549 549
             break;
550 550
           }
551 551
         }
@@ -564,16 +564,16 @@  discard block
 block discarded – undo
564 564
    */
565 565
   public static function db_upd_record_by_id($location_type, $record_id, $set) {
566 566
     //if(!($record_id = intval($record_id)) || !($set = trim($set))) return false;
567
-    if(!($record_id = idval($record_id)) || !($set = trim($set))) {
567
+    if (!($record_id = idval($record_id)) || !($set = trim($set))) {
568 568
       return false;
569 569
     }
570 570
 
571 571
     $location_info = &static::$location_info[$location_type];
572 572
     $id_field = $location_info[P_ID];
573 573
     $table_name = $location_info[P_TABLE_NAME];
574
-    if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
574
+    if ($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
575 575
     {
576
-      if(static::$db->db_affected_rows()) {
576
+      if (static::$db->db_affected_rows()) {
577 577
         // Обновляем данные только если ряд был затронут
578 578
         // TODO - переделать под работу со структурированными $set
579 579
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
   }
590 590
 
591 591
   public static function db_upd_record_list($location_type, $condition, $set) {
592
-    if(!($set = trim($set))) {
592
+    if (!($set = trim($set))) {
593 593
       return false;
594 594
     }
595 595
 
@@ -598,9 +598,9 @@  discard block
 block discarded – undo
598 598
 
599 599
 //static::db_get_record_list($location_type, $condition, false, true);
600 600
 
601
-    if($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
601
+    if ($result = static::db_query("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) {
602 602
 
603
-      if(static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
603
+      if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
604 604
         // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью
605 605
         // TODO - когда будет структурированный $condition и $set - перепаковывать данные
606 606
         static::cache_clear($location_type, true);
@@ -619,8 +619,8 @@  discard block
 block discarded – undo
619 619
   public static function db_ins_record($location_type, $set) {
620 620
     $set = trim($set);
621 621
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
622
-    if($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
623
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
622
+    if ($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
623
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
624 624
       {
625 625
         $record_id = db_insert_id();
626 626
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
@@ -642,8 +642,8 @@  discard block
 block discarded – undo
642 642
     $fields = implode(',', array_keys($field_set));
643 643
 
644 644
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
645
-    if($result = static::db_query("INSERT INTO `{{{$table_name}}}` ($fields) VALUES ($values);")) {
646
-      if(static::$db->db_affected_rows()) {
645
+    if ($result = static::db_query("INSERT INTO `{{{$table_name}}}` ($fields) VALUES ($values);")) {
646
+      if (static::$db->db_affected_rows()) {
647 647
         // Обновляем данные только если ряд был затронут
648 648
         $record_id = db_insert_id();
649 649
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
@@ -659,15 +659,15 @@  discard block
 block discarded – undo
659 659
 
660 660
   public static function db_del_record_by_id($location_type, $safe_record_id) {
661 661
     // if(!($safe_record_id = intval($safe_record_id))) return false;
662
-    if(!($safe_record_id = idval($safe_record_id))) {
662
+    if (!($safe_record_id = idval($safe_record_id))) {
663 663
       return false;
664 664
     }
665 665
 
666 666
     $location_info = &static::$location_info[$location_type];
667 667
     $id_field = $location_info[P_ID];
668 668
     $table_name = $location_info[P_TABLE_NAME];
669
-    if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) {
670
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
669
+    if ($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) {
670
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
671 671
       {
672 672
         static::cache_unset($location_type, $safe_record_id);
673 673
       }
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
   }
678 678
 
679 679
   public static function db_del_record_list($location_type, $condition) {
680
-    if(!($condition = trim($condition))) {
680
+    if (!($condition = trim($condition))) {
681 681
       return false;
682 682
     }
683 683
 
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
 
687 687
 //static::db_get_record_list($location_type, $condition, false, true);
688 688
 
689
-    if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) {
690
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
689
+    if ($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) {
690
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
691 691
       {
692 692
         // Обнуление кэша, потому что непонятно, что поменялось
693 693
         // TODO - когда будет структурированный $condition можно будет делать только cache_unset по нужным записям
@@ -734,20 +734,20 @@  discard block
 block discarded – undo
734 734
 
735 735
   public static function db_get_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) {
736 736
     // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ?
737
-    if(!($username_unsafe = trim($username_unsafe))) {
737
+    if (!($username_unsafe = trim($username_unsafe))) {
738 738
       return false;
739 739
     }
740 740
 
741 741
     $user = null;
742
-    if(is_array(static::$data[LOC_USER])) {
743
-      foreach(static::$data[LOC_USER] as $user_id => $user_data) {
744
-        if(is_array($user_data) && isset($user_data['username'])) {
742
+    if (is_array(static::$data[LOC_USER])) {
743
+      foreach (static::$data[LOC_USER] as $user_id => $user_data) {
744
+        if (is_array($user_data) && isset($user_data['username'])) {
745 745
           // проверяем поле
746 746
           // TODO Возможно есть смысл всегда искать по strtolower - но может игрок захочет переименоваться с другим регистром? Проверить!
747
-          if((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe))) {
747
+          if ((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe))) {
748 748
             // $user_as_ally = intval($user_data['user_as_ally']);
749 749
             $user_as_ally = idval($user_data['user_as_ally']);
750
-            if($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally)) {
750
+            if ($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally)) {
751 751
               $user = $user_data;
752 752
               break;
753 753
             }
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
       }
757 757
     }
758 758
 
759
-    if($user === null) {
759
+    if ($user === null) {
760 760
       // Вытаскиваем запись
761 761
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
762 762
 
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
       // self::db_get_record_list(LOC_USER, "`username` " . ($like ? 'LIKE' : '='). " '{$username_safe}'");
765 765
 
766 766
       $user = static::db_query(
767
-        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'"
767
+        "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'"
768 768
         , true);
769 769
       static::cache_set(LOC_USER, $user['id'], $user); // В кэш-юзер так же заполнять индексы
770 770
     }
@@ -774,17 +774,17 @@  discard block
 block discarded – undo
774 774
 
775 775
   // UNUSED
776 776
   public static function db_get_user_by_email($email_unsafe, $use_both = false, $for_update = false, $fields = '*') {
777
-    if(!($email_unsafe = strtolower(trim($email_unsafe)))) {
777
+    if (!($email_unsafe = strtolower(trim($email_unsafe)))) {
778 778
       return false;
779 779
     }
780 780
 
781 781
     $user = null;
782 782
     // TODO переделать на индексы
783
-    if(is_array(static::$data[LOC_USER])) {
784
-      foreach(static::$data[LOC_USER] as $user_id => $user_data) {
785
-        if(is_array($user_data) && isset($user_data['email_2'])) {
783
+    if (is_array(static::$data[LOC_USER])) {
784
+      foreach (static::$data[LOC_USER] as $user_id => $user_data) {
785
+        if (is_array($user_data) && isset($user_data['email_2'])) {
786 786
           // проверяем поле
787
-          if(strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) {
787
+          if (strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) {
788 788
             $user = $user_data;
789 789
             break;
790 790
           }
@@ -792,11 +792,11 @@  discard block
 block discarded – undo
792 792
       }
793 793
     }
794 794
 
795
-    if($user === null) {
795
+    if ($user === null) {
796 796
       // Вытаскиваем запись
797 797
       $email_safe = db_escape($email_unsafe);
798 798
       $user = static::db_query(
799
-        "SELECT * FROM {{users}} WHERE LOWER(`email_2`) = '{$email_safe}'" .
799
+        "SELECT * FROM {{users}} WHERE LOWER(`email_2`) = '{$email_safe}'".
800 800
         ($use_both ? " OR LOWER(`email`) = '{$email_safe}'" : '')
801 801
         , true);
802 802
 
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
     $user = null;
812 812
     // TODO переделать на индексы
813 813
 
814
-    if($user === null && !empty($where_safe)) {
814
+    if ($user === null && !empty($where_safe)) {
815 815
       // Вытаскиваем запись
816 816
       $user = static::db_query("SELECT * FROM {{users}} WHERE {$where_safe}", true);
817 817
 
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
   public static function db_get_unit_by_id($unit_id, $for_update = false, $fields = '*') {
834 834
     // TODO запихивать в $data[LOC_LOCATION][$location_type][$location_id]
835 835
     $unit = static::db_get_record_by_id(LOC_UNIT, $unit_id, $for_update, $fields);
836
-    if(is_array($unit)) {
836
+    if (is_array($unit)) {
837 837
       static::$locator[LOC_UNIT][$unit['unit_location_type']][$unit['unit_location_id']][$unit['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
838 838
     }
839 839
 
@@ -849,15 +849,15 @@  discard block
 block discarded – undo
849 849
    */
850 850
   public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id) {
851 851
     //if(!($location_type = intval($location_type)) || !($location_id = intval($location_id))) return false;
852
-    if(!($location_type = idval($location_type)) || !($location_id = idval($location_id))) {
852
+    if (!($location_type = idval($location_type)) || !($location_id = idval($location_id))) {
853 853
       return false;
854 854
     }
855 855
 
856 856
     $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id];
857
-    if(!isset($query_cache)) {
858
-      $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions());
859
-      if(is_array($got_data)) {
860
-        foreach($got_data as $unit_id => $unit_data) {
857
+    if (!isset($query_cache)) {
858
+      $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".static::db_unit_time_restrictions());
859
+      if (is_array($got_data)) {
860
+        foreach ($got_data as $unit_id => $unit_data) {
861 861
           // static::$data[LOC_LOCATION][$location_type][$location_id][$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
862 862
           $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
863 863
         }
@@ -865,8 +865,8 @@  discard block
 block discarded – undo
865 865
     }
866 866
 
867 867
     $result = false;
868
-    if(is_array($query_cache)) {
869
-      foreach($query_cache as $key => $value) {
868
+    if (is_array($query_cache)) {
869
+      foreach ($query_cache as $key => $value) {
870 870
         $result[$key] = $value;
871 871
       }
872 872
     }
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
    *
902 902
    */
903 903
   public static function db_que_list_by_type_location($user_id, $planet_id = null, $que_type = false, $for_update = false) {
904
-    if(!$user_id) {
904
+    if (!$user_id) {
905 905
       pdump(debug_backtrace());
906 906
       die('No user_id for que_get_que()');
907 907
     }
@@ -911,16 +911,16 @@  discard block
 block discarded – undo
911 911
     $query = array();
912 912
 
913 913
     // if($user_id = intval($user_id))
914
-    if($user_id = idval($user_id)) {
914
+    if ($user_id = idval($user_id)) {
915 915
       $query[] = "`que_player_id` = {$user_id}";
916 916
     }
917 917
 
918
-    if($que_type == QUE_RESEARCH || $planet_id === null) {
918
+    if ($que_type == QUE_RESEARCH || $planet_id === null) {
919 919
       $query[] = "`que_planet_id` IS NULL";
920
-    } elseif($planet_id) {
921
-      $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")";
920
+    } elseif ($planet_id) {
921
+      $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")";
922 922
     }
923
-    if($que_type) {
923
+    if ($que_type) {
924 924
       $query[] = "`que_type` = {$que_type}";
925 925
     }
926 926
 
@@ -953,13 +953,13 @@  discard block
 block discarded – undo
953 953
 
954 954
 
955 955
   public static function db_changeset_prepare_unit($unit_id, $unit_value, $user, $planet_id = null) {
956
-    if(!is_array($user)) {
956
+    if (!is_array($user)) {
957 957
       // TODO - remove later
958 958
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER is not ARRAY</h1>');
959 959
       pdump(debug_backtrace());
960 960
       die('USER is not ARRAY');
961 961
     }
962
-    if(!isset($user['id']) || !$user['id']) {
962
+    if (!isset($user['id']) || !$user['id']) {
963 963
       // TODO - remove later
964 964
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER[id] пустой</h1>');
965 965
       pdump($user);
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 
975 975
     $db_changeset = array();
976 976
     $temp = db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
977
-    if($temp['unit_id']) {
977
+    if ($temp['unit_id']) {
978 978
       $db_changeset = array(
979 979
         'action'  => SQL_OP_UPDATE,
980 980
         P_VERSION => 1,
@@ -1043,9 +1043,9 @@  discard block
 block discarded – undo
1043 1043
   }
1044 1044
 
1045 1045
   public function db_changeset_condition_compile(&$conditions, &$table_name = '') {
1046
-    if(!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) {
1046
+    if (!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) {
1047 1047
       $conditions[P_LOCATION] = LOC_NONE;
1048
-      switch($table_name) {
1048
+      switch ($table_name) {
1049 1049
         case 'users':
1050 1050
         case LOC_USER:
1051 1051
           $conditions[P_TABLE_NAME] = $table_name = 'users';
@@ -1067,35 +1067,33 @@  discard block
 block discarded – undo
1067 1067
     }
1068 1068
 
1069 1069
     $conditions[P_FIELDS_STR] = '';
1070
-    if($conditions['fields']) {
1070
+    if ($conditions['fields']) {
1071 1071
       $fields = array();
1072
-      foreach($conditions['fields'] as $field_name => $field_data) {
1072
+      foreach ($conditions['fields'] as $field_name => $field_data) {
1073 1073
         $condition = "`{$field_name}` = ";
1074 1074
         $value = '';
1075
-        if($field_data['delta']) {
1076
-          $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta'];
1077
-        } elseif($field_data['set']) {
1075
+        if ($field_data['delta']) {
1076
+          $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta'];
1077
+        } elseif ($field_data['set']) {
1078 1078
           $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']);
1079 1079
         }
1080 1080
 
1081
-        if($value) {
1082
-          $fields[] = $condition . $value;
1081
+        if ($value) {
1082
+          $fields[] = $condition.$value;
1083 1083
         }
1084 1084
       }
1085 1085
       $conditions[P_FIELDS_STR] = implode(',', $fields);
1086 1086
     }
1087 1087
 
1088 1088
     $conditions[P_WHERE_STR] = '';
1089
-    if(!empty($conditions['where'])) {
1090
-      if($conditions[P_VERSION] == 1) {
1089
+    if (!empty($conditions['where'])) {
1090
+      if ($conditions[P_VERSION] == 1) {
1091 1091
         $the_conditions = array();
1092
-        foreach($conditions['where'] as $field_id => $field_value) {
1092
+        foreach ($conditions['where'] as $field_id => $field_value) {
1093 1093
           // Простое условие - $field_id = $field_value
1094
-          if(is_string($field_id)) {
1094
+          if (is_string($field_id)) {
1095 1095
             $field_value =
1096
-              $field_value === null ? 'NULL' :
1097
-                (is_string($field_value) ? "'" . db_escape($field_value) . "'" :
1098
-                  (is_bool($field_value) ? intval($field_value) : $field_value));
1096
+              $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value));
1099 1097
             $the_conditions[] = "`{$field_id}` = {$field_value}";
1100 1098
           } else {
1101 1099
             die('Неподдерживаемый тип условия');
@@ -1112,7 +1110,7 @@  discard block
 block discarded – undo
1112 1110
       $conditions[P_WHERE_STR] = implode(' AND ', $the_conditions);
1113 1111
     }
1114 1112
 
1115
-    switch($conditions['action']) {
1113
+    switch ($conditions['action']) {
1116 1114
       case SQL_OP_DELETE:
1117 1115
         $conditions[P_ACTION_STR] = ("DELETE FROM {{{$table_name}}}");
1118 1116
       break;
@@ -1127,16 +1125,16 @@  discard block
 block discarded – undo
1127 1125
         die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile');
1128 1126
     }
1129 1127
 
1130
-    $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]);
1128
+    $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]);
1131 1129
   }
1132 1130
 
1133 1131
   public static function db_changeset_apply($db_changeset, $flush_delayed = false) {
1134 1132
     $result = true;
1135
-    if(!is_array($db_changeset) || empty($db_changeset)) {
1133
+    if (!is_array($db_changeset) || empty($db_changeset)) {
1136 1134
       return $result;
1137 1135
     }
1138 1136
 
1139
-    foreach($db_changeset as $table_name => &$table_data) {
1137
+    foreach ($db_changeset as $table_name => &$table_data) {
1140 1138
       // TODO - delayed changeset
1141 1139
       /*
1142 1140
       if(static::db_transaction_check(false) && !$flush_delayed && ($table_name == 'users' || $table_name == 'planets' || $table_name == 'unit'))
@@ -1145,19 +1143,19 @@  discard block
 block discarded – undo
1145 1143
         continue;
1146 1144
       }
1147 1145
       */
1148
-      foreach($table_data as $record_id => &$conditions) {
1146
+      foreach ($table_data as $record_id => &$conditions) {
1149 1147
         static::db_changeset_condition_compile($conditions, $table_name);
1150 1148
 
1151
-        if($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) {
1149
+        if ($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) {
1152 1150
           continue;
1153 1151
         }
1154
-        if($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) {
1152
+        if ($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) {
1155 1153
           continue;
1156 1154
         } // Защита от случайного удаления всех данных в таблице
1157 1155
 
1158
-        if($conditions[P_LOCATION] != LOC_NONE) {
1156
+        if ($conditions[P_LOCATION] != LOC_NONE) {
1159 1157
           //die('spec ops supernova.php line 928 Добавить работу с кэшем юнитов итд');
1160
-          switch($conditions['action']) {
1158
+          switch ($conditions['action']) {
1161 1159
             case SQL_OP_DELETE:
1162 1160
               $result = self::db_del_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR]) && $result;
1163 1161
             break;
@@ -1239,13 +1237,13 @@  discard block
 block discarded – undo
1239 1237
   public static function init_0_prepare() {
1240 1238
     // Отключаем magic_quotes
1241 1239
     ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false;
1242
-    if(@get_magic_quotes_gpc()) {
1240
+    if (@get_magic_quotes_gpc()) {
1243 1241
       $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
1244
-      array_walk_recursive($gpcr, function (&$value, $key) {
1242
+      array_walk_recursive($gpcr, function(&$value, $key) {
1245 1243
         $value = stripslashes($value);
1246 1244
       });
1247 1245
     }
1248
-    if(function_exists('set_magic_quotes_runtime')) {
1246
+    if (function_exists('set_magic_quotes_runtime')) {
1249 1247
       @set_magic_quotes_runtime(0);
1250 1248
       @ini_set('magic_quotes_runtime', 0);
1251 1249
       @ini_set('magic_quotes_sybase', 0);
@@ -1285,7 +1283,7 @@  discard block
 block discarded – undo
1285 1283
   public static function init_3_load_config_file() {
1286 1284
     $dbsettings = array();
1287 1285
 
1288
-    require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
1286
+    require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
1289 1287
     //self::$db_prefix = $dbsettings['prefix'];
1290 1288
     self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix'];
1291 1289
     self::$db_name = $dbsettings['name'];
@@ -1317,7 +1315,7 @@  discard block
 block discarded – undo
1317 1315
   }
1318 1316
 
1319 1317
   public static function init_debug_state() {
1320
-    if($_SERVER['SERVER_NAME'] == 'localhost' && !defined('BE_DEBUG')) {
1318
+    if ($_SERVER['SERVER_NAME'] == 'localhost' && !defined('BE_DEBUG')) {
1321 1319
       define('BE_DEBUG', true);
1322 1320
     }
1323 1321
 // define('DEBUG_SQL_ONLINE', true); // Полный дамп запросов в рил-тайме. Подойдет любое значение
@@ -1329,7 +1327,7 @@  discard block
 block discarded – undo
1329 1327
     defined('DEBUG_SQL_ERROR') && !defined('DEBUG_SQL_COMMENT') ? define('DEBUG_SQL_COMMENT', true) : false;
1330 1328
     defined('DEBUG_SQL_COMMENT_LONG') && !defined('DEBUG_SQL_COMMENT') ? define('DEBUG_SQL_COMMENT', true) : false;
1331 1329
 
1332
-    if(defined('BE_DEBUG') || static::$config->debug) {
1330
+    if (defined('BE_DEBUG') || static::$config->debug) {
1333 1331
       @define('BE_DEBUG', true);
1334 1332
       @ini_set('display_errors', 1);
1335 1333
       @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
Please login to merge, or discard this patch.
includes/classes/UBE/UBE.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
    * Преобразовывает данные симулятора в данные для расчета боя
465 465
    *
466 466
    * @param     $side_info
467
-   * @param     $attacker
467
+   * @param     boolean $attacker
468 468
    * @param int $player_id
469 469
    *
470 470
    * @version 41a6.22
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
   }
573 573
 
574 574
   /**
575
-   * @param $template
575
+   * @param null|template $template
576 576
    *
577 577
    * @return template
578 578
    */
Please login to merge, or discard this patch.
Spacing   +48 added lines, -49 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     $this->players->db_load_player_by_id($player_id, UBE_PLAYER_IS_DEFENDER);
148 148
 
149 149
     $player_db_row = $this->players[$player_id]->getDbRow();
150
-    if($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) {
150
+    if ($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) {
151 151
       $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $fortifier_level);
152 152
     }
153 153
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     $this->rounds[0] = new UBERound(0);
180 180
     $this->rounds[0]->make_snapshot($this->fleet_list);
181 181
 
182
-    for($round = 1; $round <= 10; $round++) {
182
+    for ($round = 1; $round <= 10; $round++) {
183 183
       // Проводим раунд
184 184
       defined('DEBUG_UBE') ? print("Round {$round}<br>") : false;
185 185
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
       // Анализируем итоги текущего раунда и готовим данные для следующего
194 194
       $this->combat_result = $this->fleet_list->ubeAnalyzeFleetOutcome($round);
195
-      if($this->combat_result != UBE_COMBAT_RESULT_DRAW) {
195
+      if ($this->combat_result != UBE_COMBAT_RESULT_DRAW) {
196 196
         break;
197 197
       }
198 198
 
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
     // Генерируем результат боя
222 222
     $this->fleet_list->ube_analyze_fleets($this->is_simulator, $this->debris, $this->resource_exchange_rates);
223 223
 
224
-    if(!$this->is_ube_loaded) {
224
+    if (!$this->is_ube_loaded) {
225 225
       $this->moon_calculator->calculate_moon($this);
226 226
 
227 227
       // Лутаем ресурсы - если аттакер выиграл
228
-      if($this->combat_result == UBE_COMBAT_RESULT_WIN) {
228
+      if ($this->combat_result == UBE_COMBAT_RESULT_WIN) {
229 229
         $this->sn_ube_combat_analyze_loot();
230 230
       }
231 231
     }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
       RES_DEUTERIUM => 0,
246 246
     );
247 247
 
248
-    if(
248
+    if (
249 249
       (($planet_resource_total = $this->fleet_list[0]->get_resources_amount()) > 0)
250 250
       &&
251 251
       (($total_capacity = $this->fleet_list->ube_get_capacity_attackers()) > 0)
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
       $planet_lootable_percent = $planet_lootable / $planet_resource_total;
258 258
 
259 259
       // Вычисляем сколько ресурсов вывезено
260
-      foreach($this->fleet_list->_container as $fleet_id => $fleet) {
260
+      foreach ($this->fleet_list->_container as $fleet_id => $fleet) {
261 261
         $looted_in_metal = 0;
262
-        foreach($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) {
262
+        foreach ($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) {
263 263
           // Вычисляем какой процент общей емкости трюмов атакующих будет задействован
264 264
           $fleet_lootable_percent = $fleet->fleet_capacity / $total_capacity;
265 265
           $looted = floor($resource_amount * $planet_lootable_percent * $fleet_lootable_percent);
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
     $destination_user_id = $this->fleet_list[0]->owner_id;
326 326
 
327 327
     // Обновляем поле обломков на планете
328
-    if(!$this->is_admin_in_combat && $this->debris->debris_total() > 0) {
328
+    if (!$this->is_admin_in_combat && $this->debris->debris_total() > 0) {
329 329
       db_planet_set_by_gspt($this->ube_planet_info[PLANET_GALAXY], $this->ube_planet_info[PLANET_SYSTEM], $this->ube_planet_info[PLANET_PLANET], PT_PLANET,
330
-        "`debris_metal` = `debris_metal` + " . $this->debris->debris_get_resource(RES_METAL) . ", `debris_crystal` = `debris_crystal` + " . $this->debris->debris_get_resource(RES_CRYSTAL)
330
+        "`debris_metal` = `debris_metal` + ".$this->debris->debris_get_resource(RES_METAL).", `debris_crystal` = `debris_crystal` + ".$this->debris->debris_get_resource(RES_CRYSTAL)
331 331
       );
332 332
     }
333 333
 
334
-    foreach($this->fleet_list->_container as $fleet_id => $UBEFleet) {
334
+    foreach ($this->fleet_list->_container as $fleet_id => $UBEFleet) {
335 335
       $ship_count_lost = $UBEFleet->unit_list->unitCountLost();
336 336
 
337
-      if($fleet_id) {
337
+      if ($fleet_id) {
338 338
         // Флот
339 339
         $UBEFleet->db_save_combat_result_fleet($this->is_small_fleet_recce, $this->moon_calculator->get_reapers_status());
340 340
       } else {
@@ -342,19 +342,19 @@  discard block
 block discarded – undo
342 342
 
343 343
         // Сохраняем изменения ресурсов - если они есть
344 344
         $resource_delta = $UBEFleet->ube_combat_result_calculate_resources();
345
-        if(!empty($resource_delta)) {
345
+        if (!empty($resource_delta)) {
346 346
           $temp = array();
347
-          foreach($resource_delta as $resource_id => $resource_amount) {
347
+          foreach ($resource_delta as $resource_id => $resource_amount) {
348 348
             $resource_db_name = pname_resource_name($resource_id);
349 349
             $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})";
350 350
           }
351 351
           db_planet_set_by_id($this->ube_planet_info[PLANET_ID], implode(',', $temp));
352 352
         }
353 353
 
354
-        if($ship_count_lost) {
354
+        if ($ship_count_lost) {
355 355
           $db_changeset = array();
356 356
           $planet_row_cache = $this->players[$destination_user_id]->getDbRow();
357
-          foreach($UBEFleet->unit_list->_container as $UBEUnit) {
357
+          foreach ($UBEFleet->unit_list->_container as $UBEUnit) {
358 358
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($UBEUnit->unitId, -$UBEUnit->units_lost, $planet_row_cache, $this->ube_planet_info[PLANET_ID]);
359 359
           }
360 360
           db_changeset_apply($db_changeset);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
     // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL
366 366
     // Для САБов
367 367
     $fleet_group_id_list = $this->fleet_list->ube_get_groups();
368
-    if(!empty($fleet_group_id_list)) {
368
+    if (!empty($fleet_group_id_list)) {
369 369
       $fleet_group_id_list = implode(',', $fleet_group_id_list);
370 370
       db_acs_delete_by_list($fleet_group_id_list);
371 371
     }
@@ -374,19 +374,19 @@  discard block
 block discarded – undo
374 374
 
375 375
     $bashing_list = array();
376 376
     $players_sides = $this->players->get_player_sides();
377
-    foreach($players_sides as $player_id => $player_side) {
378
-      if($player_side != UBE_PLAYER_IS_ATTACKER) {
377
+    foreach ($players_sides as $player_id => $player_side) {
378
+      if ($player_side != UBE_PLAYER_IS_ATTACKER) {
379 379
         continue;
380 380
       }
381
-      if($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) {
381
+      if ($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) {
382 382
         $bashing_list[] = "({$player_id}, {$this->ube_planet_info[PLANET_ID]}, {$this->combat_timestamp})";
383 383
       }
384
-      if($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) {
384
+      if ($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) {
385 385
         $str_loose_or_win = $this->combat_result == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose';
386 386
         db_user_set_by_id($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1");
387 387
       }
388 388
     }
389
-    if(!empty($bashing_list)) {
389
+    if (!empty($bashing_list)) {
390 390
       $bashing_list = implode(',', $bashing_list);
391 391
       db_bashing_insert($bashing_list);
392 392
     }
@@ -413,20 +413,19 @@  discard block
 block discarded – undo
413 413
       $planet_info[PLANET_SYSTEM],
414 414
       $planet_info[PLANET_PLANET],
415 415
       htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'),
416
-      classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' :
417
-        ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')]
416
+      classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')]
418 417
     );
419 418
 
420 419
     $text_defender = '';
421 420
     $debris = $this->debris->get_debris();
422
-    foreach($debris as $resource_id => $resource_amount) {
423
-      if($resource_id == RES_DEUTERIUM) {
421
+    foreach ($debris as $resource_id => $resource_amount) {
422
+      if ($resource_id == RES_DEUTERIUM) {
424 423
         continue;
425 424
       }
426 425
 
427
-      $text_defender .= "{$classLocale['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />';
426
+      $text_defender .= "{$classLocale['tech'][$resource_id]}: ".pretty_number($resource_amount).'<br />';
428 427
     }
429
-    if($text_defender) {
428
+    if ($text_defender) {
430 429
       $text_defender = "{$classLocale['ube_report_msg_body_debris']}{$text_defender}<br />";
431 430
     }
432 431
 
@@ -436,8 +435,8 @@  discard block
 block discarded – undo
436 435
 
437 436
     // TODO: Оптимизировать отсылку сообщений - отсылать пакетами
438 437
     $player_sides = $this->players->get_player_sides();
439
-    foreach($player_sides as $player_id => $player_side) {
440
-      $message = $text_common . ($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender);
438
+    foreach ($player_sides as $player_id => $player_side) {
439
+      $message = $text_common.($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender);
441 440
       msg_send_simple_message($player_id, '', $this->combat_timestamp, MSG_TYPE_COMBAT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_attack_report'], $message);
442 441
     }
443 442
 
@@ -473,11 +472,11 @@  discard block
 block discarded – undo
473 472
     $player_id = $player_id == -1 ? $this->players->count() : $player_id;
474 473
     $fleet_id = $player_id; // FOR SIMULATOR!
475 474
 
476
-    if(empty($this->players[$player_id])) {
475
+    if (empty($this->players[$player_id])) {
477 476
       $this->players[$player_id] = new UBEPlayer();
478 477
     }
479 478
 
480
-    foreach($side_info as $fleet_data) {
479
+    foreach ($side_info as $fleet_data) {
481 480
       $this->players[$player_id]->name = $player_id;
482 481
       $this->players[$player_id]->setSide($attacker);
483 482
 
@@ -485,32 +484,32 @@  discard block
 block discarded – undo
485 484
       $this->fleet_list[$fleet_id] = $objFleet;
486 485
 
487 486
       $this->fleet_list[$fleet_id]->owner_id = $player_id;
488
-      foreach($fleet_data as $unit_id => $unit_count) {
489
-        if(!$unit_count) {
487
+      foreach ($fleet_data as $unit_id => $unit_count) {
488
+        if (!$unit_count) {
490 489
           continue;
491 490
         }
492 491
 
493 492
         $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
494 493
 
495
-        if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
494
+        if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
496 495
           $this->fleet_list[$fleet_id]->unit_list->unitAdjustCount($unit_id, $unit_count);
497
-        } elseif($unit_type == UNIT_RESOURCES) {
496
+        } elseif ($unit_type == UNIT_RESOURCES) {
498 497
           $this->fleet_list[$fleet_id]->resource_list[$unit_id] = $unit_count;
499
-        } elseif($unit_type == UNIT_TECHNOLOGIES) {
500
-          if($unit_id == TECH_WEAPON) {
498
+        } elseif ($unit_type == UNIT_TECHNOLOGIES) {
499
+          if ($unit_id == TECH_WEAPON) {
501 500
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_WEAPON, $unit_count);
502
-          } elseif($unit_id == TECH_SHIELD) {
501
+          } elseif ($unit_id == TECH_SHIELD) {
503 502
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_SHIELD, $unit_count);
504
-          } elseif($unit_id == TECH_ARMOR) {
503
+          } elseif ($unit_id == TECH_ARMOR) {
505 504
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_ARMOR, $unit_count);
506 505
           }
507
-        } elseif($unit_type == UNIT_GOVERNORS) {
508
-          if($unit_id == MRC_FORTIFIER) {
506
+        } elseif ($unit_type == UNIT_GOVERNORS) {
507
+          if ($unit_id == MRC_FORTIFIER) {
509 508
             // Фортифаер даёт бонус ко всему
510 509
             $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $unit_count);
511 510
           }
512
-        } elseif($unit_type == UNIT_MERCENARIES) {
513
-          if($unit_id == MRC_ADMIRAL) {
511
+        } elseif ($unit_type == UNIT_MERCENARIES) {
512
+          if ($unit_id == MRC_ADMIRAL) {
514 513
             $this->players[$player_id]->player_bonus->add_unit_by_snid(MRC_ADMIRAL, $unit_count);
515 514
           }
516 515
         }
@@ -565,7 +564,7 @@  discard block
 block discarded – undo
565 564
 
566 565
     $ube->sn_ube_message_send();
567 566
 
568
-    defined('DEBUG_UBE') ? die('DIE at ' . __FILE__ . ' ' . __LINE__) : false;
567
+    defined('DEBUG_UBE') ? die('DIE at '.__FILE__.' '.__LINE__) : false;
569 568
 
570 569
     return false;
571 570
   }
@@ -580,7 +579,7 @@  discard block
 block discarded – undo
580 579
 
581 580
     $ube_report = new UBEReport();
582 581
     $ube = $ube_report->sn_ube_report_load(sys_get_param_str('cypher'));
583
-    if($ube != UBE_REPORT_NOT_FOUND) {
582
+    if ($ube != UBE_REPORT_NOT_FOUND) {
584 583
       $ube_report->sn_ube_report_generate($ube, $template_result);
585 584
 
586 585
       $template = gettemplate('ube_combat_report', $template);
@@ -608,9 +607,9 @@  discard block
 block discarded – undo
608 607
     $ube->sn_ube_combat();
609 608
     $ube_report = new UBEReport();
610 609
 
611
-    if(sys_get_param_str('reload')) {
610
+    if (sys_get_param_str('reload')) {
612 611
       $ube_new = $ube_report->sn_ube_report_load($ube->get_cypher()); // $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]);
613
-      if($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) {
612
+      if ($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) {
614 613
         $ube = $ube_new;
615 614
       }
616 615
     }
@@ -658,7 +657,7 @@  discard block
 block discarded – undo
658 657
     $this->debris->load_from_report_row($report_row);
659 658
 
660 659
     $query = doquery("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
661
-    while($player_row = db_fetch($query)) {
660
+    while ($player_row = db_fetch($query)) {
662 661
       $this->players->init_player_from_report_info($player_row);
663 662
     }
664 663
 
Please login to merge, or discard this patch.
includes/classes/UBE/UBEFleetList.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -278,6 +278,9 @@
 block discarded – undo
278 278
     return count($this->ube_side_present_at_round_start);
279 279
   }
280 280
 
281
+  /**
282
+   * @param integer $round
283
+   */
281 284
   public function ubeAnalyzeFleetOutcome($round) {
282 285
     $this->ube_actualize_sides();
283 286
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
    */
83 83
   public function ube_db_load_fleets_outcome($report_row) {
84 84
     $query = doquery("SELECT * FROM {{ube_report_outcome_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
85
-    while($row = db_fetch($query)) {
85
+    while ($row = db_fetch($query)) {
86 86
       $fleet_id = $row['ube_report_outcome_fleet_fleet_id'];
87 87
       $this[$fleet_id]->load_outcome_from_report_row($row);
88 88
     }
89 89
 
90 90
     $query = doquery("SELECT * FROM {{ube_report_outcome_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_outcome_unit_sort_order`");
91
-    while($row = db_fetch($query)) {
91
+    while ($row = db_fetch($query)) {
92 92
       $fleet_id = $row['ube_report_outcome_unit_fleet_id'];
93 93
       $this[$fleet_id]->load_unit_outcome_from_row($row);
94 94
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
       UBE_PLAYER_IS_DEFENDER => array(),
109 109
     );
110 110
 
111
-    foreach($this->_container as $fleet_id => $UBEFleet) {
111
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
112 112
       $result[$UBEFleet->is_attacker][] = array(
113 113
         'ID'          => $fleet_id,
114 114
         'NAME'        => $ube->players[$UBEFleet->owner_id]->name,
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
    */
132 132
   public function ube_analyze_fleets($is_simulator, UBEDebris $debris, array $resource_exchange_rates) {
133 133
     // Генерируем результат боя
134
-    foreach($this->_container as $fleet_id => $UBEFleet) {
134
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
135 135
       // Инициализируем массив результатов для флота
136 136
 //      $this->init_fleet_outcome_and_link_to_side($UBEFleet);
137 137
 
138
-      foreach($UBEFleet->unit_list->_container as $UBEUnit) {
138
+      foreach ($UBEFleet->unit_list->_container as $UBEUnit) {
139 139
         $UBEUnit->ube_analyze_unit($is_simulator);
140 140
       }
141 141
 
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
       $this->resources_lost_in_metal = array(
153 153
         RES_METAL => 0,
154 154
       );
155
-      foreach($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) {
155
+      foreach ($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) {
156 156
         $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id];
157 157
       }
158
-      foreach($UBEFleet->cargo_dropped as $resource_id => $resource_amount) {
158
+      foreach ($UBEFleet->cargo_dropped as $resource_id => $resource_amount) {
159 159
         $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id];
160 160
       }
161 161
     }
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
    */
167 167
   public function ube_get_groups() {
168 168
     $result = array();
169
-    foreach($this->_container as $UBEFleet) {
170
-      if($UBEFleet->group_id) {
169
+    foreach ($this->_container as $UBEFleet) {
170
+      if ($UBEFleet->group_id) {
171 171
         $result[$UBEFleet->group_id] = $UBEFleet->group_id;
172 172
       }
173 173
     }
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
    */
181 181
   public function ube_get_capacity_attackers() {
182 182
     $result = 0;
183
-    foreach($this->_container as $UBEFleet) {
184
-      if($UBEFleet->is_attacker) {
183
+    foreach ($this->_container as $UBEFleet) {
184
+      if ($UBEFleet->is_attacker) {
185 185
         $result += $UBEFleet->fleet_capacity;
186 186
       }
187 187
     }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
    */
196 196
   public function ube_db_load_from_report_row(array $report_row, UBE $ube) {
197 197
     $query = doquery("SELECT * FROM {{ube_report_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
198
-    while($fleet_row = db_fetch($query)) {
198
+    while ($fleet_row = db_fetch($query)) {
199 199
       $objFleet = new UBEFleet();
200 200
       $objFleet->load_from_report($fleet_row, $ube);
201 201
       $this[$objFleet->db_id] = $objFleet;
@@ -209,20 +209,20 @@  discard block
 block discarded – undo
209 209
    * @version 2016-02-25 23:42:45 41a4.68
210 210
    */
211 211
   public function ube_prepare_for_next_round($is_simulator) {
212
-    foreach($this->_container as $fleet_id => $UBEFleet) {
212
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
213 213
       $UBEFleet->prepare_for_next_round($is_simulator);
214 214
     }
215 215
 
216 216
     // Суммируем данные по атакующим и защитникам
217 217
     $this->ube_total[UBE_PLAYER_IS_ATTACKER]->_reset();
218 218
     $this->ube_total[UBE_PLAYER_IS_DEFENDER]->_reset();
219
-    foreach($this->_container as $fleet_id => $UBEFleet) {
219
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
220 220
       $this->ube_total[$UBEFleet->is_attacker]->add_unit_stats_array($UBEFleet->total_stats);
221 221
     }
222 222
 //pvar_dump($this->ube_total);
223 223
 
224 224
     // Высчитываем долю атаки, приходящейся на юнит равную отношению брони юнита к общей броне - крупные цели атакуют чаще
225
-    foreach($this->_container as $fleet_id => $UBEFleet) {
225
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
226 226
       $UBEFleet->calculate_unit_partial_data($this->ube_total[$UBEFleet->is_attacker]);
227 227
     }
228 228
   }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
    */
237 237
   public function ube_calculate_attack_results(UBE $ube) {
238 238
     // Каждый флот атакует все
239
-    foreach($this->_container as $attack_fleet_data) {
239
+    foreach ($this->_container as $attack_fleet_data) {
240 240
       defined('DEBUG_UBE') ? print("Fleet {$attack_fleet_data->db_id} attacks<br /><div style='margin-left: 30px;'>") : false;
241 241
 
242 242
       $attack_fleet_data->attack_fleets($this, $ube->is_simulator);
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
    * @version 2016-02-25 23:42:45 41a4.68
252 252
    */
253 253
   public function ube_actualize_sides() {
254
-    foreach($this->_container as $UBEFleet) {
255
-      if($UBEFleet->get_unit_count() > 0) {
254
+    foreach ($this->_container as $UBEFleet) {
255
+      if ($UBEFleet->get_unit_count() > 0) {
256 256
         $this->ube_side_present_at_round_start[$UBEFleet->is_attacker] = 1;
257 257
       }
258 258
     }
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
    */
266 266
   public function ube_calculate_attack_reapers() {
267 267
     $reapers = 0;
268
-    foreach($this->_container as $fleet_id => $UBERoundFleetCombat) {
269
-      if($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) {
268
+    foreach ($this->_container as $fleet_id => $UBERoundFleetCombat) {
269
+      if ($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) {
270 270
         $reapers += $UBERoundFleetCombat->unit_list->unitCountReapers();
271 271
       }
272 272
     }
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
 
284 284
     $result = UBE_COMBAT_RESULT_DRAW;
285 285
     // Проверяем результат боя
286
-    if($this->ube_get_sides_count() == 0 || $round >= 10) {
286
+    if ($this->ube_get_sides_count() == 0 || $round >= 10) {
287 287
       // Если кого-то не осталось или не осталось обоих - заканчиваем цикл
288 288
       $result = UBE_COMBAT_RESULT_DRAW_END;
289
-    } elseif($this->ube_get_sides_count() == 1) {
289
+    } elseif ($this->ube_get_sides_count() == 1) {
290 290
       // Если осталась одна сторона - она и выиграла
291 291
       $result = isset($this->ube_side_present_at_round_start[UBE_PLAYER_IS_ATTACKER]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS;
292 292
     }
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
    * @version 41a6.16
304 304
    */
305 305
   public function ubeInitGetAttackers(Fleet $objFleet, UBEPlayerList $players) {
306
-    if($objFleet->group_id) {
306
+    if ($objFleet->group_id) {
307 307
       $fleets_added = $this->dbLoadWhere("`fleet_group` = {$objFleet->group_id}");
308 308
     } else {
309 309
       $this->ube_insert_from_Fleet($objFleet);
Please login to merge, or discard this patch.
includes/classes/UBE/UBEReport.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
   /**
8 8
    * @param UBE $ube
9 9
    *
10
-   * @return bool|string
10
+   * @return false|string
11 11
    *
12 12
    * @version 2016-02-25 23:42:45 41a4.68
13 13
    */
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
   // ------------------------------------------------------------------------------------------------
187 187
   // Читает боевой отчет из БД
188 188
   /**
189
-   * @param $report_cypher
189
+   * @param string $report_cypher
190 190
    *
191 191
    * @return string|UBE
192 192
    */
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
    */
14 14
   function sn_ube_report_save($ube) {
15 15
     // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем
16
-    if($ube->get_cypher()) {
16
+    if ($ube->get_cypher()) {
17 17
       return false;
18 18
     }
19 19
 
20 20
     // Генерируем уникальный секретный ключ и проверяем наличие в базе
21 21
     do {
22 22
       $ube->report_cypher = sys_random_string(32);
23
-    } while(doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true));
23
+    } while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE", true));
24 24
 
25 25
     // Инициализация таблицы для пакетной вставки информации
26 26
     $sql_perform = array(
@@ -108,24 +108,24 @@  discard block
 block discarded – undo
108 108
     $sql_str = "INSERT INTO `{{ube_report}}`
109 109
     SET
110 110
       `ube_report_cypher` = '{$ube->report_cypher}',
111
-      `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $ube->combat_timestamp) . "',
111
+      `ube_report_time_combat` = '".date(FMT_DATE_TIME_SQL, $ube->combat_timestamp)."',
112 112
       `ube_report_time_spent` = {$ube->time_spent},
113 113
 
114
-      `ube_report_combat_admin` = " . (int)$ube->is_admin_in_combat . ",
114
+      `ube_report_combat_admin` = ".(int) $ube->is_admin_in_combat.",
115 115
       `ube_report_mission_type` = {$ube->mission_type_id},
116 116
 
117 117
       `ube_report_combat_result` = {$ube->combat_result},
118
-      `ube_report_combat_sfr` = " . (int)$ube->is_small_fleet_recce . ",
118
+      `ube_report_combat_sfr` = ".(int) $ube->is_small_fleet_recce.",
119 119
 
120
-      `ube_report_planet_id`          = " . (int)$ube->ube_planet_info[PLANET_ID] . ",
121
-      `ube_report_planet_name`        = '" . db_escape($ube->ube_planet_info[PLANET_NAME]) . "',
122
-      `ube_report_planet_size`        = " . (int)$ube->ube_planet_info[PLANET_SIZE] . ",
123
-      `ube_report_planet_galaxy`      = " . (int)$ube->ube_planet_info[PLANET_GALAXY] . ",
124
-      `ube_report_planet_system`      = " . (int)$ube->ube_planet_info[PLANET_SYSTEM] . ",
125
-      `ube_report_planet_planet`      = " . (int)$ube->ube_planet_info[PLANET_PLANET] . ",
126
-      `ube_report_planet_planet_type` = " . (int)$ube->ube_planet_info[PLANET_TYPE] . ",
120
+      `ube_report_planet_id`          = " . (int) $ube->ube_planet_info[PLANET_ID].",
121
+      `ube_report_planet_name`        = '" . db_escape($ube->ube_planet_info[PLANET_NAME])."',
122
+      `ube_report_planet_size`        = " . (int) $ube->ube_planet_info[PLANET_SIZE].",
123
+      `ube_report_planet_galaxy`      = " . (int) $ube->ube_planet_info[PLANET_GALAXY].",
124
+      `ube_report_planet_system`      = " . (int) $ube->ube_planet_info[PLANET_SYSTEM].",
125
+      `ube_report_planet_planet`      = " . (int) $ube->ube_planet_info[PLANET_PLANET].",
126
+      `ube_report_planet_planet_type` = " . (int) $ube->ube_planet_info[PLANET_TYPE].",
127 127
 
128
-      `ube_report_capture_result` = " . (int)$ube->capture_result . ", "
128
+      `ube_report_capture_result` = " . (int) $ube->capture_result.", "
129 129
       . $ube->debris->report_generate_sql()
130 130
       . $ube->moon_calculator->report_generate_sql();
131 131
 
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
 
135 135
     // Сохраняем общую информацию по игрокам
136 136
     $player_sides = $ube->players->get_player_sides();
137
-    foreach($player_sides as $player_id => $player_side) {
137
+    foreach ($player_sides as $player_id => $player_side) {
138 138
       $sql_perform['ube_report_player'][] = array(
139 139
         $ube_report_id,
140 140
         $player_id,
141 141
 
142
-        "'" . db_escape($ube->players[$player_id]->name) . "'",
142
+        "'".db_escape($ube->players[$player_id]->name)."'",
143 143
         $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0,
144 144
 
145
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
146
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
147
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
145
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
146
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
147
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
148 148
       );
149 149
     }
150 150
 
151 151
     // Всякая информация по флотам
152
-    foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
152
+    foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
153 153
       // Сохраняем общую информацию по флотам
154 154
       $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id);
155 155
 
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
     $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list);
166 166
 
167 167
     // Пакетная вставка данных
168
-    foreach($sql_perform as $table_name => $table_data) {
169
-      if(count($table_data) < 2) {
168
+    foreach ($sql_perform as $table_name => $table_data) {
169
+      if (count($table_data) < 2) {
170 170
         continue;
171 171
       }
172
-      foreach($table_data as &$record_data) {
173
-        $record_data = '(' . implode(',', $record_data) . ')';
172
+      foreach ($table_data as &$record_data) {
173
+        $record_data = '('.implode(',', $record_data).')';
174 174
       }
175 175
       $fields = $table_data[0];
176 176
       unset($table_data[0]);
177
-      doquery("INSERT INTO {{{$table_name}}} {$fields} VALUES " . implode(',', $table_data));
177
+      doquery("INSERT INTO {{{$table_name}}} {$fields} VALUES ".implode(',', $table_data));
178 178
     }
179 179
 
180 180
     return $ube->report_cypher;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     $report_cypher = db_escape($report_cypher);
193 193
 
194 194
     $report_row = doquery("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1", true);
195
-    if(!$report_row) {
195
+    if (!$report_row) {
196 196
       return UBE_REPORT_NOT_FOUND;
197 197
     }
198 198
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
    * @param     $template_result
209 209
    */
210 210
   function sn_ube_report_generate(UBE $ube, &$template_result) {
211
-    if(!is_object($ube)) {
211
+    if (!is_object($ube)) {
212 212
       return;
213 213
     }
214 214
 
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
 
224 224
     // Координаты, тип и название планеты - если есть
225 225
 //R  $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER];
226
-    if(isset($ube->ube_planet_info)) {
226
+    if (isset($ube->ube_planet_info)) {
227 227
       $template_result += $ube->ube_planet_info;
228 228
       $template_result[PLANET_NAME] = str_replace(' ', '&nbsp;', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8'));
229 229
     }
230 230
 
231 231
     // Обломки
232 232
     $debris = array();
233
-    foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) {
234
-      if($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
233
+    foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) {
234
+      if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
235 235
         $debris[] = array(
236 236
           'NAME'   => classLocale::$lang['tech'][$resource_id],
237 237
           'AMOUNT' => pretty_number($resource_amount),
Please login to merge, or discard this patch.
includes/db/db_queries_ally.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -293,7 +293,7 @@
 block discarded – undo
293 293
 }
294 294
 
295 295
 /**
296
- * @param $ranklist
296
+ * @param string $ranklist
297 297
  * @param $user
298 298
  */
299 299
 function db_ally_update_ranklist($ranklist, $user) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
     `ally_name` = '{$ally_name}',
65 65
     `ally_tag` = '{$ally_tag}',
66 66
     `ally_owner` = '{$user['id']}',
67
-    `ally_owner_range` = '" . classLocale::$lang['ali_leaderRank'] . "',
67
+    `ally_owner_range` = '".classLocale::$lang['ali_leaderRank']."',
68 68
     `ally_members` = 1,
69
-    `ranklist` = '" . classLocale::$lang['ali_defaultRankName'] . ",0,0,0,0,0',
69
+    `ranklist` = '" . classLocale::$lang['ali_defaultRankName'].",0,0,0,0,0',
70 70
     `ally_register_time`= " . SN_TIME_NOW
71 71
   );
72 72
 }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
  * @param $POST_text
86 86
  */
87 87
 function db_ally_request_insert($user, $id_ally, $POST_text) {
88
-  doquery("INSERT INTO {{alliance_requests}} SET `id_user` = {$user['id']}, `id_ally`='{$id_ally}', request_text ='{$POST_text}', request_time=" . SN_TIME_NOW . ";");
88
+  doquery("INSERT INTO {{alliance_requests}} SET `id_user` = {$user['id']}, `id_ally`='{$id_ally}', request_text ='{$POST_text}', request_time=".SN_TIME_NOW.";");
89 89
 }
90 90
 
91 91
 /**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
  * @param $ally
136 136
  */
137 137
 function db_ally_update_by_changeset($ally_changeset, $ally) {
138
-  doquery("UPDATE {{alliance}} SET " . implode(',', $ally_changeset) . " WHERE `id`='{$ally['id']}' LIMIT 1;");
138
+  doquery("UPDATE {{alliance}} SET ".implode(',', $ally_changeset)." WHERE `id`='{$ally['id']}' LIMIT 1;");
139 139
 }
140 140
 
141 141
 /**
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
  * @param $d
247 247
  */
248 248
 function db_ally_request_deny($d) {
249
-  doquery("UPDATE {{alliance_requests}} SET `request_denied` = 1, `request_text` = '" . classLocale::$lang['ali_req_deny_reason'] . "' WHERE `id_user`= {$d} LIMIT 1;");
249
+  doquery("UPDATE {{alliance_requests}} SET `request_denied` = 1, `request_text` = '".classLocale::$lang['ali_req_deny_reason']."' WHERE `id_user`= {$d} LIMIT 1;");
250 250
 }
251 251
 
252 252
 /**
Please login to merge, or discard this patch.
includes/db/db_queries_chat.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 
18 18
 /**
19 19
  * @param $user_id
20
- * @param $nick
20
+ * @param string $nick
21 21
  * @param $ally_id
22
- * @param $message
22
+ * @param string $message
23 23
  * @param $chat_message_sender_name
24 24
  * @param $chat_message_recipient_id
25 25
  * @param $chat_message_recipient_name
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  * @param $alliance
56 56
  * @param $where_add
57 57
  * @param $start_row
58
- * @param $page_limit
58
+ * @param integer $page_limit
59 59
  *
60 60
  * @return array|bool|mysqli_result|null
61 61
  */
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
       JOIN {{users}} AS u ON u.id = cp.chat_player_player_id
11 11
     WHERE
12 12
       `chat_player_refresh_last` >= '{$sql_date}'
13
-      AND (`banaday` IS NULL OR `banaday` <= " . SN_TIME_NOW . ")
13
+      AND (`banaday` IS NULL OR `banaday` <= ".SN_TIME_NOW.")
14 14
       {$ally_add}
15 15
     ORDER BY authlevel DESC, `username`");
16 16
 }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
           `user` = '{$nick}',
34 34
           `ally_id` = '{$ally_id}',
35 35
           `message` = '{$message}',
36
-          `timestamp` = " . SN_TIME_NOW . ",
36
+          `timestamp` = ".SN_TIME_NOW.",
37 37
           `chat_message_sender_name` = '{$chat_message_sender_name}',
38 38
           `chat_message_recipient_id` = {$chat_message_recipient_id},
39 39
           `chat_message_recipient_name` = '{$chat_message_recipient_name}'"
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
  * @param $user
140 140
  */
141 141
 function db_chat_player_update($user) {
142
-  doquery("UPDATE {{chat_player}} SET `chat_player_refresh_last` = " . SN_TIME_NOW . " WHERE `chat_player_player_id` = {$user['id']} LIMIT 1;");
142
+  doquery("UPDATE {{chat_player}} SET `chat_player_refresh_last` = ".SN_TIME_NOW." WHERE `chat_player_player_id` = {$user['id']} LIMIT 1;");
143 143
 }
144 144
 
145 145
 
@@ -211,5 +211,5 @@  discard block
 block discarded – undo
211 211
  * @param $user
212 212
  */
213 213
 function db_chat_player_update_activity($user) {
214
-  doquery("UPDATE {{chat_player}} SET `chat_player_activity` = '" . classSupernova::$db->db_escape(SN_TIME_SQL) . "' WHERE `chat_player_player_id` = {$user['id']} LIMIT 1");
214
+  doquery("UPDATE {{chat_player}} SET `chat_player_activity` = '".classSupernova::$db->db_escape(SN_TIME_SQL)."' WHERE `chat_player_player_id` = {$user['id']} LIMIT 1");
215 215
 }
Please login to merge, or discard this patch.
includes/db/db_queries_news_and_surveys.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 }
80 80
 
81 81
 /**
82
- * @param $template
83
- * @param $query_where
84
- * @param $query_limit
82
+ * @param template $template
83
+ * @param string $query_where
84
+ * @param integer $query_limit
85 85
  *
86 86
  * @return array|bool|mysqli_result|null
87 87
  */
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
  * @param $user
106 106
  * @param $survey_id
107 107
  * @param $survey_vote_id
108
- * @param $user_name_safe
108
+ * @param string $user_name_safe
109 109
  */
110 110
 function db_survey_vote_insert(&$user, $survey_id, $survey_vote_id, $user_name_safe) {
111 111
   doquery("INSERT INTO {{survey_votes}} SET `survey_parent_id` = {$survey_id}, `survey_parent_answer_id` = {$survey_vote_id}, `survey_vote_user_id` = {$user['id']}, `survey_vote_user_name` = '{$user_name_safe}';");
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 function db_news_insert_set($announce_time, $text, $detail_url, $user) {
13 13
   doquery("INSERT INTO {{announce}}
14 14
         SET `tsTimeStamp` = FROM_UNIXTIME({$announce_time}), `strAnnounce`='{$text}', detail_url = '{$detail_url}',
15
-        `user_id` = {$user['id']}, `user_name` = '" . db_escape($user['username']) . "'");
15
+        `user_id` = {$user['id']}, `user_name` = '".db_escape($user['username'])."'");
16 16
 }
17 17
 
18 18
 function db_survey_insert($announce_id, $survey_question, $survey_until) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
       LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce
94 94
       LEFT JOIN {{users}} AS u ON u.id = a.user_id
95 95
     {$query_where}
96
-    ORDER BY `tsTimeStamp` DESC, idAnnounce" .
96
+    ORDER BY `tsTimeStamp` DESC, idAnnounce".
97 97
     ($query_limit ? " LIMIT {$query_limit}" : ''));
98 98
 
99 99
   $template->assign_var('NEWS_COUNT', db_num_rows($announce_list));
Please login to merge, or discard this patch.