From 6e79f464df155d3bed93e79b871d16c03593a9e0 Mon Sep 17 00:00:00 2001 From: Javier Marcos Date: Tue, 10 May 2016 09:52:49 +0100 Subject: [PATCH] Fixed bases scoring system --- src/models/Level.php | 2 +- src/scripts/bases.php | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/models/Level.php b/src/models/Level.php index 248d7db1..9587d647 100644 --- a/src/models/Level.php +++ b/src/models/Level.php @@ -815,7 +815,7 @@ public static function getBasesResponses( public static async function genBaseScoring( ): Awaitable { $document_root = must_have_string(Utils::getSERVER(), 'DOCUMENT_ROOT'); - $cmd = 'hhvm -vRepo.Central.Path=/tmp/.hhvm.hhbc_bases '.escapeshellarg($document_root).'/scripts/bases.php > /dev/null 2>&1 & echo $!'; + $cmd = 'hhvm -vRepo.Central.Path=/tmp/.hhvm.hhbc_bases '.$document_root.'/scripts/bases.php > /dev/null 2>&1 & echo $!'; $pid = shell_exec($cmd); await Control::genStartScriptLog(intval($pid), 'bases', $cmd); } diff --git a/src/scripts/bases.php b/src/scripts/bases.php index 09392316..1ae29e9c 100755 --- a/src/scripts/bases.php +++ b/src/scripts/bases.php @@ -2,13 +2,14 @@ require_once('/var/www/fbctf/vendor/autoload.php'); -while ((Configuration::get('game')->getValue() === '1')) { +$conf_game = \HH\Asio\join(Configuration::gen('game')); +while ($conf_game->getValue() === '1') { // Get all active base levels $bases_endpoints = array(); - foreach (Level::allActiveBases() as $base) { + foreach (\HH\Asio\join(Level::genAllActiveBases()) as $base) { $endpoint = array( 'id' => $base->getId(), - 'url' => Level::getBaseIP($base->getId()) + 'url' => \HH\Asio\join(Level::genBaseIP($base->getId())) ); array_push($bases_endpoints, $endpoint); } @@ -20,9 +21,9 @@ $json_r = json_decode($response['response'])[0]; $teamname = $json_r->team; // Give points to the team if exists - if (Team::teamExist($teamname)) { - $team = Team::getTeamByName($teamname); - Level::scoreBase($response['id'], $team->getId()); + if (\HH\Asio\join(Team::genTeamExist($teamname))) { + $team = \HH\Asio\join(Team::genTeamByName($teamname)); + \HH\Asio\join(Level::genScoreBase($response['id'], $team->getId())); //echo "Points\n"; } //echo "Base(".strval($response['id']).") taken by ".$teamname."\n"; @@ -30,8 +31,9 @@ $code = -1; //echo "Base(".strval($response['id']).") is DOWN\n"; } - Level::logBaseEntry($response['id'], $code, strval($response['response'])); + \HH\Asio\join(Level::genLogBaseEntry($response['id'], $code, strval($response['response']))); } // Wait until next iteration - sleep(intval(Configuration::get('bases_cycle')->getValue())); + $bases_cycle = \HH\Asio\join(Configuration::gen('bases_cycle')); + sleep(intval($bases_cycle->getValue())); } \ No newline at end of file