We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | WHERE album_id = '.$db->escapeNumber($account_id) . ' AND |
| 52 | 52 | comment_id IN ('.$db->escapeArray($comment_ids) . ')'); |
| 53 | 53 | } |
| 54 | -} |
|
| 55 | -else { |
|
| 54 | +} else { |
|
| 56 | 55 | create_error('No action chosen!'); |
| 57 | 56 | } |
| 58 | 57 | |
@@ -89,12 +89,10 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | try { |
| 91 | 91 | changeNPCLogin(); |
| 92 | - } |
|
| 93 | - catch (ForwardException $e) {} |
|
| 92 | + } catch (ForwardException $e) {} |
|
| 94 | 93 | |
| 95 | 94 | NPCStuff(); |
| 96 | -} |
|
| 97 | -catch (Throwable $e) { |
|
| 95 | +} catch (Throwable $e) { |
|
| 98 | 96 | logException($e); |
| 99 | 97 | // Try to shut down cleanly |
| 100 | 98 | exitNPC(); |
@@ -157,8 +155,7 @@ discard block |
||
| 157 | 155 | $fedContainer = null; |
| 158 | 156 | if ($var['url'] == 'shop_ship_processing.php' && ($fedContainer = plotToFed($player, true)) !== true) { //We just bought a ship, we should head back to our trade gal/uno - we use HQ for now as it's both in our gal and a UNO, plus it's safe which is always a bonus |
| 159 | 157 | processContainer($fedContainer); |
| 160 | - } |
|
| 161 | - else if ($player->getShip()->isUnderAttack() === true |
|
| 158 | + } else if ($player->getShip()->isUnderAttack() === true |
|
| 162 | 159 | &&($player->hasPlottedCourse() === false || $player->getPlottedCourse()->getEndSector()->offersFederalProtection() === false) |
| 163 | 160 | &&($fedContainer == null ? $fedContainer = plotToFed($player, true) : $fedContainer) !== true) { //We're under attack and need to plot course to fed. |
| 164 | 161 | // Get the lock, remove under attack and update. |
@@ -171,20 +168,16 @@ discard block |
||
| 171 | 168 | debug('Under Attack'); |
| 172 | 169 | $underAttack = true; |
| 173 | 170 | processContainer($fedContainer); |
| 174 | - } |
|
| 175 | - else if ($player->hasPlottedCourse() === true && $player->getPlottedCourse()->getEndSector()->offersFederalProtection()) { //We have a route to fed to follow, figure it's probably a damned sensible thing to follow. |
|
| 171 | + } else if ($player->hasPlottedCourse() === true && $player->getPlottedCourse()->getEndSector()->offersFederalProtection()) { //We have a route to fed to follow, figure it's probably a damned sensible thing to follow. |
|
| 176 | 172 | debug('Follow Course: ' . $player->getPlottedCourse()->getNextOnPath()); |
| 177 | 173 | processContainer(moveToSector($player, $player->getPlottedCourse()->getNextOnPath())); |
| 178 | - } |
|
| 179 | - else if (($container = canWeUNO($player, true)) !== false) { //We have money and are at a uno, let's uno! |
|
| 174 | + } else if (($container = canWeUNO($player, true)) !== false) { //We have money and are at a uno, let's uno! |
|
| 180 | 175 | debug('We\'re UNOing'); |
| 181 | 176 | processContainer($container); |
| 182 | - } |
|
| 183 | - else if ($player->hasPlottedCourse() === true) { //We have a route to follow, figure it's probably a sensible thing to follow. |
|
| 177 | + } else if ($player->hasPlottedCourse() === true) { //We have a route to follow, figure it's probably a sensible thing to follow. |
|
| 184 | 178 | debug('Follow Course: ' . $player->getPlottedCourse()->getNextOnPath()); |
| 185 | 179 | processContainer(moveToSector($player, $player->getPlottedCourse()->getNextOnPath())); |
| 186 | - } |
|
| 187 | - else if ($player->getTurns() < NPC_LOW_TURNS || ($player->getTurns() < $player->getMaxTurns() / 2 && $player->getNewbieTurns() < NPC_LOW_NEWBIE_TURNS) || $underAttack) { //We're low on turns or have been under attack and need to plot course to fed |
|
| 180 | + } else if ($player->getTurns() < NPC_LOW_TURNS || ($player->getTurns() < $player->getMaxTurns() / 2 && $player->getNewbieTurns() < NPC_LOW_NEWBIE_TURNS) || $underAttack) { //We're low on turns or have been under attack and need to plot course to fed |
|
| 188 | 181 | if ($player->getTurns() < NPC_LOW_TURNS) { |
| 189 | 182 | debug('Low Turns:' . $player->getTurns()); |
| 190 | 183 | } |
@@ -201,16 +194,13 @@ discard block |
||
| 201 | 194 | } |
| 202 | 195 | $ship = $player->getShip(); |
| 203 | 196 | processContainer(plotToFed($player, !$ship->hasMaxShields() || !$ship->hasMaxArmour() || !$ship->hasMaxCargoHolds())); |
| 204 | - } |
|
| 205 | - else if (($container = checkForShipUpgrade($player)) !== false) { //We have money and are at a uno, let's uno! |
|
| 197 | + } else if (($container = checkForShipUpgrade($player)) !== false) { //We have money and are at a uno, let's uno! |
|
| 206 | 198 | debug('We\'re reshipping!'); |
| 207 | 199 | processContainer($container); |
| 208 | - } |
|
| 209 | - else if (($container = canWeUNO($player, false)) !== false) { //We need to UNO and have enough money to do it properly so let's do it sooner rather than later. |
|
| 200 | + } else if (($container = canWeUNO($player, false)) !== false) { //We need to UNO and have enough money to do it properly so let's do it sooner rather than later. |
|
| 210 | 201 | debug('We need to UNO, so off we go!'); |
| 211 | 202 | processContainer($container); |
| 212 | - } |
|
| 213 | - else if ($TRADE_ROUTE instanceof \Routes\Route) { |
|
| 203 | + } else if ($TRADE_ROUTE instanceof \Routes\Route) { |
|
| 214 | 204 | debug('Trade Route'); |
| 215 | 205 | $forwardRoute = $TRADE_ROUTE->getForwardRoute(); |
| 216 | 206 | $returnRoute = $TRADE_ROUTE->getReturnRoute(); |
@@ -218,8 +208,7 @@ discard block |
||
| 218 | 208 | if ($forwardRoute->getBuySectorId() == $player->getSectorID()) { |
| 219 | 209 | $buyRoute = $forwardRoute; |
| 220 | 210 | $sellRoute = $returnRoute; |
| 221 | - } |
|
| 222 | - else if ($returnRoute->getBuySectorId() == $player->getSectorID()) { |
|
| 211 | + } else if ($returnRoute->getBuySectorId() == $player->getSectorID()) { |
|
| 223 | 212 | $buyRoute = $returnRoute; |
| 224 | 213 | $sellRoute = $forwardRoute; |
| 225 | 214 | } |
@@ -236,30 +225,25 @@ discard block |
||
| 236 | 225 | //Sell goods |
| 237 | 226 | debug('Sell Goods'); |
| 238 | 227 | processContainer(tradeGoods($goodID, $player, $port)); |
| 239 | - } |
|
| 240 | - else { |
|
| 228 | + } else { |
|
| 241 | 229 | //Move to next route or fed. |
| 242 | 230 | if (($TRADE_ROUTE =& changeRoute($TRADE_ROUTES)) === false) { |
| 243 | 231 | debug('Changing Route Failed'); |
| 244 | 232 | processContainer(plotToFed($player)); |
| 245 | - } |
|
| 246 | - else { |
|
| 233 | + } else { |
|
| 247 | 234 | debug('Route Changed'); |
| 248 | 235 | continue; |
| 249 | 236 | } |
| 250 | 237 | } |
| 251 | - } |
|
| 252 | - else if ($ship->hasCargo($buyRoute->getGoodID()) === true) { //We've bought goods, plot to sell |
|
| 238 | + } else if ($ship->hasCargo($buyRoute->getGoodID()) === true) { //We've bought goods, plot to sell |
|
| 253 | 239 | debug('Plot To Sell: ' . $buyRoute->getSellSectorId()); |
| 254 | 240 | processContainer(plotToSector($player, $buyRoute->getSellSectorId())); |
| 255 | - } |
|
| 256 | - else { |
|
| 241 | + } else { |
|
| 257 | 242 | //Dump goods |
| 258 | 243 | debug('Dump Goods'); |
| 259 | 244 | processContainer(dumpCargo($player)); |
| 260 | 245 | } |
| 261 | - } |
|
| 262 | - else { //Buy goods |
|
| 246 | + } else { //Buy goods |
|
| 263 | 247 | $goodID = $buyRoute->getGoodID(); |
| 264 | 248 | |
| 265 | 249 | $port = $player->getSector()->getPort(); |
@@ -268,26 +252,22 @@ discard block |
||
| 268 | 252 | if ($tradeable === true && $port->getGoodAmount($goodID) >= $ship->getEmptyHolds()) { //Buy goods |
| 269 | 253 | debug('Buy Goods'); |
| 270 | 254 | processContainer(tradeGoods($goodID, $player, $port)); |
| 271 | - } |
|
| 272 | - else { |
|
| 255 | + } else { |
|
| 273 | 256 | //Move to next route or fed. |
| 274 | 257 | if (($TRADE_ROUTE =& changeRoute($TRADE_ROUTES)) === false) { |
| 275 | 258 | debug('Changing Route Failed'); |
| 276 | 259 | processContainer(plotToFed($player)); |
| 277 | - } |
|
| 278 | - else { |
|
| 260 | + } else { |
|
| 279 | 261 | debug('Route Changed'); |
| 280 | 262 | continue; |
| 281 | 263 | } |
| 282 | 264 | } |
| 283 | 265 | } |
| 284 | - } |
|
| 285 | - else { |
|
| 266 | + } else { |
|
| 286 | 267 | debug('Plot To Buy: ' . $forwardRoute->getBuySectorId()); |
| 287 | 268 | processContainer(plotToSector($player, $forwardRoute->getBuySectorId())); |
| 288 | 269 | } |
| 289 | - } |
|
| 290 | - else { //Something weird is going on.. Let's fed and wait. |
|
| 270 | + } else { //Something weird is going on.. Let's fed and wait. |
|
| 291 | 271 | debug('No actual action? Wtf?'); |
| 292 | 272 | processContainer(plotToFed($player)); |
| 293 | 273 | } |
@@ -299,8 +279,7 @@ discard block |
||
| 299 | 279 | processContainer(moveToSector($player,$moveTo)); |
| 300 | 280 | } |
| 301 | 281 | */ |
| 302 | - } |
|
| 303 | - catch (ForwardException $e) { |
|
| 282 | + } catch (ForwardException $e) { |
|
| 304 | 283 | global $lock; |
| 305 | 284 | if ($lock) { //only save if we have the lock. |
| 306 | 285 | SmrSector::saveSectors(); |
@@ -469,8 +448,7 @@ discard block |
||
| 469 | 448 | $hardwareSold = $location->getHardwareSold(); |
| 470 | 449 | if ($player->getNewbieTurns() > MIN_NEWBIE_TURNS_TO_BUY_CARGO && !$ship->hasMaxCargoHolds() && isset($hardwareSold[HARDWARE_CARGO]) && ($amount = floor(($player->getCredits() - MINUMUM_RESERVE_CREDITS) / Globals::getHardwareCost(HARDWARE_CARGO))) > 0) { // Buy cargo holds first if we have plenty of newbie turns left. |
| 471 | 450 | $hardwareID = HARDWARE_CARGO; |
| 472 | - } |
|
| 473 | - else { |
|
| 451 | + } else { |
|
| 474 | 452 | foreach ($hardwareArray as $hardwareArrayID) { |
| 475 | 453 | if (!$ship->hasMaxHardware($hardwareArrayID) && isset($hardwareSold[$hardwareArrayID]) && ($amount = floor(($player->getCredits() - MINUMUM_RESERVE_CREDITS) / Globals::getHardwareCost($hardwareArrayID))) > 0) { |
| 476 | 454 | $hardwareID = $hardwareArrayID; |
@@ -579,8 +557,10 @@ discard block |
||
| 579 | 557 | |
| 580 | 558 | function checkForShipUpgrade(AbstractSmrPlayer $player) { |
| 581 | 559 | foreach (SHIP_UPGRADE_PATH[$player->getRaceID()] as $upgradeShipID) { |
| 582 | - if ($player->getShipTypeID() == $upgradeShipID) //We can't upgrade, only downgrade. |
|
| 560 | + if ($player->getShipTypeID() == $upgradeShipID) { |
|
| 561 | + //We can't upgrade, only downgrade. |
|
| 583 | 562 | return false; |
| 563 | + } |
|
| 584 | 564 | $cost = $player->getShip()->getCostToUpgrade($upgradeShipID); |
| 585 | 565 | if ($cost <= 0 || $player->getCredits() - $cost > MINUMUM_RESERVE_CREDITS) { |
| 586 | 566 | return doShipUpgrade($player, $upgradeShipID); |
@@ -649,8 +629,7 @@ discard block |
||
| 649 | 629 | $routes = unserialize(gzuncompress($db->getField('routes'))); |
| 650 | 630 | debug('Using Cached Routes: #' . count($routes)); |
| 651 | 631 | return $routes; |
| 652 | - } |
|
| 653 | - else { |
|
| 632 | + } else { |
|
| 654 | 633 | debug('Generating Routes'); |
| 655 | 634 | $allSectors = array(); |
| 656 | 635 | foreach (SmrGalaxy::getGameGalaxies($player->getGameID()) as $galaxy) { |
@@ -123,7 +123,9 @@ |
||
| 123 | 123 | if ($sd[3] == $channel) { |
| 124 | 124 | |
| 125 | 125 | $seconds_since_refresh = time() - $sd[2]; |
| 126 | - if ($seconds_since_refresh < 0) $seconds_since_refresh = 0; |
|
| 126 | + if ($seconds_since_refresh < 0) { |
|
| 127 | + $seconds_since_refresh = 0; |
|
| 128 | + } |
|
| 127 | 129 | $amt_to_add = floor($seconds_since_refresh * $refresh_per_sec); |
| 128 | 130 | |
| 129 | 131 | if ($sd[1] + $amt_to_add > 4000) { |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | // get smr player |
| 48 | 48 | try { |
| 49 | 49 | $player = SmrPlayer::getPlayer($account->getAccountID(), $alliance->getGameId(), true); |
| 50 | - } |
|
| 51 | - catch (PlayerNotFoundException $e) { |
|
| 50 | + } catch (PlayerNotFoundException $e) { |
|
| 52 | 51 | if ($validationMessages === true) { |
| 53 | 52 | fputs($fp, 'PRIVMSG ' . $channel . ' :' . $nick . ', you have not joined the game that this channel belongs to.' . EOL); |
| 54 | 53 | } |
@@ -379,8 +378,9 @@ discard block |
||
| 379 | 378 | if ($topic == 'seen') { |
| 380 | 379 | fputs($fp, 'NOTICE ' . $nick . ' :Syntax !seen <nickname>' . EOL); |
| 381 | 380 | fputs($fp, 'NOTICE ' . $nick . ' : Displays the last time <nickname> was seen' . EOL); |
| 382 | - } else |
|
| 383 | - fputs($fp, 'NOTICE ' . $nick . ' :There is no help available for this command! Try !help' . EOL); |
|
| 381 | + } else { |
|
| 382 | + fputs($fp, 'NOTICE ' . $nick . ' :There is no help available for this command! Try !help' . EOL); |
|
| 383 | + } |
|
| 384 | 384 | |
| 385 | 385 | // if ($topic == 'login') |
| 386 | 386 | // fputs($fp, 'NOTICE '.$nick.' :No help available yet! Ask MrSpock!'.EOL); |
@@ -6,12 +6,13 @@ discard block |
||
| 6 | 6 | function echo_r($message) |
| 7 | 7 | { |
| 8 | 8 | if (is_array($message)) { |
| 9 | - foreach ($message as $msg) |
|
| 10 | - echo_r($msg); |
|
| 9 | + foreach ($message as $msg) { |
|
| 10 | + echo_r($msg); |
|
| 11 | + } |
|
| 12 | + } else { |
|
| 13 | + echo date("d.m.Y H:i:s => ") . $message . EOL; |
|
| 14 | + } |
|
| 11 | 15 | } |
| 12 | - else |
|
| 13 | - echo date("d.m.Y H:i:s => ") . $message . EOL; |
|
| 14 | -} |
|
| 15 | 16 | |
| 16 | 17 | // not keeping the filehandle might not be the wisest idea. |
| 17 | 18 | function write_log_message($msg) |
@@ -144,8 +145,7 @@ discard block |
||
| 144 | 145 | sleep(60); |
| 145 | 146 | |
| 146 | 147 | } |
| 147 | - } |
|
| 148 | - catch (TimeoutException $e) { |
|
| 148 | + } catch (TimeoutException $e) { |
|
| 149 | 149 | // Ignore the timeout exception, we'll loop round and reconnect. |
| 150 | 150 | } |
| 151 | 151 | } // end of while running |