Permalink
Browse files

Fix the error for no players.

  • Loading branch information...
1 parent 0cf5df0 commit 8598f9e5b08b5409e838312807c53159410348c7 @hakre hakre committed Aug 4, 2012
Showing with 4 additions and 3 deletions.
  1. +3 −2 minequery.class.php
  2. +1 −1 test-failure-no-player-query.php
View
5 minequery.class.php
@@ -63,8 +63,9 @@ public static function query($address, $port = 25566, $timeout = 30) {
$query['maxPlayers'] = $query['maxPlayers'][1];
// Player list
- $query['playerList'] = explode(" ", $response[3], 2);
- $query['playerList'] = explode(", ", trim($query['playerList'][1], "[]"));
+ list(, $buffer) = explode(" ", $response[3], 2);
+ $buffer = trim($buffer, "[] ");
+ $query['playerList'] = $buffer ? explode(", ", $buffer) : array();
$query['latency'] = $latency;
View
2 test-failure-no-player-query.php
@@ -25,7 +25,7 @@ protected static function read($address, $port, &$errno, &$errstr, $timeout, $wr
Minequery::$classname = 'MinequeryStub';
-$query = Minequery::query($host, $port, 3);
+$query = Minequery::query($host);
$playerList = $query['playerList'];
$failure = array("");
$fixed = array();

0 comments on commit 8598f9e

Please sign in to comment.