Skip to content

Commit 2889477

Browse files
committed
support file gen 22
1 parent 12d6fdb commit 2889477

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

UnityAsset.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function __construct($file) {
4848
$tableSize = $stream->ulong;
4949
$dataEnd = $stream->longlong;
5050
$dataOffset = $stream->longlong;
51+
$stream->longlong;
5152
}
5253
if ($endian === "\0") {
5354
$stream->littleEndian = true;
@@ -101,7 +102,7 @@ function __construct($file) {
101102
}
102103
$asset = new AssetPreloadData;
103104
$asset->m_PathID = $this->fileGen<14 ? $stream->long : $stream->longlong;
104-
$asset->offset = $stream->ulong;
105+
$asset->offset = $this->fileGen<22 ? $stream->ulong : $stream->longlong;
105106
$asset->offset += $dataOffset;
106107
$asset->size = $stream->long;
107108
if ($this->fileGen > 15) {

UnityBundle.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class FileStream extends Stream {
125125
function __construct($file) {
126126
$this->f = fopen($file, 'rb+');
127127
if ($this->f === false) {
128-
throw 'Unable to open file';
128+
throw new Exception('Unable to open file');
129129
}
130130
$this->size = filesize($file);
131131
}
@@ -137,7 +137,10 @@ protected function read($length) {
137137
}
138138
public function write($newData) {
139139
fwrite($this->f, $newData);
140-
$this->size += strlen($newData);
140+
$pos = $this->position;
141+
fseek($this->f, 0, SEEK_END);
142+
$this->size = ftell($this->f);
143+
$this->position = $pos;
141144
}
142145
public function seek($position) {
143146
fseek($this->f, $position);
@@ -269,8 +272,11 @@ function extractBundle($bundle) {
269272
$bundle->position = $nextFile;
270273
}
271274
return $fileList;
275+
} else if ($format == 6) {
276+
} else if ($format == 7) {
277+
} else {
278+
throw new Exception('unknown version: '.$format);
272279
}
273-
if ($format != 6) throw new Exception('unknown version: '.$format);
274280

275281
$bundle->longlong;
276282
$compressedSize = $bundle->long;
@@ -280,6 +286,9 @@ function extractBundle($bundle) {
280286
if (($flag & 128) != 0) {
281287
throw new Exception('block info at end');
282288
} else {
289+
if ($format == 7) {
290+
$bundle->alignStream(16);
291+
}
283292
$blocksInfoBytes = $bundle->readData($compressedSize);
284293
}
285294

0 commit comments

Comments
 (0)