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
Pull Request — master (#808)
by Dan
09:33
created
lib/Default/AbstractSmrAccount.class.php 1 patch
Braces   +226 added lines, -165 removed lines patch added patch discarded remove patch
@@ -99,8 +99,9 @@  discard block
 block discarded – undo
99 99
 		if (empty($login)) { return null; }
100 100
 		$db = new SmrMySqlDatabase();
101 101
 		$db->query('SELECT account_id FROM account WHERE login = '.$db->escapeString($login).' LIMIT 1');
102
-		if($db->nextRecord())
103
-			return self::getAccount($db->getInt('account_id'), $forceUpdate);
102
+		if($db->nextRecord()) {
103
+					return self::getAccount($db->getInt('account_id'), $forceUpdate);
104
+		}
104 105
 		$return = null;
105 106
 		return $return;
106 107
 	}
@@ -235,10 +236,10 @@  discard block
 block discarded – undo
235 236
 			$this->template			= $row['template'];
236 237
 			$this->colourScheme		= $row['colour_scheme'];
237 238
 
238
-			if(empty($this->hofName))
239
-				$this->hofName=$this->login;
240
-		}
241
-		else {
239
+			if(empty($this->hofName)) {
240
+							$this->hofName=$this->login;
241
+			}
242
+		} else {
242 243
 			throw new AccountNotFoundException('Account ID '.$accountID.' does not exist!');
243 244
 		}
244 245
 	}
@@ -260,8 +261,7 @@  discard block
 block discarded – undo
260 261
 				'Reason' => $this->db->getField('reason'),
261 262
 				'ReasonID' => $this->db->getInt('reason_id')
262 263
 			);
263
-		}
264
-		else {
264
+		} else {
265 265
 			return false;
266 266
 		}
267 267
 	}
@@ -317,15 +317,18 @@  discard block
 block discarded – undo
317 317
 		if ($curr_ip != 'unknown' && $curr_ip != 'unknown...' && $curr_ip != 'unknown, unknown') {
318 318
 			$curr_ip = $fi.'.'.$se.'.'.$th.'.'.$fo;
319 319
 			$host = gethostbyaddr($curr_ip);
320
-		} else $host = 'unknown';
320
+		} else {
321
+			$host = 'unknown';
322
+		}
321 323
 
322 324
 		// save...first make sure there isn't one for these keys (someone could double click and get error)
323 325
 		$this->db->query('REPLACE INTO account_has_ip (account_id, time, ip, host) VALUES ('.$this->db->escapeNumber($this->account_id).', '.$this->db->escapeNumber(TIME).', '.$this->db->escapeString($curr_ip).', '.$this->db->escapeString($host).')');
324 326
 	}
325 327
 
326 328
 	public function updateLastLogin() {
327
-		if($this->last_login == TIME)
328
-			return;
329
+		if($this->last_login == TIME) {
330
+					return;
331
+		}
329 332
 		$this->last_login = TIME;
330 333
 		$this->hasChanged = true;
331 334
 		$this->update();
@@ -336,8 +339,9 @@  discard block
 block discarded – undo
336 339
 	}
337 340
 
338 341
 	public function setLoggingEnabled($bool) {
339
-		if($this->logging==$bool)
340
-			return;
342
+		if($this->logging==$bool) {
343
+					return;
344
+		}
341 345
 		$this->logging=$bool;
342 346
 		$this->hasChanged = true;
343 347
 		$this->update();
@@ -386,12 +390,14 @@  discard block
 block discarded – undo
386 390
 
387 391
 	public function getHOF(array $typeList = null) {
388 392
 		$this->getHOFData();
389
-		if($typeList==null)
390
-			return $this->HOF;
393
+		if($typeList==null) {
394
+					return $this->HOF;
395
+		}
391 396
 		$hof=$this->HOF;
392 397
 		foreach($typeList as $type) {
393
-			if(!isset($hof[$type]))
394
-				return 0;
398
+			if(!isset($hof[$type])) {
399
+							return 0;
400
+			}
395 401
 			$hof = $hof[$type];
396 402
 		}
397 403
 		return $hof;
@@ -399,10 +405,11 @@  discard block
 block discarded – undo
399 405
 
400 406
 	public function getRankName() {
401 407
 		$rankings = Globals::getUserRanking();
402
-		if(isset($rankings[$this->getRank()]))
403
-			return $rankings[$this->getRank()];
404
-		else
405
-			return end($rankings);
408
+		if(isset($rankings[$this->getRank()])) {
409
+					return $rankings[$this->getRank()];
410
+		} else {
411
+					return end($rankings);
412
+		}
406 413
 	}
407 414
 
408 415
 	public function getScore() {
@@ -418,15 +425,17 @@  discard block
 block discarded – undo
418 425
 
419 426
 	public function getIndividualScores(SmrPlayer $player = null) {
420 427
 		$gameID=0;
421
-		if($player!=null)
422
-			$gameID = $player->getGameID();
428
+		if($player!=null) {
429
+					$gameID = $player->getGameID();
430
+		}
423 431
 		if(!isset($this->individualScores[$gameID])) {
424 432
 			$this->individualScores[$gameID] = array();
425 433
 			foreach(self::USER_RANKINGS_SCORE as $statScore) {
426
-				if($player==null)
427
-					$stat = $this->getHOF($statScore[0]);
428
-				else
429
-					$stat = $player->getHOF($statScore[0]);
434
+				if($player==null) {
435
+									$stat = $this->getHOF($statScore[0]);
436
+				} else {
437
+									$stat = $player->getHOF($statScore[0]);
438
+				}
430 439
 				$this->individualScores[$gameID][]=array('Stat'=>$statScore[0],'Score'=>pow($stat*$statScore[1],self::USER_RANKINGS_EACH_STAT_POW)*$statScore[2]);
431 440
 			}
432 441
 		}
@@ -435,16 +444,19 @@  discard block
 block discarded – undo
435 444
 
436 445
 	public function getRank() : int {
437 446
 		$rank = ICeil(pow($this->getScore(),self::USER_RANKINGS_TOTAL_SCORE_POW)/self::USER_RANKINGS_RANK_BOUNDARY);
438
-		if($rank<1)
439
-			$rank=1;
440
-		if($rank > $this->maxRankAchieved)
441
-			$this->updateMaxRankAchieved($rank);
447
+		if($rank<1) {
448
+					$rank=1;
449
+		}
450
+		if($rank > $this->maxRankAchieved) {
451
+					$this->updateMaxRankAchieved($rank);
452
+		}
442 453
 		return $rank;
443 454
 	}
444 455
 
445 456
 	protected function updateMaxRankAchieved($rank) {
446
-		if($rank <= $this->maxRankAchieved)
447
-			throw new Exception('Trying to set max rank achieved to a lower value: ' . $rank);
457
+		if($rank <= $this->maxRankAchieved) {
458
+					throw new Exception('Trying to set max rank achieved to a lower value: ' . $rank);
459
+		}
448 460
 		$delta = $rank - $this->maxRankAchieved;
449 461
 		if($this->hasReferrer()) {
450 462
 			$this->getReferrer()->increaseSmrRewardCredits($delta * CREDITS_PER_DOLLAR);
@@ -491,12 +503,15 @@  discard block
 block discarded – undo
491 503
 	}
492 504
 
493 505
 	public function decreaseTotalSmrCredits($totalCredits) {
494
-		if($totalCredits==0)
495
-			return;
496
-		if($totalCredits<0)
497
-			throw new Exception('You cannot use negative total credits');
498
-		if($totalCredits>$this->getTotalSmrCredits())
499
-			throw new Exception('You do not have that many credits in total to use');
506
+		if($totalCredits==0) {
507
+					return;
508
+		}
509
+		if($totalCredits<0) {
510
+					throw new Exception('You cannot use negative total credits');
511
+		}
512
+		if($totalCredits>$this->getTotalSmrCredits()) {
513
+					throw new Exception('You do not have that many credits in total to use');
514
+		}
500 515
 
501 516
 		$rewardCredits=$this->rewardCredits;
502 517
 		$credits=$this->credits;
@@ -505,10 +520,11 @@  discard block
 block discarded – undo
505 520
 			$credits+=$rewardCredits;
506 521
 			$rewardCredits=0;
507 522
 		}
508
-		if($this->credits==0 && $this->rewardCredits==0)
509
-			$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).','.$this->db->escapeNumber($rewardCredits).')');
510
-		else
511
-			$this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).', reward_credits='.$this->db->escapeNumber($rewardCredits).' WHERE '.$this->SQL.' LIMIT 1');
523
+		if($this->credits==0 && $this->rewardCredits==0) {
524
+					$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).','.$this->db->escapeNumber($rewardCredits).')');
525
+		} else {
526
+					$this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).', reward_credits='.$this->db->escapeNumber($rewardCredits).' WHERE '.$this->SQL.' LIMIT 1');
527
+		}
512 528
 		$this->credits=$credits;
513 529
 		$this->rewardCredits=$rewardCredits;
514 530
 	}
@@ -524,48 +540,59 @@  discard block
 block discarded – undo
524 540
 	}
525 541
 
526 542
 	public function setSmrCredits($credits) {
527
-		if($this->getSmrCredits()==$credits)
528
-			return;
529
-		if($this->credits==0 && $this->rewardCredits==0)
530
-			$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')');
531
-		else
532
-			$this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1');
543
+		if($this->getSmrCredits()==$credits) {
544
+					return;
545
+		}
546
+		if($this->credits==0 && $this->rewardCredits==0) {
547
+					$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')');
548
+		} else {
549
+					$this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1');
550
+		}
533 551
 		$this->credits=$credits;
534 552
 	}
535 553
 
536 554
 	public function increaseSmrCredits($credits) {
537
-		if($credits==0)
538
-			return;
539
-		if($credits<0)
540
-			throw new Exception('You cannot gain negative credits');
555
+		if($credits==0) {
556
+					return;
557
+		}
558
+		if($credits<0) {
559
+					throw new Exception('You cannot gain negative credits');
560
+		}
541 561
 		$this->setSmrCredits($this->getSmrCredits()+$credits);
542 562
 	}
543 563
 
544 564
 	public function decreaseSmrCredits($credits) {
545
-		if($credits==0)
546
-			return;
547
-		if($credits<0)
548
-			throw new Exception('You cannot use negative credits');
549
-		if($credits>$this->getSmrCredits())
550
-			throw new Exception('You cannot use more credits than you have');
565
+		if($credits==0) {
566
+					return;
567
+		}
568
+		if($credits<0) {
569
+					throw new Exception('You cannot use negative credits');
570
+		}
571
+		if($credits>$this->getSmrCredits()) {
572
+					throw new Exception('You cannot use more credits than you have');
573
+		}
551 574
 		$this->setSmrCredits($this->getSmrCredits()-$credits);
552 575
 	}
553 576
 
554 577
 	public function setSmrRewardCredits($credits) {
555
-		if($this->getSmrRewardCredits()==$credits)
556
-			return;
557
-		if($this->credits==0 && $this->rewardCredits==0)
558
-			$this->db->query('REPLACE INTO account_has_credits (account_id, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')');
559
-		else
560
-			$this->db->query('UPDATE account_has_credits SET reward_credits='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1');
578
+		if($this->getSmrRewardCredits()==$credits) {
579
+					return;
580
+		}
581
+		if($this->credits==0 && $this->rewardCredits==0) {
582
+					$this->db->query('REPLACE INTO account_has_credits (account_id, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')');
583
+		} else {
584
+					$this->db->query('UPDATE account_has_credits SET reward_credits='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1');
585
+		}
561 586
 		$this->rewardCredits=$credits;
562 587
 	}
563 588
 
564 589
 	public function increaseSmrRewardCredits($credits) {
565
-		if($credits==0)
566
-			return;
567
-		if($credits<0)
568
-			throw new Exception('You cannot gain negative reward credits');
590
+		if($credits==0) {
591
+					return;
592
+		}
593
+		if($credits<0) {
594
+					throw new Exception('You cannot gain negative reward credits');
595
+		}
569 596
 		$this->setSmrRewardCredits($this->getSmrRewardCredits()+$credits);
570 597
 	}
571 598
 
@@ -601,8 +628,9 @@  discard block
 block discarded – undo
601 628
 	}
602 629
 
603 630
 	public function hasOldAccountID($dbName=false) {
604
-		if($dbName===false)
605
-			return count($this->getOldAccountIDs())!=0;
631
+		if($dbName===false) {
632
+					return count($this->getOldAccountIDs())!=0;
633
+		}
606 634
 		return $this->getOldAccountID($dbName)!=0;
607 635
 	}
608 636
 
@@ -681,8 +709,9 @@  discard block
 block discarded – undo
681 709
 	}
682 710
 
683 711
 	public function setFontSize($size) {
684
-		if($this->fontSize==$size)
685
-			return;
712
+		if($this->fontSize==$size) {
713
+					return;
714
+		}
686 715
 		$this->fontSize = $size;
687 716
 		$this->hasChanged = true;
688 717
 		$this->update();
@@ -695,8 +724,9 @@  discard block
 block discarded – undo
695 724
 
696 725
 	// sets the extra CSS file linked in preferences
697 726
 	public function setCssLink($link) {
698
-		if($this->cssLink==$link)
699
-			return;
727
+		if($this->cssLink==$link) {
728
+					return;
729
+		}
700 730
 		$this->cssLink = $link;
701 731
 		$this->hasChanged = true;
702 732
 		$this->update();
@@ -707,10 +737,12 @@  discard block
 block discarded – undo
707 737
 	}
708 738
 
709 739
 	public function setTemplate($template) {
710
-		if($this->template==$template)
711
-			return;
712
-		if(!in_array($template,array_keys(Globals::getAvailableTemplates())))
713
-			throw new Exception('Template not allowed: '.$template);
740
+		if($this->template==$template) {
741
+					return;
742
+		}
743
+		if(!in_array($template,array_keys(Globals::getAvailableTemplates()))) {
744
+					throw new Exception('Template not allowed: '.$template);
745
+		}
714 746
 		$this->db->query('UPDATE account SET template = ' . $this->db->escapeString($template) . ' WHERE '.$this->SQL.' LIMIT 1');
715 747
 		$this->template = $template;
716 748
 		$colourSchemes = Globals::getAvailableColourSchemes($template);
@@ -722,10 +754,12 @@  discard block
 block discarded – undo
722 754
 	}
723 755
 
724 756
 	public function setColourScheme($colourScheme) {
725
-		if($this->colourScheme==$colourScheme)
726
-			return;
727
-		if(!in_array($colourScheme,array_keys(Globals::getAvailableColourSchemes($this->getTemplate()))))
728
-			throw new Exception('Colour scheme not allowed: '.$colourScheme);
757
+		if($this->colourScheme==$colourScheme) {
758
+					return;
759
+		}
760
+		if(!in_array($colourScheme,array_keys(Globals::getAvailableColourSchemes($this->getTemplate())))) {
761
+					throw new Exception('Colour scheme not allowed: '.$colourScheme);
762
+		}
729 763
 		$this->colourScheme = $colourScheme;
730 764
 		$this->hasChanged = true;
731 765
 		$this->update();
@@ -759,8 +793,9 @@  discard block
 block discarded – undo
759 793
 	}
760 794
 
761 795
 	public function setHofName($name) {
762
-		if($this->hofName==$name)
763
-			return;
796
+		if($this->hofName==$name) {
797
+					return;
798
+		}
764 799
 		$this->hofName = $name;
765 800
 		$this->hasChanged = true;
766 801
 		$this->update();
@@ -771,8 +806,9 @@  discard block
 block discarded – undo
771 806
 	}
772 807
 
773 808
 	public function setIrcNick($nick) {
774
-		if($this->ircNick==$nick)
775
-			return;
809
+		if($this->ircNick==$nick) {
810
+					return;
811
+		}
776 812
 		$this->ircNick = $nick;
777 813
 		$this->hasChanged = true;
778 814
 		$this->update();
@@ -800,8 +836,9 @@  discard block
 block discarded – undo
800 836
 	}
801 837
 
802 838
 	public function setShortDateFormat($format) {
803
-		if($this->dateShort==$format)
804
-			return;
839
+		if($this->dateShort==$format) {
840
+					return;
841
+		}
805 842
 		$this->dateShort = $format;
806 843
 		$this->hasChanged = true;
807 844
 		$this->update();
@@ -812,8 +849,9 @@  discard block
 block discarded – undo
812 849
 	}
813 850
 
814 851
 	public function setShortTimeFormat($format) {
815
-		if($this->timeShort==$format)
816
-			return;
852
+		if($this->timeShort==$format) {
853
+					return;
854
+		}
817 855
 		$this->timeShort = $format;
818 856
 		$this->hasChanged = true;
819 857
 		$this->update();
@@ -824,16 +862,18 @@  discard block
 block discarded – undo
824 862
 	}
825 863
 
826 864
 	protected function setValidationCode($code) {
827
-		if($this->validation_code == $code)
828
-			return;
865
+		if($this->validation_code == $code) {
866
+					return;
867
+		}
829 868
 		$this->validation_code=$code;
830 869
 		$this->hasChanged=true;
831 870
 		$this->update();
832 871
 	}
833 872
 
834 873
 	public function setValidated($bool) {
835
-		if($this->validated == $bool)
836
-			return;
874
+		if($this->validated == $bool) {
875
+					return;
876
+		}
837 877
 		$this->validated = $bool;
838 878
 		$this->hasChanged = true;
839 879
 		$this->update();
@@ -906,8 +946,9 @@  discard block
 block discarded – undo
906 946
 	}
907 947
 
908 948
 	protected function setPasswordReset($passwordReset) {
909
-		if($this->passwordReset == $passwordReset)
910
-			return;
949
+		if($this->passwordReset == $passwordReset) {
950
+					return;
951
+		}
911 952
 		$this->passwordReset=$passwordReset;
912 953
 		$this->hasChanged=true;
913 954
 		$this->update();
@@ -918,8 +959,9 @@  discard block
 block discarded – undo
918 959
 	}
919 960
 
920 961
 	public function setDisplayShipImages($yesNo) {
921
-		if($this->images == $yesNo)
922
-			return;
962
+		if($this->images == $yesNo) {
963
+					return;
964
+		}
923 965
 		$this->images = $yesNo;
924 966
 		$this->hasChanged = true;
925 967
 		$this->update();
@@ -930,8 +972,9 @@  discard block
 block discarded – undo
930 972
 	}
931 973
 
932 974
 	public function setUseAJAX($bool) {
933
-		if($this->useAJAX == $bool)
934
-			return;
975
+		if($this->useAJAX == $bool) {
976
+					return;
977
+		}
935 978
 		$this->useAJAX=$bool;
936 979
 		$this->hasChanged=true;
937 980
 		$this->update();
@@ -942,8 +985,9 @@  discard block
 block discarded – undo
942 985
 	}
943 986
 
944 987
 	public function setDefaultCSSEnabled($bool) {
945
-		if($this->defaultCSSEnabled == $bool)
946
-			return;
988
+		if($this->defaultCSSEnabled == $bool) {
989
+					return;
990
+		}
947 991
 		$this->defaultCSSEnabled=$bool;
948 992
 		$this->hasChanged=true;
949 993
 		$this->update();
@@ -953,8 +997,7 @@  discard block
 block discarded – undo
953 997
 		if($hotkeyType!==false) {
954 998
 			if(isset($this->hotkeys[$hotkeyType])) {
955 999
 				return $this->hotkeys[$hotkeyType];
956
-			}
957
-			else {
1000
+			} else {
958 1001
 				return array();
959 1002
 			}
960 1003
 		}
@@ -962,8 +1005,9 @@  discard block
 block discarded – undo
962 1005
 	}
963 1006
 
964 1007
 	public function setHotkey($hotkeyType,$binding) {
965
-		if($this->getHotkeys($hotkeyType) == $binding)
966
-			return;
1008
+		if($this->getHotkeys($hotkeyType) == $binding) {
1009
+					return;
1010
+		}
967 1011
 		$this->hotkeys[$hotkeyType] = $binding;
968 1012
 		$this->hasChanged=true;
969 1013
 		$this->update();
@@ -978,26 +1022,31 @@  discard block
 block discarded – undo
978 1022
 	}
979 1023
 
980 1024
 	public function setMessageNotifications($messageTypeID,$num) {
981
-		if($this->getMessageNotifications($messageTypeID) == $num)
982
-			return;
1025
+		if($this->getMessageNotifications($messageTypeID) == $num) {
1026
+					return;
1027
+		}
983 1028
 		$this->messageNotifications[$messageTypeID]=$num;
984 1029
 		$this->hasChanged=true;
985 1030
 		$this->update();
986 1031
 	}
987 1032
 
988 1033
 	public function increaseMessageNotifications($messageTypeID,$num) {
989
-		if($num==0)
990
-			return;
991
-		if($num<0)
992
-			throw new Exception('You cannot increase by a negative amount');
1034
+		if($num==0) {
1035
+					return;
1036
+		}
1037
+		if($num<0) {
1038
+					throw new Exception('You cannot increase by a negative amount');
1039
+		}
993 1040
 		$this->setMessageNotifications($messageTypeID, $this->getMessageNotifications($messageTypeID) + $num);
994 1041
 	}
995 1042
 
996 1043
 	public function decreaseMessageNotifications($messageTypeID,$num) {
997
-		if($num==0)
998
-			return;
999
-		if($num<0)
1000
-			throw new Exception('You cannot decrease by a negative amount');
1044
+		if($num==0) {
1045
+					return;
1046
+		}
1047
+		if($num<0) {
1048
+					throw new Exception('You cannot decrease by a negative amount');
1049
+		}
1001 1050
 		$this->setMessageNotifications($messageTypeID, $this->getMessageNotifications($messageTypeID) - $num);
1002 1051
 	}
1003 1052
 
@@ -1006,8 +1055,9 @@  discard block
 block discarded – undo
1006 1055
 	}
1007 1056
 
1008 1057
 	public function setCenterGalaxyMapOnPlayer($bool) {
1009
-		if($this->centerGalaxyMapOnPlayer == $bool)
1010
-			return;
1058
+		if($this->centerGalaxyMapOnPlayer == $bool) {
1059
+					return;
1060
+		}
1011 1061
 		$this->centerGalaxyMapOnPlayer=$bool;
1012 1062
 		$this->hasChanged=true;
1013 1063
 		$this->update();
@@ -1022,8 +1072,9 @@  discard block
 block discarded – undo
1022 1072
 	}
1023 1073
 
1024 1074
 	public function setMailBanned($time) {
1025
-		if($this->mailBanned == $time)
1026
-			return;
1075
+		if($this->mailBanned == $time) {
1076
+					return;
1077
+		}
1027 1078
 		$this->mailBanned=$time;
1028 1079
 		$this->hasChanged=true;
1029 1080
 	}
@@ -1077,53 +1128,59 @@  discard block
 block discarded – undo
1077 1128
 
1078 1129
 	public function setPoints($numPoints,$lastUpdate=false) {
1079 1130
 		$numPoints = max($numPoints,0);
1080
-		if($this->getPoints()==$numPoints)
1081
-			return;
1082
-		if ($this->points==0)
1083
-			$this->db->query('INSERT INTO account_has_points (account_id, points, last_update) VALUES ('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($numPoints).', '.$this->db->escapeNumber($lastUpdate?$lastUpdate:TIME).')');
1084
-		else if($numPoints<=0)
1085
-			$this->db->query('DELETE FROM account_has_points WHERE '.$this->SQL.' LIMIT 1');
1086
-		else
1087
-			$this->db->query('UPDATE account_has_points SET points = '.$this->db->escapeNumber($numPoints).($lastUpdate ? ', last_update = '.$this->db->escapeNumber(TIME) : '').' WHERE '.$this->SQL.' LIMIT 1');
1131
+		if($this->getPoints()==$numPoints) {
1132
+					return;
1133
+		}
1134
+		if ($this->points==0) {
1135
+					$this->db->query('INSERT INTO account_has_points (account_id, points, last_update) VALUES ('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($numPoints).', '.$this->db->escapeNumber($lastUpdate?$lastUpdate:TIME).')');
1136
+		} else if($numPoints<=0) {
1137
+					$this->db->query('DELETE FROM account_has_points WHERE '.$this->SQL.' LIMIT 1');
1138
+		} else {
1139
+					$this->db->query('UPDATE account_has_points SET points = '.$this->db->escapeNumber($numPoints).($lastUpdate ? ', last_update = '.$this->db->escapeNumber(TIME) : '').' WHERE '.$this->SQL.' LIMIT 1');
1140
+		}
1088 1141
 		$this->points=$numPoints;
1089 1142
 	}
1090 1143
 
1091 1144
 	public function removePoints($numPoints,$lastUpdate=false) {
1092
-		if($numPoints>0)
1093
-			$this->setPoints($this->getPoints()-$numPoints,$lastUpdate);
1145
+		if($numPoints>0) {
1146
+					$this->setPoints($this->getPoints()-$numPoints,$lastUpdate);
1147
+		}
1094 1148
 	}
1095 1149
 
1096 1150
 	public function addPoints($numPoints,SmrAccount $admin,$reasonID,$suspicion) {
1097 1151
 		//do we have points
1098 1152
 		$this->setPoints($this->getPoints() + $numPoints,TIME);
1099 1153
 		$totalPoints = $this->getPoints();
1100
-		if ($totalPoints < 10)
1101
-			return false;//leave scripts its only a warning
1102
-		elseif ($totalPoints < 20)
1103
-			$days = 2;
1104
-		elseif ($totalPoints < 30)
1105
-			$days = 4;
1106
-		elseif ($totalPoints < 50)
1107
-			$days = 7;
1108
-		elseif ($totalPoints < 75)
1109
-			$days = 15 ;
1110
-		elseif ($totalPoints < 100)
1111
-			$days = 30;
1112
-		elseif ($totalPoints < 125)
1113
-			$days = 60;
1114
-		elseif ($totalPoints < 150)
1115
-			$days = 120;
1116
-		elseif ($totalPoints < 175)
1117
-			$days = 240;
1118
-		elseif ($totalPoints < 200)
1119
-			$days = 480;
1120
-		else
1121
-			$days = 0; //Forever/indefinite
1154
+		if ($totalPoints < 10) {
1155
+					return false;
1156
+		}
1157
+		//leave scripts its only a warning
1158
+		elseif ($totalPoints < 20) {
1159
+					$days = 2;
1160
+		} elseif ($totalPoints < 30) {
1161
+					$days = 4;
1162
+		} elseif ($totalPoints < 50) {
1163
+					$days = 7;
1164
+		} elseif ($totalPoints < 75) {
1165
+					$days = 15 ;
1166
+		} elseif ($totalPoints < 100) {
1167
+					$days = 30;
1168
+		} elseif ($totalPoints < 125) {
1169
+					$days = 60;
1170
+		} elseif ($totalPoints < 150) {
1171
+					$days = 120;
1172
+		} elseif ($totalPoints < 175) {
1173
+					$days = 240;
1174
+		} elseif ($totalPoints < 200) {
1175
+					$days = 480;
1176
+		} else {
1177
+					$days = 0;
1178
+		}
1179
+		//Forever/indefinite
1122 1180
 
1123 1181
 		if($days==0) {
1124 1182
 			$expireTime = 0;
1125
-		}
1126
-		else {
1183
+		} else {
1127 1184
 			$expireTime = TIME + $days * 86400;
1128 1185
 		}
1129 1186
 		$this->banAccount($expireTime,$admin,$reasonID,$suspicion);
@@ -1178,26 +1235,30 @@  discard block
 block discarded – undo
1178 1235
 			$player->update();
1179 1236
 		}
1180 1237
 		$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account closed by ' . $admin->getLogin() . '.');
1181
-		if($removeExceptions!==false)
1182
-			$this->db->query('DELETE FROM account_exceptions WHERE ' . $this->SQL);
1238
+		if($removeExceptions!==false) {
1239
+					$this->db->query('DELETE FROM account_exceptions WHERE ' . $this->SQL);
1240
+		}
1183 1241
 	}
1184 1242
 
1185 1243
 	public function unbanAccount(SmrAccount $admin = null,$currException=false) {
1186 1244
 		$adminID = 0;
1187
-		if($admin!==null)
1188
-			$adminID = $admin->getAccountID();
1245
+		if($admin!==null) {
1246
+					$adminID = $admin->getAccountID();
1247
+		}
1189 1248
 		$this->db->query('DELETE FROM account_is_closed WHERE ' . $this->SQL . ' LIMIT 1');
1190 1249
 		$this->db->query('INSERT INTO account_has_closing_history
1191 1250
 						(account_id, time, admin_id, action)
1192 1251
 						VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber(TIME) . ', ' . $this->db->escapeNumber($adminID) . ', ' . $this->db->escapeString('Opened') . ')');
1193 1252
 		$this->db->query('UPDATE player SET last_turn_update = GREATEST(' . $this->db->escapeNumber(TIME) . ', last_turn_update) WHERE ' . $this->SQL);
1194
-		if($admin!==null)
1195
-			$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account reopened by ' . $admin->getLogin() . '.');
1196
-		else
1197
-			$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account automatically reopened.');
1198
-		if($currException!==false)
1199
-			$this->db->query('REPLACE INTO account_exceptions (account_id, reason)
1253
+		if($admin!==null) {
1254
+					$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account reopened by ' . $admin->getLogin() . '.');
1255
+		} else {
1256
+					$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account automatically reopened.');
1257
+		}
1258
+		if($currException!==false) {
1259
+					$this->db->query('REPLACE INTO account_exceptions (account_id, reason)
1200 1260
 							VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeString($currException) . ')');
1261
+		}
1201 1262
 	}
1202 1263
 
1203 1264
 	public function getToggleAJAXHREF() {
Please login to merge, or discard this patch.
lib/Default/SmrWeapon.class.php 1 patch
Braces   +20 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,17 +12,19 @@  discard block
 block discarded – undo
12 12
 
13 13
 	
14 14
 	protected static function initialiseDatabase() {
15
-		if (self::$db == null)
16
-			self::$db = new SmrMySqlDatabase();
15
+		if (self::$db == null) {
16
+					self::$db = new SmrMySqlDatabase();
17
+		}
17 18
 	}
18 19
 
19 20
 	public static function getWeapon($weaponTypeID, $forceUpdate = false, $db = null) {
20 21
 		if ($forceUpdate || !isset(self::$CACHE_WEAPONS[$weaponTypeID])) {
21 22
 			$w = new SmrWeapon($weaponTypeID, $db);
22
-			if ($w->exists())
23
-				self::$CACHE_WEAPONS[$weaponTypeID] = $w;
24
-			else
25
-				self::$CACHE_WEAPONS[$weaponTypeID] = false;
23
+			if ($w->exists()) {
24
+							self::$CACHE_WEAPONS[$weaponTypeID] = $w;
25
+			} else {
26
+							self::$CACHE_WEAPONS[$weaponTypeID] = false;
27
+			}
26 28
 		}
27 29
 		return self::$CACHE_WEAPONS[$weaponTypeID];
28 30
 	}
@@ -151,8 +153,9 @@  discard block
 block discarded – undo
151 153
 		$weaponShip = $weaponPlayer->getShip();
152 154
 		$targetShip = $targetPlayer->getShip();
153 155
 		$mrDiff = $targetShip->getMR() - $weaponShip->getMR();
154
-		if ($mrDiff > 0)
155
-			$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100;
156
+		if ($mrDiff > 0) {
157
+					$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100;
158
+		}
156 159
 	
157 160
 		return $modifiedAccuracy;
158 161
 	}
@@ -190,22 +193,28 @@  discard block
 block discarded – undo
190 193
 	}
191 194
 	
192 195
 	public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
193
-		if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
196
+		if (!$this->canShootForces()) {
197
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
194 198
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
199
+		}
195 200
 		$damage =& $this->getModifiedDamage();
196 201
 		return $damage;
197 202
 	}
198 203
 	
199 204
 	public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
200
-		if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
205
+		if (!$this->canShootPorts()) {
206
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
201 207
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
208
+		}
202 209
 		$damage =& $this->getModifiedDamage();
203 210
 		return $damage;
204 211
 	}
205 212
 	
206 213
 	public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) {
207
-		if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
214
+		if (!$this->canShootPlanets()) {
215
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
208 216
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
217
+		}
209 218
 		$damage =& $this->getModifiedDamage();
210 219
 		
211 220
 		$planetMod = self::PLANET_DAMAGE_MOD;
Please login to merge, or discard this patch.
lib/Default/AbstractSmrShip.class.php 1 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
 	}
@@ -168,10 +169,11 @@  discard block
 block discarded – undo
168 169
 
169 170
 	public function checkForExcessHardware() {
170 171
 		//check hardware to see if anything needs to be removed
171
-		if (is_array($hardware = $this->getHardware()))
172
-			foreach ($hardware as $hardwareTypeID => $amount) {
172
+		if (is_array($hardware = $this->getHardware())) {
173
+					foreach ($hardware as $hardwareTypeID => $amount) {
173 174
 				if ($amount > ($max = $this->getMaxHardware($hardwareTypeID))) {
174 175
 					$this->setHardware($hardwareTypeID, $max, true);
176
+		}
175 177
 				}
176 178
 			}
177 179
 	}
@@ -188,9 +190,10 @@  discard block
 block discarded – undo
188 190
 
189 191
 	public function getPowerUsed() {
190 192
 		$power = 0;
191
-		if ($this->getNumWeapons() > 0)
192
-			foreach ($this->weapons as $weapon)
193
+		if ($this->getNumWeapons() > 0) {
194
+					foreach ($this->weapons as $weapon)
193 195
 				$power += $weapon->getPowerLevel();
196
+		}
194 197
 		return $power;
195 198
 	}
196 199
 
@@ -211,17 +214,19 @@  discard block
 block discarded – undo
211 214
 	}
212 215
 
213 216
 	public function getDisplayAttackRating(AbstractSmrPlayer $player) {
214
-		if ($this->hasActiveIllusion())
215
-			return $this->getIllusionAttack();
216
-		else
217
-			return $this->getAttackRating();
217
+		if ($this->hasActiveIllusion()) {
218
+					return $this->getIllusionAttack();
219
+		} else {
220
+					return $this->getAttackRating();
221
+		}
218 222
 	}
219 223
 
220 224
 	public function getDisplayDefenseRating() {
221
-		if ($this->hasActiveIllusion())
222
-			return $this->getIllusionDefense();
223
-		else
224
-			return $this->getDefenseRating();
225
+		if ($this->hasActiveIllusion()) {
226
+					return $this->getIllusionDefense();
227
+		} else {
228
+					return $this->getDefenseRating();
229
+		}
225 230
 	}
226 231
 
227 232
 	public function getAttackRating() : int {
@@ -267,8 +272,7 @@  discard block
 block discarded – undo
267 272
 		if ($replacement < 0) {
268 273
 			// Shift everything up by one and put the selected weapon at the bottom
269 274
 			array_push($this->weapons, array_shift($this->weapons));
270
-		}
271
-		else {
275
+		} else {
272 276
 			// Swap the selected weapon with the one above it
273 277
 			$temp = $this->weapons[$replacement];
274 278
 			$this->weapons[$replacement] = $this->weapons[$orderID];
@@ -282,8 +286,7 @@  discard block
 block discarded – undo
282 286
 		if ($replacement >= count($this->weapons)) {
283 287
 			// Shift everything down by one and put the selected weapon at the top
284 288
 			array_unshift($this->weapons, array_pop($this->weapons));
285
-		}
286
-		else {
289
+		} else {
287 290
 			// Swap the selected weapon with the one below it
288 291
 			$temp = $this->weapons[$replacement];
289 292
 			$this->weapons[$replacement] = $this->weapons[$orderID];
@@ -342,8 +345,7 @@  discard block
 block discarded – undo
342 345
 			$this->setArmour(150, true);
343 346
 			$this->setCargoHolds(40);
344 347
 			$this->setShipTypeID(SHIP_TYPE_NEWBIE_MERCHANT_VESSEL);
345
-		}
346
-		else {
348
+		} else {
347 349
 			$this->setShields(50, true);
348 350
 			$this->setArmour(50, true);
349 351
 			$this->setCargoHolds(5);
@@ -363,8 +365,9 @@  discard block
 block discarded – undo
363 365
 
364 366
 
365 367
 	public function hasActiveIllusion() {
366
-		if (!$this->hasIllusion())
367
-			return false;
368
+		if (!$this->hasIllusion()) {
369
+					return false;
370
+		}
368 371
 		return $this->getIllusionShip() !== false;
369 372
 
370 373
 	}
@@ -498,14 +501,16 @@  discard block
 block discarded – undo
498 501
 	}
499 502
 
500 503
 	public function getHardware($hardwareTypeID = false) {
501
-		if ($hardwareTypeID === false)
502
-			return $this->hardware;
504
+		if ($hardwareTypeID === false) {
505
+					return $this->hardware;
506
+		}
503 507
 		return isset($this->hardware[$hardwareTypeID]) ? $this->hardware[$hardwareTypeID] : 0;
504 508
 	}
505 509
 
506 510
 	public function setHardware($hardwareTypeID, $amount) {
507
-		if ($this->getHardware($hardwareTypeID) == $amount)
508
-			return;
511
+		if ($this->getHardware($hardwareTypeID) == $amount) {
512
+					return;
513
+		}
509 514
 		$this->hardware[$hardwareTypeID] = $amount;
510 515
 		$this->hasChangedHardware[$hardwareTypeID] = true;
511 516
 	}
@@ -515,14 +520,16 @@  discard block
 block discarded – undo
515 520
 	}
516 521
 
517 522
 	public function getOldHardware($hardwareTypeID = false) {
518
-		if ($hardwareTypeID === false)
519
-			return $this->oldHardware;
523
+		if ($hardwareTypeID === false) {
524
+					return $this->oldHardware;
525
+		}
520 526
 		return isset($this->oldHardware[$hardwareTypeID]) ? $this->oldHardware[$hardwareTypeID] : 0;
521 527
 	}
522 528
 
523 529
 	public function setOldHardware($hardwareTypeID, $amount) {
524
-		if ($this->getOldHardware($hardwareTypeID) == $amount)
525
-			return;
530
+		if ($this->getOldHardware($hardwareTypeID) == $amount) {
531
+					return;
532
+		}
526 533
 		$this->oldHardware[$hardwareTypeID] = $amount;
527 534
 		$this->hasChangedHardware[$hardwareTypeID] = true;
528 535
 	}
@@ -532,8 +539,9 @@  discard block
 block discarded – undo
532 539
 	}
533 540
 
534 541
 	public function getMaxHardware($hardwareTypeID = false) {
535
-		if ($hardwareTypeID === false)
536
-			return $this->baseShip['MaxHardware'];
542
+		if ($hardwareTypeID === false) {
543
+					return $this->baseShip['MaxHardware'];
544
+		}
537 545
 		return $this->baseShip['MaxHardware'][$hardwareTypeID];
538 546
 	}
539 547
 
@@ -542,8 +550,9 @@  discard block
 block discarded – undo
542 550
 	}
543 551
 
544 552
 	public function setShields($amount, $updateOldAmount = false) {
545
-		if ($updateOldAmount && !$this->hasLostShields())
546
-			$this->setOldHardware(HARDWARE_SHIELDS, $amount);
553
+		if ($updateOldAmount && !$this->hasLostShields()) {
554
+					$this->setOldHardware(HARDWARE_SHIELDS, $amount);
555
+		}
547 556
 		$this->setHardware(HARDWARE_SHIELDS, $amount);
548 557
 	}
549 558
 
@@ -584,8 +593,9 @@  discard block
 block discarded – undo
584 593
 	}
585 594
 
586 595
 	public function setArmour($amount, $updateOldAmount = false) {
587
-		if ($updateOldAmount && !$this->hasLostArmour())
588
-			$this->setOldHardware(HARDWARE_ARMOUR, $amount);
596
+		if ($updateOldAmount && !$this->hasLostArmour()) {
597
+					$this->setOldHardware(HARDWARE_ARMOUR, $amount);
598
+		}
589 599
 		$this->setHardware(HARDWARE_ARMOUR, $amount);
590 600
 	}
591 601
 
@@ -654,8 +664,9 @@  discard block
 block discarded – undo
654 664
 	}
655 665
 
656 666
 	public function setCDs($amount, $updateOldAmount = false) {
657
-		if ($updateOldAmount && !$this->hasLostCDs())
658
-			$this->setOldHardware(HARDWARE_COMBAT, $amount);
667
+		if ($updateOldAmount && !$this->hasLostCDs()) {
668
+					$this->setOldHardware(HARDWARE_COMBAT, $amount);
669
+		}
659 670
 		$this->setHardware(HARDWARE_COMBAT, $amount);
660 671
 	}
661 672
 
@@ -737,8 +748,9 @@  discard block
 block discarded – undo
737 748
 
738 749
 	public function getCargo($goodID = false) {
739 750
 		if ($goodID !== false) {
740
-			if (isset($this->cargo[$goodID]))
741
-				return $this->cargo[$goodID];
751
+			if (isset($this->cargo[$goodID])) {
752
+							return $this->cargo[$goodID];
753
+			}
742 754
 			$cargo = 0;
743 755
 			return $cargo;
744 756
 		}
@@ -746,16 +758,19 @@  discard block
 block discarded – undo
746 758
 	}
747 759
 
748 760
 	public function hasCargo($goodID = false) {
749
-		if ($goodID !== false)
750
-			return $this->getCargo($goodID) > 0;
751
-		if (is_array($cargo = $this->getCargo()))
752
-			return array_sum($cargo) > 0;
761
+		if ($goodID !== false) {
762
+					return $this->getCargo($goodID) > 0;
763
+		}
764
+		if (is_array($cargo = $this->getCargo())) {
765
+					return array_sum($cargo) > 0;
766
+		}
753 767
 		return false;
754 768
 	}
755 769
 
756 770
 	public function setCargo($goodID, $amount) {
757
-		if ($this->getCargo($goodID) == $amount)
758
-			return;
771
+		if ($this->getCargo($goodID) == $amount) {
772
+					return;
773
+		}
759 774
 		$this->cargo[$goodID] = $amount;
760 775
 		$this->hasChangedCargo = true;
761 776
 		// Sort cargo by goodID to make sure it shows up in the correct order
@@ -764,14 +779,16 @@  discard block
 block discarded – undo
764 779
 	}
765 780
 
766 781
 	public function decreaseCargo($goodID, $amount) {
767
-		if ($amount < 0)
768
-			throw new Exception('Trying to decrease negative cargo.');
782
+		if ($amount < 0) {
783
+					throw new Exception('Trying to decrease negative cargo.');
784
+		}
769 785
 		$this->setCargo($goodID, $this->getCargo($goodID) - $amount);
770 786
 	}
771 787
 
772 788
 	public function increaseCargo($goodID, $amount) {
773
-		if ($amount < 0)
774
-			throw new Exception('Trying to increase negative cargo.');
789
+		if ($amount < 0) {
790
+					throw new Exception('Trying to increase negative cargo.');
791
+		}
775 792
 		$this->setCargo($goodID, $this->getCargo($goodID) + $amount);
776 793
 	}
777 794
 
@@ -801,8 +818,9 @@  discard block
 block discarded – undo
801 818
 		$this->setOldShields($this->getShields());
802 819
 		$this->setOldCDs($this->getCDs());
803 820
 		$this->setOldArmour($this->getArmour());
804
-		if (isset($var['UnderAttack']))
805
-			return $var['UnderAttack'];
821
+		if (isset($var['UnderAttack'])) {
822
+					return $var['UnderAttack'];
823
+		}
806 824
 		if ($underAttack && !USING_AJAX) {
807 825
 			SmrSession::updateVar('UnderAttack', $underAttack); //Remember we are under attack for AJAX
808 826
 		}
@@ -881,8 +899,9 @@  discard block
 block discarded – undo
881 899
 		$results['DeadBeforeShot'] = false;
882 900
 		foreach ($this->weapons as $orderID => $weapon) {
883 901
 			$results['Weapons'][$orderID] =& $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
884
-			if ($results['Weapons'][$orderID]['Hit'])
885
-				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
902
+			if ($results['Weapons'][$orderID]['Hit']) {
903
+							$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
904
+			}
886 905
 		}
887 906
 		if ($this->hasCDs()) {
888 907
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
@@ -944,8 +963,9 @@  discard block
 block discarded – undo
944 963
 		$results['DeadBeforeShot'] = false;
945 964
 		foreach ($this->weapons as $orderID => $weapon) {
946 965
 			$results['Weapons'][$orderID] =& $weapon->shootPort($thisPlayer, $port);
947
-			if ($results['Weapons'][$orderID]['Hit'])
948
-				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
966
+			if ($results['Weapons'][$orderID]['Hit']) {
967
+							$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
968
+			}
949 969
 		}
950 970
 		if ($this->hasCDs()) {
951 971
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
@@ -981,8 +1001,9 @@  discard block
 block discarded – undo
981 1001
 		$results['DeadBeforeShot'] = false;
982 1002
 		foreach ($this->weapons as $orderID => $weapon) {
983 1003
 			$results['Weapons'][$orderID] =& $weapon->shootPlanet($thisPlayer, $planet, $delayed);
984
-			if ($results['Weapons'][$orderID]['Hit'])
985
-				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
1004
+			if ($results['Weapons'][$orderID]['Hit']) {
1005
+							$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
1006
+			}
986 1007
 		}
987 1008
 		if ($this->hasCDs()) {
988 1009
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
@@ -1007,8 +1028,9 @@  discard block
 block discarded – undo
1007 1028
 				$cdDamage = $this->doCDDamage(min($damage['MaxDamage'], $damage['Armour']));
1008 1029
 				$damage['Armour'] -= $cdDamage;
1009 1030
 				$damage['MaxDamage'] -= $cdDamage;
1010
-				if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover']))
1011
-					$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour']));
1031
+				if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) {
1032
+									$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour']));
1033
+				}
1012 1034
 			}
1013 1035
 		}
1014 1036
 		$return = array(
Please login to merge, or discard this patch.
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
@@ -447,11 +427,13 @@  discard block
 block discarded – undo
447 427
 }
448 428
 
449 429
 function canWeUNO(AbstractSmrPlayer $player, $oppurtunisticOnly) {
450
-	if ($player->getCredits() < MINUMUM_RESERVE_CREDITS)
451
-		return false;
430
+	if ($player->getCredits() < MINUMUM_RESERVE_CREDITS) {
431
+			return false;
432
+	}
452 433
 	$ship = $player->getShip();
453
-	if ($ship->hasMaxShields() && $ship->hasMaxArmour() && $ship->hasMaxCargoHolds())
454
-		return false;
434
+	if ($ship->hasMaxShields() && $ship->hasMaxArmour() && $ship->hasMaxCargoHolds()) {
435
+			return false;
436
+	}
455 437
 	$sector = $player->getSector();
456 438
 
457 439
 	// We buy armour in preference to shields as it's cheaper.
@@ -465,8 +447,7 @@  discard block
 block discarded – undo
465 447
 			$hardwareSold = $location->getHardwareSold();
466 448
 			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.
467 449
 				$hardwareID = HARDWARE_CARGO;
468
-			}
469
-			else {
450
+			} else {
470 451
 				foreach ($hardwareArray as $hardwareArrayID) {
471 452
 					if (!$ship->hasMaxHardware($hardwareArrayID) && isset($hardwareSold[$hardwareArrayID]) && ($amount = floor(($player->getCredits() - MINUMUM_RESERVE_CREDITS) / Globals::getHardwareCost($hardwareArrayID))) > 0) {
472 453
 						$hardwareID = $hardwareArrayID;
@@ -480,11 +461,14 @@  discard block
 block discarded – undo
480 461
 		}
481 462
 	}
482 463
 
483
-	if ($oppurtunisticOnly === true)
484
-		return false;
464
+	if ($oppurtunisticOnly === true) {
465
+			return false;
466
+	}
485 467
 
486
-	if ($player->getCredits() - $ship->getCostToUNO() < MINUMUM_RESERVE_CREDITS)
487
-		return false; //Only do non-oppurtunistic UNO if we have the money to do it properly!
468
+	if ($player->getCredits() - $ship->getCostToUNO() < MINUMUM_RESERVE_CREDITS) {
469
+			return false;
470
+	}
471
+	//Only do non-oppurtunistic UNO if we have the money to do it properly!
488 472
 
489 473
 	foreach ($hardwareArray as $hardwareArrayID) {
490 474
 		if (!$ship->hasMaxHardware($hardwareArrayID)) {
@@ -573,8 +557,10 @@  discard block
 block discarded – undo
573 557
 
574 558
 function checkForShipUpgrade(AbstractSmrPlayer $player) {
575 559
 	foreach (SHIP_UPGRADE_PATH[$player->getRaceID()] as $upgradeShipID) {
576
-		if ($player->getShipTypeID() == $upgradeShipID) //We can't upgrade, only downgrade.
560
+		if ($player->getShipTypeID() == $upgradeShipID) {
561
+			//We can't upgrade, only downgrade.
577 562
 			return false;
563
+		}
578 564
 		$cost = $player->getShip()->getCostToUpgrade($upgradeShipID);
579 565
 		if ($cost <= 0 || $player->getCredits() - $cost > MINUMUM_RESERVE_CREDITS) {
580 566
 			return doShipUpgrade($player, $upgradeShipID);
@@ -596,8 +582,9 @@  discard block
 block discarded – undo
596 582
 
597 583
 function &changeRoute(array &$tradeRoutes) {
598 584
 	$false = false;
599
-	if (count($tradeRoutes) == 0)
600
-		return $false;
585
+	if (count($tradeRoutes) == 0) {
586
+			return $false;
587
+	}
601 588
 	$routeKey = array_rand($tradeRoutes);
602 589
 	$tradeRoute =& $tradeRoutes[$routeKey];
603 590
 	unset($tradeRoutes[$routeKey]);
@@ -611,10 +598,11 @@  discard block
 block discarded – undo
611 598
 
612 599
 	$tradeGoods = array(GOOD_NOTHING => false);
613 600
 	foreach (Globals::getGoods() as $goodID => $good) {
614
-		if ($player->meetsAlignmentRestriction($good['AlignRestriction']))
615
-			$tradeGoods[$goodID] = true;
616
-		else
617
-			$tradeGoods[$goodID] = false;
601
+		if ($player->meetsAlignmentRestriction($good['AlignRestriction'])) {
602
+					$tradeGoods[$goodID] = true;
603
+		} else {
604
+					$tradeGoods[$goodID] = false;
605
+		}
618 606
 	}
619 607
 	$tradeRaces = array();
620 608
 	foreach (Globals::getRaces() as $raceID => $race) {
@@ -638,8 +626,7 @@  discard block
 block discarded – undo
638 626
 		$routes = unserialize(gzuncompress($db->getField('routes')));
639 627
 		debug('Using Cached Routes: #' . count($routes));
640 628
 		return $routes;
641
-	}
642
-	else {
629
+	} else {
643 630
 		debug('Generating Routes');
644 631
 		$allSectors = array();
645 632
 		foreach (SmrGalaxy::getGameGalaxies($player->getGameID()) as $galaxy) {
@@ -648,10 +635,11 @@  discard block
 block discarded – undo
648 635
 
649 636
 		$distances = Plotter::calculatePortToPortDistances($allSectors, $maxDistance, $startSectorID, $endSectorID);
650 637
 
651
-		if ($maxNumberOfPorts == 1)
652
-			$allRoutes = \Routes\RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort);
653
-		else
654
-			$allRoutes = \Routes\RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes);
638
+		if ($maxNumberOfPorts == 1) {
639
+					$allRoutes = \Routes\RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort);
640
+		} else {
641
+					$allRoutes = \Routes\RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes);
642
+		}
655 643
 
656 644
 		unset($distances);
657 645
 
Please login to merge, or discard this patch.