@@ -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 | |