<commit_before><?php
/**
 * PHPInSimMod - PTH Module
 * @package PRISM
 * @subpackage PTH
*/
// PaTH
class PTH
{
	const PACK = 'a6CCll';
	const UNPACK = 'a6LFSPTH/CVersion/CRevision/lNumNodes/lFinishLine';

	public $LFSPTH = 'LFSPTH';
	public $Version = 0;
	public $Revision = 0;
	public $NumNodes;
	public $FinishLine;
	public $Nodes = array();

	public function __construct($pthFilePath)
	{
		$file = file_get_contents($pthFilePath);

		if ($this->unPack($file) === TRUE)
			return; # trigger_error returns (bool) TRUE, so if the return is true, there was an error.

		return $this;
	}
	public function unPack($file)
	{
		if (substr($file, 0, 6) != $this->LFSPTH)
			return trigger_error('Not a LFS PTH file', E_USER_ERROR);

		if (substr($file, 6, 1) != $this->Version)
			return trigger_error('Not a LFS PTH Verion Is Different Than PTH Paser', E_USER_ERROR);

		if (substr($file, 7, 1) != $this->Revision)
			return trigger_error('Not a LFS PTH Revision Is Different Than PTH Paser', E_USER_ERROR);
		
		foreach (unpack(self::UNPACK, substr($file, 0, 16)) as $property => $value)
			$this->$property = $value;

		for ($Node = 0; $Node < $this->NumNodes; ++$Node)
			$this->Nodes[$Node] = new Node(substr($file, 16 + ($Node * 40), 40));

		return $this;
	}
}
class Node
{
	public $Center;
	public $Direction;
	public $Limit;
	public $Road;

	public function __construct($RawNode) {
		$this->Center = new Center(substr($RawNode, 0, 12));
		$this->Direction = new Direction(substr($RawNode, 12, 12));
		$this->Limit = new Limit(substr($RawNode, 24, 8), $this);
		$this->Road = new Road(substr($RawNode, 32, 8), $this);
	}
}
class Center
{
	const PACK = 'lll';
	const UNPACK = 'lX/lY/lZ';
	
	public function __construct($rawData) {
		$this->unPack($rawData);
	}
	public function unPack($rawData) {
		foreach (unpack(self::UNPACK, $rawData) as $property => $value)
			$this->$property = $value;
	}
}
class Direction
{
	const PACK = 'fff';
	const UNPACK = 'fX/fY/fZ';

	public function __construct($rawData) {
		$this->unPack($rawData);
	}
	public function unPack($rawData) {
		foreach (unpack(Center::UNPACK, $rawData) as $property => $value)
			$this->$property = $value;
	}
}
class Limit extends PointDetail
{<commit_msg>Fixed small errors in the pth parser.<commit_after><?php
/**
 * PHPInSimMod - PTH Module
 * @package PRISM
 * @subpackage PTH
*/
// PaTH
class PTH
{
	const PACK = 'a6CCll';
	const UNPACK = 'a6LFSPTH/CVersion/CRevision/lNumNodes/lFinishLine';

	public $LFSPTH = 'LFSPTH';
	public $Version = 0;
	public $Revision = 0;
	public $NumNodes;
	public $FinishLine;
	public $Nodes = array();

	public function __construct($pthFilePath)
	{
		$file = file_get_contents($pthFilePath);

		if ($this->unPack($file) === TRUE)
			return; # trigger_error returns (bool) TRUE, so if the return is true, then was an error.

		return $this;
	}
	public function unPack($file)
	{
		if (substr($file, 0, 6) != $this->LFSPTH)
			return trigger_error('Not a LFS PTH file', E_USER_ERROR);

		if (substr($file, 6, 1) != $this->Version)
			return trigger_error('Not a LFS PTH Verion Is Different Than PTH Paser', E_USER_ERROR);

		if (substr($file, 7, 1) != $this->Revision)
			return trigger_error('Not a LFS PTH Revision Is Different Than PTH Paser', E_USER_ERROR);
		
		foreach (unpack(self::UNPACK, substr($file, 0, 16)) as $property => $value)
			$this->$property = $value;

		for ($Node = 0; $Node < $this->NumNodes; ++$Node)
			$this->Nodes[$Node] = new Node(substr($file, 16 + ($Node * 40), 40));

		return $this;
	}
}
class Node
{
	public $Center;
	public $Direction;
	public $Limit;
	public $Road;

	public function __construct($RawNode) {
		$this->Center = new Center(substr($RawNode, 0, 12));
		$this->Direction = new Direction(substr($RawNode, 12, 12));
		$this->Limit = new Limit(substr($RawNode, 24, 8), $this);
		$this->Road = new Road(substr($RawNode, 32, 8), $this);
	}
}
class Center
{
	const PACK = 'lll';
	const UNPACK = 'lX/lY/lZ';
	
	public function __construct($rawData) {
		$this->unPack($rawData);
	}
	public function unPack($rawData) {
		foreach (unpack($this::UNPACK, $rawData) as $property => $value)
			$this->$property = $value;
	}
}
class Direction
{
	const PACK = 'fff';
	const UNPACK = 'fX/fY/fZ';

	public function __construct($rawData) {
		$this->unPack($rawData);
	}
	public function unPack($rawData) {
		foreach (unpack($this::UNPACK, $rawData) as $property => $value)
			$this->$property = $value;
	}
}
class Limit extends PointDetail
{
{'fraction_non_alphanumeric': 0.16401879615126427, 'fraction_numerical': 0.014768404564779593, 'mean_word_length': 4.34688995215311, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '315025', 'n_tokens_mistral': 1808, 'n_tokens_neox': 1621, 'n_words': 440}