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
Push — master ( 8d8584...432c27 )
by Dan
31s queued 20s
created
engine/Default/smr_file_create.php 1 patch
Braces   +20 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,15 +4,17 @@  discard block
 block discarded – undo
4 4
 // code is read-only. This will help reduce sector lag and possible abuse.
5 5
 release_lock();
6 6
 
7
-if (isset($var['AdminCreateGameID']) && $var['AdminCreateGameID'] !== false)
7
+if (isset($var['AdminCreateGameID']) && $var['AdminCreateGameID'] !== false) {
8 8
 	$gameID = $var['AdminCreateGameID'];
9
-else
9
+} else {
10 10
 	$gameID = $player->getGameID();
11
+}
11 12
 
12
-if (isset($var['AdminCreateGameID']) && $var['AdminCreateGameID'] !== false)
13
+if (isset($var['AdminCreateGameID']) && $var['AdminCreateGameID'] !== false) {
13 14
 	$adminCreate = true;
14
-else
15
+} else {
15 16
 	$adminCreate = false;
17
+}
16 18
 
17 19
 // NOTE: If the format of this file is changed in an incompatible way,
18 20
 // make sure to update the SMR_FILE_VERSION!
@@ -103,8 +105,9 @@  discard block
 block discarded – undo
103 105
 	if ($location->isFed()) {
104 106
 		$locSells .= 'Fed=,';
105 107
 	}
106
-	if ($locSells != '')
107
-		$file .= substr($locSells, 0, -1);
108
+	if ($locSells != '') {
109
+			$file .= substr($locSells, 0, -1);
110
+	}
108 111
 	$file .= EOL;
109 112
 }
110 113
 
@@ -125,19 +128,22 @@  discard block
 block discarded – undo
125 128
 	foreach ($galaxy->getSectors() as $sector) {
126 129
 		$file .= '[Sector=' . $sector->getSectorID() . ']' . EOL;
127 130
 		
128
-		if (!$sector->isVisited($player) && $adminCreate === false)
129
-			continue;
131
+		if (!$sector->isVisited($player) && $adminCreate === false) {
132
+					continue;
133
+		}
130 134
 		
131 135
 		foreach ($sector->getLinks() as $linkName => $link) {
132 136
 			$file .= $linkName . '=' . $link . EOL;
133 137
 		}
134
-		if ($sector->hasWarp())
135
-			$file .= 'Warp=' . $sector->getWarp() . EOL;
138
+		if ($sector->hasWarp()) {
139
+					$file .= 'Warp=' . $sector->getWarp() . EOL;
140
+		}
136 141
 		if (($adminCreate !== false && $sector->hasPort()) || is_object($player) && $sector->hasCachedPort($player)) {
137
-			if ($adminCreate !== false)
138
-				$port = $sector->getPort();
139
-			else
140
-				$port = $sector->getCachedPort($player);
142
+			if ($adminCreate !== false) {
143
+							$port = $sector->getPort();
144
+			} else {
145
+							$port = $sector->getCachedPort($player);
146
+			}
141 147
 			$file .= 'Port Level=' . $port->getLevel() . EOL;
142 148
 			$file .= 'Port Race=' . $port->getRaceID() . EOL;
143 149
 			if (!empty($port->getSoldGoodIDs())) {
Please login to merge, or discard this patch.
admin/Default/1.6/universe_create_save_processing.php 1 patch
Braces   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -19,21 +19,19 @@  discard block
 block discarded – undo
19 19
 	}
20 20
 	SmrSector::saveSectors();
21 21
 	$var['message'] = '<span class="green">Success</span> : Succesfully created galaxies.';
22
-}
23
-else if ($submit == 'Redo Connections') {
22
+} else if ($submit == 'Redo Connections') {
24 23
 	$galaxy = SmrGalaxy::getGalaxy($var['game_id'], $var['gal_on']);
25
-	if (!$galaxy->setConnectivity($_REQUEST['connect']))
26
-		$var['message'] = '<span class="red">Error</span> : Regenerating connections failed.';
27
-	else
28
-		$var['message'] = '<span class="green">Success</span> : Regenerated connectivity with ' . $_REQUEST['connect'] . '% target.';
24
+	if (!$galaxy->setConnectivity($_REQUEST['connect'])) {
25
+			$var['message'] = '<span class="red">Error</span> : Regenerating connections failed.';
26
+	} else {
27
+			$var['message'] = '<span class="green">Success</span> : Regenerated connectivity with ' . $_REQUEST['connect'] . '% target.';
28
+	}
29 29
 	SmrSector::saveSectors();
30
-}
31
-elseif ($submit == 'Toggle Link') {
30
+} elseif ($submit == 'Toggle Link') {
32 31
 	$linkSector = SmrSector::getSector($var['game_id'], $var['sector_id']);
33 32
 	$linkSector->toggleLink($var['dir']);
34 33
 	SmrSector::saveSectors();
35
-}
36
-elseif ($submit == 'Create Locations') {
34
+} elseif ($submit == 'Create Locations') {
37 35
 	$galSectors = SmrSector::getGalaxySectors($var['game_id'], $var['gal_on']);
38 36
 	foreach ($galSectors as $galSector) {
39 37
 		$galSector->removeAllLocations();
@@ -53,8 +51,7 @@  discard block
 block discarded – undo
53 51
 		}
54 52
 	}
55 53
 	$var['message'] = '<span class="green">Success</span> : Succesfully added locations.';
56
-}
57
-elseif ($submit == 'Create Warps') {
54
+} elseif ($submit == 'Create Warps') {
58 55
 	//get all warp info from all gals, some need to be removed, some need to be added
59 56
 	$galaxy = SmrGalaxy::getGalaxy($var['game_id'], $var['gal_on']);
60 57
 	$galSectors = $galaxy->getSectors();
@@ -94,8 +91,7 @@  discard block
 block discarded – undo
94 91
 	}
95 92
 	SmrSector::saveSectors();
96 93
 	$var['message'] = '<span class="green">Success</span> : Succesfully added warps.';
97
-}
98
-elseif ($submit == 'Create Planets') {
94
+} elseif ($submit == 'Create Planets') {
99 95
 	$galaxy = SmrGalaxy::getGalaxy($var['game_id'], $var['gal_on']);
100 96
 	$galSectors = $galaxy->getSectors();
101 97
 	foreach ($galSectors as $galSector) {
@@ -108,13 +104,15 @@  discard block
 block discarded – undo
108 104
 		$numberOfPlanets = $_POST['type' . $planetTypeID];
109 105
 		for ($i = 1; $i <= $numberOfPlanets; $i++) {
110 106
 			$galSector = $galSectors[array_rand($galSectors)];
111
-			while ($galSector->hasPlanet()) $galSector = $galSectors[array_rand($galSectors)]; //1 per sector
107
+			while ($galSector->hasPlanet()) {
108
+				$galSector = $galSectors[array_rand($galSectors)];
109
+			}
110
+			//1 per sector
112 111
 			$galSector->createPlanet($planetTypeID);
113 112
 		}
114 113
 	}
115 114
 	$var['message'] = '<span class="green">Success</span> : Succesfully added planets.';
116
-}
117
-elseif ($submit == 'Create Ports') {
115
+} elseif ($submit == 'Create Ports') {
118 116
 	$numLevelPorts = [];
119 117
 	for ($i = 1; $i <= SmrPort::MAX_LEVEL; $i++) {
120 118
 		$numLevelPorts[$i] = $_REQUEST['port' . $i] ?? 0;
@@ -169,27 +167,23 @@  discard block
 block discarded – undo
169 167
 		}
170 168
 		SmrPort::savePorts();
171 169
 		$var['message'] = '<span class="green">Success</span> : Succesfully added ports.';
172
-	}
173
-	else {
170
+	} else {
174 171
 		$var['message'] = '<span class="red">Error: Your port race distribution must equal 100!</span>';
175 172
 	}
176
-}
177
-elseif ($submit == 'Edit Sector') {
173
+} elseif ($submit == 'Edit Sector') {
178 174
 	$editSector = SmrSector::getSector($var['game_id'], $var['sector_id']);
179 175
 
180 176
 	//update planet
181 177
 	if ($_POST['plan_type'] != '0') {
182 178
 		if (!$editSector->hasPlanet()) {
183 179
 			$editSector->createPlanet($_POST['plan_type']);
184
-		}
185
-		else {
180
+		} else {
186 181
 			$type = $editSector->getPlanet()->getTypeID();
187 182
 			if ($_POST['plan_type'] != $type) {
188 183
 				$editSector->getPlanet()->setTypeID($_POST['plan_type']);
189 184
 			}
190 185
 		}
191
-	}
192
-	else {
186
+	} else {
193 187
 		$editSector->removePlanet();
194 188
 	}
195 189
 
@@ -228,10 +222,11 @@  discard block
 block discarded – undo
228 222
 	for ($x = 0; $x < UNI_GEN_LOCATION_SLOTS; $x++) {
229 223
 		if ($_POST['loc_type' . $x] != 0) {
230 224
 			$locationToAdd = SmrLocation::getLocation($_POST['loc_type' . $x]);
231
-			if ($editSector->hasLocation($locationToAdd->getTypeID()))
232
-				$locationsToKeep[] = $locationToAdd;
233
-			else
234
-				$locationsToAdd[] = $locationToAdd;
225
+			if ($editSector->hasLocation($locationToAdd->getTypeID())) {
226
+							$locationsToKeep[] = $locationToAdd;
227
+			} else {
228
+							$locationsToAdd[] = $locationToAdd;
229
+			}
235 230
 		}
236 231
 	}
237 232
 	$editSector->removeAllLocations();
@@ -265,8 +260,7 @@  discard block
 block discarded – undo
265 260
 function checkSectorAllowedForLoc(SmrSector $sector, SmrLocation $location) {
266 261
 	if (!$location->isHQ()) {
267 262
 		return (count($sector->getLocations()) < 4 && !$sector->offersFederalProtection());
268
-	}
269
-	else {
263
+	} else {
270 264
 		//HQs are here
271 265
 		//find a sector where there are no locations yet
272 266
 		return !$sector->hasLocation();
@@ -274,8 +268,9 @@  discard block
 block discarded – undo
274 268
 }
275 269
 
276 270
 function addLocationToSector(SmrLocation $location, SmrSector $sector) {
277
-	if ($sector->hasLocation($location->getTypeID()))
278
-		return false;
271
+	if ($sector->hasLocation($location->getTypeID())) {
272
+			return false;
273
+	}
279 274
 
280 275
 	$sector->addLocation($location); //insert the location
281 276
 	if ($location->isHQ()) {
@@ -283,13 +278,16 @@  discard block
 block discarded – undo
283 278
 		//Racial/Fed
284 279
 		foreach ($location->getLinkedLocations() as $linkedLocation) {
285 280
 			$sector->addLocation($linkedLocation);
286
-			if ($linkedLocation->isFed())
287
-				$fedBeacon = $linkedLocation;
281
+			if ($linkedLocation->isFed()) {
282
+							$fedBeacon = $linkedLocation;
283
+			}
288 284
 		}
289 285
 			
290 286
 		//add Beacons to all surrounding areas (up to 2 sectors out)
291
-		if (!$sector->offersFederalProtection())
292
-			$sector->addLocation($fedBeacon); //add beacon to this sector
287
+		if (!$sector->offersFederalProtection()) {
288
+					$sector->addLocation($fedBeacon);
289
+		}
290
+		//add beacon to this sector
293 291
 		$visitedSectors = array();
294 292
 		$links = array('Up', 'Right', 'Down', 'Left');
295 293
 		$fedSectors = array($sector);
@@ -299,8 +297,10 @@  discard block
 block discarded – undo
299 297
 				foreach ($links as $link) {
300 298
 					if ($fedSector->hasLink($link) && !isset($visitedSectors[$fedSector->getLink($link)])) {
301 299
 						$linkSector = $sector->getLinkSector($link);
302
-						if (!$linkSector->offersFederalProtection())
303
-							$linkSector->addLocation($fedBeacon); //add beacon to this sector
300
+						if (!$linkSector->offersFederalProtection()) {
301
+													$linkSector->addLocation($fedBeacon);
302
+						}
303
+						//add beacon to this sector
304 304
 						$tempFedSectors[] = $linkSector;
305 305
 						$visitedSectors[$fedSector->getLink($link)] = true;
306 306
 					}
Please login to merge, or discard this patch.
engine/Default/shop_goods_processing.php 1 patch
Braces   +36 added lines, -23 removed lines patch added patch discarded remove patch
@@ -5,59 +5,73 @@  discard block
 block discarded – undo
5 5
 $amount = get_amount();
6 6
 $bargain_price = get_bargain_price();
7 7
 
8
-if (!is_numeric($amount) || !is_numeric($bargain_price))
8
+if (!is_numeric($amount) || !is_numeric($bargain_price)) {
9 9
 	create_error('Numbers only please!');
10
+}
10 11
 // get good name, id, ...
11 12
 $good_id = $var['good_id'];
12 13
 $good_name = Globals::getGoodName($good_id);
13 14
 
14 15
 // do we have enough turns?
15
-if ($player->getTurns() == 0)
16
+if ($player->getTurns() == 0) {
16 17
 	create_error('You don\'t have enough turns to trade.');
18
+}
17 19
 
18 20
 // get rid of those bugs when we die...there is no port at the home sector
19
-if (!$sector->hasPort())
21
+if (!$sector->hasPort()) {
20 22
 	create_error('I can\'t see a port in this sector. Can you?');
23
+}
21 24
 $port = $sector->getPort();
22 25
 
23 26
 // check if the player has the right relations to trade at the current port
24
-if ($player->getRelation($port->getRaceID()) < RELATIONS_WAR)
27
+if ($player->getRelation($port->getRaceID()) < RELATIONS_WAR) {
25 28
 	create_error('This port refuses to trade with you because you are at <span class="big bold red">WAR!</span>');
29
+}
26 30
 
27 31
 // does the port actually buy or sell this good?
28 32
 $transaction = $port->getGoodTransaction($good_id);
29
-if (empty($transaction))
33
+if (empty($transaction)) {
30 34
 	create_error('I don\'t trade in that good.');
35
+}
31 36
 
32 37
 $portGood = $port->getGood($good_id);
33 38
 // check if there are enough left at port
34
-if ($port->getGoodAmount($good_id) < $amount)
39
+if ($port->getGoodAmount($good_id) < $amount) {
35 40
 	create_error('I\'m short of ' . $good_name . '. So I\'m not going to sell you ' . $amount . ' pcs.');
41
+}
36 42
 
37 43
 // does we have what we are going to sell?
38
-if ($transaction == 'Sell' && $amount > $ship->getCargo($good_id))
44
+if ($transaction == 'Sell' && $amount > $ship->getCargo($good_id)) {
39 45
 	create_error('Scanning your ships indicates you don\'t have ' . $amount . ' pcs. of ' . $good_name . '!');
46
+}
40 47
 
41 48
 // check if we have enough room for the thing we are going to buy
42
-if ($transaction == 'Buy' && $amount > $ship->getEmptyHolds())
49
+if ($transaction == 'Buy' && $amount > $ship->getEmptyHolds()) {
43 50
 	create_error('Scanning your ships indicates you don\'t have enough free cargo bays!');
51
+}
44 52
 
45 53
 // check if the guy has enough money
46
-if ($transaction == 'Buy' && $player->getCredits() < $bargain_price)
54
+if ($transaction == 'Buy' && $player->getCredits() < $bargain_price) {
47 55
 	create_error('You don\'t have enough credits!');
56
+}
48 57
 
49 58
 // get relations for us (global + personal)
50 59
 $relations = $player->getRelation($port->getRaceID());
51 60
 
52
-if (!isset($var['ideal_price'])) SmrSession::updateVar('ideal_price', $port->getIdealPrice($good_id, $transaction, $amount, $relations));
61
+if (!isset($var['ideal_price'])) {
62
+	SmrSession::updateVar('ideal_price', $port->getIdealPrice($good_id, $transaction, $amount, $relations));
63
+}
53 64
 $ideal_price = $var['ideal_price'];
54 65
 
55
-if (!isset($var['offered_price'])) SmrSession::updateVar('offered_price', $port->getOfferPrice($ideal_price, $relations, $transaction));
66
+if (!isset($var['offered_price'])) {
67
+	SmrSession::updateVar('offered_price', $port->getOfferPrice($ideal_price, $relations, $transaction));
68
+}
56 69
 $offered_price = $var['offered_price'];
57 70
 
58 71
 // nothing should happen here but just to avoid / by 0
59
-if ($ideal_price == 0 || $offered_price == 0)
72
+if ($ideal_price == 0 || $offered_price == 0) {
60 73
 	create_error('Port calculation error...buy more goods.');
74
+}
61 75
 
62 76
 if ($_REQUEST['action'] == 'Steal') {
63 77
 	if (!$ship->isUnderground()) {
@@ -109,8 +123,7 @@  discard block
 block discarded – undo
109 123
 		$player->increaseHOF($bargain_price, array('Trade', 'Money', 'Buying'), HOF_PUBLIC);
110 124
 		$port->buyGoods($portGood, $amount, $ideal_price, $bargain_price, $gained_exp);
111 125
 		$player->increaseRelationsByTrade($amount, $port->getRaceID());
112
-	}
113
-	elseif ($transaction == 'Sell') {
126
+	} elseif ($transaction == 'Sell') {
114 127
 		$msg_transaction = 'sold';
115 128
 		$ship->decreaseCargo($good_id, $amount);
116 129
 		$player->increaseCredits($bargain_price);
@@ -120,8 +133,7 @@  discard block
 block discarded – undo
120 133
 		$player->increaseHOF($bargain_price, array('Trade', 'Money', 'Selling'), HOF_PUBLIC);
121 134
 		$port->sellGoods($portGood, $amount, $ideal_price, $bargain_price, $gained_exp);
122 135
 		$player->increaseRelationsByTrade($amount, $port->getRaceID());
123
-	}
124
-	elseif ($transaction == 'Steal') {
136
+	} elseif ($transaction == 'Steal') {
125 137
 		$msg_transaction = 'stolen';
126 138
 		$ship->increaseCargo($good_id, $amount);
127 139
 		$player->increaseHOF($amount, array('Trade', 'Goods', 'Stolen'), HOF_ALLIANCE);
@@ -151,13 +163,13 @@  discard block
 block discarded – undo
151 163
 
152 164
 	$container['trade_msg'] = $tradeMessage;
153 165
 
154
-	if ($ship->getEmptyHolds() == 0)
155
-		$container['body'] = 'current_sector.php';
156
-	else
157
-		$container['body'] = 'shop_goods.php';
166
+	if ($ship->getEmptyHolds() == 0) {
167
+			$container['body'] = 'current_sector.php';
168
+	} else {
169
+			$container['body'] = 'shop_goods.php';
170
+	}
158 171
 
159
-}
160
-else {
172
+} else {
161 173
 	// does the trader try to outsmart us?
162 174
 	$container = create_container('skeleton.php', 'shop_goods_trade.php');
163 175
 	transfer('ideal_price');
@@ -172,8 +184,9 @@  discard block
 block discarded – undo
172 184
 }
173 185
 
174 186
 // only take turns if they bargained
175
-if (!isset($container['number_of_bargains']) || $container['number_of_bargains'] != 1)
187
+if (!isset($container['number_of_bargains']) || $container['number_of_bargains'] != 1) {
176 188
 	$player->takeTurns(TURNS_PER_TRADE, TURNS_PER_TRADE);
189
+}
177 190
 
178 191
 // go to next page
179 192
 forward($container);
Please login to merge, or discard this patch.
lib/Default/ChessPiece.class.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -91,8 +91,7 @@  discard block
 block discarded – undo
91 91
 						}
92 92
 					}
93 93
 				}
94
-			}
95
-			else if($this->pieceID==self::KING) {
94
+			} else if($this->pieceID==self::KING) {
96 95
 				for($i = -1; $i < 2; $i++) {
97 96
 					for($j = -1; $j < 2; $j++) {
98 97
 						if($i!=0 || $j!=0) {
@@ -114,8 +113,7 @@  discard block
 block discarded – undo
114 113
 						$this->addMove($this->x+2, $this->y, $board, $moves, $hasMoved, $attackingCheck);
115 114
 					}
116 115
 				}
117
-			}
118
-			else if($this->pieceID==self::QUEEN) {
116
+			} else if($this->pieceID==self::QUEEN) {
119 117
 				$moveX = $this->x;
120 118
 				$moveY = $this->y;
121 119
 				while($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left
@@ -140,8 +138,7 @@  discard block
 block discarded – undo
140 138
 				$moveX = $this->x;
141 139
 				$moveY = $this->y;
142 140
 				while($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
143
-			}
144
-			else if($this->pieceID==self::ROOK) {
141
+			} else if($this->pieceID==self::ROOK) {
145 142
 				$moveX = $this->x;
146 143
 				$moveY = $this->y;
147 144
 				while($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left
@@ -154,8 +151,7 @@  discard block
 block discarded – undo
154 151
 				$moveX = $this->x;
155 152
 				$moveY = $this->y;
156 153
 				while($this->addMove($moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down
157
-			}
158
-			else if($this->pieceID==self::BISHOP) {
154
+			} else if($this->pieceID==self::BISHOP) {
159 155
 				$moveX = $this->x;
160 156
 				$moveY = $this->y;
161 157
 				while($this->addMove(--$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
@@ -168,8 +164,7 @@  discard block
 block discarded – undo
168 164
 				$moveX = $this->x;
169 165
 				$moveY = $this->y;
170 166
 				while($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
171
-			}
172
-			else if($this->pieceID==self::KNIGHT) {
167
+			} else if($this->pieceID==self::KNIGHT) {
173 168
 				$moveX = $this->x-1;
174 169
 				$moveY = $this->y-2;
175 170
 				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck);//2up-left
Please login to merge, or discard this patch.
lib/Default/Plotter.class.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -92,12 +92,14 @@  discard block
 block discarded – undo
92 92
 		$sectorsTravelled = 0;
93 93
 		$visitedSectors = array();
94 94
 		$visitedSectors[$checkSector->getSectorID()] = true;
95
-		if ($x == 'Distance')
96
-			$distances[0][$checkSector->getSectorID()] = new Distance($gameID, $checkSector->getSectorID());
95
+		if ($x == 'Distance') {
96
+					$distances[0][$checkSector->getSectorID()] = new Distance($gameID, $checkSector->getSectorID());
97
+		}
97 98
 
98 99
 		$distanceQ = array();
99
-		for ($i = 0; $i <= TURNS_WARP_SECTOR_EQUIVALENCE; $i++)
100
-			$distanceQ[] = array();
100
+		for ($i = 0; $i <= TURNS_WARP_SECTOR_EQUIVALENCE; $i++) {
101
+					$distanceQ[] = array();
102
+		}
101 103
 		//Warps first as a slight optimisation due to how visitedSectors is set.
102 104
 		if ($checkSector->hasWarp() === true) {
103 105
 			$d = new Distance($gameID, $checkSector->getSectorID());
@@ -115,8 +117,9 @@  discard block
 block discarded – undo
115 117
 		$maybeWarps = 0;
116 118
 		while ($maybeWarps <= TURNS_WARP_SECTOR_EQUIVALENCE) {
117 119
 			$sectorsTravelled++;
118
-			if ($sectorsTravelled > $distanceLimit)
119
-				return $distances;
120
+			if ($sectorsTravelled > $distanceLimit) {
121
+							return $distances;
122
+			}
120 123
 			if ($x == 'Distance') {
121 124
 				$distances[$sectorsTravelled] = array();
122 125
 			}
@@ -134,11 +137,11 @@  discard block
 block discarded – undo
134 137
 					$checkSector = SmrSector::getSector($gameID, $checkSectorID);
135 138
 					if ($x == 'Distance') {
136 139
 						$distances[$sectorsTravelled][$checkSector->getSectorID()] = $distance;
137
-					}
138
-					else if (($needsToHaveBeenExploredBy === null || $needsToHaveBeenExploredBy->hasVisitedSector($checkSector->getSectorID())) === true
140
+					} else if (($needsToHaveBeenExploredBy === null || $needsToHaveBeenExploredBy->hasVisitedSector($checkSector->getSectorID())) === true
139 141
 							&& $checkSector->hasX($x, $player) === true) {
140
-						if ($useFirst === true)
141
-							return $distance;
142
+						if ($useFirst === true) {
143
+													return $distance;
144
+						}
142 145
 						$distances[$checkSector->getSectorID()] = $distance;
143 146
 					}
144 147
 					//Warps first as a slight optimisation due to how visitedSectors is set.
Please login to merge, or discard this patch.
lib/Default/DummyShip.class.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,8 +72,7 @@
 block discarded – undo
72 72
 				$return = unserialize($db->getField('info'));
73 73
 				$return->regenerate($player);
74 74
 				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] =& $return;
75
-			}
76
-			else {
75
+			} else {
77 76
 				self::$CACHED_DUMMY_SHIPS[$player->getPlayerName()] = new DummyShip($player);
78 77
 			}
79 78
 		}
Please login to merge, or discard this patch.
lib/Default/SmrForce.class.php 1 patch
Braces   +8 added lines, -12 removed lines patch added patch discarded remove patch
@@ -252,16 +252,16 @@  discard block
 block discarded – undo
252 252
 		}
253 253
 		$this->hasChanged = true;
254 254
 		$this->expire = $time;
255
-		if (!$this->isNew)
256
-			$this->update();
255
+		if (!$this->isNew) {
256
+					$this->update();
257
+		}
257 258
 	}
258 259
 
259 260
 	public function updateExpire() {
260 261
 		// Changed (26/10/05) - scout drones count * 2
261 262
 		if ($this->getCDs() == 0 && $this->getMines() == 0 && $this->getSDs() > 0) {
262 263
 			$time = self::TIME_PER_SCOUT_ONLY * $this->getSDs();
263
-		}
264
-		else {
264
+		} else {
265 265
 			$time = ($this->getCDs() * self::TIME_PERCENT_PER_COMBAT + $this->getSDs() * self::TIME_PERCENT_PER_SCOUT + $this->getMines() * self::TIME_PERCENT_PER_MINE) * $this->getMaxGalaxyExpireTime();
266 266
 		}
267 267
 		$this->setExpire(TIME + $time);
@@ -288,11 +288,9 @@  discard block
 block discarded – undo
288 288
 		}
289 289
 		if ($mines < 10) {
290 290
 			$turns = 1;
291
-		}
292
-		else if ($mines < 25) {
291
+		} else if ($mines < 25) {
293 292
 			$turns = 2;
294
-		}
295
-		else {
293
+		} else {
296 294
 			$turns = 3;
297 295
 		}
298 296
 		if ($ship->isFederal() || $ship->hasDCS()) {
@@ -347,12 +345,10 @@  discard block
 block discarded – undo
347 345
 			if (!$this->exists()) {
348 346
 				$this->db->query('DELETE FROM sector_has_forces WHERE ' . $this->SQL);
349 347
 				$this->isNew = true;
350
-			}
351
-			else if ($this->hasChanged) {
348
+			} else if ($this->hasChanged) {
352 349
 				$this->db->query('UPDATE sector_has_forces SET combat_drones = ' . $this->db->escapeNumber($this->combatDrones) . ', scout_drones = ' . $this->db->escapeNumber($this->scoutDrones) . ', mines = ' . $this->db->escapeNumber($this->mines) . ', expire_time = ' . $this->db->escapeNumber($this->expire) . ' WHERE ' . $this->SQL);
353 350
 			}
354
-		}
355
-		else if ($this->exists()) {
351
+		} else if ($this->exists()) {
356 352
 			$this->db->query('INSERT INTO sector_has_forces (game_id, sector_id, owner_id, combat_drones, scout_drones, mines, expire_time)
357 353
 								VALUES('.$this->db->escapeNumber($this->gameID) . ', ' . $this->db->escapeNumber($this->sectorID) . ', ' . $this->db->escapeNumber($this->ownerID) . ', ' . $this->db->escapeNumber($this->combatDrones) . ', ' . $this->db->escapeNumber($this->scoutDrones) . ', ' . $this->db->escapeNumber($this->mines) . ', ' . $this->db->escapeNumber($this->expire) . ')');
358 354
 			$this->isNew = false;
Please login to merge, or discard this patch.
lib/Default/AbstractSmrCombatWeapon.class.php 1 patch
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -87,8 +87,9 @@  discard block
 block discarded – undo
87 87
 	protected function &doPlayerDamageToForce(array &$return, AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
88 88
 		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstForces($weaponPlayer,$forces);
89 89
 		$return['ActualDamage'] =& $forces->doWeaponDamage($return['WeaponDamage']);
90
-		if($return['ActualDamage']['KillingShot'])
91
-			$return['KillResults'] =& $forces->killForcesByPlayer($weaponPlayer);
90
+		if($return['ActualDamage']['KillingShot']) {
91
+					$return['KillResults'] =& $forces->killForcesByPlayer($weaponPlayer);
92
+		}
92 93
 		return $return;
93 94
 	}
94 95
 	
@@ -96,24 +97,27 @@  discard block
 block discarded – undo
96 97
 		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPlayer($weaponPlayer,$targetPlayer);
97 98
 		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
98 99
 
99
-		if($return['ActualDamage']['KillingShot'])
100
-			$return['KillResults'] =& $targetPlayer->killPlayerByPlayer($weaponPlayer);
100
+		if($return['ActualDamage']['KillingShot']) {
101
+					$return['KillResults'] =& $targetPlayer->killPlayerByPlayer($weaponPlayer);
102
+		}
101 103
 		return $return;
102 104
 	}
103 105
 	
104 106
 	protected function &doPlayerDamageToPort(array &$return, AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
105 107
 		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPort($weaponPlayer,$port);
106 108
 		$return['ActualDamage'] =& $port->doWeaponDamage($return['WeaponDamage']);
107
-		if($return['ActualDamage']['KillingShot'])
108
-			$return['KillResults'] =& $port->killPortByPlayer($weaponPlayer);
109
+		if($return['ActualDamage']['KillingShot']) {
110
+					$return['KillResults'] =& $port->killPortByPlayer($weaponPlayer);
111
+		}
109 112
 		return $return;
110 113
 	}
111 114
 	
112 115
 	protected function &doPlayerDamageToPlanet(array &$return, AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet, $delayed) {
113 116
 		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPlanet($weaponPlayer,$planet);
114 117
 		$return['ActualDamage'] =& $planet->doWeaponDamage($return['WeaponDamage'],$delayed);
115
-		if($return['ActualDamage']['KillingShot'])
116
-			$return['KillResults'] =& $planet->killPlanetByPlayer($weaponPlayer);
118
+		if($return['ActualDamage']['KillingShot']) {
119
+					$return['KillResults'] =& $planet->killPlanetByPlayer($weaponPlayer);
120
+		}
117 121
 		return $return;
118 122
 	}
119 123
 	
@@ -121,8 +125,9 @@  discard block
 block discarded – undo
121 125
 		$return['WeaponDamage'] =& $this->getModifiedPortDamageAgainstPlayer($port,$targetPlayer);
122 126
 		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
123 127
 
124
-		if($return['ActualDamage']['KillingShot'])
125
-			$return['KillResults'] =& $targetPlayer->killPlayerByPort($port);
128
+		if($return['ActualDamage']['KillingShot']) {
129
+					$return['KillResults'] =& $targetPlayer->killPlayerByPort($port);
130
+		}
126 131
 		return $return;
127 132
 	}
128 133
 	
@@ -130,8 +135,9 @@  discard block
 block discarded – undo
130 135
 		$return['WeaponDamage'] =& $this->getModifiedPlanetDamageAgainstPlayer($planet,$targetPlayer);
131 136
 		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
132 137
 
133
-		if($return['ActualDamage']['KillingShot'])
134
-			$return['KillResults'] =& $targetPlayer->killPlayerByPlanet($planet);
138
+		if($return['ActualDamage']['KillingShot']) {
139
+					$return['KillResults'] =& $targetPlayer->killPlayerByPlanet($planet);
140
+		}
135 141
 		return $return;
136 142
 	}
137 143
 	
@@ -139,8 +145,9 @@  discard block
 block discarded – undo
139 145
 		$return['WeaponDamage'] =& $this->getModifiedForceDamageAgainstPlayer($forces,$targetPlayer);
140 146
 		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
141 147
 
142
-		if($return['ActualDamage']['KillingShot'])
143
-			$return['KillResults'] =& $targetPlayer->killPlayerByForces($forces);
148
+		if($return['ActualDamage']['KillingShot']) {
149
+					$return['KillResults'] =& $targetPlayer->killPlayerByForces($forces);
150
+		}
144 151
 		return $return;
145 152
 	}
146 153
 	
Please login to merge, or discard this patch.
lib/Default/AbstractSmrLocation.class.php 1 patch
Braces   +55 added lines, -46 removed lines patch added patch discarded remove patch
@@ -74,8 +74,7 @@  discard block
 block discarded – undo
74 74
 			$this->name = $db->getField('location_name');
75 75
 			$this->processor = $db->getField('location_processor');
76 76
 			$this->image = $db->getField('location_image');
77
-		}
78
-		else {
77
+		} else {
79 78
 			throw new Exception('Cannot find location: ' . $locationTypeID);
80 79
 		}
81 80
 	}
@@ -134,8 +133,7 @@  discard block
 block discarded – undo
134 133
 		if ($bool === true) {
135 134
 			$this->db->query('INSERT IGNORE INTO location_is_fed (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
136 135
 			$this->fed = true;
137
-		}
138
-		else if ($bool === false) {
136
+		} else if ($bool === false) {
139 137
 			$this->db->query('DELETE FROM location_is_fed WHERE ' . $this->SQL . ' LIMIT 1');
140 138
 			$this->fed = false;
141 139
 		}
@@ -150,13 +148,13 @@  discard block
 block discarded – undo
150 148
 	}
151 149
 	
152 150
 	public function setBank($bool) {
153
-		if ($this->bank === $bool)
154
-			return;
151
+		if ($this->bank === $bool) {
152
+					return;
153
+		}
155 154
 		if ($bool === true) {
156 155
 			$this->db->query('INSERT INTO location_is_bank (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
157 156
 			$this->bank = true;
158
-		}
159
-		else if ($bool === false) {
157
+		} else if ($bool === false) {
160 158
 			$this->db->query('DELETE FROM location_is_bank WHERE ' . $this->SQL . ' LIMIT 1');
161 159
 			$this->bank = false;
162 160
 		}
@@ -171,13 +169,13 @@  discard block
 block discarded – undo
171 169
 	}
172 170
 	
173 171
 	public function setBar($bool) {
174
-		if ($this->bar === $bool)
175
-			return;
172
+		if ($this->bar === $bool) {
173
+					return;
174
+		}
176 175
 		if ($bool === true) {
177 176
 			$this->db->query('INSERT IGNORE INTO location_is_bar (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
178 177
 			$this->bar = true;
179
-		}
180
-		else if ($bool === false) {
178
+		} else if ($bool === false) {
181 179
 			$this->db->query('DELETE FROM location_is_bar WHERE ' . $this->SQL . ' LIMIT 1');
182 180
 			$this->bar = false;
183 181
 		}
@@ -192,13 +190,13 @@  discard block
 block discarded – undo
192 190
 	}
193 191
 	
194 192
 	public function setHQ($bool) {
195
-		if ($this->HQ === $bool)
196
-			return;
193
+		if ($this->HQ === $bool) {
194
+					return;
195
+		}
197 196
 		if ($bool === true) {
198 197
 			$this->db->query('INSERT IGNORE INTO location_is_hq (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
199 198
 			$this->HQ = true;
200
-		}
201
-		else if ($bool === false) {
199
+		} else if ($bool === false) {
202 200
 			$this->db->query('DELETE FROM location_is_hq WHERE ' . $this->SQL . ' LIMIT 1');
203 201
 			$this->HQ = false;
204 202
 		}
@@ -213,13 +211,13 @@  discard block
 block discarded – undo
213 211
 	}
214 212
 	
215 213
 	public function setUG($bool) {
216
-		if ($this->UG === $bool)
217
-			return;
214
+		if ($this->UG === $bool) {
215
+					return;
216
+		}
218 217
 		if ($bool === true) {
219 218
 			$this->db->query('INSERT INTO location_is_ug (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
220 219
 			$this->UG = true;
221
-		}
222
-		else if ($bool === false) {
220
+		} else if ($bool === false) {
223 221
 			$this->db->query('DELETE FROM location_is_ug WHERE ' . $this->SQL . ' LIMIT 1');
224 222
 			$this->UG = false;
225 223
 		}
@@ -245,18 +243,21 @@  discard block
 block discarded – undo
245 243
 	}
246 244
 	
247 245
 	public function addHardwareSold($hardwareTypeID) {
248
-		if ($this->isHardwareSold($hardwareTypeID))
249
-			return;
246
+		if ($this->isHardwareSold($hardwareTypeID)) {
247
+					return;
248
+		}
250 249
 		$this->db->query('SELECT * FROM hardware_type WHERE hardware_type_id = ' . $this->db->escapeNumber($hardwareTypeID) . ' LIMIT 1');
251
-		if (!$this->db->nextRecord())
252
-			throw new Exception('Invalid hardware type id given');
250
+		if (!$this->db->nextRecord()) {
251
+					throw new Exception('Invalid hardware type id given');
252
+		}
253 253
 		$this->db->query('INSERT INTO location_sells_hardware (location_type_id,hardware_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($hardwareTypeID) . ')');
254 254
 		$this->hardwareSold[$hardwareTypeID] = $this->db->getField('hardware_name');
255 255
 	}
256 256
 	
257 257
 	public function removeHardwareSold($hardwareTypeID) {
258
-		if (!$this->isHardwareSold($hardwareTypeID))
259
-			return;
258
+		if (!$this->isHardwareSold($hardwareTypeID)) {
259
+					return;
260
+		}
260 261
 		$this->db->query('DELETE FROM location_sells_hardware WHERE ' . $this->SQL . ' AND hardware_type_id = ' . $this->db->escapeNumber($hardwareTypeID) . ' LIMIT 1');
261 262
 		unset($this->hardwareSold[$hardwareTypeID]);
262 263
 	}
@@ -274,24 +275,28 @@  discard block
 block discarded – undo
274 275
 	
275 276
 	public function isShipSold($shipTypeID = false) {
276 277
 		$ships = $this->getShipsSold();
277
-		if ($shipTypeID === false)
278
-			return count($ships) != 0;
278
+		if ($shipTypeID === false) {
279
+					return count($ships) != 0;
280
+		}
279 281
 		return isset($ships[$shipTypeID]);
280 282
 	}
281 283
 	
282 284
 	public function addShipSold($shipTypeID) {
283
-		if ($this->isShipSold($shipTypeID))
284
-			return;
285
+		if ($this->isShipSold($shipTypeID)) {
286
+					return;
287
+		}
285 288
 		$ship = AbstractSmrShip::getBaseShip(Globals::getGameType(SmrSession::getGameID()), $shipTypeID);
286
-		if ($ship === false)
287
-			throw new Exception('Invalid ship type id given');
289
+		if ($ship === false) {
290
+					throw new Exception('Invalid ship type id given');
291
+		}
288 292
 		$this->db->query('INSERT INTO location_sells_ships (location_type_id,ship_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($shipTypeID) . ')');
289 293
 		$this->shipsSold[$shipTypeID] = $ship;
290 294
 	}
291 295
 	
292 296
 	public function removeShipSold($shipTypeID) {
293
-		if (!$this->isShipSold($shipTypeID))
294
-			return;
297
+		if (!$this->isShipSold($shipTypeID)) {
298
+					return;
299
+		}
295 300
 		$this->db->query('DELETE FROM location_sells_ships WHERE ' . $this->SQL . ' AND ship_type_id = ' . $this->db->escapeNumber($shipTypeID) . ' LIMIT 1');
296 301
 		unset($this->shipsSold[$shipTypeID]);
297 302
 	}
@@ -300,32 +305,37 @@  discard block
 block discarded – undo
300 305
 		if (!isset($this->weaponsSold)) {
301 306
 			$this->weaponsSold = array();
302 307
 			$this->db->query('SELECT * FROM location_sells_weapons JOIN weapon_type USING (weapon_type_id) WHERE ' . $this->SQL);
303
-			while ($this->db->nextRecord())
304
-				$this->weaponsSold[$this->db->getInt('weapon_type_id')] = SmrWeapon::getWeapon($this->db->getInt('weapon_type_id'), false, $this->db);
308
+			while ($this->db->nextRecord()) {
309
+							$this->weaponsSold[$this->db->getInt('weapon_type_id')] = SmrWeapon::getWeapon($this->db->getInt('weapon_type_id'), false, $this->db);
310
+			}
305 311
 		}
306 312
 		return $this->weaponsSold;
307 313
 	}
308 314
 	
309 315
 	public function isWeaponSold($weaponTypeID = false) {
310 316
 		$weapons = $this->getWeaponsSold();
311
-		if ($weaponTypeID === false)
312
-			return count($weapons) != 0;
317
+		if ($weaponTypeID === false) {
318
+					return count($weapons) != 0;
319
+		}
313 320
 		return isset($weapons[$weaponTypeID]);
314 321
 	}
315 322
 	
316 323
 	public function addWeaponSold($weaponTypeID) {
317
-		if ($this->isWeaponSold($weaponTypeID))
318
-			return;
324
+		if ($this->isWeaponSold($weaponTypeID)) {
325
+					return;
326
+		}
319 327
 		$weapon = SmrWeapon::getWeapon($weaponTypeID);
320
-		if ($weapon === false)
321
-			throw new Exception('Invalid weapon type id given');
328
+		if ($weapon === false) {
329
+					throw new Exception('Invalid weapon type id given');
330
+		}
322 331
 		$this->db->query('INSERT INTO location_sells_weapons (location_type_id,weapon_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ',' . $this->db->escapeNumber($weaponTypeID) . ')');
323 332
 		$this->weaponsSold[$weaponTypeID] = $weapon;
324 333
 	}
325 334
 	
326 335
 	public function removeWeaponSold($weaponTypeID) {
327
-		if (!$this->isWeaponSold($weaponTypeID))
328
-			return;
336
+		if (!$this->isWeaponSold($weaponTypeID)) {
337
+					return;
338
+		}
329 339
 		$this->db->query('DELETE FROM location_sells_weapons WHERE ' . $this->SQL . ' AND weapon_type_id = ' . $this->db->escapeNumber($weaponTypeID) . ' LIMIT 1');
330 340
 		unset($this->weaponsSold[$weaponTypeID]);
331 341
 	}
@@ -336,8 +346,7 @@  discard block
 block discarded – undo
336 346
 			if ($this->getTypeID() == LOCATION_TYPE_FEDERAL_HQ) {
337 347
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_BEACON);
338 348
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_MINT);
339
-			}
340
-			else {
349
+			} else {
341 350
 				$raceID = $this->getRaceID();
342 351
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_BEACONS + $raceID);
343 352
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_SHIPS + $raceID);
Please login to merge, or discard this patch.