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

Passed
Branch master (0a752f)
by Dan
03:57
created
lib/Default/SmrCombatDrones.class.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
130 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.
131 131
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
132
-		$damage =& $this->getModifiedDamage();
132
+		$damage = & $this->getModifiedDamage();
133 133
 		$damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstForces($weaponPlayer, $forces) / 100);
134 134
 		$damage['Kamikaze'] = 0;
135 135
 		if ($weaponPlayer->isCombatDronesKamikazeOnMines()) { // If kamikaze then damage is same as MINE_ARMOUR
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
152 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.
153 153
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
154
-		$damage =& $this->getModifiedDamage();
154
+		$damage = & $this->getModifiedDamage();
155 155
 		$damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPort($weaponPlayer, $port) / 100);
156 156
 		$damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage']);
157 157
 		$damage['Shield'] = ceil($damage['Launched'] * $damage['Shield']);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) {
164 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.
165 165
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
166
-		$damage =& $this->getModifiedDamage();
166
+		$damage = & $this->getModifiedDamage();
167 167
 		$damage['Launched'] = ceil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPlanet($weaponPlayer, $planet) / 100);
168 168
 		$planetMod = self::PLANET_DAMAGE_MOD;
169 169
 		$damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage'] * $planetMod);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 			$return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
179 179
 			return $return;
180 180
 		}
181
-		$damage =& $this->getModifiedDamage();
181
+		$damage = & $this->getModifiedDamage();
182 182
 		if ($targetPlayer->getShip()->hasDCS()) {
183 183
 			$damage['MaxDamage'] *= DCS_PLAYER_DAMAGE_DECIMAL_PERCENT;
184 184
 			$damage['Shield'] *= DCS_PLAYER_DAMAGE_DECIMAL_PERCENT;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 			$return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
197 197
 			return $return;
198 198
 		}
199
-		$damage =& $this->getModifiedDamage();
199
+		$damage = & $this->getModifiedDamage();
200 200
 		
201 201
 		if ($targetPlayer->getShip()->hasDCS()) {
202 202
 			$damage['MaxDamage'] *= DCS_FORCE_DAMAGE_DECIMAL_PERCENT;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 			$return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
217 217
 			return $return;
218 218
 		}
219
-		$damage =& $this->getModifiedDamage();
219
+		$damage = & $this->getModifiedDamage();
220 220
 		
221 221
 		if ($targetPlayer->getShip()->hasDCS()) {
222 222
 			$damage['MaxDamage'] *= DCS_PORT_DAMAGE_DECIMAL_PERCENT;
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			$return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
236 236
 			return $return;
237 237
 		}
238
-		$damage =& $this->getModifiedDamage();
238
+		$damage = & $this->getModifiedDamage();
239 239
 		
240 240
 		if ($targetPlayer->getShip()->hasDCS()) {
241 241
 			$damage['MaxDamage'] *= DCS_PLANET_DAMAGE_DECIMAL_PERCENT;
Please login to merge, or discard this 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/Template.class.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 		$ajaxEnabled = ($this->data['AJAX_ENABLE_REFRESH'] ?? false) !== false;
59 59
 		if ($ajaxEnabled) {
60
-			$ajaxXml =& $this->convertHtmlToAjaxXml($output, $outputXml);
60
+			$ajaxXml = & $this->convertHtmlToAjaxXml($output, $outputXml);
61 61
 			if ($outputXml) {
62 62
 				/* Left out for size: <?xml version="1.0" encoding="ISO-8859-1"?>*/
63 63
 				$output = '<all>' . $ajaxXml . '</all>';
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	}
143 143
 	
144 144
 	protected function &stopCapture() {
145
-		$captured =& $this->captures[$this->currentCaptureID];
145
+		$captured = & $this->captures[$this->currentCaptureID];
146 146
 		unset($this->captures[$this->currentCaptureID]);
147 147
 		$captured .= ob_get_contents();
148 148
 		ob_clean();
Please login to merge, or discard this patch.
lib/Default/DummyShip.class.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 		$this->cargo_left = $this->getCargoHolds();
18 18
 	}
19 19
 	protected function doFullUNO() {
20
-		foreach($this->getMaxHardware() as $hardwareTypeID => $max) {
20
+		foreach ($this->getMaxHardware() as $hardwareTypeID => $max) {
21 21
 			$this->hardware[$hardwareTypeID] = $max;
22 22
 			$this->oldHardware[$hardwareTypeID] = $max;
23 23
 		}
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	}
48 48
 	
49 49
 	public function getIllusionShip() {
50
-		if(!isset($this->illusionShip)) {
51
-			$this->illusionShip=false;
50
+		if (!isset($this->illusionShip)) {
51
+			$this->illusionShip = false;
52 52
 		}
53 53
 		return $this->illusionShip;
54 54
 	}
@@ -58,20 +58,20 @@  discard block
 block discarded – undo
58 58
 		$db = new SmrMySqlDatabase();
59 59
 		$db->query('REPLACE INTO cached_dummys ' .
60 60
 					'(type, id, info) ' .
61
-					'VALUES (\'DummyShip\', '.$db->escapeString($this->getPlayer()->getPlayerName()).', '.$db->escapeString($cache).')');
61
+					'VALUES (\'DummyShip\', ' . $db->escapeString($this->getPlayer()->getPlayerName()) . ', ' . $db->escapeString($cache) . ')');
62 62
 		unserialize($cache);
63 63
 	}
64 64
 	
65 65
 	public static function &getCachedDummyShip(AbstractSmrPlayer $player) {
66
-		if(!isset(self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()])) {
66
+		if (!isset(self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()])) {
67 67
 			$db = new SmrMySqlDatabase();
68 68
 			$db->query('SELECT info FROM cached_dummys
69 69
 						WHERE type = \'DummyShip\'
70 70
 						AND id = ' . $db->escapeString($player->getPlayerName()) . ' LIMIT 1');
71
-			if($db->nextRecord()) {
71
+			if ($db->nextRecord()) {
72 72
 				$return = unserialize($db->getField('info'));
73 73
 				$return->regenerate($player);
74
-				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] =& $return;
74
+				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = & $return;
75 75
 			}
76 76
 			else {
77 77
 				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = new DummyShip($player);
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		$db->query('SELECT id FROM cached_dummys
86 86
 					WHERE type = \'DummyShip\'');
87 87
 		$dummyNames = array();
88
-		while($db->nextRecord()) {
88
+		while ($db->nextRecord()) {
89 89
 			$dummyNames[] = $db->getField('id');
90 90
 		}
91 91
 		return $dummyNames;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	
95 95
 	
96 96
 	public function __sleep() {
97
-		return array('gameID','weapons');
97
+		return array('gameID', 'weapons');
98 98
 	}
99 99
 	
100 100
 	public function __wakeup() {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,8 +72,7 @@
 block discarded – undo
72 72
 				$return = unserialize($db->getField('info'));
73 73
 				$return->regenerate($player);
74 74
 				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] =& $return;
75
-			}
76
-			else {
75
+			} else {
77 76
 				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = new DummyShip($player);
78 77
 			}
79 78
 		}
Please login to merge, or discard this patch.
lib/Default/SmrSession.class.php 1 patch
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -156,8 +156,7 @@  discard block
 block discarded – undo
156 156
 		// now try the cookie
157 157
 		if (isset($_COOKIE['session_id']) && strlen($_COOKIE['session_id']) === 32) {
158 158
 			self::$session_id = $_COOKIE['session_id'];
159
-		}
160
-		else {
159
+		} else {
161 160
 			// create a new session id
162 161
 			do {
163 162
 				self::$session_id = md5(uniqid(mt_rand()));
@@ -209,18 +208,15 @@  discard block
 block discarded – undo
209 208
 				self::$account_id = 0;
210 209
 				self::$game_id = 0;
211 210
 				self::$var = array();
212
-			}
213
-			else {
211
+			} else {
214 212
 				foreach (self::$var as $key => &$value) {
215 213
 					if ($value['Expires'] > 0 && $value['Expires'] <= TIME) { // Use 0 for infinity
216 214
 						//This link is no longer valid
217 215
 						unset(self::$var[$key]);
218
-					}
219
-					else if ($value['RemainingPageLoads'] < 0) {
216
+					} else if ($value['RemainingPageLoads'] < 0) {
220 217
 						//This link is no longer valid
221 218
 						unset(self::$var[$key]);
222
-					}
223
-					else {
219
+					} else {
224 220
 						--$value['RemainingPageLoads'];
225 221
 						if (isset($value['CommonID'])) {
226 222
 							self::$commonIDs[$value['CommonID']] = $key;
@@ -228,8 +224,7 @@  discard block
 block discarded – undo
228 224
 					}
229 225
 				} unset($value);
230 226
 			}
231
-		}
232
-		else {
227
+		} else {
233 228
 			self::$generate = true;
234 229
 			self::$account_id = 0;
235 230
 			self::$game_id = 0;
@@ -250,8 +245,7 @@  discard block
 block discarded – undo
250 245
 			self::$db->query('UPDATE active_session SET account_id=' . self::$db->escapeNumber(self::$account_id) . ',game_id=' . self::$db->escapeNumber(self::$game_id) . (!USING_AJAX ? ',last_accessed=' . self::$db->escapeNumber(TIME) : '') . ',session_var=' . self::$db->escapeBinary($compressed) .
251 246
 					',last_sn=' . self::$db->escapeString(self::$SN) .
252 247
 					' WHERE session_id=' . self::$db->escapeString(self::$session_id) . (USING_AJAX ? ' AND last_sn=' . self::$db->escapeString(self::$lastSN) : '') . ' LIMIT 1');
253
-		}
254
-		else {
248
+		} else {
255 249
 			self::$db->query('DELETE FROM active_session WHERE account_id = ' . self::$db->escapeNumber(self::$account_id) . ' AND game_id = ' . self::$db->escapeNumber(self::$game_id));
256 250
 			self::$db->query('INSERT INTO active_session (session_id, account_id, game_id, last_accessed, session_var) VALUES(' . self::$db->escapeString(self::$session_id) . ',' . self::$db->escapeNumber(self::$account_id) . ',' . self::$db->escapeNumber(self::$game_id) . ',' . self::$db->escapeNumber(TIME) . ',' . self::$db->escapeBinary($compressed) . ')');
257 251
 			self::$generate = false;
@@ -398,8 +392,7 @@  discard block
 block discarded – undo
398 392
 		if ($value === null) {
399 393
 			unset($var[$key]);
400 394
 			unset(self::$var[self::$SN][$key]);
401
-		}
402
-		else {
395
+		} else {
403 396
 			$var[$key] = $value;
404 397
 			self::$var[self::$SN][$key] = $value;
405 398
 		}
@@ -421,8 +414,7 @@  discard block
 block discarded – undo
421 414
 
422 415
 		if ($sn === false) {
423 416
 			$sn = self::generateSN($container);
424
-		}
425
-		else {
417
+		} else {
426 418
 			// If we've been provided an SN to use then copy over the existing 'PreviousRequestTime'
427 419
 			$container['PreviousRequestTime'] = self::$var[$sn]['PreviousRequestTime'];
428 420
 		}
@@ -435,8 +427,7 @@  discard block
 block discarded – undo
435 427
 		if (isset(self::$commonIDs[$container['CommonID']])) {
436 428
 			$sn = self::$commonIDs[$container['CommonID']];
437 429
 			$container['PreviousRequestTime'] = isset(self::$var[$sn]) ? self::$var[$sn]['PreviousRequestTime'] : MICRO_TIME;
438
-		}
439
-		else {
430
+		} else {
440 431
 			do {
441 432
 				$sn = substr(md5(mt_rand()), 0, 8);
442 433
 			} while (isset(self::$var[$sn]));
Please login to merge, or discard this patch.
lib/Default/AbstractSmrShip.class.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	public function setWeaponLocations(array $orderArray) {
285 285
 		$weapons = $this->weapons;
286 286
 		foreach ($orderArray as $newOrder => $oldOrder) {
287
-			$this->weapons[$newOrder] =& $weapons[$oldOrder];
287
+			$this->weapons[$newOrder] = & $weapons[$oldOrder];
288 288
 		}
289 289
 		$this->hasChangedWeapons = true;
290 290
 	}
@@ -865,13 +865,13 @@  discard block
 block discarded – undo
865 865
 		}
866 866
 		$results['DeadBeforeShot'] = false;
867 867
 		foreach ($this->weapons as $orderID => $weapon) {
868
-			$results['Weapons'][$orderID] =& $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
868
+			$results['Weapons'][$orderID] = & $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
869 869
 			if ($results['Weapons'][$orderID]['Hit'])
870 870
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
871 871
 		}
872 872
 		if ($this->hasCDs()) {
873 873
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
874
-			$results['Drones'] =& $thisCDs->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
874
+			$results['Drones'] = & $thisCDs->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
875 875
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
876 876
 		}
877 877
 		$thisPlayer->increaseExperience(round($results['TotalDamage'] * self::EXP_PER_DAMAGE_PLAYER));
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 		}
890 890
 		$results['DeadBeforeShot'] = false;
891 891
 		foreach ($this->weapons as $orderID => $weapon) {
892
-			$results['Weapons'][$orderID] =& $weapon->shootForces($thisPlayer, $forces);
892
+			$results['Weapons'][$orderID] = & $weapon->shootForces($thisPlayer, $forces);
893 893
 			if ($results['Weapons'][$orderID]['Hit']) {
894 894
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
895 895
 				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines'], array('Combat', 'Forces', 'Mines', 'Killed'), HOF_PUBLIC);
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
 		}
904 904
 		if ($this->hasCDs()) {
905 905
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
906
-			$results['Drones'] =& $thisCDs->shootForces($thisPlayer, $forces);
906
+			$results['Drones'] = & $thisCDs->shootForces($thisPlayer, $forces);
907 907
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
908 908
 			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines'], array('Combat', 'Forces', 'Mines', 'Killed'), HOF_PUBLIC);
909 909
 			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['Mines'], array('Combat', 'Forces', 'Mines', 'Damage Done'), HOF_PUBLIC);
@@ -928,13 +928,13 @@  discard block
 block discarded – undo
928 928
 		}
929 929
 		$results['DeadBeforeShot'] = false;
930 930
 		foreach ($this->weapons as $orderID => $weapon) {
931
-			$results['Weapons'][$orderID] =& $weapon->shootPort($thisPlayer, $port);
931
+			$results['Weapons'][$orderID] = & $weapon->shootPort($thisPlayer, $port);
932 932
 			if ($results['Weapons'][$orderID]['Hit'])
933 933
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
934 934
 		}
935 935
 		if ($this->hasCDs()) {
936 936
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
937
-			$results['Drones'] =& $thisCDs->shootPort($thisPlayer, $port);
937
+			$results['Drones'] = & $thisCDs->shootPort($thisPlayer, $port);
938 938
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
939 939
 		}
940 940
 		$thisPlayer->increaseExperience(round($results['TotalDamage'] * self::EXP_PER_DAMAGE_PORT));
@@ -965,13 +965,13 @@  discard block
 block discarded – undo
965 965
 		}
966 966
 		$results['DeadBeforeShot'] = false;
967 967
 		foreach ($this->weapons as $orderID => $weapon) {
968
-			$results['Weapons'][$orderID] =& $weapon->shootPlanet($thisPlayer, $planet, $delayed);
968
+			$results['Weapons'][$orderID] = & $weapon->shootPlanet($thisPlayer, $planet, $delayed);
969 969
 			if ($results['Weapons'][$orderID]['Hit'])
970 970
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
971 971
 		}
972 972
 		if ($this->hasCDs()) {
973 973
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
974
-			$results['Drones'] =& $thisCDs->shootPlanet($thisPlayer, $planet, $delayed);
974
+			$results['Drones'] = & $thisCDs->shootPlanet($thisPlayer, $planet, $delayed);
975 975
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
976 976
 		}
977 977
 		$thisPlayer->increaseExperience(round($results['TotalDamage'] * self::EXP_PER_DAMAGE_PLANET));
Please login to merge, or discard this patch.
Braces   +84 added lines, -62 removed lines patch added patch discarded remove patch
@@ -34,10 +34,11 @@  discard block
 block discarded – undo
34 34
 			// determine ship
35 35
 			$db = new SmrMySqlDatabase();
36 36
 			$db->query('SELECT * FROM ship_type WHERE ship_type_id = ' . $db->escapeNumber($shipTypeID) . ' LIMIT 1'); //TODO add game type id
37
-			if ($db->nextRecord())
38
-				self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = self::buildBaseShip($db);
39
-			else
40
-				self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = false;
37
+			if ($db->nextRecord()) {
38
+							self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = self::buildBaseShip($db);
39
+			} else {
40
+							self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = false;
41
+			}
41 42
 		}
42 43
 		return self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID];
43 44
 	}
@@ -167,19 +168,21 @@  discard block
 block discarded – undo
167 168
 
168 169
 	public function checkForExcessHardware() {
169 170
 		//check hardware to see if anything needs to be removed
170
-		if (is_array($hardware = $this->getHardware()))
171
-			foreach ($hardware as $hardwareTypeID => $amount) {
171
+		if (is_array($hardware = $this->getHardware())) {
172
+					foreach ($hardware as $hardwareTypeID => $amount) {
172 173
 				if ($amount > ($max = $this->getMaxHardware($hardwareTypeID))) {
173 174
 					$this->setHardware($hardwareTypeID, $max, true);
175
+		}
174 176
 				}
175 177
 			}
176 178
 	}
177 179
 
178 180
 	public function getPowerUsed() {
179 181
 		$power = 0;
180
-		if ($this->getNumWeapons() > 0)
181
-			foreach ($this->weapons as $weapon)
182
+		if ($this->getNumWeapons() > 0) {
183
+					foreach ($this->weapons as $weapon)
182 184
 				$power += $weapon->getPowerLevel();
185
+		}
183 186
 		return $power;
184 187
 	}
185 188
 
@@ -200,17 +203,19 @@  discard block
 block discarded – undo
200 203
 	}
201 204
 
202 205
 	public function getDisplayAttackRating(AbstractSmrPlayer $player) {
203
-		if ($this->hasActiveIllusion())
204
-			return $this->getIllusionAttack();
205
-		else
206
-			return $this->getAttackRating();
206
+		if ($this->hasActiveIllusion()) {
207
+					return $this->getIllusionAttack();
208
+		} else {
209
+					return $this->getAttackRating();
210
+		}
207 211
 	}
208 212
 
209 213
 	public function getDisplayDefenseRating() {
210
-		if ($this->hasActiveIllusion())
211
-			return $this->getIllusionDefense();
212
-		else
213
-			return $this->getDefenseRating();
214
+		if ($this->hasActiveIllusion()) {
215
+					return $this->getIllusionDefense();
216
+		} else {
217
+					return $this->getDefenseRating();
218
+		}
214 219
 	}
215 220
 
216 221
 	public function getAttackRating() {
@@ -256,8 +261,7 @@  discard block
 block discarded – undo
256 261
 		if ($replacement < 0) {
257 262
 			// Shift everything up by one and put the selected weapon at the bottom
258 263
 			array_push($this->weapons, array_shift($this->weapons));
259
-		}
260
-		else {
264
+		} else {
261 265
 			// Swap the selected weapon with the one above it
262 266
 			$temp = $this->weapons[$replacement];
263 267
 			$this->weapons[$replacement] = $this->weapons[$orderID];
@@ -271,8 +275,7 @@  discard block
 block discarded – undo
271 275
 		if ($replacement >= count($this->weapons)) {
272 276
 			// Shift everything down by one and put the selected weapon at the top
273 277
 			array_unshift($this->weapons, array_pop($this->weapons));
274
-		}
275
-		else {
278
+		} else {
276 279
 			// Swap the selected weapon with the one below it
277 280
 			$temp = $this->weapons[$replacement];
278 281
 			$this->weapons[$replacement] = $this->weapons[$orderID];
@@ -331,8 +334,7 @@  discard block
 block discarded – undo
331 334
 			$this->setArmour(150, true);
332 335
 			$this->setCargoHolds(40);
333 336
 			$this->setShipTypeID(SHIP_TYPE_NEWBIE_MERCHANT_VESSEL);
334
-		}
335
-		else {
337
+		} else {
336 338
 			$this->setShields(50, true);
337 339
 			$this->setArmour(50, true);
338 340
 			$this->setCargoHolds(5);
@@ -352,8 +354,9 @@  discard block
 block discarded – undo
352 354
 
353 355
 
354 356
 	public function hasActiveIllusion() {
355
-		if (!$this->hasIllusion())
356
-			return false;
357
+		if (!$this->hasIllusion()) {
358
+					return false;
359
+		}
357 360
 		return $this->getIllusionShip() !== false;
358 361
 
359 362
 	}
@@ -487,14 +490,16 @@  discard block
 block discarded – undo
487 490
 	}
488 491
 
489 492
 	public function getHardware($hardwareTypeID = false) {
490
-		if ($hardwareTypeID === false)
491
-			return $this->hardware;
493
+		if ($hardwareTypeID === false) {
494
+					return $this->hardware;
495
+		}
492 496
 		return isset($this->hardware[$hardwareTypeID]) ? $this->hardware[$hardwareTypeID] : 0;
493 497
 	}
494 498
 
495 499
 	public function setHardware($hardwareTypeID, $amount) {
496
-		if ($this->getHardware($hardwareTypeID) == $amount)
497
-			return;
500
+		if ($this->getHardware($hardwareTypeID) == $amount) {
501
+					return;
502
+		}
498 503
 		$this->hardware[$hardwareTypeID] = $amount;
499 504
 		$this->hasChangedHardware[$hardwareTypeID] = true;
500 505
 	}
@@ -504,14 +509,16 @@  discard block
 block discarded – undo
504 509
 	}
505 510
 
506 511
 	public function getOldHardware($hardwareTypeID = false) {
507
-		if ($hardwareTypeID === false)
508
-			return $this->oldHardware;
512
+		if ($hardwareTypeID === false) {
513
+					return $this->oldHardware;
514
+		}
509 515
 		return isset($this->oldHardware[$hardwareTypeID]) ? $this->oldHardware[$hardwareTypeID] : 0;
510 516
 	}
511 517
 
512 518
 	public function setOldHardware($hardwareTypeID, $amount) {
513
-		if ($this->getOldHardware($hardwareTypeID) == $amount)
514
-			return;
519
+		if ($this->getOldHardware($hardwareTypeID) == $amount) {
520
+					return;
521
+		}
515 522
 		$this->oldHardware[$hardwareTypeID] = $amount;
516 523
 		$this->hasChangedHardware[$hardwareTypeID] = true;
517 524
 	}
@@ -521,8 +528,9 @@  discard block
 block discarded – undo
521 528
 	}
522 529
 
523 530
 	public function getMaxHardware($hardwareTypeID = false) {
524
-		if ($hardwareTypeID === false)
525
-			return $this->baseShip['MaxHardware'];
531
+		if ($hardwareTypeID === false) {
532
+					return $this->baseShip['MaxHardware'];
533
+		}
526 534
 		return $this->baseShip['MaxHardware'][$hardwareTypeID];
527 535
 	}
528 536
 
@@ -531,8 +539,9 @@  discard block
 block discarded – undo
531 539
 	}
532 540
 
533 541
 	public function setShields($amount, $updateOldAmount = false) {
534
-		if ($updateOldAmount && !$this->hasLostShields())
535
-			$this->setOldHardware(HARDWARE_SHIELDS, $amount);
542
+		if ($updateOldAmount && !$this->hasLostShields()) {
543
+					$this->setOldHardware(HARDWARE_SHIELDS, $amount);
544
+		}
536 545
 		$this->setHardware(HARDWARE_SHIELDS, $amount);
537 546
 	}
538 547
 
@@ -573,8 +582,9 @@  discard block
 block discarded – undo
573 582
 	}
574 583
 
575 584
 	public function setArmour($amount, $updateOldAmount = false) {
576
-		if ($updateOldAmount && !$this->hasLostArmour())
577
-			$this->setOldHardware(HARDWARE_ARMOUR, $amount);
585
+		if ($updateOldAmount && !$this->hasLostArmour()) {
586
+					$this->setOldHardware(HARDWARE_ARMOUR, $amount);
587
+		}
578 588
 		$this->setHardware(HARDWARE_ARMOUR, $amount);
579 589
 	}
580 590
 
@@ -643,8 +653,9 @@  discard block
 block discarded – undo
643 653
 	}
644 654
 
645 655
 	public function setCDs($amount, $updateOldAmount = false) {
646
-		if ($updateOldAmount && !$this->hasLostCDs())
647
-			$this->setOldHardware(HARDWARE_COMBAT, $amount);
656
+		if ($updateOldAmount && !$this->hasLostCDs()) {
657
+					$this->setOldHardware(HARDWARE_COMBAT, $amount);
658
+		}
648 659
 		$this->setHardware(HARDWARE_COMBAT, $amount);
649 660
 	}
650 661
 
@@ -726,8 +737,9 @@  discard block
 block discarded – undo
726 737
 
727 738
 	public function &getCargo($goodID = false) {
728 739
 		if ($goodID !== false) {
729
-			if (isset($this->cargo[$goodID]))
730
-				return $this->cargo[$goodID];
740
+			if (isset($this->cargo[$goodID])) {
741
+							return $this->cargo[$goodID];
742
+			}
731 743
 			$cargo = 0;
732 744
 			return $cargo;
733 745
 		}
@@ -735,16 +747,19 @@  discard block
 block discarded – undo
735 747
 	}
736 748
 
737 749
 	public function hasCargo($goodID = false) {
738
-		if ($goodID !== false)
739
-			return $this->getCargo($goodID) > 0;
740
-		if (is_array($cargo = $this->getCargo()))
741
-			return array_sum($cargo) > 0;
750
+		if ($goodID !== false) {
751
+					return $this->getCargo($goodID) > 0;
752
+		}
753
+		if (is_array($cargo = $this->getCargo())) {
754
+					return array_sum($cargo) > 0;
755
+		}
742 756
 		return false;
743 757
 	}
744 758
 
745 759
 	public function setCargo($goodID, $amount) {
746
-		if ($this->getCargo($goodID) == $amount)
747
-			return;
760
+		if ($this->getCargo($goodID) == $amount) {
761
+					return;
762
+		}
748 763
 		$this->cargo[$goodID] = $amount;
749 764
 		$this->hasChangedCargo = true;
750 765
 		// Sort cargo by goodID to make sure it shows up in the correct order
@@ -753,14 +768,16 @@  discard block
 block discarded – undo
753 768
 	}
754 769
 
755 770
 	public function decreaseCargo($goodID, $amount) {
756
-		if ($amount < 0)
757
-			throw new Exception('Trying to decrease negative cargo.');
771
+		if ($amount < 0) {
772
+					throw new Exception('Trying to decrease negative cargo.');
773
+		}
758 774
 		$this->setCargo($goodID, $this->getCargo($goodID) - $amount);
759 775
 	}
760 776
 
761 777
 	public function increaseCargo($goodID, $amount) {
762
-		if ($amount < 0)
763
-			throw new Exception('Trying to increase negative cargo.');
778
+		if ($amount < 0) {
779
+					throw new Exception('Trying to increase negative cargo.');
780
+		}
764 781
 		$this->setCargo($goodID, $this->getCargo($goodID) + $amount);
765 782
 	}
766 783
 
@@ -790,8 +807,9 @@  discard block
 block discarded – undo
790 807
 		$this->setOldShields($this->getShields());
791 808
 		$this->setOldCDs($this->getCDs());
792 809
 		$this->setOldArmour($this->getArmour());
793
-		if (isset($var['UnderAttack']))
794
-			return $var['UnderAttack'];
810
+		if (isset($var['UnderAttack'])) {
811
+					return $var['UnderAttack'];
812
+		}
795 813
 		if ($underAttack && !USING_AJAX) {
796 814
 			SmrSession::updateVar('UnderAttack', $underAttack); //Remember we are under attack for AJAX
797 815
 		}
@@ -866,8 +884,9 @@  discard block
 block discarded – undo
866 884
 		$results['DeadBeforeShot'] = false;
867 885
 		foreach ($this->weapons as $orderID => $weapon) {
868 886
 			$results['Weapons'][$orderID] =& $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
869
-			if ($results['Weapons'][$orderID]['Hit'])
870
-				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
887
+			if ($results['Weapons'][$orderID]['Hit']) {
888
+							$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
889
+			}
871 890
 		}
872 891
 		if ($this->hasCDs()) {
873 892
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
@@ -929,8 +948,9 @@  discard block
 block discarded – undo
929 948
 		$results['DeadBeforeShot'] = false;
930 949
 		foreach ($this->weapons as $orderID => $weapon) {
931 950
 			$results['Weapons'][$orderID] =& $weapon->shootPort($thisPlayer, $port);
932
-			if ($results['Weapons'][$orderID]['Hit'])
933
-				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
951
+			if ($results['Weapons'][$orderID]['Hit']) {
952
+							$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
953
+			}
934 954
 		}
935 955
 		if ($this->hasCDs()) {
936 956
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
@@ -966,8 +986,9 @@  discard block
 block discarded – undo
966 986
 		$results['DeadBeforeShot'] = false;
967 987
 		foreach ($this->weapons as $orderID => $weapon) {
968 988
 			$results['Weapons'][$orderID] =& $weapon->shootPlanet($thisPlayer, $planet, $delayed);
969
-			if ($results['Weapons'][$orderID]['Hit'])
970
-				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
989
+			if ($results['Weapons'][$orderID]['Hit']) {
990
+							$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
991
+			}
971 992
 		}
972 993
 		if ($this->hasCDs()) {
973 994
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
@@ -992,8 +1013,9 @@  discard block
 block discarded – undo
992 1013
 				$cdDamage = $this->doCDDamage(min($damage['MaxDamage'], $damage['Armour']));
993 1014
 				$damage['Armour'] -= $cdDamage;
994 1015
 				$damage['MaxDamage'] -= $cdDamage;
995
-				if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover']))
996
-					$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour']));
1016
+				if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) {
1017
+									$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour']));
1018
+				}
997 1019
 			}
998 1020
 		}
999 1021
 		$return = array(
Please login to merge, or discard this patch.
lib/Default/SmrSector.class.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -549,7 +549,7 @@
 block discarded – undo
549 549
 	 */
550 550
 	public function setWarp(SmrSector $warp) {
551 551
 		if ($this->getWarp() == $warp->getSectorID() &&
552
-		    $warp->getWarp() == $this->getSectorID()) {
552
+			$warp->getWarp() == $this->getSectorID()) {
553 553
 			// Warps are already set correctly!
554 554
 			return;
555 555
 		}
Please login to merge, or discard this patch.
Braces   +143 added lines, -99 removed lines patch added patch discarded remove patch
@@ -126,15 +126,13 @@  discard block
 block discarded – undo
126 126
 				$this->links['Right'] = $db->getInt('link_right');
127 127
 			}
128 128
 			$this->warp = $db->getInt('warp');
129
-		}
130
-		else if ($create) {
129
+		} else if ($create) {
131 130
 			$this->battles = 0;
132 131
 			$this->links = array();
133 132
 			$this->warp = 0;
134 133
 			$this->isNew = true;
135 134
 			return;
136
-		}
137
-		else {
135
+		} else {
138 136
 			throw new SectorNotFoundException('No sector ' . $sectorID . ' in game ' . $gameID);
139 137
 		}
140 138
 	}
@@ -167,52 +165,59 @@  discard block
 block discarded – undo
167 165
 	}
168 166
 
169 167
 	public function markVisited(AbstractSmrPlayer $player) {
170
-		if ($this->hasPort())
171
-			$this->getPort()->addCachePort($player->getAccountID());
168
+		if ($this->hasPort()) {
169
+					$this->getPort()->addCachePort($player->getAccountID());
170
+		}
172 171
 
173 172
 		//now delete the entry from visited
174
-		if (!$this->isVisited($player))
175
-			$this->db->query('DELETE FROM player_visited_sector WHERE ' . $this->SQL . '
173
+		if (!$this->isVisited($player)) {
174
+					$this->db->query('DELETE FROM player_visited_sector WHERE ' . $this->SQL . '
176 175
 								 AND account_id = ' . $this->db->escapeNumber($player->getAccountID()) . ' LIMIT 1');
176
+		}
177 177
 		$this->visited[$player->getAccountID()] = true;
178 178
 	}
179 179
 
180 180
 	public function hasWeaponShop() {
181 181
 		foreach ($this->getLocations() as $location) {
182
-			if ($location->isWeaponSold())
183
-				return true;
182
+			if ($location->isWeaponSold()) {
183
+							return true;
184
+			}
184 185
 		}
185 186
 		return false;
186 187
 	}
187 188
 
188 189
 	public function hasHQ() {
189 190
 		foreach ($this->getLocations() as $location) {
190
-			if ($location->isHQ())
191
-				return true;
191
+			if ($location->isHQ()) {
192
+							return true;
193
+			}
192 194
 		}
193 195
 		return false;
194 196
 	}
195 197
 
196 198
 	public function hasUG() {
197 199
 		foreach ($this->getLocations() as $location) {
198
-			if ($location->isUG())
199
-				return true;
200
+			if ($location->isUG()) {
201
+							return true;
202
+			}
200 203
 		}
201 204
 		return false;
202 205
 	}
203 206
 
204 207
 	public function hasShipShop() {
205 208
 		foreach ($this->getLocations() as $location) {
206
-			if ($location->isShipSold())
207
-				return true;
209
+			if ($location->isShipSold()) {
210
+							return true;
211
+			}
208 212
 		}
209 213
 		return false;
210 214
 	}
211 215
 
212 216
 	public function offersFederalProtection() {
213 217
 		foreach ($this->getLocations() as $location) {
214
-			if ($location->isFed())
215
-				return true;
218
+			if ($location->isFed()) {
219
+							return true;
220
+			}
216 221
 		}
217 222
 		return false;
218 223
 	}
@@ -220,32 +225,36 @@  discard block
 block discarded – undo
220 225
 	public function getFedRaceIDs() {
221 226
 		$raceIDs = array();
222 227
 		foreach ($this->getLocations() as $location) {
223
-			if ($location->isFed())
224
-				$raceIDs[$location->getRaceID()] = $location->getRaceID();
228
+			if ($location->isFed()) {
229
+							$raceIDs[$location->getRaceID()] = $location->getRaceID();
230
+			}
225 231
 		}
226 232
 		return $raceIDs;
227 233
 	}
228 234
 
229 235
 	public function hasBar() {
230 236
 		foreach ($this->getLocations() as $location) {
231
-			if ($location->isBar())
232
-				return true;
237
+			if ($location->isBar()) {
238
+							return true;
239
+			}
233 240
 		}
234 241
 		return false;
235 242
 	}
236 243
 
237 244
 	public function hasHardwareShop() {
238 245
 		foreach ($this->getLocations() as $location) {
239
-			if ($location->isHardwareSold())
240
-				return true;
246
+			if ($location->isHardwareSold()) {
247
+							return true;
248
+			}
241 249
 		}
242 250
 		return false;
243 251
 	}
244 252
 
245 253
 	public function hasBank() {
246 254
 		foreach ($this->getLocations() as $location) {
247
-			if ($location->isBank())
248
-				return true;
255
+			if ($location->isBank()) {
256
+							return true;
257
+			}
249 258
 		}
250 259
 		return false;
251 260
 	}
@@ -322,8 +331,9 @@  discard block
 block discarded – undo
322 331
 	}
323 332
 
324 333
 	public function setGalaxyID($galaxyID) {
325
-		if ($this->galaxyID == $galaxyID)
326
-			return;
334
+		if ($this->galaxyID == $galaxyID) {
335
+					return;
336
+		}
327 337
 		$this->galaxyID = $galaxyID;
328 338
 		$this->hasChanged = true;
329 339
 	}
@@ -334,18 +344,21 @@  discard block
 block discarded – undo
334 344
 
335 345
 	public function getNumberOfLinks() {
336 346
 		$num = 0;
337
-		if (!is_array($this->getLinks()))
338
-			return $num;
339
-		foreach ($this->getLinks() as $link)
340
-			if ($link !== 0)
347
+		if (!is_array($this->getLinks())) {
348
+					return $num;
349
+		}
350
+		foreach ($this->getLinks() as $link) {
351
+					if ($link !== 0)
341 352
 				$num++;
353
+		}
342 354
 		return $num;
343 355
 	}
344 356
 
345 357
 	public function getNumberOfConnections() {
346 358
 		$links = $this->getNumberOfLinks();
347
-		if ($this->hasWarp())
348
-			$links++;
359
+		if ($this->hasWarp()) {
360
+					$links++;
361
+		}
349 362
 		return $links;
350 363
 	}
351 364
 
@@ -354,30 +367,35 @@  discard block
 block discarded – undo
354 367
 	}
355 368
 
356 369
 	public function getNeighbourID($dir) {
357
-		if ($this->hasLink($dir))
358
-			return $this->getLink($dir);
370
+		if ($this->hasLink($dir)) {
371
+					return $this->getLink($dir);
372
+		}
359 373
 		$galaxy = $this->getGalaxy();
360 374
 		$neighbour = $this->getSectorID();
361 375
 		switch ($dir) {
362 376
 			case 'Up':
363 377
 				$neighbour -= $galaxy->getWidth();
364
-				if ($neighbour < $galaxy->getStartSector())
365
-					$neighbour += $galaxy->getSize();
378
+				if ($neighbour < $galaxy->getStartSector()) {
379
+									$neighbour += $galaxy->getSize();
380
+				}
366 381
 			break;
367 382
 			case 'Down':
368 383
 				$neighbour += $galaxy->getWidth();
369
-				if ($neighbour > $galaxy->getEndSector())
370
-					$neighbour -= $galaxy->getSize();
384
+				if ($neighbour > $galaxy->getEndSector()) {
385
+									$neighbour -= $galaxy->getSize();
386
+				}
371 387
 			break;
372 388
 			case 'Left':
373 389
 				$neighbour -= 1;
374
-				if ((1 + $neighbour - $galaxy->getStartSector()) % $galaxy->getWidth() == 0)
375
-					$neighbour += $galaxy->getWidth();
390
+				if ((1 + $neighbour - $galaxy->getStartSector()) % $galaxy->getWidth() == 0) {
391
+									$neighbour += $galaxy->getWidth();
392
+				}
376 393
 			break;
377 394
 			case 'Right':
378 395
 				$neighbour += 1;
379
-				if (($neighbour - $galaxy->getStartSector()) % $galaxy->getWidth() == 0)
380
-					$neighbour -= $galaxy->getWidth();
396
+				if (($neighbour - $galaxy->getStartSector()) % $galaxy->getWidth() == 0) {
397
+									$neighbour -= $galaxy->getWidth();
398
+				}
381 399
 			break;
382 400
 			default:
383 401
 				throw new Exception($dir . ': is not a valid direction');
@@ -386,13 +404,16 @@  discard block
 block discarded – undo
386 404
 	}
387 405
 
388 406
 	public function getSectorDirection($sectorID) {
389
-		if ($sectorID == $this->getSectorID())
390
-			return 'Current';
407
+		if ($sectorID == $this->getSectorID()) {
408
+					return 'Current';
409
+		}
391 410
 		$dir = array_search($sectorID, $this->getLinks());
392
-		if ($dir !== false)
393
-			return $dir;
394
-		if ($sectorID == $this->getWarp())
395
-			return 'Warp';
411
+		if ($dir !== false) {
412
+					return $dir;
413
+		}
414
+		if ($sectorID == $this->getWarp()) {
415
+					return 'Warp';
416
+		}
396 417
 		return 'None';
397 418
 	}
398 419
 
@@ -417,8 +438,9 @@  discard block
 block discarded – undo
417 438
 	}
418 439
 
419 440
 	public function &getLinkSector($name) {
420
-		if ($this->hasLink($name))
421
-			return SmrSector::getSector($this->getGameID(), $this->getLink($name));
441
+		if ($this->hasLink($name)) {
442
+					return SmrSector::getSector($this->getGameID(), $this->getLink($name));
443
+		}
422 444
 		return false;
423 445
 	}
424 446
 
@@ -426,12 +448,14 @@  discard block
 block discarded – undo
426 448
 	 * Cannot be used for Warps
427 449
 	 */
428 450
 	public function setLink($name, $linkID) {
429
-		if ($this->getLink($name) == $linkID)
430
-			return;
431
-		if ($linkID == 0)
432
-			unset($this->links[$name]);
433
-		else
434
-			$this->links[$name] = $linkID;
451
+		if ($this->getLink($name) == $linkID) {
452
+					return;
453
+		}
454
+		if ($linkID == 0) {
455
+					unset($this->links[$name]);
456
+		} else {
457
+					$this->links[$name] = $linkID;
458
+		}
435 459
 		$this->hasChanged = true;
436 460
 	}
437 461
 
@@ -439,8 +463,9 @@  discard block
 block discarded – undo
439 463
 	 * Cannot be used for Warps
440 464
 	 */
441 465
 	public function setLinkSector($dir, SmrSector $linkSector) {
442
-		if ($this->getLink($dir) == $linkSector->getSectorID() || $linkSector->equals($this))
443
-			return;
466
+		if ($this->getLink($dir) == $linkSector->getSectorID() || $linkSector->equals($this)) {
467
+					return;
468
+		}
444 469
 		$this->setLink($dir, $linkSector->getSectorID());
445 470
 		$linkSector->setLink(self::oppositeDir($dir), $this->getSectorID());
446 471
 		$this->hasChanged = true;
@@ -464,8 +489,7 @@  discard block
 block discarded – undo
464 489
 	public function toggleLink($dir) {
465 490
 		if ($this->hasLink($dir)) {
466 491
 			$this->disableLink($dir);
467
-		}
468
-		else {
492
+		} else {
469 493
 			$this->enableLink($dir);
470 494
 		}
471 495
 	}
@@ -629,21 +653,25 @@  discard block
 block discarded – undo
629 653
 		$locations = SmrLocation::getSectorLocations($this->getGameID(), $this->getSectorID());
630 654
 		$hasAction = false;
631 655
 		foreach ($locations as $location) {
632
-			if ($location->hasAction())
633
-				$hasAction = true;
656
+			if ($location->hasAction()) {
657
+							$hasAction = true;
658
+			}
634 659
 		}
635 660
 		return $hasAction;
636 661
 	}
637 662
 
638 663
 	public function hasLocation($locationTypeID = false) {
639 664
 		$locations = $this->getLocations();
640
-		if (count($locations) == 0)
641
-			return false;
642
-		if ($locationTypeID == false)
643
-			return true;
665
+		if (count($locations) == 0) {
666
+					return false;
667
+		}
668
+		if ($locationTypeID == false) {
669
+					return true;
670
+		}
644 671
 		foreach ($locations as $location) {
645
-			if ($location->getTypeID() == $locationTypeID)
646
-				return true;
672
+			if ($location->getTypeID() == $locationTypeID) {
673
+							return true;
674
+			}
647 675
 		}
648 676
 		return false;
649 677
 	}
@@ -703,11 +731,13 @@  discard block
 block discarded – undo
703 731
 	}
704 732
 
705 733
 	public function hasEnemyForces(AbstractSmrPlayer $player = null) {
706
-		if ($player == null || !$this->hasForces())
707
-			return false;
734
+		if ($player == null || !$this->hasForces()) {
735
+					return false;
736
+		}
708 737
 		foreach ($this->getForces() as $force) {
709
-			if (!$player->forceNAPAlliance($force->getOwner()))
710
-				return true;
738
+			if (!$player->forceNAPAlliance($force->getOwner())) {
739
+							return true;
740
+			}
711 741
 		}
712 742
 		return false;
713 743
 	}
@@ -715,8 +745,9 @@  discard block
 block discarded – undo
715 745
 	public function &getEnemyForces(AbstractSmrPlayer $player) {
716 746
 		$enemyForces = array();
717 747
 		foreach ($this->getForces() as $force) {
718
-			if (!$player->forceNAPAlliance($force->getOwner()))
719
-				$enemyForces[] = $force;
748
+			if (!$player->forceNAPAlliance($force->getOwner())) {
749
+							$enemyForces[] = $force;
750
+			}
720 751
 		}
721 752
 		return $enemyForces;
722 753
 	}
@@ -734,11 +765,13 @@  discard block
 block discarded – undo
734 765
 	}
735 766
 
736 767
 	public function hasFriendlyForces(AbstractSmrPlayer $player = null) {
737
-		if ($player == null || !$this->hasForces())
738
-			return false;
768
+		if ($player == null || !$this->hasForces()) {
769
+					return false;
770
+		}
739 771
 		foreach ($this->getForces() as $force) {
740
-			if ($player->forceNAPAlliance($force->getOwner()))
741
-				return true;
772
+			if ($player->forceNAPAlliance($force->getOwner())) {
773
+							return true;
774
+			}
742 775
 		}
743 776
 		return false;
744 777
 	}
@@ -746,8 +779,9 @@  discard block
 block discarded – undo
746 779
 	public function &getFriendlyForces(AbstractSmrPlayer $player) {
747 780
 		$friendlyForces = array();
748 781
 		foreach ($this->getForces() as $force) {
749
-			if ($player->forceNAPAlliance($force->getOwner()))
750
-				$friendlyForces[] = $force;
782
+			if ($player->forceNAPAlliance($force->getOwner())) {
783
+							$friendlyForces[] = $force;
784
+			}
751 785
 		}
752 786
 		return $friendlyForces;
753 787
 	}
@@ -775,8 +809,9 @@  discard block
 block discarded – undo
775 809
 	}
776 810
 
777 811
 	public function hasEnemyTraders(AbstractSmrPlayer $player = null) {
778
-		if ($player == null || !$this->hasOtherTraders($player))
779
-			return false;
812
+		if ($player == null || !$this->hasOtherTraders($player)) {
813
+					return false;
814
+		}
780 815
 		$otherPlayers = $this->getOtherTraders($player);
781 816
 		foreach ($otherPlayers as $otherPlayer) {
782 817
 			if (!$player->traderNAPAlliance($otherPlayer) 
@@ -789,12 +824,14 @@  discard block
 block discarded – undo
789 824
 	}
790 825
 
791 826
 	public function hasFriendlyTraders(AbstractSmrPlayer $player = null) {
792
-		if ($player == null || !$this->hasOtherTraders($player))
793
-			return false;
827
+		if ($player == null || !$this->hasOtherTraders($player)) {
828
+					return false;
829
+		}
794 830
 		$otherPlayers = $this->getOtherTraders($player);
795 831
 		foreach ($otherPlayers as $otherPlayer) {
796
-			if ($player->traderNAPAlliance($otherPlayer))
797
-				return true;
832
+			if ($player->traderNAPAlliance($otherPlayer)) {
833
+							return true;
834
+			}
798 835
 		}
799 836
 		return false;
800 837
 	}
@@ -816,8 +853,9 @@  discard block
 block discarded – undo
816 853
 	}
817 854
 
818 855
 	public function hasProtectedTraders(AbstractSmrPlayer $player = null) {
819
-		if ($player == null || !$this->hasOtherTraders($player))
820
-			return false;
856
+		if ($player == null || !$this->hasOtherTraders($player)) {
857
+					return false;
858
+		}
821 859
 		$otherPlayers = $this->getOtherTraders($player);
822 860
 		foreach ($otherPlayers as $otherPlayer) {
823 861
 			if (!$player->traderNAPAlliance($otherPlayer) 
@@ -853,8 +891,9 @@  discard block
 block discarded – undo
853 891
 			$planetOwner = $defendingPlanet->getOwner();
854 892
 			foreach ($alliancePlayers as $accountID => $player) {
855 893
 				if ($player->canFight()) {
856
-					if ($attackingPlayer->traderAttackPlanetAlliance($player) && !$planetOwner->planetNAPAlliance($player))
857
-						$fightingPlayers[$accountID] = $alliancePlayers[$accountID];
894
+					if ($attackingPlayer->traderAttackPlanetAlliance($player) && !$planetOwner->planetNAPAlliance($player)) {
895
+											$fightingPlayers[$accountID] = $alliancePlayers[$accountID];
896
+					}
858 897
 				}
859 898
 			}
860 899
 		}
@@ -862,8 +901,9 @@  discard block
 block discarded – undo
862 901
 	}
863 902
 
864 903
 	public function &getFightingTraders(AbstractSmrPlayer $attackingPlayer, AbstractSmrPlayer $defendingPlayer, $checkForCloak = false) {
865
-		if ($attackingPlayer->traderNAPAlliance($defendingPlayer))
866
-			throw new Exception('These traders are NAPed.');
904
+		if ($attackingPlayer->traderNAPAlliance($defendingPlayer)) {
905
+					throw new Exception('These traders are NAPed.');
906
+		}
867 907
 		$fightingPlayers = array('Attackers' => array(), 'Defenders' => array());
868 908
 		$alliancePlayers = SmrPlayer::getSectorPlayersByAlliances($this->getGameID(), $this->getSectorID(), array($attackingPlayer->getAllianceID(), $defendingPlayer->getAllianceID()));
869 909
 		$attackers = array();
@@ -923,8 +963,9 @@  discard block
 block discarded – undo
923 963
 	}
924 964
 
925 965
 	public function setBattles($amount) {
926
-		if ($this->battles == $amount)
927
-			return;
966
+		if ($this->battles == $amount) {
967
+					return;
968
+		}
928 969
 		$this->battles = $amount;
929 970
 		$this->hasChanged = true;
930 971
 	}
@@ -946,8 +987,9 @@  discard block
 block discarded – undo
946 987
 	}
947 988
 
948 989
 	public function isVisited(AbstractSmrPlayer $player = null) {
949
-		if ($player === null)
950
-			return true;
990
+		if ($player === null) {
991
+					return true;
992
+		}
951 993
 		if (!isset($this->visited[$player->getAccountID()])) {
952 994
 			$this->db->query('SELECT sector_id FROM player_visited_sector WHERE ' . $this->SQL . ' AND account_id=' . $this->db->escapeNumber($player->getAccountID()) . ' LIMIT 1');
953 995
 			$this->visited[$player->getAccountID()] = !$this->db->nextRecord();
@@ -988,10 +1030,12 @@  discard block
 block discarded – undo
988 1030
 			return $x->contains($this);
989 1031
 		}
990 1032
 
991
-		if (is_array($x) && $x['Type'] == 'Good') //Check if it's possible for port to have X, hacky but nice performance gains
1033
+		if (is_array($x) && $x['Type'] == 'Good') {
1034
+			//Check if it's possible for port to have X, hacky but nice performance gains
992 1035
 			if ($this->hasPort())
993 1036
 				if ($this->getPort()->hasX($x))
994 1037
 					return true;
1038
+		}
995 1039
 
996 1040
 		//Check if it's possible for location to have X, hacky but nice performance gains
997 1041
 		if ($x instanceof SmrWeapon || (is_array($x) && ($x['Type'] == 'Ship' || $x['Type'] == 'Hardware')) || (is_string($x) && ($x == 'Bank' || $x == 'Bar' || $x == 'Fed' || $x == 'SafeFed' || $x == 'HQ' || $x == 'UG' || $x == 'Hardware' || $x == 'Ship' || $x == 'Weapon'))) {
Please login to merge, or discard this patch.
lib/Default/SmrForce.class.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -446,20 +446,20 @@
 block discarded – undo
446 446
 
447 447
 		if ($this->hasMines()) {
448 448
 			$thisMines = new SmrMines($this->getGameID(), $this->getMines());
449
-			$results['Results']['Mines'] =& $thisMines->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)], $minesAreAttacker);
449
+			$results['Results']['Mines'] = & $thisMines->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)], $minesAreAttacker);
450 450
 			$results['TotalDamage'] += $results['Results']['Mines']['ActualDamage']['TotalDamage'];
451 451
 		}
452 452
 
453 453
 		if ($this->hasCDs()) {
454 454
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
455
-			$results['Results']['Drones'] =& $thisCDs->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)]);
455
+			$results['Results']['Drones'] = & $thisCDs->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)]);
456 456
 			$results['TotalDamage'] += $results['Results']['Drones']['ActualDamage']['TotalDamage'];
457 457
 		}
458 458
 
459 459
 		if (!$minesAreAttacker) {
460 460
 			if ($this->hasSDs()) {
461 461
 				$thisSDs = new SmrScoutDrones($this->getGameID(), $this->getSDs());
462
-				$results['Results']['Scouts'] =& $thisSDs->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)]);
462
+				$results['Results']['Scouts'] = & $thisSDs->shootPlayerAsForce($this, $targetPlayers[array_rand($targetPlayers)]);
463 463
 				$results['TotalDamage'] += $results['Results']['Scouts']['ActualDamage']['TotalDamage'];
464 464
 			}
465 465
 		}
Please login to merge, or discard this patch.
Braces   +8 added lines, -12 removed lines patch added patch discarded remove patch
@@ -252,16 +252,16 @@  discard block
 block discarded – undo
252 252
 		}
253 253
 		$this->hasChanged = true;
254 254
 		$this->expire = $time;
255
-		if (!$this->isNew)
256
-			$this->update();
255
+		if (!$this->isNew) {
256
+					$this->update();
257
+		}
257 258
 	}
258 259
 
259 260
 	public function updateExpire() {
260 261
 		// Changed (26/10/05) - scout drones count * 2
261 262
 		if ($this->getCDs() == 0 && $this->getMines() == 0 && $this->getSDs() > 0) {
262 263
 			$time = self::TIME_PER_SCOUT_ONLY * $this->getSDs();
263
-		}
264
-		else {
264
+		} else {
265 265
 			$time = ($this->getCDs() * self::TIME_PERCENT_PER_COMBAT + $this->getSDs() * self::TIME_PERCENT_PER_SCOUT + $this->getMines() * self::TIME_PERCENT_PER_MINE) * $this->getMaxGalaxyExpireTime();
266 266
 		}
267 267
 		$this->setExpire(TIME + $time);
@@ -288,11 +288,9 @@  discard block
 block discarded – undo
288 288
 		}
289 289
 		if ($mines < 10) {
290 290
 			$turns = 1;
291
-		}
292
-		else if ($mines < 25) {
291
+		} else if ($mines < 25) {
293 292
 			$turns = 2;
294
-		}
295
-		else {
293
+		} else {
296 294
 			$turns = 3;
297 295
 		}
298 296
 		if ($ship->isFederal() || $ship->hasDCS()) {
@@ -347,12 +345,10 @@  discard block
 block discarded – undo
347 345
 			if (!$this->exists()) {
348 346
 				$this->db->query('DELETE FROM sector_has_forces WHERE ' . $this->SQL);
349 347
 				$this->isNew = true;
350
-			}
351
-			else if ($this->hasChanged) {
348
+			} else if ($this->hasChanged) {
352 349
 				$this->db->query('UPDATE sector_has_forces SET combat_drones = ' . $this->db->escapeNumber($this->combatDrones) . ', scout_drones = ' . $this->db->escapeNumber($this->scoutDrones) . ', mines = ' . $this->db->escapeNumber($this->mines) . ', expire_time = ' . $this->db->escapeNumber($this->expire) . ' WHERE ' . $this->SQL);
353 350
 			}
354
-		}
355
-		else if ($this->exists()) {
351
+		} else if ($this->exists()) {
356 352
 			$this->db->query('INSERT INTO sector_has_forces (game_id, sector_id, owner_id, combat_drones, scout_drones, mines, expire_time)
357 353
 								VALUES('.$this->db->escapeNumber($this->gameID) . ', ' . $this->db->escapeNumber($this->sectorID) . ', ' . $this->db->escapeNumber($this->ownerID) . ', ' . $this->db->escapeNumber($this->combatDrones) . ', ' . $this->db->escapeNumber($this->scoutDrones) . ', ' . $this->db->escapeNumber($this->mines) . ', ' . $this->db->escapeNumber($this->expire) . ')');
358 354
 			$this->isNew = false;
Please login to merge, or discard this patch.
lib/Default/AbstractSmrCombatWeapon.class.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	protected $maxDamage;
13 13
 	protected $shieldDamage;
14 14
 	protected $armourDamage;
15
-	protected $empDamage=0;
15
+	protected $empDamage = 0;
16 16
 	protected $accuracy;
17 17
 	protected $damageRollover;
18 18
 	protected $raidWeapon;
@@ -85,62 +85,62 @@  discard block
 block discarded – undo
85 85
 	abstract public function &getModifiedForceDamageAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer);
86 86
 	
87 87
 	protected function &doPlayerDamageToForce(array &$return, AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
88
-		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstForces($weaponPlayer,$forces);
89
-		$return['ActualDamage'] =& $forces->doWeaponDamage($return['WeaponDamage']);
90
-		if($return['ActualDamage']['KillingShot'])
91
-			$return['KillResults'] =& $forces->killForcesByPlayer($weaponPlayer);
88
+		$return['WeaponDamage'] = & $this->getModifiedDamageAgainstForces($weaponPlayer, $forces);
89
+		$return['ActualDamage'] = & $forces->doWeaponDamage($return['WeaponDamage']);
90
+		if ($return['ActualDamage']['KillingShot'])
91
+			$return['KillResults'] = & $forces->killForcesByPlayer($weaponPlayer);
92 92
 		return $return;
93 93
 	}
94 94
 	
95 95
 	protected function &doPlayerDamageToPlayer(array &$return, AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) {
96
-		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPlayer($weaponPlayer,$targetPlayer);
97
-		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
96
+		$return['WeaponDamage'] = & $this->getModifiedDamageAgainstPlayer($weaponPlayer, $targetPlayer);
97
+		$return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
98 98
 
99
-		if($return['ActualDamage']['KillingShot'])
100
-			$return['KillResults'] =& $targetPlayer->killPlayerByPlayer($weaponPlayer);
99
+		if ($return['ActualDamage']['KillingShot'])
100
+			$return['KillResults'] = & $targetPlayer->killPlayerByPlayer($weaponPlayer);
101 101
 		return $return;
102 102
 	}
103 103
 	
104 104
 	protected function &doPlayerDamageToPort(array &$return, AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
105
-		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPort($weaponPlayer,$port);
106
-		$return['ActualDamage'] =& $port->doWeaponDamage($return['WeaponDamage']);
107
-		if($return['ActualDamage']['KillingShot'])
108
-			$return['KillResults'] =& $port->killPortByPlayer($weaponPlayer);
105
+		$return['WeaponDamage'] = & $this->getModifiedDamageAgainstPort($weaponPlayer, $port);
106
+		$return['ActualDamage'] = & $port->doWeaponDamage($return['WeaponDamage']);
107
+		if ($return['ActualDamage']['KillingShot'])
108
+			$return['KillResults'] = & $port->killPortByPlayer($weaponPlayer);
109 109
 		return $return;
110 110
 	}
111 111
 	
112 112
 	protected function &doPlayerDamageToPlanet(array &$return, AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet, $delayed) {
113
-		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPlanet($weaponPlayer,$planet);
114
-		$return['ActualDamage'] =& $planet->doWeaponDamage($return['WeaponDamage'],$delayed);
115
-		if($return['ActualDamage']['KillingShot'])
116
-			$return['KillResults'] =& $planet->killPlanetByPlayer($weaponPlayer);
113
+		$return['WeaponDamage'] = & $this->getModifiedDamageAgainstPlanet($weaponPlayer, $planet);
114
+		$return['ActualDamage'] = & $planet->doWeaponDamage($return['WeaponDamage'], $delayed);
115
+		if ($return['ActualDamage']['KillingShot'])
116
+			$return['KillResults'] = & $planet->killPlanetByPlayer($weaponPlayer);
117 117
 		return $return;
118 118
 	}
119 119
 	
120 120
 	protected function &doPortDamageToPlayer(array &$return, SmrPort $port, AbstractSmrPlayer $targetPlayer) {
121
-		$return['WeaponDamage'] =& $this->getModifiedPortDamageAgainstPlayer($port,$targetPlayer);
122
-		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
121
+		$return['WeaponDamage'] = & $this->getModifiedPortDamageAgainstPlayer($port, $targetPlayer);
122
+		$return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
123 123
 
124
-		if($return['ActualDamage']['KillingShot'])
125
-			$return['KillResults'] =& $targetPlayer->killPlayerByPort($port);
124
+		if ($return['ActualDamage']['KillingShot'])
125
+			$return['KillResults'] = & $targetPlayer->killPlayerByPort($port);
126 126
 		return $return;
127 127
 	}
128 128
 	
129 129
 	protected function &doPlanetDamageToPlayer(array &$return, SmrPlanet $planet, AbstractSmrPlayer $targetPlayer) {
130
-		$return['WeaponDamage'] =& $this->getModifiedPlanetDamageAgainstPlayer($planet,$targetPlayer);
131
-		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
130
+		$return['WeaponDamage'] = & $this->getModifiedPlanetDamageAgainstPlayer($planet, $targetPlayer);
131
+		$return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
132 132
 
133
-		if($return['ActualDamage']['KillingShot'])
134
-			$return['KillResults'] =& $targetPlayer->killPlayerByPlanet($planet);
133
+		if ($return['ActualDamage']['KillingShot'])
134
+			$return['KillResults'] = & $targetPlayer->killPlayerByPlanet($planet);
135 135
 		return $return;
136 136
 	}
137 137
 	
138 138
 	protected function &doForceDamageToPlayer(array &$return, SmrForce $forces, AbstractSmrPlayer $targetPlayer) {
139
-		$return['WeaponDamage'] =& $this->getModifiedForceDamageAgainstPlayer($forces,$targetPlayer);
140
-		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
139
+		$return['WeaponDamage'] = & $this->getModifiedForceDamageAgainstPlayer($forces, $targetPlayer);
140
+		$return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
141 141
 
142
-		if($return['ActualDamage']['KillingShot'])
143
-			$return['KillResults'] =& $targetPlayer->killPlayerByForces($forces);
142
+		if ($return['ActualDamage']['KillingShot'])
143
+			$return['KillResults'] = & $targetPlayer->killPlayerByForces($forces);
144 144
 		return $return;
145 145
 	}
146 146
 	
Please login to merge, or discard this patch.
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -87,8 +87,9 @@  discard block
 block discarded – undo
87 87
 	protected function &doPlayerDamageToForce(array &$return, AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
88 88
 		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstForces($weaponPlayer,$forces);
89 89
 		$return['ActualDamage'] =& $forces->doWeaponDamage($return['WeaponDamage']);
90
-		if($return['ActualDamage']['KillingShot'])
91
-			$return['KillResults'] =& $forces->killForcesByPlayer($weaponPlayer);
90
+		if($return['ActualDamage']['KillingShot']) {
91
+					$return['KillResults'] =& $forces->killForcesByPlayer($weaponPlayer);
92
+		}
92 93
 		return $return;
93 94
 	}
94 95
 	
@@ -96,24 +97,27 @@  discard block
 block discarded – undo
96 97
 		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPlayer($weaponPlayer,$targetPlayer);
97 98
 		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
98 99
 
99
-		if($return['ActualDamage']['KillingShot'])
100
-			$return['KillResults'] =& $targetPlayer->killPlayerByPlayer($weaponPlayer);
100
+		if($return['ActualDamage']['KillingShot']) {
101
+					$return['KillResults'] =& $targetPlayer->killPlayerByPlayer($weaponPlayer);
102
+		}
101 103
 		return $return;
102 104
 	}
103 105
 	
104 106
 	protected function &doPlayerDamageToPort(array &$return, AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
105 107
 		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPort($weaponPlayer,$port);
106 108
 		$return['ActualDamage'] =& $port->doWeaponDamage($return['WeaponDamage']);
107
-		if($return['ActualDamage']['KillingShot'])
108
-			$return['KillResults'] =& $port->killPortByPlayer($weaponPlayer);
109
+		if($return['ActualDamage']['KillingShot']) {
110
+					$return['KillResults'] =& $port->killPortByPlayer($weaponPlayer);
111
+		}
109 112
 		return $return;
110 113
 	}
111 114
 	
112 115
 	protected function &doPlayerDamageToPlanet(array &$return, AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet, $delayed) {
113 116
 		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPlanet($weaponPlayer,$planet);
114 117
 		$return['ActualDamage'] =& $planet->doWeaponDamage($return['WeaponDamage'],$delayed);
115
-		if($return['ActualDamage']['KillingShot'])
116
-			$return['KillResults'] =& $planet->killPlanetByPlayer($weaponPlayer);
118
+		if($return['ActualDamage']['KillingShot']) {
119
+					$return['KillResults'] =& $planet->killPlanetByPlayer($weaponPlayer);
120
+		}
117 121
 		return $return;
118 122
 	}
119 123
 	
@@ -121,8 +125,9 @@  discard block
 block discarded – undo
121 125
 		$return['WeaponDamage'] =& $this->getModifiedPortDamageAgainstPlayer($port,$targetPlayer);
122 126
 		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
123 127
 
124
-		if($return['ActualDamage']['KillingShot'])
125
-			$return['KillResults'] =& $targetPlayer->killPlayerByPort($port);
128
+		if($return['ActualDamage']['KillingShot']) {
129
+					$return['KillResults'] =& $targetPlayer->killPlayerByPort($port);
130
+		}
126 131
 		return $return;
127 132
 	}
128 133
 	
@@ -130,8 +135,9 @@  discard block
 block discarded – undo
130 135
 		$return['WeaponDamage'] =& $this->getModifiedPlanetDamageAgainstPlayer($planet,$targetPlayer);
131 136
 		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
132 137
 
133
-		if($return['ActualDamage']['KillingShot'])
134
-			$return['KillResults'] =& $targetPlayer->killPlayerByPlanet($planet);
138
+		if($return['ActualDamage']['KillingShot']) {
139
+					$return['KillResults'] =& $targetPlayer->killPlayerByPlanet($planet);
140
+		}
135 141
 		return $return;
136 142
 	}
137 143
 	
@@ -139,8 +145,9 @@  discard block
 block discarded – undo
139 145
 		$return['WeaponDamage'] =& $this->getModifiedForceDamageAgainstPlayer($forces,$targetPlayer);
140 146
 		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
141 147
 
142
-		if($return['ActualDamage']['KillingShot'])
143
-			$return['KillResults'] =& $targetPlayer->killPlayerByForces($forces);
148
+		if($return['ActualDamage']['KillingShot']) {
149
+					$return['KillResults'] =& $targetPlayer->killPlayerByForces($forces);
150
+		}
144 151
 		return $return;
145 152
 	}
146 153
 	
Please login to merge, or discard this patch.
lib/Default/AbstractSmrLocation.class.php 1 patch
Braces   +55 added lines, -46 removed lines patch added patch discarded remove patch
@@ -74,8 +74,7 @@  discard block
 block discarded – undo
74 74
 			$this->name = $db->getField('location_name');
75 75
 			$this->processor = $db->getField('location_processor');
76 76
 			$this->image = $db->getField('location_image');
77
-		}
78
-		else {
77
+		} else {
79 78
 			throw new Exception('Cannot find location: ' . $locationTypeID);
80 79
 		}
81 80
 	}
@@ -134,8 +133,7 @@  discard block
 block discarded – undo
134 133
 		if ($bool === true) {
135 134
 			$this->db->query('INSERT IGNORE INTO location_is_fed (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
136 135
 			$this->fed = true;
137
-		}
138
-		else if ($bool === false) {
136
+		} else if ($bool === false) {
139 137
 			$this->db->query('DELETE FROM location_is_fed WHERE ' . $this->SQL . ' LIMIT 1');
140 138
 			$this->fed = false;
141 139
 		}
@@ -150,13 +148,13 @@  discard block
 block discarded – undo
150 148
 	}
151 149
 	
152 150
 	public function setBank($bool) {
153
-		if ($this->bank === $bool)
154
-			return;
151
+		if ($this->bank === $bool) {
152
+					return;
153
+		}
155 154
 		if ($bool === true) {
156 155
 			$this->db->query('INSERT INTO location_is_bank (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
157 156
 			$this->bank = true;
158
-		}
159
-		else if ($bool === false) {
157
+		} else if ($bool === false) {
160 158
 			$this->db->query('DELETE FROM location_is_bank WHERE ' . $this->SQL . ' LIMIT 1');
161 159
 			$this->bank = false;
162 160
 		}
@@ -171,13 +169,13 @@  discard block
 block discarded – undo
171 169
 	}
172 170
 	
173 171
 	public function setBar($bool) {
174
-		if ($this->bar === $bool)
175
-			return;
172
+		if ($this->bar === $bool) {
173
+					return;
174
+		}
176 175
 		if ($bool === true) {
177 176
 			$this->db->query('INSERT IGNORE INTO location_is_bar (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
178 177
 			$this->bar = true;
179
-		}
180
-		else if ($bool === false) {
178
+		} else if ($bool === false) {
181 179
 			$this->db->query('DELETE FROM location_is_bar WHERE ' . $this->SQL . ' LIMIT 1');
182 180
 			$this->bar = false;
183 181
 		}
@@ -192,13 +190,13 @@  discard block
 block discarded – undo
192 190
 	}
193 191
 	
194 192
 	public function setHQ($bool) {
195
-		if ($this->HQ === $bool)
196
-			return;
193
+		if ($this->HQ === $bool) {
194
+					return;
195
+		}
197 196
 		if ($bool === true) {
198 197
 			$this->db->query('INSERT IGNORE INTO location_is_hq (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
199 198
 			$this->HQ = true;
200
-		}
201
-		else if ($bool === false) {
199
+		} else if ($bool === false) {
202 200
 			$this->db->query('DELETE FROM location_is_hq WHERE ' . $this->SQL . ' LIMIT 1');
203 201
 			$this->HQ = false;
204 202
 		}
@@ -213,13 +211,13 @@  discard block
 block discarded – undo
213 211
 	}
214 212
 	
215 213
 	public function setUG($bool) {
216
-		if ($this->UG === $bool)
217
-			return;
214
+		if ($this->UG === $bool) {
215
+					return;
216
+		}
218 217
 		if ($bool === true) {
219 218
 			$this->db->query('INSERT INTO location_is_ug (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
220 219
 			$this->UG = true;
221
-		}
222
-		else if ($bool === false) {
220
+		} else if ($bool === false) {
223 221
 			$this->db->query('DELETE FROM location_is_ug WHERE ' . $this->SQL . ' LIMIT 1');
224 222
 			$this->UG = false;
225 223
 		}
@@ -245,18 +243,21 @@  discard block
 block discarded – undo
245 243
 	}
246 244
 	
247 245
 	public function addHardwareSold($hardwareTypeID) {
248
-		if ($this->isHardwareSold($hardwareTypeID))
249
-			return;
246
+		if ($this->isHardwareSold($hardwareTypeID)) {
247
+					return;
248
+		}
250 249
 		$this->db->query('SELECT * FROM hardware_type WHERE hardware_type_id = ' . $this->db->escapeNumber($hardwareTypeID) . ' LIMIT 1');
251
-		if (!$this->db->nextRecord())
252
-			throw new Exception('Invalid hardware type id given');
250
+		if (!$this->db->nextRecord()) {
251
+					throw new Exception('Invalid hardware type id given');
252
+		}
253 253
 		$this->db->query('INSERT INTO location_sells_hardware (location_type_id,hardware_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($hardwareTypeID) . ')');
254 254
 		$this->hardwareSold[$hardwareTypeID] = $this->db->getField('hardware_name');
255 255
 	}
256 256
 	
257 257
 	public function removeHardwareSold($hardwareTypeID) {
258
-		if (!$this->isHardwareSold($hardwareTypeID))
259
-			return;
258
+		if (!$this->isHardwareSold($hardwareTypeID)) {
259
+					return;
260
+		}
260 261
 		$this->db->query('DELETE FROM location_sells_hardware WHERE ' . $this->SQL . ' AND hardware_type_id = ' . $this->db->escapeNumber($hardwareTypeID) . ' LIMIT 1');
261 262
 		unset($this->hardwareSold[$hardwareTypeID]);
262 263
 	}
@@ -274,24 +275,28 @@  discard block
 block discarded – undo
274 275
 	
275 276
 	public function isShipSold($shipTypeID = false) {
276 277
 		$ships = $this->getShipsSold();
277
-		if ($shipTypeID === false)
278
-			return count($ships) != 0;
278
+		if ($shipTypeID === false) {
279
+					return count($ships) != 0;
280
+		}
279 281
 		return isset($ships[$shipTypeID]);
280 282
 	}
281 283
 	
282 284
 	public function addShipSold($shipTypeID) {
283
-		if ($this->isShipSold($shipTypeID))
284
-			return;
285
+		if ($this->isShipSold($shipTypeID)) {
286
+					return;
287
+		}
285 288
 		$ship = AbstractSmrShip::getBaseShip(Globals::getGameType(SmrSession::getGameID()), $shipTypeID);
286
-		if ($ship === false)
287
-			throw new Exception('Invalid ship type id given');
289
+		if ($ship === false) {
290
+					throw new Exception('Invalid ship type id given');
291
+		}
288 292
 		$this->db->query('INSERT INTO location_sells_ships (location_type_id,ship_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($shipTypeID) . ')');
289 293
 		$this->shipsSold[$shipTypeID] = $ship;
290 294
 	}
291 295
 	
292 296
 	public function removeShipSold($shipTypeID) {
293
-		if (!$this->isShipSold($shipTypeID))
294
-			return;
297
+		if (!$this->isShipSold($shipTypeID)) {
298
+					return;
299
+		}
295 300
 		$this->db->query('DELETE FROM location_sells_ships WHERE ' . $this->SQL . ' AND ship_type_id = ' . $this->db->escapeNumber($shipTypeID) . ' LIMIT 1');
296 301
 		unset($this->shipsSold[$shipTypeID]);
297 302
 	}
@@ -300,32 +305,37 @@  discard block
 block discarded – undo
300 305
 		if (!isset($this->weaponsSold)) {
301 306
 			$this->weaponsSold = array();
302 307
 			$this->db->query('SELECT * FROM location_sells_weapons JOIN weapon_type USING (weapon_type_id) WHERE ' . $this->SQL);
303
-			while ($this->db->nextRecord())
304
-				$this->weaponsSold[$this->db->getInt('weapon_type_id')] = SmrWeapon::getWeapon($this->db->getInt('weapon_type_id'), false, $this->db);
308
+			while ($this->db->nextRecord()) {
309
+							$this->weaponsSold[$this->db->getInt('weapon_type_id')] = SmrWeapon::getWeapon($this->db->getInt('weapon_type_id'), false, $this->db);
310
+			}
305 311
 		}
306 312
 		return $this->weaponsSold;
307 313
 	}
308 314
 	
309 315
 	public function isWeaponSold($weaponTypeID = false) {
310 316
 		$weapons = $this->getWeaponsSold();
311
-		if ($weaponTypeID === false)
312
-			return count($weapons) != 0;
317
+		if ($weaponTypeID === false) {
318
+					return count($weapons) != 0;
319
+		}
313 320
 		return isset($weapons[$weaponTypeID]);
314 321
 	}
315 322
 	
316 323
 	public function addWeaponSold($weaponTypeID) {
317
-		if ($this->isWeaponSold($weaponTypeID))
318
-			return;
324
+		if ($this->isWeaponSold($weaponTypeID)) {
325
+					return;
326
+		}
319 327
 		$weapon = SmrWeapon::getWeapon($weaponTypeID);
320
-		if ($weapon === false)
321
-			throw new Exception('Invalid weapon type id given');
328
+		if ($weapon === false) {
329
+					throw new Exception('Invalid weapon type id given');
330
+		}
322 331
 		$this->db->query('INSERT INTO location_sells_weapons (location_type_id,weapon_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($weaponTypeID) . ')');
323 332
 		$this->weaponsSold[$weaponTypeID] = $weapon;
324 333
 	}
325 334
 	
326 335
 	public function removeWeaponSold($weaponTypeID) {
327
-		if (!$this->isWeaponSold($weaponTypeID))
328
-			return;
336
+		if (!$this->isWeaponSold($weaponTypeID)) {
337
+					return;
338
+		}
329 339
 		$this->db->query('DELETE FROM location_sells_weapons WHERE ' . $this->SQL . ' AND weapon_type_id = ' . $this->db->escapeNumber($weaponTypeID) . ' LIMIT 1');
330 340
 		unset($this->weaponsSold[$weaponTypeID]);
331 341
 	}
@@ -336,8 +346,7 @@  discard block
 block discarded – undo
336 346
 			if ($this->getTypeID() == LOCATION_TYPE_FEDERAL_HQ) {
337 347
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_BEACON);
338 348
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_MINT);
339
-			}
340
-			else {
349
+			} else {
341 350
 				$raceID = $this->getRaceID();
342 351
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_BEACONS + $raceID);
343 352
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_SHIPS + $raceID);
Please login to merge, or discard this patch.