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
Push — master ( 1f1eac...f120a4 )
by Dan
04:33
created
lib/Default/SmrSector.class.php 1 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/SmrPlayer.class.php 1 patch
Braces   +182 added lines, -138 removed lines patch added patch discarded remove patch
@@ -58,8 +58,9 @@  discard block
 block discarded – undo
58 58
 	public static function getSectorPlayersByAlliances($gameID, $sectorID, array $allianceIDs, $forceUpdate = false) {
59 59
 		$players = self::getSectorPlayers($gameID, $sectorID, $forceUpdate); // Don't use & as we do an unset
60 60
 		foreach ($players as $accountID => $player) {
61
-			if (!in_array($player->getAllianceID(), $allianceIDs))
62
-				unset($players[$accountID]);
61
+			if (!in_array($player->getAllianceID(), $allianceIDs)) {
62
+							unset($players[$accountID]);
63
+			}
63 64
 		}
64 65
 		return $players;
65 66
 	}
@@ -198,8 +199,7 @@  discard block
 block discarded – undo
198 199
 			$this->newbieWarning = $db->getBoolean('newbie_warning');
199 200
 			$this->nameChanged = $db->getBoolean('name_changed');
200 201
 			$this->combatDronesKamikazeOnMines = $db->getBoolean('combat_drones_kamikaze_on_mines');
201
-		}
202
-		else {
202
+		} else {
203 203
 			throw new PlayerNotFoundException('Invalid accountID: ' . $accountID . ' OR gameID:' . $gameID);
204 204
 		}
205 205
 	}
@@ -285,22 +285,25 @@  discard block
 block discarded – undo
285 285
 	protected function setZoom($zoom) {
286 286
 		// Set the zoom level between [1, 9]
287 287
 		$zoom = max(1, min(9, $zoom));
288
-		if ($this->zoom == $zoom)
289
-			return;
288
+		if ($this->zoom == $zoom) {
289
+					return;
290
+		}
290 291
 		$this->zoom = $zoom;
291 292
 		$this->hasChanged = true;
292 293
 //		$this->db->query('UPDATE player SET zoom = ' . $zoom . ' WHERE ' . $this->SQL . ' LIMIT 1');
293 294
 	}
294 295
 
295 296
 	public function increaseZoom($zoom) {
296
-		if ($zoom < 0)
297
-			throw new Exception('Trying to increase negative zoom.');
297
+		if ($zoom < 0) {
298
+					throw new Exception('Trying to increase negative zoom.');
299
+		}
298 300
 		$this->setZoom($this->getZoom() + $zoom);
299 301
 	}
300 302
 
301 303
 	public function decreaseZoom($zoom) {
302
-		if ($zoom < 0)
303
-			throw new Exception('Trying to decrease negative zoom.');
304
+		if ($zoom < 0) {
305
+					throw new Exception('Trying to decrease negative zoom.');
306
+		}
304 307
 		$this->setZoom($this->getZoom() - $zoom);
305 308
 	}
306 309
 
@@ -315,8 +318,9 @@  discard block
 block discarded – undo
315 318
 	}
316 319
 
317 320
 	public function setLastSectorID($lastSectorID) {
318
-		if ($this->lastSectorID == $lastSectorID)
319
-			return;
321
+		if ($this->lastSectorID == $lastSectorID) {
322
+					return;
323
+		}
320 324
 		$this->lastSectorID = $lastSectorID;
321 325
 		$this->hasChanged = true;
322 326
 //		$this->db->query('UPDATE player SET last_sector_id = '.$this->lastSectorID.' WHERE '.$this->SQL.' LIMIT 1');
@@ -329,11 +333,9 @@  discard block
 block discarded – undo
329 333
 			$kickedBy->sendMessage($this->getAccountID(), MSG_PLAYER, 'You were kicked out of the alliance!', false);
330 334
 			$this->actionTaken('PlayerKicked', array('Alliance' => $alliance, 'Player' => $kickedBy));
331 335
 			$kickedBy->actionTaken('KickPlayer', array('Alliance' => $alliance, 'Player' => $this));
332
-		}
333
-		else if ($this->isAllianceLeader()) {
336
+		} else if ($this->isAllianceLeader()) {
334 337
 			$this->actionTaken('DisbandAlliance', array('Alliance' => $alliance));
335
-		}
336
-		else {
338
+		} else {
337 339
 			$this->actionTaken('LeaveAlliance', array('Alliance' => $alliance));
338 340
 			if ($alliance->getLeaderID() != 0 && $alliance->getLeaderID() != ACCOUNT_ID_NHL) {
339 341
 				$this->sendMessage($alliance->getLeaderID(), MSG_PLAYER, 'I left your alliance!', false);
@@ -361,7 +363,9 @@  discard block
 block discarded – undo
361 363
 			try {
362 364
 				$this->sendMessage($alliance->getLeaderID(), MSG_PLAYER, 'I joined your alliance!', false);
363 365
 			} catch (AccountNotFoundException $e) {
364
-				if ($alliance->getLeaderID() != ACCOUNT_ID_NHL) throw $e;
366
+				if ($alliance->getLeaderID() != ACCOUNT_ID_NHL) {
367
+					throw $e;
368
+				}
365 369
 			}
366 370
 
367 371
 			$roleID = ALLIANCE_ROLE_NEW_MEMBER;
@@ -381,8 +385,9 @@  discard block
 block discarded – undo
381 385
 	}
382 386
 
383 387
 	private function setAllianceJoinable($time) {
384
-		if ($this->allianceJoinable == $time)
385
-			return;
388
+		if ($this->allianceJoinable == $time) {
389
+					return;
390
+		}
386 391
 		$this->allianceJoinable = $time;
387 392
 		$this->hasChanged = true;
388 393
 	}
@@ -392,8 +397,9 @@  discard block
 block discarded – undo
392 397
 	}
393 398
 
394 399
 	public function setAttackColour($colour) {
395
-		if ($this->attackColour == $colour)
396
-			return;
400
+		if ($this->attackColour == $colour) {
401
+					return;
402
+		}
397 403
 		$this->attackColour = $colour;
398 404
 		$this->hasChanged = true;
399 405
 //		$this->db->query('UPDATE player SET attack_warning = ' . $this->db->escapeString($this->attackColour) . ' WHERE ' . $this->SQL . ' LIMIT 1');
@@ -404,28 +410,35 @@  discard block
 block discarded – undo
404 410
 	}
405 411
 
406 412
 	public function increaseBank($credits) {
407
-		if ($credits < 0)
408
-			throw new Exception('Trying to increase negative credits.');
409
-		if ($credits == 0)
410
-			return;
413
+		if ($credits < 0) {
414
+					throw new Exception('Trying to increase negative credits.');
415
+		}
416
+		if ($credits == 0) {
417
+					return;
418
+		}
411 419
 		$credits += $this->bank;
412 420
 		$this->setBank($credits);
413 421
 	}
414 422
 	public function decreaseBank($credits) {
415
-		if ($credits < 0)
416
-			throw new Exception('Trying to decrease negative credits.');
417
-		if ($credits == 0)
418
-			return;
423
+		if ($credits < 0) {
424
+					throw new Exception('Trying to decrease negative credits.');
425
+		}
426
+		if ($credits == 0) {
427
+					return;
428
+		}
419 429
 		$credits = $this->bank - $credits;
420 430
 		$this->setBank($credits);
421 431
 	}
422 432
 	public function setBank($credits) {
423
-		if ($this->bank == $credits)
424
-			return;
425
-		if ($credits < 0)
426
-			throw new Exception('Trying to set negative credits.');
427
-		if ($credits > MAX_MONEY)
428
-			throw new Exception('Trying to set more than max credits.');
433
+		if ($this->bank == $credits) {
434
+					return;
435
+		}
436
+		if ($credits < 0) {
437
+					throw new Exception('Trying to set negative credits.');
438
+		}
439
+		if ($credits > MAX_MONEY) {
440
+					throw new Exception('Trying to set more than max credits.');
441
+		}
429 442
 		$this->bank = $credits;
430 443
 		$this->hasChanged = true;
431 444
 //		$this->db->query('UPDATE player SET bank = '.$this->bank.' WHERE '.$this->SQL.' LIMIT 1');
@@ -436,8 +449,9 @@  discard block
 block discarded – undo
436 449
 	}
437 450
 
438 451
 	private function setLastNewsUpdate($time) {
439
-		if ($this->lastNewsUpdate == $time)
440
-			return;
452
+		if ($this->lastNewsUpdate == $time) {
453
+					return;
454
+		}
441 455
 		$this->lastNewsUpdate = $time;
442 456
 		$this->hasChanged = true;
443 457
 //		$this->db->query('UPDATE player SET last_news_update = ' . $time . ' WHERE ' . $this->SQL . ' LIMIT 1');
@@ -484,7 +498,9 @@  discard block
 block discarded – undo
484 498
 
485 499
 	public function updateTurns() {
486 500
 		// is account validated?
487
-		if (!$this->getAccount()->isValidated()) return;
501
+		if (!$this->getAccount()->isValidated()) {
502
+			return;
503
+		}
488 504
 
489 505
 		// how many turns would he get right now?
490 506
 		$extraTurns = $this->getTurnsGained(TIME);
@@ -503,8 +519,9 @@  discard block
 block discarded – undo
503 519
 	}
504 520
 
505 521
 	public function setIgnoreGlobals($bool) {
506
-		if ($this->ignoreGlobals == $bool)
507
-			return;
522
+		if ($this->ignoreGlobals == $bool) {
523
+					return;
524
+		}
508 525
 		$this->ignoreGlobals = $bool;
509 526
 		$this->hasChanged = true;
510 527
 //		$this->db->query('UPDATE player SET ignore_globals = '.$this->db->escapeBoolean($bool).' WHERE '.$this->SQL.' LIMIT 1');
@@ -516,8 +533,9 @@  discard block
 block discarded – undo
516 533
 	}
517 534
 
518 535
 	public function setLastPort($lastPort) {
519
-		if ($this->lastPort == $lastPort)
520
-			return;
536
+		if ($this->lastPort == $lastPort) {
537
+					return;
538
+		}
521 539
 		$this->lastPort = $lastPort;
522 540
 		$this->hasChanged = true;
523 541
 //		$this->db->query('UPDATE player SET last_port = ' . $this->lastPort . ' WHERE ' . $this->SQL . ' LIMIT 1');
@@ -528,8 +546,9 @@  discard block
 block discarded – undo
528 546
 	}
529 547
 
530 548
 	public function setDisplayMissions($bool) {
531
-		if ($this->displayMissions == $bool)
532
-			return;
549
+		if ($this->displayMissions == $bool) {
550
+					return;
551
+		}
533 552
 		$this->displayMissions = $bool;
534 553
 		$this->hasChanged = true;
535 554
 	}
@@ -544,8 +563,9 @@  discard block
 block discarded – undo
544 563
 	 * which does not acquire a sector lock.
545 564
 	 */
546 565
 	public function setDisplayWeapons($bool) {
547
-		if ($this->displayWeapons == $bool)
548
-			return;
566
+		if ($this->displayWeapons == $bool) {
567
+					return;
568
+		}
549 569
 		$this->displayWeapons = $bool;
550 570
 		$this->db->query('UPDATE player SET display_weapons=' . $this->db->escapeBoolean($this->displayWeapons) . ' WHERE ' . $this->SQL);
551 571
 	}
@@ -555,8 +575,9 @@  discard block
 block discarded – undo
555 575
 	}
556 576
 
557 577
 	public function setForceDropMessages($bool) {
558
-		if ($this->forceDropMessages == $bool)
559
-			return;
578
+		if ($this->forceDropMessages == $bool) {
579
+					return;
580
+		}
560 581
 		$this->forceDropMessages = $bool;
561 582
 		$this->hasChanged = true;
562 583
 	}
@@ -588,8 +609,9 @@  discard block
 block discarded – undo
588 609
 	}
589 610
 
590 611
 	public function setLastTurnUpdate($time) {
591
-		if ($this->lastTurnUpdate == $time)
592
-			return;
612
+		if ($this->lastTurnUpdate == $time) {
613
+					return;
614
+		}
593 615
 		$this->lastTurnUpdate = $time;
594 616
 		$this->hasChanged = true;
595 617
 //		$sql = $this->db->query('UPDATE player SET last_turn_update = ' . $this->lastTurnUpdate . ' WHERE '. $this->SQL . ' LIMIT 1');
@@ -629,27 +651,33 @@  discard block
 block discarded – undo
629 651
 	}
630 652
 
631 653
 	public function increaseRelations($relations, $raceID) {
632
-		if ($relations < 0)
633
-			throw new Exception('Trying to increase negative relations.');
634
-		if ($relations == 0)
635
-			return;
654
+		if ($relations < 0) {
655
+					throw new Exception('Trying to increase negative relations.');
656
+		}
657
+		if ($relations == 0) {
658
+					return;
659
+		}
636 660
 		$relations += $this->getPureRelation($raceID);
637 661
 		$this->setRelations($relations, $raceID);
638 662
 	}
639 663
 	public function decreaseRelations($relations, $raceID) {
640
-		if ($relations < 0)
641
-			throw new Exception('Trying to decrease negative relations.');
642
-		if ($relations == 0)
643
-			return;
664
+		if ($relations < 0) {
665
+					throw new Exception('Trying to decrease negative relations.');
666
+		}
667
+		if ($relations == 0) {
668
+					return;
669
+		}
644 670
 		$relations = $this->getPureRelation($raceID) - $relations;
645 671
 		$this->setRelations($relations, $raceID);
646 672
 	}
647 673
 	public function setRelations($relations, $raceID) {
648 674
 		$this->getRelations();
649
-		if ($this->pureRelations[$raceID] == $relations)
650
-			return;
651
-		if ($relations < MIN_RELATIONS)
652
-			$relations = MIN_RELATIONS;
675
+		if ($this->pureRelations[$raceID] == $relations) {
676
+					return;
677
+		}
678
+		if ($relations < MIN_RELATIONS) {
679
+					$relations = MIN_RELATIONS;
680
+		}
653 681
 		$relationsDiff = IRound($relations - $this->pureRelations[$raceID]);
654 682
 		$this->pureRelations[$raceID] = $relations;
655 683
 		$this->relations[$raceID] += $relationsDiff;
@@ -684,8 +712,7 @@  discard block
 block discarded – undo
684 712
 			$this->db->query('SELECT * FROM ship_has_name WHERE ' . $this->SQL . ' LIMIT 1');
685 713
 			if ($this->db->nextRecord()) {
686 714
 				$this->customShipName = $this->db->getField('ship_name');
687
-			}
688
-			else {
715
+			} else {
689 716
 				$this->customShipName = false;
690 717
 			}
691 718
 		}
@@ -703,8 +730,7 @@  discard block
 block discarded – undo
703 730
 				$this->knowledge['Nyx'] = $this->db->getInt('nyx');
704 731
 				$this->knowledge['Federation'] = 0;
705 732
 				$this->knowledge['Underground'] = 0;
706
-			}
707
-			else {
733
+			} else {
708 734
 				$this->knowledge['Erebus'] = 0;
709 735
 				$this->knowledge['Aether'] = 0;
710 736
 				$this->knowledge['Tartarus'] = 0;
@@ -713,10 +739,12 @@  discard block
 block discarded – undo
713 739
 				$this->knowledge['Underground'] = 0;
714 740
 			}
715 741
 		}
716
-		if ($knowledgeType === false)
717
-			return $this->knowledge;
718
-		if (isset($this->knowledge[$knowledgeType]))
719
-			return $this->knowledge[$knowledgeType];
742
+		if ($knowledgeType === false) {
743
+					return $this->knowledge;
744
+		}
745
+		if (isset($this->knowledge[$knowledgeType])) {
746
+					return $this->knowledge[$knowledgeType];
747
+		}
720 748
 		return false;
721 749
 	}
722 750
 
@@ -729,9 +757,10 @@  discard block
 block discarded – undo
729 757
 		$sector->diedHere($this);
730 758
 
731 759
 		// if we are in an alliance we increase their deaths
732
-		if ($this->hasAlliance())
733
-			$this->db->query('UPDATE alliance SET alliance_deaths = alliance_deaths + 1
760
+		if ($this->hasAlliance()) {
761
+					$this->db->query('UPDATE alliance SET alliance_deaths = alliance_deaths + 1
734 762
 							WHERE game_id = ' . $this->db->escapeNumber($this->getGameID()) . ' AND alliance_id = ' . $this->db->escapeNumber($this->getAllianceID()) . ' LIMIT 1');
763
+		}
735 764
 
736 765
 		// record death stat
737 766
 		$this->increaseHOF(1, array('Dying', 'Deaths'), HOF_PUBLIC);
@@ -744,8 +773,9 @@  discard block
 block discarded – undo
744 773
 		$newCredits = IRound($this->getShip()->getCost() / 4);
745 774
 		$old_speed = $this->getShip()->getSpeed();
746 775
 
747
-		if ($newCredits < 100000)
748
-			$newCredits = 100000;
776
+		if ($newCredits < 100000) {
777
+					$newCredits = 100000;
778
+		}
749 779
 		$this->setCredits($newCredits);
750 780
 
751 781
 		$this->setSectorID($this::getHome($this->getGameID(), $this->getRaceID()));
@@ -820,14 +850,14 @@  discard block
 block discarded – undo
820 850
 		$relation = $relations[$killer->getRaceID()];
821 851
 
822 852
 		$alignChangePerRelation = 0.1;
823
-		if ($relation >= RELATIONS_PEACE || $relation <= RELATIONS_WAR)
824
-			$alignChangePerRelation = 0.04;
853
+		if ($relation >= RELATIONS_PEACE || $relation <= RELATIONS_WAR) {
854
+					$alignChangePerRelation = 0.04;
855
+		}
825 856
 
826 857
 		$return['KillerAlign'] = -$relation * $alignChangePerRelation; //Lose relations when killing a peaceful race
827 858
 		if ($return['KillerAlign'] > 0) {
828 859
 			$killer->increaseAlignment($return['KillerAlign']);
829
-		}
830
-		else {
860
+		} else {
831 861
 			$killer->decreaseAlignment(-$return['KillerAlign']);
832 862
 		}
833 863
 		// War setting gives them military pay
@@ -861,8 +891,7 @@  discard block
 block discarded – undo
861 891
 			// If the podded players alignment makes them deputy or member then set bounty
862 892
 			if ($this->getAlignment() >= 100) {
863 893
 				$return['BountyGained']['Type'] = 'HQ';
864
-			}
865
-			else if ($this->getAlignment() <= 100) {
894
+			} else if ($this->getAlignment() <= 100) {
866 895
 				$return['BountyGained']['Type'] = 'UG';
867 896
 			}
868 897
 
@@ -884,16 +913,14 @@  discard block
 block discarded – undo
884 913
 
885 914
 			if ($return['KillerAlign'] > 0) {
886 915
 				$killer->increaseHOF($return['KillerAlign'], array('Killing', 'NPC', 'Alignment', 'Gain'), HOF_PUBLIC);
887
-			}
888
-			else {
916
+			} else {
889 917
 				$killer->increaseHOF(-$return['KillerAlign'], array('Killing', 'NPC', 'Alignment', 'Loss'), HOF_PUBLIC);
890 918
 			}
891 919
 
892 920
 			$killer->increaseHOF($return['BountyGained']['Amount'], array('Killing', 'NPC', 'Money', 'Bounty Gained'), HOF_PUBLIC);
893 921
 
894 922
 			$killer->increaseHOF(1, array('Killing', 'NPC Kills'), HOF_PUBLIC);
895
-		}
896
-		else {
923
+		} else {
897 924
 			$killer->increaseHOF($return['KillerExp'], array('Killing', 'Experience', 'Gained'), HOF_PUBLIC);
898 925
 			$killer->increaseHOF($this->getExperience(), array('Killing', 'Experience', 'Of Traders Killed'), HOF_PUBLIC);
899 926
 
@@ -905,8 +932,7 @@  discard block
 block discarded – undo
905 932
 
906 933
 			if ($return['KillerAlign'] > 0) {
907 934
 				$killer->increaseHOF($return['KillerAlign'], array('Killing', 'Alignment', 'Gain'), HOF_PUBLIC);
908
-			}
909
-			else {
935
+			} else {
910 936
 				$killer->increaseHOF(-$return['KillerAlign'], array('Killing', 'Alignment', 'Loss'), HOF_PUBLIC);
911 937
 			}
912 938
 
@@ -914,8 +940,7 @@  discard block
 block discarded – undo
914 940
 
915 941
 			if ($this->getShip()->getAttackRatingWithMaxCDs() <= MAX_ATTACK_RATING_NEWBIE && $this->hasNewbieStatus() && !$killer->hasNewbieStatus()) { //Newbie kill
916 942
 				$killer->increaseHOF(1, array('Killing', 'Newbie Kills'), HOF_PUBLIC);
917
-			}
918
-			else {
943
+			} else {
919 944
 				$killer->increaseKills(1);
920 945
 				$killer->increaseHOF(1, array('Killing', 'Kills'), HOF_PUBLIC);
921 946
 
@@ -1097,20 +1122,21 @@  discard block
 block discarded – undo
1097 1122
 				$bountyChanged = false;
1098 1123
 				$bounty = $this->getBounty($key);
1099 1124
 				if ($bounty['New'] === true) {
1100
-					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0)
1101
-						$this->db->query('INSERT INTO bounty (account_id,game_id,type,amount,smr_credits,claimer_id,time) VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeString($bounty['Type']) . ',' . $this->db->escapeNumber($bounty['Amount']) . ',' . $this->db->escapeNumber($bounty['SmrCredits']) . ',' . $this->db->escapeNumber($bounty['Claimer']) . ',' . $this->db->escapeNumber($bounty['Time']) . ')');
1102
-				}
1103
-				else {
1104
-					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0)
1105
-						$this->db->query('UPDATE bounty
1125
+					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0) {
1126
+											$this->db->query('INSERT INTO bounty (account_id,game_id,type,amount,smr_credits,claimer_id,time) VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeString($bounty['Type']) . ',' . $this->db->escapeNumber($bounty['Amount']) . ',' . $this->db->escapeNumber($bounty['SmrCredits']) . ',' . $this->db->escapeNumber($bounty['Claimer']) . ',' . $this->db->escapeNumber($bounty['Time']) . ')');
1127
+					}
1128
+				} else {
1129
+					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0) {
1130
+											$this->db->query('UPDATE bounty
1106 1131
 							SET amount=' . $this->db->escapeNumber($bounty['Amount']) . ',
1107 1132
 							smr_credits=' . $this->db->escapeNumber($bounty['SmrCredits']) . ',
1108 1133
 							type=' . $this->db->escapeString($bounty['Type']) . ',
1109 1134
 							claimer_id=' . $this->db->escapeNumber($bounty['Claimer']) . ',
1110 1135
 							time=' . $this->db->escapeNumber($bounty['Time']) . '
1111 1136
 							WHERE bounty_id=' . $this->db->escapeNumber($bounty['ID']) . ' AND ' . $this->SQL . ' LIMIT 1');
1112
-					else
1113
-						$this->db->query('DELETE FROM bounty WHERE bounty_id=' . $this->db->escapeNumber($bounty['ID']) . ' AND ' . $this->SQL . ' LIMIT 1');
1137
+					} else {
1138
+											$this->db->query('DELETE FROM bounty WHERE bounty_id=' . $this->db->escapeNumber($bounty['ID']) . ' AND ' . $this->SQL . ' LIMIT 1');
1139
+					}
1114 1140
 				}
1115 1141
 			}
1116 1142
 		}
@@ -1118,14 +1144,16 @@  discard block
 block discarded – undo
1118 1144
 	}
1119 1145
 
1120 1146
 	public function saveHOF() {
1121
-		if ($this->hasHOFChanged !== false)
1122
-			$this->doHOFSave($this->hasHOFChanged);
1147
+		if ($this->hasHOFChanged !== false) {
1148
+					$this->doHOFSave($this->hasHOFChanged);
1149
+		}
1123 1150
 		if (!empty(self::$hasHOFVisChanged)) {
1124 1151
 			foreach (self::$hasHOFVisChanged as $hofType => $changeType) {
1125
-				if ($changeType == self::HOF_NEW)
1126
-					$this->db->query('INSERT INTO hof_visibility (type, visibility) VALUES (' . $this->db->escapeString($hofType) . ',' . $this->db->escapeString(self::$HOFVis[$hofType]) . ')');
1127
-				else
1128
-					$this->db->query('UPDATE hof_visibility SET visibility = ' . $this->db->escapeString(self::$HOFVis[$hofType]) . ' WHERE type = ' . $this->db->escapeString($hofType) . ' LIMIT 1');
1152
+				if ($changeType == self::HOF_NEW) {
1153
+									$this->db->query('INSERT INTO hof_visibility (type, visibility) VALUES (' . $this->db->escapeString($hofType) . ',' . $this->db->escapeString(self::$HOFVis[$hofType]) . ')');
1154
+				} else {
1155
+									$this->db->query('UPDATE hof_visibility SET visibility = ' . $this->db->escapeString(self::$HOFVis[$hofType]) . ' WHERE type = ' . $this->db->escapeString($hofType) . ' LIMIT 1');
1156
+				}
1129 1157
 				unset(self::$hasHOFVisChanged[$hofType]);
1130 1158
 			}
1131 1159
 		}
@@ -1136,14 +1164,13 @@  discard block
 block discarded – undo
1136 1164
 			$tempTypeList[] = $type;
1137 1165
 			if (is_array($hofChanged)) {
1138 1166
 				$this->doHOFSave($hofChanged, $tempTypeList);
1139
-			}
1140
-			else {
1167
+			} else {
1141 1168
 				$amount = $this->getHOF($tempTypeList);
1142 1169
 				if ($hofChanged == self::HOF_NEW) {
1143
-					if ($amount > 0)
1144
-						$this->db->query('INSERT INTO player_hof (account_id,game_id,type,amount) VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeArray($tempTypeList, false, true, ':', false) . ',' . $this->db->escapeNumber($amount) . ')');
1145
-				}
1146
-				else if ($hofChanged == self::HOF_CHANGED) {
1170
+					if ($amount > 0) {
1171
+											$this->db->query('INSERT INTO player_hof (account_id,game_id,type,amount) VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeArray($tempTypeList, false, true, ':', false) . ',' . $this->db->escapeNumber($amount) . ')');
1172
+					}
1173
+				} else if ($hofChanged == self::HOF_CHANGED) {
1147 1174
 	//				if($amount > 0)
1148 1175
 						$this->db->query('UPDATE player_hof
1149 1176
 							SET amount=' . $this->db->escapeNumber($amount) . '
@@ -1254,11 +1281,12 @@  discard block
 block discarded – undo
1254 1281
 			$this->tickers = array();
1255 1282
 			//get ticker info
1256 1283
 			$this->db->query('SELECT type,time,expires,recent FROM player_has_ticker WHERE ' . $this->SQL . ' AND expires > ' . $this->db->escapeNumber(TIME));
1257
-			while ($this->db->nextRecord())
1258
-				$this->tickers[$this->db->getField('type')] = array('Type' => $this->db->getField('type'),
1284
+			while ($this->db->nextRecord()) {
1285
+							$this->tickers[$this->db->getField('type')] = array('Type' => $this->db->getField('type'),
1259 1286
 																				'Time' => $this->db->getInt('time'),
1260 1287
 																				'Expires' => $this->db->getInt('expires'),
1261 1288
 																				'Recent' => $this->db->getField('recent'));
1289
+			}
1262 1290
 		}
1263 1291
 		return $this->tickers;
1264 1292
 	}
@@ -1269,8 +1297,9 @@  discard block
 block discarded – undo
1269 1297
 
1270 1298
 	public function getTicker($tickerType) {
1271 1299
 		$tickers = $this->getTickers();
1272
-		if (isset($tickers[$tickerType]))
1273
-			return $tickers[$tickerType];
1300
+		if (isset($tickers[$tickerType])) {
1301
+					return $tickers[$tickerType];
1302
+		}
1274 1303
 		return false;
1275 1304
 	}
1276 1305
 
@@ -1279,9 +1308,15 @@  discard block
 block discarded – undo
1279 1308
 	}
1280 1309
 
1281 1310
 	public function getTurnsLevel() {
1282
-		if (!$this->hasTurns()) return 'NONE';
1283
-		if ($this->getTurns() <= 25) return 'LOW';
1284
-		if ($this->getTurns() <= 75) return 'MEDIUM';
1311
+		if (!$this->hasTurns()) {
1312
+			return 'NONE';
1313
+		}
1314
+		if ($this->getTurns() <= 25) {
1315
+			return 'LOW';
1316
+		}
1317
+		if ($this->getTurns() <= 75) {
1318
+			return 'MEDIUM';
1319
+		}
1285 1320
 		return 'HIGH';
1286 1321
 	}
1287 1322
 
@@ -1359,8 +1394,9 @@  discard block
 block discarded – undo
1359 1394
 
1360 1395
 	public function sendGlobalMessage($message, $canBeIgnored = true) {
1361 1396
 		if ($canBeIgnored) {
1362
-			if ($this->getAccount()->isMailBanned())
1363
-				create_error('You are currently banned from sending messages');
1397
+			if ($this->getAccount()->isMailBanned()) {
1398
+							create_error('You are currently banned from sending messages');
1399
+			}
1364 1400
 		}
1365 1401
 		$this->sendMessageToBox(BOX_GLOBALS, $message);
1366 1402
 
@@ -1383,12 +1419,14 @@  discard block
 block discarded – undo
1383 1419
 	public function sendMessage($receiverID, $messageTypeID, $message, $canBeIgnored = true, $unread = true, $expires = false, $senderDelete = false) {
1384 1420
 		//get expire time
1385 1421
 		if ($canBeIgnored) {
1386
-			if ($this->getAccount()->isMailBanned())
1387
-				create_error('You are currently banned from sending messages');
1422
+			if ($this->getAccount()->isMailBanned()) {
1423
+							create_error('You are currently banned from sending messages');
1424
+			}
1388 1425
 			// Don't send messages to players ignoring us
1389 1426
 			$this->db->query('SELECT account_id FROM message_blacklist WHERE account_id=' . $this->db->escapeNumber($receiverID) . ' AND blacklisted_id=' . $this->db->escapeNumber($this->getAccountID()) . ' LIMIT 1');
1390
-			if ($this->db->nextRecord())
1391
-				return;
1427
+			if ($this->db->nextRecord()) {
1428
+							return;
1429
+			}
1392 1430
 		}
1393 1431
 
1394 1432
 		$message = word_filter($message);
@@ -1469,32 +1507,36 @@  discard block
 block discarded – undo
1469 1507
 
1470 1508
 	public static function sendMessageFromAdmin($gameID, $receiverID, $message, $expires = false) {
1471 1509
 		//get expire time
1472
-		if ($expires === false)
1473
-			$expires = TIME + 86400 * 365;
1510
+		if ($expires === false) {
1511
+					$expires = TIME + 86400 * 365;
1512
+		}
1474 1513
 		// send him the message
1475 1514
 		self::doMessageSending(ACCOUNT_ID_ADMIN, $receiverID, $gameID, MSG_ADMIN, $message, $expires);
1476 1515
 	}
1477 1516
 
1478 1517
 	public static function sendMessageFromAllianceAmbassador($gameID, $receiverID, $message, $expires = false) {
1479 1518
 		//get expire time
1480
-		if ($expires === false)
1481
-			$expires = TIME + 86400 * 31;
1519
+		if ($expires === false) {
1520
+					$expires = TIME + 86400 * 31;
1521
+		}
1482 1522
 		// send him the message
1483 1523
 		self::doMessageSending(ACCOUNT_ID_ALLIANCE_AMBASSADOR, $receiverID, $gameID, MSG_ALLIANCE, $message, $expires);
1484 1524
 	}
1485 1525
 
1486 1526
 	public static function sendMessageFromCasino($gameID, $receiverID, $message, $expires = false) {
1487 1527
 		//get expire time
1488
-		if ($expires === false)
1489
-			$expires = TIME + 86400 * 7;
1528
+		if ($expires === false) {
1529
+					$expires = TIME + 86400 * 7;
1530
+		}
1490 1531
 		// send him the message
1491 1532
 		self::doMessageSending(ACCOUNT_ID_CASINO, $receiverID, $gameID, MSG_CASINO, $message, $expires);
1492 1533
 	}
1493 1534
 
1494 1535
 	public static function sendMessageFromRace($raceID, $gameID, $receiverID, $message, $expires = false) {
1495 1536
 		//get expire time
1496
-		if ($expires === false)
1497
-			$expires = TIME + 86400 * 5;
1537
+		if ($expires === false) {
1538
+					$expires = TIME + 86400 * 5;
1539
+		}
1498 1540
 		// send him the message
1499 1541
 		self::doMessageSending(ACCOUNT_ID_GROUP_RACES + $raceID, $receiverID, $gameID, MSG_POLITICAL, $message, $expires);
1500 1542
 	}
@@ -1537,11 +1579,11 @@  discard block
 block discarded – undo
1537 1579
 	public function setPlottedCourse(Distance $plottedCourse) {
1538 1580
 		$hadPlottedCourse = $this->hasPlottedCourse();
1539 1581
 		$this->plottedCourse = $plottedCourse;
1540
-		if ($this->plottedCourse->getTotalSectors() > 0)
1541
-			$this->db->query('REPLACE INTO player_plotted_course
1582
+		if ($this->plottedCourse->getTotalSectors() > 0) {
1583
+					$this->db->query('REPLACE INTO player_plotted_course
1542 1584
 				(account_id, game_id, course)
1543 1585
 				VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeBinary(serialize($this->plottedCourse)) . ')');
1544
-		else if ($hadPlottedCourse) {
1586
+		} else if ($hadPlottedCourse) {
1545 1587
 			$this->deletePlottedCourse();
1546 1588
 		}
1547 1589
 	}
@@ -1551,12 +1593,14 @@  discard block
 block discarded – undo
1551 1593
 	}
1552 1594
 
1553 1595
 	public function isPartOfCourse($sectorOrSectorID) {
1554
-		if (!$this->hasPlottedCourse())
1555
-			return false;
1556
-		if ($sectorOrSectorID instanceof SmrSector)
1557
-			$sectorID = $sectorOrSectorID->getSectorID();
1558
-		else
1559
-			$sectorID = $sectorOrSectorID;
1596
+		if (!$this->hasPlottedCourse()) {
1597
+					return false;
1598
+		}
1599
+		if ($sectorOrSectorID instanceof SmrSector) {
1600
+					$sectorID = $sectorOrSectorID->getSectorID();
1601
+		} else {
1602
+					$sectorID = $sectorOrSectorID;
1603
+		}
1560 1604
 		return $this->getPlottedCourse()->isInPath($sectorID);
1561 1605
 	}
1562 1606
 
Please login to merge, or discard this patch.
lib/Default/message.functions.inc 1 patch
Braces   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -26,30 +26,30 @@
 block discarded – undo
26 26
 }
27 27
 
28 28
 function getMessagePlayer($accountID, $gameID, $messageType = false) {
29
-	if ($accountID == ACCOUNT_ID_PORT)
30
-		$return = '<span class="yellow">Port Defenses</span>';
31
-	else if ($accountID == ACCOUNT_ID_ADMIN)
32
-		$return = '<span class="admin">Administrator</span>';
33
-	else if ($accountID == ACCOUNT_ID_PLANET)
34
-		$return = '<span class="yellow">Planetary Defenses</span>';
35
-	else if ($accountID == ACCOUNT_ID_ALLIANCE_AMBASSADOR)
36
-		$return = '<span class="green">Alliance Ambassador</span>';
37
-	else if ($accountID == ACCOUNT_ID_CASINO)
38
-		$return = '<span class="yellow">Casino</span>';
39
-	else if ($accountID == ACCOUNT_ID_FED_CLERK)
40
-		$return = '<span class="yellow">Federal Clerk</span>';
41
-	else if ($accountID == ACCOUNT_ID_OP_ANNOUNCE || $accountID == ACCOUNT_ID_ALLIANCE_COMMAND)
42
-		$return = '<span class="green">Alliance Command</span>';
43
-	else {
29
+	if ($accountID == ACCOUNT_ID_PORT) {
30
+			$return = '<span class="yellow">Port Defenses</span>';
31
+	} else if ($accountID == ACCOUNT_ID_ADMIN) {
32
+			$return = '<span class="admin">Administrator</span>';
33
+	} else if ($accountID == ACCOUNT_ID_PLANET) {
34
+			$return = '<span class="yellow">Planetary Defenses</span>';
35
+	} else if ($accountID == ACCOUNT_ID_ALLIANCE_AMBASSADOR) {
36
+			$return = '<span class="green">Alliance Ambassador</span>';
37
+	} else if ($accountID == ACCOUNT_ID_CASINO) {
38
+			$return = '<span class="yellow">Casino</span>';
39
+	} else if ($accountID == ACCOUNT_ID_FED_CLERK) {
40
+			$return = '<span class="yellow">Federal Clerk</span>';
41
+	} else if ($accountID == ACCOUNT_ID_OP_ANNOUNCE || $accountID == ACCOUNT_ID_ALLIANCE_COMMAND) {
42
+			$return = '<span class="green">Alliance Command</span>';
43
+	} else {
44 44
 		foreach (Globals::getRaces() as $raceID => $raceInfo) {
45 45
 			if ($accountID == ACCOUNT_ID_GROUP_RACES + $raceID) {
46 46
 				$return = '<span class="yellow">' . $raceInfo['Race Name'] . ' Government</span>';
47 47
 				return $return;
48 48
 			}
49 49
 		}
50
-		if (!empty($accountID))
51
-			$return = SmrPlayer::getPlayer($accountID, $gameID);
52
-		else {
50
+		if (!empty($accountID)) {
51
+					$return = SmrPlayer::getPlayer($accountID, $gameID);
52
+		} else {
53 53
 			switch ($messageType) {
54 54
 				case MSG_ADMIN:
55 55
 					$return = '<span class="admin">Administrator</span>';
Please login to merge, or discard this patch.
tools/npc/npc.php 1 patch
Braces   +55 added lines, -67 removed lines patch added patch discarded remove patch
@@ -89,12 +89,10 @@  discard block
 block discarded – undo
89 89
 
90 90
 	try {
91 91
 		changeNPCLogin();
92
-	}
93
-	catch (ForwardException $e) {}
92
+	} catch (ForwardException $e) {}
94 93
 
95 94
 	NPCStuff();
96
-}
97
-catch (Throwable $e) {
95
+} catch (Throwable $e) {
98 96
 	logException($e);
99 97
 	// Try to shut down cleanly
100 98
 	exitNPC();
@@ -157,8 +155,7 @@  discard block
 block discarded – undo
157 155
 			$fedContainer = null;
158 156
 			if ($var['url'] == 'shop_ship_processing.php' && ($fedContainer = plotToFed($player, true)) !== true) { //We just bought a ship, we should head back to our trade gal/uno - we use HQ for now as it's both in our gal and a UNO, plus it's safe which is always a bonus
159 157
 				processContainer($fedContainer);
160
-			}
161
-			else if ($player->getShip()->isUnderAttack() === true
158
+			} else if ($player->getShip()->isUnderAttack() === true
162 159
 				&&($player->hasPlottedCourse() === false || $player->getPlottedCourse()->getEndSector()->offersFederalProtection() === false)
163 160
 				&&($fedContainer == null ? $fedContainer = plotToFed($player, true) : $fedContainer) !== true) { //We're under attack and need to plot course to fed.
164 161
 				// Get the lock, remove under attack and update.
@@ -171,20 +168,16 @@  discard block
 block discarded – undo
171 168
 				debug('Under Attack');
172 169
 				$underAttack = true;
173 170
 				processContainer($fedContainer);
174
-			}
175
-			else if ($player->hasPlottedCourse() === true && $player->getPlottedCourse()->getEndSector()->offersFederalProtection()) { //We have a route to fed to follow, figure it's probably a damned sensible thing to follow.
171
+			} else if ($player->hasPlottedCourse() === true && $player->getPlottedCourse()->getEndSector()->offersFederalProtection()) { //We have a route to fed to follow, figure it's probably a damned sensible thing to follow.
176 172
 				debug('Follow Course: ' . $player->getPlottedCourse()->getNextOnPath());
177 173
 				processContainer(moveToSector($player, $player->getPlottedCourse()->getNextOnPath()));
178
-			}
179
-			else if (($container = canWeUNO($player, true)) !== false) { //We have money and are at a uno, let's uno!
174
+			} else if (($container = canWeUNO($player, true)) !== false) { //We have money and are at a uno, let's uno!
180 175
 				debug('We\'re UNOing');
181 176
 				processContainer($container);
182
-			}
183
-			else if ($player->hasPlottedCourse() === true) { //We have a route to follow, figure it's probably a sensible thing to follow.
177
+			} else if ($player->hasPlottedCourse() === true) { //We have a route to follow, figure it's probably a sensible thing to follow.
184 178
 				debug('Follow Course: ' . $player->getPlottedCourse()->getNextOnPath());
185 179
 				processContainer(moveToSector($player, $player->getPlottedCourse()->getNextOnPath()));
186
-			}
187
-			else if ($player->getTurns() < NPC_LOW_TURNS || ($player->getTurns() < $player->getMaxTurns() / 2 && $player->getNewbieTurns() < NPC_LOW_NEWBIE_TURNS) || $underAttack) { //We're low on turns or have been under attack and need to plot course to fed
180
+			} else if ($player->getTurns() < NPC_LOW_TURNS || ($player->getTurns() < $player->getMaxTurns() / 2 && $player->getNewbieTurns() < NPC_LOW_NEWBIE_TURNS) || $underAttack) { //We're low on turns or have been under attack and need to plot course to fed
188 181
 				if ($player->getTurns() < NPC_LOW_TURNS) {
189 182
 					debug('Low Turns:' . $player->getTurns());
190 183
 				}
@@ -201,16 +194,13 @@  discard block
 block discarded – undo
201 194
 				}
202 195
 				$ship = $player->getShip();
203 196
 				processContainer(plotToFed($player, !$ship->hasMaxShields() || !$ship->hasMaxArmour() || !$ship->hasMaxCargoHolds()));
204
-			}
205
-			else if (($container = checkForShipUpgrade($player)) !== false) { //We have money and are at a uno, let's uno!
197
+			} else if (($container = checkForShipUpgrade($player)) !== false) { //We have money and are at a uno, let's uno!
206 198
 				debug('We\'re reshipping!');
207 199
 				processContainer($container);
208
-			}
209
-			else if (($container = canWeUNO($player, false)) !== false) { //We need to UNO and have enough money to do it properly so let's do it sooner rather than later.
200
+			} else if (($container = canWeUNO($player, false)) !== false) { //We need to UNO and have enough money to do it properly so let's do it sooner rather than later.
210 201
 				debug('We need to UNO, so off we go!');
211 202
 				processContainer($container);
212
-			}
213
-			else if ($TRADE_ROUTE instanceof \Routes\Route) {
203
+			} else if ($TRADE_ROUTE instanceof \Routes\Route) {
214 204
 				debug('Trade Route');
215 205
 				$forwardRoute = $TRADE_ROUTE->getForwardRoute();
216 206
 				$returnRoute = $TRADE_ROUTE->getReturnRoute();
@@ -218,8 +208,7 @@  discard block
 block discarded – undo
218 208
 					if ($forwardRoute->getBuySectorId() == $player->getSectorID()) {
219 209
 						$buyRoute = $forwardRoute;
220 210
 						$sellRoute = $returnRoute;
221
-					}
222
-					else if ($returnRoute->getBuySectorId() == $player->getSectorID()) {
211
+					} else if ($returnRoute->getBuySectorId() == $player->getSectorID()) {
223 212
 						$buyRoute = $returnRoute;
224 213
 						$sellRoute = $forwardRoute;
225 214
 					}
@@ -236,30 +225,25 @@  discard block
 block discarded – undo
236 225
 								//Sell goods
237 226
 								debug('Sell Goods');
238 227
 								processContainer(tradeGoods($goodID, $player, $port));
239
-							}
240
-							else {
228
+							} else {
241 229
 								//Move to next route or fed.
242 230
 								if (($TRADE_ROUTE =& changeRoute($TRADE_ROUTES)) === false) {
243 231
 									debug('Changing Route Failed');
244 232
 									processContainer(plotToFed($player));
245
-								}
246
-								else {
233
+								} else {
247 234
 									debug('Route Changed');
248 235
 									continue;
249 236
 								}
250 237
 							}
251
-						}
252
-						else if ($ship->hasCargo($buyRoute->getGoodID()) === true) { //We've bought goods, plot to sell
238
+						} else if ($ship->hasCargo($buyRoute->getGoodID()) === true) { //We've bought goods, plot to sell
253 239
 							debug('Plot To Sell: ' . $buyRoute->getSellSectorId());
254 240
 							processContainer(plotToSector($player, $buyRoute->getSellSectorId()));
255
-						}
256
-						else {
241
+						} else {
257 242
 							//Dump goods
258 243
 							debug('Dump Goods');
259 244
 							processContainer(dumpCargo($player));
260 245
 						}
261
-					}
262
-					else { //Buy goods
246
+					} else { //Buy goods
263 247
 						$goodID = $buyRoute->getGoodID();
264 248
 
265 249
 						$port = $player->getSector()->getPort();
@@ -268,26 +252,22 @@  discard block
 block discarded – undo
268 252
 						if ($tradeable === true && $port->getGoodAmount($goodID) >= $ship->getEmptyHolds()) { //Buy goods
269 253
 							debug('Buy Goods');
270 254
 							processContainer(tradeGoods($goodID, $player, $port));
271
-						}
272
-						else {
255
+						} else {
273 256
 							//Move to next route or fed.
274 257
 							if (($TRADE_ROUTE =& changeRoute($TRADE_ROUTES)) === false) {
275 258
 								debug('Changing Route Failed');
276 259
 								processContainer(plotToFed($player));
277
-							}
278
-							else {
260
+							} else {
279 261
 								debug('Route Changed');
280 262
 								continue;
281 263
 							}
282 264
 						}
283 265
 					}
284
-				}
285
-				else {
266
+				} else {
286 267
 					debug('Plot To Buy: ' . $forwardRoute->getBuySectorId());
287 268
 					processContainer(plotToSector($player, $forwardRoute->getBuySectorId()));
288 269
 				}
289
-			}
290
-			else { //Something weird is going on.. Let's fed and wait.
270
+			} else { //Something weird is going on.. Let's fed and wait.
291 271
 				debug('No actual action? Wtf?');
292 272
 				processContainer(plotToFed($player));
293 273
 			}
@@ -299,8 +279,7 @@  discard block
 block discarded – undo
299 279
 				processContainer(moveToSector($player,$moveTo));
300 280
 			}
301 281
 			*/
302
-		}
303
-		catch (ForwardException $e) {
282
+		} catch (ForwardException $e) {
304 283
 			global $lock;
305 284
 			if ($lock) { //only save if we have the lock.
306 285
 				SmrSector::saveSectors();
@@ -308,8 +287,9 @@  discard block
 block discarded – undo
308 287
 				SmrPlayer::savePlayers();
309 288
 				SmrForce::saveForces();
310 289
 				SmrPort::savePorts();
311
-				if (class_exists('WeightedRandom', false))
312
-					WeightedRandom::saveWeightedRandoms();
290
+				if (class_exists('WeightedRandom', false)) {
291
+									WeightedRandom::saveWeightedRandoms();
292
+				}
313 293
 				release_lock();
314 294
 			}
315 295
 			//Clean up the caches as the data may get changed by other players
@@ -448,11 +428,13 @@  discard block
 block discarded – undo
448 428
 }
449 429
 
450 430
 function canWeUNO(AbstractSmrPlayer $player, $oppurtunisticOnly) {
451
-	if ($player->getCredits() < MINUMUM_RESERVE_CREDITS)
452
-		return false;
431
+	if ($player->getCredits() < MINUMUM_RESERVE_CREDITS) {
432
+			return false;
433
+	}
453 434
 	$ship = $player->getShip();
454
-	if ($ship->hasMaxShields() && $ship->hasMaxArmour() && $ship->hasMaxCargoHolds())
455
-		return false;
435
+	if ($ship->hasMaxShields() && $ship->hasMaxArmour() && $ship->hasMaxCargoHolds()) {
436
+			return false;
437
+	}
456 438
 	$sector = $player->getSector();
457 439
 
458 440
 	// We buy armour in preference to shields as it's cheaper.
@@ -466,8 +448,7 @@  discard block
 block discarded – undo
466 448
 			$hardwareSold = $location->getHardwareSold();
467 449
 			if ($player->getNewbieTurns() > MIN_NEWBIE_TURNS_TO_BUY_CARGO && !$ship->hasMaxCargoHolds() && isset($hardwareSold[HARDWARE_CARGO]) && ($amount = floor(($player->getCredits() - MINUMUM_RESERVE_CREDITS) / Globals::getHardwareCost(HARDWARE_CARGO))) > 0) { // Buy cargo holds first if we have plenty of newbie turns left.
468 450
 				$hardwareID = HARDWARE_CARGO;
469
-			}
470
-			else {
451
+			} else {
471 452
 				foreach ($hardwareArray as $hardwareArrayID) {
472 453
 					if (!$ship->hasMaxHardware($hardwareArrayID) && isset($hardwareSold[$hardwareArrayID]) && ($amount = floor(($player->getCredits() - MINUMUM_RESERVE_CREDITS) / Globals::getHardwareCost($hardwareArrayID))) > 0) {
473 454
 						$hardwareID = $hardwareArrayID;
@@ -481,11 +462,14 @@  discard block
 block discarded – undo
481 462
 		}
482 463
 	}
483 464
 
484
-	if ($oppurtunisticOnly === true)
485
-		return false;
465
+	if ($oppurtunisticOnly === true) {
466
+			return false;
467
+	}
486 468
 
487
-	if ($player->getCredits() - $ship->getCostToUNO() < MINUMUM_RESERVE_CREDITS)
488
-		return false; //Only do non-oppurtunistic UNO if we have the money to do it properly!
469
+	if ($player->getCredits() - $ship->getCostToUNO() < MINUMUM_RESERVE_CREDITS) {
470
+			return false;
471
+	}
472
+	//Only do non-oppurtunistic UNO if we have the money to do it properly!
489 473
 
490 474
 	foreach ($hardwareArray as $hardwareArrayID) {
491 475
 		if (!$ship->hasMaxHardware($hardwareArrayID)) {
@@ -574,8 +558,10 @@  discard block
 block discarded – undo
574 558
 
575 559
 function checkForShipUpgrade(AbstractSmrPlayer $player) {
576 560
 	foreach (SHIP_UPGRADE_PATH[$player->getRaceID()] as $upgradeShipID) {
577
-		if ($player->getShipTypeID() == $upgradeShipID) //We can't upgrade, only downgrade.
561
+		if ($player->getShipTypeID() == $upgradeShipID) {
562
+			//We can't upgrade, only downgrade.
578 563
 			return false;
564
+		}
579 565
 		$cost = $player->getShip()->getCostToUpgrade($upgradeShipID);
580 566
 		if ($cost <= 0 || $player->getCredits() - $cost > MINUMUM_RESERVE_CREDITS) {
581 567
 			return doShipUpgrade($player, $upgradeShipID);
@@ -597,8 +583,9 @@  discard block
 block discarded – undo
597 583
 
598 584
 function &changeRoute(array &$tradeRoutes) {
599 585
 	$false = false;
600
-	if (count($tradeRoutes) == 0)
601
-		return $false;
586
+	if (count($tradeRoutes) == 0) {
587
+			return $false;
588
+	}
602 589
 	$routeKey = array_rand($tradeRoutes);
603 590
 	$tradeRoute =& $tradeRoutes[$routeKey];
604 591
 	unset($tradeRoutes[$routeKey]);
@@ -612,10 +599,11 @@  discard block
 block discarded – undo
612 599
 
613 600
 	$tradeGoods = array(GOOD_NOTHING => false);
614 601
 	foreach (Globals::getGoods() as $goodID => $good) {
615
-		if ($player->meetsAlignmentRestriction($good['AlignRestriction']))
616
-			$tradeGoods[$goodID] = true;
617
-		else
618
-			$tradeGoods[$goodID] = false;
602
+		if ($player->meetsAlignmentRestriction($good['AlignRestriction'])) {
603
+					$tradeGoods[$goodID] = true;
604
+		} else {
605
+					$tradeGoods[$goodID] = false;
606
+		}
619 607
 	}
620 608
 
621 609
 	// Only allow NPCs to trade at ports of their race and neutral ports
@@ -642,8 +630,7 @@  discard block
 block discarded – undo
642 630
 		$routes = unserialize(gzuncompress($db->getField('routes')));
643 631
 		debug('Using Cached Routes: #' . count($routes));
644 632
 		return $routes;
645
-	}
646
-	else {
633
+	} else {
647 634
 		debug('Generating Routes');
648 635
 		$allSectors = array();
649 636
 		foreach (SmrGalaxy::getGameGalaxies($player->getGameID()) as $galaxy) {
@@ -652,10 +639,11 @@  discard block
 block discarded – undo
652 639
 
653 640
 		$distances = Plotter::calculatePortToPortDistances($allSectors, $maxDistance, $startSectorID, $endSectorID);
654 641
 
655
-		if ($maxNumberOfPorts == 1)
656
-			$allRoutes = \Routes\RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort);
657
-		else
658
-			$allRoutes = \Routes\RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes);
642
+		if ($maxNumberOfPorts == 1) {
643
+					$allRoutes = \Routes\RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort);
644
+		} else {
645
+					$allRoutes = \Routes\RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes);
646
+		}
659 647
 
660 648
 		unset($distances);
661 649
 
Please login to merge, or discard this patch.
lib/Default/smr.inc 1 patch
Braces   +80 added lines, -58 removed lines patch added patch discarded remove patch
@@ -8,8 +8,9 @@  discard block
 block discarded – undo
8 8
 
9 9
 function parseBoolean($check) {
10 10
 	// Only negative strings are not implicitly converted to the correct bool
11
-	if (is_string($check) && (strcasecmp($check, 'NO') == 0 || strcasecmp($check, 'FALSE') == 0))
12
-		return false;
11
+	if (is_string($check) && (strcasecmp($check, 'NO') == 0 || strcasecmp($check, 'FALSE') == 0)) {
12
+			return false;
13
+	}
13 14
 	return (bool)$check;
14 15
 }
15 16
 
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 			break;
33 34
 			case 'player':
34 35
 				$playerID = $default;
35
-				if (!is_numeric($playerID))
36
-					$playerID = $tagParams['id'];
36
+				if (!is_numeric($playerID)) {
37
+									$playerID = $tagParams['id'];
38
+				}
37 39
 				$bbPlayer = SmrPlayer::getPlayerByPlayerID($playerID, $overrideGameID);
38 40
 				if ($action == \Nbbc\BBCode::BBCODE_CHECK) {
39 41
 					return true;
@@ -46,8 +48,9 @@  discard block
 block discarded – undo
46 48
 			break;
47 49
 			case 'alliance':
48 50
 				$allianceID = $default;
49
-				if (!is_numeric($allianceID))
50
-					$allianceID = $tagParams['id'];
51
+				if (!is_numeric($allianceID)) {
52
+									$allianceID = $tagParams['id'];
53
+				}
51 54
 				$alliance = SmrAlliance::getAlliance($allianceID, $overrideGameID);
52 55
 				if ($action == \Nbbc\BBCode::BBCODE_CHECK) {
53 56
 					return true;
@@ -56,10 +59,11 @@  discard block
 block discarded – undo
56 59
 				if ($disableBBLinks === false && $overrideGameID == SmrSession::getGameID()) {
57 60
 					$container = create_container('skeleton.php');
58 61
 					$container['alliance_id'] = $alliance->getAllianceID();
59
-					if (is_object($player) && $alliance->getAllianceID() == $player->getAllianceID())
60
-						$container['body'] = 'alliance_mod.php';
61
-					else
62
-						$container['body'] = 'alliance_roster.php';
62
+					if (is_object($player) && $alliance->getAllianceID() == $player->getAllianceID()) {
63
+											$container['body'] = 'alliance_mod.php';
64
+					} else {
65
+											$container['body'] = 'alliance_roster.php';
66
+					}
63 67
 					return create_link($container, $alliance->getAllianceDisplayName());
64 68
 				}
65 69
 				return $alliance->getAllianceDisplayName();
@@ -83,8 +87,9 @@  discard block
 block discarded – undo
83 87
 					return true;
84 88
 				}
85 89
 				if ($timeString != '' && ($time = strtotime($timeString)) !== false) {
86
-					if (is_object($account))
87
-						$time += $account->getOffset() * 3600;
90
+					if (is_object($account)) {
91
+											$time += $account->getOffset() * 3600;
92
+					}
88 93
 					return date(DATE_FULL_SHORT, $time);
89 94
 				}
90 95
 			break;
@@ -127,8 +132,7 @@  discard block
 block discarded – undo
127 132
 				return '<div class="buttonA"><a class="buttonA" href="' . SmrSession::getNewHREF($container) . '">Join ' . $alliance->getAllianceDisplayName() . '</a></div>';
128 133
 			break;
129 134
 		}
130
-	}
131
-	catch (Exception $e) {
135
+	} catch (Exception $e) {
132 136
 	}
133 137
 	if ($action == \Nbbc\BBCode::BBCODE_CHECK) {
134 138
 		return false;
@@ -173,15 +177,15 @@  discard block
 block discarded – undo
173 177
 		$bbParser->addRule('join_alliance', $smrRule);
174 178
 	}
175 179
 	global $disableBBLinks;
176
-	if ($noLinks === true)
177
-		$disableBBLinks = true;
178
-	else
179
-		$disableBBLinks = false;
180
+	if ($noLinks === true) {
181
+			$disableBBLinks = true;
182
+	} else {
183
+			$disableBBLinks = false;
184
+	}
180 185
 	if (strpos($message, '[') !== false) { //We have BBCode so let's do a full parse.
181 186
 		$message = $bbParser->parse($message);
182 187
 		$message = str_replace('&lt;br /&gt;', '<br />', $message);
183
-	}
184
-	else { //Otherwise just convert newlines
188
+	} else { //Otherwise just convert newlines
185 189
 		$message = nl2br($message, true);
186 190
 	}
187 191
 	return $message;
@@ -221,8 +225,7 @@  discard block
 block discarded – undo
221 225
 
222 226
 	if (!is_array($actions)) {
223 227
 		$form['submit'] = '<input class="submit" type="submit" name="action" value="' . htmlspecialchars($actions) . '">';
224
-	}
225
-	else {
228
+	} else {
226 229
 		$form['submit'] = array();
227 230
 		foreach ($actions as $action) {
228 231
 			$form['submit'][$action[0]] = '<input class="submit" type="submit" name="action" value="' . htmlspecialchars($action[1]) . '">';
@@ -267,8 +270,9 @@  discard block
 block discarded – undo
267 270
 }
268 271
 
269 272
 function forward($new_container) {
270
-	if (defined('OVERRIDE_FORWARD') && OVERRIDE_FORWARD === true)
271
-		return overrideForward($new_container);
273
+	if (defined('OVERRIDE_FORWARD') && OVERRIDE_FORWARD === true) {
274
+			return overrideForward($new_container);
275
+	}
272 276
 	resetContainer($new_container);
273 277
 	do_voodoo();
274 278
 }
@@ -284,8 +288,9 @@  discard block
 block discarded – undo
284 288
 	global $var, $container;
285 289
 
286 290
 	// transfer this value to next container
287
-	if (isset($var[$what]))
288
-		$container[$what] = $var[$what];
291
+	if (isset($var[$what])) {
292
+			$container[$what] = $var[$what];
293
+	}
289 294
 
290 295
 }
291 296
 
@@ -313,8 +318,7 @@  discard block
 block discarded – undo
313 318
 	}
314 319
 	if ($maxValue - $minValue == 0) {
315 320
 		return $text;
316
-	}
317
-	else {
321
+	} else {
318 322
 		$normalisedValue = round(510 * max(0, min($maxValue, $value) - $minValue) / ($maxValue - $minValue)) - 255;
319 323
 	}
320 324
 	if ($type == 'Game') {
@@ -324,28 +328,33 @@  discard block
 block discarded – undo
324 328
 			if (strlen($g_component) == 1) {
325 329
 				$g_component = '0' . $g_component;
326 330
 			}
327
-		}
328
-		else if ($normalisedValue > 0) {
331
+		} else if ($normalisedValue > 0) {
329 332
 			$g_component = 'ff';
330 333
 			$r_component = dechex(255 - $normalisedValue);
331 334
 			if (strlen($r_component) == 1) {
332 335
 				$r_component = '0' . $r_component;
333 336
 			}
334
-		}
335
-		else {
337
+		} else {
336 338
 			$r_component = 'ff';
337 339
 			$g_component = 'ff';
338 340
 		}
339 341
 		$colour = $r_component . $g_component . '00';
340
-		if ($return_type == 'Colour') return $colour;
342
+		if ($return_type == 'Colour') {
343
+			return $colour;
344
+		}
341 345
 		return '<span style="color:#' . $colour . '">' . $text . '</span>';
342
-	}
343
-	elseif ($type == 'IRC') {
346
+	} elseif ($type == 'IRC') {
344 347
 		//IRC color codes
345
-		if ($normalisedValue == 255) $colour = '[k03]';
346
-		elseif ($normalisedValue == -255) $colour = '[k04]';
347
-		else $colour = '[k08]';
348
-		if ($return_type == 'Colour') return $colour;
348
+		if ($normalisedValue == 255) {
349
+			$colour = '[k03]';
350
+		} elseif ($normalisedValue == -255) {
351
+			$colour = '[k04]';
352
+		} else {
353
+			$colour = '[k08]';
354
+		}
355
+		if ($return_type == 'Colour') {
356
+			return $colour;
357
+		}
349 358
 		return $colour . $text;
350 359
 	}
351 360
 }
@@ -404,10 +413,18 @@  discard block
 block discarded – undo
404 413
 	// create account object
405 414
 	$account = SmrSession::getAccount();
406 415
 
407
-	if (!defined('DATE_DATE_SHORT')) define('DATE_DATE_SHORT', $account->getShortDateFormat());
408
-	if (!defined('DATE_TIME_SHORT')) define('DATE_TIME_SHORT', $account->getShortTimeFormat());
409
-	if (!defined('DATE_FULL_SHORT')) define('DATE_FULL_SHORT', DATE_DATE_SHORT . ' ' . DATE_TIME_SHORT);
410
-	if (!defined('DATE_FULL_SHORT_SPLIT')) define('DATE_FULL_SHORT_SPLIT', DATE_DATE_SHORT . '\<b\r /\>' . DATE_TIME_SHORT);
416
+	if (!defined('DATE_DATE_SHORT')) {
417
+		define('DATE_DATE_SHORT', $account->getShortDateFormat());
418
+	}
419
+	if (!defined('DATE_TIME_SHORT')) {
420
+		define('DATE_TIME_SHORT', $account->getShortTimeFormat());
421
+	}
422
+	if (!defined('DATE_FULL_SHORT')) {
423
+		define('DATE_FULL_SHORT', DATE_DATE_SHORT . ' ' . DATE_TIME_SHORT);
424
+	}
425
+	if (!defined('DATE_FULL_SHORT_SPLIT')) {
426
+		define('DATE_FULL_SHORT_SPLIT', DATE_DATE_SHORT . '\<b\r /\>' . DATE_TIME_SHORT);
427
+	}
411 428
 
412 429
 	// initialize objects we usually need, like player, ship
413 430
 	if (SmrSession::hasGame()) {
@@ -454,8 +471,9 @@  discard block
 block discarded – undo
454 471
 
455 472
 		if (!$player->isDead() && $player->getNewbieTurns() <= NEWBIE_TURNS_WARNING_LIMIT &&
456 473
 			$player->getNewbieWarning() &&
457
-			$var['url'] != 'newbie_warning_processing.php')
458
-			forward(create_container('newbie_warning_processing.php'));
474
+			$var['url'] != 'newbie_warning_processing.php') {
475
+					forward(create_container('newbie_warning_processing.php'));
476
+		}
459 477
 	}
460 478
 
461 479
 	// Initialize the template
@@ -533,8 +551,9 @@  discard block
 block discarded – undo
533 551
 function acquire_lock($sector) {
534 552
 	global $db, $lock, $locksFailed;
535 553
 
536
-	if ($lock)
537
-		return true;
554
+	if ($lock) {
555
+			return true;
556
+	}
538 557
 
539 558
 	// Insert ourselves into the queue.
540 559
 	$db->query('INSERT INTO locks_queue (game_id,account_id,sector_id,timestamp) VALUES(' . $db->escapeNumber(SmrSession::getGameID()) . ',' . $db->escapeNumber(SmrSession::getAccountID()) . ',' . $db->escapeNumber($sector) . ',' . $db->escapeNumber(TIME) . ')');
@@ -560,8 +579,7 @@  discard block
 block discarded – undo
560 579
 
561 580
 			usleep(25000 * $locksInQueue);
562 581
 			continue;
563
-		}
564
-		else {
582
+		} else {
565 583
 			return true;
566 584
 		}
567 585
 	}
@@ -758,7 +776,9 @@  discard block
 block discarded – undo
758 776
 		$container['player_id'] = $player->getPlayerID();
759 777
 		$template->assign('PlayerNameLink', SmrSession::getNewHREF($container));
760 778
 
761
-		if (is_array(Globals::getHiddenPlayers()) && in_array($player->getAccountID(), Globals::getHiddenPlayers())) $template->assign('PlayerInvisible', true);
779
+		if (is_array(Globals::getHiddenPlayers()) && in_array($player->getAccountID(), Globals::getHiddenPlayers())) {
780
+			$template->assign('PlayerInvisible', true);
781
+		}
762 782
 
763 783
 		// ******* Hardware *******
764 784
 		$container = create_container('skeleton.php', 'configure_hardware.php');
@@ -898,16 +918,18 @@  discard block
 block discarded – undo
898 918
 
899 919
 function number_colour_format($number, $justSign = false) {
900 920
 	$formatted = '<span';
901
-	if ($number > 0)
902
-		$formatted .= ' class="green">+';
903
-	else if ($number < 0)
904
-		$formatted .= ' class="red">-';
905
-	else
906
-		$formatted .= '>';
921
+	if ($number > 0) {
922
+			$formatted .= ' class="green">+';
923
+	} else if ($number < 0) {
924
+			$formatted .= ' class="red">-';
925
+	} else {
926
+			$formatted .= '>';
927
+	}
907 928
 	if ($justSign === false) {
908 929
 		$decimalPlaces = 0;
909
-		if (($pos = strpos((string)$number, '.')) !== false)
910
-			$decimalPlaces = strlen(substr((string)$number, $pos + 1));
930
+		if (($pos = strpos((string)$number, '.')) !== false) {
931
+					$decimalPlaces = strlen(substr((string)$number, $pos + 1));
932
+		}
911 933
 		$formatted .= number_format(abs($number), $decimalPlaces);
912 934
 	}
913 935
 	$formatted .= '</span>';
Please login to merge, or discard this patch.