We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -139,8 +139,7 @@ |
||
139 | 139 | $news = 'The [race=' . $race_id_1 . '] have declared <span class="red">WAR</span> on the [race=' . $race_id_2 . ']'; |
140 | 140 | $db2->query('INSERT INTO news (game_id, time, news_message) VALUES ' . |
141 | 141 | '(' . $db2->escapeNumber($player->getGameID()) . ', ' . $db2->escapeNumber(TIME) . ', ' . $db2->escapeString($news) . ')'); |
142 | - } |
|
143 | - elseif ($type == 'PEACE') { |
|
142 | + } elseif ($type == 'PEACE') { |
|
144 | 143 | // get 'yes' votes |
145 | 144 | $db2->query('SELECT * FROM player_votes_pact |
146 | 145 | WHERE game_id = '.$db2->escapeNumber($player->getGameID()) . ' |
@@ -126,15 +126,13 @@ discard block |
||
126 | 126 | $this->links['Right'] = $db->getInt('link_right'); |
127 | 127 | } |
128 | 128 | $this->warp = $db->getInt('warp'); |
129 | - } |
|
130 | - else if ($create) { |
|
129 | + } else if ($create) { |
|
131 | 130 | $this->battles = 0; |
132 | 131 | $this->links = array(); |
133 | 132 | $this->warp = 0; |
134 | 133 | $this->isNew = true; |
135 | 134 | return; |
136 | - } |
|
137 | - else { |
|
135 | + } else { |
|
138 | 136 | throw new SectorNotFoundException('No sector ' . $sectorID . ' in game ' . $gameID); |
139 | 137 | } |
140 | 138 | } |
@@ -492,8 +490,7 @@ discard block |
||
492 | 490 | public function toggleLink($dir) { |
493 | 491 | if ($this->hasLink($dir)) { |
494 | 492 | $this->disableLink($dir); |
495 | - } |
|
496 | - else { |
|
493 | + } else { |
|
497 | 494 | $this->enableLink($dir); |
498 | 495 | } |
499 | 496 | } |
@@ -200,8 +200,7 @@ discard block |
||
200 | 200 | $this->newbieWarning = $db->getBoolean('newbie_warning'); |
201 | 201 | $this->nameChanged = $db->getBoolean('name_changed'); |
202 | 202 | $this->combatDronesKamikazeOnMines = $db->getBoolean('combat_drones_kamikaze_on_mines'); |
203 | - } |
|
204 | - else { |
|
203 | + } else { |
|
205 | 204 | throw new PlayerNotFoundException('Invalid accountID: ' . $accountID . ' OR gameID:' . $gameID); |
206 | 205 | } |
207 | 206 | } |
@@ -335,11 +334,9 @@ discard block |
||
335 | 334 | $kickedBy->sendMessage($this->getAccountID(), MSG_PLAYER, 'You were kicked out of the alliance!', false); |
336 | 335 | $this->actionTaken('PlayerKicked', array('Alliance' => $alliance, 'Player' => $kickedBy)); |
337 | 336 | $kickedBy->actionTaken('KickPlayer', array('Alliance' => $alliance, 'Player' => $this)); |
338 | - } |
|
339 | - else if ($this->isAllianceLeader()) { |
|
337 | + } else if ($this->isAllianceLeader()) { |
|
340 | 338 | $this->actionTaken('DisbandAlliance', array('Alliance' => $alliance)); |
341 | - } |
|
342 | - else { |
|
339 | + } else { |
|
343 | 340 | $this->actionTaken('LeaveAlliance', array('Alliance' => $alliance)); |
344 | 341 | if ($alliance->getLeaderID() != 0 && $alliance->getLeaderID() != ACCOUNT_ID_NHL) { |
345 | 342 | $this->sendMessage($alliance->getLeaderID(), MSG_PLAYER, 'I left your alliance!', false); |
@@ -367,7 +364,9 @@ discard block |
||
367 | 364 | try { |
368 | 365 | $this->sendMessage($alliance->getLeaderID(), MSG_PLAYER, 'I joined your alliance!', false); |
369 | 366 | } catch (AccountNotFoundException $e) { |
370 | - if ($alliance->getLeaderID() != ACCOUNT_ID_NHL) throw $e; |
|
367 | + if ($alliance->getLeaderID() != ACCOUNT_ID_NHL) { |
|
368 | + throw $e; |
|
369 | + } |
|
371 | 370 | } |
372 | 371 | |
373 | 372 | $roleID = ALLIANCE_ROLE_NEW_MEMBER; |
@@ -500,7 +499,9 @@ discard block |
||
500 | 499 | |
501 | 500 | public function updateTurns() { |
502 | 501 | // is account validated? |
503 | - if (!$this->getAccount()->isValidated()) return; |
|
502 | + if (!$this->getAccount()->isValidated()) { |
|
503 | + return; |
|
504 | + } |
|
504 | 505 | |
505 | 506 | // how many turns would he get right now? |
506 | 507 | $extraTurns = $this->getTurnsGained(TIME); |
@@ -712,8 +713,7 @@ discard block |
||
712 | 713 | $this->db->query('SELECT * FROM ship_has_name WHERE ' . $this->SQL . ' LIMIT 1'); |
713 | 714 | if ($this->db->nextRecord()) { |
714 | 715 | $this->customShipName = $this->db->getField('ship_name'); |
715 | - } |
|
716 | - else { |
|
716 | + } else { |
|
717 | 717 | $this->customShipName = false; |
718 | 718 | } |
719 | 719 | } |
@@ -731,8 +731,7 @@ discard block |
||
731 | 731 | $this->knowledge['Nyx'] = $this->db->getInt('nyx'); |
732 | 732 | $this->knowledge['Federation'] = 0; |
733 | 733 | $this->knowledge['Underground'] = 0; |
734 | - } |
|
735 | - else { |
|
734 | + } else { |
|
736 | 735 | $this->knowledge['Erebus'] = 0; |
737 | 736 | $this->knowledge['Aether'] = 0; |
738 | 737 | $this->knowledge['Tartarus'] = 0; |
@@ -859,8 +858,7 @@ discard block |
||
859 | 858 | $return['KillerAlign'] = -$relation * $alignChangePerRelation; //Lose relations when killing a peaceful race |
860 | 859 | if ($return['KillerAlign'] > 0) { |
861 | 860 | $killer->increaseAlignment($return['KillerAlign']); |
862 | - } |
|
863 | - else { |
|
861 | + } else { |
|
864 | 862 | $killer->decreaseAlignment(-$return['KillerAlign']); |
865 | 863 | } |
866 | 864 | // War setting gives them military pay |
@@ -894,8 +892,7 @@ discard block |
||
894 | 892 | // If the podded players alignment makes them deputy or member then set bounty |
895 | 893 | if ($this->getAlignment() >= 100) { |
896 | 894 | $return['BountyGained']['Type'] = 'HQ'; |
897 | - } |
|
898 | - else if ($this->getAlignment() <= 100) { |
|
895 | + } else if ($this->getAlignment() <= 100) { |
|
899 | 896 | $return['BountyGained']['Type'] = 'UG'; |
900 | 897 | } |
901 | 898 | |
@@ -917,16 +914,14 @@ discard block |
||
917 | 914 | |
918 | 915 | if ($return['KillerAlign'] > 0) { |
919 | 916 | $killer->increaseHOF($return['KillerAlign'], array('Killing', 'NPC', 'Alignment', 'Gain'), HOF_PUBLIC); |
920 | - } |
|
921 | - else { |
|
917 | + } else { |
|
922 | 918 | $killer->increaseHOF(-$return['KillerAlign'], array('Killing', 'NPC', 'Alignment', 'Loss'), HOF_PUBLIC); |
923 | 919 | } |
924 | 920 | |
925 | 921 | $killer->increaseHOF($return['BountyGained']['Amount'], array('Killing', 'NPC', 'Money', 'Bounty Gained'), HOF_PUBLIC); |
926 | 922 | |
927 | 923 | $killer->increaseHOF(1, array('Killing', 'NPC Kills'), HOF_PUBLIC); |
928 | - } |
|
929 | - else { |
|
924 | + } else { |
|
930 | 925 | $killer->increaseHOF($return['KillerExp'], array('Killing', 'Experience', 'Gained'), HOF_PUBLIC); |
931 | 926 | $killer->increaseHOF($this->getExperience(), array('Killing', 'Experience', 'Of Traders Killed'), HOF_PUBLIC); |
932 | 927 | |
@@ -938,8 +933,7 @@ discard block |
||
938 | 933 | |
939 | 934 | if ($return['KillerAlign'] > 0) { |
940 | 935 | $killer->increaseHOF($return['KillerAlign'], array('Killing', 'Alignment', 'Gain'), HOF_PUBLIC); |
941 | - } |
|
942 | - else { |
|
936 | + } else { |
|
943 | 937 | $killer->increaseHOF(-$return['KillerAlign'], array('Killing', 'Alignment', 'Loss'), HOF_PUBLIC); |
944 | 938 | } |
945 | 939 | |
@@ -947,8 +941,7 @@ discard block |
||
947 | 941 | |
948 | 942 | if ($this->getShip()->getAttackRatingWithMaxCDs() <= MAX_ATTACK_RATING_NEWBIE && $this->hasNewbieStatus() && !$killer->hasNewbieStatus()) { //Newbie kill |
949 | 943 | $killer->increaseHOF(1, array('Killing', 'Newbie Kills'), HOF_PUBLIC); |
950 | - } |
|
951 | - else { |
|
944 | + } else { |
|
952 | 945 | $killer->increaseKills(1); |
953 | 946 | $killer->increaseHOF(1, array('Killing', 'Kills'), HOF_PUBLIC); |
954 | 947 | |
@@ -1133,8 +1126,7 @@ discard block |
||
1133 | 1126 | if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0) { |
1134 | 1127 | $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']) . ')'); |
1135 | 1128 | } |
1136 | - } |
|
1137 | - else { |
|
1129 | + } else { |
|
1138 | 1130 | if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0) { |
1139 | 1131 | $this->db->query('UPDATE bounty |
1140 | 1132 | SET amount=' . $this->db->escapeNumber($bounty['Amount']) . ', |
@@ -1173,15 +1165,13 @@ discard block |
||
1173 | 1165 | $tempTypeList[] = $type; |
1174 | 1166 | if (is_array($hofChanged)) { |
1175 | 1167 | $this->doHOFSave($hofChanged, $tempTypeList); |
1176 | - } |
|
1177 | - else { |
|
1168 | + } else { |
|
1178 | 1169 | $amount = $this->getHOF($tempTypeList); |
1179 | 1170 | if ($hofChanged == self::HOF_NEW) { |
1180 | 1171 | if ($amount > 0) { |
1181 | 1172 | $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) . ')'); |
1182 | 1173 | } |
1183 | - } |
|
1184 | - else if ($hofChanged == self::HOF_CHANGED) { |
|
1174 | + } else if ($hofChanged == self::HOF_CHANGED) { |
|
1185 | 1175 | // if($amount > 0) |
1186 | 1176 | $this->db->query('UPDATE player_hof |
1187 | 1177 | SET amount=' . $this->db->escapeNumber($amount) . ' |
@@ -1292,11 +1282,12 @@ discard block |
||
1292 | 1282 | $this->tickers = array(); |
1293 | 1283 | //get ticker info |
1294 | 1284 | $this->db->query('SELECT type,time,expires,recent FROM player_has_ticker WHERE ' . $this->SQL . ' AND expires > ' . $this->db->escapeNumber(TIME)); |
1295 | - while ($this->db->nextRecord()) |
|
1296 | - $this->tickers[$this->db->getField('type')] = array('Type' => $this->db->getField('type'), |
|
1285 | + while ($this->db->nextRecord()) { |
|
1286 | + $this->tickers[$this->db->getField('type')] = array('Type' => $this->db->getField('type'), |
|
1297 | 1287 | 'Time' => $this->db->getInt('time'), |
1298 | 1288 | 'Expires' => $this->db->getInt('expires'), |
1299 | 1289 | 'Recent' => $this->db->getField('recent')); |
1290 | + } |
|
1300 | 1291 | } |
1301 | 1292 | return $this->tickers; |
1302 | 1293 | } |
@@ -1318,9 +1309,15 @@ discard block |
||
1318 | 1309 | } |
1319 | 1310 | |
1320 | 1311 | public function getTurnsLevel() { |
1321 | - if (!$this->hasTurns()) return 'NONE'; |
|
1322 | - if ($this->getTurns() <= 25) return 'LOW'; |
|
1323 | - if ($this->getTurns() <= 75) return 'MEDIUM'; |
|
1312 | + if (!$this->hasTurns()) { |
|
1313 | + return 'NONE'; |
|
1314 | + } |
|
1315 | + if ($this->getTurns() <= 25) { |
|
1316 | + return 'LOW'; |
|
1317 | + } |
|
1318 | + if ($this->getTurns() <= 75) { |
|
1319 | + return 'MEDIUM'; |
|
1320 | + } |
|
1324 | 1321 | return 'HIGH'; |
1325 | 1322 | } |
1326 | 1323 |
@@ -97,8 +97,9 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | $distanceQ = array(); |
100 | - for ($i = 0; $i <= TURNS_WARP_SECTOR_EQUIVALENCE; $i++) |
|
101 | - $distanceQ[] = array(); |
|
100 | + for ($i = 0; $i <= TURNS_WARP_SECTOR_EQUIVALENCE; $i++) { |
|
101 | + $distanceQ[] = array(); |
|
102 | + } |
|
102 | 103 | //Warps first as a slight optimisation due to how visitedSectors is set. |
103 | 104 | if ($checkSector->hasWarp() === true) { |
104 | 105 | $d = new Distance($gameID, $checkSector->getSectorID()); |
@@ -136,8 +137,7 @@ discard block |
||
136 | 137 | $checkSector = SmrSector::getSector($gameID, $checkSectorID); |
137 | 138 | if ($x == 'Distance') { |
138 | 139 | $distances[$sectorsTravelled][$checkSector->getSectorID()] = $distance; |
139 | - } |
|
140 | - else if (($needsToHaveBeenExploredBy === null || $needsToHaveBeenExploredBy->hasVisitedSector($checkSector->getSectorID())) === true |
|
140 | + } else if (($needsToHaveBeenExploredBy === null || $needsToHaveBeenExploredBy->hasVisitedSector($checkSector->getSectorID())) === true |
|
141 | 141 | && $checkSector->hasX($x, $player) === true) { |
142 | 142 | if ($useFirst === true) { |
143 | 143 | return $distance; |
@@ -22,8 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | if ($alliance_id) { |
24 | 24 | $in_alliance = ($alliance_id == $player->getAllianceID()); |
25 | - } |
|
26 | - else { |
|
25 | + } else { |
|
27 | 26 | $in_alliance = $player->hasAlliance(); |
28 | 27 | } |
29 | 28 | if (!$in_alliance) { |
@@ -36,8 +35,7 @@ discard block |
||
36 | 35 | $mbRead = $db->getBoolean('mb_read'); |
37 | 36 | $modRead = $db->getBoolean('mod_read'); |
38 | 37 | $planetLand = $db->getBoolean('planet_land'); |
39 | - } |
|
40 | - else { |
|
38 | + } else { |
|
41 | 39 | $mbRead = FALSE; |
42 | 40 | $modRead = FALSE; |
43 | 41 | $planetLand = FALSE; |
@@ -366,8 +364,7 @@ discard block |
||
366 | 364 | } |
367 | 365 | } |
368 | 366 | $return .= ('</small></td>'); |
369 | - } |
|
370 | - else { |
|
367 | + } else { |
|
371 | 368 | // if it's not the first entry we have to put |
372 | 369 | // additional empty cell for the spacer |
373 | 370 | //if ($number > 0) |
@@ -153,8 +153,7 @@ discard block |
||
153 | 153 | $this->checkDefenses(); |
154 | 154 | $this->getGoods(); |
155 | 155 | $this->checkForUpgrade(); |
156 | - } |
|
157 | - else { |
|
156 | + } else { |
|
158 | 157 | $this->shields = 0; |
159 | 158 | $this->combatDrones = 0; |
160 | 159 | $this->armour = 0; |
@@ -566,8 +565,7 @@ discard block |
||
566 | 565 | } |
567 | 566 | if (($key = array_search($goodID, $this->goodIDs['Buy'])) !== false) { |
568 | 567 | array_splice($this->goodIDs['Buy'], $key, 1); |
569 | - } |
|
570 | - elseif (($key = array_search($goodID, $this->goodIDs['Sell'])) !== false) { |
|
568 | + } elseif (($key = array_search($goodID, $this->goodIDs['Sell'])) !== false) { |
|
571 | 569 | array_splice($this->goodIDs['Sell'], $key, 1); |
572 | 570 | } |
573 | 571 | |
@@ -649,8 +647,7 @@ discard block |
||
649 | 647 | $newsMessage = '<span class="red bold">*MAYDAY* *MAYDAY*</span> A distress beacon has been activated by the port in sector ' . Globals::getSectorBBLink($this->getSectorID()) . '. It is under attack by '; |
650 | 648 | if ($trigger->hasAlliance()) { |
651 | 649 | $newsMessage .= 'members of ' . $trigger->getAllianceBBLink(); |
652 | - } |
|
653 | - else { |
|
650 | + } else { |
|
654 | 651 | $newsMessage .= $trigger->getBBLink(); |
655 | 652 | } |
656 | 653 | |
@@ -659,8 +656,7 @@ discard block |
||
659 | 656 | |
660 | 657 | if ($trigger->hasAlliance()) { |
661 | 658 | $newsMessage .= 'bounties of <span class="creds">' . $bounty . '</span> credits for the deaths of any raiding members of ' . $trigger->getAllianceBBLink(); |
662 | - } |
|
663 | - else { |
|
659 | + } else { |
|
664 | 660 | $newsMessage .= 'a bounty of <span class="creds">' . $bounty . '</span> credits for the death of ' . $trigger->getBBLink(); |
665 | 661 | } |
666 | 662 | $newsMessage .= ' prior to the destruction of the port, or until federal forces arrive to defend the port.'; |
@@ -1005,8 +1001,9 @@ discard block |
||
1005 | 1001 | if ($transactionType == 'Buy') { |
1006 | 1002 | $relationsEffect = 2 - $relationsEffect; |
1007 | 1003 | return max($idealPrice, IFloor($idealPrice * $relationsEffect)); |
1008 | - } else |
|
1009 | - return min($idealPrice, ICeil($idealPrice * $relationsEffect)); |
|
1004 | + } else { |
|
1005 | + return min($idealPrice, ICeil($idealPrice * $relationsEffect)); |
|
1006 | + } |
|
1010 | 1007 | } |
1011 | 1008 | // $range = .11 - .095; |
1012 | 1009 | // $rand = .095 + $range * mt_rand(0, 32767)/32767; |
@@ -1069,8 +1066,7 @@ discard block |
||
1069 | 1066 | if ($this->getCredits() > 0) { |
1070 | 1067 | $container = create_container('skeleton.php', 'port_payout_processing.php'); |
1071 | 1068 | $container['PayoutType'] = 'Loot'; |
1072 | - } |
|
1073 | - else { |
|
1069 | + } else { |
|
1074 | 1070 | $container = create_container('skeleton.php', 'current_sector.php'); |
1075 | 1071 | $container['msg'] = 'This port has already been looted.'; |
1076 | 1072 | } |
@@ -1141,9 +1137,9 @@ discard block |
||
1141 | 1137 | if ($db->nextRecord()) { |
1142 | 1138 | self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID] = unserialize(gzuncompress($db->getField('port_info'))); |
1143 | 1139 | self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID]->setCachedTime($db->getInt('visited')); |
1140 | + } else { |
|
1141 | + self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID] = false; |
|
1144 | 1142 | } |
1145 | - else |
|
1146 | - self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID] = false; |
|
1147 | 1143 | } |
1148 | 1144 | return self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID]; |
1149 | 1145 | } |
@@ -1189,8 +1185,7 @@ discard block |
||
1189 | 1185 | ', attack_started = ' . $this->db->escapeNumber($this->getAttackStarted()) . |
1190 | 1186 | ', race_id = ' . $this->db->escapeNumber($this->getRaceID()) . ' |
1191 | 1187 | WHERE ' . $this->SQL . ' LIMIT 1'); |
1192 | - } |
|
1193 | - else { |
|
1188 | + } else { |
|
1194 | 1189 | $this->db->query('INSERT INTO port (game_id,sector_id,experience,shields,armour,combat_drones,level,credits,upgrade,reinforce_time,attack_started,race_id) |
1195 | 1190 | values |
1196 | 1191 | (' . $this->db->escapeNumber($this->getGameID()) . |
@@ -1273,8 +1268,7 @@ discard block |
||
1273 | 1268 | $armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour'])); |
1274 | 1269 | } |
1275 | 1270 | } |
1276 | - } |
|
1277 | - else { //hit drones behind shields |
|
1271 | + } else { //hit drones behind shields |
|
1278 | 1272 | $cdDamage = $this->doCDDamage(IFloor(min($damage['MaxDamage'], $damage['Armour']) * DRONES_BEHIND_SHIELDS_DAMAGE_PERCENT)); |
1279 | 1273 | } |
1280 | 1274 | } |
@@ -1370,8 +1364,11 @@ discard block |
||
1370 | 1364 | |
1371 | 1365 | // News Entry |
1372 | 1366 | $news = $this->getDisplayName() . ' has been successfully raided by '; |
1373 | - if ($killer->hasAlliance()) $news .= 'the members of <span class="yellow">' . $killer->getAllianceBBLink() . '</span>'; |
|
1374 | - else $news .= $killer->getBBLink(); |
|
1367 | + if ($killer->hasAlliance()) { |
|
1368 | + $news .= 'the members of <span class="yellow">' . $killer->getAllianceBBLink() . '</span>'; |
|
1369 | + } else { |
|
1370 | + $news .= $killer->getBBLink(); |
|
1371 | + } |
|
1375 | 1372 | $this->db->query('INSERT INTO news (game_id, time, news_message, type,killer_id,killer_alliance,dead_id) VALUES (' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeNumber(TIME) . ', ' . $this->db->escapeString($news) . ', \'REGULAR\',' . $this->db->escapeNumber($killer->getAccountID()) . ',' . $this->db->escapeNumber($killer->getAllianceID()) . ',' . $this->db->escapeNumber(ACCOUNT_ID_PORT) . ')'); |
1376 | 1373 | // Killer gets a relations change and a bounty if port is taken |
1377 | 1374 | $return['KillerBounty'] = $killer->getExperience() * $this->getLevel(); |
@@ -132,8 +132,7 @@ discard block |
||
132 | 132 | return '<div class="buttonA"><a class="buttonA" href="' . SmrSession::getNewHREF($container) . '">Join ' . $alliance->getAllianceDisplayName() . '</a></div>'; |
133 | 133 | break; |
134 | 134 | } |
135 | - } |
|
136 | - catch (Exception $e) { |
|
135 | + } catch (Exception $e) { |
|
137 | 136 | } |
138 | 137 | if ($action == \Nbbc\BBCode::BBCODE_CHECK) { |
139 | 138 | return false; |
@@ -186,8 +185,7 @@ discard block |
||
186 | 185 | if (strpos($message, '[') !== false) { //We have BBCode so let's do a full parse. |
187 | 186 | $message = $bbParser->parse($message); |
188 | 187 | $message = str_replace('<br />', '<br />', $message); |
189 | - } |
|
190 | - else { //Otherwise just convert newlines |
|
188 | + } else { //Otherwise just convert newlines |
|
191 | 189 | $message = nl2br($message, true); |
192 | 190 | } |
193 | 191 | return $message; |
@@ -227,8 +225,7 @@ discard block |
||
227 | 225 | |
228 | 226 | if (!is_array($actions)) { |
229 | 227 | $form['submit'] = '<input class="submit" type="submit" name="action" value="' . htmlspecialchars($actions) . '">'; |
230 | - } |
|
231 | - else { |
|
228 | + } else { |
|
232 | 229 | $form['submit'] = array(); |
233 | 230 | foreach ($actions as $action) { |
234 | 231 | $form['submit'][$action[0]] = '<input class="submit" type="submit" name="action" value="' . htmlspecialchars($action[1]) . '">'; |
@@ -319,8 +316,7 @@ discard block |
||
319 | 316 | } |
320 | 317 | if ($maxValue - $minValue == 0) { |
321 | 318 | return $text; |
322 | - } |
|
323 | - else { |
|
319 | + } else { |
|
324 | 320 | $normalisedValue = round(510 * max(0, min($maxValue, $value) - $minValue) / ($maxValue - $minValue)) - 255; |
325 | 321 | } |
326 | 322 | if ($type == 'Game') { |
@@ -330,28 +326,33 @@ discard block |
||
330 | 326 | if (strlen($g_component) == 1) { |
331 | 327 | $g_component = '0' . $g_component; |
332 | 328 | } |
333 | - } |
|
334 | - else if ($normalisedValue > 0) { |
|
329 | + } else if ($normalisedValue > 0) { |
|
335 | 330 | $g_component = 'ff'; |
336 | 331 | $r_component = dechex(255 - $normalisedValue); |
337 | 332 | if (strlen($r_component) == 1) { |
338 | 333 | $r_component = '0' . $r_component; |
339 | 334 | } |
340 | - } |
|
341 | - else { |
|
335 | + } else { |
|
342 | 336 | $r_component = 'ff'; |
343 | 337 | $g_component = 'ff'; |
344 | 338 | } |
345 | 339 | $colour = $r_component . $g_component . '00'; |
346 | - if ($return_type == 'Colour') return $colour; |
|
340 | + if ($return_type == 'Colour') { |
|
341 | + return $colour; |
|
342 | + } |
|
347 | 343 | return '<span style="color:#' . $colour . '">' . $text . '</span>'; |
348 | - } |
|
349 | - elseif ($type == 'IRC') { |
|
344 | + } elseif ($type == 'IRC') { |
|
350 | 345 | //IRC color codes |
351 | - if ($normalisedValue == 255) $colour = '[k03]'; |
|
352 | - elseif ($normalisedValue == -255) $colour = '[k04]'; |
|
353 | - else $colour = '[k08]'; |
|
354 | - if ($return_type == 'Colour') return $colour; |
|
346 | + if ($normalisedValue == 255) { |
|
347 | + $colour = '[k03]'; |
|
348 | + } elseif ($normalisedValue == -255) { |
|
349 | + $colour = '[k04]'; |
|
350 | + } else { |
|
351 | + $colour = '[k08]'; |
|
352 | + } |
|
353 | + if ($return_type == 'Colour') { |
|
354 | + return $colour; |
|
355 | + } |
|
355 | 356 | return $colour . $text; |
356 | 357 | } |
357 | 358 | } |
@@ -410,10 +411,18 @@ discard block |
||
410 | 411 | // create account object |
411 | 412 | $account = SmrSession::getAccount(); |
412 | 413 | |
413 | - if (!defined('DATE_DATE_SHORT')) define('DATE_DATE_SHORT', $account->getShortDateFormat()); |
|
414 | - if (!defined('DATE_TIME_SHORT')) define('DATE_TIME_SHORT', $account->getShortTimeFormat()); |
|
415 | - if (!defined('DATE_FULL_SHORT')) define('DATE_FULL_SHORT', DATE_DATE_SHORT . ' ' . DATE_TIME_SHORT); |
|
416 | - if (!defined('DATE_FULL_SHORT_SPLIT')) define('DATE_FULL_SHORT_SPLIT', DATE_DATE_SHORT . '\<b\r /\>' . DATE_TIME_SHORT); |
|
414 | + if (!defined('DATE_DATE_SHORT')) { |
|
415 | + define('DATE_DATE_SHORT', $account->getShortDateFormat()); |
|
416 | + } |
|
417 | + if (!defined('DATE_TIME_SHORT')) { |
|
418 | + define('DATE_TIME_SHORT', $account->getShortTimeFormat()); |
|
419 | + } |
|
420 | + if (!defined('DATE_FULL_SHORT')) { |
|
421 | + define('DATE_FULL_SHORT', DATE_DATE_SHORT . ' ' . DATE_TIME_SHORT); |
|
422 | + } |
|
423 | + if (!defined('DATE_FULL_SHORT_SPLIT')) { |
|
424 | + define('DATE_FULL_SHORT_SPLIT', DATE_DATE_SHORT . '\<b\r /\>' . DATE_TIME_SHORT); |
|
425 | + } |
|
417 | 426 | |
418 | 427 | // initialize objects we usually need, like player, ship |
419 | 428 | if (SmrSession::hasGame()) { |
@@ -460,8 +469,9 @@ discard block |
||
460 | 469 | |
461 | 470 | if (!$player->isDead() && $player->getNewbieTurns() <= NEWBIE_TURNS_WARNING_LIMIT && |
462 | 471 | $player->getNewbieWarning() && |
463 | - $var['url'] != 'newbie_warning_processing.php') |
|
464 | - forward(create_container('newbie_warning_processing.php')); |
|
472 | + $var['url'] != 'newbie_warning_processing.php') { |
|
473 | + forward(create_container('newbie_warning_processing.php')); |
|
474 | + } |
|
465 | 475 | } |
466 | 476 | |
467 | 477 | // Initialize the template |
@@ -567,8 +577,7 @@ discard block |
||
567 | 577 | |
568 | 578 | usleep(25000 * $locksInQueue); |
569 | 579 | continue; |
570 | - } |
|
571 | - else { |
|
580 | + } else { |
|
572 | 581 | return true; |
573 | 582 | } |
574 | 583 | } |
@@ -765,7 +774,9 @@ discard block |
||
765 | 774 | $container['player_id'] = $player->getPlayerID(); |
766 | 775 | $template->assign('PlayerNameLink', SmrSession::getNewHREF($container)); |
767 | 776 | |
768 | - if (is_array(Globals::getHiddenPlayers()) && in_array($player->getAccountID(), Globals::getHiddenPlayers())) $template->assign('PlayerInvisible', true); |
|
777 | + if (is_array(Globals::getHiddenPlayers()) && in_array($player->getAccountID(), Globals::getHiddenPlayers())) { |
|
778 | + $template->assign('PlayerInvisible', true); |
|
779 | + } |
|
769 | 780 | |
770 | 781 | // ******* Hardware ******* |
771 | 782 | $container = create_container('skeleton.php', 'configure_hardware.php'); |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | $routes = array(); |
72 | 72 | foreach ($distances as $currentSectorId => $d) { |
73 | 73 | $raceID = $sectors[$currentSectorId]->getPort()->getRaceID(); |
74 | - if (isset($races[$raceID])===false) { |
|
75 | - echo 'Error with Race ID: '.$sectors[$currentSectorId]->getPort()->getRaceID(); |
|
74 | + if (isset($races[$raceID]) === false) { |
|
75 | + echo 'Error with Race ID: ' . $sectors[$currentSectorId]->getPort()->getRaceID(); |
|
76 | 76 | continue; |
77 | 77 | } |
78 | - if($races[$raceID]===false) { |
|
78 | + if ($races[$raceID] === false) { |
|
79 | 79 | continue; |
80 | 80 | } |
81 | 81 | $rl = array(); |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | if (!$races[$sectors[$targetSectorId]->getPort()->getRaceID()]) { |
84 | 84 | continue; |
85 | 85 | } |
86 | - if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) { |
|
86 | + if ($routesForPort !== -1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) { |
|
87 | 87 | continue; |
88 | 88 | } |
89 | 89 | |
90 | - if ($goods[GOOD_NOTHING]===true) { |
|
90 | + if ($goods[GOOD_NOTHING] === true) { |
|
91 | 91 | $rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $raceID, $sectors[$targetSectorId]->getPort()->getRaceID(), 0, 0, $distance, GOOD_NOTHING); |
92 | 92 | } |
93 | 93 | |
94 | 94 | foreach (\Globals::getGoods() as $goodId => $value) { |
95 | - if ($goods[$goodId]===true) { |
|
95 | + if ($goods[$goodId] === true) { |
|
96 | 96 | if ($sectors[$currentSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_SELLS && |
97 | 97 | $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
98 | 98 | $rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $raceID, $sectors[$targetSectorId]->getPort()->getRaceID(), $sectors[$currentSectorId]->getPort()->getGoodDistance($goodId), $sectors[$targetSectorId]->getPort()->getGoodDistance($goodId), $distance, $goodId); |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | public static function generateOneWayRoutes(array $sectors, array $distances, array $goods, array $races, int $routesForPort) : array { |
109 | 109 | self::initialize(); |
110 | 110 | foreach ($distances as $currentSectorId => $d) { |
111 | - if ($races[$sectors[$currentSectorId]->getPort()->getRaceID()]===false) { |
|
111 | + if ($races[$sectors[$currentSectorId]->getPort()->getRaceID()] === false) { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | foreach ($d as $targetSectorId => $distance) { |
115 | - if ($races[$sectors[$targetSectorId]->getPort()->getRaceID()]===false) { |
|
115 | + if ($races[$sectors[$targetSectorId]->getPort()->getRaceID()] === false) { |
|
116 | 116 | continue; |
117 | 117 | } |
118 | - if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) { |
|
118 | + if ($routesForPort !== -1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) { |
|
119 | 119 | continue; |
120 | 120 | } |
121 | 121 | |
122 | 122 | foreach (\Globals::getGoods() as $goodId => $value) { |
123 | - if ($goods[$goodId]===true) { |
|
123 | + if ($goods[$goodId] === true) { |
|
124 | 124 | if ($sectors[$currentSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_SELLS && |
125 | 125 | $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
126 | 126 | $owr = new OneWayRoute($currentSectorId, $targetSectorId, $sectors[$currentSectorId]->getPort()->getRaceID(), $sectors[$targetSectorId]->getPort()->getRaceID(), $sectors[$currentSectorId]->getPort()->getGoodDistance($goodId), $sectors[$targetSectorId]->getPort()->getGoodDistance($goodId), $distance, $goodId); |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | $i = 0; |
167 | 167 | krsort(self::$expRoutes, SORT_NUMERIC); |
168 | 168 | foreach (self::$expRoutes as $multi => $routesByMulti) { |
169 | - if(count($routesByMulti)+$i < $trimToBestXRoutes) { |
|
169 | + if (count($routesByMulti) + $i < $trimToBestXRoutes) { |
|
170 | 170 | $i += count($routesByMulti); |
171 | 171 | } |
172 | - else if($i > $trimToBestXRoutes) { |
|
172 | + else if ($i > $trimToBestXRoutes) { |
|
173 | 173 | unset(self::$expRoutes[$multi]); |
174 | 174 | } |
175 | 175 | else { |
176 | - foreach($routesByMulti as $key => $value) { |
|
176 | + foreach ($routesByMulti as $key => $value) { |
|
177 | 177 | $i++; |
178 | - if($i < $trimToBestXRoutes) { |
|
178 | + if ($i < $trimToBestXRoutes) { |
|
179 | 179 | continue; |
180 | 180 | } |
181 | - if($i === $trimToBestXRoutes) { |
|
181 | + if ($i === $trimToBestXRoutes) { |
|
182 | 182 | self::$dontAddWorseThan[self::EXP_ROUTE] = $multi; |
183 | 183 | continue; |
184 | 184 | } |
@@ -190,20 +190,20 @@ discard block |
||
190 | 190 | $i = 0; |
191 | 191 | krsort(self::$moneyRoutes, SORT_NUMERIC); |
192 | 192 | foreach (self::$moneyRoutes as $multi => $routesByMulti) { |
193 | - if(count($routesByMulti)+$i < $trimToBestXRoutes) { |
|
193 | + if (count($routesByMulti) + $i < $trimToBestXRoutes) { |
|
194 | 194 | $i += count($routesByMulti); |
195 | 195 | } |
196 | - else if($i > $trimToBestXRoutes) { |
|
196 | + else if ($i > $trimToBestXRoutes) { |
|
197 | 197 | unset(self::$moneyRoutes[$multi]); |
198 | 198 | continue; |
199 | 199 | } |
200 | 200 | else { |
201 | - foreach($routesByMulti as $key => $value) { |
|
201 | + foreach ($routesByMulti as $key => $value) { |
|
202 | 202 | $i++; |
203 | - if($i < $trimToBestXRoutes) { |
|
203 | + if ($i < $trimToBestXRoutes) { |
|
204 | 204 | continue; |
205 | 205 | } |
206 | - if($i === $trimToBestXRoutes) { |
|
206 | + if ($i === $trimToBestXRoutes) { |
|
207 | 207 | self::$dontAddWorseThan[self::MONEY_ROUTE] = $multi; |
208 | 208 | continue; |
209 | 209 | } |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | $mpr = new MultiplePortRoute($routeToContinue, $currentStepRoute); |
59 | 59 | self::addExpRoute($mpr); |
60 | 60 | self::addMoneyRoute($mpr); |
61 | - } |
|
62 | - else if ($maxNumPorts > 1 && !$routeToContinue->containsPort($currentStepBuySector)) { |
|
61 | + } else if ($maxNumPorts > 1 && !$routeToContinue->containsPort($currentStepBuySector)) { |
|
63 | 62 | $mpr = new MultiplePortRoute($routeToContinue, $currentStepRoute); |
64 | 63 | self::getContinueRoutes($maxNumPorts - 1, $startSectorId, $mpr, $routeLists[$currentStepBuySector], $routeLists, $lastGoodIsNothing); |
65 | 64 | } |
@@ -168,11 +167,9 @@ discard block |
||
168 | 167 | foreach (self::$expRoutes as $multi => $routesByMulti) { |
169 | 168 | if(count($routesByMulti)+$i < $trimToBestXRoutes) { |
170 | 169 | $i += count($routesByMulti); |
171 | - } |
|
172 | - else if($i > $trimToBestXRoutes) { |
|
170 | + } else if($i > $trimToBestXRoutes) { |
|
173 | 171 | unset(self::$expRoutes[$multi]); |
174 | - } |
|
175 | - else { |
|
172 | + } else { |
|
176 | 173 | foreach($routesByMulti as $key => $value) { |
177 | 174 | $i++; |
178 | 175 | if($i < $trimToBestXRoutes) { |
@@ -192,12 +189,10 @@ discard block |
||
192 | 189 | foreach (self::$moneyRoutes as $multi => $routesByMulti) { |
193 | 190 | if(count($routesByMulti)+$i < $trimToBestXRoutes) { |
194 | 191 | $i += count($routesByMulti); |
195 | - } |
|
196 | - else if($i > $trimToBestXRoutes) { |
|
192 | + } else if($i > $trimToBestXRoutes) { |
|
197 | 193 | unset(self::$moneyRoutes[$multi]); |
198 | 194 | continue; |
199 | - } |
|
200 | - else { |
|
195 | + } else { |
|
201 | 196 | foreach($routesByMulti as $key => $value) { |
202 | 197 | $i++; |
203 | 198 | if($i < $trimToBestXRoutes) { |
@@ -62,8 +62,9 @@ discard block |
||
62 | 62 | // get all id's and build array |
63 | 63 | $album_ids = array(); |
64 | 64 | |
65 | - while ($db->nextRecord()) |
|
66 | - $album_ids[] = $db->getInt('album_id'); |
|
65 | + while ($db->nextRecord()) { |
|
66 | + $album_ids[] = $db->getInt('album_id'); |
|
67 | + } |
|
67 | 68 | |
68 | 69 | // double check if we have id's |
69 | 70 | if (count($album_ids) > 0) { |
@@ -73,8 +74,7 @@ discard block |
||
73 | 74 | } |
74 | 75 | } |
75 | 76 | |
76 | - } |
|
77 | - elseif ($db->getNumRows() == 1) { |
|
77 | + } elseif ($db->getNumRows() == 1) { |
|
78 | 78 | if ($db->nextRecord()) { |
79 | 79 | album_entry($db->getInt('album_id')); |
80 | 80 | } else { |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | } else { |
87 | 87 | main_page(); |
88 | 88 | } |
89 | -} |
|
90 | -catch (Throwable $e) { |
|
89 | +} catch (Throwable $e) { |
|
91 | 90 | handleException($e); |
92 | 91 | } |
93 | 92 | ?> |