Scrutinizer GitHub App not installed

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

Install GitHub App

Completed
Branch master (287493)
by Dan
06:08
created
lib/Default/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.
lib/Default/SmrPlayer.class.inc 1 patch
Braces   +202 added lines, -152 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
 	}
@@ -175,8 +176,7 @@  discard block
 block discarded – undo
175 176
 			$this->newbieWarning = $db->getBoolean('newbie_warning');
176 177
 			$this->nameChanged = $db->getBoolean('name_changed');
177 178
 			$this->combatDronesKamikazeOnMines = $db->getBoolean('combat_drones_kamikaze_on_mines');
178
-		}
179
-		else {
179
+		} else {
180 180
 			throw new PlayerNotFoundException('Invalid accountID: '.$accountID. ' OR gameID:'.$gameID);
181 181
 		}
182 182
 	}
@@ -302,24 +302,31 @@  discard block
 block discarded – undo
302 302
 	}
303 303
 
304 304
 	function setZoom($zoom) {
305
-		if ($zoom < 0) $zoom = 0;
306
-		if ($zoom > 12) $zoom = 12;
307
-		if($this->zoom == $zoom)
308
-			return;
305
+		if ($zoom < 0) {
306
+			$zoom = 0;
307
+		}
308
+		if ($zoom > 12) {
309
+			$zoom = 12;
310
+		}
311
+		if($this->zoom == $zoom) {
312
+					return;
313
+		}
309 314
 		$this->zoom=$zoom;
310 315
 		$this->hasChanged=true;
311 316
 //		$this->db->query('UPDATE player SET zoom = ' . $zoom . ' WHERE ' . $this->SQL . ' LIMIT 1');
312 317
 	}
313 318
 
314 319
 	function increaseZoom($zoom) {
315
-		if ($zoom < 0)
316
-			throw new Exception('Trying to increase negative zoom.');
320
+		if ($zoom < 0) {
321
+					throw new Exception('Trying to increase negative zoom.');
322
+		}
317 323
 		$this->setZoom($this->getZoom()+$zoom);
318 324
 	}
319 325
 
320 326
 	function decreaseZoom($zoom) {
321
-		if ($zoom < 0)
322
-			throw new Exception('Trying to decrease negative zoom.');
327
+		if ($zoom < 0) {
328
+					throw new Exception('Trying to decrease negative zoom.');
329
+		}
323 330
 		$this->setZoom($this->getZoom()-$zoom);
324 331
 	}
325 332
 
@@ -334,8 +341,9 @@  discard block
 block discarded – undo
334 341
 	}
335 342
 
336 343
 	function setLastSectorID($lastSectorID) {
337
-		if($this->lastSectorID == $lastSectorID)
338
-			return;
344
+		if($this->lastSectorID == $lastSectorID) {
345
+					return;
346
+		}
339 347
 		$this->lastSectorID=$lastSectorID;
340 348
 		$this->hasChanged=true;
341 349
 //		$this->db->query('UPDATE player SET last_sector_id = '.$this->lastSectorID.' WHERE '.$this->SQL.' LIMIT 1');
@@ -348,11 +356,9 @@  discard block
 block discarded – undo
348 356
 			$kickedBy->sendMessage($this->getAccountID(), MSG_PLAYER, 'You were kicked out of the alliance!', false);
349 357
 			$this->actionTaken('PlayerKicked', array('Alliance' => $alliance, 'Player' => $kickedBy));
350 358
 			$kickedBy->actionTaken('KickPlayer', array('Alliance' => $alliance, 'Player' => $this));
351
-		}
352
-		else if($this->isAllianceLeader()) {
359
+		} else if($this->isAllianceLeader()) {
353 360
 			$this->actionTaken('DisbandAlliance', array('Alliance' => $alliance));
354
-		}
355
-		else {
361
+		} else {
356 362
 			$this->actionTaken('LeaveAlliance', array('Alliance' => $alliance));
357 363
 			if ($alliance->getLeaderID() != 0 && $alliance->getLeaderID() != ACCOUNT_ID_NHL) {
358 364
 				$this->sendMessage($alliance->getLeaderID(), MSG_PLAYER, 'I left your alliance!', false);
@@ -377,7 +383,9 @@  discard block
 block discarded – undo
377 383
 			try {
378 384
 				$this->sendMessage($alliance->getLeaderID(), MSG_PLAYER, 'I joined your alliance!', false);
379 385
 			} catch (AccountNotFoundException $e) {
380
-				if ($alliance->getLeaderID() != ACCOUNT_ID_NHL) throw $e;
386
+				if ($alliance->getLeaderID() != ACCOUNT_ID_NHL) {
387
+					throw $e;
388
+				}
381 389
 			}
382 390
 		}
383 391
 
@@ -393,8 +401,9 @@  discard block
 block discarded – undo
393 401
 	}
394 402
 
395 403
 	function setAllianceJoinable($time) {
396
-		if($this->allianceJoinable == $time)
397
-			return;
404
+		if($this->allianceJoinable == $time) {
405
+					return;
406
+		}
398 407
 		$this->allianceJoinable=$time;
399 408
 		$this->hasChanged=true;
400 409
 	}
@@ -404,8 +413,9 @@  discard block
 block discarded – undo
404 413
 	}
405 414
 
406 415
 	function setAttackColour($colour) {
407
-		if($this->attackColour == $colour)
408
-			return;
416
+		if($this->attackColour == $colour) {
417
+					return;
418
+		}
409 419
 		$this->attackColour=$colour;
410 420
 		$this->hasChanged=true;
411 421
 //		$this->db->query('UPDATE player SET attack_warning = ' . $this->db->escapeString($this->attackColour) . ' WHERE ' . $this->SQL . ' LIMIT 1');
@@ -416,28 +426,35 @@  discard block
 block discarded – undo
416 426
 	}
417 427
 
418 428
 	function increaseBank($credits) {
419
-		if($credits < 0)
420
-			throw new Exception('Trying to increase negative credits.');
421
-		if($credits == 0)
422
-			return;
429
+		if($credits < 0) {
430
+					throw new Exception('Trying to increase negative credits.');
431
+		}
432
+		if($credits == 0) {
433
+					return;
434
+		}
423 435
 		$credits += $this->bank;
424 436
 		$this->setBank($credits);
425 437
 	}
426 438
 	function decreaseBank($credits) {
427
-		if($credits < 0)
428
-			throw new Exception('Trying to decrease negative credits.');
429
-		if($credits == 0)
430
-			return;
439
+		if($credits < 0) {
440
+					throw new Exception('Trying to decrease negative credits.');
441
+		}
442
+		if($credits == 0) {
443
+					return;
444
+		}
431 445
 		$credits = $this->bank - $credits;
432 446
 		$this->setBank($credits);
433 447
 	}
434 448
 	function setBank($credits) {
435
-		if($this->bank == $credits)
436
-			return;
437
-		if($credits < 0)
438
-			throw new Exception('Trying to set negative credits.');
439
-		if($credits > MAX_MONEY)
440
-			throw new Exception('Trying to set more than max credits.');
449
+		if($this->bank == $credits) {
450
+					return;
451
+		}
452
+		if($credits < 0) {
453
+					throw new Exception('Trying to set negative credits.');
454
+		}
455
+		if($credits > MAX_MONEY) {
456
+					throw new Exception('Trying to set more than max credits.');
457
+		}
441 458
 		$this->bank = $credits;
442 459
 		$this->hasChanged=true;
443 460
 //		$this->db->query('UPDATE player SET bank = '.$this->bank.' WHERE '.$this->SQL.' LIMIT 1');
@@ -448,8 +465,9 @@  discard block
 block discarded – undo
448 465
 	}
449 466
 
450 467
 	function setLastNewsUpdate($time) {
451
-		if($this->lastNewsUpdate == $time)
452
-			return;
468
+		if($this->lastNewsUpdate == $time) {
469
+					return;
470
+		}
453 471
 		$this->lastNewsUpdate=$time;
454 472
 		$this->hasChanged=true;
455 473
 //		$this->db->query('UPDATE player SET last_news_update = ' . $time . ' WHERE ' . $this->SQL . ' LIMIT 1');
@@ -487,7 +505,9 @@  discard block
 block discarded – undo
487 505
 
488 506
 	public function updateTurns() {
489 507
 		// is account validated?
490
-		if (!$this->getAccount()->isValidated()) return;
508
+		if (!$this->getAccount()->isValidated()) {
509
+			return;
510
+		}
491 511
 
492 512
 		// how many turns would he get right now?
493 513
 		$extraTurns = $this->getTurnsGained(TIME);
@@ -516,8 +536,9 @@  discard block
 block discarded – undo
516 536
 	}
517 537
 
518 538
 	function setIgnoreGlobals($bool) {
519
-		if($this->ignoreGlobals == $bool)
520
-			return;
539
+		if($this->ignoreGlobals == $bool) {
540
+					return;
541
+		}
521 542
 		$this->ignoreGlobals=$bool;
522 543
 		$this->hasChanged=true;
523 544
 //		$this->db->query('UPDATE player SET ignore_globals = '.$this->db->escapeBoolean($bool).' WHERE '.$this->SQL.' LIMIT 1');
@@ -529,8 +550,9 @@  discard block
 block discarded – undo
529 550
 	}
530 551
 
531 552
 	function setLastPort($lastPort) {
532
-		if($this->lastPort == $lastPort)
533
-			return;
553
+		if($this->lastPort == $lastPort) {
554
+					return;
555
+		}
534 556
 		$this->lastPort=$lastPort;
535 557
 		$this->hasChanged=true;
536 558
 //		$this->db->query('UPDATE player SET last_port = ' . $this->lastPort . ' WHERE ' . $this->SQL . ' LIMIT 1');
@@ -541,8 +563,9 @@  discard block
 block discarded – undo
541 563
 	}
542 564
 
543 565
 	function setDisplayMissions($bool) {
544
-		if($this->displayMissions == $bool)
545
-			return;
566
+		if($this->displayMissions == $bool) {
567
+					return;
568
+		}
546 569
 		$this->displayMissions=$bool;
547 570
 		$this->hasChanged=true;
548 571
 	}
@@ -552,8 +575,9 @@  discard block
 block discarded – undo
552 575
 	}
553 576
 
554 577
 	function setDisplayWeapons($bool) {
555
-		if($this->displayWeapons == $bool)
556
-			return;
578
+		if($this->displayWeapons == $bool) {
579
+					return;
580
+		}
557 581
 		$this->displayWeapons=$bool;
558 582
 		$this->hasChanged=true;
559 583
 	}
@@ -563,8 +587,9 @@  discard block
 block discarded – undo
563 587
 	}
564 588
 
565 589
 	function setForceDropMessages($bool) {
566
-		if($this->forceDropMessages == $bool)
567
-			return;
590
+		if($this->forceDropMessages == $bool) {
591
+					return;
592
+		}
568 593
 		$this->forceDropMessages=$bool;
569 594
 		$this->hasChanged=true;
570 595
 	}
@@ -596,8 +621,9 @@  discard block
 block discarded – undo
596 621
 	}
597 622
 
598 623
 	function setLastTurnUpdate($time) {
599
-		if($this->lastTurnUpdate == $time)
600
-			return;
624
+		if($this->lastTurnUpdate == $time) {
625
+					return;
626
+		}
601 627
 		$this->lastTurnUpdate=$time;
602 628
 		$this->hasChanged=true;
603 629
 //		$sql = $this->db->query('UPDATE player SET last_turn_update = ' . $this->lastTurnUpdate . ' WHERE '. $this->SQL . ' LIMIT 1');
@@ -621,8 +647,9 @@  discard block
 block discarded – undo
621 647
 	function increaseRelationsByTrade($numGoods,$raceID) {
622 648
 		$relations = ceil(min($numGoods,300)/30);
623 649
 		//Cap relations to a max of 1 after 500 have been reached
624
-		if($this->getPureRelation($raceID) + $relations >= 500)
625
-			$relations = max(1, min($relations, 500 - $this->getPureRelation($raceID)));
650
+		if($this->getPureRelation($raceID) + $relations >= 500) {
651
+					$relations = max(1, min($relations, 500 - $this->getPureRelation($raceID)));
652
+		}
626 653
 		$this->increaseRelations($relations,$raceID);
627 654
 	}
628 655
 
@@ -632,27 +659,33 @@  discard block
 block discarded – undo
632 659
 	}
633 660
 
634 661
 	function increaseRelations($relations,$raceID) {
635
-		if($relations < 0)
636
-			throw new Exception('Trying to increase negative relations.');
637
-		if($relations == 0)
638
-			return;
662
+		if($relations < 0) {
663
+					throw new Exception('Trying to increase negative relations.');
664
+		}
665
+		if($relations == 0) {
666
+					return;
667
+		}
639 668
 		$relations += $this->getPureRelation($raceID);
640 669
 		$this->setRelations($relations,$raceID);
641 670
 	}
642 671
 	function decreaseRelations($relations,$raceID) {
643
-		if($relations < 0)
644
-			throw new Exception('Trying to decrease negative relations.');
645
-		if($relations == 0)
646
-			return;
672
+		if($relations < 0) {
673
+					throw new Exception('Trying to decrease negative relations.');
674
+		}
675
+		if($relations == 0) {
676
+					return;
677
+		}
647 678
 		$relations = $this->getPureRelation($raceID) - $relations;
648 679
 		$this->setRelations($relations,$raceID);
649 680
 	}
650 681
 	function setRelations($relations,$raceID) {
651 682
 		$this->getRelations();
652
-		if($this->pureRelations[$raceID] == $relations)
653
-			return;
654
-		if($relations < MIN_RELATIONS)
655
-			$relations = MIN_RELATIONS;
683
+		if($this->pureRelations[$raceID] == $relations) {
684
+					return;
685
+		}
686
+		if($relations < MIN_RELATIONS) {
687
+					$relations = MIN_RELATIONS;
688
+		}
656 689
 		$relationsDiff = $relations - $this->pureRelations[$raceID];
657 690
 		$this->pureRelations[$raceID] = $relations;
658 691
 		$this->relations[$raceID] += round($relationsDiff);
@@ -687,8 +720,7 @@  discard block
 block discarded – undo
687 720
 			$this->db->query('SELECT * FROM ship_has_name WHERE ' . $this->SQL . ' LIMIT 1');
688 721
 			if ($this->db->nextRecord()) {
689 722
 				$this->customShipName = $this->db->getField('ship_name');
690
-			}
691
-			else {
723
+			} else {
692 724
 				$this->customShipName = false;
693 725
 			}
694 726
 		}
@@ -700,8 +732,9 @@  discard block
 block discarded – undo
700 732
 			//Get Player Gadgets
701 733
 			$this->db->query('SELECT gadget_id,equipped,cooldown,lasts_until FROM player_has_gadget WHERE ' . $this->SQL);
702 734
 			$this->gadgets = array();
703
-			while ($this->db->nextRecord())
704
-				$this->gadgets[$this->db->getField('gadget_id')] = array('Equipped' => $this->db->getField('equipped'), 'Cooldown' => $this->db->getField('cooldown'), 'Expires' => $this->db->getField('lasts_until'));
735
+			while ($this->db->nextRecord()) {
736
+							$this->gadgets[$this->db->getField('gadget_id')] = array('Equipped' => $this->db->getField('equipped'), 'Cooldown' => $this->db->getField('cooldown'), 'Expires' => $this->db->getField('lasts_until'));
737
+			}
705 738
 		}
706 739
 	}
707 740
 
@@ -723,8 +756,7 @@  discard block
 block discarded – undo
723 756
 				$set=substr($set,0,-1);
724 757
 				$this->db->query('UPDATE player_has_gadget SET '.$set.' WHERE '.$this->SQL.' LIMIT '.count($this->gadgets));
725 758
 			}
726
-		}
727
-		else {
759
+		} else {
728 760
 			$field = $this->gadgetKeyToField($keyOrUpdateArray);
729 761
 			if($field!==false) {
730 762
 				foreach($this->gadgets as $gadgetID => $gadget) {
@@ -758,12 +790,12 @@  discard block
 block discarded – undo
758 790
 					$this->db->query('UPDATE player_has_gadget SET '.$set.' WHERE '.$this->SQL.' AND gadget_id = ' . $this->db->escapeNumber($gadgetID) . ' LIMIT 1');
759 791
 					return true;
760 792
 				}
761
-			}
762
-			else {
793
+			} else {
763 794
 				$field = $this->gadgetKeyToField($keyOrUpdateArray);
764 795
 				if($field!==false) {
765
-					if($this->gadgets[$gadgetID][$keyOrUpdateArray] == $value)
766
-						return;
796
+					if($this->gadgets[$gadgetID][$keyOrUpdateArray] == $value) {
797
+											return;
798
+					}
767 799
 					$this->gadgets[$gadgetID][$keyOrUpdateArray]=$value;
768 800
 					$this->db->query('UPDATE player_has_gadget SET `' . $field . '` = ' . $this->db->escapeString($value) . ' WHERE '.$this->SQL.' AND gadget_id = ' . $this->db->escapeNumber($gadgetID) . ' LIMIT 1');
769 801
 					return true;
@@ -774,8 +806,9 @@  discard block
 block discarded – undo
774 806
 	}
775 807
 
776 808
 	public function addGadget($gadgetID) {
777
-		if(isset($this->gadgets[$gadgetID]))
778
-			return false;
809
+		if(isset($this->gadgets[$gadgetID])) {
810
+					return false;
811
+		}
779 812
 		$this->gadgets[$gadgetID] = array('Equipped' => 0, 'Cooldown' => 0, 'Expires' => 0);
780 813
 		$this->db->query('REPLACE INTO player_has_gadget (game_id, account_id, gadget_id, cooldown, equipped,lasts_until) VALUES (' . $this->db->escapeNumber($this->gameID) . ',' . $this->db->escapeNumber($this->accountID) . ',' . $this->db->escapeNumber($gadgetID) . ',0,0,0)');
781 814
 		return true;
@@ -808,8 +841,7 @@  discard block
 block discarded – undo
808 841
 				$this->knowledge['Nyx'] = $this->db->getInt('nyx');
809 842
 				$this->knowledge['Federation'] = 0;
810 843
 				$this->knowledge['Underground'] = 0;
811
-			}
812
-			else {
844
+			} else {
813 845
 				$this->knowledge['Erebus'] = 0;
814 846
 				$this->knowledge['Aether'] = 0;
815 847
 				$this->knowledge['Tartarus'] = 0;
@@ -818,10 +850,12 @@  discard block
 block discarded – undo
818 850
 				$this->knowledge['Underground'] = 0;
819 851
 			}
820 852
 		}
821
-		if($knowledgeType===false)
822
-			return $this->knowledge;
823
-		if(isset($this->knowledge[$knowledgeType]))
824
-			return $this->knowledge[$knowledgeType];
853
+		if($knowledgeType===false) {
854
+					return $this->knowledge;
855
+		}
856
+		if(isset($this->knowledge[$knowledgeType])) {
857
+					return $this->knowledge[$knowledgeType];
858
+		}
825 859
 		return false;
826 860
 	}
827 861
 
@@ -834,9 +868,10 @@  discard block
 block discarded – undo
834 868
 		$sector->diedHere($this);
835 869
 
836 870
 		// if we are in an alliance we increase their deaths
837
-		if ($this->hasAlliance())
838
-			$this->db->query('UPDATE alliance SET alliance_deaths = alliance_deaths + 1
871
+		if ($this->hasAlliance()) {
872
+					$this->db->query('UPDATE alliance SET alliance_deaths = alliance_deaths + 1
839 873
 							WHERE game_id = ' . $this->db->escapeNumber($this->getGameID()) . ' AND alliance_id = ' . $this->db->escapeNumber($this->getAllianceID()) . ' LIMIT 1');
874
+		}
840 875
 
841 876
 		// record death stat
842 877
 		$this->increaseHOF(1,array('Dying','Deaths'), HOF_PUBLIC);
@@ -849,8 +884,9 @@  discard block
 block discarded – undo
849 884
 		$newCredits = round($this->getShip()->getCost() / 4);
850 885
 		$old_speed = $this->getShip()->getSpeed();
851 886
 
852
-		if ($newCredits < 100000)
853
-			$newCredits = 100000;
887
+		if ($newCredits < 100000) {
888
+					$newCredits = 100000;
889
+		}
854 890
 		$this->setCredits($newCredits);
855 891
 
856 892
 		$this->setSectorID($this::getHome($this->getGameID(), $this->getRaceID()));
@@ -924,14 +960,14 @@  discard block
 block discarded – undo
924 960
 		$relation = $relations[$killer->getRaceID()];
925 961
 
926 962
 		$alignChangePerRelation = 0.1;
927
-		if($relation >= RELATIONS_PEACE || $relation <= RELATIONS_WAR)
928
-			$alignChangePerRelation = 0.04;
963
+		if($relation >= RELATIONS_PEACE || $relation <= RELATIONS_WAR) {
964
+					$alignChangePerRelation = 0.04;
965
+		}
929 966
 
930 967
 		$return['KillerAlign'] = -$relation * $alignChangePerRelation; //Lose relations when killing a peaceful race
931 968
 		if($return['KillerAlign'] > 0) {
932 969
 			$killer->increaseAlignment($return['KillerAlign']);
933
-		}
934
-		else {
970
+		} else {
935 971
 			$killer->decreaseAlignment(-$return['KillerAlign']);
936 972
 		}
937 973
 		// War setting gives them military pay
@@ -965,8 +1001,7 @@  discard block
 block discarded – undo
965 1001
 			// If the podded players alignment makes them deputy or member then set bounty
966 1002
 			if($this->getAlignment() >= 100) {
967 1003
 				$return['BountyGained']['Type'] = 'HQ';
968
-			}
969
-			else if ($this->getAlignment() <= 100) {
1004
+			} else if ($this->getAlignment() <= 100) {
970 1005
 				$return['BountyGained']['Type'] = 'UG';
971 1006
 			}
972 1007
 
@@ -988,16 +1023,14 @@  discard block
 block discarded – undo
988 1023
 
989 1024
 			if($return['KillerAlign'] > 0) {
990 1025
 				$killer->increaseHOF($return['KillerAlign'],array('Killing','NPC','Alignment','Gain'), HOF_PUBLIC);
991
-			}
992
-			else {
1026
+			} else {
993 1027
 				$killer->increaseHOF(-$return['KillerAlign'],array('Killing','NPC','Alignment','Loss'), HOF_PUBLIC);
994 1028
 			}
995 1029
 
996 1030
 			$killer->increaseHOF($return['BountyGained']['Amount'],array('Killing','NPC','Money','Bounty Gained'), HOF_PUBLIC);
997 1031
 
998 1032
 			$killer->increaseHOF(1,array('Killing','NPC Kills'), HOF_PUBLIC);
999
-		}
1000
-		else {
1033
+		} else {
1001 1034
 			$killer->increaseHOF($return['KillerExp'],array('Killing','Experience','Gained'), HOF_PUBLIC);
1002 1035
 			$killer->increaseHOF($this->getExperience(),array('Killing','Experience','Of Traders Killed'), HOF_PUBLIC);
1003 1036
 
@@ -1009,8 +1042,7 @@  discard block
 block discarded – undo
1009 1042
 
1010 1043
 			if($return['KillerAlign'] > 0) {
1011 1044
 				$killer->increaseHOF($return['KillerAlign'],array('Killing','Alignment','Gain'), HOF_PUBLIC);
1012
-			}
1013
-			else {
1045
+			} else {
1014 1046
 				$killer->increaseHOF(-$return['KillerAlign'],array('Killing','Alignment','Loss'), HOF_PUBLIC);
1015 1047
 			}
1016 1048
 
@@ -1018,8 +1050,7 @@  discard block
 block discarded – undo
1018 1050
 
1019 1051
 			if($this->getShip()->getAttackRatingWithMaxCDs() <= MAX_ATTACK_RATING_NEWBIE && $this->hasNewbieStatus() && !$killer->hasNewbieStatus()) { //Newbie kill
1020 1052
 				$killer->increaseHOF(1,array('Killing','Newbie Kills'), HOF_PUBLIC);
1021
-			}
1022
-			else {
1053
+			} else {
1023 1054
 				$killer->increaseKills(1);
1024 1055
 				$killer->increaseHOF(1,array('Killing','Kills'), HOF_PUBLIC);
1025 1056
 
@@ -1202,20 +1233,21 @@  discard block
 block discarded – undo
1202 1233
 				$bountyChanged = false;
1203 1234
 				$bounty = $this->getBounty($key);
1204 1235
 				if($bounty['New'] === true) {
1205
-					if($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0)
1206
-						$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']) .')');
1207
-				}
1208
-				else {
1209
-					if($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0)
1210
-						$this->db->query('UPDATE bounty
1236
+					if($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0) {
1237
+											$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']) .')');
1238
+					}
1239
+				} else {
1240
+					if($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0) {
1241
+											$this->db->query('UPDATE bounty
1211 1242
 							SET amount=' . $this->db->escapeNumber($bounty['Amount']) . ',
1212 1243
 							smr_credits=' . $this->db->escapeString($bounty['SmrCredits']) . ',
1213 1244
 							type=' . $this->db->escapeString($bounty['Type']) . ',
1214 1245
 							claimer_id=' . $this->db->escapeNumber($bounty['Claimer']) . ',
1215 1246
 							time=' . $this->db->escapeNumber($bounty['Time']) . '
1216 1247
 							WHERE bounty_id=' . $this->db->escapeNumber($bounty['ID']) . ' AND ' . $this->SQL . ' LIMIT 1');
1217
-					else
1218
-						$this->db->query('DELETE FROM bounty WHERE bounty_id=' . $this->db->escapeNumber($bounty['ID']) . ' AND ' . $this->SQL . ' LIMIT 1');
1248
+					} else {
1249
+											$this->db->query('DELETE FROM bounty WHERE bounty_id=' . $this->db->escapeNumber($bounty['ID']) . ' AND ' . $this->SQL . ' LIMIT 1');
1250
+					}
1219 1251
 				}
1220 1252
 			}
1221 1253
 		}
@@ -1223,14 +1255,16 @@  discard block
 block discarded – undo
1223 1255
 	}
1224 1256
 
1225 1257
 	public function saveHOF() {
1226
-		if($this->hasHOFChanged!==false)
1227
-			$this->doHOFSave($this->hasHOFChanged);
1258
+		if($this->hasHOFChanged!==false) {
1259
+					$this->doHOFSave($this->hasHOFChanged);
1260
+		}
1228 1261
 		if(!empty(self::$hasHOFVisChanged)) {
1229 1262
 			foreach(self::$hasHOFVisChanged as $hofType => $changeType) {
1230
-				if($changeType==self::HOF_NEW)
1231
-					$this->db->query('INSERT INTO hof_visibility (type, visibility) VALUES ('.$this->db->escapeString($hofType).','.$this->db->escapeString(self::$HOFVis[$hofType]).')');
1232
-				else
1233
-					$this->db->query('UPDATE hof_visibility SET visibility = '.$this->db->escapeString(self::$HOFVis[$hofType]).' WHERE type = '.$this->db->escapeString($hofType).' LIMIT 1');
1263
+				if($changeType==self::HOF_NEW) {
1264
+									$this->db->query('INSERT INTO hof_visibility (type, visibility) VALUES ('.$this->db->escapeString($hofType).','.$this->db->escapeString(self::$HOFVis[$hofType]).')');
1265
+				} else {
1266
+									$this->db->query('UPDATE hof_visibility SET visibility = '.$this->db->escapeString(self::$HOFVis[$hofType]).' WHERE type = '.$this->db->escapeString($hofType).' LIMIT 1');
1267
+				}
1234 1268
 				unset(self::$hasHOFVisChanged[$hofType]);
1235 1269
 			}
1236 1270
 		}
@@ -1241,14 +1275,13 @@  discard block
 block discarded – undo
1241 1275
 			$tempTypeList[] = $type;
1242 1276
 			if(is_array($hofChanged)) {
1243 1277
 				$this->doHOFSave($hofChanged,$tempTypeList);
1244
-			}
1245
-			else {
1278
+			} else {
1246 1279
 				$amount = $this->getHOF($tempTypeList);
1247 1280
 				if($hofChanged==self::HOF_NEW) {
1248
-					if($amount > 0)
1249
-						$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) . ')');
1250
-				}
1251
-				else if($hofChanged==self::HOF_CHANGED) {
1281
+					if($amount > 0) {
1282
+											$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) . ')');
1283
+					}
1284
+				} else if($hofChanged==self::HOF_CHANGED) {
1252 1285
 	//				if($amount > 0)
1253 1286
 						$this->db->query('UPDATE player_hof
1254 1287
 							SET amount=' . $this->db->escapeNumber($amount) . '
@@ -1359,11 +1392,12 @@  discard block
 block discarded – undo
1359 1392
 			$this->tickers = array();
1360 1393
 			//get ticker info
1361 1394
 			$this->db->query('SELECT type,time,expires,recent FROM player_has_ticker WHERE ' . $this->SQL .' AND expires > ' . $this->db->escapeNumber(TIME));
1362
-			while($this->db->nextRecord())
1363
-				$this->tickers[$this->db->getField('type')] = array( 'Type' => $this->db->getField('type'),
1395
+			while($this->db->nextRecord()) {
1396
+							$this->tickers[$this->db->getField('type')] = array( 'Type' => $this->db->getField('type'),
1364 1397
 																				'Time' => $this->db->getInt('time'),
1365 1398
 																				'Expires' => $this->db->getInt('expires'),
1366 1399
 																				'Recent' => $this->db->getField('recent'));
1400
+			}
1367 1401
 		}
1368 1402
 		return $this->tickers;
1369 1403
 	}
@@ -1374,8 +1408,9 @@  discard block
 block discarded – undo
1374 1408
 
1375 1409
 	public function getTicker($tickerType) {
1376 1410
 		$tickers = $this->getTickers();
1377
-		if(isset($tickers[$tickerType]))
1378
-			return $tickers[$tickerType];
1411
+		if(isset($tickers[$tickerType])) {
1412
+					return $tickers[$tickerType];
1413
+		}
1379 1414
 		return false;
1380 1415
 	}
1381 1416
 
@@ -1384,9 +1419,15 @@  discard block
 block discarded – undo
1384 1419
 	}
1385 1420
 
1386 1421
 	public function getTurnsLevel() {
1387
-		if (!$this->hasTurns()) return 'NONE';
1388
-		if ($this->getTurns() <= 25 ) return 'LOW';
1389
-		if ($this->getTurns() <= 75 ) return 'MEDIUM';
1422
+		if (!$this->hasTurns()) {
1423
+			return 'NONE';
1424
+		}
1425
+		if ($this->getTurns() <= 25 ) {
1426
+			return 'LOW';
1427
+		}
1428
+		if ($this->getTurns() <= 75 ) {
1429
+			return 'MEDIUM';
1430
+		}
1390 1431
 		return 'HIGH';
1391 1432
 	}
1392 1433
 
@@ -1464,8 +1505,9 @@  discard block
 block discarded – undo
1464 1505
 
1465 1506
 	public function sendGlobalMessage($message, $canBeIgnored = true) {
1466 1507
 		if($canBeIgnored) {
1467
-			if($this->getAccount()->isMailBanned())
1468
-				create_error('You are currently banned from sending messages');
1508
+			if($this->getAccount()->isMailBanned()) {
1509
+							create_error('You are currently banned from sending messages');
1510
+			}
1469 1511
 		}
1470 1512
 		$this->sendMessageToBox(BOX_GLOBALS,$message);
1471 1513
 
@@ -1488,12 +1530,14 @@  discard block
 block discarded – undo
1488 1530
 	public function sendMessage($receiverID, $messageTypeID, $message, $canBeIgnored = true, $unread = true, $expires = false, $senderDelete = false) {
1489 1531
 		//get expire time
1490 1532
 		if($canBeIgnored) {
1491
-			if($this->getAccount()->isMailBanned())
1492
-				create_error('You are currently banned from sending messages');
1533
+			if($this->getAccount()->isMailBanned()) {
1534
+							create_error('You are currently banned from sending messages');
1535
+			}
1493 1536
 			// Don't send messages to players ignoring us
1494 1537
 			$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');
1495
-			if($this->db->nextRecord())
1496
-				return;
1538
+			if($this->db->nextRecord()) {
1539
+							return;
1540
+			}
1497 1541
 		}
1498 1542
 
1499 1543
 		$message = word_filter($message);
@@ -1574,32 +1618,36 @@  discard block
 block discarded – undo
1574 1618
 
1575 1619
 	public static function sendMessageFromAdmin($gameID, $receiverID, $message, $expires = false) {
1576 1620
 		//get expire time
1577
-		if($expires===false)
1578
-			$expires = TIME + 86400 * 365;
1621
+		if($expires===false) {
1622
+					$expires = TIME + 86400 * 365;
1623
+		}
1579 1624
 		// send him the message
1580 1625
 		self::doMessageSending(ACCOUNT_ID_ADMIN,$receiverID, $gameID, MSG_ADMIN, $message, $expires);
1581 1626
 	}
1582 1627
 
1583 1628
 	public static function sendMessageFromAllianceAmbassador($gameID, $receiverID, $message, $expires = false) {
1584 1629
 		//get expire time
1585
-		if($expires===false)
1586
-			$expires = TIME + 86400 * 31;
1630
+		if($expires===false) {
1631
+					$expires = TIME + 86400 * 31;
1632
+		}
1587 1633
 		// send him the message
1588 1634
 		self::doMessageSending(ACCOUNT_ID_ALLIANCE_AMBASSADOR, $receiverID, $gameID, MSG_ALLIANCE, $message, $expires);
1589 1635
 	}
1590 1636
 
1591 1637
 	public static function sendMessageFromCasino($gameID, $receiverID, $message, $expires = false) {
1592 1638
 		//get expire time
1593
-		if($expires===false)
1594
-			$expires = TIME + 86400 * 7;
1639
+		if($expires===false) {
1640
+					$expires = TIME + 86400 * 7;
1641
+		}
1595 1642
 		// send him the message
1596 1643
 		self::doMessageSending(ACCOUNT_ID_CASINO, $receiverID, $gameID, MSG_CASINO, $message, $expires);
1597 1644
 	}
1598 1645
 
1599 1646
 	public static function sendMessageFromRace($raceID, $gameID, $receiverID, $message, $expires = false) {
1600 1647
 		//get expire time
1601
-		if($expires===false)
1602
-			$expires = TIME + 86400 * 5;
1648
+		if($expires===false) {
1649
+					$expires = TIME + 86400 * 5;
1650
+		}
1603 1651
 		// send him the message
1604 1652
 		self::doMessageSending(ACCOUNT_ID_GROUP_RACES+$raceID,$receiverID, $gameID, MSG_POLITICAL, $message, $expires);
1605 1653
 	}
@@ -1642,11 +1690,11 @@  discard block
 block discarded – undo
1642 1690
 	public function setPlottedCourse(Distance $plottedCourse) {
1643 1691
 		$hadPlottedCourse = $this->hasPlottedCourse();
1644 1692
 		$this->plottedCourse = $plottedCourse;
1645
-		if ($this->plottedCourse->getTotalSectors()>0)
1646
-			$this->db->query('REPLACE INTO player_plotted_course
1693
+		if ($this->plottedCourse->getTotalSectors()>0) {
1694
+					$this->db->query('REPLACE INTO player_plotted_course
1647 1695
 				(account_id, game_id, course)
1648 1696
 				VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeBinary(serialize($this->plottedCourse)) . ')');
1649
-		else if($hadPlottedCourse) {
1697
+		} else if($hadPlottedCourse) {
1650 1698
 			$this->deletePlottedCourse();
1651 1699
 		}
1652 1700
 	}
@@ -1656,12 +1704,14 @@  discard block
 block discarded – undo
1656 1704
 	}
1657 1705
 
1658 1706
 	public function isPartOfCourse($sectorOrSectorID) {
1659
-		if(!$this->hasPlottedCourse())
1660
-			return false;
1661
-		if($sectorOrSectorID instanceof SmrSector )
1662
-			$sectorID = $sectorOrSectorID->getSectorID();
1663
-		else
1664
-			$sectorID = $sectorOrSectorID;
1707
+		if(!$this->hasPlottedCourse()) {
1708
+					return false;
1709
+		}
1710
+		if($sectorOrSectorID instanceof SmrSector ) {
1711
+					$sectorID = $sectorOrSectorID->getSectorID();
1712
+		} else {
1713
+					$sectorID = $sectorOrSectorID;
1714
+		}
1665 1715
 		return $this->getPlottedCourse()->isInPath($sectorID);
1666 1716
 	}
1667 1717
 
Please login to merge, or discard this patch.
lib/Default/DummyShip.class.inc 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,8 +72,7 @@
 block discarded – undo
72 72
 				$return = unserialize($db->getField('info'));
73 73
 				$return->regenerate($player);
74 74
 				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] =& $return;
75
-			}
76
-			else {
75
+			} else {
77 76
 				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = new DummyShip($player);
78 77
 			}
79 78
 		}
Please login to merge, or discard this patch.
lib/Default/AbstractSmrShip.class.inc 1 patch
Braces   +87 added lines, -64 removed lines patch added patch discarded remove patch
@@ -28,10 +28,11 @@  discard block
 block discarded – undo
28 28
 			// determine ship
29 29
 			$db = new SmrMySqlDatabase();
30 30
 			$db->query('SELECT * FROM ship_type WHERE ship_type_id = '.$db->escapeNumber($shipTypeID).' LIMIT 1'); //TODO add game type id
31
-			if($db->nextRecord())
32
-				self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = self::buildBaseShip($db);
33
-			else
34
-				self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = false;
31
+			if($db->nextRecord()) {
32
+							self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = self::buildBaseShip($db);
33
+			} else {
34
+							self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = false;
35
+			}
35 36
 		}
36 37
 		return self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID];
37 38
 	}
@@ -149,8 +150,9 @@  discard block
 block discarded – undo
149 150
 				do {
150 151
 					list($goodID,$amount)=each($goods);
151 152
 				} while($amount==0);
152
-				if($amount > $total-$this->getCargoHolds())
153
-					$amount = $total-$this->getCargoHolds();
153
+				if($amount > $total-$this->getCargoHolds()) {
154
+									$amount = $total-$this->getCargoHolds();
155
+				}
154 156
 				$this->decreaseCargo($goodID,$amount);
155 157
 			}
156 158
 		}
@@ -158,19 +160,21 @@  discard block
 block discarded – undo
158 160
 
159 161
 	public function checkForExcessHardware() {
160 162
 		//check hardware to see if anything needs to be removed
161
-		if(is_array($hardware = $this->getHardware()))
162
-			foreach ($hardware as $hardwareTypeID => $amount) {
163
+		if(is_array($hardware = $this->getHardware())) {
164
+					foreach ($hardware as $hardwareTypeID => $amount) {
163 165
 				if ($amount > ($max=$this->getMaxHardware($hardwareTypeID))) {
164 166
 					$this->setHardware($hardwareTypeID,$max,true);
167
+		}
165 168
 				}
166 169
 			}
167 170
 	}
168 171
 
169 172
 	public function getPowerUsed() {
170 173
 		$power = 0;
171
-		if($this->getNumWeapons()>0)
172
-			foreach ($this->weapons as $weapon)
174
+		if($this->getNumWeapons()>0) {
175
+					foreach ($this->weapons as $weapon)
173 176
 				$power += $weapon->getPowerLevel();
177
+		}
174 178
 		return $power;
175 179
 	}
176 180
 
@@ -191,17 +195,19 @@  discard block
 block discarded – undo
191 195
 	}
192 196
 
193 197
 	public function getDisplayAttackRating(AbstractSmrPlayer $player) {
194
-		if($this->hasActiveIllusion())
195
-			return $this->getIllusionAttack();
196
-		else
197
-			return $this->getAttackRating();
198
+		if($this->hasActiveIllusion()) {
199
+					return $this->getIllusionAttack();
200
+		} else {
201
+					return $this->getAttackRating();
202
+		}
198 203
 	}
199 204
 
200 205
 	public function getDisplayDefenseRating() {
201
-		if($this->hasActiveIllusion())
202
-			return $this->getIllusionDefense();
203
-		else
204
-			return $this->getDefenseRating();
206
+		if($this->hasActiveIllusion()) {
207
+					return $this->getIllusionDefense();
208
+		} else {
209
+					return $this->getDefenseRating();
210
+		}
205 211
 	}
206 212
 
207 213
 	public function getAttackRating() {
@@ -251,8 +257,7 @@  discard block
 block discarded – undo
251 257
 				$this->weapons[$i-1] =& $this->weapons[$i]; //If we go above the bounds of the array it will keep on going due to assign by ref. Hence $i-1 =& $i not $i =& $i+1
252 258
 			}
253 259
 			$this->weapons[count($this->weapons)-1] =& $temp;
254
-		}
255
-		else {
260
+		} else {
256 261
 			$temp = $this->weapons[$replacement];
257 262
 			$this->weapons[$replacement] = $this->weapons[$orderID];
258 263
 			$this->weapons[$orderID] = $temp;
@@ -269,8 +274,7 @@  discard block
 block discarded – undo
269 274
 				$this->weapons[$i] =& $this->weapons[$i-1];
270 275
 			}
271 276
 			$this->weapons[0] =& $temp;
272
-		}
273
-		else {
277
+		} else {
274 278
 			$temp = $this->weapons[$replacement];
275 279
 			$this->weapons[$replacement] = $this->weapons[$orderID];
276 280
 			$this->weapons[$orderID] = $temp;
@@ -329,8 +333,7 @@  discard block
 block discarded – undo
329 333
 			$this->setArmour(150,true);
330 334
 			$this->setCargoHolds(40);
331 335
 			$this->setShipTypeID(SHIP_TYPE_NEWBIE_MERCHANT_VESSEL);
332
-		}
333
-		else {
336
+		} else {
334 337
 			$this->setShields(50,true);
335 338
 			$this->setArmour(50,true);
336 339
 			$this->setCargoHolds(5);
@@ -350,8 +353,9 @@  discard block
 block discarded – undo
350 353
 
351 354
 
352 355
 	public function hasActiveIllusion() {
353
-		if(!$this->hasIllusion())
354
-			return false;
356
+		if(!$this->hasIllusion()) {
357
+					return false;
358
+		}
355 359
 		return $this->getIllusionShip()!==false;
356 360
 
357 361
 	}
@@ -475,14 +479,16 @@  discard block
 block discarded – undo
475 479
 	}
476 480
 
477 481
 	public function getHardware($hardwareTypeID = false) {
478
-		if($hardwareTypeID === false)
479
-			return $this->hardware;
482
+		if($hardwareTypeID === false) {
483
+					return $this->hardware;
484
+		}
480 485
 		return isset($this->hardware[$hardwareTypeID]) ? $this->hardware[$hardwareTypeID] : 0;
481 486
 	}
482 487
 
483 488
 	public function setHardware($hardwareTypeID,$amount) {
484
-		if($this->getHardware($hardwareTypeID) == $amount)
485
-			return;
489
+		if($this->getHardware($hardwareTypeID) == $amount) {
490
+					return;
491
+		}
486 492
 		$this->hardware[$hardwareTypeID] = $amount;
487 493
 		$this->hasChangedHardware[$hardwareTypeID] = true;
488 494
 	}
@@ -492,14 +498,16 @@  discard block
 block discarded – undo
492 498
 	}
493 499
 
494 500
 	public function getOldHardware($hardwareTypeID = false) {
495
-		if($hardwareTypeID === false)
496
-			return $this->oldHardware;
501
+		if($hardwareTypeID === false) {
502
+					return $this->oldHardware;
503
+		}
497 504
 		return isset($this->oldHardware[$hardwareTypeID]) ? $this->oldHardware[$hardwareTypeID] : 0;
498 505
 	}
499 506
 
500 507
 	public function setOldHardware($hardwareTypeID,$amount) {
501
-		if($this->getOldHardware($hardwareTypeID) == $amount)
502
-			return;
508
+		if($this->getOldHardware($hardwareTypeID) == $amount) {
509
+					return;
510
+		}
503 511
 		$this->oldHardware[$hardwareTypeID] = $amount;
504 512
 		$this->hasChangedHardware[$hardwareTypeID] = true;
505 513
 	}
@@ -509,8 +517,9 @@  discard block
 block discarded – undo
509 517
 	}
510 518
 
511 519
 	public function getMaxHardware($hardwareTypeID = false) {
512
-		if($hardwareTypeID === false)
513
-			return $this->baseShip['MaxHardware'];
520
+		if($hardwareTypeID === false) {
521
+					return $this->baseShip['MaxHardware'];
522
+		}
514 523
 		return $this->baseShip['MaxHardware'][$hardwareTypeID];
515 524
 	}
516 525
 
@@ -519,8 +528,9 @@  discard block
 block discarded – undo
519 528
 	}
520 529
 
521 530
 	public function setShields($amount,$updateOldAmount=false) {
522
-		if($updateOldAmount && !$this->hasLostShields())
523
-			$this->setOldHardware(HARDWARE_SHIELDS,$amount);
531
+		if($updateOldAmount && !$this->hasLostShields()) {
532
+					$this->setOldHardware(HARDWARE_SHIELDS,$amount);
533
+		}
524 534
 		$this->setHardware(HARDWARE_SHIELDS,$amount);
525 535
 	}
526 536
 
@@ -561,8 +571,9 @@  discard block
 block discarded – undo
561 571
 	}
562 572
 
563 573
 	public function setArmour($amount,$updateOldAmount=false) {
564
-		if($updateOldAmount && !$this->hasLostArmour())
565
-			$this->setOldHardware(HARDWARE_ARMOUR,$amount);
574
+		if($updateOldAmount && !$this->hasLostArmour()) {
575
+					$this->setOldHardware(HARDWARE_ARMOUR,$amount);
576
+		}
566 577
 		$this->setHardware(HARDWARE_ARMOUR,$amount);
567 578
 	}
568 579
 
@@ -631,8 +642,9 @@  discard block
 block discarded – undo
631 642
 	}
632 643
 
633 644
 	public function setCDs($amount,$updateOldAmount=false) {
634
-		if($updateOldAmount && !$this->hasLostCDs())
635
-			$this->setOldHardware(HARDWARE_COMBAT,$amount);
645
+		if($updateOldAmount && !$this->hasLostCDs()) {
646
+					$this->setOldHardware(HARDWARE_COMBAT,$amount);
647
+		}
636 648
 		$this->setHardware(HARDWARE_COMBAT,$amount);
637 649
 	}
638 650
 
@@ -714,8 +726,9 @@  discard block
 block discarded – undo
714 726
 
715 727
 	public function &getCargo($goodID=false) {
716 728
 		if($goodID!==false) {
717
-			if(isset($this->cargo[$goodID]))
718
-				return $this->cargo[$goodID];
729
+			if(isset($this->cargo[$goodID])) {
730
+							return $this->cargo[$goodID];
731
+			}
719 732
 			$cargo = 0;
720 733
 			return $cargo;
721 734
 		}
@@ -723,16 +736,19 @@  discard block
 block discarded – undo
723 736
 	}
724 737
 
725 738
 	public function hasCargo($goodID=false) {
726
-		if($goodID!==false)
727
-			return $this->getCargo($goodID)>0;
728
-		if(is_array($cargo = $this->getCargo()))
729
-			return array_sum($cargo)>0;
739
+		if($goodID!==false) {
740
+					return $this->getCargo($goodID)>0;
741
+		}
742
+		if(is_array($cargo = $this->getCargo())) {
743
+					return array_sum($cargo)>0;
744
+		}
730 745
 		return false;
731 746
 	}
732 747
 
733 748
 	public function setCargo($goodID,$amount) {
734
-		if($this->getCargo($goodID) == $amount)
735
-			return;
749
+		if($this->getCargo($goodID) == $amount) {
750
+					return;
751
+		}
736 752
 		$this->cargo[$goodID] = $amount;
737 753
 		$this->hasChangedCargo = true;
738 754
 		// Sort cargo by goodID to make sure it shows up in the correct order
@@ -741,14 +757,16 @@  discard block
 block discarded – undo
741 757
 	}
742 758
 
743 759
 	public function decreaseCargo($goodID,$amount) {
744
-		if($amount < 0)
745
-			throw new Exception('Trying to decrease negative cargo.');
760
+		if($amount < 0) {
761
+					throw new Exception('Trying to decrease negative cargo.');
762
+		}
746 763
 		$this->setCargo($goodID,$this->getCargo($goodID)-$amount);
747 764
 	}
748 765
 
749 766
 	public function increaseCargo($goodID,$amount) {
750
-		if($amount < 0)
751
-			throw new Exception('Trying to increase negative cargo.');
767
+		if($amount < 0) {
768
+					throw new Exception('Trying to increase negative cargo.');
769
+		}
752 770
 		$this->setCargo($goodID,$this->getCargo($goodID)+$amount);
753 771
 	}
754 772
 
@@ -778,8 +796,9 @@  discard block
 block discarded – undo
778 796
 		$this->setOldShields($this->getShields());
779 797
 		$this->setOldCDs($this->getCDs());
780 798
 		$this->setOldArmour($this->getArmour());
781
-		if(isset($var['UnderAttack']))
782
-			return $var['UnderAttack'];
799
+		if(isset($var['UnderAttack'])) {
800
+					return $var['UnderAttack'];
801
+		}
783 802
 		if($underAttack && !USING_AJAX) {
784 803
 			SmrSession::updateVar('UnderAttack',$underAttack); //Remember we are under attack for AJAX
785 804
 		}
@@ -854,8 +873,9 @@  discard block
 block discarded – undo
854 873
 		$results['DeadBeforeShot'] = false;
855 874
 		foreach($this->weapons as $orderID => $weapon) {
856 875
 			$results['Weapons'][$orderID] =& $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
857
-			if($results['Weapons'][$orderID]['Hit'])
858
-				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
876
+			if($results['Weapons'][$orderID]['Hit']) {
877
+							$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
878
+			}
859 879
 		}
860 880
 		if($this->hasCDs()) {
861 881
 			$thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs());
@@ -917,8 +937,9 @@  discard block
 block discarded – undo
917 937
 		$results['DeadBeforeShot'] = false;
918 938
 		foreach($this->weapons as $orderID => $weapon) {
919 939
 			$results['Weapons'][$orderID] =& $weapon->shootPort($thisPlayer, $port);
920
-			if($results['Weapons'][$orderID]['Hit'])
921
-				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
940
+			if($results['Weapons'][$orderID]['Hit']) {
941
+							$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
942
+			}
922 943
 		}
923 944
 		if($this->hasCDs()) {
924 945
 			$thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs());
@@ -954,8 +975,9 @@  discard block
 block discarded – undo
954 975
 		$results['DeadBeforeShot'] = false;
955 976
 		foreach($this->weapons as $orderID => $weapon) {
956 977
 			$results['Weapons'][$orderID] =& $weapon->shootPlanet($thisPlayer, $planet, $delayed);
957
-			if($results['Weapons'][$orderID]['Hit'])
958
-				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
978
+			if($results['Weapons'][$orderID]['Hit']) {
979
+							$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
980
+			}
959 981
 		}
960 982
 		if($this->hasCDs()) {
961 983
 			$thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs());
@@ -980,8 +1002,9 @@  discard block
 block discarded – undo
980 1002
 				$cdDamage = $this->doCDDamage(min($damage['MaxDamage'],$damage['Armour']));
981 1003
 				$damage['Armour'] -= $cdDamage;
982 1004
 				$damage['MaxDamage'] -= $cdDamage;
983
-				if(!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover']))
984
-					$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'],$damage['Armour']));
1005
+				if(!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) {
1006
+									$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'],$damage['Armour']));
1007
+				}
985 1008
 			}
986 1009
 		}
987 1010
 		$return = array(
Please login to merge, or discard this patch.
lib/Default/council.inc 1 patch
Braces   +14 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,17 +16,19 @@  discard block
 block discarded – undo
16 16
 		$race_id_2	= $db->getInt('race_id_2');
17 17
 		$action		= $db->getField('action');
18 18
 
19
-		if ($action == 'INC')
20
-			$relation_modifier = RELATIONS_VOTE_CHANGE;
21
-		else
22
-			$relation_modifier = -RELATIONS_VOTE_CHANGE;
19
+		if ($action == 'INC') {
20
+					$relation_modifier = RELATIONS_VOTE_CHANGE;
21
+		} else {
22
+					$relation_modifier = -RELATIONS_VOTE_CHANGE;
23
+		}
23 24
 
24 25
 		$db2->query('SELECT * FROM race_has_relation ' .
25 26
 					'WHERE race_id_1 = ' . $db2->escapeNumber($race_id_1) . '
26 27
 						AND race_id_2 = ' . $db2->escapeNumber($race_id_2) . '
27 28
 						AND game_id = ' . $db2->escapeNumber($player->getGameID()));
28
-		if ($db2->nextRecord())
29
-			$relation = $db2->getField('relation') + $relation_modifier;
29
+		if ($db2->nextRecord()) {
30
+					$relation = $db2->getField('relation') + $relation_modifier;
31
+		}
30 32
 
31 33
 		if ($relation < MIN_GLOBAL_RELATIONS) {
32 34
 			$relation = MIN_GLOBAL_RELATIONS;
@@ -107,10 +109,11 @@  discard block
 block discarded – undo
107 109
 					$expireTime = TIME + TIME_FOR_WAR_VOTE_FED_SAFETY;
108 110
 					$query = 'REPLACE INTO player_can_fed (account_id, game_id, race_id, expiry, allowed) VALUES ';
109 111
 					foreach($currentlyParkedAccountIDs as $raceID => $accountIDs) {
110
-						if($raceID == $race_id_1)
111
-							$message = 'We have declared war upon your race';
112
-						else
113
-							$message = 'Your race has declared war upon us';
112
+						if($raceID == $race_id_1) {
113
+													$message = 'We have declared war upon your race';
114
+						} else {
115
+													$message = 'Your race has declared war upon us';
116
+						}
114 117
 						$message .= ', you have '.format_time(TIME_FOR_WAR_VOTE_FED_SAFETY).' to vacate our federal space, after that time you will no longer be protected (unless you have strong personal relations).';
115 118
 						foreach($accountIDs as $accountID) {
116 119
 							$query .= '('.$db2->escapeNumber($accountID).','.$db2->escapeNumber($player->getGameID()).','.$db2->escapeNumber($raceID).','.$db2->escapeNumber($expireTime).','.$db2->escapeBoolean(true).'),';
@@ -135,8 +138,7 @@  discard block
 block discarded – undo
135 138
 				$news = 'The [race='.$race_id_1.'] have declared <span class="red">WAR</span> on the [race='.$race_id_2.']';
136 139
 				$db2->query('INSERT INTO news (game_id, time, news_message) VALUES ' .
137 140
 							'('.$db2->escapeNumber($player->getGameID()).', '.$db2->escapeNumber(TIME).', ' . $db2->escapeString($news) . ')');
138
-			}
139
-			elseif ($type == 'PEACE') {
141
+			} elseif ($type == 'PEACE') {
140 142
 				// get 'yes' votes
141 143
 				$db2->query('SELECT * FROM player_votes_pact
142 144
 							WHERE game_id = '.$db2->escapeNumber($player->getGameID()).'
Please login to merge, or discard this patch.
lib/Default/AbstractSmrPlayer.class.inc 1 patch
Braces   +238 added lines, -163 removed lines patch added patch discarded remove patch
@@ -78,8 +78,9 @@  discard block
 block discarded – undo
78 78
 		return $this->getNewbieTurns()>0;
79 79
 	}
80 80
 	public function setNewbieTurns($newbieTurns) {
81
-		if($this->newbieTurns == $newbieTurns)
82
-			return;
81
+		if($this->newbieTurns == $newbieTurns) {
82
+					return;
83
+		}
83 84
 		$this->newbieTurns=$newbieTurns;
84 85
 		$this->hasChanged=true;
85 86
 	}
@@ -89,8 +90,9 @@  discard block
 block discarded – undo
89 90
 	}
90 91
 
91 92
 	public function setShipTypeID($shipID) {
92
-		if($this->shipID == $shipID)
93
-			return;
93
+		if($this->shipID == $shipID) {
94
+					return;
95
+		}
94 96
 		$this->shipID=$shipID;
95 97
 		$this->hasChanged=true;
96 98
 	}
@@ -206,8 +208,9 @@  discard block
 block discarded – undo
206 208
 		}
207 209
 
208 210
 		$ship = $this->getShip();
209
-		if ($ship->hasIllegalGoods())
210
-			return false;
211
+		if ($ship->hasIllegalGoods()) {
212
+					return false;
213
+		}
211 214
 
212 215
 		if ($ship->getAttackRating() <= $this->getSafeAttackRating()) {
213 216
 			foreach($sector->getFedRaceIDs() as $fedRaceID) {
@@ -248,8 +251,9 @@  discard block
 block discarded – undo
248 251
 	}
249 252
 
250 253
 	public function setDead($bool) {
251
-		if($this->dead == $bool)
252
-			return;
254
+		if($this->dead == $bool) {
255
+					return;
256
+		}
253 257
 		$this->dead=$bool;
254 258
 		$this->hasChanged=true;
255 259
 	}
@@ -259,14 +263,16 @@  discard block
 block discarded – undo
259 263
 	}
260 264
 
261 265
 	public function increaseKills($kills) {
262
-		if($kills < 0)
263
-			throw new Exception('Trying to increase negative kills.');
266
+		if($kills < 0) {
267
+					throw new Exception('Trying to increase negative kills.');
268
+		}
264 269
 		$this->setKills($this->kills+$kills);
265 270
 	}
266 271
 
267 272
 	public function setKills($kills) {
268
-		if($this->kills == $kills)
269
-			return;
273
+		if($this->kills == $kills) {
274
+					return;
275
+		}
270 276
 		$this->kills=$kills;
271 277
 		$this->hasChanged=true;
272 278
 	}
@@ -276,14 +282,16 @@  discard block
 block discarded – undo
276 282
 	}
277 283
 
278 284
 	public function increaseDeaths($deaths) {
279
-		if($deaths < 0)
280
-			throw new Exception('Trying to increase negative deaths.');
285
+		if($deaths < 0) {
286
+					throw new Exception('Trying to increase negative deaths.');
287
+		}
281 288
 		$this->setDeaths($this->getDeaths()+$deaths);
282 289
 	}
283 290
 
284 291
 	public function setDeaths($deaths) {
285
-		if($this->deaths == $deaths)
286
-			return;
292
+		if($this->deaths == $deaths) {
293
+					return;
294
+		}
287 295
 		$this->deaths = $deaths;
288 296
 		$this->hasChanged=true;
289 297
 	}
@@ -305,24 +313,29 @@  discard block
 block discarded – undo
305 313
 	}
306 314
 
307 315
 	public function increaseAlignment($align) {
308
-		if($align < 0)
309
-			throw new Exception('Trying to increase negative align.');
310
-		if($align == 0)
311
-			return;
316
+		if($align < 0) {
317
+					throw new Exception('Trying to increase negative align.');
318
+		}
319
+		if($align == 0) {
320
+					return;
321
+		}
312 322
 		$align += $this->alignment;
313 323
 		$this->setAlignment($align);
314 324
 	}
315 325
 	public function decreaseAlignment($align) {
316
-		if($align < 0)
317
-			throw new Exception('Trying to decrease negative align.');
318
-		if($align == 0)
319
-			return;
326
+		if($align < 0) {
327
+					throw new Exception('Trying to decrease negative align.');
328
+		}
329
+		if($align == 0) {
330
+					return;
331
+		}
320 332
 		$align = $this->alignment - $align;
321 333
 		$this->setAlignment($align);
322 334
 	}
323 335
 	public function setAlignment($align) {
324
-		if($this->alignment == $align)
325
-			return;
336
+		if($this->alignment == $align) {
337
+					return;
338
+		}
326 339
 		$this->alignment = $align;
327 340
 		$this->hasChanged=true;
328 341
 	}
@@ -336,8 +349,9 @@  discard block
 block discarded – undo
336 349
 	}
337 350
 
338 351
 	public function getNextLevelPercentAcquired() {
339
-		if($this->getNextLevelExperience() == $this->getThisLevelExperience())
340
-			return 100;
352
+		if($this->getNextLevelExperience() == $this->getThisLevelExperience()) {
353
+					return 100;
354
+		}
341 355
 		return max(0,min(100,round(($this->getExperience() - $this->getThisLevelExperience()) / ($this->getNextLevelExperience() - $this->getThisLevelExperience())*100)));
342 356
 	}
343 357
 
@@ -347,8 +361,10 @@  discard block
 block discarded – undo
347 361
 
348 362
 	public function getNextLevelExperience() {
349 363
 		$LEVELS_REQUIREMENTS = Globals::getLevelRequirements();
350
-		if(!isset($LEVELS_REQUIREMENTS[$this->getLevelID()+1]))
351
-			return $this->getThisLevelExperience(); //Return current level experience if on last level.
364
+		if(!isset($LEVELS_REQUIREMENTS[$this->getLevelID()+1])) {
365
+					return $this->getThisLevelExperience();
366
+		}
367
+		//Return current level experience if on last level.
352 368
 		return $LEVELS_REQUIREMENTS[$this->getLevelID()+1]['Requirement'];
353 369
 	}
354 370
 
@@ -358,12 +374,15 @@  discard block
 block discarded – undo
358 374
 	}
359 375
 
360 376
 	public function setExperience($experience) {
361
-		if($this->experience == $experience)
362
-			return;
363
-		if($experience<MIN_EXPERIENCE)
364
-			$experience = MIN_EXPERIENCE;
365
-		if($experience>MAX_EXPERIENCE)
366
-			$experience = MAX_EXPERIENCE;
377
+		if($this->experience == $experience) {
378
+					return;
379
+		}
380
+		if($experience<MIN_EXPERIENCE) {
381
+					$experience = MIN_EXPERIENCE;
382
+		}
383
+		if($experience>MAX_EXPERIENCE) {
384
+					$experience = MAX_EXPERIENCE;
385
+		}
367 386
 		$this->experience = $experience;
368 387
 		$this->hasChanged=true;
369 388
 
@@ -373,46 +392,57 @@  discard block
 block discarded – undo
373 392
 	}
374 393
 
375 394
 	public function increaseCredits($credits) {
376
-		if($credits < 0)
377
-			throw new Exception('Trying to increase negative credits.');
378
-		if($credits == 0)
379
-			return;
395
+		if($credits < 0) {
396
+					throw new Exception('Trying to increase negative credits.');
397
+		}
398
+		if($credits == 0) {
399
+					return;
400
+		}
380 401
 		$credits += $this->credits;
381 402
 		$this->setCredits($credits);
382 403
 	}
383 404
 	public function decreaseCredits($credits) {
384
-		if($credits < 0)
385
-			throw new Exception('Trying to decrease negative credits.');
386
-		if($credits == 0)
387
-			return;
405
+		if($credits < 0) {
406
+					throw new Exception('Trying to decrease negative credits.');
407
+		}
408
+		if($credits == 0) {
409
+					return;
410
+		}
388 411
 		$credits = $this->credits - $credits;
389 412
 		$this->setCredits($credits);
390 413
 	}
391 414
 	public function setCredits($credits) {
392
-		if($this->credits == $credits)
393
-			return;
394
-		if($credits < 0)
395
-			throw new Exception('Trying to set negative credits.');
396
-		if($credits > MAX_MONEY)
397
-			$credits = MAX_MONEY;
415
+		if($this->credits == $credits) {
416
+					return;
417
+		}
418
+		if($credits < 0) {
419
+					throw new Exception('Trying to set negative credits.');
420
+		}
421
+		if($credits > MAX_MONEY) {
422
+					$credits = MAX_MONEY;
423
+		}
398 424
 		$this->credits = $credits;
399 425
 		$this->hasChanged=true;
400 426
 	}
401 427
 
402 428
 	public function increaseExperience($experience) {
403
-		if($experience < 0)
404
-			throw new Exception('Trying to increase negative experience.');
405
-		if($experience == 0)
406
-			return;
429
+		if($experience < 0) {
430
+					throw new Exception('Trying to increase negative experience.');
431
+		}
432
+		if($experience == 0) {
433
+					return;
434
+		}
407 435
 		$newExperience = $this->experience + $experience;
408 436
 		$this->setExperience($newExperience);
409 437
 		$this->increaseHOF($experience,array('Experience','Total','Gain'), HOF_PUBLIC);
410 438
 	}
411 439
 	public function decreaseExperience($experience) {
412
-		if($experience < 0)
413
-			throw new Exception('Trying to decrease negative experience.');
414
-		if($experience == 0)
415
-			return;
440
+		if($experience < 0) {
441
+					throw new Exception('Trying to decrease negative experience.');
442
+		}
443
+		if($experience == 0) {
444
+					return;
445
+		}
416 446
 		$newExperience = $this->experience - $experience;
417 447
 		$this->setExperience($newExperience);
418 448
 		$this->decreaseHOF($experience,array('Experience','Total','Loss'), HOF_PUBLIC);
@@ -423,8 +453,9 @@  discard block
 block discarded – undo
423 453
 	}
424 454
 
425 455
 	public function setLandedOnPlanet($bool) {
426
-		if($this->landedOnPlanet == $bool)
427
-			return;
456
+		if($this->landedOnPlanet == $bool) {
457
+					return;
458
+		}
428 459
 		$this->landedOnPlanet=$bool;
429 460
 		$this->hasChanged=true;
430 461
 	}
@@ -438,7 +469,9 @@  discard block
 block discarded – undo
438 469
 		if ($this->level === null) {
439 470
 			$LEVELS_REQUIREMENTS = Globals::getLevelRequirements();
440 471
 			foreach ($LEVELS_REQUIREMENTS as $level_id => $require) {
441
-				if ($this->getExperience() >= $require['Requirement']) continue;
472
+				if ($this->getExperience() >= $require['Requirement']) {
473
+					continue;
474
+				}
442 475
 				$this->level = $level_id - 1;
443 476
 				return $this->level;
444 477
 			}
@@ -516,8 +549,9 @@  discard block
 block discarded – undo
516 549
 	}
517 550
 
518 551
 	public function setRaceID($raceID) {
519
-		if($this->raceID == $raceID)
520
-			return;
552
+		if($this->raceID == $raceID) {
553
+					return;
554
+		}
521 555
 		$this->raceID=$raceID;
522 556
 		$this->hasChanged=true;
523 557
 	}
@@ -539,8 +573,9 @@  discard block
 block discarded – undo
539 573
 	}
540 574
 
541 575
 	public function setAllianceID($ID) {
542
-		if($this->allianceID == $ID)
543
-			return;
576
+		if($this->allianceID == $ID) {
577
+					return;
578
+		}
544 579
 		$this->allianceID=$ID;
545 580
 		if ($this->allianceID != 0) {
546 581
 			$status = $this->hasNewbieStatus() ? 'NEWBIE' : 'VETERAN';
@@ -557,8 +592,7 @@  discard block
 block discarded – undo
557 592
 	public function getAllianceName($linked=false, $includeAllianceID=false) {
558 593
 		if($this->hasAlliance()) {
559 594
 			return $this->getAlliance()->getAllianceName($linked, $includeAllianceID);
560
-		}
561
-		else {
595
+		} else {
562 596
 			return 'No Alliance';
563 597
 		}
564 598
 	}
@@ -590,8 +624,9 @@  discard block
 block discarded – undo
590 624
 	}
591 625
 
592 626
 	public function setCombatDronesKamikazeOnMines($bool) {
593
-		if($this->combatDronesKamikazeOnMines == $bool)
594
-			return;
627
+		if($this->combatDronesKamikazeOnMines == $bool) {
628
+					return;
629
+		}
595 630
 		$this->combatDronesKamikazeOnMines = $bool;
596 631
 		$this->hasChanged=true;
597 632
 	}
@@ -608,15 +643,17 @@  discard block
 block discarded – undo
608 643
 			$gadgetID = $GADGETS[$gadgetID]['ID'];
609 644
 		}
610 645
 		$gadgets = $this->getGadgets();
611
-		if(isset($gadgets[$gadgetID]))
612
-			return $gadgets[$gadgetID];
646
+		if(isset($gadgets[$gadgetID])) {
647
+					return $gadgets[$gadgetID];
648
+		}
613 649
 		return false;
614 650
 	}
615 651
 
616 652
 	public function isGadgetEquipped($gadgetID) {
617 653
 		$gadget = $this->getGadget($gadgetID);
618
-		if($gadget===false)
619
-			return false;
654
+		if($gadget===false) {
655
+					return false;
656
+		}
620 657
 		return $gadget['Equipped'] > 0 && $gadget['Equipped'] < TIME && ($gadget['Expires'] == 0 || $gadget['Expires'] > TIME) && $gadget['Cooldown'] <= TIME;
621 658
 	}
622 659
 
@@ -688,21 +725,24 @@  discard block
 block discarded – undo
688 725
 	}
689 726
 
690 727
 	public function setMilitaryPayment($amount) {
691
-		if($this->militaryPayment == $amount)
692
-			return;
728
+		if($this->militaryPayment == $amount) {
729
+					return;
730
+		}
693 731
 		$this->militaryPayment = $amount;
694 732
 		$this->hasChanged=true;
695 733
 	}
696 734
 
697 735
 	public function increaseMilitaryPayment($amount) {
698
-		if($amount < 0)
699
-			throw new Exception('Trying to increase negative military payment.');
736
+		if($amount < 0) {
737
+					throw new Exception('Trying to increase negative military payment.');
738
+		}
700 739
 		$this->setMilitaryPayment($this->getMilitaryPayment()+$amount);
701 740
 	}
702 741
 
703 742
 	public function decreaseMilitaryPayment($amount) {
704
-		if($amount < 0)
705
-			throw new Exception('Trying to decrease negative military payment.');
743
+		if($amount < 0) {
744
+					throw new Exception('Trying to decrease negative military payment.');
745
+		}
706 746
 		$this->setMilitaryPayment($this->getMilitaryPayment()-$amount);
707 747
 	}
708 748
 
@@ -744,10 +784,11 @@  discard block
 block discarded – undo
744 784
 
745 785
 	public function getNextBountyID() {
746 786
 		$keys = array_keys($this->getBounties());
747
-		if(count($keys)>0)
748
-			return max($keys)+1;
749
-		else
750
-			return 0;
787
+		if(count($keys)>0) {
788
+					return max($keys)+1;
789
+		} else {
790
+					return 0;
791
+		}
751 792
 	}
752 793
 
753 794
 	public function setBounty(array $bounty) {
@@ -762,22 +803,25 @@  discard block
 block discarded – undo
762 803
 	}
763 804
 
764 805
 	public function increaseBountyAmount($bountyID,$amount) {
765
-		if($amount < 0)
766
-			throw new Exception('Trying to increase negative bounty.');
806
+		if($amount < 0) {
807
+					throw new Exception('Trying to increase negative bounty.');
808
+		}
767 809
 		$this->setBountyAmount($this->getBountyAmount($bountyID)+$amount);
768 810
 	}
769 811
 
770 812
 	public function decreaseBountyAmount($bountyID,$amount) {
771
-		if($amount < 0)
772
-			throw new Exception('Trying to decrease negative bounty.');
813
+		if($amount < 0) {
814
+					throw new Exception('Trying to decrease negative bounty.');
815
+		}
773 816
 		$this->setBountyAmount($this->getBountyAmount($bountyID)+$amount);
774 817
 	}
775 818
 
776 819
 	public function getCurrentBounty($type) {
777 820
 		$bounties = $this->getBounties();
778 821
 		foreach($bounties as $bounty) {
779
-			if($bounty['Claimer'] == 0 && $bounty['Type']==$type)
780
-				return $bounty;
822
+			if($bounty['Claimer'] == 0 && $bounty['Type']==$type) {
823
+							return $bounty;
824
+			}
781 825
 		}
782 826
 		return $this->createBounty($type);
783 827
 	}
@@ -785,8 +829,9 @@  discard block
 block discarded – undo
785 829
 	public function hasCurrentBounty($type) {
786 830
 		$bounties = $this->getBounties();
787 831
 		foreach($bounties as $bounty) {
788
-			if($bounty['Claimer'] == 0 && $bounty['Type']==$type)
789
-				return true;
832
+			if($bounty['Claimer'] == 0 && $bounty['Type']==$type) {
833
+							return true;
834
+			}
790 835
 		}
791 836
 		return false;
792 837
 	}
@@ -798,21 +843,24 @@  discard block
 block discarded – undo
798 843
 
799 844
 	public function setCurrentBountyAmount($type, $amount) {
800 845
 		$bounty = $this->getCurrentBounty($type);
801
-		if($bounty['Amount'] == $amount)
802
-			return;
846
+		if($bounty['Amount'] == $amount) {
847
+					return;
848
+		}
803 849
 		$bounty['Amount'] = $amount;
804 850
 		$this->setBounty($bounty);
805 851
 	}
806 852
 
807 853
 	public function increaseCurrentBountyAmount($type,$amount) {
808
-		if($amount < 0)
809
-			throw new Exception('Trying to increase negative current bounty.');
854
+		if($amount < 0) {
855
+					throw new Exception('Trying to increase negative current bounty.');
856
+		}
810 857
 		$this->setCurrentBountyAmount($type,$this->getCurrentBountyAmount($type)+$amount);
811 858
 	}
812 859
 
813 860
 	public function decreaseCurrentBountyAmount($type,$amount) {
814
-		if($amount < 0)
815
-			throw new Exception('Trying to decrease negative current bounty.');
861
+		if($amount < 0) {
862
+					throw new Exception('Trying to decrease negative current bounty.');
863
+		}
816 864
 		$this->setCurrentBountyAmount($type,$this->getCurrentBountyAmount($type)-$amount);
817 865
 	}
818 866
 
@@ -823,21 +871,24 @@  discard block
 block discarded – undo
823 871
 
824 872
 	public function setCurrentBountySmrCredits($type, $credits) {
825 873
 		$bounty = $this->getCurrentBounty($type);
826
-		if($bounty['SmrCredits'] == $credits)
827
-			return;
874
+		if($bounty['SmrCredits'] == $credits) {
875
+					return;
876
+		}
828 877
 		$bounty['SmrCredits'] = $credits;
829 878
 		$this->setBounty($bounty);
830 879
 	}
831 880
 
832 881
 	public function increaseCurrentBountySmrCredits($type,$credits) {
833
-		if($credits<0)
834
-			throw new Exception('Trying to increase negative current bounty.');
882
+		if($credits<0) {
883
+					throw new Exception('Trying to increase negative current bounty.');
884
+		}
835 885
 		$this->setCurrentBountySmrCredits($type,$this->getCurrentBountySmrCredits($type)+$credits);
836 886
 	}
837 887
 
838 888
 	public function decreaseCurrentBountySmrCredits($type,$credits) {
839
-		if($credits<0)
840
-			throw new Exception('Trying to decrease negative current bounty.');
889
+		if($credits<0) {
890
+					throw new Exception('Trying to decrease negative current bounty.');
891
+		}
841 892
 		$this->setCurrentBountySmrCredits($type,$this->getCurrentBountySmrCredits($type)-$credits);
842 893
 	}
843 894
 
@@ -858,51 +909,59 @@  discard block
 block discarded – undo
858 909
 
859 910
 	public function getHOF(array $typeList = null) {
860 911
 		$this->getHOFData();
861
-		if($typeList==null)
862
-			return $this->HOF;
912
+		if($typeList==null) {
913
+					return $this->HOF;
914
+		}
863 915
 		$hof=$this->HOF;
864 916
 		foreach($typeList as $type) {
865
-			if(!isset($hof[$type]))
866
-				return 0;
917
+			if(!isset($hof[$type])) {
918
+							return 0;
919
+			}
867 920
 			$hof = $hof[$type];
868 921
 		}
869 922
 		return $hof;
870 923
 	}
871 924
 
872 925
 	public function increaseHOF($amount,array $typeList, $visibility) {
873
-		if($amount < 0)
874
-			throw new Exception('Trying to increase negative HOF: '.implode(':',$typeList));
875
-		if($amount == 0)
876
-			return;
926
+		if($amount < 0) {
927
+					throw new Exception('Trying to increase negative HOF: '.implode(':',$typeList));
928
+		}
929
+		if($amount == 0) {
930
+					return;
931
+		}
877 932
 		$this->setHOF($this->getHOF($typeList)+$amount,$typeList, $visibility);
878 933
 	}
879 934
 
880 935
 	public function decreaseHOF($amount,array $typeList, $visibility) {
881
-		if($amount < 0)
882
-			throw new Exception('Trying to decrease negative HOF: '.implode(':',$typeList));
883
-		if($amount == 0)
884
-			return;
936
+		if($amount < 0) {
937
+					throw new Exception('Trying to decrease negative HOF: '.implode(':',$typeList));
938
+		}
939
+		if($amount == 0) {
940
+					return;
941
+		}
885 942
 		$this->setHOF($this->getHOF($typeList)-$amount,$typeList, $visibility);
886 943
 	}
887 944
 
888 945
 	public function setHOF($amount,array $typeList, $visibility) {
889
-		if(is_array($this->getHOF($typeList)))
890
-			throw new Exception('Trying to overwrite a HOF type: '.implode(':',$typeList));
946
+		if(is_array($this->getHOF($typeList))) {
947
+					throw new Exception('Trying to overwrite a HOF type: '.implode(':',$typeList));
948
+		}
891 949
 		if($this->isNPC()) {
892 950
 			// Don't store HOF for NPCs.
893 951
 			return;
894 952
 		}
895
-		if($this->getHOF($typeList)==$amount)
896
-			return;
897
-		if($amount < 0)
898
-			$amount=0;
953
+		if($this->getHOF($typeList)==$amount) {
954
+					return;
955
+		}
956
+		if($amount < 0) {
957
+					$amount=0;
958
+		}
899 959
 		$this->getHOF();
900 960
 
901 961
 		$hofType = implode(':',$typeList);
902 962
 		if(!isset(self::$HOFVis[$hofType])) {
903 963
 			self::$hasHOFVisChanged[$hofType] = self::HOF_NEW;
904
-		}
905
-		else if(self::$HOFVis[$hofType] != $visibility) {
964
+		} else if(self::$HOFVis[$hofType] != $visibility) {
906 965
 			self::$hasHOFVisChanged[$hofType] = self::HOF_CHANGED;
907 966
 		}
908 967
 		self::$HOFVis[$hofType] = $visibility;
@@ -911,8 +970,9 @@  discard block
 block discarded – undo
911 970
 		$hofChanged =& $this->hasHOFChanged;
912 971
 		$new = false;
913 972
 		foreach($typeList as $type) {
914
-			if(!isset($hofChanged[$type]))
915
-				$hofChanged[$type] = array();
973
+			if(!isset($hofChanged[$type])) {
974
+							$hofChanged[$type] = array();
975
+			}
916 976
 			if(!isset($hof[$type])) {
917 977
 				$hof[$type] = array();
918 978
 				$new = true;
@@ -922,8 +982,9 @@  discard block
 block discarded – undo
922 982
 		}
923 983
 		if($hofChanged==null) {
924 984
 			$hofChanged = self::HOF_CHANGED;
925
-			if($new)
926
-				$hofChanged = self::HOF_NEW;
985
+			if($new) {
986
+							$hofChanged = self::HOF_NEW;
987
+			}
927 988
 		}
928 989
 		$hof = $amount;
929 990
 	}
@@ -949,16 +1010,19 @@  discard block
 block discarded – undo
949 1010
 	}
950 1011
 
951 1012
 	public function setTurns($turns,$newNoob = false,$updateLastActive = false) {
952
-		if($this->turns == $turns && ($this->newbieTurns == $newNoob || $newNoob==false) && !$updateLastActive)
953
-			return;
1013
+		if($this->turns == $turns && ($this->newbieTurns == $newNoob || $newNoob==false) && !$updateLastActive) {
1014
+					return;
1015
+		}
954 1016
 
955 1017
 		// Make sure turns are in range [0, MaxTurns]
956 1018
 		$this->turns = max(0, min($turns, $this->getMaxTurns()));
957 1019
 
958
-		if($newNoob !== false)
959
-			$this->newbieTurns = $newNoob;
960
-		if ($this->newbieTurns < 0)
961
-			$this->newbieTurns = 0;
1020
+		if($newNoob !== false) {
1021
+					$this->newbieTurns = $newNoob;
1022
+		}
1023
+		if ($this->newbieTurns < 0) {
1024
+					$this->newbieTurns = 0;
1025
+		}
962 1026
 
963 1027
 		$this->hasChanged=true;
964 1028
 		if($updateLastActive === true) {
@@ -968,8 +1032,9 @@  discard block
 block discarded – undo
968 1032
 	}
969 1033
 
970 1034
 	public function takeTurns($take, $noob = 0, $updateLastActive = true) {
971
-		if($take < 0 || $noob < 0)
972
-			throw new Exception('Trying to take negative turns.');
1035
+		if($take < 0 || $noob < 0) {
1036
+					throw new Exception('Trying to take negative turns.');
1037
+		}
973 1038
 		$take = ceil($take);
974 1039
 		$new_turns = $this->getTurns() - $take;
975 1040
 		$newbiesTaken = min($this->getNewbieTurns(),$noob);
@@ -982,8 +1047,9 @@  discard block
 block discarded – undo
982 1047
 	}
983 1048
 
984 1049
 	public function giveTurns($give, $noob = 0,$updateLastActive = false) {
985
-		if($give < 0 || $noob < 0)
986
-			throw new Exception('Trying to give negative turns.');
1050
+		if($give < 0 || $noob < 0) {
1051
+					throw new Exception('Trying to give negative turns.');
1052
+		}
987 1053
 		$give = floor($give);
988 1054
 
989 1055
 		$this->setTurns($this->getTurns() + $give, $this->getNewbieTurns() + $noob, $updateLastActive);
@@ -994,8 +1060,9 @@  discard block
 block discarded – undo
994 1060
 	}
995 1061
 
996 1062
 	public function setLastActive($lastActive) {
997
-		if($this->lastActive == $lastActive)
998
-			return;
1063
+		if($this->lastActive == $lastActive) {
1064
+					return;
1065
+		}
999 1066
 		$this->lastActive=$lastActive;
1000 1067
 		$this->hasChanged=true;
1001 1068
 	}
@@ -1005,8 +1072,9 @@  discard block
 block discarded – undo
1005 1072
 	}
1006 1073
 
1007 1074
 	public function setLastCPLAction($time) {
1008
-		if($this->lastCPLAction == $time)
1009
-			return;
1075
+		if($this->lastCPLAction == $time) {
1076
+					return;
1077
+		}
1010 1078
 		$this->lastCPLAction=$time;
1011 1079
 		$this->hasChanged=true;
1012 1080
 	}
@@ -1021,8 +1089,9 @@  discard block
 block discarded – undo
1021 1089
 			//Get Player missions
1022 1090
 			$this->db->query('SELECT mission_id FROM player_completed_mission WHERE ' . $this->SQL);
1023 1091
 			$this->completedMissions = array();
1024
-			while ($this->db->nextRecord())
1025
-				$this->completedMissions[$this->db->getField('mission_id')] = $this->db->getField('mission_id');
1092
+			while ($this->db->nextRecord()) {
1093
+							$this->completedMissions[$this->db->getField('mission_id')] = $this->db->getField('mission_id');
1094
+			}
1026 1095
 		}
1027 1096
 		return $this->completedMissions;
1028 1097
 	}
@@ -1059,8 +1128,9 @@  discard block
 block discarded – undo
1059 1128
 
1060 1129
 	function getMission($missionID) {
1061 1130
 		$missions = $this->getMissions();
1062
-		if(isset($missions[$missionID]))
1063
-			return $missions[$missionID];
1131
+		if(isset($missions[$missionID])) {
1132
+					return $missions[$missionID];
1133
+		}
1064 1134
 		return false;
1065 1135
 	}
1066 1136
 
@@ -1106,8 +1176,9 @@  discard block
 block discarded – undo
1106 1176
 	function addMission($missionID) {
1107 1177
 		$this->getMissions();
1108 1178
 
1109
-		if(isset($this->missions[$missionID]))
1110
-			return;
1179
+		if(isset($this->missions[$missionID])) {
1180
+					return;
1181
+		}
1111 1182
 		$sector = 0;
1112 1183
 
1113 1184
 		$mission = array(
@@ -1136,8 +1207,7 @@  discard block
 block discarded – undo
1136 1207
 		if ($mission['On Step'] >= count(MISSIONS[$missionID]['Steps'])) {
1137 1208
 			// If we have completed this mission just use false to indicate no current task.
1138 1209
 			$currentStep = false;
1139
-		}
1140
-		else {
1210
+		} else {
1141 1211
 			$currentStep = MISSIONS[$missionID]['Steps'][$mission['On Step']];
1142 1212
 			$currentStep['Text'] = str_replace(array('<Race>','<Sector>','<Starting Sector>','<trader>'),array($this->getRaceID(),$mission['Sector'],$mission['Starting Sector'],$this->playerName),$currentStep['Text']);
1143 1213
 			if (isset($currentStep['Task'])) {
@@ -1145,8 +1215,7 @@  discard block
 block discarded – undo
1145 1215
 			}
1146 1216
 			if (isset($currentStep['Level'])) {
1147 1217
 				$currentStep['Level'] = str_replace('<Player Level>',$this->levelID,$currentStep['Level']);
1148
-			}
1149
-			else {
1218
+			} else {
1150 1219
 				$currentStep['Level'] = 0;
1151 1220
 			}
1152 1221
 		}
@@ -1274,12 +1343,15 @@  discard block
 block discarded – undo
1274 1343
 	}
1275 1344
 
1276 1345
 	public function canSee(AbstractSmrPlayer $otherPlayer) {
1277
-		if(!$otherPlayer->getShip()->isCloaked())
1278
-			return true;
1279
-		if($this->sameAlliance($otherPlayer))
1280
-			return true;
1281
-		if($this->getExperience()>=$otherPlayer->getExperience())
1282
-			return true;
1346
+		if(!$otherPlayer->getShip()->isCloaked()) {
1347
+					return true;
1348
+		}
1349
+		if($this->sameAlliance($otherPlayer)) {
1350
+					return true;
1351
+		}
1352
+		if($this->getExperience()>=$otherPlayer->getExperience()) {
1353
+					return true;
1354
+		}
1283 1355
 		return false;
1284 1356
 	}
1285 1357
 
@@ -1332,10 +1404,12 @@  discard block
 block discarded – undo
1332 1404
 	}
1333 1405
 
1334 1406
 	public function meetsAlignmentRestriction($restriction) {
1335
-		if($restriction<0)
1336
-			return $this->getAlignment()<=$restriction;
1337
-		if($restriction>0)
1338
-			return $this->getAlignment()>=$restriction;
1407
+		if($restriction<0) {
1408
+					return $this->getAlignment()<=$restriction;
1409
+		}
1410
+		if($restriction>0) {
1411
+					return $this->getAlignment()>=$restriction;
1412
+		}
1339 1413
 		return true;
1340 1414
 	}
1341 1415
 
@@ -1358,8 +1432,9 @@  discard block
 block discarded – undo
1358 1432
 		if(!isset($this->visitedSectors)) {
1359 1433
 			$this->visitedSectors = array();
1360 1434
 			$this->db->query('SELECT sector_id FROM player_visited_sector WHERE ' . $this->SQL);
1361
-			while($this->db->nextRecord())
1362
-				$this->visitedSectors[$this->db->getField('sector_id')] = false;
1435
+			while($this->db->nextRecord()) {
1436
+							$this->visitedSectors[$this->db->getField('sector_id')] = false;
1437
+			}
1363 1438
 		}
1364 1439
 		return !isset($this->visitedSectors[$sectorID]);
1365 1440
 	}
Please login to merge, or discard this patch.
lib/Default/Plotter.class.inc 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -94,12 +94,14 @@  discard block
 block discarded – undo
94 94
 		$sectorsTravelled = 0;
95 95
 		$visitedSectors = array();
96 96
 		$visitedSectors[$checkSector->getSectorID()] = true;
97
-		if($x=='Distance')
98
-			$distances[0][$checkSector->getSectorID()] = new Distance($gameID,$checkSector->getSectorID());
97
+		if($x=='Distance') {
98
+					$distances[0][$checkSector->getSectorID()] = new Distance($gameID,$checkSector->getSectorID());
99
+		}
99 100
 
100 101
 		$distanceQ = array();
101
-		for($i=0;$i<=TURNS_WARP_SECTOR_EQUIVALENCE;$i++)
102
-			$distanceQ[] = array();
102
+		for($i=0;$i<=TURNS_WARP_SECTOR_EQUIVALENCE;$i++) {
103
+					$distanceQ[] = array();
104
+		}
103 105
 		//Warps first as a slight optimisation due to how visitedSectors is set.
104 106
 		if($checkSector->hasWarp()===true) {
105 107
 			$d = new Distance($gameID,$checkSector->getSectorID());
@@ -117,8 +119,9 @@  discard block
 block discarded – undo
117 119
 		$maybeWarps=0;
118 120
 		while ($maybeWarps<=TURNS_WARP_SECTOR_EQUIVALENCE) {
119 121
 			$sectorsTravelled++;
120
-			if ($sectorsTravelled > $distanceLimit)
121
-				return $distances;
122
+			if ($sectorsTravelled > $distanceLimit) {
123
+							return $distances;
124
+			}
122 125
 			if($x=='Distance') {
123 126
 				$distances[$sectorsTravelled] = array();
124 127
 			}
@@ -136,11 +139,11 @@  discard block
 block discarded – undo
136 139
 					$checkSector = SmrSector::getSector($gameID,$checkSectorID);
137 140
 					if($x=='Distance') {
138 141
 						$distances[$sectorsTravelled][$checkSector->getSectorID()] = $distance;
139
-					}
140
-					else if (($needsToHaveBeenExploredBy===null||$needsToHaveBeenExploredBy->hasVisitedSector($checkSector->getSectorID()))===true
142
+					} else if (($needsToHaveBeenExploredBy===null||$needsToHaveBeenExploredBy->hasVisitedSector($checkSector->getSectorID()))===true
141 143
 							&& $checkSector->hasX($x,$player)===true) {
142
-						if($useFirst===true)
143
-							return $distance;
144
+						if($useFirst===true) {
145
+													return $distance;
146
+						}
144 147
 						$distances[$checkSector->getSectorID()] = $distance;
145 148
 					}
146 149
 					//Warps first as a slight optimisation due to how visitedSectors is set.
Please login to merge, or discard this patch.
lib/Default/SmrPlanet.class.inc 1 patch
Braces   +47 added lines, -54 removed lines patch added patch discarded remove patch
@@ -138,26 +138,19 @@  discard block
 block discarded – undo
138 138
 		$level = $this->getLevel();
139 139
 		if ($level < 9) {
140 140
 			return .0404;
141
-		}
142
-		elseif ($level < 19) {
141
+		} elseif ($level < 19) {
143 142
 			return .0609;
144
-		}
145
-		elseif ($level < 29) {
143
+		} elseif ($level < 29) {
146 144
 			return .1236;
147
-		}
148
-		elseif ($level < 39) {
145
+		} elseif ($level < 39) {
149 146
 			return .050625;
150
-		}
151
-		elseif ($level < 49) {
147
+		} elseif ($level < 49) {
152 148
 			return .0404;
153
-		}
154
-		elseif ($level < 59) {
149
+		} elseif ($level < 59) {
155 150
 			return .030225;
156
-		}
157
-		elseif ($level < 69) {
151
+		} elseif ($level < 69) {
158 152
 			return .0201;
159
-		}
160
-		else {
153
+		} else {
161 154
 			return .018081;
162 155
 		}
163 156
 	}
@@ -366,8 +359,7 @@  discard block
 block discarded – undo
366 359
 		}
367 360
 		if($delayed===false) {
368 361
 			$this->setShields($this->getShields() - $number);
369
-		}
370
-		else {
362
+		} else {
371 363
 			$this->delayedShieldsDelta -= $number;
372 364
 		}
373 365
 	}
@@ -378,8 +370,7 @@  discard block
 block discarded – undo
378 370
 		}
379 371
 		if($delayed===false) {
380 372
 			$this->setShields($this->getShields() + $number);
381
-		}
382
-		else {
373
+		} else {
383 374
 			$this->delayedShieldsDelta += $number;
384 375
 		}
385 376
 	}
@@ -411,8 +402,7 @@  discard block
 block discarded – undo
411 402
 		}
412 403
 		if($delayed===false) {
413 404
 			$this->setArmour($this->getArmour() - $number);
414
-		}
415
-		else {
405
+		} else {
416 406
 			$this->delayedArmourDelta -= $number;
417 407
 		}
418 408
 	}
@@ -423,8 +413,7 @@  discard block
 block discarded – undo
423 413
 		}
424 414
 		if($delayed===false) {
425 415
 			$this->setArmour($this->getArmour() + $number);
426
-		}
427
-		else {
416
+		} else {
428 417
 			$this->delayedArmourDelta += $number;
429 418
 		}
430 419
 	}
@@ -456,8 +445,7 @@  discard block
 block discarded – undo
456 445
 		}
457 446
 		if($delayed===false) {
458 447
 			$this->setCDs($this->getCDs() - $number);
459
-		}
460
-		else {
448
+		} else {
461 449
 			$this->delayedCDsDelta -= $number;
462 450
 		}
463 451
 	}
@@ -468,8 +456,7 @@  discard block
 block discarded – undo
468 456
 		}
469 457
 		if($delayed===false) {
470 458
 			$this->setCDs($this->getCDs() + $number);
471
-		}
472
-		else {
459
+		} else {
473 460
 			$this->delayedCDsDelta += $number;
474 461
 		}
475 462
 	}
@@ -569,13 +556,16 @@  discard block
 block discarded – undo
569 556
 			// get supplies from db
570 557
 			$this->db->query('SELECT good_id, amount FROM planet_has_cargo WHERE ' . $this->SQL);
571 558
 			// adding cargo and amount to array
572
-			while ($this->db->nextRecord())
573
-				$this->stockpile[$this->db->getInt('good_id')] = $this->db->getInt('amount');
559
+			while ($this->db->nextRecord()) {
560
+							$this->stockpile[$this->db->getInt('good_id')] = $this->db->getInt('amount');
561
+			}
562
+		}
563
+		if($goodID===false) {
564
+					return $this->stockpile;
565
+		}
566
+		if(isset($this->stockpile[$goodID])) {
567
+					return $this->stockpile[$goodID];
574 568
 		}
575
-		if($goodID===false)
576
-			return $this->stockpile;
577
-		if(isset($this->stockpile[$goodID]))
578
-			return $this->stockpile[$goodID];
579 569
 		return 0;
580 570
 	}
581 571
 
@@ -583,8 +573,7 @@  discard block
 block discarded – undo
583 573
 		if($goodID===false) {
584 574
 			$stockpile = $this->getStockpile($goodID);
585 575
 			return count($stockpile) > 0 && max($stockpile) > 0;
586
-		}
587
-		else {
576
+		} else {
588 577
 			return $this->getStockpile($goodID) > 0;
589 578
 		}
590 579
 	}
@@ -601,14 +590,16 @@  discard block
 block discarded – undo
601 590
 	}
602 591
 
603 592
 	public function decreaseStockpile($goodID,$amount) {
604
-		if($amount < 0)
605
-			throw new Exception('Trying to decrease negative stockpile.');
593
+		if($amount < 0) {
594
+					throw new Exception('Trying to decrease negative stockpile.');
595
+		}
606 596
 		$this->setStockpile($goodID,$this->getStockpile($goodID) - $amount);
607 597
 	}
608 598
 
609 599
 	public function increaseStockpile($goodID,$amount) {
610
-		if($amount < 0)
611
-			throw new Exception('Trying to increase negative stockpile.');
600
+		if($amount < 0) {
601
+					throw new Exception('Trying to increase negative stockpile.');
602
+		}
612 603
 		$this->setStockpile($goodID,$this->getStockpile($goodID) + $amount);
613 604
 	}
614 605
 
@@ -642,8 +633,9 @@  discard block
 block discarded – undo
642 633
 	}
643 634
 
644 635
 	public function setBuilding($buildingTypeID,$number) {
645
-		if($this->getBuilding($buildingTypeID) == $number)
646
-			return;
636
+		if($this->getBuilding($buildingTypeID) == $number) {
637
+					return;
638
+		}
647 639
 
648 640
 		$this->buildings[$buildingTypeID] = $number;
649 641
 		$this->hasChangedBuildings[$buildingTypeID] = true;
@@ -815,8 +807,7 @@  discard block
 block discarded – undo
815 807
 				if ($amount != 0) {
816 808
 					$this->db->query('REPLACE INTO planet_has_cargo (game_id, sector_id, good_id, amount) ' .
817 809
 										 'VALUES(' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeNumber($this->getSectorID()) . ', ' . $this->db->escapeNumber($id) . ', ' . $this->db->escapeNumber($amount) . ')');
818
-				}
819
-				else {
810
+				} else {
820 811
 					$this->db->query('DELETE FROM planet_has_cargo WHERE ' . $this->SQL . '
821 812
 										AND good_id = ' . $this->db->escapeNumber($id));
822 813
 				}
@@ -844,8 +835,7 @@  discard block
 block discarded – undo
844 835
 				if ($this->hasBuilding($id)) {
845 836
 					$this->db->query('REPLACE INTO planet_has_building (game_id, sector_id, construction_id, amount) ' .
846 837
 										'VALUES(' . $this->db->escapeNumber($this->gameID) . ', ' . $this->db->escapeNumber($this->sectorID) . ', ' . $this->db->escapeNumber($id) . ', ' . $this->db->escapeNumber($this->getBuilding($id)) . ')');
847
-				}
848
-				else {
838
+				} else {
849 839
 					$this->db->query('DELETE FROM planet_has_building WHERE ' . $this->SQL . '
850 840
 										AND construction_id = ' . $this->db->escapeNumber($id));
851 841
 				}
@@ -1090,23 +1080,27 @@  discard block
 block discarded – undo
1090 1080
 	}
1091 1081
 
1092 1082
 	public function hasEnemyTraders(AbstractSmrPlayer $player) {
1093
-		if(!$this->hasOtherTraders($player))
1094
-			return false;
1083
+		if(!$this->hasOtherTraders($player)) {
1084
+					return false;
1085
+		}
1095 1086
 		$otherPlayers = $this->getOtherTraders($player);
1096 1087
 		foreach($otherPlayers as $otherPlayer) {
1097
-			if(!$player->traderNAPAlliance($otherPlayer))
1098
-				return true;
1088
+			if(!$player->traderNAPAlliance($otherPlayer)) {
1089
+							return true;
1090
+			}
1099 1091
 		}
1100 1092
 		return false;
1101 1093
 	}
1102 1094
 
1103 1095
 	public function hasFriendlyTraders(AbstractSmrPlayer $player) {
1104
-		if(!$this->hasOtherTraders($player))
1105
-			return false;
1096
+		if(!$this->hasOtherTraders($player)) {
1097
+					return false;
1098
+		}
1106 1099
 		$otherPlayers = $this->getOtherTraders($player);
1107 1100
 		foreach($otherPlayers as $otherPlayer) {
1108
-			if($player->traderNAPAlliance($otherPlayer))
1109
-				return true;
1101
+			if($player->traderNAPAlliance($otherPlayer)) {
1102
+							return true;
1103
+			}
1110 1104
 		}
1111 1105
 		return false;
1112 1106
 	}
@@ -1203,8 +1197,7 @@  discard block
 block discarded – undo
1203 1197
 					}
1204 1198
 				}
1205 1199
 
1206
-			}
1207
-			else { // hit drones behind shields - we should only use this reduced damage branch if we cannot hit shields.
1200
+			} else { // hit drones behind shields - we should only use this reduced damage branch if we cannot hit shields.
1208 1201
 				$cdDamage = $this->doCDDamage(floor(min($damage['MaxDamage'],$damage['Armour'])*DRONES_BEHIND_SHIELDS_DAMAGE_PERCENT),$delayed);
1209 1202
 			}
1210 1203
 		}
Please login to merge, or discard this patch.
lib/Default/Sorter.class.inc 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@
 block discarded – undo
20 20
 	}
21 21
 
22 22
 	public static function cmpNum($a, $b) {
23
-		if($a == $b) return 0;
23
+		if($a == $b) {
24
+			return 0;
25
+		}
24 26
 		return (self::$reverseOrder?-1:1)*($a < $b ? -1 : 1);
25 27
 	}
26 28
 
Please login to merge, or discard this patch.