Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Branch master (287493)
by Dan
06:08
created
lib/Default/ChessGame.class.inc 1 patch
Braces   +17 added lines, -34 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 			$this->blackID = $this->db->getInt('black_id');
82 82
 			$this->winner = $this->db->getInt('winner_id');
83 83
 			$this->resetHasMoved();
84
-		}
85
-		else {
84
+		} else {
86 85
 			throw new Exception('Chess game not found: ' . $chessGameID);
87 86
 		}
88 87
 	}
@@ -149,8 +148,7 @@  discard block
 block discarded – undo
149 148
 					break;
150 149
 				}
151 150
 			}
152
-		}
153
-		catch(Exception $e) {
151
+		} catch(Exception $e) {
154 152
 			if($debugInfo === true) {
155 153
 				echo $e->getMessage() . EOL . $e->getTraceAsString() . EOL;
156 154
 			}
@@ -199,11 +197,9 @@  discard block
 block discarded – undo
199 197
 			if(!$mate && $this->hasEnded()) {
200 198
 				if($this->getWinner() != 0) {
201 199
 					$this->moves[] = ($this->getWinner() == $this->getWhiteID() ? 'Black' : 'White') . ' Resigned.';
202
-				}
203
-				else if(count($this->moves) < 2) {
200
+				} else if(count($this->moves) < 2) {
204 201
 					$this->moves[] = 'Game Cancelled.';
205
-				}
206
-				else {
202
+				} else {
207 203
 					$this->moves[] = 'Game Drawn.';
208 204
 				}
209 205
 			}
@@ -222,8 +218,7 @@  discard block
 block discarded – undo
222 218
 			for($x=0; $x < 8; $x++) {
223 219
 				if($board[$y][$x] == null) {
224 220
 					$blanks++;
225
-				}
226
-				else {
221
+				} else {
227 222
 					if($blanks > 0) {
228 223
 						$fen .= $blanks;
229 224
 						$blanks = 0;
@@ -278,8 +273,7 @@  discard block
 block discarded – undo
278 273
 					$fen .= '3';
279 274
 				break;
280 275
 			}
281
-		}
282
-		else {
276
+		} else {
283 277
 			$fen .= '-';
284 278
 		}
285 279
 		$fen .= ' 0 ' . floor(count($this->moves)/2);
@@ -412,8 +406,7 @@  discard block
 block discarded – undo
412 406
 		}
413 407
 		if($pieceID == ChessPiece::PAWN && ($startY == 1 || $startY == 6) && ($endY == 3 || $endY == 4)) {
414 408
 			$this->hasMoved[ChessPiece::PAWN] = array($endX, $endY);
415
-		}
416
-		else {
409
+		} else {
417 410
 			$this->hasMoved[ChessPiece::PAWN] = array(-1,-1);
418 411
 		}
419 412
 		return ($castling == 'Queen' ? '0-0-0' : ($castling == 'King' ? '0-0' : ''))
@@ -519,8 +512,7 @@  discard block
 block discarded – undo
519 512
 				$board[$toY][$castling['ToX']]->setX($castling['ToX']);
520 513
 				$board[$y][$castling['X']] = null;
521 514
 			}
522
-		}
523
-		else if($p->pieceID == ChessPiece::PAWN) {
515
+		} else if($p->pieceID == ChessPiece::PAWN) {
524 516
 			if($toY == 0 || $toY == 7) {
525 517
 				$pawnPromotion = $p->promote($pawnPromotionPiece, $board);
526 518
 			}
@@ -538,8 +530,7 @@  discard block
 block discarded – undo
538 530
 				}
539 531
 				$board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = null;
540 532
 			}
541
-		}
542
-		else if($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) {
533
+		} else if($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) {
543 534
 			//Rook moved?
544 535
 			if($hasMoved[$p->colour][ChessPiece::ROOK][$x==0?'Queen':'King'] === false) {
545 536
 				// We set rook moved in here as it's used for move info.
@@ -599,12 +590,10 @@  discard block
 block discarded – undo
599 590
 				$board[$y][$castling['X']]->setX($castling['X']);
600 591
 				$board[$toY][$castling['ToX']] = null;
601 592
 			}
602
-		}
603
-		else if($moveInfo['EnPassant'] === true) {
593
+		} else if($moveInfo['EnPassant'] === true) {
604 594
 			$board[$toY][$toX] = null;
605 595
 			$board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = $moveInfo['PieceTaken'];
606
-		}
607
-		else if($moveInfo['RookMoved'] !== false) {
596
+		} else if($moveInfo['RookMoved'] !== false) {
608 597
 			$hasMoved[$p->colour][ChessPiece::ROOK][$moveInfo['RookMoved']] = false;
609 598
 		}
610 599
 		if($moveInfo['RookTaken'] !== false) {
@@ -728,8 +717,7 @@  discard block
 block discarded – undo
728 717
 					$this->setWinner($forAccountID);
729 718
 					$return = 1;
730 719
 					SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'You have just lost [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].');
731
-				}
732
-				else {
720
+				} else {
733 721
 					SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'It is now your turn in [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].');
734 722
 					if($checking == 'CHECK') {
735 723
 						$currentPlayer->increaseHOF(1, array($chessType,'Moves','Check Given'), HOF_PUBLIC);
@@ -759,8 +747,7 @@  discard block
 block discarded – undo
759 747
 	public function &getWhitePlayer() {
760 748
 		try {
761 749
 			return SmrPlayer::getPlayer($this->whiteID, $this->getGameID());
762
-		}
763
-		catch(Exception $e) {
750
+		} catch(Exception $e) {
764 751
 			$null = null;
765 752
 			return $null;
766 753
 		}
@@ -773,8 +760,7 @@  discard block
 block discarded – undo
773 760
 	public function &getBlackPlayer() {
774 761
 		try {
775 762
 			return SmrPlayer::getPlayer($this->blackID, $this->getGameID());
776
-		}
777
-		catch(Exception $e) {
763
+		} catch(Exception $e) {
778 764
 			$null = null;
779 765
 			return $null;
780 766
 		}
@@ -796,8 +782,7 @@  discard block
 block discarded – undo
796 782
 	public function &getColourPlayer($colour) {
797 783
 		try {
798 784
 			return SmrPlayer::getPlayer($this->getColourID($colour), $this->getGameID());
799
-		}
800
-		catch(Exception $e) {
785
+		} catch(Exception $e) {
801 786
 			$null = null;
802 787
 			return $null;
803 788
 		}
@@ -854,8 +839,7 @@  discard block
 block discarded – undo
854 839
 	public function &getCurrentTurnPlayer() {
855 840
 		try {
856 841
 			return SmrPlayer::getPlayer($this->getCurrentTurnAccountID(), $this->getGameID());
857
-		}
858
-		catch(Exception $e) {
842
+		} catch(Exception $e) {
859 843
 			$null = null;
860 844
 			return $null;
861 845
 		}
@@ -902,8 +886,7 @@  discard block
 block discarded – undo
902 886
 							SET end_time=' . $this->db->escapeNumber(TIME) . '
903 887
 							WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ';');
904 888
 			return 1;
905
-		}
906
-		else {
889
+		} else {
907 890
 			$loserColour = $this->getColourForAccountID($accountID);
908 891
 			$winnerAccountID = $this->getColourID(self::getOtherColour($loserColour));
909 892
 			$results = $this->setWinner($winnerAccountID);
Please login to merge, or discard this patch.
lib/Default/SmrCombatDrones.class.inc 1 patch
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@  discard block
 block discarded – undo
13 13
 			$this->maxDamage = 2;
14 14
 			$this->shieldDamage = 2;
15 15
 			$this->armourDamage = 2;
16
-		}
17
-		else {
16
+		} else {
18 17
 			$this->maxDamage = 1;
19 18
 			$this->shieldDamage = 1;
20 19
 			$this->armourDamage = 1;
@@ -84,8 +83,9 @@  discard block
 block discarded – undo
84 83
 		$weaponShip = $weaponPlayer->getShip();
85 84
 		$targetShip = $targetPlayer->getShip();
86 85
 		$mrDiff = $targetShip->getMR() - $weaponShip->getMR();
87
-		if($mrDiff > 0)
88
-			$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff/MR_FACTOR)/100;
86
+		if($mrDiff > 0) {
87
+					$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff/MR_FACTOR)/100;
88
+		}
89 89
 	
90 90
 		return max(0,min(100,$modifiedAccuracy));
91 91
 	}
@@ -127,8 +127,10 @@  discard block
 block discarded – undo
127 127
 	}
128 128
 	
129 129
 	public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
130
-		if(!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
130
+		if(!$this->canShootForces()) {
131
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
131 132
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
133
+		}
132 134
 		$damage =& $this->getModifiedDamage();
133 135
 		$damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstForces($weaponPlayer,$forces) / 100);
134 136
 		$damage['Kamikaze'] = 0;
@@ -149,8 +151,10 @@  discard block
 block discarded – undo
149 151
 	}
150 152
 	
151 153
 	public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
152
-		if(!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
154
+		if(!$this->canShootPorts()) {
155
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
153 156
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
157
+		}
154 158
 		$damage =& $this->getModifiedDamage();
155 159
 		$damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPort($weaponPlayer,$port) / 100);
156 160
 		$damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage']);
@@ -161,8 +165,10 @@  discard block
 block discarded – undo
161 165
 	}
162 166
 	
163 167
 	public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) {
164
-		if(!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
168
+		if(!$this->canShootPlanets()) {
169
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
165 170
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
171
+		}
166 172
 		$damage =& $this->getModifiedDamage();
167 173
 		$damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPlanet($weaponPlayer,$planet) / 100);
168 174
 		$planetMod = self::PLANET_DAMAGE_MOD;
Please login to merge, or discard this patch.
lib/Default/smr.inc 1 patch
Braces   +141 added lines, -89 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
 
18 18
 function parseBoolean($check) {
19 19
 	// Only negative strings are not implicitly converted to the correct bool
20
-	if(is_string($check) && (strcasecmp($check,'NO') == 0 || strcasecmp($check,'FALSE')==0))
21
-		return false;
20
+	if(is_string($check) && (strcasecmp($check,'NO') == 0 || strcasecmp($check,'FALSE')==0)) {
21
+			return false;
22
+	}
22 23
 	return (bool)$check;
23 24
 }
24 25
 
@@ -37,8 +38,9 @@  discard block
 block discarded – undo
37 38
 			break;
38 39
 			case 'player':
39 40
 				$playerID = $default;
40
-				if(!is_numeric($playerID))
41
-					$playerID = $tagParams['id'];
41
+				if(!is_numeric($playerID)) {
42
+									$playerID = $tagParams['id'];
43
+				}
42 44
 				$bbPlayer = SmrPlayer::getPlayerByPlayerID($playerID, $overrideGameID);
43 45
 				if ($action == \Nbbc\BBCode::BBCODE_CHECK) {
44 46
 					return true;
@@ -52,8 +54,9 @@  discard block
 block discarded – undo
52 54
 			case 'alliance':
53 55
 				$db = new SmrMySqlDatabase();
54 56
 				$allianceID = $default;
55
-				if(!is_numeric($allianceID))
56
-					$allianceID = $tagParams['id'];
57
+				if(!is_numeric($allianceID)) {
58
+									$allianceID = $tagParams['id'];
59
+				}
57 60
 				$alliance = SmrAlliance::getAlliance($allianceID, $overrideGameID);
58 61
 				if ($action == \Nbbc\BBCode::BBCODE_CHECK) {
59 62
 					return true;
@@ -62,10 +65,11 @@  discard block
 block discarded – undo
62 65
 				if($disableBBLinks===false && $overrideGameID==SmrSession::getGameID()) {
63 66
 					$container = create_container('skeleton.php');
64 67
 					$container['alliance_id'] = $alliance->getAllianceID();
65
-					if (is_object($player) && $alliance->getAllianceID() == $player->getAllianceID())
66
-						$container['body'] = 'alliance_mod.php';
67
-					else
68
-						$container['body'] = 'alliance_roster.php';
68
+					if (is_object($player) && $alliance->getAllianceID() == $player->getAllianceID()) {
69
+											$container['body'] = 'alliance_mod.php';
70
+					} else {
71
+											$container['body'] = 'alliance_roster.php';
72
+					}
69 73
 					return create_link($container, $alliance->getAllianceName());
70 74
 				}
71 75
 				return $alliance->getAllianceName();
@@ -89,8 +93,9 @@  discard block
 block discarded – undo
89 93
 					return true;
90 94
 				}
91 95
 				if ($timeString != '' && ($time = strtotime($timeString)) !== false) {
92
-					if(is_object($account))
93
-						$time += $account->getOffset() * 3600;
96
+					if(is_object($account)) {
97
+											$time += $account->getOffset() * 3600;
98
+					}
94 99
 					return date(DATE_FULL_SHORT, $time);
95 100
 				}
96 101
 			break;
@@ -133,8 +138,7 @@  discard block
 block discarded – undo
133 138
 				return '<div class="buttonA"><a class="buttonA" href="' . SmrSession::getNewHREF($container) . '">Join ' . $alliance->getAllianceName() . '</a></div>';
134 139
 			break;
135 140
 		}
136
-	}
137
-	catch (Exception $e) {
141
+	} catch (Exception $e) {
138 142
 	}
139 143
 	if ($action == \Nbbc\BBCode::BBCODE_CHECK) {
140 144
 		return false;
@@ -179,15 +183,15 @@  discard block
 block discarded – undo
179 183
 		$bbParser->addRule('join_alliance',$smrRule);
180 184
 	}
181 185
 	global $disableBBLinks;
182
-	if($noLinks===true)
183
-		$disableBBLinks = true;
184
-	else
185
-		$disableBBLinks = false;
186
+	if($noLinks===true) {
187
+			$disableBBLinks = true;
188
+	} else {
189
+			$disableBBLinks = false;
190
+	}
186 191
 	if(strpos($message, '[')!==false) { //We have BBCode so let's do a full parse.
187 192
 		$message = $bbParser->parse($message);
188 193
 		$message = str_replace('&lt;br /&gt;','<br />',$message);
189
-	}
190
-	else { //Otherwise just convert newlines
194
+	} else { //Otherwise just convert newlines
191 195
 		$message = nl2br($message, true);
192 196
 	}
193 197
 	return $message;
@@ -227,8 +231,7 @@  discard block
 block discarded – undo
227 231
 
228 232
 	if(!is_array($actions)) {
229 233
 		$form['submit'] =  '<input class="submit" type="submit" name="action" value="' . htmlspecialchars($actions) . '">';
230
-	}
231
-	else {
234
+	} else {
232 235
 		$form['submit'] = array();
233 236
 		foreach($actions as $action) {
234 237
 			$form['submit'][$action[0]] =  '<input class="submit" type="submit" name="action" value="' . htmlspecialchars($action[1]) . '">';
@@ -273,8 +276,9 @@  discard block
 block discarded – undo
273 276
 }
274 277
 
275 278
 function forward($new_container) {
276
-	if(defined('OVERRIDE_FORWARD')&&OVERRIDE_FORWARD===true)
277
-		return overrideForward($new_container);
279
+	if(defined('OVERRIDE_FORWARD')&&OVERRIDE_FORWARD===true) {
280
+			return overrideForward($new_container);
281
+	}
278 282
 	resetContainer($new_container);
279 283
 	do_voodoo();
280 284
 }
@@ -290,8 +294,9 @@  discard block
 block discarded – undo
290 294
 	global $var, $container;
291 295
 
292 296
 	// transfer this value to next container
293
-	if(isset($var[$what]))
294
-		$container[$what] = $var[$what];
297
+	if(isset($var[$what])) {
298
+			$container[$what] = $var[$what];
299
+	}
295 300
 
296 301
 }
297 302
 
@@ -319,8 +324,7 @@  discard block
 block discarded – undo
319 324
 	}
320 325
 	if($maxValue-$minValue==0) {
321 326
 		return $text;
322
-	}
323
-	else {
327
+	} else {
324 328
 		$normalisedValue = round(510*max(0,min($maxValue,$value)-$minValue)/($maxValue-$minValue))-255;
325 329
 	}
326 330
 	if ($type == 'Game') {
@@ -330,28 +334,33 @@  discard block
 block discarded – undo
330 334
 			if(strlen($g_component) == 1) {
331 335
 				$g_component = '0' . $g_component;
332 336
 			}
333
-		}
334
-		else if($normalisedValue > 0) {
337
+		} else if($normalisedValue > 0) {
335 338
 			$g_component='ff';
336 339
 			$r_component = dechex(255-$normalisedValue);
337 340
 			if(strlen($r_component) == 1) {
338 341
 				$r_component = '0' . $r_component;
339 342
 			}
340
-		}
341
-		else {
343
+		} else {
342 344
 			$r_component = 'ff';
343 345
 			$g_component = 'ff';
344 346
 		}
345 347
 		$colour = $r_component . $g_component . '00';
346
-		if ($return_type == 'Colour') return $colour;
348
+		if ($return_type == 'Colour') {
349
+			return $colour;
350
+		}
347 351
 		return '<span style="color:#' . $colour . '">' . $text . '</span>';
348
-	}
349
-	elseif ($type == 'IRC') {
352
+	} elseif ($type == 'IRC') {
350 353
 		//IRC color codes
351
-		if ($normalisedValue == 255) $colour = '[k03]';
352
-		elseif ($normalisedValue == -255) $colour = '[k04]';
353
-		else $colour = '[k08]';
354
-		if ($return_type == 'Colour') return $colour;
354
+		if ($normalisedValue == 255) {
355
+			$colour = '[k03]';
356
+		} elseif ($normalisedValue == -255) {
357
+			$colour = '[k04]';
358
+		} else {
359
+			$colour = '[k08]';
360
+		}
361
+		if ($return_type == 'Colour') {
362
+			return $colour;
363
+		}
355 364
 		return $colour . $text;
356 365
 	}
357 366
 }
@@ -409,9 +418,10 @@  discard block
 block discarded – undo
409 418
 	if(!defined('AJAX_CONTAINER')) {
410 419
 		define('AJAX_CONTAINER', isset($var['AJAX']) && $var['AJAX'] === true);
411 420
 	}
412
-	if(!AJAX_CONTAINER && USING_AJAX && SmrSession::$SN != SmrSession::$lastSN)
413
-		exit;
414
-//	ob_clean();
421
+	if(!AJAX_CONTAINER && USING_AJAX && SmrSession::$SN != SmrSession::$lastSN) {
422
+			exit;
423
+	}
424
+	//	ob_clean();
415 425
 
416 426
 	foreach ($GLOBALS as $key => $value) {
417 427
 		$$key = &$GLOBALS[$key];
@@ -420,10 +430,18 @@  discard block
 block discarded – undo
420 430
 	$account =& SmrAccount::getAccount(SmrSession::$account_id);
421 431
 	$GLOBALS['account'] =& $account;
422 432
 
423
-	if(!defined('DATE_DATE_SHORT')) define('DATE_DATE_SHORT',$account->getShortDateFormat());
424
-	if(!defined('DATE_TIME_SHORT')) define('DATE_TIME_SHORT',$account->getShortTimeFormat());
425
-	if(!defined('DATE_FULL_SHORT')) define('DATE_FULL_SHORT',DATE_DATE_SHORT.' '.DATE_TIME_SHORT);
426
-	if(!defined('DATE_FULL_SHORT_SPLIT')) define('DATE_FULL_SHORT_SPLIT',DATE_DATE_SHORT.'\<b\r /\>'.DATE_TIME_SHORT);
433
+	if(!defined('DATE_DATE_SHORT')) {
434
+		define('DATE_DATE_SHORT',$account->getShortDateFormat());
435
+	}
436
+	if(!defined('DATE_TIME_SHORT')) {
437
+		define('DATE_TIME_SHORT',$account->getShortTimeFormat());
438
+	}
439
+	if(!defined('DATE_FULL_SHORT')) {
440
+		define('DATE_FULL_SHORT',DATE_DATE_SHORT.' '.DATE_TIME_SHORT);
441
+	}
442
+	if(!defined('DATE_FULL_SHORT_SPLIT')) {
443
+		define('DATE_FULL_SHORT_SPLIT',DATE_DATE_SHORT.'\<b\r /\>'.DATE_TIME_SHORT);
444
+	}
427 445
 
428 446
 
429 447
 	$db = new SmrMySqlDatabase();
@@ -490,8 +508,9 @@  discard block
 block discarded – undo
490 508
 
491 509
 		if (!$player->isDead() && $player->getNewbieTurns() <= NEWBIE_TURNS_WARNING_LIMIT &&
492 510
 			$player->getNewbieWarning() &&
493
-			$var['url'] != 'newbie_warning_processing.php')
494
-			forward(create_container('newbie_warning_processing.php'));
511
+			$var['url'] != 'newbie_warning_processing.php') {
512
+					forward(create_container('newbie_warning_processing.php'));
513
+		}
495 514
 	}
496 515
 
497 516
 	if($var['url'] != 'skeleton.php') {
@@ -501,13 +520,13 @@  discard block
 block discarded – undo
501 520
 		$PHP_OUTPUT = '';
502 521
 		if ($var['body']=='error.php') { // infinite includes for error pages
503 522
 			require(get_file_loc($var['body']));
504
-		}
505
-		else {
523
+		} else {
506 524
 			require_once(get_file_loc($var['body']));
507 525
 		}
508 526
 
509
-		if($PHP_OUTPUT!='')
510
-			$template->assign('PHP_OUTPUT',$PHP_OUTPUT);
527
+		if($PHP_OUTPUT!='') {
528
+					$template->assign('PHP_OUTPUT',$PHP_OUTPUT);
529
+		}
511 530
 	}
512 531
 
513 532
 	if (SmrSession::hasGame()) {
@@ -571,8 +590,9 @@  discard block
 block discarded – undo
571 590
 function acquire_lock($sector) {
572 591
 	global $db, $lock, $locksFailed;
573 592
 
574
-	if($lock)
575
-		return true;
593
+	if($lock) {
594
+			return true;
595
+	}
576 596
 
577 597
 	// Insert ourselves into the queue.
578 598
 	$db->query('INSERT INTO locks_queue (game_id,account_id,sector_id,timestamp) VALUES(' . $db->escapeNumber(SmrSession::getGameID()) . ',' . $db->escapeNumber(SmrSession::$account_id) . ',' . $db->escapeNumber($sector) . ',' . $db->escapeNumber(TIME) . ')');
@@ -598,8 +618,7 @@  discard block
 block discarded – undo
598 618
 
599 619
 			usleep(25000 * $locksInQueue);
600 620
 			continue;
601
-		}
602
-		else {
621
+		} else {
603 622
 			return true;
604 623
 		}
605 624
 	}
@@ -798,7 +817,9 @@  discard block
 block discarded – undo
798 817
 		$container['player_id']	= $player->getPlayerID();
799 818
 		$template->assign('PlayerNameLink',SmrSession::getNewHREF($container));
800 819
 
801
-		if (is_array(Globals::getHiddenPlayers())&&in_array($player->getAccountID(), Globals::getHiddenPlayers())) $template->assign('PlayerInvisible',true);
820
+		if (is_array(Globals::getHiddenPlayers())&&in_array($player->getAccountID(), Globals::getHiddenPlayers())) {
821
+			$template->assign('PlayerInvisible',true);
822
+		}
802 823
 
803 824
 		// ******* Hardware *******
804 825
 		$container = create_container('skeleton.php', 'configure_hardware.php');
@@ -872,7 +893,9 @@  discard block
 block discarded – undo
872 893
 	$string = '';
873 894
 	if ($seconds == 0) {
874 895
 		$string = '0 seconds';
875
-		if ($short) $string = '0s';
896
+		if ($short) {
897
+			$string = '0s';
898
+		}
876 899
 	}
877 900
 	if ($seconds >= 60) {
878 901
 		$minutes = floor($seconds/60);
@@ -892,58 +915,85 @@  discard block
 block discarded – undo
892 915
 	}
893 916
 	if ($weeks > 0) {
894 917
 		$string .= $weeks;
895
-		if ($short) $string .= 'w';
896
-		else {
918
+		if ($short) {
919
+			$string .= 'w';
920
+		} else {
897 921
 			$string .= ' week';
898
-			if ($weeks > 1) $string .= 's';
922
+			if ($weeks > 1) {
923
+				$string .= 's';
924
+			}
899 925
 		}
900 926
 	}
901 927
 	if ($days > 0) {
902 928
 		$before = $weeks;
903 929
 		$after = $hours + $minutes + $seconds;
904
-		if ($before > 0 && $after > 0) $string .= ', ';
905
-		elseif ($before > 0 && $after == 0) $string .= ' and ';
930
+		if ($before > 0 && $after > 0) {
931
+			$string .= ', ';
932
+		} elseif ($before > 0 && $after == 0) {
933
+			$string .= ' and ';
934
+		}
906 935
 		$string .= $days;
907
-		if ($short) $string .= 'd';
908
-		else {
936
+		if ($short) {
937
+			$string .= 'd';
938
+		} else {
909 939
 			$string .= ' day';
910
-			if ($days > 1) $string .= 's';
940
+			if ($days > 1) {
941
+				$string .= 's';
942
+			}
911 943
 		}
912 944
 	}
913 945
 	if ($hours > 0) {
914 946
 		$before = $weeks + $days;
915 947
 		$after = $minutes + $seconds;
916
-		if ($before > 0 && $after > 0) $string .= ', ';
917
-		elseif ($before > 0 && $after == 0) $string .= ' and ';
948
+		if ($before > 0 && $after > 0) {
949
+			$string .= ', ';
950
+		} elseif ($before > 0 && $after == 0) {
951
+			$string .= ' and ';
952
+		}
918 953
 		$string .= $hours;
919
-		if ($short) $string .= 'h';
920
-		else {
954
+		if ($short) {
955
+			$string .= 'h';
956
+		} else {
921 957
 			$string .= ' hour';
922
-			if ($hours > 1) $string .= 's';
958
+			if ($hours > 1) {
959
+				$string .= 's';
960
+			}
923 961
 		}
924 962
 	}
925 963
 	if ($minutes > 0) {
926 964
 		$before = $weeks + $days + $hours;
927 965
 		$after = $seconds;
928
-		if ($before > 0 && $after > 0) $string .= ', ';
929
-		elseif ($before > 0 && $after == 0) $string .= ' and ';
966
+		if ($before > 0 && $after > 0) {
967
+			$string .= ', ';
968
+		} elseif ($before > 0 && $after == 0) {
969
+			$string .= ' and ';
970
+		}
930 971
 		$string .= $minutes;
931
-		if ($short) $string .= 'm';
932
-		else {
972
+		if ($short) {
973
+			$string .= 'm';
974
+		} else {
933 975
 			$string .= ' minute';
934
-			if ($minutes > 1) $string .= 's';
976
+			if ($minutes > 1) {
977
+				$string .= 's';
978
+			}
935 979
 		}
936 980
 	}
937 981
 	if ($seconds > 0) {
938 982
 		$before = $weeks + $days + $hours + $minutes;
939 983
 		$after = 0;
940
-		if ($before > 0 && $after > 0) $string .= ', ';
941
-		elseif ($before > 0 && $after == 0) $string .= ' and ';
984
+		if ($before > 0 && $after > 0) {
985
+			$string .= ', ';
986
+		} elseif ($before > 0 && $after == 0) {
987
+			$string .= ' and ';
988
+		}
942 989
 		$string .= $seconds;
943
-		if ($short) $string .= 's';
944
-		else {
990
+		if ($short) {
991
+			$string .= 's';
992
+		} else {
945 993
 			$string .= ' second';
946
-			if ($seconds > 1) $string .= 's';
994
+			if ($seconds > 1) {
995
+				$string .= 's';
996
+			}
947 997
 		}
948 998
 	}
949 999
 	return $string;
@@ -951,16 +1001,18 @@  discard block
 block discarded – undo
951 1001
 
952 1002
 function number_colour_format($number,$justSign = false) {
953 1003
 	$formatted = '<span';
954
-	if($number > 0)
955
-		$formatted .= ' class="green">+';
956
-	else if($number < 0)
957
-		$formatted .= ' class="red">-';
958
-	else
959
-		$formatted .= '>';
1004
+	if($number > 0) {
1005
+			$formatted .= ' class="green">+';
1006
+	} else if($number < 0) {
1007
+			$formatted .= ' class="red">-';
1008
+	} else {
1009
+			$formatted .= '>';
1010
+	}
960 1011
 	if($justSign===false) {
961 1012
 		$decimalPlaces = 0;
962
-		if(($pos = strpos($number,'.'))!==false)
963
-			$decimalPlaces = strlen(substr($number,$pos+1));
1013
+		if(($pos = strpos($number,'.'))!==false) {
1014
+					$decimalPlaces = strlen(substr($number,$pos+1));
1015
+		}
964 1016
 		$formatted .= number_format(abs($number),$decimalPlaces);
965 1017
 	}
966 1018
 	$formatted .= '</span>';
Please login to merge, or discard this patch.
lib/Default/Rankings.class.inc 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@  discard block
 block discarded – undo
13 13
 			$class = '';
14 14
 			if ($player->getAllianceID() == $currentAlliance->getAllianceID()) {
15 15
 				$class = ' class="bold"';
16
-			}
17
-			else if($currentAlliance->hasDisbanded()) {
16
+			} else if($currentAlliance->hasDisbanded()) {
18 17
 				$class = ' class="red"';
19 18
 			}
20 19
 
@@ -61,12 +60,10 @@  discard block
 block discarded – undo
61 60
 		if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'Show' && is_numeric($_REQUEST['min_rank']) && is_numeric($_REQUEST['max_rank'])) {
62 61
 			$minRank = min($_REQUEST['min_rank'], $_REQUEST['max_rank']);
63 62
 			$maxRank = max($_REQUEST['min_rank'], $_REQUEST['max_rank']);
64
-		}
65
-		elseif(isset($var['MinRank']) && isset($var['MaxRank'])) {
63
+		} elseif(isset($var['MinRank']) && isset($var['MaxRank'])) {
66 64
 			$minRank = $var['MinRank'];
67 65
 			$maxRank = $var['MaxRank'];
68
-		}
69
-		else {
66
+		} else {
70 67
 			$minRank = $ourRank - 5;
71 68
 			$maxRank = $ourRank + 5;
72 69
 		}
Please login to merge, or discard this patch.
lib/Default/hof.functions.inc 1 patch
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,13 +8,11 @@  discard block
 block discarded – undo
8 8
 	$rank = array('Amount'=>0,'Rank'=>0);
9 9
 	if($view == DONATION_NAME) {
10 10
 		$db->query('SELECT SUM(amount) as amount FROM account_donated WHERE account_id='.$db->escapeNumber($accountID).' GROUP BY account_id LIMIT 1');
11
-	}
12
-	else if($view == USER_SCORE_NAME) {
11
+	} else if($view == USER_SCORE_NAME) {
13 12
 		$statements = SmrAccount::getUserScoreCaseStatement($db);
14 13
 		$query = 'SELECT '.$statements['CASE'].' amount FROM (SELECT type, SUM(amount) amount FROM player_hof WHERE type IN ('.$statements['IN'].') AND account_id='.$db->escapeNumber($accountID).$gameIDSql.' GROUP BY account_id,type) x ORDER BY amount DESC';
15 14
 		$db->query($query);
16
-	}
17
-	else {
15
+	} else {
18 16
 		$db->query('SELECT visibility FROM hof_visibility WHERE type='.$db->escapeArray($viewType,false,true,':',false).' LIMIT 1');
19 17
 		if(!$db->nextRecord()) {
20 18
 			return $rank;
@@ -38,8 +36,7 @@  discard block
 block discarded – undo
38 36
 	}
39 37
 	if($vis==HOF_PUBLIC || $account->getAccountID()==$accountID) {
40 38
 		$rank['Amount'] = $realAmount;
41
-	}
42
-	else if($vis==HOF_ALLIANCE&&$account->getAccountID()!=$accountID) {
39
+	} else if($vis==HOF_ALLIANCE&&$account->getAccountID()!=$accountID) {
43 40
 		if (isset($gameID)) {
44 41
 			$hofPlayer = SmrPlayer::getPlayer($accountID, $gameID);
45 42
 			// Only show the real amount if player is in your alliance.
@@ -61,12 +58,10 @@  discard block
 block discarded – undo
61 58
 
62 59
 	if($view == DONATION_NAME) {
63 60
 		$db->query('SELECT COUNT(account_id) rank FROM (SELECT account_id FROM account_donated GROUP BY account_id HAVING SUM(amount)>' . $db->escapeNumber($rank['Amount']) . ') x');
64
-	}
65
-	else if($view == USER_SCORE_NAME) {
61
+	} else if($view == USER_SCORE_NAME) {
66 62
 		$query = 'SELECT COUNT(account_id) rank FROM (SELECT account_id FROM player_hof WHERE type IN ('.$statements['IN'].')'.$gameIDSql.' GROUP BY account_id HAVING '.$statements['CASE'].'>' . $db->escapeNumber($rank['Amount']) . ') x';
67 63
 		$db->query($query);
68
-	}
69
-	else {
64
+	} else {
70 65
 		$db->query('SELECT COUNT(account_id) rank FROM (SELECT account_id FROM player_hof WHERE type='.$db->escapeArray($viewType,false,true,':',false).$gameIDSql.' GROUP BY account_id HAVING SUM(amount)>'.$db->escapeNumber($realAmount).') x');
71 66
 	}
72 67
 	if($db->nextRecord()) {
@@ -80,12 +75,10 @@  discard block
 block discarded – undo
80 75
 	if(isset($var['game_id']) && Globals::isValidGame($var['game_id'])) {
81 76
 		try {
82 77
 			$hofPlayer = SmrPlayer::getPlayer($accountID,$var['game_id']);
83
-		}
84
-		catch(PlayerNotFoundException $e) {
78
+		} catch(PlayerNotFoundException $e) {
85 79
 			$hofAccount = SmrAccount::getAccount($accountID);
86 80
 		}
87
-	}
88
-	else {
81
+	} else {
89 82
 		$hofAccount = SmrAccount::getAccount($accountID);
90 83
 	}
91 84
 	$bold = '';
@@ -101,17 +94,14 @@  discard block
 block discarded – undo
101 94
 	if (isset($var['game_id'])) {
102 95
 		$container['game_id'] = $var['game_id'];
103 96
 		$container['sending_page'] = 'personal_current_hof';
104
-	}
105
-	else {
97
+	} else {
106 98
 		$container['sending_page'] = 'personal_hof';
107 99
 	}
108 100
 	if(isset($hofPlayer) && is_object($hofPlayer)) {
109 101
 		$return.=('<td align="center"'.$bold.'>'.create_link($container, $hofPlayer->getPlayerName()) .'</td>');
110
-	}
111
-	else if(isset($hofAccount) && is_object($hofAccount)) {
102
+	} else if(isset($hofAccount) && is_object($hofAccount)) {
112 103
 		$return.=('<td align="center"'.$bold.'>'.create_link($container, $hofAccount->getHofName()) .'</td>');
113
-	}
114
-	else {
104
+	} else {
115 105
 		$return.=('<td align="center"'.$bold.'>Unknown</td>');
116 106
 	}
117 107
 	$return.=('<td align="center"'.$bold.'>' . $amount . '</td>');
@@ -131,8 +121,7 @@  discard block
 block discarded – undo
131 121
 				$var['type'] = $typeList;
132 122
 				$var['view'] = $type;
133 123
 				break;
134
-			}
135
-			else {
124
+			} else {
136 125
 				$typeList[] = $type;
137 126
 			}
138 127
 			$viewing .= ' -&gt; ';
Please login to merge, or discard this patch.
lib/Default/Menu.class.inc 1 patch
Braces   +32 added lines, -27 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 		if($alliance_id) {
24 24
 			$in_alliance = ($alliance_id == $player->getAllianceID());
25
-		}
26
-		else {
25
+		} else {
27 26
 			$in_alliance = $player->hasAlliance();
28 27
 		}
29 28
 		if(!$in_alliance) {
@@ -36,8 +35,7 @@  discard block
 block discarded – undo
36 35
 				$mbRead = $db->getBoolean('mb_read');
37 36
 				$modRead = $db->getBoolean('mod_read');
38 37
 				$planetLand = $db->getBoolean('planet_land');
39
-			}
40
-			else {
38
+			} else {
41 39
 				$mbRead = FALSE;
42 40
 				$modRead = FALSE;
43 41
 				$planetLand = FALSE;
@@ -251,9 +249,10 @@  discard block
 block discarded – undo
251 249
 		$menu_items[] = create_link(create_container('skeleton.php', 'bank_personal.php'),
252 250
 														'Personal Account','nav');
253 251
 
254
-		if ($player->hasAlliance())
255
-			$menu_items[] = create_link(create_container('skeleton.php', 'bank_alliance.php'),
252
+		if ($player->hasAlliance()) {
253
+					$menu_items[] = create_link(create_container('skeleton.php', 'bank_alliance.php'),
256 254
 															'Alliance Account','nav');
255
+		}
257 256
 
258 257
 		$menu_items[] = create_link(create_container('skeleton.php', 'bank_anon.php'),
259 258
 														'Anonymous Account','nav');
@@ -276,12 +275,14 @@  discard block
 block discarded – undo
276 275
 		$menu_items[] = create_link($container, 'Send Message','nav');
277 276
 
278 277
 		if($player->getRaceID()==$race_id) {
279
-			if ($player->isOnCouncil())
280
-				$menu_items[] = create_link(create_container('skeleton.php', 'council_vote.php'),
278
+			if ($player->isOnCouncil()) {
279
+							$menu_items[] = create_link(create_container('skeleton.php', 'council_vote.php'),
281 280
 																'Voting Center','nav');
282
-			if ($player->isPresident())
283
-				$menu_items[] = create_link(create_container('skeleton.php', 'council_embassy.php'),
281
+			}
282
+			if ($player->isPresident()) {
283
+							$menu_items[] = create_link(create_container('skeleton.php', 'council_embassy.php'),
284 284
 																'Embassy','nav');
285
+			}
285 286
 		}
286 287
 
287 288
 		create_menu($menu_items);
@@ -310,8 +311,9 @@  discard block
 block discarded – undo
310 311
 	static function navigation(&$template, &$player) {
311 312
 		$menuItems = array();
312 313
 		$menuItems[] = array('Link'=>Globals::getPlotCourseHREF(),'Text'=>'Plot A Course');
313
-		if(!$player->isLandedOnPlanet())
314
-			$menuItems[] = array('Link'=>Globals::getLocalMapHREF(),'Text'=>'Local Map');
314
+		if(!$player->isLandedOnPlanet()) {
315
+					$menuItems[] = array('Link'=>Globals::getLocalMapHREF(),'Text'=>'Local Map');
316
+		}
315 317
 		$menuItems[] = array('Link'=>'map_galaxy.php" target="gal_map','Text'=>'Galaxy Map');
316 318
 		$template->assign('MenuItems', $menuItems);
317 319
 	}
@@ -333,14 +335,16 @@  discard block
 block discarded – undo
333 335
 	$return .= ('<tr>');
334 336
 	foreach ($menu as $number => $entry) {
335 337
 		// insert spacer
336
-		if ($number > 0)
337
-			$return .= ('<td>&nbsp;|&nbsp;</td>');
338
+		if ($number > 0) {
339
+					$return .= ('<td>&nbsp;|&nbsp;</td>');
340
+		}
338 341
 
339 342
 		// if this is the active entry we mark it
340
-		if ($number == $active_level1)
341
-			$active = ' class="bold"';
342
-		else
343
-			$active = '';
343
+		if ($number == $active_level1) {
344
+					$active = ' class="bold"';
345
+		} else {
346
+					$active = '';
347
+		}
344 348
 
345 349
 		// echo entry itself
346 350
 		$return .= ('<td align="center"'.$active.'> ' . $entry['entry'] . '</td>');
@@ -354,17 +358,18 @@  discard block
 block discarded – undo
354 358
 		if (isset($entry['submenu']) && $number == $active_level1) {
355 359
 			$return .= ('<td><small>');
356 360
 			foreach ($entry['submenu'] as $sub_number => $sub_entry) {
357
-				if ($sub_number > 0)
358
-					$return .= (' | ');
359
-
360
-				if ($sub_number == $active_level2)
361
-					$return .= ('<span class="bold">'.$sub_entry.'</span>');
362
-				else
363
-					$return .= ($sub_entry);
361
+				if ($sub_number > 0) {
362
+									$return .= (' | ');
363
+				}
364
+
365
+				if ($sub_number == $active_level2) {
366
+									$return .= ('<span class="bold">'.$sub_entry.'</span>');
367
+				} else {
368
+									$return .= ($sub_entry);
369
+				}
364 370
 			}
365 371
 			$return .= ('</small></td>');
366
-		}
367
-		else {
372
+		} else {
368 373
 			// if it's not the first entry we have to put
369 374
 			// additional empty cell for the spacer
370 375
 			//if ($number > 0)
Please login to merge, or discard this patch.
lib/Default/WeightedRandom.class.inc 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@
 block discarded – undo
48 48
 		$this->db->query('SELECT weighting FROM weighted_random WHERE game_id = '.$this->db->escapeNumber($gameID).' AND account_id = '.$this->db->escapeNumber($accountID).' AND type = '.$this->db->escapeString($type).' AND type_id = '.$this->db->escapeNumber($typeID).' LIMIT 1');
49 49
 		if ($this->db->nextRecord()) {
50 50
 			$this->weighting = $this->db->getField('weighting');
51
-		}
52
-		else {
51
+		} else {
53 52
 			$this->weighting = 0;
54 53
 		}
55 54
 	}
Please login to merge, or discard this patch.
lib/Default/RouteGenerator.class.inc 1 patch
Braces   +49 added lines, -42 removed lines patch added patch discarded remove patch
@@ -65,15 +65,16 @@  discard block
 block discarded – undo
65 65
 	private static function getContinueRoutes($maxNumPorts, $startSectorId, Route &$routeToContinue, array &$forwardRoutes, array &$routeLists, $lastGoodIsNothing) {
66 66
 		foreach($forwardRoutes as &$currentStepRoute) {
67 67
 			$currentStepBuySector = $currentStepRoute->getBuySectorId();
68
-			if ($lastGoodIsNothing & ($lastGoodIsNothing = GOOD_NOTHING === $currentStepRoute->getGoodID()))
69
-				continue; // Don't do two nothings in a row
68
+			if ($lastGoodIsNothing & ($lastGoodIsNothing = GOOD_NOTHING === $currentStepRoute->getGoodID())) {
69
+							continue;
70
+			}
71
+			// Don't do two nothings in a row
70 72
 			if ($currentStepBuySector >= $startSectorId) { // Not already checked or back to start
71 73
 				if ($currentStepBuySector === $startSectorId) { // Route returns to start
72 74
 					$mpr = new MultiplePortRoute($routeToContinue, $currentStepRoute);
73 75
 					self::addExpRoute($mpr);
74 76
 					self::addMoneyRoute($mpr);
75
-				}
76
-				else if ($maxNumPorts > 1 && !$routeToContinue->containsPort($currentStepBuySector)) {
77
+				} else if ($maxNumPorts > 1 && !$routeToContinue->containsPort($currentStepBuySector)) {
77 78
 					$mpr = new MultiplePortRoute($routeToContinue, $currentStepRoute);
78 79
 					self::getContinueRoutes($maxNumPorts - 1, $startSectorId, $mpr, $routeLists[$currentStepBuySector], $routeLists, $lastGoodIsNothing);
79 80
 				}
@@ -89,17 +90,21 @@  discard block
 block discarded – undo
89 90
 				echo 'Error with Race ID: '.$sectors[$currentSectorId]->getPort()->getRaceID();
90 91
 				continue;
91 92
 			}
92
-			if($races[$raceID]===false)
93
-				continue;
93
+			if($races[$raceID]===false) {
94
+							continue;
95
+			}
94 96
 			$rl = array();
95 97
 			foreach($d as $targetSectorId => &$distance) {
96
-				if (!$races[$sectors[$targetSectorId]->getPort()->getRaceID()])
97
-					continue;
98
-				if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort)
99
-					continue;
98
+				if (!$races[$sectors[$targetSectorId]->getPort()->getRaceID()]) {
99
+									continue;
100
+				}
101
+				if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) {
102
+									continue;
103
+				}
100 104
 
101
-				if ($goods[GOOD_NOTHING]===true)
102
-					$rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $races[$raceID], $sectors[$targetSectorId]->getPort()->getRaceID(), 0, 0, $distance, GOOD_NOTHING);
105
+				if ($goods[GOOD_NOTHING]===true) {
106
+									$rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $races[$raceID], $sectors[$targetSectorId]->getPort()->getRaceID(), 0, 0, $distance, GOOD_NOTHING);
107
+				}
103 108
 
104 109
 				$gameGoods = Globals::getGoods();
105 110
 				foreach($gameGoods as $goodId => &$value) {
@@ -120,13 +125,16 @@  discard block
 block discarded – undo
120 125
 		self::$expRoutes = array();
121 126
 		self::$moneyRoutes = array();
122 127
 		foreach($distances as $currentSectorId => &$d) {
123
-			if ($races[$sectors[$currentSectorId]->getPort()->getRaceID()]===false)
124
-				continue;
128
+			if ($races[$sectors[$currentSectorId]->getPort()->getRaceID()]===false) {
129
+							continue;
130
+			}
125 131
 			foreach($d as $targetSectorId => &$distance) {
126
-				if ($races[$sectors[$targetSectorId]->getPort()->getRaceID()]===false)
127
-					continue;
128
-				if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort)
129
-					continue;
132
+				if ($races[$sectors[$targetSectorId]->getPort()->getRaceID()]===false) {
133
+									continue;
134
+				}
135
+				if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) {
136
+									continue;
137
+				}
130 138
 
131 139
 				$gameGoods =& Globals::getGoods();
132 140
 				foreach($gameGoods as $goodId => &$value) {
@@ -154,8 +162,7 @@  discard block
 block discarded – undo
154 162
 		if ($overallMultiplier > self::$dontAddWorseThan[self::EXP_ROUTE]) {
155 163
 			if (isset(self::$expRoutes[$overallMultiplier])) {
156 164
 				$rl =& self::$expRoutes[$overallMultiplier];
157
-			}
158
-			else {
165
+			} else {
159 166
 				$rl = array();
160 167
 			}
161 168
 			$rl[] =& $r;
@@ -168,8 +175,7 @@  discard block
 block discarded – undo
168 175
 		if ($overallMultiplier > self::$dontAddWorseThan[self::MONEY_ROUTE]) {
169 176
 			if (isset(self::$moneyRoutes[$overallMultiplier])) {
170 177
 				$rl =& self::$moneyRoutes[$overallMultiplier];
171
-			}
172
-			else {
178
+			} else {
173 179
 				$rl = array();
174 180
 			}
175 181
 			$rl[] =& $r;
@@ -183,15 +189,14 @@  discard block
 block discarded – undo
183 189
 		foreach(self::$expRoutes as $multi => &$routesByMulti) {
184 190
 			if(count($routesByMulti)+$i < $trimToBestXRoutes) {
185 191
 				$i += count($routesByMulti);
186
-			}
187
-			else if($i > $trimToBestXRoutes) {
192
+			} else if($i > $trimToBestXRoutes) {
188 193
 				unset(self::$expRoutes[$multi]);
189
-			}
190
-			else {
194
+			} else {
191 195
 				foreach($routesByMulti as $key => &$value) {
192 196
 					$i++;
193
-					if($i < $trimToBestXRoutes)
194
-						continue;
197
+					if($i < $trimToBestXRoutes) {
198
+											continue;
199
+					}
195 200
 					if($i === $trimToBestXRoutes) {
196 201
 						self::$dontAddWorseThan[self::EXP_ROUTE] = $multi;
197 202
 						continue;
@@ -206,16 +211,15 @@  discard block
 block discarded – undo
206 211
 		foreach(self::$moneyRoutes as $multi => &$routesByMulti) {
207 212
 			if(count($routesByMulti)+$i < $trimToBestXRoutes) {
208 213
 				$i += count($routesByMulti);
209
-			}
210
-			else if($i > $trimToBestXRoutes) {
214
+			} else if($i > $trimToBestXRoutes) {
211 215
 				unset(self::$moneyRoutes[$multi]);
212 216
 				continue;
213
-			}
214
-			else {
217
+			} else {
215 218
 				foreach($routesByMulti as $key => &$value) {
216 219
 					$i++;
217
-					if($i < $trimToBestXRoutes)
218
-						continue;
220
+					if($i < $trimToBestXRoutes) {
221
+											continue;
222
+					}
219 223
 					if($i === $trimToBestXRoutes) {
220 224
 						self::$dontAddWorseThan[self::MONEY_ROUTE] = $multi;
221 225
 						continue;
@@ -379,18 +383,21 @@  discard block
 block discarded – undo
379 383
 	}
380 384
 
381 385
 	public function getTurnsForRoute() {
382
-		if ($this->goodId === GOOD_NOTHING)
383
-			$tradeTurns = 0;
384
-		else
385
-			$tradeTurns = 2 * TURNS_PER_TRADE;
386
+		if ($this->goodId === GOOD_NOTHING) {
387
+					$tradeTurns = 0;
388
+		} else {
389
+					$tradeTurns = 2 * TURNS_PER_TRADE;
390
+		}
386 391
 		return $this->distance->getTurns() + $tradeTurns;
387 392
 	}
388 393
 
389 394
 	public function compareTo(OneWayRoute &$compare) {
390
-		if ($this->equals($compare)===true)
391
-			return 0;
392
-		if ($this->getOverallExpMultiplier() > $compare->getOverallExpMultiplier())
393
-			return 1;
395
+		if ($this->equals($compare)===true) {
396
+					return 0;
397
+		}
398
+		if ($this->getOverallExpMultiplier() > $compare->getOverallExpMultiplier()) {
399
+					return 1;
400
+		}
394 401
 		return -1;
395 402
 	}
396 403
 
Please login to merge, or discard this patch.
lib/Default/SmrWeapon.class.inc 1 patch
Braces   +26 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,17 +12,19 @@  discard block
 block discarded – undo
12 12
 
13 13
 	
14 14
 	protected static function initialiseDatabase() {
15
-		if(self::$db==null)
16
-			self::$db = new SmrMySqlDatabase();
15
+		if(self::$db==null) {
16
+					self::$db = new SmrMySqlDatabase();
17
+		}
17 18
 	}
18 19
 
19 20
 	public static function &getWeapon($weaponTypeID, $forceUpdate=false, $db=null) {
20 21
 		if($forceUpdate || !isset(self::$CACHE_WEAPONS[$weaponTypeID])) {
21 22
 			$w = new SmrWeapon($weaponTypeID, $db);
22
-			if ($w->exists())
23
-				self::$CACHE_WEAPONS[$weaponTypeID] = $w;
24
-			else
25
-				self::$CACHE_WEAPONS[$weaponTypeID] = false;
23
+			if ($w->exists()) {
24
+							self::$CACHE_WEAPONS[$weaponTypeID] = $w;
25
+			} else {
26
+							self::$CACHE_WEAPONS[$weaponTypeID] = false;
27
+			}
26 28
 		}
27 29
 		return self::$CACHE_WEAPONS[$weaponTypeID];
28 30
 	}
@@ -115,8 +117,9 @@  discard block
 block discarded – undo
115 117
 	public function getModifiedAccuracy(AbstractSmrPlayer $weaponPlayer) {
116 118
 		$modifiedAccuracy = $this->getBaseAccuracy();
117 119
 		$modifiedAccuracy += $this->getBaseAccuracy() * self::getPlayerLevelAccuracyMod($weaponPlayer);
118
-		if ($weaponPlayer->isGadgetEquipped('Increased Accuracy'))
119
-			$modifiedAccuracy += $this->getBaseAccuracy() * INCREASED_ACC_GADGET_FACTOR/100;
120
+		if ($weaponPlayer->isGadgetEquipped('Increased Accuracy')) {
121
+					$modifiedAccuracy += $this->getBaseAccuracy() * INCREASED_ACC_GADGET_FACTOR/100;
122
+		}
120 123
 		return $modifiedAccuracy;
121 124
 	}
122 125
 	
@@ -140,14 +143,16 @@  discard block
 block discarded – undo
140 143
 	public function getModifiedAccuracyAgainstPlayer(AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) {
141 144
 		$modifiedAccuracy = $this->getModifiedAccuracy($weaponPlayer);
142 145
 		$modifiedAccuracy -= $this->getBaseAccuracy() * self::getPlayerLevelAccuracyMod($targetPlayer) / 2;
143
-		if ($targetPlayer->isGadgetEquipped('Increased Maneuverability'))
144
-			$modifiedAccuracy -= $this->getBaseAccuracy() * INCREASED_MAN_GADGET_FACTOR/100;
146
+		if ($targetPlayer->isGadgetEquipped('Increased Maneuverability')) {
147
+					$modifiedAccuracy -= $this->getBaseAccuracy() * INCREASED_MAN_GADGET_FACTOR/100;
148
+		}
145 149
 		
146 150
 		$weaponShip = $weaponPlayer->getShip();
147 151
 		$targetShip = $targetPlayer->getShip();
148 152
 		$mrDiff = $targetShip->getMR() - $weaponShip->getMR();
149
-		if($mrDiff > 0)
150
-			$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff/MR_FACTOR)/100;
153
+		if($mrDiff > 0) {
154
+					$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff/MR_FACTOR)/100;
155
+		}
151 156
 	
152 157
 		return $modifiedAccuracy;
153 158
 	}
@@ -191,22 +196,28 @@  discard block
 block discarded – undo
191 196
 	}
192 197
 	
193 198
 	public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
194
-		if(!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
199
+		if(!$this->canShootForces()) {
200
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
195 201
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
202
+		}
196 203
 		$damage =& $this->getModifiedDamage($weaponPlayer);
197 204
 		return $damage;
198 205
 	}
199 206
 	
200 207
 	public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
201
-		if(!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
208
+		if(!$this->canShootPorts()) {
209
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
202 210
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
211
+		}
203 212
 		$damage =& $this->getModifiedDamage($weaponPlayer);
204 213
 		return $damage;
205 214
 	}
206 215
 	
207 216
 	public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) {
208
-		if(!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
217
+		if(!$this->canShootPlanets()) {
218
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
209 219
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
220
+		}
210 221
 		$damage =& $this->getModifiedDamage($weaponPlayer);
211 222
 		
212 223
 		$planetMod = self::PLANET_DAMAGE_MOD;
Please login to merge, or discard this patch.