Commit graph

399 commits

Author SHA1 Message Date
sluicebox
56ea963cea SCI: Create message workaround system
Adds a new workaround system for known broken messages and their
corresponding audio and sync resources. This replaces all special
cases in c++ and several script patches with data structures and
generic handling.

Common message bugs:
- Wrong tuple requested by game script
- Wrong tuple in message resource
- Wrong message text that exists in another record
- Missing message text
- Audio or sync resource with different tuple than message
2019-06-09 15:35:57 -07:00
sluicebox
b00049732f SCI: Fix diskdump patch file headers
Fix 'diskdump' debugger command creating an additional patch file
header for resources that were loaded from patch files
2019-04-15 22:48:19 +03:00
sluicebox
08ae52608c SCI: Fix sync36 patch files not being loaded
Fixes GK1 bug #10788
2019-03-03 22:44:29 +02:00
Filippos Karapetis
57f114cbc3 SCI: Don't try to validate resources added from a Mac resource fork
The fix has been authored originally by csnover, adapted from commit ca420e44167e5ee488b4ad547104fa6b976e6f1c

Fixes Trac#10440, Trac#10892.
2018-12-30 12:53:23 +02:00
Colin Snover
0962edc69b SCI: Silence more incorrect audio patch type warnings 2018-12-05 01:02:26 +02:00
Filippos Karapetis
7cbd3782f1 SCI: Load the correct sound effects in Hoyle 4
Fixes bug #10412
2018-08-27 23:45:34 +03:00
Dan Church
0c26da90bb SCI32: Fix segfault when SCI3 vocab isn't found
Seen when attempting to detect and/or run the Shivers 2 demo.

Closes gh-1106.
2018-01-02 12:57:59 -06:00
Colin Snover
617497d094 SCI: Fix UB shifting negative integers 2017-11-19 12:48:14 -06:00
Colin Snover
dc7e37fdb6 SCI32: Fix extremely broken patch for RAMA RESOURCE.SFX
Obviously, games other than RAMA need to have sound effects
volumes.
2017-09-29 23:02:38 -05:00
Colin Snover
f43b2c66fe SCI32: Improve RESOURCE.SFX fallback for RAMA
Since Datafiles says to rename any RESOURCE.SFX to RESSFX.00n,
and there is only a RESOURCE.SFX on CD 1, don't confuse users by
failing to use RESSFX.001 for CD2 and CD3.
2017-09-29 20:20:20 -05:00
Colin Snover
743082ac8c SCI32: Disable all SCI32 Mac code
This code is currently untestable and is almost certainly at least
partly based on guesswork & not actual reverse-engineering (as was
the case for all other pre-2015 SCI32 code), so future developers
interested in adding SCI32 Mac support should use it only as an
intermediate reference rather than as known good code.
2017-09-24 22:56:59 -05:00
Colin Snover
9fc24ed0b0 SCI32: Support RAMA's single sound effects volume
The original installer copied RESOURCE.SFX to the hard drive so
there was only one RESOURCE.SFX on CD 1. Instead of requiring
users to create duplicates, just use the single RESOURCE.SFX if it
exists.
2017-09-19 20:00:28 -05:00
Colin Snover
200c8c442b SCI: Remove dead code 2017-09-10 22:17:17 -05:00
Colin Snover
4771c41c35 SCI: Add method to get resource patch file extensions 2017-09-08 16:02:32 -05:00
Colin Snover
d97f192f45 SCI: Improve array bounds safety check
There is no practical risk now since the enum and array sizes are
the same, but there is no reason to rely on a separate data
structure to avoid potential out-of-bounds index use here instead
of just checking the array size directly, which is always safe.
2017-09-08 16:02:32 -05:00
Colin Snover
cc3088c529 SCI32: Make audio resource size mismatch non-fatal
Lighthouse audio.225 in RESSCI.002 (US English 1.0C) triggers this
condition; the audio resource says its data is one byte larger
than the recorded size in the volume. In this case, just use the
smaller of the two values for the size, to avoid overreads.
2017-09-03 20:58:08 -05:00
Colin Snover
b5bd7b8478 SCI32: Stop blacklisting 37.MAP from Phantasmagoria
It turns out that GOG.com version of Phantasmagoria needs the
37.MAP patch file because for some reason the 37.MAP in RESSCI.000
is empty (36 bytes, versus the correct file which is ~1kB).
Fortunately, this file is the same across all CDs in the original
US release, so hopefully unblocking this patch will not cause any
problems for any of the CD releases either.

Fixes Trac#10161.
2017-08-25 18:53:32 -05:00
Colin Snover
5412bda5ab SCI32: Fix loading audio resources from RESSCI.PAT
This is used by Lighthouse.
2017-08-04 13:29:55 -05:00
Colin Snover
d38704e16d SCI: Blacklist certain audio map patch files
Refs Trac#9976.
2017-07-23 16:01:19 -05:00
Colin Snover
4d52b018a2 SCI: Keep audio maps out of the LRU cache 2017-07-23 16:01:19 -05:00
Colin Snover
970c312e76 SCI32: Detect multi-disc audio by RESSCI files instead of RESAUD
If a user fails to rename audio files in the required manner when
copying them, detecting multi-disc audio by looking for a renamed
audio file does not work very well. Looking at RESSCI.00n is a
better choice, though this is not completely valid since e.g.
Rama 1.0 US has only one RESOURCE.SFX volume which its installer
copies to the hard drive, so a little more work will need to be
done in the future to find and fix these kinds of edge cases.

Refs Trac#9976.
2017-07-23 10:35:13 -05:00
Colin Snover
b73906feb7 SCI: Get LRU from list directly, instead of from a reverse iterator 2017-06-09 22:47:54 -05:00
Colin Snover
e29f60858d SCI32: Clarify code comment about Steam GK2 RESMAP.001 2017-06-08 00:28:44 -05:00
Colin Snover
cb657c0c0f SCI: Ignore patch resources with .DOS and .WIN extensions
Type mismatch is triggered on THEGUIDE.DOS and THEGUIDE.WIN from
at least Phant1 French 1.100.000.
2017-05-20 21:14:18 -05:00
Colin Snover
b1ace1a01c SCI: Suppress resource warnings when running fallback detection
For the moment, only warn about bad resources when a game is
actually starting, since unknown but valid resources being
detected by the fallback detector currently also trigger the
warning.
2017-05-13 22:49:40 -05:00
Colin Snover
f44d8b6da6 SCI: Dispose uncached volume file streams
The stream returned by a call to ResourceManager::getVolumeFile
either MUST (when returning an I/O stream from a Common::FSNode)
or must NOT (when returning a Common::File *) be deleted by the
caller, depending upon some internal implementation details of
ResourceSource that should never have been exposed to callers.

FSNode streams that should have been deleted were not being
deleted all the time, which leaked and eventually caused ScummVM
to run out of FDs.

This commit improves this situation by shielding callers from
these internal details by centralizing the destruction logic in
one place, so FSNode read streams stop being leaked and callers
no longer need to know stuff about the internals of the
ResourceSource they are trying to read in order to avoid leaking
or breaking the volume file cache.

Fixes Trac#9782.
2017-05-13 22:46:25 -05:00
Colin Snover
ea6eebca09 SCI: Fix reading of Rave data from compressed KQ6 audio volumes
Refs Trac#9764.
2017-05-10 15:29:53 -05:00
Colin Snover
dd13c3be43 SCI: Fix support for ScummVM compressed audio volumes
The runtime code for this had previously relied on hot patching
volume file offsets at the moment that a resource was loaded,
instead of correcting file offsets when reading audio maps. The
code added for sanity checking audio volumes started to report
warnings because the offsets being received were for the original
uncompressed audio volume, which (naturally) is larger than the
compressed audio volume.

This commit also deduplicates code between addResource and
updateResource, and tweaks a validation-related error message for
improved clarity.

Fixes Trac#9764.
2017-05-10 10:55:00 -05:00
Colin Snover
c788642b72 SCI: Add ifdef for SCI32 types in processPatch 2017-05-09 00:26:23 -05:00
Colin Snover
eb6e179169 SCI: Fix SCI1.1 patch resources
While earlier commits had fixed handling of audio resources in
audio bundles to match SSCI, audio *patches* in SCI16 were still
being treated like standard resource patches. They are now
special-cased in the resource manager, just like SCI32.

Incidentally, while fixing the problem with audio patches, I also
noticed that the patch resource fixes for SQ5/German were very
similar to the special-case operations for resources in SCI32,
though using an odd heuristic. After investigating, it appears
that Sierra SCI1.1 works mostly like SCI32, and not like what
was there from SCI View. So, the old special-case code is deleted
and the special-case code for SCI32 has been expanded to cover
SCI1.1. (SSCI prior to 1.1 do not appear to do this
special-casing.)

Fixes Trac#9773.
2017-05-08 23:59:28 -05:00
Colin Snover
f8d4ffa8ed SCI: Fix Audio36 patch suffix matching against lowercase extensions
The Lighthouse glider demo comes with a file named SDirectX.dll
which was failing to match the case-sensitive suffix search for
.DLL.
2017-05-08 11:26:47 -05:00
Colin Snover
130c9ecbb8 SCI: Fix some issues with ChunkResourceSource
1. The chunk number was hard-coded to zero and inaccessible.
2. Running ResourceManager::getVolumeFile for a chunk resource
   would always return nullptr instead of a stream of the chunk,
   which made it impossible to generically validate that resources
   being added were within bounds of the container file (or, in
   this case, container chunk).
2017-05-08 11:26:46 -05:00
Colin Snover
554a73e012 SCI: Improve detection and reporting of resource errors
Simple assertions in the resource manager are not sufficient to
track down resource corruption issues, and some error conditions
that were being checked already were either ignored or only raised
as warnings that casual users would be unlikely to see.

Ideally, error handling in ResourceManager would be improved to
the point where errors would correctly propagate out of it (so the
warning dialogue could be displayed from outside), but right now
error codes are dropped all over the place, and it would take more
effort to fix that without much benefit for the current situation.
If/until someone has the energy to fix that, the warning dialogue
is simply shown from ResourceManager::scanNewSources.

Refs Trac#9764.
2017-05-08 11:26:46 -05:00
Colin Snover
b208c82494 SCI32: Add support for Shivers interactive demo
Closes Trac#9745.
2017-05-01 12:31:21 -05:00
Colin Snover
89ec9e6762 SCI32: Remove SCI3 TODO
SCI3 resources appear to already be properly handled.
2017-04-23 22:13:53 -05:00
Colin Snover
82d9cacba0 SCI32: Allow resource maps with missing corresponding volumes
GK2 on Steam comes with an extra bogus resource map file which
would previously cause ScummVM to refuse to load the game due to
a mismatch in the number of map & volume files. This does not
cause any harm, but is a pain for users (since it requires them to
manually delete the file, and it will be recreated if a user runs
the Steam game file integrity check), so allow the game to load
with a warning instead.
2017-04-23 22:11:05 -05:00
Colin Snover
b3ecc54a7a SCI: Always search for .CSC script patches
Skipping a search for .CSC scripts when any .SCR files exist does
not work with at least Phant2, because it comes with an INSTALL.SCR
file. Searching unconditionally for .CSC files should not cause any
issues since the game scripts will either be in .SCR format or in
.CSC format, not both in the same game.
2017-04-23 13:07:25 -05:00
Colin Snover
866419fa71 SCI: Implement fallback detection for SCI3 2017-04-23 13:07:25 -05:00
Colin Snover
8aed6759e4 SCI32: Remove incomplete SCI3 detection warning
Map format is the same as SCI2/2.1 and volume format is detected
correctly as SCI3.
2017-04-23 13:07:25 -05:00
Colin Snover
0826501ef6 SCI32: Fix audio, wave, VMD, Duck, CLUT, TGA, ZZZ, Etc patches
Specifically, audio patches are used in at least PQ:SWAT
(40103.AUD), Lighthouse (9103.AUD), and the GK2 demo (300.AUD).
2017-03-30 19:46:27 -05:00
Colin Snover
d0e9724ae1 SCI32: Support reading sound effects from normal resource bundles 2017-03-30 19:46:27 -05:00
Colin Snover
a233696212 SCI: Update formatting strings to match updated Span API 2017-03-30 14:23:41 -05:00
Colin Snover
31daa956d6 SCI: Implement bounds-checked reads of game resources 2017-03-27 19:42:31 -05:00
Willem Jan Palenstijn
905feaa8c2 SCI: Fix unaligned read 2017-02-18 15:07:02 +01:00
Colin Snover
70cfdb6a1f SCI32: Ignore .OLD extension when searching Audio36 patches
KQ7 2.00b includes a SIERRINF.OLD file which should not be matched.
2017-01-09 19:34:54 -06:00
Colin Snover
472a43695a SCI: Remove unnecessary indirection in Resource::loadPatch 2016-12-03 12:21:55 -06:00
Colin Snover
fe8fbf7007 SCI32: Fix reading view, pic, and palette patches
Unlike SCI16 games, the location of data within SCI32 patch files
is calculated on a per-resource-type basis by the game engine,
instead of by reading byte 1 of the patch file.
2016-11-20 16:16:17 -06:00
Colin Snover
ee4b172d54 SCI: Remove old SCI32 hires detection heuristic 2016-11-02 15:43:07 -05:00
Colin Snover
8cb994b801 SCI32: Increase resource manager LRU cache size
This fixes high CPU utilisation playing Stooge Fighter 3 in SQ6.
2016-09-29 19:39:16 -05:00
Colin Snover
bf7adaa58f SCI32: Fix incorrect warnings about unlocking type 140
This type in SSCI corresponds to Wave resources, but since ScummVM
does not differentiate between Wave and Audio resources, just say
it's an Audio resource type, not an Invalid resource type.
2016-09-29 19:39:16 -05:00