We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -4,7 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | $fn_forces = function ($message, $params) { |
| 6 | 6 | $link = new GameLink($message->channel, $message->author); |
| 7 | - if (!$link->valid) return; |
|
| 7 | + if (!$link->valid) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 8 | 10 | |
| 9 | 11 | // print the next expiring forces |
| 10 | 12 | $option = isset($params[0]) ? $params[0] : null; |
@@ -6,7 +6,9 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | $fn_op = function ($message) { |
| 8 | 8 | $link = new GameLink($message->channel, $message->author); |
| 9 | - if (!$link->valid) return; |
|
| 9 | + if (!$link->valid) { |
|
| 10 | + return; |
|
| 11 | + } |
|
| 10 | 12 | $player = $link->player; |
| 11 | 13 | |
| 12 | 14 | // print info about the next op |
@@ -16,7 +18,9 @@ discard block |
||
| 16 | 18 | |
| 17 | 19 | $fn_op_list = function ($message) { |
| 18 | 20 | $link = new GameLink($message->channel, $message->author); |
| 19 | - if (!$link->valid) return; |
|
| 21 | + if (!$link->valid) { |
|
| 22 | + return; |
|
| 23 | + } |
|
| 20 | 24 | $player = $link->player; |
| 21 | 25 | |
| 22 | 26 | // print list of attendees |
@@ -26,7 +30,9 @@ discard block |
||
| 26 | 30 | |
| 27 | 31 | $fn_op_turns = function ($message) { |
| 28 | 32 | $link = new GameLink($message->channel, $message->author); |
| 29 | - if (!$link->valid) return; |
|
| 33 | + if (!$link->valid) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 30 | 36 | $player = $link->player; |
| 31 | 37 | |
| 32 | 38 | // print list of attendees |
@@ -4,7 +4,9 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | $fn_seedlist = function ($message) { |
| 6 | 6 | $link = new GameLink($message->channel, $message->author); |
| 7 | - if (!$link->valid) return; |
|
| 7 | + if (!$link->valid) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 8 | 10 | |
| 9 | 11 | // print the entire seedlist |
| 10 | 12 | $results = shared_channel_msg_seedlist($link->player); |
@@ -13,7 +15,9 @@ discard block |
||
| 13 | 15 | |
| 14 | 16 | $fn_seedlist_add = function ($message, $sectors) { |
| 15 | 17 | $link = new GameLink($message->channel, $message->author); |
| 16 | - if (!$link->valid) return; |
|
| 18 | + if (!$link->valid) { |
|
| 19 | + return; |
|
| 20 | + } |
|
| 17 | 21 | |
| 18 | 22 | // add sectors to the seedlist |
| 19 | 23 | $results = shared_channel_msg_seedlist_add($link->player, $sectors); |
@@ -22,7 +26,9 @@ discard block |
||
| 22 | 26 | |
| 23 | 27 | $fn_seedlist_del = function ($message, $sectors) { |
| 24 | 28 | $link = new GameLink($message->channel, $message->author); |
| 25 | - if (!$link->valid) return; |
|
| 29 | + if (!$link->valid) { |
|
| 30 | + return; |
|
| 31 | + } |
|
| 26 | 32 | |
| 27 | 33 | // delete sectors from the seedlist |
| 28 | 34 | $results = shared_channel_msg_seedlist_del($link->player, $sectors); |
@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | $fn_turns = function ($message) { |
| 19 | 19 | $link = new GameLink($message->channel, $message->author); |
| 20 | - if (!$link->valid) return; |
|
| 20 | + if (!$link->valid) { |
|
| 21 | + return; |
|
| 22 | + } |
|
| 21 | 23 | |
| 22 | 24 | $msg = get_turns_message($link->player); |
| 23 | 25 | $message->channel->sendMessage($msg); |
@@ -25,7 +27,9 @@ discard block |
||
| 25 | 27 | |
| 26 | 28 | $fn_turns_all = function ($message) { |
| 27 | 29 | $link = new GameLink($message->channel, $message->author); |
| 28 | - if (!$link->valid) return; |
|
| 30 | + if (!$link->valid) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 29 | 33 | $player = $link->player; |
| 30 | 34 | |
| 31 | 35 | $results = array_map('get_turns_message', $player->getSharingPlayers(true)); |
@@ -4,7 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | $fn_money = function ($message) { |
| 6 | 6 | $link = new GameLink($message->channel, $message->author); |
| 7 | - if (!$link->valid) return; |
|
| 7 | + if (!$link->valid) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 8 | 10 | |
| 9 | 11 | $result = shared_channel_msg_money($link->player); |
| 10 | 12 | if ($result) { |
@@ -15,8 +15,7 @@ discard block |
||
| 15 | 15 | ) |
| 16 | 16 | ORDER BY expire_time ASC LIMIT 1' |
| 17 | 17 | ); |
| 18 | - } |
|
| 19 | - else if ($option == "seedlist") { |
|
| 18 | + } else if ($option == "seedlist") { |
|
| 20 | 19 | // are we restricting to the seedlist? |
| 21 | 20 | $seedlist = get_seedlist($player); |
| 22 | 21 | if (count($seedlist) == 0) { |
@@ -33,8 +32,7 @@ discard block |
||
| 33 | 32 | ) |
| 34 | 33 | ORDER BY expire_time ASC LIMIT 1' |
| 35 | 34 | ); |
| 36 | - } |
|
| 37 | - else { |
|
| 35 | + } else { |
|
| 38 | 36 | // did we get a galaxy name? |
| 39 | 37 | $db->query('SELECT galaxy_id FROM game_galaxy WHERE galaxy_name = ' . $db->escapeString($option)); |
| 40 | 38 | if ($db->nextRecord()) { |
@@ -101,12 +101,10 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | try { |
| 103 | 103 | changeNPCLogin(); |
| 104 | - } |
|
| 105 | - catch(ForwardException $e) {} |
|
| 104 | + } catch(ForwardException $e) {} |
|
| 106 | 105 | |
| 107 | 106 | NPCStuff(); |
| 108 | -} |
|
| 109 | -catch(Throwable $e) { |
|
| 107 | +} catch(Throwable $e) { |
|
| 110 | 108 | logException($e); |
| 111 | 109 | // Try to shut down cleanly |
| 112 | 110 | exitNPC(); |
@@ -137,15 +135,15 @@ discard block |
||
| 137 | 135 | // dirty hack so we can revisit the init block here on next iteration |
| 138 | 136 | $actions--; |
| 139 | 137 | |
| 140 | - if($player->hasAlliance()) |
|
| 141 | - processContainer(leaveAlliance()); |
|
| 138 | + if($player->hasAlliance()) { |
|
| 139 | + processContainer(leaveAlliance()); |
|
| 140 | + } |
|
| 142 | 141 | |
| 143 | 142 | // figure out if the selected alliance already exist |
| 144 | 143 | $db->query('SELECT alliance_id FROM alliance WHERE alliance_name='.$db->escapeString($NPC_LOGIN['AllianceName']).' AND game_id='.$db->escapeNumber(SmrSession::getGameID())); |
| 145 | 144 | if ($db->nextRecord()) { |
| 146 | 145 | processContainer(joinAlliance($db->getField('alliance_id'),'*--NPCS--*')); |
| 147 | - } |
|
| 148 | - else { |
|
| 146 | + } else { |
|
| 149 | 147 | processContainer(createAlliance($NPC_LOGIN['AllianceName'],'*--NPCS--*')); |
| 150 | 148 | } |
| 151 | 149 | } |
@@ -173,8 +171,7 @@ discard block |
||
| 173 | 171 | $fedContainer = null; |
| 174 | 172 | 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 |
| 175 | 173 | processContainer($fedContainer); |
| 176 | - } |
|
| 177 | - else if($player->getShip()->isUnderAttack()===true |
|
| 174 | + } else if($player->getShip()->isUnderAttack()===true |
|
| 178 | 175 | &&($player->hasPlottedCourse()===false||$player->getPlottedCourse()->getEndSector()->offersFederalProtection()===false) |
| 179 | 176 | &&($fedContainer==null?$fedContainer = plotToFed($player,true):$fedContainer)!==true) { //We're under attack and need to plot course to fed. |
| 180 | 177 | // Get the lock, remove under attack and update. |
@@ -187,20 +184,16 @@ discard block |
||
| 187 | 184 | debug('Under Attack'); |
| 188 | 185 | $underAttack = true; |
| 189 | 186 | processContainer($fedContainer); |
| 190 | - } |
|
| 191 | - 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. |
|
| 187 | + } 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. |
|
| 192 | 188 | debug('Follow Course: '.$player->getPlottedCourse()->getNextOnPath()); |
| 193 | 189 | processContainer(moveToSector($player,$player->getPlottedCourse()->getNextOnPath())); |
| 194 | - } |
|
| 195 | - else if(($container = canWeUNO($player,true))!==false) { //We have money and are at a uno, let's uno! |
|
| 190 | + } else if(($container = canWeUNO($player,true))!==false) { //We have money and are at a uno, let's uno! |
|
| 196 | 191 | debug('We\'re UNOing'); |
| 197 | 192 | processContainer($container); |
| 198 | - } |
|
| 199 | - else if($player->hasPlottedCourse()===true) { //We have a route to follow, figure it's probably a sensible thing to follow. |
|
| 193 | + } else if($player->hasPlottedCourse()===true) { //We have a route to follow, figure it's probably a sensible thing to follow. |
|
| 200 | 194 | debug('Follow Course: '.$player->getPlottedCourse()->getNextOnPath()); |
| 201 | 195 | processContainer(moveToSector($player,$player->getPlottedCourse()->getNextOnPath())); |
| 202 | - } |
|
| 203 | - 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 |
|
| 196 | + } 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 |
|
| 204 | 197 | if($player->getTurns()<NPC_LOW_TURNS) { |
| 205 | 198 | debug('Low Turns:'.$player->getTurns()); |
| 206 | 199 | } |
@@ -217,16 +210,13 @@ discard block |
||
| 217 | 210 | } |
| 218 | 211 | $ship =& $player->getShip(); |
| 219 | 212 | processContainer(plotToFed($player,!$ship->hasMaxShields()||!$ship->hasMaxArmour()||!$ship->hasMaxCargoHolds())); |
| 220 | - } |
|
| 221 | - else if(($container = checkForShipUpgrade($player))!==false) { //We have money and are at a uno, let's uno! |
|
| 213 | + } else if(($container = checkForShipUpgrade($player))!==false) { //We have money and are at a uno, let's uno! |
|
| 222 | 214 | debug('We\'re reshipping!'); |
| 223 | 215 | processContainer($container); |
| 224 | - } |
|
| 225 | - 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. |
|
| 216 | + } 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. |
|
| 226 | 217 | debug('We need to UNO, so off we go!'); |
| 227 | 218 | processContainer($container); |
| 228 | - } |
|
| 229 | - else if($TRADE_ROUTE instanceof Route) { |
|
| 219 | + } else if($TRADE_ROUTE instanceof Route) { |
|
| 230 | 220 | debug('Trade Route'); |
| 231 | 221 | $forwardRoute =& $TRADE_ROUTE->getForwardRoute(); |
| 232 | 222 | $returnRoute =& $TRADE_ROUTE->getReturnRoute(); |
@@ -234,8 +224,7 @@ discard block |
||
| 234 | 224 | if($forwardRoute->getBuySectorId()==$player->getSectorID()) { |
| 235 | 225 | $buyRoute =& $forwardRoute; |
| 236 | 226 | $sellRoute =& $returnRoute; |
| 237 | - } |
|
| 238 | - else if($returnRoute->getBuySectorId()==$player->getSectorID()) { |
|
| 227 | + } else if($returnRoute->getBuySectorId()==$player->getSectorID()) { |
|
| 239 | 228 | $buyRoute =& $returnRoute; |
| 240 | 229 | $sellRoute =& $forwardRoute; |
| 241 | 230 | } |
@@ -252,30 +241,25 @@ discard block |
||
| 252 | 241 | //Sell goods |
| 253 | 242 | debug('Sell Goods'); |
| 254 | 243 | processContainer(tradeGoods($goodID,$player,$port)); |
| 255 | - } |
|
| 256 | - else { |
|
| 244 | + } else { |
|
| 257 | 245 | //Move to next route or fed. |
| 258 | 246 | if(($TRADE_ROUTE =& changeRoute($TRADE_ROUTES))===false) { |
| 259 | 247 | debug('Changing Route Failed'); |
| 260 | 248 | processContainer(plotToFed($player)); |
| 261 | - } |
|
| 262 | - else { |
|
| 249 | + } else { |
|
| 263 | 250 | debug('Route Changed'); |
| 264 | 251 | continue; |
| 265 | 252 | } |
| 266 | 253 | } |
| 267 | - } |
|
| 268 | - else if($ship->hasCargo($buyRoute->getGoodID())===true) { //We've bought goods, plot to sell |
|
| 254 | + } else if($ship->hasCargo($buyRoute->getGoodID())===true) { //We've bought goods, plot to sell |
|
| 269 | 255 | debug('Plot To Sell: '.$buyRoute->getSellSectorId()); |
| 270 | 256 | processContainer(plotToSector($player,$buyRoute->getSellSectorId())); |
| 271 | - } |
|
| 272 | - else { |
|
| 257 | + } else { |
|
| 273 | 258 | //Dump goods |
| 274 | 259 | debug('Dump Goods'); |
| 275 | 260 | processContainer(dumpCargo($player)); |
| 276 | 261 | } |
| 277 | - } |
|
| 278 | - else { //Buy goods |
|
| 262 | + } else { //Buy goods |
|
| 279 | 263 | $goodID = $buyRoute->getGoodID(); |
| 280 | 264 | |
| 281 | 265 | $port =& $player->getSector()->getPort(); |
@@ -284,26 +268,22 @@ discard block |
||
| 284 | 268 | if($tradeable===true && $port->getGoodAmount($goodID)>=$ship->getEmptyHolds()) { //Buy goods |
| 285 | 269 | debug('Buy Goods'); |
| 286 | 270 | processContainer(tradeGoods($goodID,$player,$port)); |
| 287 | - } |
|
| 288 | - else { |
|
| 271 | + } else { |
|
| 289 | 272 | //Move to next route or fed. |
| 290 | 273 | if(($TRADE_ROUTE =& changeRoute($TRADE_ROUTES))===false) { |
| 291 | 274 | debug('Changing Route Failed'); |
| 292 | 275 | processContainer(plotToFed($player)); |
| 293 | - } |
|
| 294 | - else { |
|
| 276 | + } else { |
|
| 295 | 277 | debug('Route Changed'); |
| 296 | 278 | continue; |
| 297 | 279 | } |
| 298 | 280 | } |
| 299 | 281 | } |
| 300 | - } |
|
| 301 | - else { |
|
| 282 | + } else { |
|
| 302 | 283 | debug('Plot To Buy: '.$forwardRoute->getBuySectorId()); |
| 303 | 284 | processContainer(plotToSector($player,$forwardRoute->getBuySectorId())); |
| 304 | 285 | } |
| 305 | - } |
|
| 306 | - else { //Something weird is going on.. Let's fed and wait. |
|
| 286 | + } else { //Something weird is going on.. Let's fed and wait. |
|
| 307 | 287 | debug('No actual action? Wtf?'); |
| 308 | 288 | processContainer(plotToFed($player)); |
| 309 | 289 | } |
@@ -315,8 +295,7 @@ discard block |
||
| 315 | 295 | processContainer(moveToSector($player,$moveTo)); |
| 316 | 296 | } |
| 317 | 297 | */ |
| 318 | - } |
|
| 319 | - catch(ForwardException $e) { |
|
| 298 | + } catch(ForwardException $e) { |
|
| 320 | 299 | global $lock; |
| 321 | 300 | if($lock) { //only save if we have the lock. |
| 322 | 301 | SmrSector::saveSectors(); |
@@ -324,8 +303,9 @@ discard block |
||
| 324 | 303 | SmrPlayer::savePlayers(); |
| 325 | 304 | SmrForce::saveForces(); |
| 326 | 305 | SmrPort::savePorts();; |
| 327 | - if(class_exists('WeightedRandom', false)) |
|
| 328 | - WeightedRandom::saveWeightedRandoms(); |
|
| 306 | + if(class_exists('WeightedRandom', false)) { |
|
| 307 | + WeightedRandom::saveWeightedRandoms(); |
|
| 308 | + } |
|
| 329 | 309 | release_lock(); |
| 330 | 310 | } |
| 331 | 311 | //Clean up the caches as the data may get changed by other players |
@@ -451,8 +431,7 @@ discard block |
||
| 451 | 431 | debug('Creating account for: '.$NPC_LOGIN['Login']); |
| 452 | 432 | $account = SmrAccount::createAccount($NPC_LOGIN['Login'],'','[email protected]','NPC','NPC',0,0); |
| 453 | 433 | $account->setValidated(true); |
| 454 | - } |
|
| 455 | - else { |
|
| 434 | + } else { |
|
| 456 | 435 | $account = SmrAccount::getAccountByName($NPC_LOGIN['Login']); |
| 457 | 436 | } |
| 458 | 437 | |
@@ -472,11 +451,13 @@ discard block |
||
| 472 | 451 | } |
| 473 | 452 | |
| 474 | 453 | function canWeUNO(AbstractSmrPlayer &$player, $oppurtunisticOnly) { |
| 475 | - if($player->getCredits()<MINUMUM_RESERVE_CREDITS) |
|
| 476 | - return false; |
|
| 454 | + if($player->getCredits()<MINUMUM_RESERVE_CREDITS) { |
|
| 455 | + return false; |
|
| 456 | + } |
|
| 477 | 457 | $ship =& $player->getShip(); |
| 478 | - if($ship->hasMaxShields()&&$ship->hasMaxArmour()&&$ship->hasMaxCargoHolds()) |
|
| 479 | - return false; |
|
| 458 | + if($ship->hasMaxShields()&&$ship->hasMaxArmour()&&$ship->hasMaxCargoHolds()) { |
|
| 459 | + return false; |
|
| 460 | + } |
|
| 480 | 461 | $sector =& $player->getSector(); |
| 481 | 462 | |
| 482 | 463 | // We buy armour in preference to shields as it's cheaper. |
@@ -491,8 +472,7 @@ discard block |
||
| 491 | 472 | $hardwareSold =& $location->getHardwareSold(); |
| 492 | 473 | 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. |
| 493 | 474 | $hardwareID = HARDWARE_CARGO; |
| 494 | - } |
|
| 495 | - else { |
|
| 475 | + } else { |
|
| 496 | 476 | foreach($hardwareArray as $hardwareArrayID) { |
| 497 | 477 | if(!$ship->hasMaxHardware($hardwareArrayID) && isset($hardwareSold[$hardwareArrayID]) && ($amount = floor(($player->getCredits()-MINUMUM_RESERVE_CREDITS)/Globals::getHardwareCost($hardwareArrayID))) > 0) { |
| 498 | 478 | $hardwareID = $hardwareArrayID; |
@@ -506,11 +486,14 @@ discard block |
||
| 506 | 486 | } |
| 507 | 487 | } |
| 508 | 488 | |
| 509 | - if($oppurtunisticOnly===true) |
|
| 510 | - return false; |
|
| 489 | + if($oppurtunisticOnly===true) { |
|
| 490 | + return false; |
|
| 491 | + } |
|
| 511 | 492 | |
| 512 | - if($player->getCredits()-$ship->getCostToUNO()<MINUMUM_RESERVE_CREDITS) |
|
| 513 | - return false; //Only do non-oppurtunistic UNO if we have the money to do it properly! |
|
| 493 | + if($player->getCredits()-$ship->getCostToUNO()<MINUMUM_RESERVE_CREDITS) { |
|
| 494 | + return false; |
|
| 495 | + } |
|
| 496 | + //Only do non-oppurtunistic UNO if we have the money to do it properly! |
|
| 514 | 497 | |
| 515 | 498 | foreach($hardwareArray as $hardwareArrayID) { |
| 516 | 499 | if(!$ship->hasMaxHardware($hardwareArrayID)) { |
@@ -596,10 +579,14 @@ discard block |
||
| 596 | 579 | |
| 597 | 580 | function checkForShipUpgrade(AbstractSmrPlayer &$player) { |
| 598 | 581 | foreach(SHIP_UPGRADE_PATH[$player->getRaceID()] as $upgradeShipID) { |
| 599 | - if($player->getShipTypeID()==$upgradeShipID) //We can't upgrade, only downgrade. |
|
| 582 | + if($player->getShipTypeID()==$upgradeShipID) { |
|
| 583 | + //We can't upgrade, only downgrade. |
|
| 600 | 584 | return false; |
| 601 | - if($upgradeShipID == SHIP_TYPE_NEWBIE_MERCHANT_VESSEL) //We can't actually buy the NMV, we just don't want to downgrade from it if we have it. |
|
| 585 | + } |
|
| 586 | + if($upgradeShipID == SHIP_TYPE_NEWBIE_MERCHANT_VESSEL) { |
|
| 587 | + //We can't actually buy the NMV, we just don't want to downgrade from it if we have it. |
|
| 602 | 588 | continue; |
| 589 | + } |
|
| 603 | 590 | $cost = $player->getShip()->getCostToUpgrade($upgradeShipID); |
| 604 | 591 | if($cost <= 0 || $player->getCredits()-$cost > MINUMUM_RESERVE_CREDITS) { |
| 605 | 592 | return doShipUpgrade($player, $upgradeShipID); |
@@ -621,8 +608,9 @@ discard block |
||
| 621 | 608 | |
| 622 | 609 | function &changeRoute(array &$tradeRoutes) { |
| 623 | 610 | $false = false; |
| 624 | - if(count($tradeRoutes)==0) |
|
| 625 | - return $false; |
|
| 611 | + if(count($tradeRoutes)==0) { |
|
| 612 | + return $false; |
|
| 613 | + } |
|
| 626 | 614 | $routeKey = array_rand($tradeRoutes); |
| 627 | 615 | $tradeRoute =& $tradeRoutes[$routeKey]; |
| 628 | 616 | unset($tradeRoutes[$routeKey]); |
@@ -672,10 +660,11 @@ discard block |
||
| 672 | 660 | $tradeGoods = array(GOOD_NOTHING => false); |
| 673 | 661 | $goods =& Globals::getGoods(); |
| 674 | 662 | foreach($goods as $goodID => &$good) { |
| 675 | - if($player->meetsAlignmentRestriction($good['AlignRestriction'])) |
|
| 676 | - $tradeGoods[$goodID] = true; |
|
| 677 | - else |
|
| 678 | - $tradeGoods[$goodID] = false; |
|
| 663 | + if($player->meetsAlignmentRestriction($good['AlignRestriction'])) { |
|
| 664 | + $tradeGoods[$goodID] = true; |
|
| 665 | + } else { |
|
| 666 | + $tradeGoods[$goodID] = false; |
|
| 667 | + } |
|
| 679 | 668 | } unset($good); |
| 680 | 669 | $tradeRaces = array(); |
| 681 | 670 | $races =& Globals::getRaces(); |
@@ -700,8 +689,7 @@ discard block |
||
| 700 | 689 | $routes = unserialize(gzuncompress($db->getField('routes'))); |
| 701 | 690 | debug('Using Cached Routes: #'.count($routes)); |
| 702 | 691 | return $routes; |
| 703 | - } |
|
| 704 | - else { |
|
| 692 | + } else { |
|
| 705 | 693 | debug('Generating Routes'); |
| 706 | 694 | $allSectors = array(); |
| 707 | 695 | foreach($galaxies as &$galaxy) { |
@@ -711,10 +699,11 @@ discard block |
||
| 711 | 699 | $distances =& Plotter::calculatePortToPortDistances($allSectors,$maxDistance,$startSectorID,$endSectorID); |
| 712 | 700 | |
| 713 | 701 | |
| 714 | - if ($maxNumberOfPorts == 1) |
|
| 715 | - $allRoutes = RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort); |
|
| 716 | - else |
|
| 717 | - $allRoutes = RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes); |
|
| 702 | + if ($maxNumberOfPorts == 1) { |
|
| 703 | + $allRoutes = RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort); |
|
| 704 | + } else { |
|
| 705 | + $allRoutes = RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes); |
|
| 706 | + } |
|
| 718 | 707 | |
| 719 | 708 | unset($distances); |
| 720 | 709 | |
@@ -79,8 +79,7 @@ |
||
| 79 | 79 | fclose($toEngine); |
| 80 | 80 | fclose($fromEngine); |
| 81 | 81 | proc_close($engine); |
| 82 | -} |
|
| 83 | -catch(Throwable $e) { |
|
| 82 | +} catch(Throwable $e) { |
|
| 84 | 83 | logException($e); |
| 85 | 84 | exit; |
| 86 | 85 | } |
@@ -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 |
@@ -164,12 +164,14 @@ discard block |
||
| 164 | 164 | $rdata = preg_replace('/\s+/', ' ', $rdata); |
| 165 | 165 | |
| 166 | 166 | // log for reports (if enabled via command line (-log) |
| 167 | - if (IRC_LOGGING && strlen($rdata) > 0) |
|
| 168 | - write_log_message($rdata); |
|
| 167 | + if (IRC_LOGGING && strlen($rdata) > 0) { |
|
| 168 | + write_log_message($rdata); |
|
| 169 | + } |
|
| 169 | 170 | |
| 170 | 171 | // remember the last time we got something from the server |
| 171 | - if (strlen($rdata) > 0) |
|
| 172 | - $last_ping = time(); |
|
| 172 | + if (strlen($rdata) > 0) { |
|
| 173 | + $last_ping = time(); |
|
| 174 | + } |
|
| 173 | 175 | |
| 174 | 176 | // timeout detection! |
| 175 | 177 | if ($last_ping < time() - 300) { |
@@ -186,76 +188,102 @@ discard block |
||
| 186 | 188 | } |
| 187 | 189 | |
| 188 | 190 | // required!!! otherwise timeout! |
| 189 | - if (server_ping($fp, $rdata)) |
|
| 190 | - return; |
|
| 191 | + if (server_ping($fp, $rdata)) { |
|
| 192 | + return; |
|
| 193 | + } |
|
| 191 | 194 | |
| 192 | 195 | // server msg |
| 193 | - if (server_msg_307($fp, $rdata)) |
|
| 194 | - return; |
|
| 195 | - if (server_msg_318($fp, $rdata)) |
|
| 196 | - return; |
|
| 197 | - if (server_msg_352($fp, $rdata)) |
|
| 198 | - return; |
|
| 199 | - if (server_msg_401($fp, $rdata)) |
|
| 200 | - return; |
|
| 196 | + if (server_msg_307($fp, $rdata)) { |
|
| 197 | + return; |
|
| 198 | + } |
|
| 199 | + if (server_msg_318($fp, $rdata)) { |
|
| 200 | + return; |
|
| 201 | + } |
|
| 202 | + if (server_msg_352($fp, $rdata)) { |
|
| 203 | + return; |
|
| 204 | + } |
|
| 205 | + if (server_msg_401($fp, $rdata)) { |
|
| 206 | + return; |
|
| 207 | + } |
|
| 201 | 208 | |
| 202 | 209 | //Are they using a linked nick instead |
| 203 | - if(notice_nickserv_registered_user($fp, $rdata)) |
|
| 204 | - return; |
|
| 205 | - if(notice_nickserv_unknown_user($fp, $rdata)) |
|
| 206 | - return; |
|
| 210 | + if(notice_nickserv_registered_user($fp, $rdata)) { |
|
| 211 | + return; |
|
| 212 | + } |
|
| 213 | + if(notice_nickserv_unknown_user($fp, $rdata)) { |
|
| 214 | + return; |
|
| 215 | + } |
|
| 207 | 216 | |
| 208 | 217 | // some nice things |
| 209 | - if (ctcp_version($fp, $rdata)) |
|
| 210 | - return; |
|
| 211 | - if (ctcp_finger($fp, $rdata)) |
|
| 212 | - return; |
|
| 213 | - if (ctcp_time($fp, $rdata)) |
|
| 214 | - return; |
|
| 215 | - if (ctcp_ping($fp, $rdata)) |
|
| 216 | - return; |
|
| 218 | + if (ctcp_version($fp, $rdata)) { |
|
| 219 | + return; |
|
| 220 | + } |
|
| 221 | + if (ctcp_finger($fp, $rdata)) { |
|
| 222 | + return; |
|
| 223 | + } |
|
| 224 | + if (ctcp_time($fp, $rdata)) { |
|
| 225 | + return; |
|
| 226 | + } |
|
| 227 | + if (ctcp_ping($fp, $rdata)) { |
|
| 228 | + return; |
|
| 229 | + } |
|
| 217 | 230 | |
| 218 | - if (invite($fp, $rdata)) |
|
| 219 | - return; |
|
| 231 | + if (invite($fp, $rdata)) { |
|
| 232 | + return; |
|
| 233 | + } |
|
| 220 | 234 | |
| 221 | 235 | // join and part |
| 222 | - if (channel_join($fp, $rdata)) |
|
| 223 | - return; |
|
| 224 | - if (channel_part($fp, $rdata)) |
|
| 225 | - return; |
|
| 236 | + if (channel_join($fp, $rdata)) { |
|
| 237 | + return; |
|
| 238 | + } |
|
| 239 | + if (channel_part($fp, $rdata)) { |
|
| 240 | + return; |
|
| 241 | + } |
|
| 226 | 242 | |
| 227 | 243 | // nick change and quit |
| 228 | - if (user_nick($fp, $rdata)) |
|
| 229 | - return; |
|
| 230 | - if (user_quit($fp, $rdata)) |
|
| 231 | - return; |
|
| 244 | + if (user_nick($fp, $rdata)) { |
|
| 245 | + return; |
|
| 246 | + } |
|
| 247 | + if (user_quit($fp, $rdata)) { |
|
| 248 | + return; |
|
| 249 | + } |
|
| 232 | 250 | |
| 233 | - if (channel_action_slap($fp, $rdata)) |
|
| 234 | - return; |
|
| 251 | + if (channel_action_slap($fp, $rdata)) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 235 | 254 | |
| 236 | 255 | // channel msg (!xyz) without registration |
| 237 | - if (channel_msg_help($fp, $rdata)) |
|
| 238 | - return; |
|
| 239 | - if (channel_msg_seedlist($fp, $rdata)) |
|
| 240 | - return; |
|
| 241 | - if (channel_msg_op($fp, $rdata)) |
|
| 242 | - return; |
|
| 243 | - if (channel_msg_timer($fp, $rdata)) |
|
| 244 | - return; |
|
| 245 | - if (channel_msg_8ball($fp, $rdata)) |
|
| 246 | - return; |
|
| 247 | - if (channel_msg_seen($fp, $rdata)) |
|
| 248 | - return; |
|
| 249 | - if (channel_msg_sd($fp, $rdata)) |
|
| 250 | - return; |
|
| 256 | + if (channel_msg_help($fp, $rdata)) { |
|
| 257 | + return; |
|
| 258 | + } |
|
| 259 | + if (channel_msg_seedlist($fp, $rdata)) { |
|
| 260 | + return; |
|
| 261 | + } |
|
| 262 | + if (channel_msg_op($fp, $rdata)) { |
|
| 263 | + return; |
|
| 264 | + } |
|
| 265 | + if (channel_msg_timer($fp, $rdata)) { |
|
| 266 | + return; |
|
| 267 | + } |
|
| 268 | + if (channel_msg_8ball($fp, $rdata)) { |
|
| 269 | + return; |
|
| 270 | + } |
|
| 271 | + if (channel_msg_seen($fp, $rdata)) { |
|
| 272 | + return; |
|
| 273 | + } |
|
| 274 | + if (channel_msg_sd($fp, $rdata)) { |
|
| 275 | + return; |
|
| 276 | + } |
|
| 251 | 277 | |
| 252 | 278 | // channel msg (!xyz) with registration |
| 253 | - if (channel_msg_with_registration($fp, $rdata)) |
|
| 254 | - return; |
|
| 279 | + if (channel_msg_with_registration($fp, $rdata)) { |
|
| 280 | + return; |
|
| 281 | + } |
|
| 255 | 282 | |
| 256 | 283 | // MrSpock can use this to send commands as caretaker |
| 257 | - if (query_command($fp, $rdata)) |
|
| 258 | - return; |
|
| 284 | + if (query_command($fp, $rdata)) { |
|
| 285 | + return; |
|
| 286 | + } |
|
| 259 | 287 | |
| 260 | 288 | |
| 261 | 289 | // debug |