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/shop_goods.inc 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function checkPortTradeable(&$port,&$player) {
4
-	if($port->getSectorID()!=$player->getSectorID())
3
+function checkPortTradeable(&$port, &$player) {
4
+	if ($port->getSectorID() != $player->getSectorID())
5 5
 		return 'That port is not in this sector!';
6 6
 	
7
-	if(!$port->exists())
7
+	if (!$port->exists())
8 8
 		return 'There is no port in this sector!';
9 9
 	
10
-	if($player->getRelation($port->getRaceID()) <= RELATIONS_WAR)
10
+	if ($player->getRelation($port->getRaceID()) <= RELATIONS_WAR)
11 11
 		return 'We will not trade with our enemies!';
12 12
 	
13
-	if($port->getReinforceTime() > TIME)
13
+	if ($port->getReinforceTime() > TIME)
14 14
 		return 'We are still repairing damage caused during the last raid.';
15 15
 	
16 16
 	return true;
17 17
 }
18 18
 
19
-function check_bargain_number($amount,$ideal_price,$offered_price,$bargain_price,&$container) {
19
+function check_bargain_number($amount, $ideal_price, $offered_price, $bargain_price, &$container) {
20 20
 	global $var, $player;
21 21
 
22 22
 	$port = $player->getSectorPort();
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 	if (isset($var['overall_number_of_bargains'])) {
28 28
 		// lose relations for bad bargain
29 29
 		if ($port->getRaceID() != RACE_NEUTRAL || $player->getRaceID() == RACE_ALSKANT) {
30
-			$player->decreaseRelationsByTrade($amount,$port->getRaceID());
30
+			$player->decreaseRelationsByTrade($amount, $port->getRaceID());
31 31
 		}
32
-		$player->increaseHOF(1,array('Trade','Results','Fail'), HOF_PUBLIC);
32
+		$player->increaseHOF(1, array('Trade', 'Results', 'Fail'), HOF_PUBLIC);
33 33
 		// transfer values
34 34
 		transfer('overall_number_of_bargains');
35 35
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 		if ($container['number_of_bargains'] > $container['overall_number_of_bargains']) {
38 38
 			// change relation for non neutral ports
39 39
 			if ($port->getRaceID() != RACE_NEUTRAL || $player->getRaceID() == RACE_ALSKANT) {
40
-				$player->decreaseRelationsByTrade($amount,$port->getRaceID());
40
+				$player->decreaseRelationsByTrade($amount, $port->getRaceID());
41 41
 			}
42
-			$player->increaseHOF(1,array('Trade','Results','Epic Fail'), HOF_PUBLIC);
42
+			$player->increaseHOF(1, array('Trade', 'Results', 'Epic Fail'), HOF_PUBLIC);
43 43
 			create_error('You don\'t want to accept my offer? I\'m sick of you! Get out of here!');
44 44
 		}
45 45
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 }
94 94
 
95 95
 function get_bargain_price() {
96
-	global $_REQUEST,$var;
96
+	global $_REQUEST, $var;
97 97
 
98 98
 	// we get it from form
99 99
 	if (isset($_REQUEST['bargain_price']))
Please login to merge, or discard this patch.
lib/Default/MySqlDatabase.class.inc 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 	protected $dbRecord = null;
8 8
 	
9 9
 	public function __construct($host, $user, $password, $dbName, $port, $socket) {
10
-		if(!self::$dbConn) {
10
+		if (!self::$dbConn) {
11 11
 			self::$dbConn = new mysqli($host, $user, $password, $dbName, $port, $socket);
12 12
 			if (self::$dbConn->connect_errno) {
13 13
 				$this->error('Connection failed: ' . self::$dbConn->connect_error);
@@ -33,17 +33,17 @@  discard block
 block discarded – undo
33 33
 	}
34 34
 	
35 35
 	public function query($query) {
36
-		if(!$this->dbResult = self::$dbConn->query($query)) {
36
+		if (!$this->dbResult = self::$dbConn->query($query)) {
37 37
 			$this->error('SQL query failed (' . $query . ')');
38 38
 			// the SQL error message will be reported by logException
39 39
 		}
40 40
 	}
41 41
 	
42 42
 	public function nextRecord() {
43
-		if(!$this->dbResult)
43
+		if (!$this->dbResult)
44 44
 			$this->error('No resource to get record from.');
45 45
 		
46
-		if($this->dbRecord = $this->dbResult->fetch_assoc()) {
46
+		if ($this->dbRecord = $this->dbResult->fetch_assoc()) {
47 47
 			return true;
48 48
 		}
49 49
 		return false;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	}
57 57
 	
58 58
 	public function getBoolean($name) {
59
-		if($this->dbRecord[$name] == 'TRUE')
59
+		if ($this->dbRecord[$name] == 'TRUE')
60 60
 			return true;
61 61
 //		if($this->dbRecord[$name] == 'FALSE')
62 62
 		return false;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	// For backwards compatibility, set $pad_msec=true to try to guess at the
76 76
 	// intended value. This is not safe if the Microtime length is wrong for an
77 77
 	// unrelated reason!
78
-	public function getMicrotime($name, $pad_msec=false) {
78
+	public function getMicrotime($name, $pad_msec = false) {
79 79
 		$data = $this->dbRecord[$name];
80 80
 		$sec  = substr($data, 0, 10);
81 81
 		$msec = substr($data, 10);
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 			if ($pad_msec) {
84 84
 				$msec = str_pad($msec, 6, '0', STR_PAD_LEFT);
85 85
 			} else {
86
-				throw new Exception('Field is not an escaped microtime ('.$data.')');
86
+				throw new Exception('Field is not an escaped microtime (' . $data . ')');
87 87
 			}
88 88
 		}
89 89
 		return "$sec.$msec";
90 90
 	}
91 91
 	
92
-	public function getObject($name,$compressed=false) {
92
+	public function getObject($name, $compressed = false) {
93 93
 		$object = $this->getField($name);
94
-		if($compressed===true)
94
+		if ($compressed === true)
95 95
 			$object = gzuncompress($object);
96 96
 		return unserialize($object);
97 97
 	}
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 	
103 103
 	public function lockTable($table) {
104
-		if(!self::$dbConn->query('LOCK TABLES ' . $table . ' WRITE')) {
105
-			$this->error('Unable to lock table: '. $table);
104
+		if (!self::$dbConn->query('LOCK TABLES ' . $table . ' WRITE')) {
105
+			$this->error('Unable to lock table: ' . $table);
106 106
 		}
107 107
 	}
108 108
 	
109 109
 	public function unlock() {
110
-		if(!self::$dbConn->query('UNLOCK TABLES')) {
110
+		if (!self::$dbConn->query('UNLOCK TABLES')) {
111 111
 			$this->error('Unable to remove table locks.');
112 112
 		}
113 113
 	}
@@ -132,70 +132,70 @@  discard block
 block discarded – undo
132 132
 		throw new Exception($err);
133 133
 	}
134 134
 	
135
-	public function escape($escape,$autoQuotes=true,$quotes=true) {
136
-		if(is_bool($escape)) {
137
-			if($autoQuotes)
135
+	public function escape($escape, $autoQuotes = true, $quotes = true) {
136
+		if (is_bool($escape)) {
137
+			if ($autoQuotes)
138 138
 				return $this->escapeBoolean($escape);
139 139
 			else
140
-				return $this->escapeBoolean($escape,$quotes);
140
+				return $this->escapeBoolean($escape, $quotes);
141 141
 		}
142
-		if(is_numeric($escape)) {
142
+		if (is_numeric($escape)) {
143 143
 			return $this->escapeNumber($escape);
144 144
 		}
145
-		if(is_string($escape)) {
146
-			if($autoQuotes)
145
+		if (is_string($escape)) {
146
+			if ($autoQuotes)
147 147
 				return $this->escapeString($escape);
148 148
 			else
149
-				return $this->escapeString($escape,$quotes);
149
+				return $this->escapeString($escape, $quotes);
150 150
 		}
151
-		if(is_array($escape)) {
152
-			return $this->escapeArray($escape,$autoQuotes,$quotes);
151
+		if (is_array($escape)) {
152
+			return $this->escapeArray($escape, $autoQuotes, $quotes);
153 153
 		}
154
-		if(is_object($escape)) {
155
-			if($autoQuotes)
154
+		if (is_object($escape)) {
155
+			if ($autoQuotes)
156 156
 				return $this->escapeObject($escape);
157 157
 			else
158
-				return $this->escapeObject($escape,$quotes);
158
+				return $this->escapeObject($escape, $quotes);
159 159
 		}
160 160
 	}
161 161
 	
162
-	public function escapeString($string,$quotes=true,$nullable=false) {
163
-		if($nullable===true && ($string===null || $string===''))
162
+	public function escapeString($string, $quotes = true, $nullable = false) {
163
+		if ($nullable === true && ($string === null || $string === ''))
164 164
 			return 'NULL';
165
-		if($string===true)
165
+		if ($string === true)
166 166
 			$string = 'TRUE';
167
-		else if($string===false)
167
+		else if ($string === false)
168 168
 			$string = 'FALSE';
169
-		if(is_array($string)) {
169
+		if (is_array($string)) {
170 170
 			$escapedString = '';
171
-			foreach($string as $value) {
172
-				$escapedString .= $this->escapeString($value, $quotes) .',';
171
+			foreach ($string as $value) {
172
+				$escapedString .= $this->escapeString($value, $quotes) . ',';
173 173
 			}
174
-			return substr($escapedString,0,-1);
174
+			return substr($escapedString, 0, -1);
175 175
 		}
176
-		if($quotes) {
176
+		if ($quotes) {
177 177
 			return '\'' . self::$dbConn->real_escape_string($string) . '\'';
178 178
 		}
179 179
 		return self::$dbConn->real_escape_string($string);
180 180
 	}
181 181
 	
182 182
 	public function escapeBinary($binary) {
183
-		return '0x'.bin2hex($binary);
183
+		return '0x' . bin2hex($binary);
184 184
 	}
185 185
 	
186
-	public function escapeArray(array $array,$autoQuotes=true,$quotes=true,$implodeString=',',$escapeIndividually=true) {
186
+	public function escapeArray(array $array, $autoQuotes = true, $quotes = true, $implodeString = ',', $escapeIndividually = true) {
187 187
 		$string = '';
188
-		if($escapeIndividually) {
189
-			foreach($array as $value) {
190
-				if(is_array($value))
191
-					$string .= $this->escapeArray($value,$autoQuotes,$quotes,$implodeString,$escapeIndividually).$implodeString;
188
+		if ($escapeIndividually) {
189
+			foreach ($array as $value) {
190
+				if (is_array($value))
191
+					$string .= $this->escapeArray($value, $autoQuotes, $quotes, $implodeString, $escapeIndividually) . $implodeString;
192 192
 				else
193
-					$string .= $this->escape($value, $autoQuotes, $quotes).$implodeString;
193
+					$string .= $this->escape($value, $autoQuotes, $quotes) . $implodeString;
194 194
 			}
195
-			$string = substr($string,0,-1);
195
+			$string = substr($string, 0, -1);
196 196
 		}
197 197
 		else {
198
-			$string = $this->escape(implode($implodeString,$array), $autoQuotes, $quotes);
198
+			$string = $this->escape(implode($implodeString, $array), $autoQuotes, $quotes);
199 199
 		}
200 200
 		return $string;
201 201
 	}
@@ -206,29 +206,29 @@  discard block
 block discarded – undo
206 206
 		if (is_numeric($num)) {
207 207
 			return $num;
208 208
 		} else {
209
-			throw new Exception('Not a number! ('.$num.')');
209
+			throw new Exception('Not a number! (' . $num . ')');
210 210
 		}
211 211
 	}
212 212
 	
213
-	public function escapeMicrotime($microtime,$quotes=false) {
213
+	public function escapeMicrotime($microtime, $quotes = false) {
214 214
 		$sec_str = sprintf('%010d', $microtime);
215
-		$usec_str = sprintf('%06d', fmod($microtime,1) * 1E6);
215
+		$usec_str = sprintf('%06d', fmod($microtime, 1) * 1E6);
216 216
 		return $this->escapeString($sec_str . $usec_str, $quotes);
217 217
 	}
218 218
 	
219
-	public function escapeBoolean($bool,$quotes=true) {
220
-		if($bool===true)
221
-			return $this->escapeString('TRUE',$quotes);
222
-		else if($bool===false)
223
-			return $this->escapeString('FALSE',$quotes);
219
+	public function escapeBoolean($bool, $quotes = true) {
220
+		if ($bool === true)
221
+			return $this->escapeString('TRUE', $quotes);
222
+		else if ($bool === false)
223
+			return $this->escapeString('FALSE', $quotes);
224 224
 		else
225 225
 			throw new Exception('Not a boolean!'); //TEST
226 226
 	}
227 227
 	
228
-	public function escapeObject($object,$compress=false,$quotes=true,$nullable=false) {
229
-		if($compress===true)
228
+	public function escapeObject($object, $compress = false, $quotes = true, $nullable = false) {
229
+		if ($compress === true)
230 230
 			return $this->escapeBinary(gzcompress(serialize($object)));
231
-		return $this->escapeString(serialize($object),$quotes,$nullable);
231
+		return $this->escapeString(serialize($object), $quotes, $nullable);
232 232
 	}
233 233
 
234 234
 }
Please login to merge, or discard this patch.
lib/Default/AbstractSmrLocation.class.inc 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 	protected $weaponsSold;
24 24
 	
25 25
 	public static function &getAllLocations($forceUpdate = false) {
26
-		if($forceUpdate || !isset(self::$CACHE_ALL_LOCATIONS)) {
26
+		if ($forceUpdate || !isset(self::$CACHE_ALL_LOCATIONS)) {
27 27
 			$db = new SmrMySqlDatabase();
28 28
 			$db->query('SELECT * FROM location_type ORDER BY location_type_id');
29 29
 			$locations = array();
30
-			while($db->nextRecord()) {
30
+			while ($db->nextRecord()) {
31 31
 				$locationTypeID = $db->getInt('location_type_id');
32 32
 				$locations[$locationTypeID] = SmrLocation::getLocation($locationTypeID, $forceUpdate, $db);
33 33
 			}
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 		return self::$CACHE_ALL_LOCATIONS;
37 37
 	}
38 38
 	
39
-	public static function &getSectorLocations($gameID,$sectorID,$forceUpdate = false) {
40
-		if($forceUpdate || !isset(self::$CACHE_SECTOR_LOCATIONS[$gameID][$sectorID])) {
39
+	public static function &getSectorLocations($gameID, $sectorID, $forceUpdate = false) {
40
+		if ($forceUpdate || !isset(self::$CACHE_SECTOR_LOCATIONS[$gameID][$sectorID])) {
41 41
 			$db = new SmrMySqlDatabase();
42 42
 			$db->query('SELECT * FROM location JOIN location_type USING (location_type_id) WHERE sector_id = ' . $db->escapeNumber($sectorID) . ' AND game_id=' . $db->escapeNumber($gameID));
43 43
 			$locations = array();
44
-			while($db->nextRecord()) {
44
+			while ($db->nextRecord()) {
45 45
 				$locationTypeID = $db->getInt('location_type_id');
46 46
 				$locations[$locationTypeID] = self::getLocation($locationTypeID, $forceUpdate, $db);
47 47
 			}
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 		return self::$CACHE_SECTOR_LOCATIONS[$gameID][$sectorID];
51 51
 	}
52 52
 	
53
-	public static function &getLocation($locationTypeID, $forceUpdate=false, $db=null) {
54
-		if($forceUpdate || !isset(self::$CACHE_LOCATIONS[$locationTypeID])) {
53
+	public static function &getLocation($locationTypeID, $forceUpdate = false, $db = null) {
54
+		if ($forceUpdate || !isset(self::$CACHE_LOCATIONS[$locationTypeID])) {
55 55
 			self::$CACHE_LOCATIONS[$locationTypeID] = new SmrLocation($locationTypeID, $db);
56 56
 		}
57 57
 		return self::$CACHE_LOCATIONS[$locationTypeID];
58 58
 	}
59 59
 	
60
-	protected function __construct($locationTypeID, $db=null) {
60
+	protected function __construct($locationTypeID, $db = null) {
61 61
 		$this->db = new SmrMySqlDatabase();
62 62
 		$this->SQL = 'location_type_id = ' . $this->db->escapeNumber($locationTypeID);
63 63
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			$this->image = $db->getField('location_image');
77 77
 		}
78 78
 		else {
79
-			throw new Exception('Cannot find location: '.$locationTypeID);
79
+			throw new Exception('Cannot find location: ' . $locationTypeID);
80 80
 		}
81 81
 	}
82 82
 	
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 	
87 87
 	public function getRaceID() {
88
-		if($this->isFed() && $this->getTypeID()!=LOCATION_TYPE_FEDERAL_BEACON) {
88
+		if ($this->isFed() && $this->getTypeID() != LOCATION_TYPE_FEDERAL_BEACON) {
89 89
 			return $this->getTypeID() - LOCATION_GROUP_RACIAL_BEACONS;
90 90
 		}
91
-		if($this->isHQ() && $this->getTypeID()!=LOCATION_TYPE_FEDERAL_HQ) {
91
+		if ($this->isHQ() && $this->getTypeID() != LOCATION_TYPE_FEDERAL_HQ) {
92 92
 			return $this->getTypeID() - LOCATION_GROUP_RACIAL_HQS;
93 93
 		}
94 94
 		return RACE_NEUTRAL;
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 	
101 101
 	public function setName($name) {
102
-		$name = htmlentities($name,ENT_COMPAT,'utf-8');
103
-		if($this->name==$name) {
102
+		$name = htmlentities($name, ENT_COMPAT, 'utf-8');
103
+		if ($this->name == $name) {
104 104
 			return;
105 105
 		}
106 106
 		$this->name = $name;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	}
109 109
 	
110 110
 	public function hasAction() {
111
-		return $this->processor!=null;
111
+		return $this->processor != null;
112 112
 	}
113 113
 	
114 114
 	public function getAction() {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	}
121 121
 	
122 122
 	public function isFed() {
123
-		if(!isset($this->fed)) {
123
+		if (!isset($this->fed)) {
124 124
 			$this->db->query('SELECT * FROM location_is_fed WHERE ' . $this->SQL . ' LIMIT 1');
125 125
 			$this->fed = $this->db->nextRecord();
126 126
 		}
@@ -128,21 +128,21 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 	
130 130
 	public function setFed($bool) {
131
-		if($this->fed===$bool) {
131
+		if ($this->fed === $bool) {
132 132
 			return;
133 133
 		}
134
-		if($bool===true) {
134
+		if ($bool === true) {
135 135
 			$this->db->query('INSERT IGNORE INTO location_is_fed (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
136 136
 			$this->fed = true;
137 137
 		}
138
-		else if($bool===false) {
138
+		else if ($bool === false) {
139 139
 			$this->db->query('DELETE FROM location_is_fed WHERE ' . $this->SQL . ' LIMIT 1');
140 140
 			$this->fed = false;
141 141
 		}
142 142
 	}
143 143
 	
144 144
 	public function isBank() {
145
-		if(!isset($this->bank)) {
145
+		if (!isset($this->bank)) {
146 146
 			$this->db->query('SELECT * FROM location_is_bank WHERE ' . $this->SQL . ' LIMIT 1');
147 147
 			$this->bank = $this->db->nextRecord();
148 148
 		}
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
 	}
151 151
 	
152 152
 	public function setBank($bool) {
153
-		if($this->bank===$bool)
153
+		if ($this->bank === $bool)
154 154
 			return;
155
-		if($bool===true) {
155
+		if ($bool === true) {
156 156
 			$this->db->query('INSERT INTO location_is_bank (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
157 157
 			$this->bank = true;
158 158
 		}
159
-		else if($bool===false) {
159
+		else if ($bool === false) {
160 160
 			$this->db->query('DELETE FROM location_is_bank WHERE ' . $this->SQL . ' LIMIT 1');
161 161
 			$this->bank = false;
162 162
 		}
163 163
 	}
164 164
 	
165 165
 	public function isBar() {
166
-		if(!isset($this->bar)) {
166
+		if (!isset($this->bar)) {
167 167
 			$this->db->query('SELECT * FROM location_is_bar WHERE ' . $this->SQL . ' LIMIT 1');
168 168
 			$this->bar = $this->db->nextRecord();
169 169
 		}
@@ -171,20 +171,20 @@  discard block
 block discarded – undo
171 171
 	}
172 172
 	
173 173
 	public function setBar($bool) {
174
-		if($this->bar===$bool)
174
+		if ($this->bar === $bool)
175 175
 			return;
176
-		if($bool===true) {
176
+		if ($bool === true) {
177 177
 			$this->db->query('INSERT IGNORE INTO location_is_bar (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
178 178
 			$this->bar = true;
179 179
 		}
180
-		else if($bool===false) {
180
+		else if ($bool === false) {
181 181
 			$this->db->query('DELETE FROM location_is_bar WHERE ' . $this->SQL . ' LIMIT 1');
182 182
 			$this->bar = false;
183 183
 		}
184 184
 	}
185 185
 	
186 186
 	public function isHQ() {
187
-		if(!isset($this->HQ)) {
187
+		if (!isset($this->HQ)) {
188 188
 			$this->db->query('SELECT * FROM location_is_hq WHERE ' . $this->SQL . ' LIMIT 1');
189 189
 			$this->HQ = $this->db->nextRecord();
190 190
 		}
@@ -192,20 +192,20 @@  discard block
 block discarded – undo
192 192
 	}
193 193
 	
194 194
 	public function setHQ($bool) {
195
-		if($this->HQ===$bool)
195
+		if ($this->HQ === $bool)
196 196
 			return;
197
-		if($bool===true) {
197
+		if ($bool === true) {
198 198
 			$this->db->query('INSERT IGNORE INTO location_is_hq (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
199 199
 			$this->HQ = true;
200 200
 		}
201
-		else if($bool===false) {
201
+		else if ($bool === false) {
202 202
 			$this->db->query('DELETE FROM location_is_hq WHERE ' . $this->SQL . ' LIMIT 1');
203 203
 			$this->HQ = false;
204 204
 		}
205 205
 	}
206 206
 	
207 207
 	public function isUG() {
208
-		if(!isset($this->UG)) {
208
+		if (!isset($this->UG)) {
209 209
 			$this->db->query('SELECT * FROM location_is_ug WHERE ' . $this->SQL . ' LIMIT 1');
210 210
 			$this->UG = $this->db->nextRecord();
211 211
 		}
@@ -213,118 +213,118 @@  discard block
 block discarded – undo
213 213
 	}
214 214
 	
215 215
 	public function setUG($bool) {
216
-		if($this->UG===$bool)
216
+		if ($this->UG === $bool)
217 217
 			return;
218
-		if($bool===true) {
218
+		if ($bool === true) {
219 219
 			$this->db->query('INSERT INTO location_is_ug (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
220 220
 			$this->UG = true;
221 221
 		}
222
-		else if($bool===false) {
222
+		else if ($bool === false) {
223 223
 			$this->db->query('DELETE FROM location_is_ug WHERE ' . $this->SQL . ' LIMIT 1');
224 224
 			$this->UG = false;
225 225
 		}
226 226
 	}
227 227
 	
228 228
 	public function &getHardwareSold() {
229
-		if(!isset($this->hardwareSold)) {
229
+		if (!isset($this->hardwareSold)) {
230 230
 			$this->hardwareSold = array();
231 231
 			$this->db->query('SELECT hardware_type_id FROM location_sells_hardware WHERE ' . $this->SQL);
232
-			while($this->db->nextRecord()) {
232
+			while ($this->db->nextRecord()) {
233 233
 				$this->hardwareSold[$this->db->getInt('hardware_type_id')] = Globals::getHardwareTypes($this->db->getInt('hardware_type_id'));
234 234
 			}
235 235
 		}
236 236
 		return $this->hardwareSold;
237 237
 	}
238 238
 	
239
-	public function isHardwareSold($hardwareTypeID=false) {
239
+	public function isHardwareSold($hardwareTypeID = false) {
240 240
 		$hardware = $this->getHardwareSold();
241
-		if($hardwareTypeID===false) {
242
-			return count($hardware)!=0;
241
+		if ($hardwareTypeID === false) {
242
+			return count($hardware) != 0;
243 243
 		}
244 244
 		return isset($hardware[$hardwareTypeID]);
245 245
 	}
246 246
 	
247 247
 	public function addHardwareSold($hardwareTypeID) {
248
-		if($this->isHardwareSold($hardwareTypeID))
248
+		if ($this->isHardwareSold($hardwareTypeID))
249 249
 			return;
250 250
 		$this->db->query('SELECT * FROM hardware_type WHERE hardware_type_id = ' . $this->db->escapeNumber($hardwareTypeID) . ' LIMIT 1');
251
-		if(!$this->db->nextRecord())
251
+		if (!$this->db->nextRecord())
252 252
 			throw new Exception('Invalid hardware type id given');
253 253
 		$this->db->query('INSERT INTO location_sells_hardware (location_type_id,hardware_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($hardwareTypeID) . ')');
254 254
 		$this->hardwareSold[$hardwareTypeID] = $this->db->getField('hardware_name');
255 255
 	}
256 256
 	
257 257
 	public function removeHardwareSold($hardwareTypeID) {
258
-		if(!$this->isHardwareSold($hardwareTypeID))
258
+		if (!$this->isHardwareSold($hardwareTypeID))
259 259
 			return;
260 260
 		$this->db->query('DELETE FROM location_sells_hardware WHERE ' . $this->SQL . ' AND hardware_type_id = ' . $this->db->escapeNumber($hardwareTypeID) . ' LIMIT 1');
261 261
 		unset($this->hardwareSold[$hardwareTypeID]);
262 262
 	}
263 263
 	
264 264
 	public function &getShipsSold() {
265
-		if(!isset($this->shipsSold)) {
265
+		if (!isset($this->shipsSold)) {
266 266
 			$this->shipsSold = array();
267 267
 			$this->db->query('SELECT * FROM location_sells_ships WHERE ' . $this->SQL);
268
-			while($this->db->nextRecord()) {
268
+			while ($this->db->nextRecord()) {
269 269
 				$this->shipsSold[$this->db->getInt('ship_type_id')] = AbstractSmrShip::getBaseShip(Globals::getGameType(SmrSession::getGameID()), $this->db->getInt('ship_type_id'));
270 270
 			}
271 271
 		}
272 272
 		return $this->shipsSold;
273 273
 	}
274 274
 	
275
-	public function isShipSold($shipTypeID=false) {
275
+	public function isShipSold($shipTypeID = false) {
276 276
 		$ships = $this->getShipsSold();
277
-		if($shipTypeID===false)
278
-			return count($ships)!=0;
277
+		if ($shipTypeID === false)
278
+			return count($ships) != 0;
279 279
 		return isset($ships[$shipTypeID]);
280 280
 	}
281 281
 	
282 282
 	public function addShipSold($shipTypeID) {
283
-		if($this->isShipSold($shipTypeID))
283
+		if ($this->isShipSold($shipTypeID))
284 284
 			return;
285 285
 		$ship = AbstractSmrShip::getBaseShip(Globals::getGameType(SmrSession::getGameID()), $shipTypeID);
286
-		if($ship===false)
286
+		if ($ship === false)
287 287
 			throw new Exception('Invalid ship type id given');
288 288
 		$this->db->query('INSERT INTO location_sells_ships (location_type_id,ship_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($shipTypeID) . ')');
289 289
 		$this->shipsSold[$shipTypeID] = $ship;
290 290
 	}
291 291
 	
292 292
 	public function removeShipSold($shipTypeID) {
293
-		if(!$this->isShipSold($shipTypeID))
293
+		if (!$this->isShipSold($shipTypeID))
294 294
 			return;
295 295
 		$this->db->query('DELETE FROM location_sells_ships WHERE ' . $this->SQL . ' AND ship_type_id = ' . $this->db->escapeNumber($shipTypeID) . ' LIMIT 1');
296 296
 		unset($this->shipsSold[$shipTypeID]);
297 297
 	}
298 298
 	
299 299
 	public function &getWeaponsSold() {
300
-		if(!isset($this->weaponsSold)) {
300
+		if (!isset($this->weaponsSold)) {
301 301
 			$this->weaponsSold = array();
302 302
 			$this->db->query('SELECT * FROM location_sells_weapons JOIN weapon_type USING (weapon_type_id) WHERE ' . $this->SQL);
303
-			while($this->db->nextRecord())
303
+			while ($this->db->nextRecord())
304 304
 				$this->weaponsSold[$this->db->getInt('weapon_type_id')] = SmrWeapon::getWeapon($this->db->getInt('weapon_type_id'), false, $this->db);
305 305
 		}
306 306
 		return $this->weaponsSold;
307 307
 	}
308 308
 	
309
-	public function isWeaponSold($weaponTypeID=false) {
309
+	public function isWeaponSold($weaponTypeID = false) {
310 310
 		$weapons = $this->getWeaponsSold();
311
-		if($weaponTypeID===false)
312
-			return count($weapons)!=0;
311
+		if ($weaponTypeID === false)
312
+			return count($weapons) != 0;
313 313
 		return isset($weapons[$weaponTypeID]);
314 314
 	}
315 315
 	
316 316
 	public function addWeaponSold($weaponTypeID) {
317
-		if($this->isWeaponSold($weaponTypeID))
317
+		if ($this->isWeaponSold($weaponTypeID))
318 318
 			return;
319 319
 		$weapon = SmrWeapon::getWeapon($weaponTypeID);
320
-		if($weapon===false)
320
+		if ($weapon === false)
321 321
 			throw new Exception('Invalid weapon type id given');
322
-		$this->db->query('INSERT INTO location_sells_weapons (location_type_id,weapon_type_id) values (' . $this->db->escapeNumber($this->getTypeID()). ',' . $this->db->escapeNumber($weaponTypeID) . ')');
322
+		$this->db->query('INSERT INTO location_sells_weapons (location_type_id,weapon_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($weaponTypeID) . ')');
323 323
 		$this->weaponsSold[$weaponTypeID] = $weapon;
324 324
 	}
325 325
 	
326 326
 	public function removeWeaponSold($weaponTypeID) {
327
-		if(!$this->isWeaponSold($weaponTypeID))
327
+		if (!$this->isWeaponSold($weaponTypeID))
328 328
 			return;
329 329
 		$this->db->query('DELETE FROM location_sells_weapons WHERE ' . $this->SQL . ' AND weapon_type_id = ' . $this->db->escapeNumber($weaponTypeID) . ' LIMIT 1');
330 330
 		unset($this->weaponsSold[$weaponTypeID]);
@@ -332,16 +332,16 @@  discard block
 block discarded – undo
332 332
 	
333 333
 	public function &getLinkedLocations() {
334 334
 		$linkedLocations = array();
335
-		if($this->isHQ()) {
336
-			if($this->getTypeID()==LOCATION_TYPE_FEDERAL_HQ) {
335
+		if ($this->isHQ()) {
336
+			if ($this->getTypeID() == LOCATION_TYPE_FEDERAL_HQ) {
337 337
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_BEACON);
338 338
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_MINT);
339 339
 			}
340 340
 			else {
341 341
 				$raceID = $this->getRaceID();
342
-				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_BEACONS+$raceID);
343
-				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_SHIPS+$raceID);
344
-				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_SHOPS+$raceID);
342
+				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_BEACONS + $raceID);
343
+				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_SHIPS + $raceID);
344
+				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_SHOPS + $raceID);
345 345
 			}
346 346
 		}
347 347
 		return $linkedLocations;
@@ -361,47 +361,47 @@  discard block
 block discarded – undo
361 361
 	}
362 362
 	
363 363
 	public function equals(SmrLocation $otherLocation) {
364
-		return $this->getTypeID()==$otherLocation->getTypeID();
364
+		return $this->getTypeID() == $otherLocation->getTypeID();
365 365
 	}
366 366
 
367
-	public function hasX(/*Object*/ $x, AbstractSmrPlayer $player=null) {
367
+	public function hasX(/*Object*/ $x, AbstractSmrPlayer $player = null) {
368 368
 		if ($x instanceof SmrWeapon) {
369 369
 			return $this->isWeaponSold($x->getWeaponTypeID());
370 370
 		}
371 371
 		if (is_array($x)) {
372
-			if($x['Type']=='Ship') { // instanceof Ship)
372
+			if ($x['Type'] == 'Ship') { // instanceof Ship)
373 373
 				return $this->isShipSold($x['ShipTypeID']);
374 374
 			}
375
-			if ($x['Type']=='Hardware') { // instanceof ShipEquipment)
375
+			if ($x['Type'] == 'Hardware') { // instanceof ShipEquipment)
376 376
 				return $this->isHardwareSold($x['ID']);
377 377
 			}
378 378
 		}
379
-		if(is_string($x)) {
380
-			if ($x=='Bank') {
379
+		if (is_string($x)) {
380
+			if ($x == 'Bank') {
381 381
 				return $this->isBank();
382 382
 			}
383
-			if ($x=='Bar') {
383
+			if ($x == 'Bar') {
384 384
 				return $this->isBar();
385 385
 			}
386
-			if ($x=='Fed') {
386
+			if ($x == 'Fed') {
387 387
 				return $this->isFed();
388 388
 			}
389
-			if ($x=='SafeFed') {
389
+			if ($x == 'SafeFed') {
390 390
 				return $player != null && $this->isFed() && $player->canBeProtectedByRace($this->getRaceID());
391 391
 			}
392
-			if ($x=='HQ') {
392
+			if ($x == 'HQ') {
393 393
 				return $this->isHQ();
394 394
 			}
395
-			if ($x=='UG') {
395
+			if ($x == 'UG') {
396 396
 				return $this->isUG();
397 397
 			}
398
-			if ($x=='Hardware') {
398
+			if ($x == 'Hardware') {
399 399
 				return $this->isHardwareSold();
400 400
 			}
401
-			if ($x=='Ship') {
401
+			if ($x == 'Ship') {
402 402
 				return $this->isShipSold();
403 403
 			}
404
-			if ($x=='Weapon') {
404
+			if ($x == 'Weapon') {
405 405
 				return $this->isWeaponSold();
406 406
 			}
407 407
 		}
Please login to merge, or discard this patch.
lib/Default/SocialLogin.class.inc 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
 	private $loginType = null;
11 11
 	private $userID = null;
12 12
 	private $email = null;
13
-	private static $facebook=null;
14
-	private static $openID=null;
13
+	private static $facebook = null;
14
+	private static $openID = null;
15 15
 	private static $OPEN_ID_IDENTITIES = array();
16 16
 
17 17
 	private static function getFacebookObj() {
18 18
 		if (session_status() === PHP_SESSION_NONE) {
19 19
 			session_start();
20 20
 		}
21
-		if(self::$facebook==null) {
21
+		if (self::$facebook == null) {
22 22
 			self::$facebook = new Facebook\Facebook([
23 23
 				'app_id' => FACEBOOK_APP_ID,
24 24
 				'app_secret' => FACEBOOK_APP_SECRET,
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		return self::$facebook;
29 29
 	}
30 30
 
31
-	private static function getTwitterObj($token=null) {
31
+	private static function getTwitterObj($token = null) {
32 32
 		return new Abraham\TwitterOAuth\TwitterOAuth(
33 33
 			TWITTER_CONSUMER_KEY,
34 34
 			TWITTER_CONSUMER_SECRET,
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	}
39 39
 
40 40
 	private static function getOpenIdObj() {
41
-		if(self::$openID==null) {
42
-			require_once(LIB.'External/OpenID/openid.php');
41
+		if (self::$openID == null) {
42
+			require_once(LIB . 'External/OpenID/openid.php');
43 43
 			self::$openID = new LightOpenID();
44 44
 		}
45 45
 		return self::$openID;
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	}
80 80
 
81 81
 	public static function getOpenIdLoginUrl($loginType) {
82
-		if(!isset(self::$OPEN_ID_IDENTITIES[$loginType])) {
83
-			throw new Exception('OpenID does not exist for login type: '.$loginType);
82
+		if (!isset(self::$OPEN_ID_IDENTITIES[$loginType])) {
83
+			throw new Exception('OpenID does not exist for login type: ' . $loginType);
84 84
 		}
85 85
 		$openID = self::getOpenIdObj();
86 86
 		$openID->required = array('contact/email');
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	public function __construct($loginType) {
93 93
 		$this->loginType = $loginType;
94 94
 
95
-		if($loginType == self::FACEBOOK) {
95
+		if ($loginType == self::FACEBOOK) {
96 96
 			$helper = self::getFacebookObj()->getRedirectLoginHelper();
97 97
 			$accessToken = $helper->getAccessToken(self::getRedirectUrl($loginType));
98 98
 			$response = self::getFacebookObj()->get('/me?fields=email', $accessToken);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 			$this->email = $userInfo->getEmail();
102 102
 			$this->valid = true;
103 103
 		}
104
-		else if($loginType == self::TWITTER) {
104
+		else if ($loginType == self::TWITTER) {
105 105
 			if (session_status() === PHP_SESSION_NONE) {
106 106
 				session_start();
107 107
 			}
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 				$this->valid = true;
120 120
 			}
121 121
 		}
122
-		else if($loginType == self::GOOGLE) {
123
-			if(self::getOpenIdObj()->validate()) {
124
-				if(strripos(self::getOpenIdObj()->identity, self::$OPEN_ID_IDENTITIES[$loginType]) === 0) {
125
-					$this->userID=self::getOpenIdObj()->identity;
122
+		else if ($loginType == self::GOOGLE) {
123
+			if (self::getOpenIdObj()->validate()) {
124
+				if (strripos(self::getOpenIdObj()->identity, self::$OPEN_ID_IDENTITIES[$loginType]) === 0) {
125
+					$this->userID = self::getOpenIdObj()->identity;
126 126
 					$userInfo = self::getOpenIdObj()->getAttributes();
127
-					$this->email=$userInfo['contact/email'];
127
+					$this->email = $userInfo['contact/email'];
128 128
 					$this->valid = true;
129 129
 				}
130 130
 			}
Please login to merge, or discard this patch.
lib/Default/SmrAlliance.class.inc 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
 	protected $memberList;
26 26
 	protected $seedlist;
27 27
 
28
-	public static function &getAlliance($allianceID,$gameID,$forceUpdate = false) {
29
-		if($forceUpdate || !isset(self::$CACHE_ALLIANCES[$gameID][$allianceID])) {
28
+	public static function &getAlliance($allianceID, $gameID, $forceUpdate = false) {
29
+		if ($forceUpdate || !isset(self::$CACHE_ALLIANCES[$gameID][$allianceID])) {
30 30
 			self::$CACHE_ALLIANCES[$gameID][$allianceID] = new SmrAlliance($allianceID, $gameID);
31 31
 		}
32 32
 		return self::$CACHE_ALLIANCES[$gameID][$allianceID];
33 33
 	}
34 34
 
35
-	public static function getAllianceByDiscordChannel($channel, $forceUpdate=false) {
35
+	public static function getAllianceByDiscordChannel($channel, $forceUpdate = false) {
36 36
 		$db = new SmrMySqlDatabase();
37
-		$db->query('SELECT alliance_id, game_id FROM alliance JOIN game USING(game_id) WHERE discord_channel = '.$db->escapeString($channel).' AND game.end_date > '.$db->escapeNumber(time()).' ORDER BY game_id DESC LIMIT 1');
37
+		$db->query('SELECT alliance_id, game_id FROM alliance JOIN game USING(game_id) WHERE discord_channel = ' . $db->escapeString($channel) . ' AND game.end_date > ' . $db->escapeNumber(time()) . ' ORDER BY game_id DESC LIMIT 1');
38 38
 		if ($db->nextRecord()) {
39 39
 			return self::getAlliance($db->getInt('alliance_id'), $db->getInt('game_id'), $forceUpdate);
40 40
 		} else {
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 		}
43 43
 	}
44 44
 
45
-	public static function &getAllianceByIrcChannel($channel,$forceUpdate = false) {
45
+	public static function &getAllianceByIrcChannel($channel, $forceUpdate = false) {
46 46
 		$db = new SmrMySqlDatabase();
47
-		$db->query('SELECT alliance_id, game_id FROM irc_alliance_has_channel WHERE channel = '.$db->escapeString($channel).' LIMIT 1');
48
-		if($db->nextRecord()) {
47
+		$db->query('SELECT alliance_id, game_id FROM irc_alliance_has_channel WHERE channel = ' . $db->escapeString($channel) . ' LIMIT 1');
48
+		if ($db->nextRecord()) {
49 49
 			return self::getAlliance($db->getInt('alliance_id'), $db->getInt('game_id'), $forceUpdate);
50 50
 		}
51 51
 		$return = null;
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 		if ($allianceID != 0) {
63 63
 			$this->db->query('SELECT * FROM alliance WHERE ' . $this->SQL);
64 64
 			$this->db->nextRecord();
65
-			$this->allianceName		= stripslashes($this->db->getField('alliance_name'));
65
+			$this->allianceName = stripslashes($this->db->getField('alliance_name'));
66 66
 			$this->password			= stripslashes($this->db->getField('alliance_password'));
67
-			$this->description		= strip_tags(stripslashes($this->db->getField('alliance_description')));
67
+			$this->description = strip_tags(stripslashes($this->db->getField('alliance_description')));
68 68
 			$this->leaderID			= $this->db->getInt('leader_id');
69
-			$this->account			= $this->db->getInt('alliance_account');
69
+			$this->account = $this->db->getInt('alliance_account');
70 70
 			$this->kills			= $this->db->getInt('alliance_kills');
71 71
 			$this->deaths			= $this->db->getInt('alliance_deaths');
72 72
 			$this->motd				= strip_tags(stripslashes($this->db->getField('mod')));
73 73
 			$this->imgSrc			= $this->db->getField('img_src');
74
-			$this->discordServer	= $this->db->getField('discord_server');
75
-			$this->discordChannel	= $this->db->getField('discord_channel');
74
+			$this->discordServer = $this->db->getField('discord_server');
75
+			$this->discordChannel = $this->db->getField('discord_channel');
76 76
 			$this->flagshipID = $this->db->getInt('flagship_id');
77 77
 
78 78
 			if (empty($this->kills)) {
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 		return $this->allianceID;
96 96
 	}
97 97
 
98
-	public function getAllianceName($linked=false, $includeAllianceID=false) {
98
+	public function getAllianceName($linked = false, $includeAllianceID = false) {
99 99
 		$name = $this->allianceName;
100 100
 		if ($includeAllianceID) {
101 101
 			$name .= ' (' . $this->allianceID . ')';
102 102
 		}
103
-		if($linked === true && !$this->hasDisbanded()) {
103
+		if ($linked === true && !$this->hasDisbanded()) {
104 104
 			return create_link(Globals::getAllianceRosterHREF($this->getAllianceID()), $name);
105 105
 		}
106 106
 		return $name;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	}
124 124
 
125 125
 	public function &getLeader() {
126
-		return SmrPlayer::getPlayer($this->getLeaderID(),$this->getGameID());
126
+		return SmrPlayer::getPlayer($this->getLeaderID(), $this->getGameID());
127 127
 	}
128 128
 
129 129
 	public function getDiscordServer() {
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	}
144 144
 
145 145
 	public function getIrcChannel() {
146
-		if(!isset($this->ircChannel)) {
146
+		if (!isset($this->ircChannel)) {
147 147
 			$this->db->query('SELECT channel FROM irc_alliance_has_channel WHERE ' . $this->SQL);
148
-			if($this->db->nextRecord()) {
148
+			if ($this->db->nextRecord()) {
149 149
 				$this->ircChannel = $this->db->getField('channel');
150 150
 			}
151 151
 			else {
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 	}
157 157
 
158 158
 	public function setIrcChannel($ircChannel) {
159
-		if($this->ircChannel == $ircChannel) {
159
+		if ($this->ircChannel == $ircChannel) {
160 160
 			return;
161 161
 		}
162
-		if(strlen($ircChannel)>0 && $ircChannel != '#') {
163
-			if($ircChannel[0] != '#') {
162
+		if (strlen($ircChannel) > 0 && $ircChannel != '#') {
163
+			if ($ircChannel[0] != '#') {
164 164
 				$ircChannel = '#' . $ircChannel;
165 165
 			}
166 166
 			if ($ircChannel == '#smr' || $ircChannel == '#smr-bar') {
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	}
185 185
 
186 186
 	public function setImageURL($url) {
187
-		if(preg_match('/"/',$url)) {
187
+		if (preg_match('/"/', $url)) {
188 188
 			throw new Exception('Tried to set an image url with ": ' . $url);
189 189
 		}
190 190
 		$this->imgSrc = htmlspecialchars($url);
@@ -228,18 +228,18 @@  discard block
 block discarded – undo
228 228
 
229 229
 	public function setAllianceDescription($description) {
230 230
 		$description = word_filter($description);
231
-		if($description==$this->description) {
231
+		if ($description == $this->description) {
232 232
 			return;
233 233
 		}
234
-		global $player,$account;
235
-		$boxDescription = 'Alliance '.$this->getAllianceName(false, true).' had their description changed to:'.EOL.EOL.$description;
236
-		if(is_object($player)) {
237
-			$player->sendMessageToBox(BOX_ALLIANCE_DESCRIPTIONS,$boxDescription);
234
+		global $player, $account;
235
+		$boxDescription = 'Alliance ' . $this->getAllianceName(false, true) . ' had their description changed to:' . EOL . EOL . $description;
236
+		if (is_object($player)) {
237
+			$player->sendMessageToBox(BOX_ALLIANCE_DESCRIPTIONS, $boxDescription);
238 238
 		}
239 239
 		else {
240
-			$account->sendMessageToBox(BOX_ALLIANCE_DESCRIPTIONS,$boxDescription);
240
+			$account->sendMessageToBox(BOX_ALLIANCE_DESCRIPTIONS, $boxDescription);
241 241
 		}
242
-		$this->description=nl2br(htmlspecialchars($description));
242
+		$this->description = nl2br(htmlspecialchars($description));
243 243
 	}
244 244
 
245 245
 	public function hasFlagship() {
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 		$this->flagshipID = $accountID;
265 265
 	}
266 266
 
267
-	public function canJoinAlliance(SmrPlayer $player, $doAllianceCheck=true) {
267
+	public function canJoinAlliance(SmrPlayer $player, $doAllianceCheck = true) {
268 268
 		if (!$player->getAccount()->isValidated()) {
269 269
 			return 'You cannot join an alliance until you validate your account.';
270 270
 		}
@@ -274,23 +274,23 @@  discard block
 block discarded – undo
274 274
 		if ($doAllianceCheck && $player->hasAlliance()) {
275 275
 			return 'You are already in an alliance!';
276 276
 		}
277
-		if($this->getPassword()=='*') {
277
+		if ($this->getPassword() == '*') {
278 278
 			return 'This alliance is not currently accepting new recruits.';
279 279
 		}
280
-		if($player->getAllianceJoinable() > TIME) {
281
-			return 'You cannot join another alliance for '.format_time($player->getAllianceJoinable()-TIME).'.';
280
+		if ($player->getAllianceJoinable() > TIME) {
281
+			return 'You cannot join another alliance for ' . format_time($player->getAllianceJoinable() - TIME) . '.';
282 282
 		}
283
-		if($this->getNumMembers()<Globals::getAllianceMaxPlayers($this->getGameID())) {
283
+		if ($this->getNumMembers() < Globals::getAllianceMaxPlayers($this->getGameID())) {
284 284
 			if ($player->hasNewbieStatus()) {
285 285
 				return true;
286 286
 			}
287 287
 			$maxVets = Globals::getAllianceMaxVets($this->getGameID());
288
-			if($this->getNumMembers()<$maxVets) {
288
+			if ($this->getNumMembers() < $maxVets) {
289 289
 				return true;
290 290
 			}
291
-			$this->db->query('SELECT status FROM player_joined_alliance WHERE account_id='.$this->db->escapeNumber($player->getAccountID()).' AND '.$this->SQL);
292
-			if($this->db->nextRecord()) {
293
-				if($this->db->getField('status')=='NEWBIE') {
291
+			$this->db->query('SELECT status FROM player_joined_alliance WHERE account_id=' . $this->db->escapeNumber($player->getAccountID()) . ' AND ' . $this->SQL);
292
+			if ($this->db->nextRecord()) {
293
+				if ($this->db->getField('status') == 'NEWBIE') {
294 294
 					return true;
295 295
 				}
296 296
 			}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 							FROM player_joined_alliance
299 299
 							JOIN player USING (account_id, alliance_id, game_id)
300 300
 							WHERE ' . $this->SQL . ' AND status=\'VETERAN\'');
301
-			if(!$this->db->nextRecord() || $this->db->getInt('num_orig_vets') < $maxVets) {
301
+			if (!$this->db->nextRecord() || $this->db->getInt('num_orig_vets') < $maxVets) {
302 302
 				return true;
303 303
 			}
304 304
 		}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	}
307 307
 
308 308
 	public function getNumVeterans() {
309
-		$numVeterans=0;
309
+		$numVeterans = 0;
310 310
 		foreach ($this->getMembers() as $player) {
311 311
 			if (!$player->hasNewbieStatus()) {
312 312
 				$numVeterans++;
@@ -321,16 +321,16 @@  discard block
 block discarded – undo
321 321
 
322 322
 	function update() {
323 323
 		$this->db->query('UPDATE alliance SET alliance_password = ' . $this->db->escapeString($this->password) . ',
324
-								alliance_account = '.$this->db->escapeNumber($this->account).',
324
+								alliance_account = '.$this->db->escapeNumber($this->account) . ',
325 325
 								alliance_description = ' . $this->db->escapeString($this->description) . ',
326 326
 								`mod` = ' . $this->db->escapeString($this->motd) . ',
327 327
 								img_src = ' . $this->db->escapeString($this->imgSrc) . ',
328
-								alliance_kills = '.$this->db->escapeNumber($this->kills).',
329
-								alliance_deaths = '.$this->db->escapeNumber($this->deaths).',
330
-								discord_server = '.$this->db->escapeString($this->discordServer).',
331
-								discord_channel = '.$this->db->escapeString($this->discordChannel).',
332
-								flagship_id = '.$this->db->escapeNumber($this->flagshipID).',
333
-								leader_id = '.$this->db->escapeNumber($this->leaderID).'
328
+								alliance_kills = '.$this->db->escapeNumber($this->kills) . ',
329
+								alliance_deaths = '.$this->db->escapeNumber($this->deaths) . ',
330
+								discord_server = '.$this->db->escapeString($this->discordServer) . ',
331
+								discord_channel = '.$this->db->escapeString($this->discordChannel) . ',
332
+								flagship_id = '.$this->db->escapeNumber($this->flagshipID) . ',
333
+								leader_id = '.$this->db->escapeNumber($this->leaderID) . '
334 334
 							WHERE ' . $this->SQL);
335 335
 	}
336 336
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	}
343 343
 
344 344
 	function getMemberIDs() {
345
-		if(!isset($this->memberList)) {
345
+		if (!isset($this->memberList)) {
346 346
 			$this->db->query('SELECT account_id FROM player WHERE ' . $this->SQL);
347 347
 
348 348
 			//we have the list of players put them in an array now
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 		$this->db->query('SELECT account_id
361 361
 						FROM active_session
362 362
 						JOIN player USING(account_id, game_id)
363
-						WHERE '.$this->SQL.' AND last_accessed >= ' . $this->db->escapeNumber(TIME - 600));
363
+						WHERE '.$this->SQL . ' AND last_accessed >= ' . $this->db->escapeNumber(TIME - 600));
364 364
 		
365
-		while($this->db->nextRecord()) {
365
+		while ($this->db->nextRecord()) {
366 366
 			$activeIDs[] = $this->db->getInt('account_id');
367 367
 		}
368 368
 		
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * Create the default roles for this alliance.
413 413
 	 * This should only be called once after the alliance is created.
414 414
 	 */
415
-	public function createDefaultRoles($newMemberPermission='basic') {
415
+	public function createDefaultRoles($newMemberPermission = 'basic') {
416 416
 		$db = $this->db; //for convenience
417 417
 
418 418
 		$withPerDay = ALLIANCE_BANK_UNLIMITED;
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 		$opLeader = TRUE;
428 428
 		$viewBonds = TRUE;
429 429
 		$db->query('INSERT INTO alliance_has_roles (alliance_id, game_id, role_id, role, with_per_day, remove_member, change_pass, change_mod, change_roles, planet_access, exempt_with, mb_messages, send_alliance_msg, op_leader, view_bonds) ' .
430
-			'VALUES (' . $db->escapeNumber($this->getAllianceID()) . ', ' . $db->escapeNumber($this->getGameID()) . ', 1, \'Leader\', ' . $db->escapeNumber($withPerDay) . ', '.$db->escapeBoolean($removeMember) . ', ' . $db->escapeBoolean($changePass) . ', ' . $db->escapeBoolean($changeMOD) . ', '.$db->escapeBoolean($changeRoles) . ', ' . $db->escapeBoolean($planetAccess) . ', ' . $db->escapeBoolean($exemptWith) . ', ' . $db->escapeBoolean($mbMessages) . ', ' . $db->escapeString($sendAllMsg) . ', ' . $db->escapeBoolean($opLeader) . ', ' . $db->escapeBoolean($viewBonds) . ')');
430
+			'VALUES (' . $db->escapeNumber($this->getAllianceID()) . ', ' . $db->escapeNumber($this->getGameID()) . ', 1, \'Leader\', ' . $db->escapeNumber($withPerDay) . ', ' . $db->escapeBoolean($removeMember) . ', ' . $db->escapeBoolean($changePass) . ', ' . $db->escapeBoolean($changeMOD) . ', ' . $db->escapeBoolean($changeRoles) . ', ' . $db->escapeBoolean($planetAccess) . ', ' . $db->escapeBoolean($exemptWith) . ', ' . $db->escapeBoolean($mbMessages) . ', ' . $db->escapeString($sendAllMsg) . ', ' . $db->escapeBoolean($opLeader) . ', ' . $db->escapeBoolean($viewBonds) . ')');
431 431
 
432 432
 		switch ($newMemberPermission) {
433 433
 			case 'full':
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 			break;
462 462
 		}
463 463
 		$db->query('INSERT INTO alliance_has_roles (alliance_id, game_id, role_id, role, with_per_day, remove_member, change_pass, change_mod, change_roles, planet_access, exempt_with, mb_messages, send_alliance_msg, op_leader, view_bonds) ' .
464
-					'VALUES (' . $db->escapeNumber($this->getAllianceID()) . ', ' . $db->escapeNumber($this->getGameID()) . ', 2, \'New Member\', ' . $db->escapeNumber($withPerDay) . ', '.$db->escapeBoolean($removeMember) . ', ' . $db->escapeBoolean($changePass) . ', ' . $db->escapeBoolean($changeMOD) . ', '.$db->escapeBoolean($changeRoles) . ', ' . $db->escapeBoolean($planetAccess) . ', ' . $db->escapeBoolean($exemptWith) . ', ' . $db->escapeBoolean($mbMessages) . ', ' . $db->escapeString($sendAllMsg) . ', ' . $db->escapeBoolean($opLeader) . ', ' . $db->escapeBoolean($viewBonds) . ')');
464
+					'VALUES (' . $db->escapeNumber($this->getAllianceID()) . ', ' . $db->escapeNumber($this->getGameID()) . ', 2, \'New Member\', ' . $db->escapeNumber($withPerDay) . ', ' . $db->escapeBoolean($removeMember) . ', ' . $db->escapeBoolean($changePass) . ', ' . $db->escapeBoolean($changeMOD) . ', ' . $db->escapeBoolean($changeRoles) . ', ' . $db->escapeBoolean($planetAccess) . ', ' . $db->escapeBoolean($exemptWith) . ', ' . $db->escapeBoolean($mbMessages) . ', ' . $db->escapeString($sendAllMsg) . ', ' . $db->escapeBoolean($opLeader) . ', ' . $db->escapeBoolean($viewBonds) . ')');
465 465
 
466 466
 		// Set the leader permissions
467 467
 		$db->query('INSERT INTO player_has_alliance_role (game_id, account_id, role_id, alliance_id) VALUES (' . $db->escapeNumber($this->getGameID()) . ', ' . $db->escapeNumber($this->getLeaderID()) . ', 1,' . $db->escapeNumber($this->getAllianceID()) . ')');
Please login to merge, or discard this patch.
lib/Default/message.functions.inc 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,31 +26,31 @@
 block discarded – undo
26 26
 }
27 27
 
28 28
 function &getMessagePlayer($accountID, $gameID, $messageType = false) {
29
-	if($accountID==ACCOUNT_ID_PORT)
29
+	if ($accountID == ACCOUNT_ID_PORT)
30 30
 		$return = '<span class="yellow">Port Defenses</span>';
31
-	else if($accountID==ACCOUNT_ID_ADMIN)
31
+	else if ($accountID == ACCOUNT_ID_ADMIN)
32 32
 		$return = '<span class="admin">Administrator</span>';
33
-	else if($accountID==ACCOUNT_ID_PLANET)
33
+	else if ($accountID == ACCOUNT_ID_PLANET)
34 34
 		$return = '<span class="yellow">Planetary Defenses</span>';
35
-	else if($accountID==ACCOUNT_ID_ALLIANCE_AMBASSADOR)
35
+	else if ($accountID == ACCOUNT_ID_ALLIANCE_AMBASSADOR)
36 36
 		$return = '<span class="green">Alliance Ambassador</span>';
37
-	else if($accountID==ACCOUNT_ID_CASINO)
37
+	else if ($accountID == ACCOUNT_ID_CASINO)
38 38
 		$return = '<span class="yellow">Casino</span>';
39
-	else if($accountID==ACCOUNT_ID_FED_CLERK)
39
+	else if ($accountID == ACCOUNT_ID_FED_CLERK)
40 40
 		$return = '<span class="yellow">Federal Clerk</span>';
41
-	else if($accountID==ACCOUNT_ID_OP_ANNOUNCE || $accountID==ACCOUNT_ID_ALLIANCE_COMMAND)
41
+	else if ($accountID == ACCOUNT_ID_OP_ANNOUNCE || $accountID == ACCOUNT_ID_ALLIANCE_COMMAND)
42 42
 		$return = '<span class="green">Alliance Command</span>';
43 43
 	else {
44 44
 		foreach (Globals::getRaces() as $raceID => $raceInfo) {
45
-			if($accountID==ACCOUNT_ID_GROUP_RACES+$raceID) {
46
-				$return = '<span class="yellow">'.$raceInfo['Race Name'].' Government</span>';
45
+			if ($accountID == ACCOUNT_ID_GROUP_RACES + $raceID) {
46
+				$return = '<span class="yellow">' . $raceInfo['Race Name'] . ' Government</span>';
47 47
 				return $return;
48 48
 			}
49 49
 		}
50
-		if(!empty($accountID))
50
+		if (!empty($accountID))
51 51
 			$return = SmrPlayer::getPlayer($accountID, $gameID);
52 52
 		else {
53
-			switch($messageType) {
53
+			switch ($messageType) {
54 54
 				case MSG_ADMIN:
55 55
 					$return = '<span class="admin">Administrator</span>';
56 56
 				break;
Please login to merge, or discard this patch.
lib/Default/SmrPlayer.class.inc 1 patch
Spacing   +344 added lines, -344 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 
36 36
 
37 37
 	public static function refreshCache() {
38
-		foreach(self::$CACHE_PLAYERS as $gameID => &$gamePlayers) {
39
-			foreach($gamePlayers as $accountID => &$player) {
40
-				$player = self::getPlayer($accountID,$gameID,true);
38
+		foreach (self::$CACHE_PLAYERS as $gameID => &$gamePlayers) {
39
+			foreach ($gamePlayers as $accountID => &$player) {
40
+				$player = self::getPlayer($accountID, $gameID, true);
41 41
 			}
42 42
 		}
43 43
 	}
@@ -48,28 +48,28 @@  discard block
 block discarded – undo
48 48
 	}
49 49
 
50 50
 	public static function savePlayers() {
51
-		foreach(self::$CACHE_PLAYERS as $gamePlayers) {
52
-			foreach($gamePlayers as $player) {
51
+		foreach (self::$CACHE_PLAYERS as $gamePlayers) {
52
+			foreach ($gamePlayers as $player) {
53 53
 				$player->save();
54 54
 			}
55 55
 		}
56 56
 	}
57 57
 
58
-	public static function &getSectorPlayersByAlliances($gameID,$sectorID, array $allianceIDs, $forceUpdate = false) {
59
-		$players = self::getSectorPlayers($gameID,$sectorID,$forceUpdate); // Don't use & as we do an unset
60
-		foreach($players as $accountID => $player) {
61
-			if(!in_array($player->getAllianceID(),$allianceIDs))
58
+	public static function &getSectorPlayersByAlliances($gameID, $sectorID, array $allianceIDs, $forceUpdate = false) {
59
+		$players = self::getSectorPlayers($gameID, $sectorID, $forceUpdate); // Don't use & as we do an unset
60
+		foreach ($players as $accountID => $player) {
61
+			if (!in_array($player->getAllianceID(), $allianceIDs))
62 62
 				unset($players[$accountID]);
63 63
 		}
64 64
 		return $players;
65 65
 	}
66 66
 
67
-	public static function &getSectorPlayers($gameID,$sectorID,$forceUpdate = false) {
68
-		if($forceUpdate || !isset(self::$CACHE_SECTOR_PLAYERS[$gameID][$sectorID])) {
67
+	public static function &getSectorPlayers($gameID, $sectorID, $forceUpdate = false) {
68
+		if ($forceUpdate || !isset(self::$CACHE_SECTOR_PLAYERS[$gameID][$sectorID])) {
69 69
 			$db = new SmrMySqlDatabase();
70
-			$db->query('SELECT * FROM player WHERE sector_id = ' . $db->escapeNumber($sectorID) . ' AND game_id=' . $db->escapeNumber($gameID) . ' AND land_on_planet = ' . $db->escapeBoolean(false) . ' AND (last_cpl_action > ' . $db->escapeNumber(TIME-TIME_BEFORE_INACTIVE) . ' OR newbie_turns = 0) AND account_id NOT IN (' . $db->escapeArray(Globals::getHiddenPlayers()) . ') ORDER BY last_cpl_action DESC');
70
+			$db->query('SELECT * FROM player WHERE sector_id = ' . $db->escapeNumber($sectorID) . ' AND game_id=' . $db->escapeNumber($gameID) . ' AND land_on_planet = ' . $db->escapeBoolean(false) . ' AND (last_cpl_action > ' . $db->escapeNumber(TIME - TIME_BEFORE_INACTIVE) . ' OR newbie_turns = 0) AND account_id NOT IN (' . $db->escapeArray(Globals::getHiddenPlayers()) . ') ORDER BY last_cpl_action DESC');
71 71
 			$players = array();
72
-			while($db->nextRecord()) {
72
+			while ($db->nextRecord()) {
73 73
 				$accountID = $db->getInt('account_id');
74 74
 				$players[$accountID] = self::getPlayer($accountID, $gameID, $forceUpdate, $db);
75 75
 			}
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
 		return self::$CACHE_SECTOR_PLAYERS[$gameID][$sectorID];
79 79
 	}
80 80
 
81
-	public static function &getPlanetPlayers($gameID,$sectorID,$forceUpdate = false) {
82
-		if($forceUpdate || !isset(self::$CACHE_PLANET_PLAYERS[$gameID][$sectorID])) {
81
+	public static function &getPlanetPlayers($gameID, $sectorID, $forceUpdate = false) {
82
+		if ($forceUpdate || !isset(self::$CACHE_PLANET_PLAYERS[$gameID][$sectorID])) {
83 83
 			$db = new SmrMySqlDatabase();
84 84
 			$db->query('SELECT * FROM player WHERE sector_id = ' . $db->escapeNumber($sectorID) . ' AND game_id=' . $db->escapeNumber($gameID) . ' AND land_on_planet = ' . $db->escapeBoolean(true) . ' AND account_id NOT IN (' . $db->escapeArray(Globals::getHiddenPlayers()) . ') ORDER BY last_cpl_action DESC');
85 85
 			$players = array();
86
-			while($db->nextRecord()) {
86
+			while ($db->nextRecord()) {
87 87
 				$accountID = $db->getField('account_id');
88 88
 				$players[$accountID] = self::getPlayer($accountID, $gameID, $forceUpdate, $db);
89 89
 			}
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 		return self::$CACHE_PLANET_PLAYERS[$gameID][$sectorID];
93 93
 	}
94 94
 
95
-	public static function &getAlliancePlayers($gameID,$allianceID,$forceUpdate = false) {
96
-		if($forceUpdate || !isset(self::$CACHE_ALLIANCE_PLAYERS[$gameID][$allianceID])) {
95
+	public static function &getAlliancePlayers($gameID, $allianceID, $forceUpdate = false) {
96
+		if ($forceUpdate || !isset(self::$CACHE_ALLIANCE_PLAYERS[$gameID][$allianceID])) {
97 97
 			$db = new SmrMySqlDatabase();
98
-			$db->query('SELECT * FROM player WHERE alliance_id = ' . $db->escapeNumber($allianceID) . ' AND game_id=' . $db->escapeNumber($gameID) .' ORDER BY experience DESC');
98
+			$db->query('SELECT * FROM player WHERE alliance_id = ' . $db->escapeNumber($allianceID) . ' AND game_id=' . $db->escapeNumber($gameID) . ' ORDER BY experience DESC');
99 99
 			$players = array();
100
-			while($db->nextRecord()) {
100
+			while ($db->nextRecord()) {
101 101
 				$accountID = $db->getInt('account_id');
102 102
 				$players[$accountID] = self::getPlayer($accountID, $gameID, $forceUpdate, $db);
103 103
 			}
@@ -106,23 +106,23 @@  discard block
 block discarded – undo
106 106
 		return self::$CACHE_ALLIANCE_PLAYERS[$gameID][$allianceID];
107 107
 	}
108 108
 
109
-	public static function &getPlayer($accountID, $gameID, $forceUpdate=false, $db=null) {
109
+	public static function &getPlayer($accountID, $gameID, $forceUpdate = false, $db = null) {
110 110
 		if ($forceUpdate || !isset(self::$CACHE_PLAYERS[$gameID][$accountID])) {
111 111
 			self::$CACHE_PLAYERS[$gameID][$accountID] = new SmrPlayer($gameID, $accountID, $db);
112 112
 		}
113 113
 		return self::$CACHE_PLAYERS[$gameID][$accountID];
114 114
 	}
115 115
 
116
-	public static function &getPlayerByPlayerID($playerID,$gameID,$forceUpdate = false) {
116
+	public static function &getPlayerByPlayerID($playerID, $gameID, $forceUpdate = false) {
117 117
 		$db = new SmrMySqlDatabase();
118
-		$db->query('SELECT * FROM player WHERE game_id = '.$db->escapeNumber($gameID).' AND player_id = '.$db->escapeNumber($playerID).' LIMIT 1');
118
+		$db->query('SELECT * FROM player WHERE game_id = ' . $db->escapeNumber($gameID) . ' AND player_id = ' . $db->escapeNumber($playerID) . ' LIMIT 1');
119 119
 		if ($db->nextRecord()) {
120 120
 			return self::getPlayer($db->getInt('account_id'), $gameID, $forceUpdate, $db);
121 121
 		}
122 122
 		throw new PlayerNotFoundException('Player ID not found.');
123 123
 	}
124 124
 
125
-	protected function __construct($gameID, $accountID, $db=null) {
125
+	protected function __construct($gameID, $accountID, $db = null) {
126 126
 		parent::__construct();
127 127
 		$this->db = new SmrMySqlDatabase();
128 128
 		$this->SQL = 'account_id = ' . $this->db->escapeNumber($accountID) . ' AND game_id = ' . $this->db->escapeNumber($gameID);
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 		}
137 137
 
138 138
 		if ($playerExists) {
139
-			$this->accountID = (int) $accountID;
140
-			$this->gameID = (int) $gameID;
139
+			$this->accountID = (int)$accountID;
140
+			$this->gameID = (int)$gameID;
141 141
 			$this->playerName = $db->getField('player_name');
142 142
 			$this->playerID = $db->getInt('player_id');
143 143
 			$this->sectorID = $db->getInt('sector_id');
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
 			$this->combatDronesKamikazeOnMines = $db->getBoolean('combat_drones_kamikaze_on_mines');
178 178
 		}
179 179
 		else {
180
-			throw new PlayerNotFoundException('Invalid accountID: '.$accountID. ' OR gameID:'.$gameID);
180
+			throw new PlayerNotFoundException('Invalid accountID: ' . $accountID . ' OR gameID:' . $gameID);
181 181
 		}
182 182
 	}
183 183
 
184 184
 	// Get array of players whose info can be accessed by this player.
185 185
 	// Skips players who are not in the same alliance as this player.
186
-	public function getSharingPlayers($forceUpdate=false) {
186
+	public function getSharingPlayers($forceUpdate = false) {
187 187
 		$results = array($this);
188 188
 
189 189
 		// Only return this player if not in an alliance
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	}
213 213
 
214 214
 	function get($bit) {
215
-		switch($bit) {
215
+		switch ($bit) {
216 216
 			case 'Sector ID':
217 217
 				return $this->sectorID;
218 218
 			case 'Last Sector ID':
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 			case 'Aether Knowledge':
286 286
 				return $this->getKnowledge('Aether');
287 287
 			default:
288
-				throw new Exception('Player->get('.$bit.') not found, report to Page.');
288
+				throw new Exception('Player->get(' . $bit . ') not found, report to Page.');
289 289
 		}
290 290
 	}
291 291
 
@@ -304,52 +304,52 @@  discard block
 block discarded – undo
304 304
 	function setZoom($zoom) {
305 305
 		if ($zoom < 0) $zoom = 0;
306 306
 		if ($zoom > 12) $zoom = 12;
307
-		if($this->zoom == $zoom)
307
+		if ($this->zoom == $zoom)
308 308
 			return;
309
-		$this->zoom=$zoom;
310
-		$this->hasChanged=true;
309
+		$this->zoom = $zoom;
310
+		$this->hasChanged = true;
311 311
 //		$this->db->query('UPDATE player SET zoom = ' . $zoom . ' WHERE ' . $this->SQL . ' LIMIT 1');
312 312
 	}
313 313
 
314 314
 	function increaseZoom($zoom) {
315 315
 		if ($zoom < 0)
316 316
 			throw new Exception('Trying to increase negative zoom.');
317
-		$this->setZoom($this->getZoom()+$zoom);
317
+		$this->setZoom($this->getZoom() + $zoom);
318 318
 	}
319 319
 
320 320
 	function decreaseZoom($zoom) {
321 321
 		if ($zoom < 0)
322 322
 			throw new Exception('Trying to decrease negative zoom.');
323
-		$this->setZoom($this->getZoom()-$zoom);
323
+		$this->setZoom($this->getZoom() - $zoom);
324 324
 	}
325 325
 
326 326
 	public function setSectorID($sectorID) {
327
-		$port = SmrPort::getPort($this->getGameID(),$this->getSectorID());
327
+		$port = SmrPort::getPort($this->getGameID(), $this->getSectorID());
328 328
 		$port->addCachePort($this->getAccountID()); //Add port of sector we were just in, to make sure it is left totally up to date.
329 329
 
330 330
 		parent::setSectorID($sectorID);
331 331
 
332
-		$port = SmrPort::getPort($this->getGameID(),$sectorID);
332
+		$port = SmrPort::getPort($this->getGameID(), $sectorID);
333 333
 		$port->addCachePort($this->getAccountID()); //Add the port of sector we are now in.
334 334
 	}
335 335
 
336 336
 	function setLastSectorID($lastSectorID) {
337
-		if($this->lastSectorID == $lastSectorID)
337
+		if ($this->lastSectorID == $lastSectorID)
338 338
 			return;
339
-		$this->lastSectorID=$lastSectorID;
340
-		$this->hasChanged=true;
339
+		$this->lastSectorID = $lastSectorID;
340
+		$this->hasChanged = true;
341 341
 //		$this->db->query('UPDATE player SET last_sector_id = '.$this->lastSectorID.' WHERE '.$this->SQL.' LIMIT 1');
342 342
 	}
343 343
 
344 344
 	function leaveAlliance(AbstractSmrPlayer $kickedBy = null) {
345 345
 		$allianceID = $this->getAllianceID();
346 346
 		$alliance = $this->getAlliance();
347
-		if($kickedBy != null) {
347
+		if ($kickedBy != null) {
348 348
 			$kickedBy->sendMessage($this->getAccountID(), MSG_PLAYER, 'You were kicked out of the alliance!', false);
349 349
 			$this->actionTaken('PlayerKicked', array('Alliance' => $alliance, 'Player' => $kickedBy));
350 350
 			$kickedBy->actionTaken('KickPlayer', array('Alliance' => $alliance, 'Player' => $this));
351 351
 		}
352
-		else if($this->isAllianceLeader()) {
352
+		else if ($this->isAllianceLeader()) {
353 353
 			$this->actionTaken('DisbandAlliance', array('Alliance' => $alliance));
354 354
 		}
355 355
 		else {
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 		$this->setAllianceID(0);
363 363
 		$this->db->query('DELETE FROM player_has_alliance_role WHERE ' . $this->SQL);
364 364
 
365
-		if(!$this->isAllianceLeader() && $allianceID!=NHA_ID) { // Don't have a delay for switching alliance after leaving NHA, or for disbanding an alliance.
365
+		if (!$this->isAllianceLeader() && $allianceID != NHA_ID) { // Don't have a delay for switching alliance after leaving NHA, or for disbanding an alliance.
366 366
 			$this->setAllianceJoinable(TIME + self::TIME_FOR_ALLIANCE_SWITCH);
367 367
 			$alliance->getLeader()->setAllianceJoinable(TIME + self::TIME_FOR_ALLIANCE_SWITCH); //We set the joinable time for leader here, that way a single player alliance won't cause a player to wait before switching.
368 368
 		}
@@ -393,10 +393,10 @@  discard block
 block discarded – undo
393 393
 	}
394 394
 
395 395
 	function setAllianceJoinable($time) {
396
-		if($this->allianceJoinable == $time)
396
+		if ($this->allianceJoinable == $time)
397 397
 			return;
398
-		$this->allianceJoinable=$time;
399
-		$this->hasChanged=true;
398
+		$this->allianceJoinable = $time;
399
+		$this->hasChanged = true;
400 400
 	}
401 401
 
402 402
 	function getAttackColour() {
@@ -404,10 +404,10 @@  discard block
 block discarded – undo
404 404
 	}
405 405
 
406 406
 	function setAttackColour($colour) {
407
-		if($this->attackColour == $colour)
407
+		if ($this->attackColour == $colour)
408 408
 			return;
409
-		$this->attackColour=$colour;
410
-		$this->hasChanged=true;
409
+		$this->attackColour = $colour;
410
+		$this->hasChanged = true;
411 411
 //		$this->db->query('UPDATE player SET attack_warning = ' . $this->db->escapeString($this->attackColour) . ' WHERE ' . $this->SQL . ' LIMIT 1');
412 412
 	}
413 413
 
@@ -416,30 +416,30 @@  discard block
 block discarded – undo
416 416
 	}
417 417
 
418 418
 	function increaseBank($credits) {
419
-		if($credits < 0)
419
+		if ($credits < 0)
420 420
 			throw new Exception('Trying to increase negative credits.');
421
-		if($credits == 0)
421
+		if ($credits == 0)
422 422
 			return;
423 423
 		$credits += $this->bank;
424 424
 		$this->setBank($credits);
425 425
 	}
426 426
 	function decreaseBank($credits) {
427
-		if($credits < 0)
427
+		if ($credits < 0)
428 428
 			throw new Exception('Trying to decrease negative credits.');
429
-		if($credits == 0)
429
+		if ($credits == 0)
430 430
 			return;
431 431
 		$credits = $this->bank - $credits;
432 432
 		$this->setBank($credits);
433 433
 	}
434 434
 	function setBank($credits) {
435
-		if($this->bank == $credits)
435
+		if ($this->bank == $credits)
436 436
 			return;
437
-		if($credits < 0)
437
+		if ($credits < 0)
438 438
 			throw new Exception('Trying to set negative credits.');
439
-		if($credits > MAX_MONEY)
439
+		if ($credits > MAX_MONEY)
440 440
 			throw new Exception('Trying to set more than max credits.');
441 441
 		$this->bank = $credits;
442
-		$this->hasChanged=true;
442
+		$this->hasChanged = true;
443 443
 //		$this->db->query('UPDATE player SET bank = '.$this->bank.' WHERE '.$this->SQL.' LIMIT 1');
444 444
 	}
445 445
 
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
 	}
449 449
 
450 450
 	function setLastNewsUpdate($time) {
451
-		if($this->lastNewsUpdate == $time)
451
+		if ($this->lastNewsUpdate == $time)
452 452
 			return;
453
-		$this->lastNewsUpdate=$time;
454
-		$this->hasChanged=true;
453
+		$this->lastNewsUpdate = $time;
454
+		$this->hasChanged = true;
455 455
 //		$this->db->query('UPDATE player SET last_news_update = ' . $time . ' WHERE ' . $this->SQL . ' LIMIT 1');
456 456
 	}
457 457
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * Calculate the time in seconds between the given time and when the
468 468
 	 * player will be at max turns.
469 469
 	 */
470
-	public function getTimeUntilMaxTurns($time, $forceUpdate=false) {
470
+	public function getTimeUntilMaxTurns($time, $forceUpdate = false) {
471 471
 		$timeDiff = $time - $this->getLastTurnUpdate();
472 472
 		$turnsDiff = $this->getMaxTurns() - $this->getTurns();
473 473
 		$ship = $this->getShip($forceUpdate);
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 
479 479
 	// Turns only update when player is active.
480 480
 	// Calculate turns gained between given time and the last turn update
481
-	public function getTurnsGained($time, $forceUpdate=false) {
481
+	public function getTurnsGained($time, $forceUpdate = false) {
482 482
 		$timeDiff = $time - $this->getLastTurnUpdate();
483 483
 		$ship = $this->getShip($forceUpdate);
484 484
 		$extraTurns = floor($timeDiff * $ship->getRealSpeed() / 3600);
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 			$newLastTurnUpdate = $this->getLastTurnUpdate() + ceil($extraTurns * 3600 / $ship->getRealSpeed());
500 500
 
501 501
 			$startTurnsDate = $this->getGame()->getStartTurnsDate();
502
-			if($startTurnsDate < $newLastTurnUpdate && $startTurnsDate >= $this->getLastTurnUpdate()) {
502
+			if ($startTurnsDate < $newLastTurnUpdate && $startTurnsDate >= $this->getLastTurnUpdate()) {
503 503
 				$startingTurns = min($ship->getRealSpeed() * $this->getGame()->getStartTurnHours(), $this->getMaxTurns() - $this->getTurns());
504 504
 				$extraUpdateTime = (ceil($startingTurns) - $startingTurns) * 3600 / $ship->getRealSpeed();
505 505
 				$extraTurns += $startingTurns;
@@ -516,10 +516,10 @@  discard block
 block discarded – undo
516 516
 	}
517 517
 
518 518
 	function setIgnoreGlobals($bool) {
519
-		if($this->ignoreGlobals == $bool)
519
+		if ($this->ignoreGlobals == $bool)
520 520
 			return;
521
-		$this->ignoreGlobals=$bool;
522
-		$this->hasChanged=true;
521
+		$this->ignoreGlobals = $bool;
522
+		$this->hasChanged = true;
523 523
 //		$this->db->query('UPDATE player SET ignore_globals = '.$this->db->escapeBoolean($bool).' WHERE '.$this->SQL.' LIMIT 1');
524 524
 	}
525 525
 
@@ -529,10 +529,10 @@  discard block
 block discarded – undo
529 529
 	}
530 530
 
531 531
 	function setLastPort($lastPort) {
532
-		if($this->lastPort == $lastPort)
532
+		if ($this->lastPort == $lastPort)
533 533
 			return;
534
-		$this->lastPort=$lastPort;
535
-		$this->hasChanged=true;
534
+		$this->lastPort = $lastPort;
535
+		$this->hasChanged = true;
536 536
 //		$this->db->query('UPDATE player SET last_port = ' . $this->lastPort . ' WHERE ' . $this->SQL . ' LIMIT 1');
537 537
 	}
538 538
 
@@ -541,10 +541,10 @@  discard block
 block discarded – undo
541 541
 	}
542 542
 
543 543
 	function setDisplayMissions($bool) {
544
-		if($this->displayMissions == $bool)
544
+		if ($this->displayMissions == $bool)
545 545
 			return;
546
-		$this->displayMissions=$bool;
547
-		$this->hasChanged=true;
546
+		$this->displayMissions = $bool;
547
+		$this->hasChanged = true;
548 548
 	}
549 549
 
550 550
 	function isDisplayWeapons() {
@@ -552,10 +552,10 @@  discard block
 block discarded – undo
552 552
 	}
553 553
 
554 554
 	function setDisplayWeapons($bool) {
555
-		if($this->displayWeapons == $bool)
555
+		if ($this->displayWeapons == $bool)
556 556
 			return;
557
-		$this->displayWeapons=$bool;
558
-		$this->hasChanged=true;
557
+		$this->displayWeapons = $bool;
558
+		$this->hasChanged = true;
559 559
 	}
560 560
 
561 561
 	function isForceDropMessages() {
@@ -563,10 +563,10 @@  discard block
 block discarded – undo
563 563
 	}
564 564
 
565 565
 	function setForceDropMessages($bool) {
566
-		if($this->forceDropMessages == $bool)
566
+		if ($this->forceDropMessages == $bool)
567 567
 			return;
568
-		$this->forceDropMessages=$bool;
569
-		$this->hasChanged=true;
568
+		$this->forceDropMessages = $bool;
569
+		$this->hasChanged = true;
570 570
 	}
571 571
 
572 572
 	function getScoutMessageGroupLimit() {
@@ -596,15 +596,15 @@  discard block
 block discarded – undo
596 596
 	}
597 597
 
598 598
 	function setLastTurnUpdate($time) {
599
-		if($this->lastTurnUpdate == $time)
599
+		if ($this->lastTurnUpdate == $time)
600 600
 			return;
601
-		$this->lastTurnUpdate=$time;
602
-		$this->hasChanged=true;
601
+		$this->lastTurnUpdate = $time;
602
+		$this->hasChanged = true;
603 603
 //		$sql = $this->db->query('UPDATE player SET last_turn_update = ' . $this->lastTurnUpdate . ' WHERE '. $this->SQL . ' LIMIT 1');
604 604
 	}
605 605
 
606 606
 	protected function getPureRelationsData() {
607
-		if(!isset($this->pureRelations)) {
607
+		if (!isset($this->pureRelations)) {
608 608
 			//get relations
609 609
 			$RACES = Globals::getRaces();
610 610
 			$this->pureRelations = array();
@@ -618,40 +618,40 @@  discard block
 block discarded – undo
618 618
 		}
619 619
 	}
620 620
 
621
-	function increaseRelationsByTrade($numGoods,$raceID) {
622
-		$relations = ceil(min($numGoods,300)/30);
621
+	function increaseRelationsByTrade($numGoods, $raceID) {
622
+		$relations = ceil(min($numGoods, 300) / 30);
623 623
 		//Cap relations to a max of 1 after 500 have been reached
624
-		if($this->getPureRelation($raceID) + $relations >= 500)
624
+		if ($this->getPureRelation($raceID) + $relations >= 500)
625 625
 			$relations = max(1, min($relations, 500 - $this->getPureRelation($raceID)));
626
-		$this->increaseRelations($relations,$raceID);
626
+		$this->increaseRelations($relations, $raceID);
627 627
 	}
628 628
 
629
-	function decreaseRelationsByTrade($numGoods,$raceID) {
630
-		$relations = ceil(min($numGoods,300)/30);
631
-		$this->decreaseRelations($relations,$raceID);
629
+	function decreaseRelationsByTrade($numGoods, $raceID) {
630
+		$relations = ceil(min($numGoods, 300) / 30);
631
+		$this->decreaseRelations($relations, $raceID);
632 632
 	}
633 633
 
634
-	function increaseRelations($relations,$raceID) {
635
-		if($relations < 0)
634
+	function increaseRelations($relations, $raceID) {
635
+		if ($relations < 0)
636 636
 			throw new Exception('Trying to increase negative relations.');
637
-		if($relations == 0)
637
+		if ($relations == 0)
638 638
 			return;
639 639
 		$relations += $this->getPureRelation($raceID);
640
-		$this->setRelations($relations,$raceID);
640
+		$this->setRelations($relations, $raceID);
641 641
 	}
642
-	function decreaseRelations($relations,$raceID) {
643
-		if($relations < 0)
642
+	function decreaseRelations($relations, $raceID) {
643
+		if ($relations < 0)
644 644
 			throw new Exception('Trying to decrease negative relations.');
645
-		if($relations == 0)
645
+		if ($relations == 0)
646 646
 			return;
647 647
 		$relations = $this->getPureRelation($raceID) - $relations;
648
-		$this->setRelations($relations,$raceID);
648
+		$this->setRelations($relations, $raceID);
649 649
 	}
650
-	function setRelations($relations,$raceID) {
650
+	function setRelations($relations, $raceID) {
651 651
 		$this->getRelations();
652
-		if($this->pureRelations[$raceID] == $relations)
652
+		if ($this->pureRelations[$raceID] == $relations)
653 653
 			return;
654
-		if($relations < MIN_RELATIONS)
654
+		if ($relations < MIN_RELATIONS)
655 655
 			$relations = MIN_RELATIONS;
656 656
 		$relationsDiff = $relations - $this->pureRelations[$raceID];
657 657
 		$this->pureRelations[$raceID] = $relations;
@@ -664,9 +664,9 @@  discard block
 block discarded – undo
664 664
 	 * This will flag the player as having used their free name change.
665 665
 	 */
666 666
 	public function setPlayerNameByPlayer($playerName) {
667
-		$this->playerName=$playerName;
667
+		$this->playerName = $playerName;
668 668
 		$this->setNameChanged(true);
669
-		$this->hasChanged=true;
669
+		$this->hasChanged = true;
670 670
 	}
671 671
 
672 672
 	public function isNameChanged() {
@@ -675,15 +675,15 @@  discard block
 block discarded – undo
675 675
 
676 676
 	public function setNameChanged($bool) {
677 677
 		$this->nameChanged = $bool;
678
-		$this->hasChanged=true;
678
+		$this->hasChanged = true;
679 679
 	}
680 680
 
681 681
 	public function hasCustomShipName() {
682
-		return $this->getCustomShipName()!==false;
682
+		return $this->getCustomShipName() !== false;
683 683
 	}
684 684
 
685 685
 	public function getCustomShipName() {
686
-		if(!isset($this->customShipName)) {
686
+		if (!isset($this->customShipName)) {
687 687
 			$this->db->query('SELECT * FROM ship_has_name WHERE ' . $this->SQL . ' LIMIT 1');
688 688
 			if ($this->db->nextRecord()) {
689 689
 				$this->customShipName = $this->db->getField('ship_name');
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	}
697 697
 
698 698
 	protected function getGadgetsData() {
699
-		if(!isset($this->gadgets)) {
699
+		if (!isset($this->gadgets)) {
700 700
 			//Get Player Gadgets
701 701
 			$this->db->query('SELECT gadget_id,equipped,cooldown,lasts_until FROM player_has_gadget WHERE ' . $this->SQL);
702 702
 			$this->gadgets = array();
@@ -705,67 +705,67 @@  discard block
 block discarded – undo
705 705
 		}
706 706
 	}
707 707
 
708
-	public function setGadgets($keyOrUpdateArray,$value) {
708
+	public function setGadgets($keyOrUpdateArray, $value) {
709 709
 		$this->getGadgets();
710 710
 
711
-		if(is_array($keyOrUpdateArray)) {
711
+		if (is_array($keyOrUpdateArray)) {
712 712
 			$set = '';
713
-			foreach($keyOrUpdateArray as $key => $newInfo) {
713
+			foreach ($keyOrUpdateArray as $key => $newInfo) {
714 714
 				$field = $this->gadgetKeyToField($key);
715
-				if($field!==false) {
716
-					foreach($this->gadgets as $gadgetID => $gadget) {
715
+				if ($field !== false) {
716
+					foreach ($this->gadgets as $gadgetID => $gadget) {
717 717
 						$this->gadgets[$gadgetID][$key] = $newInfo;
718 718
 					}
719
-					$set .= '`' . $field . '` = '.$this->db->escapeString($newInfo).',';
719
+					$set .= '`' . $field . '` = ' . $this->db->escapeString($newInfo) . ',';
720 720
 				}
721 721
 			}
722
-			if($set!=='') {
723
-				$set=substr($set,0,-1);
724
-				$this->db->query('UPDATE player_has_gadget SET '.$set.' WHERE '.$this->SQL.' LIMIT '.count($this->gadgets));
722
+			if ($set !== '') {
723
+				$set = substr($set, 0, -1);
724
+				$this->db->query('UPDATE player_has_gadget SET ' . $set . ' WHERE ' . $this->SQL . ' LIMIT ' . count($this->gadgets));
725 725
 			}
726 726
 		}
727 727
 		else {
728 728
 			$field = $this->gadgetKeyToField($keyOrUpdateArray);
729
-			if($field!==false) {
730
-				foreach($this->gadgets as $gadgetID => $gadget) {
729
+			if ($field !== false) {
730
+				foreach ($this->gadgets as $gadgetID => $gadget) {
731 731
 					$this->gadgets[$gadgetID][$keyOrUpdateArray] = $value;
732 732
 				}
733
-				$this->db->query('UPDATE player_has_gadget SET `'.$field.'` = ' . $this->db->escapeString($value) . ' WHERE '.$this->SQL.' LIMIT '.count($this->gadgets));
733
+				$this->db->query('UPDATE player_has_gadget SET `' . $field . '` = ' . $this->db->escapeString($value) . ' WHERE ' . $this->SQL . ' LIMIT ' . count($this->gadgets));
734 734
 			}
735 735
 		}
736 736
 	}
737 737
 
738
-	function setGadget($gadgetID,$keyOrUpdateArray,$value) {
739
-		if(!is_numeric($gadgetID)) {
738
+	function setGadget($gadgetID, $keyOrUpdateArray, $value) {
739
+		if (!is_numeric($gadgetID)) {
740 740
 			global $GADGETS;
741 741
 			$gadgetID = $GADGETS[$gadgetID]['ID'];
742 742
 		}
743 743
 		$this->getGadgets();
744
-		if(isset($this->gadgets[$gadgetID])) {
745
-			if(is_array($keyOrUpdateArray)) {
744
+		if (isset($this->gadgets[$gadgetID])) {
745
+			if (is_array($keyOrUpdateArray)) {
746 746
 				$set = '';
747
-				foreach($keyOrUpdateArray as $key => $newInfo) {
747
+				foreach ($keyOrUpdateArray as $key => $newInfo) {
748 748
 					$field = $this->gadgetKeyToField($key);
749
-					if($field!==false) {
750
-						if($this->gadgets[$gadgetID][$key] != $newInfo) {
751
-							$this->gadgets[$gadgetID][$key]=$newInfo;
752
-							$set .= '`' . $field . '` = '.$this->db->escapeString($newInfo).',';
749
+					if ($field !== false) {
750
+						if ($this->gadgets[$gadgetID][$key] != $newInfo) {
751
+							$this->gadgets[$gadgetID][$key] = $newInfo;
752
+							$set .= '`' . $field . '` = ' . $this->db->escapeString($newInfo) . ',';
753 753
 						}
754 754
 					}
755 755
 				}
756
-				if($set!=='') {
757
-					$set=substr($set,0,-1);
758
-					$this->db->query('UPDATE player_has_gadget SET '.$set.' WHERE '.$this->SQL.' AND gadget_id = ' . $this->db->escapeNumber($gadgetID) . ' LIMIT 1');
756
+				if ($set !== '') {
757
+					$set = substr($set, 0, -1);
758
+					$this->db->query('UPDATE player_has_gadget SET ' . $set . ' WHERE ' . $this->SQL . ' AND gadget_id = ' . $this->db->escapeNumber($gadgetID) . ' LIMIT 1');
759 759
 					return true;
760 760
 				}
761 761
 			}
762 762
 			else {
763 763
 				$field = $this->gadgetKeyToField($keyOrUpdateArray);
764
-				if($field!==false) {
765
-					if($this->gadgets[$gadgetID][$keyOrUpdateArray] == $value)
764
+				if ($field !== false) {
765
+					if ($this->gadgets[$gadgetID][$keyOrUpdateArray] == $value)
766 766
 						return;
767
-					$this->gadgets[$gadgetID][$keyOrUpdateArray]=$value;
768
-					$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');
767
+					$this->gadgets[$gadgetID][$keyOrUpdateArray] = $value;
768
+					$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 769
 					return true;
770 770
 				}
771 771
 			}
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 	}
775 775
 
776 776
 	public function addGadget($gadgetID) {
777
-		if(isset($this->gadgets[$gadgetID]))
777
+		if (isset($this->gadgets[$gadgetID]))
778 778
 			return false;
779 779
 		$this->gadgets[$gadgetID] = array('Equipped' => 0, 'Cooldown' => 0, 'Expires' => 0);
780 780
 		$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)');
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 	}
783 783
 
784 784
 	protected function gadgetKeyToField($key) {
785
-		switch($key) {
785
+		switch ($key) {
786 786
 			case 'Equipped':
787 787
 				return 'equipped';
788 788
 			break;
@@ -793,12 +793,12 @@  discard block
 block discarded – undo
793 793
 				return 'lasts_until';
794 794
 			break;
795 795
 			default:
796
-				throw new Exception('Invalid gadget attribute: '.$key);
796
+				throw new Exception('Invalid gadget attribute: ' . $key);
797 797
 		}
798 798
 	}
799 799
 
800
-	function getKnowledge($knowledgeType=false) {
801
-		if(!isset($this->knowledge)) {
800
+	function getKnowledge($knowledgeType = false) {
801
+		if (!isset($this->knowledge)) {
802 802
 			//get players faction knowledge
803 803
 			$this->db->query('SELECT * FROM player_knows_faction WHERE ' . $this->SQL . ' LIMIT 1');
804 804
 			if ($this->db->nextRecord()) {
@@ -818,15 +818,15 @@  discard block
 block discarded – undo
818 818
 				$this->knowledge['Underground'] = 0;
819 819
 			}
820 820
 		}
821
-		if($knowledgeType===false)
821
+		if ($knowledgeType === false)
822 822
 			return $this->knowledge;
823
-		if(isset($this->knowledge[$knowledgeType]))
823
+		if (isset($this->knowledge[$knowledgeType]))
824 824
 			return $this->knowledge[$knowledgeType];
825 825
 		return false;
826 826
 	}
827 827
 
828 828
 	public function killPlayer($sectorID) {
829
-		$sector = SmrSector::getSector($this->getGameID(),$sectorID);
829
+		$sector = SmrSector::getSector($this->getGameID(), $sectorID);
830 830
 		//msg taken care of in trader_att_proc.php
831 831
 		// forget plotted course
832 832
 		$this->deletePlottedCourse();
@@ -839,11 +839,11 @@  discard block
 block discarded – undo
839 839
 							WHERE game_id = ' . $this->db->escapeNumber($this->getGameID()) . ' AND alliance_id = ' . $this->db->escapeNumber($this->getAllianceID()) . ' LIMIT 1');
840 840
 
841 841
 		// record death stat
842
-		$this->increaseHOF(1,array('Dying','Deaths'), HOF_PUBLIC);
842
+		$this->increaseHOF(1, array('Dying', 'Deaths'), HOF_PUBLIC);
843 843
 		//record cost of ship lost
844
-		$this->increaseHOF($this->getShip()->getCost(),array('Dying','Money','Cost Of Ships Lost'), HOF_PUBLIC);
844
+		$this->increaseHOF($this->getShip()->getCost(), array('Dying', 'Money', 'Cost Of Ships Lost'), HOF_PUBLIC);
845 845
 		// reset turns since last death
846
-		$this->setHOF(0,array('Movement','Turns Used','Since Last Death'), HOF_ALLIANCE);
846
+		$this->setHOF(0, array('Movement', 'Turns Used', 'Since Last Death'), HOF_ALLIANCE);
847 847
 
848 848
 		// 1/4 of ship value -> insurance
849 849
 		$newCredits = round($this->getShip()->getCost() / 4);
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 
863 863
 		// Update turns due to ship change
864 864
 		$new_speed = $this->getShip()->getSpeed();
865
-		$this->setTurns(round($this->turns / $old_speed * $new_speed),100);
865
+		$this->setTurns(round($this->turns / $old_speed * $new_speed), 100);
866 866
 	}
867 867
 
868 868
 	static public function getHome($gameID, $raceID) {
@@ -893,16 +893,16 @@  discard block
 block discarded – undo
893 893
 
894 894
 		if ($this->hasCustomShipName()) {
895 895
 			$named_ship = strip_tags($this->getCustomShipName(), '<font><span><img>');
896
-			$msg .= ' flying <span class="yellow">'.$named_ship.'</span>';
896
+			$msg .= ' flying <span class="yellow">' . $named_ship . '</span>';
897 897
 		}
898 898
 		$msg .= ' was destroyed by ' . $killer->getBBLink();
899 899
 		if ($killer->hasCustomShipName()) {
900 900
 			$named_ship = strip_tags($killer->getCustomShipName(), '<font><span><img>');
901
-			$msg .= ' flying <span class="yellow">'.$named_ship.'</span>';
901
+			$msg .= ' flying <span class="yellow">' . $named_ship . '</span>';
902 902
 		}
903 903
 		$msg .= ' in Sector&nbsp;' . Globals::getSectorBBLink($this->getSectorID());
904 904
 		$this->getSector()->increaseBattles(1);
905
-		$this->db->query('INSERT INTO news (game_id,time,news_message,type,killer_id,killer_alliance,dead_id,dead_alliance) VALUES (' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeNumber(TIME) . ',' . $this->db->escapeString($msg,true) . ',\'regular\',' . $this->db->escapeNumber($killer->getAccountID()) . ',' . $this->db->escapeNumber($killer->getAllianceID()) . ',' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getAllianceID()) . ')');
905
+		$this->db->query('INSERT INTO news (game_id,time,news_message,type,killer_id,killer_alliance,dead_id,dead_alliance) VALUES (' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeNumber(TIME) . ',' . $this->db->escapeString($msg, true) . ',\'regular\',' . $this->db->escapeNumber($killer->getAccountID()) . ',' . $this->db->escapeNumber($killer->getAllianceID()) . ',' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getAllianceID()) . ')');
906 906
 
907 907
 		self::sendMessageFromFedClerk($this->getGameID(), $this->getAccountID(), 'You were <span class="red">DESTROYED</span> by ' . $killer->getBBLink() . ' in sector ' . Globals::getSectorBBLink($this->getSectorID()));
908 908
 		self::sendMessageFromFedClerk($this->getGameID(), $killer->getAccountID(), 'You <span class="red">DESTROYED</span>&nbsp;' . $this->getBBLink() . ' in sector ' . Globals::getSectorBBLink($this->getSectorID()));
@@ -924,19 +924,19 @@  discard block
 block discarded – undo
924 924
 		$relation = $relations[$killer->getRaceID()];
925 925
 
926 926
 		$alignChangePerRelation = 0.1;
927
-		if($relation >= RELATIONS_PEACE || $relation <= RELATIONS_WAR)
927
+		if ($relation >= RELATIONS_PEACE || $relation <= RELATIONS_WAR)
928 928
 			$alignChangePerRelation = 0.04;
929 929
 
930 930
 		$return['KillerAlign'] = -$relation * $alignChangePerRelation; //Lose relations when killing a peaceful race
931
-		if($return['KillerAlign'] > 0) {
931
+		if ($return['KillerAlign'] > 0) {
932 932
 			$killer->increaseAlignment($return['KillerAlign']);
933 933
 		}
934 934
 		else {
935 935
 			$killer->decreaseAlignment(-$return['KillerAlign']);
936 936
 		}
937 937
 		// War setting gives them military pay
938
-		if($relation <= RELATIONS_WAR) {
939
-			$killer->increaseMilitaryPayment(-floor($relation * 100 * (pow($return['KillerExp']/2,0.25))));
938
+		if ($relation <= RELATIONS_WAR) {
939
+			$killer->increaseMilitaryPayment(-floor($relation * 100 * (pow($return['KillerExp'] / 2, 0.25))));
940 940
 		}
941 941
 
942 942
 		//check for federal bounty being offered for current port raiders;
@@ -961,69 +961,69 @@  discard block
 block discarded – undo
961 961
 			'Type' => 'None',
962 962
 			'Amount' => 0
963 963
 		);
964
-		if($alignmentDiff >= 200) {
964
+		if ($alignmentDiff >= 200) {
965 965
 			// If the podded players alignment makes them deputy or member then set bounty
966
-			if($this->getAlignment() >= 100) {
966
+			if ($this->getAlignment() >= 100) {
967 967
 				$return['BountyGained']['Type'] = 'HQ';
968 968
 			}
969 969
 			else if ($this->getAlignment() <= 100) {
970 970
 				$return['BountyGained']['Type'] = 'UG';
971 971
 			}
972 972
 
973
-			if($return['BountyGained']['Type'] != 'None') {
973
+			if ($return['BountyGained']['Type'] != 'None') {
974 974
 				$return['BountyGained']['Amount'] = floor(pow($alignmentDiff, 2.56));
975 975
 				$killer->increaseCurrentBountyAmount($return['BountyGained']['Type'], $return['BountyGained']['Amount']);
976 976
 			}
977 977
 		}
978 978
 
979
-		if($this->isNPC()) {
980
-			$killer->increaseHOF($return['KillerExp'],array('Killing','NPC','Experience','Gained'), HOF_PUBLIC);
981
-			$killer->increaseHOF($this->getExperience(),array('Killing','NPC','Experience','Of Traders Killed'), HOF_PUBLIC);
979
+		if ($this->isNPC()) {
980
+			$killer->increaseHOF($return['KillerExp'], array('Killing', 'NPC', 'Experience', 'Gained'), HOF_PUBLIC);
981
+			$killer->increaseHOF($this->getExperience(), array('Killing', 'NPC', 'Experience', 'Of Traders Killed'), HOF_PUBLIC);
982 982
 
983
-			$killer->increaseHOF($return['DeadExp'],array('Killing','Experience','Lost By NPCs Killed'), HOF_PUBLIC);
983
+			$killer->increaseHOF($return['DeadExp'], array('Killing', 'Experience', 'Lost By NPCs Killed'), HOF_PUBLIC);
984 984
 
985
-			$killer->increaseHOF($return['KillerCredits'],array('Killing','NPC','Money','Lost By Traders Killed'), HOF_PUBLIC);
986
-			$killer->increaseHOF($return['KillerCredits'],array('Killing','NPC','Money','Gain'), HOF_PUBLIC);
987
-			$killer->increaseHOF($this->getShip()->getCost(),array('Killing','NPC','Money','Cost Of Ships Killed'), HOF_PUBLIC);
985
+			$killer->increaseHOF($return['KillerCredits'], array('Killing', 'NPC', 'Money', 'Lost By Traders Killed'), HOF_PUBLIC);
986
+			$killer->increaseHOF($return['KillerCredits'], array('Killing', 'NPC', 'Money', 'Gain'), HOF_PUBLIC);
987
+			$killer->increaseHOF($this->getShip()->getCost(), array('Killing', 'NPC', 'Money', 'Cost Of Ships Killed'), HOF_PUBLIC);
988 988
 
989
-			if($return['KillerAlign'] > 0) {
990
-				$killer->increaseHOF($return['KillerAlign'],array('Killing','NPC','Alignment','Gain'), HOF_PUBLIC);
989
+			if ($return['KillerAlign'] > 0) {
990
+				$killer->increaseHOF($return['KillerAlign'], array('Killing', 'NPC', 'Alignment', 'Gain'), HOF_PUBLIC);
991 991
 			}
992 992
 			else {
993
-				$killer->increaseHOF(-$return['KillerAlign'],array('Killing','NPC','Alignment','Loss'), HOF_PUBLIC);
993
+				$killer->increaseHOF(-$return['KillerAlign'], array('Killing', 'NPC', 'Alignment', 'Loss'), HOF_PUBLIC);
994 994
 			}
995 995
 
996
-			$killer->increaseHOF($return['BountyGained']['Amount'],array('Killing','NPC','Money','Bounty Gained'), HOF_PUBLIC);
996
+			$killer->increaseHOF($return['BountyGained']['Amount'], array('Killing', 'NPC', 'Money', 'Bounty Gained'), HOF_PUBLIC);
997 997
 
998
-			$killer->increaseHOF(1,array('Killing','NPC Kills'), HOF_PUBLIC);
998
+			$killer->increaseHOF(1, array('Killing', 'NPC Kills'), HOF_PUBLIC);
999 999
 		}
1000 1000
 		else {
1001
-			$killer->increaseHOF($return['KillerExp'],array('Killing','Experience','Gained'), HOF_PUBLIC);
1002
-			$killer->increaseHOF($this->getExperience(),array('Killing','Experience','Of Traders Killed'), HOF_PUBLIC);
1001
+			$killer->increaseHOF($return['KillerExp'], array('Killing', 'Experience', 'Gained'), HOF_PUBLIC);
1002
+			$killer->increaseHOF($this->getExperience(), array('Killing', 'Experience', 'Of Traders Killed'), HOF_PUBLIC);
1003 1003
 
1004
-			$killer->increaseHOF($return['DeadExp'],array('Killing','Experience','Lost By Traders Killed'), HOF_PUBLIC);
1004
+			$killer->increaseHOF($return['DeadExp'], array('Killing', 'Experience', 'Lost By Traders Killed'), HOF_PUBLIC);
1005 1005
 
1006
-			$killer->increaseHOF($return['KillerCredits'],array('Killing','Money','Lost By Traders Killed'), HOF_PUBLIC);
1007
-			$killer->increaseHOF($return['KillerCredits'],array('Killing','Money','Gain'), HOF_PUBLIC);
1008
-			$killer->increaseHOF($this->getShip()->getCost(),array('Killing','Money','Cost Of Ships Killed'), HOF_PUBLIC);
1006
+			$killer->increaseHOF($return['KillerCredits'], array('Killing', 'Money', 'Lost By Traders Killed'), HOF_PUBLIC);
1007
+			$killer->increaseHOF($return['KillerCredits'], array('Killing', 'Money', 'Gain'), HOF_PUBLIC);
1008
+			$killer->increaseHOF($this->getShip()->getCost(), array('Killing', 'Money', 'Cost Of Ships Killed'), HOF_PUBLIC);
1009 1009
 
1010
-			if($return['KillerAlign'] > 0) {
1011
-				$killer->increaseHOF($return['KillerAlign'],array('Killing','Alignment','Gain'), HOF_PUBLIC);
1010
+			if ($return['KillerAlign'] > 0) {
1011
+				$killer->increaseHOF($return['KillerAlign'], array('Killing', 'Alignment', 'Gain'), HOF_PUBLIC);
1012 1012
 			}
1013 1013
 			else {
1014
-				$killer->increaseHOF(-$return['KillerAlign'],array('Killing','Alignment','Loss'), HOF_PUBLIC);
1014
+				$killer->increaseHOF(-$return['KillerAlign'], array('Killing', 'Alignment', 'Loss'), HOF_PUBLIC);
1015 1015
 			}
1016 1016
 
1017
-			$killer->increaseHOF($return['BountyGained']['Amount'],array('Killing','Money','Bounty Gained'), HOF_PUBLIC);
1017
+			$killer->increaseHOF($return['BountyGained']['Amount'], array('Killing', 'Money', 'Bounty Gained'), HOF_PUBLIC);
1018 1018
 
1019
-			if($this->getShip()->getAttackRatingWithMaxCDs() <= MAX_ATTACK_RATING_NEWBIE && $this->hasNewbieStatus() && !$killer->hasNewbieStatus()) { //Newbie kill
1020
-				$killer->increaseHOF(1,array('Killing','Newbie Kills'), HOF_PUBLIC);
1019
+			if ($this->getShip()->getAttackRatingWithMaxCDs() <= MAX_ATTACK_RATING_NEWBIE && $this->hasNewbieStatus() && !$killer->hasNewbieStatus()) { //Newbie kill
1020
+				$killer->increaseHOF(1, array('Killing', 'Newbie Kills'), HOF_PUBLIC);
1021 1021
 			}
1022 1022
 			else {
1023 1023
 				$killer->increaseKills(1);
1024
-				$killer->increaseHOF(1,array('Killing','Kills'), HOF_PUBLIC);
1024
+				$killer->increaseHOF(1, array('Killing', 'Kills'), HOF_PUBLIC);
1025 1025
 
1026
-				if($killer->hasAlliance()) {
1026
+				if ($killer->hasAlliance()) {
1027 1027
 					$this->db->query('UPDATE alliance SET alliance_kills=alliance_kills+1 WHERE alliance_id=' . $this->db->escapeNumber($killer->getAllianceID()) . ' AND game_id=' . $this->db->escapeNumber($killer->getGameID()) . ' LIMIT 1');
1028 1028
 				}
1029 1029
 
@@ -1032,13 +1032,13 @@  discard block
 block discarded – undo
1032 1032
 			}
1033 1033
 		}
1034 1034
 
1035
-		$this->increaseHOF($return['BountyGained']['Amount'],array('Dying','Players','Money','Bounty Gained By Killer'), HOF_PUBLIC);
1036
-		$this->increaseHOF($return['KillerExp'],array('Dying','Players','Experience','Gained By Killer'), HOF_PUBLIC);
1037
-		$this->increaseHOF($return['DeadExp'],array('Dying','Experience','Lost'), HOF_PUBLIC);
1038
-		$this->increaseHOF($return['DeadExp'],array('Dying','Players','Experience','Lost'), HOF_PUBLIC);
1039
-		$this->increaseHOF($return['KillerCredits'],array('Dying','Players','Money Lost'), HOF_PUBLIC);
1040
-		$this->increaseHOF($this->getShip()->getCost(),array('Dying','Players','Money','Cost Of Ships Lost'), HOF_PUBLIC);
1041
-		$this->increaseHOF(1,array('Dying','Players','Deaths'), HOF_PUBLIC);
1035
+		$this->increaseHOF($return['BountyGained']['Amount'], array('Dying', 'Players', 'Money', 'Bounty Gained By Killer'), HOF_PUBLIC);
1036
+		$this->increaseHOF($return['KillerExp'], array('Dying', 'Players', 'Experience', 'Gained By Killer'), HOF_PUBLIC);
1037
+		$this->increaseHOF($return['DeadExp'], array('Dying', 'Experience', 'Lost'), HOF_PUBLIC);
1038
+		$this->increaseHOF($return['DeadExp'], array('Dying', 'Players', 'Experience', 'Lost'), HOF_PUBLIC);
1039
+		$this->increaseHOF($return['KillerCredits'], array('Dying', 'Players', 'Money Lost'), HOF_PUBLIC);
1040
+		$this->increaseHOF($this->getShip()->getCost(), array('Dying', 'Players', 'Money', 'Cost Of Ships Lost'), HOF_PUBLIC);
1041
+		$this->increaseHOF(1, array('Dying', 'Players', 'Deaths'), HOF_PUBLIC);
1042 1042
 
1043 1043
 		$this->killPlayer($this->getSectorID());
1044 1044
 		return $return;
@@ -1048,13 +1048,13 @@  discard block
 block discarded – undo
1048 1048
 		$return = array();
1049 1049
 		$owner = $forces->getOwner();
1050 1050
 		// send a message to the person who died
1051
-		self::sendMessageFromFedClerk($this->getGameID(), $owner->getAccountID(), 'Your forces <span class="red">DESTROYED </span>'.$this->getBBLink().' in sector '.Globals::getSectorBBLink($forces->getSectorID()));
1052
-		self::sendMessageFromFedClerk($this->getGameID(), $this->getAccountID(), 'You were <span class="red">DESTROYED</span> by '.$owner->getBBLink().'\'s forces in sector '.Globals::getSectorBBLink($this->getSectorID()));
1051
+		self::sendMessageFromFedClerk($this->getGameID(), $owner->getAccountID(), 'Your forces <span class="red">DESTROYED </span>' . $this->getBBLink() . ' in sector ' . Globals::getSectorBBLink($forces->getSectorID()));
1052
+		self::sendMessageFromFedClerk($this->getGameID(), $this->getAccountID(), 'You were <span class="red">DESTROYED</span> by ' . $owner->getBBLink() . '\'s forces in sector ' . Globals::getSectorBBLink($this->getSectorID()));
1053 1053
 
1054 1054
 		$news_message = $this->getBBLink();
1055 1055
 		if ($this->hasCustomShipName()) {
1056 1056
 			$named_ship = strip_tags($this->getCustomShipName(), '<font><span><img>');
1057
-			$news_message .= ' flying <span class="yellow">'.$named_ship.'</span>';
1057
+			$news_message .= ' flying <span class="yellow">' . $named_ship . '</span>';
1058 1058
 		}
1059 1059
 		$news_message .= ' was destroyed by ' . $owner->getBBLink() . '\'s forces in sector ' . Globals::getSectorBBLink($forces->getSectorID());
1060 1060
 		// insert the news entry
@@ -1072,11 +1072,11 @@  discard block
 block discarded – undo
1072 1072
 		$this->incrementAllianceVsDeaths(ALLIANCE_VS_FORCES);
1073 1073
 		$owner->incrementAllianceVsKills(ALLIANCE_VS_FORCES);
1074 1074
 
1075
-		$this->increaseHOF($return['DeadExp'], array('Dying','Experience','Lost'), HOF_PUBLIC);
1076
-		$this->increaseHOF($return['DeadExp'], array('Dying','Forces','Experience Lost'), HOF_PUBLIC);
1077
-		$this->increaseHOF($return['LostCredits'], array('Dying','Forces','Money Lost'), HOF_PUBLIC);
1078
-		$this->increaseHOF($this->getShip()->getCost(), array('Dying','Forces','Cost Of Ships Lost'), HOF_PUBLIC);
1079
-		$this->increaseHOF(1, array('Dying','Forces','Deaths'), HOF_PUBLIC);
1075
+		$this->increaseHOF($return['DeadExp'], array('Dying', 'Experience', 'Lost'), HOF_PUBLIC);
1076
+		$this->increaseHOF($return['DeadExp'], array('Dying', 'Forces', 'Experience Lost'), HOF_PUBLIC);
1077
+		$this->increaseHOF($return['LostCredits'], array('Dying', 'Forces', 'Money Lost'), HOF_PUBLIC);
1078
+		$this->increaseHOF($this->getShip()->getCost(), array('Dying', 'Forces', 'Cost Of Ships Lost'), HOF_PUBLIC);
1079
+		$this->increaseHOF(1, array('Dying', 'Forces', 'Deaths'), HOF_PUBLIC);
1080 1080
 
1081 1081
 		$this->killPlayer($forces->getSectorID());
1082 1082
 		return $return;
@@ -1085,20 +1085,20 @@  discard block
 block discarded – undo
1085 1085
 	public function &killPlayerByPort(SmrPort $port) {
1086 1086
 		$return = array();
1087 1087
 		// send a message to the person who died
1088
-		self::sendMessageFromFedClerk($this->getGameID(), $this->getAccountID(), 'You were <span class="red">DESTROYED</span> by the defenses of '.$port->getDisplayName());
1088
+		self::sendMessageFromFedClerk($this->getGameID(), $this->getAccountID(), 'You were <span class="red">DESTROYED</span> by the defenses of ' . $port->getDisplayName());
1089 1089
 
1090 1090
 		$news_message = $this->getBBLink();
1091 1091
 		if ($this->hasCustomShipName()) {
1092 1092
 			$named_ship = strip_tags($this->getCustomShipName(), '<font><span><img>');
1093
-			$news_message .= ' flying <span class="yellow">'.$named_ship.'</span>';
1093
+			$news_message .= ' flying <span class="yellow">' . $named_ship . '</span>';
1094 1094
 		}
1095
-		$news_message .= ' was destroyed while invading '.$port->getDisplayName().'.';
1095
+		$news_message .= ' was destroyed while invading ' . $port->getDisplayName() . '.';
1096 1096
 		// insert the news entry
1097 1097
 		$this->db->query('INSERT INTO news (game_id, time, news_message,killer_id,dead_id,dead_alliance)
1098 1098
 						VALUES(' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeNumber(TIME) . ', ' . $this->db->escapeString($news_message) . ',' . $this->db->escapeNumber(ACCOUNT_ID_PORT) . ',' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getAllianceID()) . ')');
1099 1099
 
1100 1100
 		// Player loses between 20% and 28% experience
1101
-		$expLossPercentage = .29 - .09 * $port->getLevel()/$port->getMaxLevel();
1101
+		$expLossPercentage = .29 - .09 * $port->getLevel() / $port->getMaxLevel();
1102 1102
 		$return['DeadExp'] = max(0, floor($this->getExperience() * $expLossPercentage));
1103 1103
 		$this->decreaseExperience($return['DeadExp']);
1104 1104
 
@@ -1107,11 +1107,11 @@  discard block
 block discarded – undo
1107 1107
 		// alliance vs. alliance stats
1108 1108
 		$this->incrementAllianceVsDeaths(ALLIANCE_VS_PORTS);
1109 1109
 
1110
-		$this->increaseHOF($return['DeadExp'], array('Dying','Experience','Lost'), HOF_PUBLIC);
1111
-		$this->increaseHOF($return['DeadExp'], array('Dying','Ports','Experience Lost'), HOF_PUBLIC);
1112
-		$this->increaseHOF($return['LostCredits'], array('Dying','Ports','Money Lost'), HOF_PUBLIC);
1113
-		$this->increaseHOF($this->getShip()->getCost(), array('Dying','Ports','Cost Of Ships Lost'), HOF_PUBLIC);
1114
-		$this->increaseHOF(1, array('Dying','Ports','Deaths'), HOF_PUBLIC);
1110
+		$this->increaseHOF($return['DeadExp'], array('Dying', 'Experience', 'Lost'), HOF_PUBLIC);
1111
+		$this->increaseHOF($return['DeadExp'], array('Dying', 'Ports', 'Experience Lost'), HOF_PUBLIC);
1112
+		$this->increaseHOF($return['LostCredits'], array('Dying', 'Ports', 'Money Lost'), HOF_PUBLIC);
1113
+		$this->increaseHOF($this->getShip()->getCost(), array('Dying', 'Ports', 'Cost Of Ships Lost'), HOF_PUBLIC);
1114
+		$this->increaseHOF(1, array('Dying', 'Ports', 'Deaths'), HOF_PUBLIC);
1115 1115
 
1116 1116
 		$this->killPlayer($port->getSectorID());
1117 1117
 		return $return;
@@ -1121,13 +1121,13 @@  discard block
 block discarded – undo
1121 1121
 		$return = array();
1122 1122
 		// send a message to the person who died
1123 1123
 		$planetOwner = $planet->getOwner();
1124
-		self::sendMessageFromFedClerk($this->getGameID(), $planetOwner->getAccountID(), 'Your planet <span class="red">DESTROYED</span>&nbsp;'.$this->getBBLink().' in sector '.Globals::getSectorBBLink($planet->getSectorID()));
1125
-		self::sendMessageFromFedClerk($this->getGameID(), $this->getAccountID(), 'You were <span class="red">DESTROYED</span> by the planetary defenses of '.$planet->getDisplayName());
1124
+		self::sendMessageFromFedClerk($this->getGameID(), $planetOwner->getAccountID(), 'Your planet <span class="red">DESTROYED</span>&nbsp;' . $this->getBBLink() . ' in sector ' . Globals::getSectorBBLink($planet->getSectorID()));
1125
+		self::sendMessageFromFedClerk($this->getGameID(), $this->getAccountID(), 'You were <span class="red">DESTROYED</span> by the planetary defenses of ' . $planet->getDisplayName());
1126 1126
 
1127 1127
 		$news_message = $this->getBBLink();
1128 1128
 		if ($this->hasCustomShipName()) {
1129 1129
 			$named_ship = strip_tags($this->getCustomShipName(), '<font><span><img>');
1130
-			$news_message .= ' flying <span class="yellow">'.$named_ship.'</span>';
1130
+			$news_message .= ' flying <span class="yellow">' . $named_ship . '</span>';
1131 1131
 		}
1132 1132
 		$news_message .= ' was destroyed by ' . $planet->getDisplayName() . '\'s planetary defenses in sector ' . Globals::getSectorBBLink($planet->getSectorID()) . '.';
1133 1133
 		// insert the news entry
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
 						VALUES(' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeNumber(TIME) . ', ' . $this->db->escapeString($news_message) . ',' . $this->db->escapeNumber($planetOwner->getAccountID()) . ',' . $this->db->escapeNumber($planetOwner->getAllianceID()) . ',' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getAllianceID()) . ')');
1136 1136
 
1137 1137
 		// Player loses between 20% and 27% experience
1138
-		$expLossPercentage = .27 - .07 * $planet->getLevel()/$planet->getMaxLevel();
1138
+		$expLossPercentage = .27 - .07 * $planet->getLevel() / $planet->getMaxLevel();
1139 1139
 		$return['DeadExp'] = max(0, floor($this->getExperience() * $expLossPercentage));
1140 1140
 		$this->decreaseExperience($return['DeadExp']);
1141 1141
 
@@ -1145,68 +1145,68 @@  discard block
 block discarded – undo
1145 1145
 		$this->incrementAllianceVsDeaths(ALLIANCE_VS_PLANETS);
1146 1146
 		$planetOwner->incrementAllianceVsKills(ALLIANCE_VS_PLANETS);
1147 1147
 
1148
-		$this->increaseHOF($return['DeadExp'], array('Dying','Experience','Lost'), HOF_PUBLIC);
1149
-		$this->increaseHOF($return['DeadExp'], array('Dying','Planets','Experience Lost'), HOF_PUBLIC);
1150
-		$this->increaseHOF($return['LostCredits'], array('Dying','Planets','Money Lost'), HOF_PUBLIC);
1151
-		$this->increaseHOF($this->getShip()->getCost(), array('Dying','Planets','Cost Of Ships Lost'), HOF_PUBLIC);
1152
-		$this->increaseHOF(1, array('Dying','Planets','Deaths'), HOF_PUBLIC);
1148
+		$this->increaseHOF($return['DeadExp'], array('Dying', 'Experience', 'Lost'), HOF_PUBLIC);
1149
+		$this->increaseHOF($return['DeadExp'], array('Dying', 'Planets', 'Experience Lost'), HOF_PUBLIC);
1150
+		$this->increaseHOF($return['LostCredits'], array('Dying', 'Planets', 'Money Lost'), HOF_PUBLIC);
1151
+		$this->increaseHOF($this->getShip()->getCost(), array('Dying', 'Planets', 'Cost Of Ships Lost'), HOF_PUBLIC);
1152
+		$this->increaseHOF(1, array('Dying', 'Planets', 'Deaths'), HOF_PUBLIC);
1153 1153
 
1154 1154
 		$this->killPlayer($planet->getSectorID());
1155 1155
 		return $return;
1156 1156
 	}
1157 1157
 
1158 1158
 	public function save() {
1159
-		if($this->hasChanged === true) {
1160
-			$this->db->query('UPDATE player SET player_name='.$this->db->escapeString($this->playerName).
1161
-				', player_id='.$this->db->escapeNumber($this->playerID).
1162
-				', sector_id='.$this->db->escapeNumber($this->sectorID).
1163
-				', last_sector_id='.$this->db->escapeNumber($this->lastSectorID).
1164
-				', turns='.$this->db->escapeNumber($this->turns).
1165
-				', last_turn_update='.$this->db->escapeNumber($this->lastTurnUpdate).
1166
-				', newbie_turns='.$this->db->escapeNumber($this->newbieTurns).
1167
-				', last_news_update='.$this->db->escapeNumber($this->lastNewsUpdate).
1168
-				', attack_warning='.$this->db->escapeString($this->attackColour).
1169
-				', dead='.$this->db->escapeBoolean($this->dead).
1170
-				', newbie_status='.$this->db->escapeBoolean($this->newbieStatus).
1171
-				', land_on_planet='.$this->db->escapeBoolean($this->landedOnPlanet).
1172
-				', last_active='.$this->db->escapeNumber($this->lastActive).
1173
-				', last_cpl_action='.$this->db->escapeNumber($this->lastCPLAction).
1174
-				', race_id='.$this->db->escapeNumber($this->raceID).
1175
-				', credits='.$this->db->escapeNumber($this->credits).
1176
-				', experience='.$this->db->escapeNumber($this->experience).
1177
-				', alignment='.$this->db->escapeNumber($this->alignment).
1178
-				', military_payment='.$this->db->escapeString($this->militaryPayment).
1159
+		if ($this->hasChanged === true) {
1160
+			$this->db->query('UPDATE player SET player_name=' . $this->db->escapeString($this->playerName) .
1161
+				', player_id=' . $this->db->escapeNumber($this->playerID) .
1162
+				', sector_id=' . $this->db->escapeNumber($this->sectorID) .
1163
+				', last_sector_id=' . $this->db->escapeNumber($this->lastSectorID) .
1164
+				', turns=' . $this->db->escapeNumber($this->turns) .
1165
+				', last_turn_update=' . $this->db->escapeNumber($this->lastTurnUpdate) .
1166
+				', newbie_turns=' . $this->db->escapeNumber($this->newbieTurns) .
1167
+				', last_news_update=' . $this->db->escapeNumber($this->lastNewsUpdate) .
1168
+				', attack_warning=' . $this->db->escapeString($this->attackColour) .
1169
+				', dead=' . $this->db->escapeBoolean($this->dead) .
1170
+				', newbie_status=' . $this->db->escapeBoolean($this->newbieStatus) .
1171
+				', land_on_planet=' . $this->db->escapeBoolean($this->landedOnPlanet) .
1172
+				', last_active=' . $this->db->escapeNumber($this->lastActive) .
1173
+				', last_cpl_action=' . $this->db->escapeNumber($this->lastCPLAction) .
1174
+				', race_id=' . $this->db->escapeNumber($this->raceID) .
1175
+				', credits=' . $this->db->escapeNumber($this->credits) .
1176
+				', experience=' . $this->db->escapeNumber($this->experience) .
1177
+				', alignment=' . $this->db->escapeNumber($this->alignment) .
1178
+				', military_payment=' . $this->db->escapeString($this->militaryPayment) .
1179 1179
 //				', past_knowledge='.$this->db->escapeString($this->pastKnowledge).
1180
-				', alliance_id='.$this->db->escapeNumber($this->allianceID).
1181
-				', alliance_join='.$this->db->escapeNumber($this->allianceJoinable).
1182
-				', ship_type_id='.$this->db->escapeNumber($this->shipID).
1183
-				', kills='.$this->db->escapeNumber($this->kills).
1184
-				', deaths='.$this->db->escapeNumber($this->deaths).
1185
-				', assists='.$this->db->escapeNumber($this->assists).
1186
-				', last_port='.$this->db->escapeNumber($this->lastPort).
1187
-				', bank='.$this->db->escapeNumber($this->bank).
1188
-				', zoom='.$this->db->escapeString($this->zoom).
1189
-				', display_missions='.$this->db->escapeBoolean($this->displayMissions).
1190
-				', display_weapons='.$this->db->escapeBoolean($this->displayWeapons).
1191
-				', force_drop_messages='.$this->db->escapeBoolean($this->forceDropMessages).
1192
-				', group_scout_messages='.$this->db->escapeString($this->groupScoutMessages).
1193
-				', ignore_globals='.$this->db->escapeBoolean($this->ignoreGlobals).
1194
-				', newbie_warning = ' . $this->db->escapeBoolean($this->newbieWarning).
1195
-				', name_changed = ' . $this->db->escapeBoolean($this->nameChanged).
1196
-				', combat_drones_kamikaze_on_mines = ' . $this->db->escapeBoolean($this->combatDronesKamikazeOnMines).
1197
-				' WHERE '.$this->SQL.' LIMIT 1');
1198
-			$this->hasChanged=false;
1199
-		}
1200
-		foreach($this->hasBountyChanged as $key => &$bountyChanged) {
1201
-			if($bountyChanged===true) {
1180
+				', alliance_id=' . $this->db->escapeNumber($this->allianceID) .
1181
+				', alliance_join=' . $this->db->escapeNumber($this->allianceJoinable) .
1182
+				', ship_type_id=' . $this->db->escapeNumber($this->shipID) .
1183
+				', kills=' . $this->db->escapeNumber($this->kills) .
1184
+				', deaths=' . $this->db->escapeNumber($this->deaths) .
1185
+				', assists=' . $this->db->escapeNumber($this->assists) .
1186
+				', last_port=' . $this->db->escapeNumber($this->lastPort) .
1187
+				', bank=' . $this->db->escapeNumber($this->bank) .
1188
+				', zoom=' . $this->db->escapeString($this->zoom) .
1189
+				', display_missions=' . $this->db->escapeBoolean($this->displayMissions) .
1190
+				', display_weapons=' . $this->db->escapeBoolean($this->displayWeapons) .
1191
+				', force_drop_messages=' . $this->db->escapeBoolean($this->forceDropMessages) .
1192
+				', group_scout_messages=' . $this->db->escapeString($this->groupScoutMessages) .
1193
+				', ignore_globals=' . $this->db->escapeBoolean($this->ignoreGlobals) .
1194
+				', newbie_warning = ' . $this->db->escapeBoolean($this->newbieWarning) .
1195
+				', name_changed = ' . $this->db->escapeBoolean($this->nameChanged) .
1196
+				', combat_drones_kamikaze_on_mines = ' . $this->db->escapeBoolean($this->combatDronesKamikazeOnMines) .
1197
+				' WHERE ' . $this->SQL . ' LIMIT 1');
1198
+			$this->hasChanged = false;
1199
+		}
1200
+		foreach ($this->hasBountyChanged as $key => &$bountyChanged) {
1201
+			if ($bountyChanged === true) {
1202 1202
 				$bountyChanged = false;
1203 1203
 				$bounty = $this->getBounty($key);
1204
-				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']) .')');
1204
+				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 1207
 				}
1208 1208
 				else {
1209
-					if($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0)
1209
+					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0)
1210 1210
 						$this->db->query('UPDATE bounty
1211 1211
 							SET amount=' . $this->db->escapeNumber($bounty['Amount']) . ',
1212 1212
 							smr_credits=' . $this->db->escapeString($bounty['SmrCredits']) . ',
@@ -1223,36 +1223,36 @@  discard block
 block discarded – undo
1223 1223
 	}
1224 1224
 
1225 1225
 	public function saveHOF() {
1226
-		if($this->hasHOFChanged!==false)
1226
+		if ($this->hasHOFChanged !== false)
1227 1227
 			$this->doHOFSave($this->hasHOFChanged);
1228
-		if(!empty(self::$hasHOFVisChanged)) {
1229
-			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]).')');
1228
+		if (!empty(self::$hasHOFVisChanged)) {
1229
+			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 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');
1233
+					$this->db->query('UPDATE hof_visibility SET visibility = ' . $this->db->escapeString(self::$HOFVis[$hofType]) . ' WHERE type = ' . $this->db->escapeString($hofType) . ' LIMIT 1');
1234 1234
 				unset(self::$hasHOFVisChanged[$hofType]);
1235 1235
 			}
1236 1236
 		}
1237 1237
 	}
1238
-	protected function doHOFSave(array &$hasChangedList,array $typeList = array()) {
1239
-		foreach($hasChangedList as $type => &$hofChanged) {
1238
+	protected function doHOFSave(array &$hasChangedList, array $typeList = array()) {
1239
+		foreach ($hasChangedList as $type => &$hofChanged) {
1240 1240
 			$tempTypeList = $typeList;
1241 1241
 			$tempTypeList[] = $type;
1242
-			if(is_array($hofChanged)) {
1243
-				$this->doHOFSave($hofChanged,$tempTypeList);
1242
+			if (is_array($hofChanged)) {
1243
+				$this->doHOFSave($hofChanged, $tempTypeList);
1244 1244
 			}
1245 1245
 			else {
1246 1246
 				$amount = $this->getHOF($tempTypeList);
1247
-				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) . ')');
1247
+				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 1250
 				}
1251
-				else if($hofChanged==self::HOF_CHANGED) {
1251
+				else if ($hofChanged == self::HOF_CHANGED) {
1252 1252
 	//				if($amount > 0)
1253 1253
 						$this->db->query('UPDATE player_hof
1254 1254
 							SET amount=' . $this->db->escapeNumber($amount) . '
1255
-							WHERE ' . $this->SQL . ' AND type = ' . $this->db->escapeArray($tempTypeList,false,true,':',false).' LIMIT 1');
1255
+							WHERE ' . $this->SQL . ' AND type = ' . $this->db->escapeArray($tempTypeList, false, true, ':', false) . ' LIMIT 1');
1256 1256
 	//				else
1257 1257
 	//					$this->db->query('DELETE FROM player_hof WHERE account_id=' . $this->getAccountID() . ' AND game_id = ' . $this->getGameID() . ' AND type = ' . $this->db->escapeArray($tempTypeList,false,true,':',false) . ' LIMIT 1');
1258 1258
 	//				}
@@ -1263,18 +1263,18 @@  discard block
 block discarded – undo
1263 1263
 	}
1264 1264
 
1265 1265
 	protected function getHOFData() {
1266
-		if(!isset($this->HOF)) {
1266
+		if (!isset($this->HOF)) {
1267 1267
 			//Get Player HOF
1268 1268
 			$this->db->query('SELECT type,amount FROM player_hof WHERE ' . $this->SQL);
1269 1269
 			$this->HOF = array();
1270
-			while($this->db->nextRecord()) {
1271
-				$hof =& $this->HOF;
1272
-				$typeList = explode(':',$this->db->getField('type'));
1273
-				foreach($typeList as $type) {
1274
-					if(!isset($hof[$type])) {
1270
+			while ($this->db->nextRecord()) {
1271
+				$hof = & $this->HOF;
1272
+				$typeList = explode(':', $this->db->getField('type'));
1273
+				foreach ($typeList as $type) {
1274
+					if (!isset($hof[$type])) {
1275 1275
 						$hof[$type] = array();
1276 1276
 					}
1277
-					$hof =& $hof[$type];
1277
+					$hof = & $hof[$type];
1278 1278
 				}
1279 1279
 				$hof = $this->db->getField('amount');
1280 1280
 			}
@@ -1283,22 +1283,22 @@  discard block
 block discarded – undo
1283 1283
 	}
1284 1284
 
1285 1285
 	public static function getHOFVis() {
1286
-		if(!isset(self::$HOFVis)) {
1286
+		if (!isset(self::$HOFVis)) {
1287 1287
 			//Get Player HOF Vis
1288 1288
 			$db = new SmrMySqlDatabase();
1289 1289
 			$db->query('SELECT type,visibility FROM hof_visibility');
1290 1290
 			self::$HOFVis = array();
1291
-			while($db->nextRecord()) {
1291
+			while ($db->nextRecord()) {
1292 1292
 				self::$HOFVis[$db->getField('type')] = $db->getField('visibility');
1293 1293
 			}
1294 1294
 		}
1295 1295
 	}
1296 1296
 
1297 1297
 	protected function getBountiesData() {
1298
-		if(!isset($this->bounties)) {
1298
+		if (!isset($this->bounties)) {
1299 1299
 			$this->bounties = array();
1300 1300
 			$this->db->query('SELECT * FROM bounty WHERE ' . $this->SQL);
1301
-			while($this->db->nextRecord()) {
1301
+			while ($this->db->nextRecord()) {
1302 1302
 				$this->bounties[$this->db->getField('bounty_id')] = array(
1303 1303
 							'Amount' => $this->db->getInt('amount'),
1304 1304
 							'SmrCredits' => $this->db->getInt('smr_credits'),
@@ -1339,15 +1339,15 @@  discard block
 block discarded – undo
1339 1339
 	}
1340 1340
 
1341 1341
 	public function isOnCouncil() {
1342
-		return Council::isOnCouncil($this->getGameID(),$this->getRaceID(),$this->getAccountID());
1342
+		return Council::isOnCouncil($this->getGameID(), $this->getRaceID(), $this->getAccountID());
1343 1343
 	}
1344 1344
 
1345 1345
 	public function setNewbieWarning($bool) {
1346
-		if($this->newbieWarning==$bool) {
1346
+		if ($this->newbieWarning == $bool) {
1347 1347
 			return;
1348 1348
 		}
1349
-		$this->newbieWarning=$bool;
1350
-		$this->hasChanged=true;
1349
+		$this->newbieWarning = $bool;
1350
+		$this->hasChanged = true;
1351 1351
 	}
1352 1352
 
1353 1353
 	public function getNewbieWarning() {
@@ -1355,12 +1355,12 @@  discard block
 block discarded – undo
1355 1355
 	}
1356 1356
 
1357 1357
 	public function getTickers() {
1358
-		if(!isset($this->tickers)) {
1358
+		if (!isset($this->tickers)) {
1359 1359
 			$this->tickers = array();
1360 1360
 			//get ticker info
1361
-			$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'),
1361
+			$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'),
1364 1364
 																				'Time' => $this->db->getInt('time'),
1365 1365
 																				'Expires' => $this->db->getInt('expires'),
1366 1366
 																				'Recent' => $this->db->getField('recent'));
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 
1375 1375
 	public function getTicker($tickerType) {
1376 1376
 		$tickers = $this->getTickers();
1377
-		if(isset($tickers[$tickerType]))
1377
+		if (isset($tickers[$tickerType]))
1378 1378
 			return $tickers[$tickerType];
1379 1379
 		return false;
1380 1380
 	}
@@ -1385,8 +1385,8 @@  discard block
 block discarded – undo
1385 1385
 
1386 1386
 	public function getTurnsLevel() {
1387 1387
 		if (!$this->hasTurns()) return 'NONE';
1388
-		if ($this->getTurns() <= 25 ) return 'LOW';
1389
-		if ($this->getTurns() <= 75 ) return 'MEDIUM';
1388
+		if ($this->getTurns() <= 25) return 'LOW';
1389
+		if ($this->getTurns() <= 75) return 'MEDIUM';
1390 1390
 		return 'HIGH';
1391 1391
 	}
1392 1392
 
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
 	 * Returns the CSS class color to use when displaying the player's turns
1395 1395
 	 */
1396 1396
 	public function getTurnsColor() {
1397
-		switch($this->getTurnsLevel()) {
1397
+		switch ($this->getTurnsLevel()) {
1398 1398
 			case 'NONE':
1399 1399
 			case 'LOW':
1400 1400
 				return 'red';
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 		$this->save();
1412 1412
 	}
1413 1413
 
1414
-	protected static function doMessageSending($senderID,$receiverID, $gameID, $messageTypeID, $message, $expires, $senderDelete = false, $unread = true) {
1414
+	protected static function doMessageSending($senderID, $receiverID, $gameID, $messageTypeID, $message, $expires, $senderDelete = false, $unread = true) {
1415 1415
 		$message = trim($message);
1416 1416
 		$db = new SmrMySqlDatabase();
1417 1417
 		// send him the message
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 			$db->escapeBoolean($senderDelete) . ')'
1429 1429
 		);
1430 1430
 
1431
-		if($unread === true) {
1431
+		if ($unread === true) {
1432 1432
 			// give him the message icon
1433 1433
 			$db->query('REPLACE INTO player_has_unread_messages (game_id, account_id, message_type_id) VALUES
1434 1434
 						(' . $db->escapeNumber($gameID) . ', ' . $db->escapeNumber($receiverID) . ', ' . $db->escapeNumber($messageTypeID) . ')');
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
 		switch ($messageTypeID) {
1438 1438
 			case MSG_PLAYER:
1439 1439
 				$receiverAccount = SmrAccount::getAccount($receiverID);
1440
-				if($receiverAccount->isValidated() && $receiverAccount->isReceivingMessageNotifications($messageTypeID) && !$receiverAccount->isLoggedIn()) {
1440
+				if ($receiverAccount->isValidated() && $receiverAccount->isReceivingMessageNotifications($messageTypeID) && !$receiverAccount->isLoggedIn()) {
1441 1441
 					require_once(get_file_loc('message.functions.inc'));
1442 1442
 					$sender = getMessagePlayer($senderID, $gameID, $messageTypeID);
1443 1443
 					if ($sender instanceof SmrPlayer) {
@@ -1446,12 +1446,12 @@  discard block
 block discarded – undo
1446 1446
 					$mail = setupMailer();
1447 1447
 					$mail->Subject = 'Message Notification';
1448 1448
 					$mail->setFrom('[email protected]', 'SMR Notifications');
1449
-					$bbifiedMessage = 'From: ' . $sender . ' Date: ' . date($receiverAccount->getShortDateFormat().' '.$receiverAccount->getShortTimeFormat(),TIME) . "<br/>\r\n<br/>\r\n" . bbifyMessage($message,true);
1449
+					$bbifiedMessage = 'From: ' . $sender . ' Date: ' . date($receiverAccount->getShortDateFormat() . ' ' . $receiverAccount->getShortTimeFormat(), TIME) . "<br/>\r\n<br/>\r\n" . bbifyMessage($message, true);
1450 1450
 					$mail->msgHTML($bbifiedMessage);
1451 1451
 					$mail->AltBody = strip_tags($bbifiedMessage);
1452 1452
 					$mail->addAddress($receiverAccount->getEmail(), $receiverAccount->getHofName());
1453 1453
 					$mail->send();
1454
-					$receiverAccount->decreaseMessageNotifications($messageTypeID,1);
1454
+					$receiverAccount->decreaseMessageNotifications($messageTypeID, 1);
1455 1455
 				}
1456 1456
 			break;
1457 1457
 		}
@@ -1463,11 +1463,11 @@  discard block
 block discarded – undo
1463 1463
 	}
1464 1464
 
1465 1465
 	public function sendGlobalMessage($message, $canBeIgnored = true) {
1466
-		if($canBeIgnored) {
1467
-			if($this->getAccount()->isMailBanned())
1466
+		if ($canBeIgnored) {
1467
+			if ($this->getAccount()->isMailBanned())
1468 1468
 				create_error('You are currently banned from sending messages');
1469 1469
 		}
1470
-		$this->sendMessageToBox(BOX_GLOBALS,$message);
1470
+		$this->sendMessageToBox(BOX_GLOBALS, $message);
1471 1471
 
1472 1472
 		// send to all online player
1473 1473
 		$db = new SmrMySqlDatabase();
@@ -1487,12 +1487,12 @@  discard block
 block discarded – undo
1487 1487
 
1488 1488
 	public function sendMessage($receiverID, $messageTypeID, $message, $canBeIgnored = true, $unread = true, $expires = false, $senderDelete = false) {
1489 1489
 		//get expire time
1490
-		if($canBeIgnored) {
1491
-			if($this->getAccount()->isMailBanned())
1490
+		if ($canBeIgnored) {
1491
+			if ($this->getAccount()->isMailBanned())
1492 1492
 				create_error('You are currently banned from sending messages');
1493 1493
 			// Don't send messages to players ignoring us
1494 1494
 			$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())
1495
+			if ($this->db->nextRecord())
1496 1496
 				return;
1497 1497
 		}
1498 1498
 
@@ -1537,10 +1537,10 @@  discard block
 block discarded – undo
1537 1537
 		}
1538 1538
 
1539 1539
 		// send him the message
1540
-		self::doMessageSending($this->getAccountID(),$receiverID, $this->getGameID(), $messageTypeID, $message, $expires, $senderDelete, $unread);
1540
+		self::doMessageSending($this->getAccountID(), $receiverID, $this->getGameID(), $messageTypeID, $message, $expires, $senderDelete, $unread);
1541 1541
 	}
1542 1542
 
1543
-	public function sendMessageFromOpAnnounce($receiverID, $message, $expires=false) {
1543
+	public function sendMessageFromOpAnnounce($receiverID, $message, $expires = false) {
1544 1544
 		// get expire time if not set
1545 1545
 		if ($expires === false) {
1546 1546
 			$expires = TIME + 86400 * 14;
@@ -1557,14 +1557,14 @@  discard block
 block discarded – undo
1557 1557
 		//get expire time
1558 1558
 		$expires = TIME + 86400 * 31;
1559 1559
 		// send him the message
1560
-		self::doMessageSending(ACCOUNT_ID_PLANET,$receiverID, $gameID, MSG_PLANET, $message, $expires);
1560
+		self::doMessageSending(ACCOUNT_ID_PLANET, $receiverID, $gameID, MSG_PLANET, $message, $expires);
1561 1561
 	}
1562 1562
 
1563 1563
 	public static function sendMessageFromPort($gameID, $receiverID, $message) {
1564 1564
 		//get expire time
1565 1565
 		$expires = TIME + 86400 * 31;
1566 1566
 		// send him the message
1567
-		self::doMessageSending(ACCOUNT_ID_PORT,$receiverID, $gameID, MSG_PLAYER, $message, $expires);
1567
+		self::doMessageSending(ACCOUNT_ID_PORT, $receiverID, $gameID, MSG_PLAYER, $message, $expires);
1568 1568
 	}
1569 1569
 
1570 1570
 	public static function sendMessageFromFedClerk($gameID, $receiverID, $message) {
@@ -1574,15 +1574,15 @@  discard block
 block discarded – undo
1574 1574
 
1575 1575
 	public static function sendMessageFromAdmin($gameID, $receiverID, $message, $expires = false) {
1576 1576
 		//get expire time
1577
-		if($expires===false)
1577
+		if ($expires === false)
1578 1578
 			$expires = TIME + 86400 * 365;
1579 1579
 		// send him the message
1580
-		self::doMessageSending(ACCOUNT_ID_ADMIN,$receiverID, $gameID, MSG_ADMIN, $message, $expires);
1580
+		self::doMessageSending(ACCOUNT_ID_ADMIN, $receiverID, $gameID, MSG_ADMIN, $message, $expires);
1581 1581
 	}
1582 1582
 
1583 1583
 	public static function sendMessageFromAllianceAmbassador($gameID, $receiverID, $message, $expires = false) {
1584 1584
 		//get expire time
1585
-		if($expires===false)
1585
+		if ($expires === false)
1586 1586
 			$expires = TIME + 86400 * 31;
1587 1587
 		// send him the message
1588 1588
 		self::doMessageSending(ACCOUNT_ID_ALLIANCE_AMBASSADOR, $receiverID, $gameID, MSG_ALLIANCE, $message, $expires);
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
 
1591 1591
 	public static function sendMessageFromCasino($gameID, $receiverID, $message, $expires = false) {
1592 1592
 		//get expire time
1593
-		if($expires===false)
1593
+		if ($expires === false)
1594 1594
 			$expires = TIME + 86400 * 7;
1595 1595
 		// send him the message
1596 1596
 		self::doMessageSending(ACCOUNT_ID_CASINO, $receiverID, $gameID, MSG_CASINO, $message, $expires);
@@ -1598,19 +1598,19 @@  discard block
 block discarded – undo
1598 1598
 
1599 1599
 	public static function sendMessageFromRace($raceID, $gameID, $receiverID, $message, $expires = false) {
1600 1600
 		//get expire time
1601
-		if($expires===false)
1601
+		if ($expires === false)
1602 1602
 			$expires = TIME + 86400 * 5;
1603 1603
 		// send him the message
1604
-		self::doMessageSending(ACCOUNT_ID_GROUP_RACES+$raceID,$receiverID, $gameID, MSG_POLITICAL, $message, $expires);
1604
+		self::doMessageSending(ACCOUNT_ID_GROUP_RACES + $raceID, $receiverID, $gameID, MSG_POLITICAL, $message, $expires);
1605 1605
 	}
1606 1606
 
1607 1607
 	public function setMessagesRead($messageTypeID) {
1608 1608
 		$this->db->query('DELETE FROM player_has_unread_messages
1609
-							WHERE '.$this->SQL.' AND message_type_id = ' . $this->db->escapeNumber($messageTypeID));
1609
+							WHERE '.$this->SQL . ' AND message_type_id = ' . $this->db->escapeNumber($messageTypeID));
1610 1610
 	}
1611 1611
 
1612 1612
 	public function getPlottedCourse() {
1613
-		if(!isset($this->plottedCourse)) {
1613
+		if (!isset($this->plottedCourse)) {
1614 1614
 			// check if we have a course plotted
1615 1615
 			$this->db->query('SELECT course FROM player_plotted_course WHERE ' . $this->SQL . ' LIMIT 1');
1616 1616
 
@@ -1642,23 +1642,23 @@  discard block
 block discarded – undo
1642 1642
 	public function setPlottedCourse(Distance $plottedCourse) {
1643 1643
 		$hadPlottedCourse = $this->hasPlottedCourse();
1644 1644
 		$this->plottedCourse = $plottedCourse;
1645
-		if ($this->plottedCourse->getTotalSectors()>0)
1645
+		if ($this->plottedCourse->getTotalSectors() > 0)
1646 1646
 			$this->db->query('REPLACE INTO player_plotted_course
1647 1647
 				(account_id, game_id, course)
1648 1648
 				VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeBinary(serialize($this->plottedCourse)) . ')');
1649
-		else if($hadPlottedCourse) {
1649
+		else if ($hadPlottedCourse) {
1650 1650
 			$this->deletePlottedCourse();
1651 1651
 		}
1652 1652
 	}
1653 1653
 
1654 1654
 	public function hasPlottedCourse() {
1655
-		return $this->getPlottedCourse()!==false;
1655
+		return $this->getPlottedCourse() !== false;
1656 1656
 	}
1657 1657
 
1658 1658
 	public function isPartOfCourse($sectorOrSectorID) {
1659
-		if(!$this->hasPlottedCourse())
1659
+		if (!$this->hasPlottedCourse())
1660 1660
 			return false;
1661
-		if($sectorOrSectorID instanceof SmrSector )
1661
+		if ($sectorOrSectorID instanceof SmrSector)
1662 1662
 			$sectorID = $sectorOrSectorID->getSectorID();
1663 1663
 		else
1664 1664
 			$sectorID = $sectorOrSectorID;
@@ -1667,14 +1667,14 @@  discard block
 block discarded – undo
1667 1667
 
1668 1668
 	public function deletePlottedCourse() {
1669 1669
 		$this->plottedCourse = false;
1670
-		$this->db->query('DELETE FROM player_plotted_course WHERE '.$this->SQL.' LIMIT 1');
1670
+		$this->db->query('DELETE FROM player_plotted_course WHERE ' . $this->SQL . ' LIMIT 1');
1671 1671
 	}
1672 1672
 
1673 1673
 	// Computes the turn cost and max misjump between current and target sector
1674 1674
 	public function getJumpInfo(SmrSector $targetSector) {
1675 1675
 		$path = Plotter::findDistanceToX($targetSector, $this->getSector(), true);
1676
-		if ($path===false) {
1677
-			create_error('Unable to plot from '.$this->getSectorID().' to '.$targetSector->getSectorID().'.');
1676
+		if ($path === false) {
1677
+			create_error('Unable to plot from ' . $this->getSectorID() . ' to ' . $targetSector->getSectorID() . '.');
1678 1678
 		}
1679 1679
 		$distance = $path->getRelativeDistance();
1680 1680
 
@@ -1688,10 +1688,10 @@  discard block
 block discarded – undo
1688 1688
 	}
1689 1689
 
1690 1690
 	public function &getStoredDestinations() {
1691
-		if(!isset($this->storedDestinations)) {
1691
+		if (!isset($this->storedDestinations)) {
1692 1692
 			$storedDestinations = array();
1693 1693
 			$this->db->query('SELECT * FROM player_stored_sector WHERE ' . $this->SQL);
1694
-			while($this->db->nextRecord()) {
1694
+			while ($this->db->nextRecord()) {
1695 1695
 				$storedDestinations[] = array(
1696 1696
 					'Label' => $this->db->getField('label'),
1697 1697
 					'SectorID' => $this->db->getInt('sector_id'),
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 					'OffsetLeft' => $this->db->getInt('offset_left')
1700 1700
 				);
1701 1701
 			}
1702
-			$this->storedDestinations =& $storedDestinations;
1702
+			$this->storedDestinations = & $storedDestinations;
1703 1703
 		}
1704 1704
 		return $this->storedDestinations;
1705 1705
 	}
@@ -1707,19 +1707,19 @@  discard block
 block discarded – undo
1707 1707
 
1708 1708
 	function moveDestinationButton($sectorID, $offsetTop, $offsetLeft) {
1709 1709
 
1710
-		if( !is_numeric($offsetLeft) || !is_numeric($offsetTop)) {
1710
+		if (!is_numeric($offsetLeft) || !is_numeric($offsetTop)) {
1711 1711
 			create_error('The position of the saved sector must be numeric!.');
1712 1712
 		}
1713 1713
 		$offsetTop = round($offsetTop);
1714 1714
 		$offsetLeft = round($offsetLeft);
1715 1715
 
1716
-		if($offsetLeft < 0 || $offsetLeft > 500 || $offsetTop < 0 || $offsetTop > 300) {
1716
+		if ($offsetLeft < 0 || $offsetLeft > 500 || $offsetTop < 0 || $offsetTop > 300) {
1717 1717
 			create_error('The saved sector must be in the box!');
1718 1718
 		}
1719 1719
 
1720
-		$storedDestinations =& $this->getStoredDestinations();
1721
-		foreach($storedDestinations as &$sd) {
1722
-			if($sd['SectorID'] == $sectorID) {
1720
+		$storedDestinations = & $this->getStoredDestinations();
1721
+		foreach ($storedDestinations as &$sd) {
1722
+			if ($sd['SectorID'] == $sectorID) {
1723 1723
 				$sd['OffsetTop'] = $offsetTop;
1724 1724
 				$sd['OffsetLeft'] = $offsetLeft;
1725 1725
 				$this->db->query('
@@ -1741,8 +1741,8 @@  discard block
 block discarded – undo
1741 1741
 		}
1742 1742
 
1743 1743
 		// sector already stored ?
1744
-		foreach($this->getStoredDestinations() as $sd) {
1745
-			if($sd['SectorID'] == $sectorID) {
1744
+		foreach ($this->getStoredDestinations() as $sd) {
1745
+			if ($sd['SectorID'] == $sectorID) {
1746 1746
 				create_error('Sector already stored!');
1747 1747
 			}
1748 1748
 		}
@@ -1765,8 +1765,8 @@  discard block
 block discarded – undo
1765 1765
 			create_error('You want to remove a non-existent sector?');
1766 1766
 		}
1767 1767
 
1768
-		foreach($this->getStoredDestinations() as $key => $sd) {
1769
-			if($sd['SectorID'] == $sectorID) {
1768
+		foreach ($this->getStoredDestinations() as $key => $sd) {
1769
+			if ($sd['SectorID'] == $sectorID) {
1770 1770
 				$this->db->query('
1771 1771
 					DELETE FROM player_stored_sector
1772 1772
 					WHERE ' . $this->SQL . '
@@ -1795,9 +1795,9 @@  discard block
 block discarded – undo
1795 1795
 		$this->db->query('SELECT count(*) FROM player
1796 1796
 			WHERE game_id = ' . $this->db->escapeNumber($this->getGameID()) . '
1797 1797
 			AND (
1798
-				'.$dbField.' > '.$this->db->escapeNumber($playerAmount).'
1798
+				'.$dbField . ' > ' . $this->db->escapeNumber($playerAmount) . '
1799 1799
 				OR (
1800
-					'.$dbField.' = '.$this->db->escapeNumber($playerAmount).'
1800
+					'.$dbField . ' = ' . $this->db->escapeNumber($playerAmount) . '
1801 1801
 					AND player_name <= ' . $this->db->escapeString($this->getPlayerName()) . '
1802 1802
 				)
1803 1803
 			)');
Please login to merge, or discard this patch.
lib/Default/DummyShip.class.inc 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 		$this->cargo_left = $this->getCargoHolds();
18 18
 	}
19 19
 	protected function doFullUNO() {
20
-		foreach($this->getMaxHardware() as $hardwareTypeID => $max) {
20
+		foreach ($this->getMaxHardware() as $hardwareTypeID => $max) {
21 21
 			$this->hardware[$hardwareTypeID] = $max;
22 22
 			$this->oldHardware[$hardwareTypeID] = $max;
23 23
 		}
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	}
48 48
 	
49 49
 	public function getIllusionShip() {
50
-		if(!isset($this->illusionShip)) {
51
-			$this->illusionShip=false;
50
+		if (!isset($this->illusionShip)) {
51
+			$this->illusionShip = false;
52 52
 		}
53 53
 		return $this->illusionShip;
54 54
 	}
@@ -58,20 +58,20 @@  discard block
 block discarded – undo
58 58
 		$db = new SmrMySqlDatabase();
59 59
 		$db->query('REPLACE INTO cached_dummys ' .
60 60
 					'(type, id, info) ' .
61
-					'VALUES (\'DummyShip\', '.$db->escapeString($this->getPlayer()->getPlayerName()).', '.$db->escapeString($cache).')');
61
+					'VALUES (\'DummyShip\', ' . $db->escapeString($this->getPlayer()->getPlayerName()) . ', ' . $db->escapeString($cache) . ')');
62 62
 		unserialize($cache);
63 63
 	}
64 64
 	
65 65
 	public static function &getCachedDummyShip(AbstractSmrPlayer $player) {
66
-		if(!isset(self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()])) {
66
+		if (!isset(self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()])) {
67 67
 			$db = new SmrMySqlDatabase();
68 68
 			$db->query('SELECT info FROM cached_dummys
69 69
 						WHERE type = \'DummyShip\'
70 70
 						AND id = ' . $db->escapeString($player->getPlayerName()) . ' LIMIT 1');
71
-			if($db->nextRecord()) {
71
+			if ($db->nextRecord()) {
72 72
 				$return = unserialize($db->getField('info'));
73 73
 				$return->regenerate($player);
74
-				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] =& $return;
74
+				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = & $return;
75 75
 			}
76 76
 			else {
77 77
 				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = new DummyShip($player);
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		$db->query('SELECT id FROM cached_dummys
86 86
 					WHERE type = \'DummyShip\'');
87 87
 		$dummyNames = array();
88
-		while($db->nextRecord()) {
88
+		while ($db->nextRecord()) {
89 89
 			$dummyNames[] = $db->getField('id');
90 90
 		}
91 91
 		return $dummyNames;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	
95 95
 	
96 96
 	public function __sleep() {
97
-		return array('gameID','weapons');
97
+		return array('gameID', 'weapons');
98 98
 	}
99 99
 	
100 100
 	public function __wakeup() {
Please login to merge, or discard this patch.
lib/Default/AbstractSmrShip.class.inc 1 patch
Spacing   +241 added lines, -241 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
 	protected $hasChangedCargo = false;
24 24
 	protected $hasChangedHardware = array();
25 25
 
26
-	public static function &getBaseShip($gameTypeID,$shipTypeID,$forceUpdate = false) {
27
-		if($forceUpdate || !isset(self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID])) {
26
+	public static function &getBaseShip($gameTypeID, $shipTypeID, $forceUpdate = false) {
27
+		if ($forceUpdate || !isset(self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID])) {
28 28
 			// determine ship
29 29
 			$db = new SmrMySqlDatabase();
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())
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 32
 				self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = self::buildBaseShip($db);
33 33
 			else
34 34
 				self::$CACHE_BASE_SHIPS[$gameTypeID][$shipTypeID] = false;
@@ -40,40 +40,40 @@  discard block
 block discarded – undo
40 40
 		$ship = array();
41 41
 		$ship['Type']				= 'Ship';
42 42
 		$ship['Name']				= $db->getField('ship_name');
43
-		$ship['ShipTypeID']			= $db->getField('ship_type_id');
44
-		$ship['RaceID']				= $db->getField('race_id');
45
-		$ship['Hardpoint']			= $db->getField('hardpoint');
43
+		$ship['ShipTypeID'] = $db->getField('ship_type_id');
44
+		$ship['RaceID'] = $db->getField('race_id');
45
+		$ship['Hardpoint'] = $db->getField('hardpoint');
46 46
 		$ship['Speed']				= $db->getField('speed');
47
-		$ship['Cost']				= $db->getField('cost');
48
-		$ship['AlignRestriction']	= $db->getField('buyer_restriction');
47
+		$ship['Cost'] = $db->getField('cost');
48
+		$ship['AlignRestriction'] = $db->getField('buyer_restriction');
49 49
 		$ship['Level']				= $db->getField('lvl_needed');
50 50
 
51 51
 		$maxPower = 0;
52
-		switch($ship['Hardpoint']) {
52
+		switch ($ship['Hardpoint']) {
53 53
 			default:
54
-				$maxPower+=1*$ship['Hardpoint']-10;
54
+				$maxPower += 1 * $ship['Hardpoint'] - 10;
55 55
 			case 10:
56
-				$maxPower+=2;
56
+				$maxPower += 2;
57 57
 			case 9:
58
-				$maxPower+=2;
58
+				$maxPower += 2;
59 59
 			case 8:
60
-				$maxPower+=2;
60
+				$maxPower += 2;
61 61
 			case 7:
62
-				$maxPower+=2;
62
+				$maxPower += 2;
63 63
 			case 6:
64
-				$maxPower+=3;
64
+				$maxPower += 3;
65 65
 			case 5:
66
-				$maxPower+=3;
66
+				$maxPower += 3;
67 67
 			case 4:
68
-				$maxPower+=3;
68
+				$maxPower += 3;
69 69
 			case 3:
70
-				$maxPower+=4;
70
+				$maxPower += 4;
71 71
 			case 2:
72
-				$maxPower+=4;
72
+				$maxPower += 4;
73 73
 			case 1:
74
-				$maxPower+=5;
74
+				$maxPower += 5;
75 75
 			case 0:
76
-				$maxPower+=0;
76
+				$maxPower += 0;
77 77
 		}
78 78
 		$ship['MaxPower'] = $maxPower;
79 79
 
@@ -81,38 +81,38 @@  discard block
 block discarded – undo
81 81
 		// get supported hardware from db
82 82
 		$db2 = new SmrMySqlDatabase();
83 83
 		$db2->query('SELECT hardware_type_id, max_amount FROM ship_type_support_hardware ' .
84
-			'WHERE ship_type_id = '.$db2->escapeNumber($ship['ShipTypeID']).' ORDER BY hardware_type_id');
84
+			'WHERE ship_type_id = ' . $db2->escapeNumber($ship['ShipTypeID']) . ' ORDER BY hardware_type_id');
85 85
 
86 86
 		while ($db2->nextRecord()) {
87 87
 			// adding hardware to array
88 88
 			$ship['MaxHardware'][$db2->getField('hardware_type_id')] = $db2->getField('max_amount');
89 89
 		}
90 90
 
91
-		$ship['BaseMR'] = 	round(
91
+		$ship['BaseMR'] = round(
92 92
 								700 -
93 93
 								(
94 94
 									(
95 95
 										$ship['MaxHardware'][HARDWARE_SHIELDS]
96 96
 										+$ship['MaxHardware'][HARDWARE_ARMOUR]
97
-										+$ship['MaxHardware'][HARDWARE_COMBAT]*3
98
-									)/25
97
+										+$ship['MaxHardware'][HARDWARE_COMBAT] * 3
98
+									) / 25
99 99
 									+(
100
-										$ship['MaxHardware'][HARDWARE_CARGO]/100
101
-										-$ship['Speed']*5
102
-										+$ship['Hardpoint']*5
103
-										+$ship['MaxHardware'][HARDWARE_COMBAT]/5
100
+										$ship['MaxHardware'][HARDWARE_CARGO] / 100
101
+										-$ship['Speed'] * 5
102
+										+$ship['Hardpoint'] * 5
103
+										+$ship['MaxHardware'][HARDWARE_COMBAT] / 5
104 104
 									)
105 105
 								)
106 106
 							);
107 107
 		return $ship;
108 108
 	}
109 109
 
110
-	public static function &getAllBaseShips($gameTypeID,$forceUpdate = false) {
110
+	public static function &getAllBaseShips($gameTypeID, $forceUpdate = false) {
111 111
 		// determine ship
112 112
 		$db = new SmrMySqlDatabase();
113 113
 		$db->query('SELECT * FROM ship_type ORDER BY ship_type_id ASC'); //TODO add game type id
114
-		while($db->nextRecord()) {
115
-			if(!isset(self::$CACHE_BASE_SHIPS[$gameTypeID][$db->getInt('ship_type_id')])) {
114
+		while ($db->nextRecord()) {
115
+			if (!isset(self::$CACHE_BASE_SHIPS[$gameTypeID][$db->getInt('ship_type_id')])) {
116 116
 				self::$CACHE_BASE_SHIPS[$gameTypeID][$db->getInt('ship_type_id')] = self::buildBaseShip($db);
117 117
 			}
118 118
 		}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	}
127 127
 
128 128
 	protected function regenerateBaseShip() {
129
-		$this->baseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->gameID),$this->player->getShipTypeID());
129
+		$this->baseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->gameID), $this->player->getShipTypeID());
130 130
 		$this->checkForExcess();
131 131
 	}
132 132
 
@@ -144,42 +144,42 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 
146 146
 	public function checkForExcessCargo() {
147
-		if($this->hasCargo()) {
148
-			while(($total=array_sum($goods=$this->getCargo())) > $this->getCargoHolds()) {
147
+		if ($this->hasCargo()) {
148
+			while (($total = array_sum($goods = $this->getCargo())) > $this->getCargoHolds()) {
149 149
 				do {
150
-					list($goodID,$amount)=each($goods);
151
-				} while($amount==0);
152
-				if($amount > $total-$this->getCargoHolds())
153
-					$amount = $total-$this->getCargoHolds();
154
-				$this->decreaseCargo($goodID,$amount);
150
+					list($goodID, $amount) = each($goods);
151
+				} while ($amount == 0);
152
+				if ($amount > $total - $this->getCargoHolds())
153
+					$amount = $total - $this->getCargoHolds();
154
+				$this->decreaseCargo($goodID, $amount);
155 155
 			}
156 156
 		}
157 157
 	}
158 158
 
159 159
 	public function checkForExcessHardware() {
160 160
 		//check hardware to see if anything needs to be removed
161
-		if(is_array($hardware = $this->getHardware()))
161
+		if (is_array($hardware = $this->getHardware()))
162 162
 			foreach ($hardware as $hardwareTypeID => $amount) {
163
-				if ($amount > ($max=$this->getMaxHardware($hardwareTypeID))) {
164
-					$this->setHardware($hardwareTypeID,$max,true);
163
+				if ($amount > ($max = $this->getMaxHardware($hardwareTypeID))) {
164
+					$this->setHardware($hardwareTypeID, $max, true);
165 165
 				}
166 166
 			}
167 167
 	}
168 168
 
169 169
 	public function getPowerUsed() {
170 170
 		$power = 0;
171
-		if($this->getNumWeapons()>0)
171
+		if ($this->getNumWeapons() > 0)
172 172
 			foreach ($this->weapons as $weapon)
173 173
 				$power += $weapon->getPowerLevel();
174 174
 		return $power;
175 175
 	}
176 176
 
177 177
 	public function getRemainingPower() {
178
-		return $this->getMaxPower()-$this->getPowerUsed();
178
+		return $this->getMaxPower() - $this->getPowerUsed();
179 179
 	}
180 180
 
181 181
 	public function hasRemainingPower() {
182
-		return $this->getRemainingPower()>0;
182
+		return $this->getRemainingPower() > 0;
183 183
 	}
184 184
 
185 185
 	public function getMaxPower() {
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 	}
192 192
 
193 193
 	public function getDisplayAttackRating(AbstractSmrPlayer $player) {
194
-		if($this->hasActiveIllusion())
194
+		if ($this->hasActiveIllusion())
195 195
 			return $this->getIllusionAttack();
196 196
 		else
197 197
 			return $this->getAttackRating();
198 198
 	}
199 199
 
200 200
 	public function getDisplayDefenseRating() {
201
-		if($this->hasActiveIllusion())
201
+		if ($this->hasActiveIllusion())
202 202
 			return $this->getIllusionDefense();
203 203
 		else
204 204
 			return $this->getDefenseRating();
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 
231 231
 
232 232
 	public function &addWeapon($weaponTypeID) {
233
-		if($this->hasOpenWeaponSlots() && $this->hasRemainingPower()) {
233
+		if ($this->hasOpenWeaponSlots() && $this->hasRemainingPower()) {
234 234
 			$weapon = SmrWeapon::getWeapon($weaponTypeID);
235
-			if($this->getRemainingPower()>=$weapon->getPowerLevel()) {
235
+			if ($this->getRemainingPower() >= $weapon->getPowerLevel()) {
236 236
 				$this->weapons[count($this->weapons)] = $weapon;
237 237
 				$this->hasChangedWeapons = true;
238 238
 				return $weapon;
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 
245 245
 	public function moveWeaponUp($orderID) {
246 246
 		$replacement = $orderID - 1;
247
-		if($replacement < 0) {
247
+		if ($replacement < 0) {
248 248
 			// Shift everything up by one and put the selected weapon at the bottom
249
-			$temp =& $this->weapons[$orderID];
250
-			for($i=1;$i<count($this->weapons);++$i) {
251
-				$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
249
+			$temp = & $this->weapons[$orderID];
250
+			for ($i = 1; $i < count($this->weapons); ++$i) {
251
+				$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 252
 			}
253
-			$this->weapons[count($this->weapons)-1] =& $temp;
253
+			$this->weapons[count($this->weapons) - 1] = & $temp;
254 254
 		}
255 255
 		else {
256 256
 			$temp = $this->weapons[$replacement];
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 
263 263
 	public function moveWeaponDown($orderID) {
264 264
 		$replacement = $orderID + 1;
265
-		if($replacement >= count($this->weapons)) {
265
+		if ($replacement >= count($this->weapons)) {
266 266
 			// Shift everything down by one and put the selected weapon at the top
267
-			$temp =& $this->weapons[count($this->weapons)-1];
268
-			for($i=count($this->weapons)-1;$i>0;--$i) {
269
-				$this->weapons[$i] =& $this->weapons[$i-1];
267
+			$temp = & $this->weapons[count($this->weapons) - 1];
268
+			for ($i = count($this->weapons) - 1; $i > 0; --$i) {
269
+				$this->weapons[$i] = & $this->weapons[$i - 1];
270 270
 			}
271
-			$this->weapons[0] =& $temp;
271
+			$this->weapons[0] = & $temp;
272 272
 		}
273 273
 		else {
274 274
 			$temp = $this->weapons[$replacement];
@@ -279,22 +279,22 @@  discard block
 block discarded – undo
279 279
 	}
280 280
 
281 281
 	public function setWeaponLocations(array $orderArray) {
282
-		$weapons=$this->weapons;
283
-		foreach($orderArray as $newOrder => $oldOrder) {
284
-			$this->weapons[$newOrder] =& $weapons[$oldOrder];
282
+		$weapons = $this->weapons;
283
+		foreach ($orderArray as $newOrder => $oldOrder) {
284
+			$this->weapons[$newOrder] = & $weapons[$oldOrder];
285 285
 		}
286 286
 		$this->hasChangedWeapons = true;
287 287
 	}
288 288
 
289 289
 	public function removeLastWeapon() {
290
-		$this->removeWeapon($this->getNumWeapons()-1);
290
+		$this->removeWeapon($this->getNumWeapons() - 1);
291 291
 	}
292 292
 
293 293
 	public function removeWeapon($orderID) {
294 294
 		// Shift everything after the removed weapon up by one and put the selected weapon at the bottom
295
-		for($i=$orderID+1;$i<count($this->weapons);++$i) {
296
-			$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
297
-		} unset($this->weapons[count($this->weapons)-1]);
295
+		for ($i = $orderID + 1; $i < count($this->weapons); ++$i) {
296
+			$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
297
+		} unset($this->weapons[count($this->weapons) - 1]);
298 298
 		$this->hasChangedWeapons = true;
299 299
 	}
300 300
 
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
 	}
305 305
 
306 306
 	public function removeAllCargo() {
307
-		if(is_array($this->cargo)) {
308
-			foreach($this->cargo as $goodID => $amount) {
309
-				$this->setCargo($goodID,0);
307
+		if (is_array($this->cargo)) {
308
+			foreach ($this->cargo as $goodID => $amount) {
309
+				$this->setCargo($goodID, 0);
310 310
 			}
311 311
 		}
312 312
 	}
@@ -324,15 +324,15 @@  discard block
 block discarded – undo
324 324
 		$this->removeAllCargo();
325 325
 		$this->removeAllHardware();
326 326
 
327
-		if($isNewbie) {
328
-			$this->setShields(75,true);
329
-			$this->setArmour(150,true);
327
+		if ($isNewbie) {
328
+			$this->setShields(75, true);
329
+			$this->setArmour(150, true);
330 330
 			$this->setCargoHolds(40);
331 331
 			$this->setShipTypeID(SHIP_TYPE_NEWBIE_MERCHANT_VESSEL);
332 332
 		}
333 333
 		else {
334
-			$this->setShields(50,true);
335
-			$this->setArmour(50,true);
334
+			$this->setShields(50, true);
335
+			$this->setArmour(50, true);
336 336
 			$this->setCargoHolds(5);
337 337
 			$this->setShipTypeID(SHIP_TYPE_ESCAPE_POD);
338 338
 		}
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
 
351 351
 
352 352
 	public function hasActiveIllusion() {
353
-		if(!$this->hasIllusion())
353
+		if (!$this->hasIllusion())
354 354
 			return false;
355
-		return $this->getIllusionShip()!==false;
355
+		return $this->getIllusionShip() !== false;
356 356
 
357 357
 	}
358 358
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	}
445 445
 
446 446
 	public function getCostToUpgrade($upgradeShipID) {
447
-		$upgadeBaseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->getGameID()),$upgradeShipID);
447
+		$upgadeBaseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->getGameID()), $upgradeShipID);
448 448
 		return $upgadeBaseShip['Cost'] - floor($this->getCost() * SHIP_REFUND_PERCENT);
449 449
 	}
450 450
 
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
 	}
454 454
 
455 455
 	protected function getCostToUNOAgainstShip($shipID) {
456
-		$baseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->getGameID()),$shipID);
456
+		$baseShip = AbstractSmrShip::getBaseShip(Globals::getGameType($this->getGameID()), $shipID);
457 457
 		$cost = 0;
458 458
 		$hardwareTypes = array(HARDWARE_SHIELDS, HARDWARE_ARMOUR, HARDWARE_CARGO);
459
-		foreach($hardwareTypes as $hardwareTypeID) {
460
-			$cost += max(0,$baseShip['MaxHardware'][$hardwareTypeID]-$this->getHardware($hardwareTypeID))*Globals::getHardwareCost($hardwareTypeID);
459
+		foreach ($hardwareTypes as $hardwareTypeID) {
460
+			$cost += max(0, $baseShip['MaxHardware'][$hardwareTypeID] - $this->getHardware($hardwareTypeID)) * Globals::getHardwareCost($hardwareTypeID);
461 461
 		}
462 462
 		return $cost;
463 463
 	}
@@ -475,41 +475,41 @@  discard block
 block discarded – undo
475 475
 	}
476 476
 
477 477
 	public function getHardware($hardwareTypeID = false) {
478
-		if($hardwareTypeID === false)
478
+		if ($hardwareTypeID === false)
479 479
 			return $this->hardware;
480 480
 		return isset($this->hardware[$hardwareTypeID]) ? $this->hardware[$hardwareTypeID] : 0;
481 481
 	}
482 482
 
483
-	public function setHardware($hardwareTypeID,$amount) {
484
-		if($this->getHardware($hardwareTypeID) == $amount)
483
+	public function setHardware($hardwareTypeID, $amount) {
484
+		if ($this->getHardware($hardwareTypeID) == $amount)
485 485
 			return;
486 486
 		$this->hardware[$hardwareTypeID] = $amount;
487 487
 		$this->hasChangedHardware[$hardwareTypeID] = true;
488 488
 	}
489 489
 
490
-	public function increaseHardware($hardwareTypeID,$amount) {
491
-		$this->setHardware($hardwareTypeID,$this->getHardware($hardwareTypeID)+$amount);
490
+	public function increaseHardware($hardwareTypeID, $amount) {
491
+		$this->setHardware($hardwareTypeID, $this->getHardware($hardwareTypeID) + $amount);
492 492
 	}
493 493
 
494 494
 	public function getOldHardware($hardwareTypeID = false) {
495
-		if($hardwareTypeID === false)
495
+		if ($hardwareTypeID === false)
496 496
 			return $this->oldHardware;
497 497
 		return isset($this->oldHardware[$hardwareTypeID]) ? $this->oldHardware[$hardwareTypeID] : 0;
498 498
 	}
499 499
 
500
-	public function setOldHardware($hardwareTypeID,$amount) {
501
-		if($this->getOldHardware($hardwareTypeID) == $amount)
500
+	public function setOldHardware($hardwareTypeID, $amount) {
501
+		if ($this->getOldHardware($hardwareTypeID) == $amount)
502 502
 			return;
503 503
 		$this->oldHardware[$hardwareTypeID] = $amount;
504 504
 		$this->hasChangedHardware[$hardwareTypeID] = true;
505 505
 	}
506 506
 
507 507
 	public function hasMaxHardware($hardwareTypeID) {
508
-		return $this->getHardware($hardwareTypeID)==$this->getMaxHardware($hardwareTypeID);
508
+		return $this->getHardware($hardwareTypeID) == $this->getMaxHardware($hardwareTypeID);
509 509
 	}
510 510
 
511 511
 	public function getMaxHardware($hardwareTypeID = false) {
512
-		if($hardwareTypeID === false)
512
+		if ($hardwareTypeID === false)
513 513
 			return $this->baseShip['MaxHardware'];
514 514
 		return $this->baseShip['MaxHardware'][$hardwareTypeID];
515 515
 	}
@@ -518,18 +518,18 @@  discard block
 block discarded – undo
518 518
 		return $this->getHardware(HARDWARE_SHIELDS);
519 519
 	}
520 520
 
521
-	public function setShields($amount,$updateOldAmount=false) {
522
-		if($updateOldAmount && !$this->hasLostShields())
523
-			$this->setOldHardware(HARDWARE_SHIELDS,$amount);
524
-		$this->setHardware(HARDWARE_SHIELDS,$amount);
521
+	public function setShields($amount, $updateOldAmount = false) {
522
+		if ($updateOldAmount && !$this->hasLostShields())
523
+			$this->setOldHardware(HARDWARE_SHIELDS, $amount);
524
+		$this->setHardware(HARDWARE_SHIELDS, $amount);
525 525
 	}
526 526
 
527 527
 	public function decreaseShields($amount) {
528
-		$this->setShields($this->getShields()-$amount);
528
+		$this->setShields($this->getShields() - $amount);
529 529
 	}
530 530
 
531 531
 	public function increaseShields($amount) {
532
-		$this->setShields($this->getShields()+$amount);
532
+		$this->setShields($this->getShields() + $amount);
533 533
 	}
534 534
 
535 535
 	public function getOldShields() {
@@ -537,19 +537,19 @@  discard block
 block discarded – undo
537 537
 	}
538 538
 
539 539
 	public function setOldShields($amount) {
540
-		$this->setOldHardware(HARDWARE_SHIELDS,$amount);
540
+		$this->setOldHardware(HARDWARE_SHIELDS, $amount);
541 541
 	}
542 542
 
543 543
 	public function hasShields() {
544
-		return $this->getShields()>0;
544
+		return $this->getShields() > 0;
545 545
 	}
546 546
 
547 547
 	public function hasLostShields() {
548
-		return $this->getShields()<$this->getOldShields();
548
+		return $this->getShields() < $this->getOldShields();
549 549
 	}
550 550
 
551 551
 	public function hasMaxShields() {
552
-		return $this->getShields()==$this->getMaxShields();
552
+		return $this->getShields() == $this->getMaxShields();
553 553
 	}
554 554
 
555 555
 	public function getMaxShields() {
@@ -560,18 +560,18 @@  discard block
 block discarded – undo
560 560
 		return $this->getHardware(HARDWARE_ARMOUR);
561 561
 	}
562 562
 
563
-	public function setArmour($amount,$updateOldAmount=false) {
564
-		if($updateOldAmount && !$this->hasLostArmour())
565
-			$this->setOldHardware(HARDWARE_ARMOUR,$amount);
566
-		$this->setHardware(HARDWARE_ARMOUR,$amount);
563
+	public function setArmour($amount, $updateOldAmount = false) {
564
+		if ($updateOldAmount && !$this->hasLostArmour())
565
+			$this->setOldHardware(HARDWARE_ARMOUR, $amount);
566
+		$this->setHardware(HARDWARE_ARMOUR, $amount);
567 567
 	}
568 568
 
569 569
 	public function decreaseArmour($amount) {
570
-		$this->setArmour($this->getArmour()-$amount);
570
+		$this->setArmour($this->getArmour() - $amount);
571 571
 	}
572 572
 
573 573
 	public function increaseArmour($amount) {
574
-		$this->setArmour($this->getArmour()+$amount);
574
+		$this->setArmour($this->getArmour() + $amount);
575 575
 	}
576 576
 
577 577
 	public function getOldArmour() {
@@ -579,19 +579,19 @@  discard block
 block discarded – undo
579 579
 	}
580 580
 
581 581
 	public function setOldArmour($amount) {
582
-		$this->setOldHardware(HARDWARE_ARMOUR,$amount);
582
+		$this->setOldHardware(HARDWARE_ARMOUR, $amount);
583 583
 	}
584 584
 
585 585
 	public function hasArmour() {
586
-		return $this->getArmour()>0;
586
+		return $this->getArmour() > 0;
587 587
 	}
588 588
 
589 589
 	public function hasLostArmour() {
590
-		return $this->getArmour()<$this->getOldArmour();
590
+		return $this->getArmour() < $this->getOldArmour();
591 591
 	}
592 592
 
593 593
 	public function hasMaxArmour() {
594
-		return $this->getArmour()==$this->getMaxArmour();
594
+		return $this->getArmour() == $this->getMaxArmour();
595 595
 	}
596 596
 
597 597
 	public function getMaxArmour() {
@@ -599,53 +599,53 @@  discard block
 block discarded – undo
599 599
 	}
600 600
 
601 601
 	public function isDead() {
602
-		return !$this->hasArmour()&&!$this->hasShields();
602
+		return !$this->hasArmour() && !$this->hasShields();
603 603
 	}
604 604
 
605 605
 	public function canAcceptCDs() {
606
-		return $this->getCDs()<$this->getMaxCDs();
606
+		return $this->getCDs() < $this->getMaxCDs();
607 607
 	}
608 608
 
609 609
 	public function canAcceptSDs() {
610
-		return $this->getSDs()<$this->getMaxSDs();
610
+		return $this->getSDs() < $this->getMaxSDs();
611 611
 	}
612 612
 
613 613
 	public function canAcceptMines() {
614
-		return $this->getMines()<$this->getMaxMines();
614
+		return $this->getMines() < $this->getMaxMines();
615 615
 	}
616 616
 
617 617
 	public function hasCDs() {
618
-		return $this->getCDs()>0;
618
+		return $this->getCDs() > 0;
619 619
 	}
620 620
 
621 621
 	public function hasSDs() {
622
-		return $this->getSDs()>0;
622
+		return $this->getSDs() > 0;
623 623
 	}
624 624
 
625 625
 	public function hasMines() {
626
-		return $this->getMines()>0;
626
+		return $this->getMines() > 0;
627 627
 	}
628 628
 
629 629
 	public function getCDs() {
630 630
 		return $this->getHardware(HARDWARE_COMBAT);
631 631
 	}
632 632
 
633
-	public function setCDs($amount,$updateOldAmount=false) {
634
-		if($updateOldAmount && !$this->hasLostCDs())
635
-			$this->setOldHardware(HARDWARE_COMBAT,$amount);
636
-		$this->setHardware(HARDWARE_COMBAT,$amount);
633
+	public function setCDs($amount, $updateOldAmount = false) {
634
+		if ($updateOldAmount && !$this->hasLostCDs())
635
+			$this->setOldHardware(HARDWARE_COMBAT, $amount);
636
+		$this->setHardware(HARDWARE_COMBAT, $amount);
637 637
 	}
638 638
 
639 639
 	/**
640 640
 	 * Decreases the ship CDs. Use $updateOldAmount=true to prevent
641 641
 	 * this change from triggering `isUnderAttack`.
642 642
 	 */
643
-	public function decreaseCDs($amount,$updateOldAmount=false) {
644
-		$this->setCDs($this->getCDs()-$amount,$updateOldAmount);
643
+	public function decreaseCDs($amount, $updateOldAmount = false) {
644
+		$this->setCDs($this->getCDs() - $amount, $updateOldAmount);
645 645
 	}
646 646
 
647 647
 	public function increaseCDs($amount) {
648
-		$this->setCDs($this->getCDs()+$amount);
648
+		$this->setCDs($this->getCDs() + $amount);
649 649
 	}
650 650
 
651 651
 	public function getOldCDs() {
@@ -653,11 +653,11 @@  discard block
 block discarded – undo
653 653
 	}
654 654
 
655 655
 	public function setOldCDs($amount) {
656
-		$this->setOldHardware(HARDWARE_COMBAT,$amount);
656
+		$this->setOldHardware(HARDWARE_COMBAT, $amount);
657 657
 	}
658 658
 
659 659
 	public function hasLostCDs() {
660
-		return $this->getCDs()<$this->getOldCDs();
660
+		return $this->getCDs() < $this->getOldCDs();
661 661
 	}
662 662
 
663 663
 	public function getMaxCDs() {
@@ -669,15 +669,15 @@  discard block
 block discarded – undo
669 669
 	}
670 670
 
671 671
 	public function setSDs($amount) {
672
-		$this->setHardware(HARDWARE_SCOUT,$amount);
672
+		$this->setHardware(HARDWARE_SCOUT, $amount);
673 673
 	}
674 674
 
675 675
 	public function decreaseSDs($amount) {
676
-		$this->setSDs($this->getSDs()-$amount);
676
+		$this->setSDs($this->getSDs() - $amount);
677 677
 	}
678 678
 
679 679
 	public function increaseSDs($amount) {
680
-		$this->setSDs($this->getSDs()+$amount);
680
+		$this->setSDs($this->getSDs() + $amount);
681 681
 	}
682 682
 
683 683
 	public function getMaxSDs() {
@@ -689,15 +689,15 @@  discard block
 block discarded – undo
689 689
 	}
690 690
 
691 691
 	public function setMines($amount) {
692
-		$this->setHardware(HARDWARE_MINE,$amount);
692
+		$this->setHardware(HARDWARE_MINE, $amount);
693 693
 	}
694 694
 
695 695
 	public function decreaseMines($amount) {
696
-		$this->setMines($this->getMines()-$amount);
696
+		$this->setMines($this->getMines() - $amount);
697 697
 	}
698 698
 
699 699
 	public function increaseMines($amount) {
700
-		$this->setMines($this->getMines()+$amount);
700
+		$this->setMines($this->getMines() + $amount);
701 701
 	}
702 702
 
703 703
 	public function getMaxMines() {
@@ -709,12 +709,12 @@  discard block
 block discarded – undo
709 709
 	}
710 710
 
711 711
 	public function setCargoHolds($amount) {
712
-		$this->setHardware(HARDWARE_CARGO,$amount);
712
+		$this->setHardware(HARDWARE_CARGO, $amount);
713 713
 	}
714 714
 
715
-	public function &getCargo($goodID=false) {
716
-		if($goodID!==false) {
717
-			if(isset($this->cargo[$goodID]))
715
+	public function &getCargo($goodID = false) {
716
+		if ($goodID !== false) {
717
+			if (isset($this->cargo[$goodID]))
718 718
 				return $this->cargo[$goodID];
719 719
 			$cargo = 0;
720 720
 			return $cargo;
@@ -722,16 +722,16 @@  discard block
 block discarded – undo
722 722
 		return $this->cargo;
723 723
 	}
724 724
 
725
-	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;
725
+	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;
730 730
 		return false;
731 731
 	}
732 732
 
733
-	public function setCargo($goodID,$amount) {
734
-		if($this->getCargo($goodID) == $amount)
733
+	public function setCargo($goodID, $amount) {
734
+		if ($this->getCargo($goodID) == $amount)
735 735
 			return;
736 736
 		$this->cargo[$goodID] = $amount;
737 737
 		$this->hasChangedCargo = true;
@@ -740,20 +740,20 @@  discard block
 block discarded – undo
740 740
 		ksort($this->cargo);
741 741
 	}
742 742
 
743
-	public function decreaseCargo($goodID,$amount) {
744
-		if($amount < 0)
743
+	public function decreaseCargo($goodID, $amount) {
744
+		if ($amount < 0)
745 745
 			throw new Exception('Trying to decrease negative cargo.');
746
-		$this->setCargo($goodID,$this->getCargo($goodID)-$amount);
746
+		$this->setCargo($goodID, $this->getCargo($goodID) - $amount);
747 747
 	}
748 748
 
749
-	public function increaseCargo($goodID,$amount) {
750
-		if($amount < 0)
749
+	public function increaseCargo($goodID, $amount) {
750
+		if ($amount < 0)
751 751
 			throw new Exception('Trying to increase negative cargo.');
752
-		$this->setCargo($goodID,$this->getCargo($goodID)+$amount);
752
+		$this->setCargo($goodID, $this->getCargo($goodID) + $amount);
753 753
 	}
754 754
 
755 755
 	public function getEmptyHolds() {
756
-		return $this->getCargoHolds()-$this->getUsedHolds();
756
+		return $this->getCargoHolds() - $this->getUsedHolds();
757 757
 	}
758 758
 
759 759
 	public function getUsedHolds() {
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	}
762 762
 
763 763
 	public function hasMaxCargoHolds() {
764
-		return $this->getCargoHolds()==$this->getMaxCargoHolds();
764
+		return $this->getCargoHolds() == $this->getMaxCargoHolds();
765 765
 	}
766 766
 
767 767
 	public function getMaxCargoHolds() {
@@ -778,16 +778,16 @@  discard block
 block discarded – undo
778 778
 		$this->setOldShields($this->getShields());
779 779
 		$this->setOldCDs($this->getCDs());
780 780
 		$this->setOldArmour($this->getArmour());
781
-		if(isset($var['UnderAttack']))
781
+		if (isset($var['UnderAttack']))
782 782
 			return $var['UnderAttack'];
783
-		if($underAttack && !USING_AJAX) {
784
-			SmrSession::updateVar('UnderAttack',$underAttack); //Remember we are under attack for AJAX
783
+		if ($underAttack && !USING_AJAX) {
784
+			SmrSession::updateVar('UnderAttack', $underAttack); //Remember we are under attack for AJAX
785 785
 		}
786 786
 		return $underAttack;
787 787
 	}
788 788
 
789 789
 	public function hasWeapons() {
790
-		return $this->getNumWeapons()>0;
790
+		return $this->getNumWeapons() > 0;
791 791
 	}
792 792
 
793 793
 	public function &getWeapons() {
@@ -803,11 +803,11 @@  discard block
 block discarded – undo
803 803
 	}
804 804
 
805 805
 	public function getOpenWeaponSlots() {
806
-		return $this->getHardpoints()-$this->getNumWeapons();
806
+		return $this->getHardpoints() - $this->getNumWeapons();
807 807
 	}
808 808
 
809 809
 	public function hasOpenWeaponSlots() {
810
-		return $this->getOpenWeaponSlots()>0;
810
+		return $this->getOpenWeaponSlots() > 0;
811 811
 	}
812 812
 
813 813
 	public function getHardpoints() {
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 	public function getTotalShieldDamage() {
818 818
 		$weapons = $this->getWeapons();
819 819
 		$shieldDamage = 0;
820
-		foreach($weapons as $weapon) {
821
-			$shieldDamage+=$weapon->getShieldDamage();
820
+		foreach ($weapons as $weapon) {
821
+			$shieldDamage += $weapon->getShieldDamage();
822 822
 		}
823 823
 		return $shieldDamage;
824 824
 	}
@@ -826,8 +826,8 @@  discard block
 block discarded – undo
826 826
 	public function getTotalArmourDamage() {
827 827
 		$weapons = $this->getWeapons();
828 828
 		$armourDamage = 0;
829
-		foreach($weapons as $weapon) {
830
-			$armourDamage+=$weapon->getArmourDamage();
829
+		foreach ($weapons as $weapon) {
830
+			$armourDamage += $weapon->getArmourDamage();
831 831
 		}
832 832
 		return $armourDamage;
833 833
 	}
@@ -847,86 +847,86 @@  discard block
 block discarded – undo
847 847
 	public function &shootPlayers(array $targetPlayers) {
848 848
 		$thisPlayer = $this->getPlayer();
849 849
 		$results = array('Player' => $thisPlayer, 'TotalDamage' => 0);
850
-		if($thisPlayer->isDead()) {
850
+		if ($thisPlayer->isDead()) {
851 851
 			$results['DeadBeforeShot'] = true;
852 852
 			return $results;
853 853
 		}
854 854
 		$results['DeadBeforeShot'] = false;
855
-		foreach($this->weapons as $orderID => $weapon) {
856
-			$results['Weapons'][$orderID] =& $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
857
-			if($results['Weapons'][$orderID]['Hit'])
855
+		foreach ($this->weapons as $orderID => $weapon) {
856
+			$results['Weapons'][$orderID] = & $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
857
+			if ($results['Weapons'][$orderID]['Hit'])
858 858
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
859 859
 		}
860
-		if($this->hasCDs()) {
861
-			$thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs());
862
-			$results['Drones'] =& $thisCDs->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
860
+		if ($this->hasCDs()) {
861
+			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
862
+			$results['Drones'] = & $thisCDs->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
863 863
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
864 864
 		}
865
-		$thisPlayer->increaseExperience(round($results['TotalDamage']/4)); // 1/4 weapon damage to exp.
866
-		$thisPlayer->increaseHOF($results['TotalDamage'],array('Combat','Player','Damage Done'), HOF_PUBLIC);
867
-		$thisPlayer->increaseHOF(1,array('Combat','Player','Shots'), HOF_PUBLIC);
865
+		$thisPlayer->increaseExperience(round($results['TotalDamage'] / 4)); // 1/4 weapon damage to exp.
866
+		$thisPlayer->increaseHOF($results['TotalDamage'], array('Combat', 'Player', 'Damage Done'), HOF_PUBLIC);
867
+		$thisPlayer->increaseHOF(1, array('Combat', 'Player', 'Shots'), HOF_PUBLIC);
868 868
 		return $results;
869 869
 	}
870 870
 
871 871
 	public function &shootForces(SmrForce $forces) {
872 872
 		$thisPlayer = $this->getPlayer();
873 873
 		$results = array('Player' => $thisPlayer, 'TotalDamage' => 0);
874
-		if($thisPlayer->isDead()) {
874
+		if ($thisPlayer->isDead()) {
875 875
 			$results['DeadBeforeShot'] = true;
876 876
 			return $results;
877 877
 		}
878 878
 		$results['DeadBeforeShot'] = false;
879
-		foreach($this->weapons as $orderID => $weapon) {
880
-			$results['Weapons'][$orderID] =& $weapon->shootForces($thisPlayer, $forces);
881
-			if($results['Weapons'][$orderID]['Hit']) {
879
+		foreach ($this->weapons as $orderID => $weapon) {
880
+			$results['Weapons'][$orderID] = & $weapon->shootForces($thisPlayer, $forces);
881
+			if ($results['Weapons'][$orderID]['Hit']) {
882 882
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
883
-				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines'],array('Combat','Forces','Mines','Killed'), HOF_PUBLIC);
884
-				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['Mines'],array('Combat','Forces','Mines','Damage Done'), HOF_PUBLIC);
885
-				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumCDs'],array('Combat','Forces','Combat Drones','Killed'), HOF_PUBLIC);
886
-				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['CDs'],array('Combat','Forces','Combat Drones','Damage Done'), HOF_PUBLIC);
887
-				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumSDs'],array('Combat','Forces','Scout Drones','Killed'), HOF_PUBLIC);
888
-				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['SDs'],array('Combat','Forces','Scout Drones','Damage Done'), HOF_PUBLIC);
889
-				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines']+$results['Weapons'][$orderID]['ActualDamage']['NumCDs']+$results['Weapons'][$orderID]['ActualDamage']['NumSDs'],array('Combat','Forces','Killed'), HOF_PUBLIC);
883
+				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines'], array('Combat', 'Forces', 'Mines', 'Killed'), HOF_PUBLIC);
884
+				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['Mines'], array('Combat', 'Forces', 'Mines', 'Damage Done'), HOF_PUBLIC);
885
+				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumCDs'], array('Combat', 'Forces', 'Combat Drones', 'Killed'), HOF_PUBLIC);
886
+				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['CDs'], array('Combat', 'Forces', 'Combat Drones', 'Damage Done'), HOF_PUBLIC);
887
+				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumSDs'], array('Combat', 'Forces', 'Scout Drones', 'Killed'), HOF_PUBLIC);
888
+				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['SDs'], array('Combat', 'Forces', 'Scout Drones', 'Damage Done'), HOF_PUBLIC);
889
+				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines'] + $results['Weapons'][$orderID]['ActualDamage']['NumCDs'] + $results['Weapons'][$orderID]['ActualDamage']['NumSDs'], array('Combat', 'Forces', 'Killed'), HOF_PUBLIC);
890 890
 			}
891 891
 		}
892
-		if($this->hasCDs()) {
893
-			$thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs());
894
-			$results['Drones'] =& $thisCDs->shootForces($thisPlayer, $forces);
892
+		if ($this->hasCDs()) {
893
+			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
894
+			$results['Drones'] = & $thisCDs->shootForces($thisPlayer, $forces);
895 895
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
896
-			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines'],array('Combat','Forces','Mines','Killed'), HOF_PUBLIC);
897
-			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['Mines'],array('Combat','Forces','Mines','Damage Done'), HOF_PUBLIC);
898
-			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumCDs'],array('Combat','Forces','Combat Drones','Killed'), HOF_PUBLIC);
899
-			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['CDs'],array('Combat','Forces','Combat Drones','Damage Done'), HOF_PUBLIC);
900
-			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumSDs'],array('Combat','Forces','Scout Drones','Killed'), HOF_PUBLIC);
901
-			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['SDs'],array('Combat','Forces','Scout Drones','Damage Done'), HOF_PUBLIC);
902
-			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines']+$results['Drones']['ActualDamage']['NumCDs']+$results['Drones']['ActualDamage']['NumSDs'],array('Combat','Forces','Killed'), HOF_PUBLIC);
896
+			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines'], array('Combat', 'Forces', 'Mines', 'Killed'), HOF_PUBLIC);
897
+			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['Mines'], array('Combat', 'Forces', 'Mines', 'Damage Done'), HOF_PUBLIC);
898
+			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumCDs'], array('Combat', 'Forces', 'Combat Drones', 'Killed'), HOF_PUBLIC);
899
+			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['CDs'], array('Combat', 'Forces', 'Combat Drones', 'Damage Done'), HOF_PUBLIC);
900
+			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumSDs'], array('Combat', 'Forces', 'Scout Drones', 'Killed'), HOF_PUBLIC);
901
+			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['SDs'], array('Combat', 'Forces', 'Scout Drones', 'Damage Done'), HOF_PUBLIC);
902
+			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines'] + $results['Drones']['ActualDamage']['NumCDs'] + $results['Drones']['ActualDamage']['NumSDs'], array('Combat', 'Forces', 'Killed'), HOF_PUBLIC);
903 903
 		}
904
-		$thisPlayer->increaseExperience(round($results['TotalDamage']/20)); // 1/20 weapon damage to exp.
905
-		$thisPlayer->increaseHOF($results['TotalDamage'],array('Combat','Forces','Damage Done'), HOF_PUBLIC);
906
-		$thisPlayer->increaseHOF(1,array('Combat','Forces','Shots'), HOF_PUBLIC);
904
+		$thisPlayer->increaseExperience(round($results['TotalDamage'] / 20)); // 1/20 weapon damage to exp.
905
+		$thisPlayer->increaseHOF($results['TotalDamage'], array('Combat', 'Forces', 'Damage Done'), HOF_PUBLIC);
906
+		$thisPlayer->increaseHOF(1, array('Combat', 'Forces', 'Shots'), HOF_PUBLIC);
907 907
 		return $results;
908 908
 	}
909 909
 
910 910
 	public function &shootPort(SmrPort $port) {
911 911
 		$thisPlayer = $this->getPlayer();
912 912
 		$results = array('Player' => $thisPlayer, 'TotalDamage' => 0);
913
-		if($thisPlayer->isDead()) {
913
+		if ($thisPlayer->isDead()) {
914 914
 			$results['DeadBeforeShot'] = true;
915 915
 			return $results;
916 916
 		}
917 917
 		$results['DeadBeforeShot'] = false;
918
-		foreach($this->weapons as $orderID => $weapon) {
919
-			$results['Weapons'][$orderID] =& $weapon->shootPort($thisPlayer, $port);
920
-			if($results['Weapons'][$orderID]['Hit'])
918
+		foreach ($this->weapons as $orderID => $weapon) {
919
+			$results['Weapons'][$orderID] = & $weapon->shootPort($thisPlayer, $port);
920
+			if ($results['Weapons'][$orderID]['Hit'])
921 921
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
922 922
 		}
923
-		if($this->hasCDs()) {
924
-			$thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs());
925
-			$results['Drones'] =& $thisCDs->shootPort($thisPlayer, $port);
923
+		if ($this->hasCDs()) {
924
+			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
925
+			$results['Drones'] = & $thisCDs->shootPort($thisPlayer, $port);
926 926
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
927 927
 		}
928
-		$thisPlayer->increaseExperience(round($results['TotalDamage']/20)); // 1/20 weapon damage to exp.
929
-		$thisPlayer->increaseHOF($results['TotalDamage'],array('Combat','Port','Damage Done'), HOF_PUBLIC);
928
+		$thisPlayer->increaseExperience(round($results['TotalDamage'] / 20)); // 1/20 weapon damage to exp.
929
+		$thisPlayer->increaseHOF($results['TotalDamage'], array('Combat', 'Port', 'Damage Done'), HOF_PUBLIC);
930 930
 //		$thisPlayer->increaseHOF(1,array('Combat','Port','Shots')); //in SmrPortt::attackedBy()
931 931
 
932 932
 		// Change alignment if we reach a damage threshold.
@@ -935,10 +935,10 @@  discard block
 block discarded – undo
935 935
 			$relations = Globals::getRaceRelations($thisPlayer->getGameID(), $thisPlayer->getRaceID());
936 936
 			if ($relations[$port->getRaceID()] <= RELATIONS_WAR) {
937 937
 				$thisPlayer->increaseAlignment(1);
938
-				$thisPlayer->increaseHOF(1, array('Combat','Port','Alignment','Gain'), HOF_PUBLIC);
938
+				$thisPlayer->increaseHOF(1, array('Combat', 'Port', 'Alignment', 'Gain'), HOF_PUBLIC);
939 939
 			} else {
940 940
 				$thisPlayer->decreaseAlignment(1);
941
-				$thisPlayer->increaseHOF(1, array('Combat','Port','Alignment','Loss'), HOF_PUBLIC);
941
+				$thisPlayer->increaseHOF(1, array('Combat', 'Port', 'Alignment', 'Loss'), HOF_PUBLIC);
942 942
 			}
943 943
 		}
944 944
 		return $results;
@@ -947,23 +947,23 @@  discard block
 block discarded – undo
947 947
 	public function &shootPlanet(SmrPlanet $planet, $delayed) {
948 948
 		$thisPlayer = $this->getPlayer();
949 949
 		$results = array('Player' => $thisPlayer, 'TotalDamage' => 0);
950
-		if($thisPlayer->isDead()) {
950
+		if ($thisPlayer->isDead()) {
951 951
 			$results['DeadBeforeShot'] = true;
952 952
 			return $results;
953 953
 		}
954 954
 		$results['DeadBeforeShot'] = false;
955
-		foreach($this->weapons as $orderID => $weapon) {
956
-			$results['Weapons'][$orderID] =& $weapon->shootPlanet($thisPlayer, $planet, $delayed);
957
-			if($results['Weapons'][$orderID]['Hit'])
955
+		foreach ($this->weapons as $orderID => $weapon) {
956
+			$results['Weapons'][$orderID] = & $weapon->shootPlanet($thisPlayer, $planet, $delayed);
957
+			if ($results['Weapons'][$orderID]['Hit'])
958 958
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
959 959
 		}
960
-		if($this->hasCDs()) {
961
-			$thisCDs = new SmrCombatDrones($this->getGameID(),$this->getCDs());
962
-			$results['Drones'] =& $thisCDs->shootPlanet($thisPlayer, $planet, $delayed);
960
+		if ($this->hasCDs()) {
961
+			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
962
+			$results['Drones'] = & $thisCDs->shootPlanet($thisPlayer, $planet, $delayed);
963 963
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
964 964
 		}
965
-		$thisPlayer->increaseExperience(round($results['TotalDamage']/20)); // 1/20 weapon damage to exp.
966
-		$thisPlayer->increaseHOF($results['TotalDamage'],array('Combat','Planet','Damage Done'), HOF_PUBLIC);
965
+		$thisPlayer->increaseExperience(round($results['TotalDamage'] / 20)); // 1/20 weapon damage to exp.
966
+		$thisPlayer->increaseHOF($results['TotalDamage'], array('Combat', 'Planet', 'Damage Done'), HOF_PUBLIC);
967 967
 //		$thisPlayer->increaseHOF(1,array('Combat','Planet','Shots')); //in SmrPlanet::attackedBy()
968 968
 		return $results;
969 969
 	}
@@ -973,15 +973,15 @@  discard block
 block discarded – undo
973 973
 		$armourDamage = 0;
974 974
 		$cdDamage = 0;
975 975
 		$shieldDamage = 0;
976
-		if(!$alreadyDead) {
977
-			$shieldDamage = $this->doShieldDamage(min($damage['MaxDamage'],$damage['Shield']));
976
+		if (!$alreadyDead) {
977
+			$shieldDamage = $this->doShieldDamage(min($damage['MaxDamage'], $damage['Shield']));
978 978
 			$damage['MaxDamage'] -= $shieldDamage;
979
-			if(!$this->hasShields() && ($shieldDamage == 0 || $damage['Rollover'])) {
980
-				$cdDamage = $this->doCDDamage(min($damage['MaxDamage'],$damage['Armour']));
979
+			if (!$this->hasShields() && ($shieldDamage == 0 || $damage['Rollover'])) {
980
+				$cdDamage = $this->doCDDamage(min($damage['MaxDamage'], $damage['Armour']));
981 981
 				$damage['Armour'] -= $cdDamage;
982 982
 				$damage['MaxDamage'] -= $cdDamage;
983
-				if(!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover']))
984
-					$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'],$damage['Armour']));
983
+				if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover']))
984
+					$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour']));
985 985
 			}
986 986
 		}
987 987
 		$return = array(
@@ -989,10 +989,10 @@  discard block
 block discarded – undo
989 989
 						'TargetAlreadyDead' => $alreadyDead,
990 990
 						'Shield' => $shieldDamage,
991 991
 						'CDs' => $cdDamage,
992
-						'NumCDs' => $cdDamage/CD_ARMOUR,
992
+						'NumCDs' => $cdDamage / CD_ARMOUR,
993 993
 						'Armour' => $armourDamage,
994 994
 						'HasCDs' => $this->hasCDs(),
995
-						'TotalDamage' => $shieldDamage+$cdDamage+$armourDamage
995
+						'TotalDamage' => $shieldDamage + $cdDamage + $armourDamage
996 996
 		);
997 997
 		return $return;
998 998
 	}
@@ -1002,11 +1002,11 @@  discard block
 block discarded – undo
1002 1002
 		$armourDamage = 0;
1003 1003
 		$cdDamage = 0;
1004 1004
 		$shieldDamage = 0;
1005
-		if(!$alreadyDead) {
1006
-			$shieldDamage = $this->doShieldDamage(min($damage['MaxDamage'],$damage['Shield']));
1005
+		if (!$alreadyDead) {
1006
+			$shieldDamage = $this->doShieldDamage(min($damage['MaxDamage'], $damage['Shield']));
1007 1007
 			$damage['MaxDamage'] -= $shieldDamage;
1008
-			if(!$this->hasShields() && ($shieldDamage == 0 || $damage['Rollover'])) { //skip CDs if it's mines
1009
-				$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'],$damage['Armour']));
1008
+			if (!$this->hasShields() && ($shieldDamage == 0 || $damage['Rollover'])) { //skip CDs if it's mines
1009
+				$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour']));
1010 1010
 			}
1011 1011
 		}
1012 1012
 		$return = array(
@@ -1014,28 +1014,28 @@  discard block
 block discarded – undo
1014 1014
 						'TargetAlreadyDead' => $alreadyDead,
1015 1015
 						'Shield' => $shieldDamage,
1016 1016
 						'CDs' => $cdDamage,
1017
-						'NumCDs' => $cdDamage/CD_ARMOUR,
1017
+						'NumCDs' => $cdDamage / CD_ARMOUR,
1018 1018
 						'Armour' => $armourDamage,
1019 1019
 						'HasCDs' => $this->hasCDs(),
1020
-						'TotalDamage' => $shieldDamage+$cdDamage+$armourDamage
1020
+						'TotalDamage' => $shieldDamage + $cdDamage + $armourDamage
1021 1021
 		);
1022 1022
 		return $return;
1023 1023
 	}
1024 1024
 
1025 1025
 	protected function doShieldDamage($damage) {
1026
-		$actualDamage = min($this->getShields(),$damage);
1026
+		$actualDamage = min($this->getShields(), $damage);
1027 1027
 		$this->decreaseShields($actualDamage);
1028 1028
 		return $actualDamage;
1029 1029
 	}
1030 1030
 
1031 1031
 	protected function doCDDamage($damage) {
1032
-		$actualDamage = min($this->getCDs(),floor($damage/CD_ARMOUR));
1032
+		$actualDamage = min($this->getCDs(), floor($damage / CD_ARMOUR));
1033 1033
 		$this->decreaseCDs($actualDamage);
1034
-		return $actualDamage*CD_ARMOUR;
1034
+		return $actualDamage * CD_ARMOUR;
1035 1035
 	}
1036 1036
 
1037 1037
 	protected function doArmourDamage($damage) {
1038
-		$actualDamage = min($this->getArmour(),$damage);
1038
+		$actualDamage = min($this->getArmour(), $damage);
1039 1039
 		$this->decreaseArmour($actualDamage);
1040 1040
 		return $actualDamage;
1041 1041
 	}
@@ -1047,17 +1047,17 @@  discard block
 block discarded – undo
1047 1047
 							(
1048 1048
 								$this->getShields()
1049 1049
 								+$this->getArmour()
1050
-								+$this->getCDs()*3
1051
-							)/25
1050
+								+$this->getCDs() * 3
1051
+							) / 25
1052 1052
 							+(
1053
-								$this->getCargoHolds()/100
1054
-								-$this->getSpeed()*5
1055
-								+($this->getHardpoints()/*+$ship['Increases']['Ship Power']*/)*5
1053
+								$this->getCargoHolds() / 100
1054
+								-$this->getSpeed() * 5
1055
+								+($this->getHardpoints()/*+$ship['Increases']['Ship Power']*/) * 5
1056 1056
 								/*+(
1057 1057
 									$ship['Increases']['Mines']
1058 1058
 									+$ship['Increases']['Scout Drones']
1059 1059
 								)/12*/
1060
-								+$this->getCDs()/5
1060
+								+$this->getCDs() / 5
1061 1061
 							)
1062 1062
 						)
1063 1063
 					);
Please login to merge, or discard this patch.