@@ -12,4 +12,4 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace codemasher\WildstarDB; |
| 14 | 14 | |
| 15 | -class WSDBException extends \Exception{} |
|
| 15 | +class WSDBException extends \Exception {} |
|
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | use chillerlan\Database\Database; |
| 16 | 16 | |
| 17 | -interface ReaderInterface{ |
|
| 17 | +interface ReaderInterface { |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @param string $name |
@@ -9,6 +9,6 @@ |
||
| 9 | 9 | |
| 10 | 10 | namespace codemasher\WildstarDB; |
| 11 | 11 | |
| 12 | -if(!defined('WSDB_FUNCTIONS')){ |
|
| 12 | +if (!defined('WSDB_FUNCTIONS')) { |
|
| 13 | 13 | require_once __DIR__.'/functions.php'; |
| 14 | 14 | } |
@@ -17,11 +17,9 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | if($endianness === true){ // big-endian |
| 19 | 19 | $f = 'N'; |
| 20 | - } |
|
| 21 | - elseif($endianness === false){ // little-endian |
|
| 20 | + } elseif($endianness === false){ // little-endian |
|
| 22 | 21 | $f = 'V'; |
| 23 | - } |
|
| 24 | - else{ // machine byte order |
|
| 22 | + } else{ // machine byte order |
|
| 25 | 23 | $f = 'L'; |
| 26 | 24 | } |
| 27 | 25 | |
@@ -34,11 +32,9 @@ discard block |
||
| 34 | 32 | |
| 35 | 33 | if($endianness === true){ // big-endian |
| 36 | 34 | $f = 'J'; |
| 37 | - } |
|
| 38 | - elseif($endianness === false){ // little-endian |
|
| 35 | + } elseif($endianness === false){ // little-endian |
|
| 39 | 36 | $f = 'P'; |
| 40 | - } |
|
| 41 | - else{ // machine byte order |
|
| 37 | + } else{ // machine byte order |
|
| 42 | 38 | $f = 'Q'; |
| 43 | 39 | } |
| 44 | 40 | |
@@ -51,11 +47,9 @@ discard block |
||
| 51 | 47 | |
| 52 | 48 | if($endianness === true){ // big-endian |
| 53 | 49 | $f = 'G'; |
| 54 | - } |
|
| 55 | - elseif($endianness === false){ // little-endian |
|
| 50 | + } elseif($endianness === false){ // little-endian |
|
| 56 | 51 | $f = 'g'; |
| 57 | - } |
|
| 58 | - else{ // machine byte order |
|
| 52 | + } else{ // machine byte order |
|
| 59 | 53 | $f = 'f'; |
| 60 | 54 | } |
| 61 | 55 | |
@@ -19,15 +19,15 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @return array|string|false |
| 21 | 21 | */ |
| 22 | -function uint32($i, bool $endianness = null){ |
|
| 22 | +function uint32($i, bool $endianness = null) { |
|
| 23 | 23 | |
| 24 | - if($endianness === true){ // big-endian |
|
| 24 | + if ($endianness === true) { // big-endian |
|
| 25 | 25 | $f = 'N'; |
| 26 | 26 | } |
| 27 | - elseif($endianness === false){ // little-endian |
|
| 27 | + elseif ($endianness === false) { // little-endian |
|
| 28 | 28 | $f = 'V'; |
| 29 | 29 | } |
| 30 | - else{ // machine byte order |
|
| 30 | + else { // machine byte order |
|
| 31 | 31 | $f = 'L'; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return array|string|false |
| 44 | 44 | */ |
| 45 | -function uint64($i, bool $endianness = null){ |
|
| 45 | +function uint64($i, bool $endianness = null) { |
|
| 46 | 46 | |
| 47 | - if($endianness === true){ // big-endian |
|
| 47 | + if ($endianness === true) { // big-endian |
|
| 48 | 48 | $f = 'J'; |
| 49 | 49 | } |
| 50 | - elseif($endianness === false){ // little-endian |
|
| 50 | + elseif ($endianness === false) { // little-endian |
|
| 51 | 51 | $f = 'P'; |
| 52 | 52 | } |
| 53 | - else{ // machine byte order |
|
| 53 | + else { // machine byte order |
|
| 54 | 54 | $f = 'Q'; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -65,15 +65,15 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @return array|string|false |
| 67 | 67 | */ |
| 68 | -function float($i, bool $endianness = null){ |
|
| 68 | +function float($i, bool $endianness = null) { |
|
| 69 | 69 | |
| 70 | - if($endianness === true){ // big-endian |
|
| 70 | + if ($endianness === true) { // big-endian |
|
| 71 | 71 | $f = 'G'; |
| 72 | 72 | } |
| 73 | - elseif($endianness === false){ // little-endian |
|
| 73 | + elseif ($endianness === false) { // little-endian |
|
| 74 | 74 | $f = 'g'; |
| 75 | 75 | } |
| 76 | - else{ // machine byte order |
|
| 76 | + else { // machine byte order |
|
| 77 | 77 | $f = 'f'; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace codemasher\WildstarDB; |
| 14 | 14 | |
| 15 | -class ArchiveDirectory extends ArchiveItemAbstract{ |
|
| 15 | +class ArchiveDirectory extends ArchiveItemAbstract { |
|
| 16 | 16 | |
| 17 | 17 | public $BlockIndex; |
| 18 | 18 | public $Content; |
@@ -12,15 +12,15 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace codemasher\WildstarDB; |
| 14 | 14 | |
| 15 | -abstract class ArchiveItemAbstract{ |
|
| 15 | +abstract class ArchiveItemAbstract { |
|
| 16 | 16 | |
| 17 | 17 | public $Parent; |
| 18 | 18 | public $Name; |
| 19 | 19 | public $NameOffset; |
| 20 | 20 | |
| 21 | - public function __construct(array $data, string $parent){ |
|
| 21 | + public function __construct(array $data, string $parent) { |
|
| 22 | 22 | |
| 23 | - foreach($data as $property => $value){ |
|
| 23 | + foreach ($data as $property => $value) { |
|
| 24 | 24 | $this->{$property} = $value; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @property array $blocktable |
| 19 | 19 | */ |
| 20 | -abstract class PACKReaderAbstract extends ReaderAbstract{ |
|
| 20 | +abstract class PACKReaderAbstract extends ReaderAbstract { |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * @var string |
@@ -48,14 +48,14 @@ discard block |
||
| 48 | 48 | $this->loadFile($filename); |
| 49 | 49 | $this->blocktable = []; |
| 50 | 50 | |
| 51 | - if($this->header['Signature'] !== "\x4b\x43\x41\x50"){ // KCAP |
|
| 51 | + if ($this->header['Signature'] !== "\x4b\x43\x41\x50") { // KCAP |
|
| 52 | 52 | throw new WSDBException('invalid PACK'); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // read the block info table |
| 56 | 56 | \fseek($this->fh, $this->header['BlockTableOffset']); |
| 57 | 57 | |
| 58 | - for($i = 0; $i < $this->header['BlockCount']; $i++){ |
|
| 58 | + for ($i = 0; $i < $this->header['BlockCount']; $i++) { |
|
| 59 | 59 | $this->blocktable[$i] = \unpack('QOffset/QSize', \fread($this->fh, 16)); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @property string $prettyname |
| 19 | 19 | */ |
| 20 | -class LTEXReader extends ReaderAbstract{ |
|
| 20 | +class LTEXReader extends ReaderAbstract { |
|
| 21 | 21 | |
| 22 | 22 | // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c |
| 23 | 23 | protected const LCID = [ |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | public function read(string $filename):ReaderInterface{ |
| 44 | 44 | $this->loadFile($filename); |
| 45 | 45 | |
| 46 | - if($this->header['Signature'] !== "\x58\x45\x54\x4c"){ // XETL |
|
| 46 | + if ($this->header['Signature'] !== "\x58\x45\x54\x4c") { // XETL |
|
| 47 | 47 | throw new WSDBException('invalid LTEX'); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $this->prettyname = $this->decodeString(\fread($this->fh, $this->header['LongNameStringLength'] * 2)); |
| 53 | 53 | $this->name = 'LocalizedText_'.$this::LCID[$this->header['LCID']]; |
| 54 | 54 | $this->cols = [ |
| 55 | - ['name' => 'ID', 'header' => ['DataType' => 3]], |
|
| 55 | + ['name' => 'ID', 'header' => ['DataType' => 3]], |
|
| 56 | 56 | ['name' => 'LocalizedText', 'header' => ['DataType' => 130]], |
| 57 | 57 | ]; |
| 58 | 58 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | $this->data = array_fill(0, $this->header['EntryCount'], null); |
| 73 | 73 | |
| 74 | - foreach($this->data as $i => $_){ |
|
| 74 | + foreach ($this->data as $i => $_) { |
|
| 75 | 75 | // get the id and offset for the data block |
| 76 | 76 | $c = \unpack('Lid/Loffset', \fread($this->fh, 8)); |
| 77 | 77 | // save the current position |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $v = ''; |
| 84 | 84 | // read until we hit a double nul or the void |
| 85 | - do{ |
|
| 85 | + do { |
|
| 86 | 86 | $s = \fread($this->fh, 2); |
| 87 | 87 | $v .= $s; |
| 88 | 88 | } |
| 89 | - while($s !== "\x00\x00" && $s !== ''); |
|
| 89 | + while ($s !== "\x00\x00" && $s !== ''); |
|
| 90 | 90 | |
| 91 | 91 | $this->data[$i] = ['ID' => $c['id'], 'LocalizedText' => $this->decodeString($v)]; |
| 92 | 92 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | namespace codemasher\WildstarDB; |
| 14 | 14 | |
| 15 | -class ArchiveFile extends ArchiveItemAbstract{ |
|
| 15 | +class ArchiveFile extends ArchiveItemAbstract { |
|
| 16 | 16 | |
| 17 | 17 | public $Flags; |
| 18 | 18 | public $Filetime; |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | public $SizeCompressed; |
| 22 | 22 | public $Hash; |
| 23 | 23 | |
| 24 | - public function __construct(array $data, string $parent){ |
|
| 24 | + public function __construct(array $data, string $parent) { |
|
| 25 | 25 | parent::__construct($data, $parent); |
| 26 | 26 | |
| 27 | 27 | $this->Hash = \bin2hex($this->Hash); |
| 28 | - $this->FileUtime = (int)($this->Filetime/100000000); |
|
| 28 | + $this->FileUtime = (int)($this->Filetime / 100000000); |
|
| 29 | 29 | # $dt = (new \DateTime)->createFromFormat('U.u', $this->FileUtime) ?: (new \DateTime)->createFromFormat('U', $this->FileUtime); |
| 30 | 30 | # $this->FileTimeStr = $dt->format(\DateTimeInterface::RFC3339_EXTENDED); |
| 31 | 31 | } |