@@ -37,41 +37,32 @@ function __construct($file) {
3737 $ this ->fileGen = $ stream ->long ;
3838 $ dataOffset = $ stream ->long ;
3939
40- switch ($ this ->fileGen ) {
41- case 6 :
42- $ stream ->position = $ dataEnd - $ tableSize + 1 ;
43- break ;
44- case 7 :
45- $ stream ->position = $ dataEnd - $ tableSize + 1 ;
46- $ this ->m_Version = $ stream ->string ;
47- break ;
48- case 8 :
49- $ stream ->position = $ dataEnd - $ tableSize + 1 ;
50- $ this ->m_Version = $ stream ->string ;
51- $ this ->platform = $ stream ->long ;
52- break ;
53- case 9 :
54- $ stream ->position += 4 ;
55- $ this ->m_Version = $ stream ->string ;
56- $ this ->platform = $ stream ->long ;
57- break ;
58- case 14 :
59- case 15 :
60- case 16 :
61- case 17 :
62- $ stream ->position += 4 ;
63- $ this ->m_Version = $ stream ->string ;
64- $ this ->platform = $ stream ->long ;
65- $ this ->baseDefinitions = $ stream ->readBoolean ();
66- break ;
67- default :
68- return ;
40+ if ($ this ->fileGen >= 9 ) {
41+ $ endian = $ stream ->byte ;
42+ $ stream ->readData (3 );
43+ } else {
44+ $ stream ->position = $ dataEnd - $ tableSize ;
45+ $ endian = $ stream ->byte ;
6946 }
70-
71- if ($ this ->platform > 255 || $ this ->platform < 0 ) {
72- $ this ->platform = unpack ('V ' , pack ('N ' , $ this ->platform ))[1 ];
47+ if ($ this ->fileGen >= 22 ) {
48+ $ tableSize = $ stream ->ulong ;
49+ $ dataEnd = $ stream ->longlong ;
50+ $ dataOffset = $ stream ->longlong ;
51+ }
52+ if ($ endian === "\0" ) {
7353 $ stream ->littleEndian = true ;
7454 }
55+
56+ if ($ this ->fileGen >= 7 ) {
57+ $ this ->m_Version = $ stream ->string ;
58+ }
59+ if ($ this ->fileGen >= 8 ) {
60+ $ this ->platform = $ stream ->long ;
61+ }
62+ if ($ this ->fileGen >= 13 ) {
63+ $ this ->baseDefinitions = $ stream ->byte === "\x01" ;
64+ }
65+
7566 switch ($ this ->platform ) {
7667 case -2 : $ this ->platformStr = 'Unity Package ' ; break ;
7768 case 4 : $ this ->platformStr = 'OSX ' ; break ;
@@ -95,7 +86,7 @@ function __construct($file) {
9586 if ($ this ->fileGen < 14 ) {
9687 throw new Exception ('fileGen < 14 ' );
9788 } else {
98- $ this ->readBase5 ();
89+ $ this ->readSerializedType ();
9990 }
10091 }
10192
@@ -165,7 +156,7 @@ function __construct($file) {
165156 } catch (Excepti4on $ e ) { }
166157 }
167158
168- private function readBase5 () {
159+ private function readSerializedType () {
169160 $ stream = $ this ->stream ;
170161 $ classID = $ stream ->long ;
171162 if ($ this ->fileGen > 15 ) {
@@ -185,13 +176,17 @@ private function readBase5() {
185176 }
186177 $ stream ->position += 16 ;
187178 if ($ this ->baseDefinitions ) {
179+ $ nodeInfoSize = 24 ;
180+ if ($ this ->fileGen >= 19 ) {
181+ $ nodeInfoSize += 8 ;
182+ }
188183 $ varCount = $ stream ->long ;
189184 $ stringSize = $ stream ->long ;
190- $ stream ->position += $ varCount * 24 ;
185+ $ stream ->position += $ varCount * $ nodeInfoSize ;
191186 $ stringReader = new MemoryStream ($ stringSize ?$ stream ->readData ($ stringSize ):'' );
192187 $ className = '' ;
193188 $ classVar = [];
194- $ stream ->position -= $ varCount * 24 + $ stringSize ;
189+ $ stream ->position -= $ varCount * $ nodeInfoSize + $ stringSize ;
195190 for ($ i =0 ; $ i <$ varCount ; $ i ++) {
196191 $ stream ->readInt16 ();
197192 $ level = ord ($ stream ->readData (1 ));
@@ -216,6 +211,9 @@ private function readBase5() {
216211 $ size = $ stream ->long ;
217212 $ flag2 = $ stream ->readInt32 () != 0 ;
218213 $ flag = $ stream ->long ;
214+ if ($ this ->fileGen >= 19 ) {
215+ $ RefTypeHash = $ stream ->ulonglong ;
216+ }
219217 if (!$ flag2 ) {
220218 $ className = $ varTypeStr . ' ' . $ varNameStr ;
221219 } else {
@@ -237,6 +235,11 @@ private function readBase5() {
237235 );
238236 //aClass.SubItems.Add(classID.ToString());
239237 $ this ->ClassStructures [$ classID ] = $ aClass ;
238+
239+ if ($ this ->fileGen >= 21 ) {
240+ $ arrSize = $ stream ->long ;
241+ $ stream ->position += $ arrSize * 4 ;
242+ }
240243 }
241244 }
242245
0 commit comments