@@ -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 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | namespace codemasher\WildstarDB; |
| 17 | 17 | |
| 18 | -class DTBLReader extends ReaderAbstract{ |
|
| 18 | +class DTBLReader extends ReaderAbstract { |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @var string |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | public function read(string $filename):ReaderInterface{ |
| 51 | 51 | $this->loadFile($filename); |
| 52 | 52 | |
| 53 | - if($this->header['Signature'] !== "\x4c\x42\x54\x44"){ // LBTD |
|
| 53 | + if ($this->header['Signature'] !== "\x4c\x42\x54\x44") { // LBTD |
|
| 54 | 54 | throw new WSDBException('invalid DTBL'); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $this->readColumnHeaders(); |
| 58 | 58 | $this->readData(); |
| 59 | 59 | |
| 60 | - if(\count($this->data) !== $this->header['RecordCount']){ |
|
| 60 | + if (\count($this->data) !== $this->header['RecordCount']) { |
|
| 61 | 61 | throw new WSDBException('invalid row count'); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -76,18 +76,18 @@ discard block |
||
| 76 | 76 | \fseek($this->fh, $this->header['DescriptionOffset'] + $this->headerSize); |
| 77 | 77 | |
| 78 | 78 | // read the column headers (4+4+8+2+2+4 = 24 bytes) |
| 79 | - for($i = 0; $i < $this->header['FieldCount']; $i++){ |
|
| 79 | + for ($i = 0; $i < $this->header['FieldCount']; $i++) { |
|
| 80 | 80 | $this->cols[$i]['header'] = \unpack('LNameLength/x4/QNameOffset/SDataType/x2/x4', \fread($this->fh, 24)); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $offset = $this->header['FieldCount'] * 24 + $this->header['DescriptionOffset'] + $this->headerSize; |
| 84 | 84 | |
| 85 | - if($this->header['FieldCount'] % 2){ |
|
| 85 | + if ($this->header['FieldCount'] % 2) { |
|
| 86 | 86 | $offset += 8; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // read the column names |
| 90 | - foreach($this->cols as $i => $col){ |
|
| 90 | + foreach ($this->cols as $i => $col) { |
|
| 91 | 91 | \fseek($this->fh, $offset + $col['header']['NameOffset']); |
| 92 | 92 | |
| 93 | 93 | // column name (UTF-16LE: length *2) |
@@ -107,16 +107,16 @@ discard block |
||
| 107 | 107 | $this->data = array_fill(0, $this->header['RecordCount'], null); |
| 108 | 108 | |
| 109 | 109 | // read a row |
| 110 | - foreach($this->data as $i => $_){ |
|
| 110 | + foreach ($this->data as $i => $_) { |
|
| 111 | 111 | $this->rowdata = \fread($this->fh, $this->header['RecordSize']); |
| 112 | 112 | $this->pos = 0; |
| 113 | 113 | $this->skip = false; |
| 114 | 114 | |
| 115 | 115 | // loop through the columns |
| 116 | - foreach($this->cols as $c => $col){ |
|
| 116 | + foreach ($this->cols as $c => $col) { |
|
| 117 | 117 | |
| 118 | 118 | // skip 4 bytes if the string offset is 0 (determined by $skip), the current type is string and the next isn't |
| 119 | - if($this->skip === true && ($c > 0 && $this->cols[$c - 1]['header']['DataType'] === 130) && $col['header']['DataType'] !== 130){ |
|
| 119 | + if ($this->skip === true && ($c > 0 && $this->cols[$c - 1]['header']['DataType'] === 130) && $col['header']['DataType'] !== 130) { |
|
| 120 | 120 | $this->pos += 4; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // if we run into this, a horrible thing happened |
| 127 | - if(\count($this->data[$i]) !== $this->header['FieldCount']){ |
|
| 127 | + if (\count($this->data[$i]) !== $this->header['FieldCount']) { |
|
| 128 | 128 | throw new WSDBException('invalid field count'); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @return int|float|string|null |
| 139 | 139 | */ |
| 140 | - protected function getValue(int $datatype){ |
|
| 140 | + protected function getValue(int $datatype) { |
|
| 141 | 141 | |
| 142 | - switch($datatype){ |
|
| 142 | + switch ($datatype) { |
|
| 143 | 143 | case 3: // uint32 |
| 144 | 144 | case 11: // booleans (stored as uint32 0/1) |
| 145 | 145 | $v = uint32(\substr($this->rowdata, $this->pos, 4)); |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | $v = ''; |
| 174 | 174 | // loop through the string until we hit 2 nul bytes or the void |
| 175 | - do{ |
|
| 175 | + do { |
|
| 176 | 176 | $s = \fread($this->fh, 2); |
| 177 | 177 | $v .= $s; |
| 178 | 178 | } |
| 179 | - while($s !== "\x00\x00" && $s !== ''); |
|
| 179 | + while ($s !== "\x00\x00" && $s !== ''); |
|
| 180 | 180 | |
| 181 | 181 | \fseek($this->fh, $p); |
| 182 | 182 | |