/** * Overload the default detail process since this version is different * * @param \GameQ\Buffer $buffer * * @return array */ protected function processDetails(Buffer $buffer) { // Set the result to a new result instance $result = new Result(); $result->add('serverid', $buffer->readInt32()); // 0 $result->add('serverip', $buffer->readPascalString(1)); // empty $result->add('gameport', $buffer->readInt32()); $result->add('queryport', $buffer->readInt32()); // 0 // We burn the first char since it is not always correct with the hostname $buffer->skip(1); // Read as a regular string since the length is incorrect (what we skipped earlier) $result->add('servername', utf8_encode($buffer->readString())); // The rest is read as normal $result->add('mapname', utf8_encode($buffer->readPascalString(1))); $result->add('gametype', $buffer->readPascalString(1)); $result->add('numplayers', $buffer->readInt32()); $result->add('maxplayers', $buffer->readInt32()); $result->add('currentwave', $buffer->readInt32()); unset($buffer); return $result->fetch(); }
/** * Handles processing the player data into a usable format * * @param Buffer $buffer * * @return array */ protected function processPlayers(Buffer $buffer) { // Set the result to a new result instance $result = new Result(); // Get the number of players $result->add('numplayers', $buffer->readInt16()); // Parse players while ($buffer->getLength()) { // Player id if (($id = $buffer->readInt16()) !== 0) { // Add the results $result->addPlayer('id', $id); $result->addPlayer('name', utf8_encode($buffer->readPascalString())); } } unset($buffer, $id); return $result->fetch(); }
/** * Handles processing the rules data into a usable format * * @param \GameQ\Buffer $buffer * * @return array */ protected function processRules(Buffer $buffer) { // Set the result to a new result instance $result = new Result(); // Number of rules $result->add('num_rules', $buffer->readInt16()); // Run until we run out of buffer while ($buffer->getLength()) { $result->add($buffer->readPascalString(), $buffer->readPascalString()); } unset($buffer); return $result->fetch(); }
/** * Handles processing the player and team data into a usable format * * @param \GameQ\Buffer $buffer * @param \GameQ\Result $result */ protected function processPlayersAndTeams(Buffer &$buffer, Result &$result) { // Players and team info while ($buffer->getLength()) { // Get the flags $flags = $buffer->readInt8(); // Get data according to the flags if ($flags & 1) { $result->addPlayer('name', $buffer->readPascalString(1, true)); } if ($flags & 2) { $result->addPlayer('team', $buffer->readPascalString(1, true)); } if ($flags & 4) { $result->addPlayer('skin', $buffer->readPascalString(1, true)); } if ($flags & 8) { $result->addPlayer('score', $buffer->readPascalString(1, true)); } if ($flags & 16) { $result->addPlayer('ping', $buffer->readPascalString(1, true)); } if ($flags & 32) { $result->addPlayer('time', $buffer->readPascalString(1, true)); } } }