Completed
Push — work-fleets ( 9e446e...674b8a )
by SuperNova.WS
12:48 queued 05:50
created
classes/DBStatic/DBStaticPlanet.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@
 block discarded – undo
68 68
     $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0;
69 69
     $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0;
70 70
     $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0;
71
-    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) :
72
-      (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
71
+    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
73 72
     $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type;
74 73
 
75 74
     return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields);
Please login to merge, or discard this patch.
classes/DBStatic/DBStaticUnit.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
     $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
210 210
     if (!empty($temp['unit_id'])) {
211
-      $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_by_id(
211
+      $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_by_id(
212 212
         LOC_UNIT,
213 213
         $temp['unit_id'],
214 214
         array(),
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
     } else {
220 220
       $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id;
221 221
       $unitType = get_unit_param($unit_id, P_UNIT_TYPE);
222
-      $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record(
222
+      $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record(
223 223
         LOC_UNIT,
224 224
         array(
225 225
           'unit_player_id'     => $user['id'],
226
-          'unit_location_type' => (int)$unit_location,
226
+          'unit_location_type' => (int) $unit_location,
227 227
           'unit_location_id'   => $locationIdRendered,
228
-          'unit_type'          => (int)$unitType,
229
-          'unit_snid'          => (int)$unit_id,
230
-          'unit_level'         => (float)$unit_value,
228
+          'unit_type'          => (int) $unitType,
229
+          'unit_snid'          => (int) $unit_id,
230
+          'unit_level'         => (float) $unit_value,
231 231
         )
232 232
       );
233 233
     }
Please login to merge, or discard this patch.
classes/DBStatic/DBStaticAlly.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,12 +77,12 @@
 block discarded – undo
77 77
    */
78 78
   public static function db_ally_insert($ally_name_unsafe, $ally_tag_unsafe, $userId) {
79 79
     $ally = classSupernova::$db->doInsertSet(TABLE_ALLIANCE, array(
80
-      'ally_name'          => (string)$ally_name_unsafe,
81
-      'ally_tag'           => (string)$ally_tag_unsafe,
80
+      'ally_name'          => (string) $ally_name_unsafe,
81
+      'ally_tag'           => (string) $ally_tag_unsafe,
82 82
       'ally_owner'         => $userId,
83
-      'ally_owner_range'   => (string)classLocale::$lang['ali_leaderRank'],
84
-      'ally_members'       => (int)1,
85
-      'ranklist'           => (string)(classLocale::$lang['ali_defaultRankName'] . ",0,0,0,0,0"),
83
+      'ally_owner_range'   => (string) classLocale::$lang['ali_leaderRank'],
84
+      'ally_members'       => (int) 1,
85
+      'ranklist'           => (string) (classLocale::$lang['ali_defaultRankName'] . ",0,0,0,0,0"),
86 86
       'ally_register_time' => SN_TIME_NOW,
87 87
     ));
88 88
 
Please login to merge, or discard this patch.
classes/DbQueryConstructor.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
   // TODO - rewrite
232 232
   public function getParamsFromStaticClass($className) {
233 233
     if (is_string($className) && $className && class_exists($className)) {
234
-      if(method_exists($className, 'getDb')) {
234
+      if (method_exists($className, 'getDb')) {
235 235
         $this->setDb($className::getDb());
236 236
       }
237 237
       $this->from($className::$_table);
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
    */
399 399
   protected function processField($fieldName) {
400 400
     if (is_bool($fieldName)) {
401
-      $result = (string)intval($fieldName);
401
+      $result = (string) intval($fieldName);
402 402
     } elseif (is_numeric($fieldName)) {
403 403
       $result = $fieldName;
404 404
     } elseif (is_null($fieldName)) {
405 405
       $result = 'NULL';
406 406
     } else {
407 407
       // Field has other type - string or should be convertible to string
408
-      $result = (string)$fieldName;
408
+      $result = (string) $fieldName;
409 409
       if (!$fieldName instanceof DbSqlLiteral) {
410 410
         $result = $this->quoteField($fieldName);
411 411
       }
Please login to merge, or discard this patch.
classes/UnitList.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@
 block discarded – undo
248 248
    */
249 249
   public function unitsCostInMetal($shipCostInMetalPerPiece) {
250 250
     $shipsCostInMetal = array();
251
-    foreach($this->mapUnitIdToDb as $ship_id => $ship) {
251
+    foreach ($this->mapUnitIdToDb as $ship_id => $ship) {
252 252
       $shipsCostInMetal[$ship_id] = $ship->count * $shipCostInMetalPerPiece[$ship_id];
253 253
     }
254 254
 
Please login to merge, or discard this patch.
classes/debug.php 1 patch
Spacing   +39 added lines, -40 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 defined('INSIDE') || die();
34 34
 
35
-if(php_sapi_name() == "cli") {
35
+if (php_sapi_name() == "cli") {
36 36
   // In cli-mode
37 37
   define('__DEBUG_CRLF', "\r\n");
38 38
   define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF);
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
   public function log_file($message, $ident_change = 0) {
53 53
     static $ident = 0;
54 54
 
55
-    if(!defined('SN_DEBUG_LOG')) {
55
+    if (!defined('SN_DEBUG_LOG')) {
56 56
       return;
57 57
     }
58 58
 
59
-    if($this->log_file_handler === null) {
59
+    if ($this->log_file_handler === null) {
60 60
       $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
61 61
       @fwrite($this->log_file_handler, "\r\n\r\n");
62 62
     }
63 63
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
64
-    if($this->log_file_handler) {
64
+    if ($this->log_file_handler) {
65 65
       @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
66 66
     }
67 67
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
     $result = array();
93 93
     $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId();
94 94
     $result[] = "tID {$transaction_id}";
95
-    foreach($backtrace as $a_trace) {
96
-      if(in_array($a_trace['function'], $exclude_functions)) {
95
+    foreach ($backtrace as $a_trace) {
96
+      if (in_array($a_trace['function'], $exclude_functions)) {
97 97
         continue;
98 98
       }
99 99
       $function =
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
       // $result[] = "{$function} ({$a_trace['line']})'{$file}'";
111 111
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
112 112
 
113
-      if(!$long_comment) {
113
+      if (!$long_comment) {
114 114
         break;
115 115
       }
116 116
     }
@@ -131,26 +131,26 @@  discard block
 block discarded – undo
131 131
   public function dump($dump = false, $force_base = false, $deadlock = false) {
132 132
     global $user, $planetrow;
133 133
 
134
-    if($dump === false) {
134
+    if ($dump === false) {
135 135
       return;
136 136
     }
137 137
 
138 138
     $error_backtrace = array();
139 139
     $base_dump = false;
140 140
 
141
-    if($force_base === true) {
141
+    if ($force_base === true) {
142 142
       $base_dump = true;
143 143
     }
144 144
 
145
-    if($dump === true) {
145
+    if ($dump === true) {
146 146
       $base_dump = true;
147 147
     } else {
148
-      if(!is_array($dump)) {
148
+      if (!is_array($dump)) {
149 149
         $dump = array('var' => $dump);
150 150
       }
151 151
 
152
-      foreach($dump as $dump_var_name => $dump_var) {
153
-        if($dump_var_name == 'base_dump') {
152
+      foreach ($dump as $dump_var_name => $dump_var) {
153
+        if ($dump_var_name == 'base_dump') {
154 154
           $base_dump = $dump_var;
155 155
         } else {
156 156
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -158,22 +158,21 @@  discard block
 block discarded – undo
158 158
       }
159 159
     }
160 160
 
161
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
161
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
162 162
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
163 163
       $error_backtrace['locks'] = classSupernova::$gc->snCache->getLocks();
164 164
       $error_backtrace['cSN_data'] = classSupernova::$gc->snCache->getData();
165
-      foreach($error_backtrace['cSN_data'] as &$location) {
166
-        foreach($location as $location_id => &$location_data) {
167
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
168
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
165
+      foreach ($error_backtrace['cSN_data'] as &$location) {
166
+        foreach ($location as $location_id => &$location_data) {
167
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
169 168
         }
170 169
       }
171 170
       $error_backtrace['cSN_queries'] = classSupernova::$gc->snCache->getQueries();
172 171
     }
173 172
 
174
-    if($base_dump) {
175
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
176
-        foreach($this->log_array as $log) {
173
+    if ($base_dump) {
174
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
175
+        foreach ($this->log_array as $log) {
177 176
           $error_backtrace['queries'][] = $log;
178 177
         }
179 178
       }
@@ -202,14 +201,14 @@  discard block
 block discarded – undo
202 201
   public function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
203 202
     global $sys_stop_log_hit, $sys_log_disabled, $user;
204 203
 
205
-    if(empty(classSupernova::$db->connected)) {
204
+    if (empty(classSupernova::$db->connected)) {
206 205
       // TODO - писать ошибку в файл
207 206
       die('SQL server currently unavailable. Please contact Administration...');
208 207
     }
209 208
 
210 209
     sn_db_transaction_rollback();
211 210
 
212
-    if(classSupernova::$config->debug == 1) {
211
+    if (classSupernova::$config->debug == 1) {
213 212
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
214 213
       echo "<table>{$this->log}</table>";
215 214
     }
@@ -221,7 +220,7 @@  discard block
 block discarded – undo
221 220
 
222 221
     $userId = empty($user['id']) ? 0 : $user['id'];
223 222
 
224
-    if(!$sys_log_disabled) {
223
+    if (!$sys_log_disabled) {
225 224
       $query = "INSERT INTO `{{logs}}` SET
226 225
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "',
227 226
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -240,7 +239,7 @@  discard block
 block discarded – undo
240 239
       ob_start();
241 240
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
242 241
 
243
-      foreach($error_backtrace as $name => $value) {
242
+      foreach ($error_backtrace as $name => $value) {
244 243
         print(__DEBUG_LINE);
245 244
         pdump($value, $name);
246 245
       }
@@ -258,7 +257,7 @@  discard block
 block discarded – undo
258 257
   public function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
259 258
     global $user, $sys_log_disabled;
260 259
 
261
-    if(empty(classSupernova::$db->connected)) {
260
+    if (empty(classSupernova::$db->connected)) {
262 261
       // TODO - писать ошибку в файл
263 262
       die('SQL server currently unavailable. Please contact Administration...');
264 263
     }
@@ -267,7 +266,7 @@  discard block
 block discarded – undo
267 266
 
268 267
     $userId = empty($user['id']) ? 0 : $user['id'];
269 268
 
270
-    if(!$sys_log_disabled) {
269
+    if (!$sys_log_disabled) {
271 270
       $query = "INSERT INTO `{{logs}}` SET
272 271
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "',
273 272
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -285,11 +284,11 @@  discard block
 block discarded – undo
285 284
 // Dump variables nicer then var_dump()
286 285
 
287 286
 function dump($value, $varname = null, $level = 0, $dumper = '') {
288
-  if(isset($varname)) {
287
+  if (isset($varname)) {
289 288
     $varname .= " = ";
290 289
   }
291 290
 
292
-  if($level == -1) {
291
+  if ($level == -1) {
293 292
     $trans[' '] = '&there4;';
294 293
     $trans["\t"] = '&rArr;';
295 294
     $trans["\n"] = '&para;;';
@@ -298,7 +297,7 @@  discard block
 block discarded – undo
298 297
 
299 298
     return strtr(htmlspecialchars($value), $trans);
300 299
   }
301
-  if($level == 0) {
300
+  if ($level == 0) {
302 301
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
303 302
     $dumper = mt_rand(10, 99) . '|' . $varname;
304 303
   }
@@ -306,22 +305,22 @@  discard block
 block discarded – undo
306 305
   $type = gettype($value);
307 306
   $dumper .= $type;
308 307
 
309
-  if($type == TYPE_STRING) {
308
+  if ($type == TYPE_STRING) {
310 309
     $dumper .= '(' . strlen($value) . ')';
311 310
     $value = dump($value, '', -1);
312
-  } elseif($type == TYPE_BOOLEAN) {
311
+  } elseif ($type == TYPE_BOOLEAN) {
313 312
     $value = ($value ? 'true' : 'false');
314
-  } elseif($type == 'object') {
313
+  } elseif ($type == 'object') {
315 314
     $props = get_class_vars(get_class($value));
316 315
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
317
-    foreach($props as $key => $val) {
316
+    foreach ($props as $key => $val) {
318 317
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
319 318
       $dumper .= dump($value->$key, '', $level + 1);
320 319
     }
321 320
     $value = '';
322
-  } elseif($type == TYPE_ARRAY) {
321
+  } elseif ($type == TYPE_ARRAY) {
323 322
     $dumper .= '(' . count($value) . ')';
324
-    foreach($value as $key => $val) {
323
+    foreach ($value as $key => $val) {
325 324
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
326 325
       $dumper .= dump($val, '', $level + 1);
327 326
     }
@@ -341,7 +340,7 @@  discard block
 block discarded – undo
341 340
 //  $backtrace = $backtrace[1];
342 341
 
343 342
   $caller = '';
344
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
343
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
345 344
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
346 345
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
347 346
       $backtrace[1]['function'] .
@@ -368,7 +367,7 @@  discard block
 block discarded – undo
368 367
 }
369 368
 
370 369
 function pr($prePrint = false) {
371
-  if($prePrint) {
370
+  if ($prePrint) {
372 371
     print(__DEBUG_CRLF);
373 372
   }
374 373
   print(mt_rand() . __DEBUG_CRLF);
@@ -378,7 +377,7 @@  discard block
 block discarded – undo
378 377
   global $_PRINT_COUNT_VALUE;
379 378
   $_PRINT_COUNT_VALUE++;
380 379
 
381
-  if($prePrint) {
380
+  if ($prePrint) {
382 381
     print(__DEBUG_CRLF);
383 382
   }
384 383
   print($_PRINT_COUNT_VALUE . __DEBUG_CRLF);
@@ -409,7 +408,7 @@  discard block
 block discarded – undo
409 408
  */
410 409
 function pdie($message = '', $level = 0) {
411 410
   $backtrace = debug_backtrace();
412
-  for($i = 0; $i < $level; $i++) {
411
+  for ($i = 0; $i < $level; $i++) {
413 412
     array_pop($backtrace);
414 413
   }
415 414
 
Please login to merge, or discard this patch.
classes/PropertyHider.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
    * @return string
278 278
    */
279 279
   protected function adjustPropertyString($name, $diff) {
280
-    return (string)$this->$name . (string)$diff;
280
+    return (string) $this->$name . (string) $diff;
281 281
   }
282 282
 
283 283
   /**
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
    * @return array
288 288
    */
289 289
   protected function adjustPropertyArray($name, $diff) {
290
-    $copy = (array)$this->$name;
291
-    HelperArray::merge($copy, (array)$diff, HelperArray::MERGE_PHP);
290
+    $copy = (array) $this->$name;
291
+    HelperArray::merge($copy, (array) $diff, HelperArray::MERGE_PHP);
292 292
 
293 293
     return $copy;
294 294
   }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
    * @return int
301 301
    */
302 302
   protected function deltaInteger($name, $diff) {
303
-    return (int)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0) + (int)$diff;
303
+    return (int) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0) + (int) $diff;
304 304
   }
305 305
 
306 306
   /**
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
    * @return float
311 311
    */
312 312
   protected function deltaDouble($name, $diff) {
313
-    return (float)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0.0) + (float)$diff;
313
+    return (float) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0.0) + (float) $diff;
314 314
   }
315 315
 
316 316
   /**
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
    * @return string
321 321
    */
322 322
   protected function deltaString($name, $diff) {
323
-    return (string)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, '') . (string)$diff;
323
+    return (string) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, '') . (string) $diff;
324 324
   }
325 325
 
326 326
   /**
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
    * @return array
331 331
    */
332 332
   protected function deltaArray($name, $diff) {
333
-    $copy = (array)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, array());
333
+    $copy = (array) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, array());
334 334
     HelperArray::merge($copy, $diff, HelperArray::MERGE_PHP);
335 335
 
336 336
     return $copy;
Please login to merge, or discard this patch.
classes/DbSqlAware.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
    */
60 60
   protected function quoteFieldSimpleByRef(&$string) {
61 61
     $string = $this->escapeString($string);
62
-    if ((string)$string && '*' != $string) {
62
+    if ((string) $string && '*' != $string) {
63 63
       $string = '`' . $string . '`';
64 64
     }
65 65
   }
Please login to merge, or discard this patch.
classes/SnDbCachedOperator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
               ($filter ? ' WHERE ' . $filter : '') .
243 243
               ($fetch ? ' LIMIT 1' : ''));
244 244
           }
245
-          while($row = db_fetch($query)) {
245
+          while ($row = db_fetch($query)) {
246 246
             // Исключаем из списка родительских ИД уже заблокированные записи
247 247
             if (!$this->snCache->cache_lock_get($owner_location_type, $row['parent_id'])) {
248 248
               $parent_id_list[$row['parent_id']] = $row['parent_id'];
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
           . " FOR UPDATE"
283 283
         );
284 284
       }
285
-      while($row = db_fetch($query)) {
285
+      while ($row = db_fetch($query)) {
286 286
         // Caching record in row cache
287 287
         $this->snCache->cache_set($location_type, $row);
288 288
         // Making ref to cached record in query cache
Please login to merge, or discard this patch.