MCPcopy Create free account
hub / github.com/Timic3/rw-parser / parse

Method parse

src/renderware/dff/DffParser.ts:174–212  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172 }
173
174 parse(): RwDff {
175 let version: string | undefined;
176 let versionNumber: number | undefined;
177 let clumps: RwClump[] = [];
178
179 while (this.getPosition() < this.getSize()) {
180 const header = this.readSectionHeader();
181
182 if (header.sectionType === 0) {
183 break;
184 }
185
186 if (header.sectionSize == 0) {
187 continue;
188 }
189 versionNumber = RwVersion.unpackVersion(header.versionNumber);
190 version = RwVersion.versions[versionNumber];
191
192 switch (header.sectionType) {
193 case RwSections.RwClump:
194 clumps.push(this.readClump(header.sectionSize));
195 break;
196 default:
197 console.debug(`Section type ${header.sectionType} (${header.sectionType.toString(16)}) not found at offset (${this.getPosition().toString(16)}). Skipping ${header.sectionSize} bytes.`);
198 this.skip(header.sectionSize);
199 break;
200 }
201 }
202
203 if (!version || !versionNumber) {
204 throw new RwParseStructureNotFoundError('version');
205 }
206
207 return {
208 version: version,
209 versionNumber: versionNumber,
210 clumps: clumps,
211 };
212 }
213
214 public readClump(clumpSize: number): RwClump {
215 const { versionNumber } = this.readSectionHeader();

Callers 4

wuzimu.dff.test.tsFile · 0.45

Calls 6

readClumpMethod · 0.95
getPositionMethod · 0.80
getSizeMethod · 0.80
readSectionHeaderMethod · 0.80
unpackVersionMethod · 0.80
skipMethod · 0.80

Tested by

no test coverage detected