@@ -110,9 +110,9 @@ SciResourceDataType CompressSci::detectData(byte *header, bool compressMode) {
110
110
_input.read_throwsOnError (&buffer[6 ], 8 );
111
111
dataSize = READ_LE_UINT32 (buffer + 9 );
112
112
// HACK: LSL6 resource.aud has a SOL that specifies incorrect dataSize, we fix it here
113
- if ((_inputOffset == 0x619bf07 ) && (dataSize == 0x1dd78 ))
113
+ if ((_inputOffset == 102350599 ) && (dataSize == 122232 ))
114
114
dataSize--;
115
- if ((_inputOffset == 0x101DFBC5 ) && (dataSize == 0x1cfc1 ))
115
+ if ((_inputOffset == 270400453 ) && (dataSize == 118721 ))
116
116
dataSize--;
117
117
_inputEndOffset = _inputOffset + 14 + dataSize;
118
118
return kSciResourceDataTypeSOL ;
@@ -249,8 +249,6 @@ void CompressSci::compressData(SciResourceDataType dataType) {
249
249
error (" Unable to read WAV at offset %lx" , _inputOffset);
250
250
251
251
sampleData = new byte[sampleDataSize];
252
- if (!sampleData)
253
- error (" malloc error" );
254
252
_input.read_throwsOnError (sampleData, sampleDataSize);
255
253
if (sampleFlags & Audio::Mixer::FLAG_16BITS)
256
254
sampleBits = 16 ;
@@ -268,8 +266,6 @@ void CompressSci::compressData(SciResourceDataType dataType) {
268
266
_input.readByte ();
269
267
// Now we read SOL datastream
270
268
sampleData = new byte[sampleDataSize];
271
- if (!sampleData)
272
- error (" malloc error" );
273
269
_input.read_throwsOnError (sampleData, sampleDataSize);
274
270
275
271
bool dataUnsigned = false ;
@@ -295,17 +291,13 @@ void CompressSci::compressData(SciResourceDataType dataType) {
295
291
// No headers so just use the original data as sample data
296
292
sampleDataSize = orgDataSize;
297
293
sampleData = new byte[sampleDataSize];
298
- if (!sampleData)
299
- error (" malloc error" );
300
294
_input.read_throwsOnError (sampleData, sampleDataSize);
301
295
break ;
302
296
case kSciResourceTypeTypeSync :
303
297
print (" SYNC found at %lx\n " , _inputOffset);
304
298
// Simply copy original data over
305
299
newDataSize = orgDataSize;
306
300
newData = new byte[newDataSize];
307
- if (!newData)
308
- error (" malloc error" );
309
301
_input.read_throwsOnError (newData, newDataSize);
310
302
break ;
311
303
default :
@@ -325,8 +317,6 @@ void CompressSci::compressData(SciResourceDataType dataType) {
325
317
Common::File tempfileEnc (TEMP_ENC, " rb" );
326
318
newDataSize = tempfileEnc.size ();
327
319
newData = new byte[newDataSize];
328
- if (!newData)
329
- error (" malloc error" );
330
320
tempfileEnc.read_throwsOnError (newData, newDataSize);
331
321
tempfileEnc.close ();
332
322
}
@@ -340,16 +330,12 @@ uint CompressSci::parseRawAudioMap() {
340
330
// Assume the map is in the same dir as the resource file
341
331
// and is called AUDIO001.MAP
342
332
mapFileName.setFullName (" AUDIO001.MAP" );
343
- warning (" Trying %s as resource map\n " , mapFileName.getFullPath ().data ());
333
+ print (" Trying %s as resource map\n " , mapFileName.getFullPath ().data ());
344
334
Common::File mapFile;
345
335
mapFile.open (mapFileName, " rb" );
346
- // Ten byte entries, the last one is fake
347
- uint32 numEntries = (mapFile.size () / 10 ) - 1 ;
348
336
uint32 offset = 0 ;
349
- for (uint32 i = 0 ; i < numEntries; i++) {
350
- // shouldn't reach the fake entry but break if we do
351
- if (mapFile.readUint16LE () == 0xffff )
352
- break ;
337
+ // Ten byte entries, the last is fake, stop when it's reached
338
+ while (mapFile.readUint16LE () != 0xffff ) {
353
339
// mask out the resource volume number
354
340
offset = mapFile.readUint32LE () & 0x0fffffff ;
355
341
_rawAudioMap[offset] = mapFile.readUint32LE ();
@@ -382,8 +368,8 @@ void CompressSci::execute() {
382
368
error (" This resource file is already FLAC-compressed, aborting...\n " );
383
369
384
370
int resourceCount = 0 ;
385
- if (_input.size () == 0x05C9B000 or _input.size () == 0x0160E000 ) {
386
- warning (" Size matches KQ5 or Jones in the Fast Lane audio file, assuming raw audio\n " );
371
+ if (_input.size () == 97103872 || _input.size () == 23126016 ) {
372
+ print (" Size matches KQ5 or Jones in the Fast Lane audio file, assuming raw audio\n " );
387
373
_rawAudio = true ;
388
374
resourceCount = parseRawAudioMap ();
389
375
} else {
@@ -440,8 +426,8 @@ void CompressSci::execute() {
440
426
compressData (recognizedDataType);
441
427
442
428
// raw files are 0-padded to 2048 bytes
443
- if (_rawAudio and _inputEndOffset % 2048 )
444
- _inputEndOffset = (((_inputEndOffset >> 11 ) + 1 ) << 11 ) & 0xffffffff ;
429
+ if (_rawAudio)
430
+ _inputEndOffset = (((_inputEndOffset - 1 ) >> 11 ) + 1 ) << 11 ;
445
431
446
432
// Seek inputfile to the end of the data
447
433
_input.seek (_inputEndOffset, SEEK_SET);
0 commit comments