Commit Graph
526 Commits
Author SHA1 Message Date
sluicebox 2fbeecab23 SCI: Prevent script lockers from overflowing
Script::_locker is supposed to track the number of classes and objects
that use a script in order to determine when it can be safely unloaded.
But for system script 999, _locker rapidly increases throughout the game
and eventually overflows. This causes script 999 to unload and crash.
Other scripts may also be affected.

We have been provided QFG1 SCI0 saves where this occurred over the
course of hours within only three days. Logging shows this value
skyrocketing in many games even when they are just polling input or
animating the screen. Alarmingly, this suggests that many SCI games
become unplayable in ScummVM after an achievable amount of game time.

This may be a large and complex problem within the script locker system.
For now, we can mitigate this by making Script::_locker unsigned, which
its callers expected it to be, and by logging overflow attempts and
lowering the locker. This fixes existing save games, even if they have
already overflowed the signed maximum.
2022-11-22 12:37:32 -08:00
sluicebox c346905a1a SCI: Reset palette cycling when loading games
Fixes frozen palette animation when loading from within the engine
2022-07-30 16:39:26 -04:00
sluicebox 6e5b1e31f0 SCI: Include all music fade flags in save files
fadeSetVolume and fadeCompleted are used by the fade timer to signal
SoundCommand::processUpdateCues() that there is work to be done.
By not syncing them, if a save occurs after a fade completes but before
it's processed then the game won't see the completed fade when loading.
This can happen when the game is paused because the user has brought up
the game's menu bar or control panel in order to save a game. The fade
completes while the UI is displayed, then a save occurs, and then the
fade is processed after the UI is dismissed.

Now completed fades are processed when loading.

Fixes bug #7073 in KQ6 where saving in the Land of the Dead while
Alexander dismounts Night Mare results in a softlocked save.

Fixes bug #13546 in LSL6HIRES where saving while music fades from
a previous room results in a save that doesn't play the new music.
2022-07-30 16:39:25 -04:00
sluicebox fa59cf87f3 SCI: Fix reading version string on earlier games
Fixes the version string not being included in GMM saves or autosaves
if the game stored its string in global 28 instead of 27.
2022-06-06 17:30:47 -04:00
sluicebox a61bcdee59 SCI32: Fix saving from GMM in LSL7 2022-03-22 17:20:51 -04:00
Filippos Karapetis 3a8e79c674 SCI: Allow saving from the GMM for more SCI32 games
Saving from the GMM should now work for the following games as well:
GK2, Lighthouse, LSL7, Phant2, Shivers and Torin

Many thanks to @sluicebox for his help checking the game scripts of
these games
2022-01-16 21:36:42 +02:00
Filippos Karapetis 74fdf50a9e SCI: Improve the save/load code for saving and checking game versions 2022-01-16 18:36:26 +02:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Orgad Shaneh 940c7bfc14 SCI: Use nullptr
Using clang-tidy modernize-use-nullptr
2021-11-14 15:51:59 +02:00
sluicebox e5951416d4 SCI: Improve MOTHERGOOSE256 save-id workaround
The existing workarounds for this game's unique way of handling saves
assumed that the player restored a game at some point before the end.
Starting a new game and playing to the end would still cause an error
in the SCI1.1 floppy version because the game's save global would
contain an SCI id instead of our virtual id; we were only patching the
global when restoring.

Now we also patch the global on kSaveGame so that it always contains a
virtual id when there is a saved game.

Note that the existing uninitialized read workaround had no effect since
the read occurred in a local procedure but the workaround entry didn't
include a local procedure signature. Updating that workaround wouldn't
fix this; there would still be scenarios where the wrong save would be
auto-deleted.

Fixes bug #5294
2021-09-08 17:02:36 -05:00
sluicebox f6dd4fa234 SCI: Add option to use KQ5 CD Windows cursors
Ticket #7800
2021-04-29 09:27:13 -07:00
athrxx 5a626c8b78 SCI: (SCI0 sound) - fix sound restoring
This mainly concerns restoring sounds after loading savefiles, but it should make the whole relationship between playing and paused sounds more accurate.

The test case which I was told about was KQ4, room 21, picking up the golden ball under the bridge, saving during playback of the pickup sound and then loading that savegame. It would result in hanging note due toe the sound being triggered multiple times by reconstructPlaylist() and updateSci0Cues(). Now, the sound should only start once.

I've changed the code to be more in line with disasm and tested some situations that sluicebox told me about or that I found in the comments (ICEMAN room 14, LSL3 start scene). I got rid of isQueued, since the original doesn't have that, it has caused some confusion and doesn't even get saved with the savegames.

I cleaned up updateSci0Cues(), so that it (together with processUpdateCues()) does a bit more what the original Midi timer proc does there. An exception is the sound fade out code in processUpdateCues(). It seems that we need that, as we don't have the fading code in the drivers like the original.

The original SCI0 code is actually much simpler than our code. It relies on a correctly sorted playlist (based on priority), but my impression is that we got that right, even if we do it slightly differently. I added a sortPlayList() to the sound init, since the original inserts the node at the right position, too.
2021-03-13 17:41:54 +02:00
sluicebox 9982c761a2 SCI: Update all old bug tracker ticket numbers 2021-02-25 01:18:52 -08:00
Cameron Cawley c877097b49 ALL: Remove use of "" in Common::U32String constructors 2020-11-16 16:56:58 +00:00
aryanrawlani28 d41d0e9b22 JANITORIAL: Fix formatting issues 2020-08-30 14:43:41 +02:00
aryanrawlani28 12e4f871a3 GUI: U32: Improve u32 in all engine subsystems
- Common: add wordWrap function to ustr.cpp
- Bladerunner: Explicitly state we have a U32String in subs (same as Subtitles::loadOuttakeSubsText)
- Don't use translations for engine specific "put strings", because they might not support.
- SCI: Use const references for showScummVMDialog
- SCUMM:
-- Don't use translation in md5 warning. left comments with the translated version.
-- Remove some redundant headers in help.cpp
-- Don't use translation in handleSaveload when printing to console
-- Also, display success transaction correctly via u32::format
- TESTBED: Use fake constructor when setting label of button
- SKY: Correctly use translation when using SaveStateDescription
- ULTIMA: Don't use translations when display_string
- ENGINES:
-- GenerateUnknownGameReport correctly, with proper translations.
-- There was an error, where a function had been declared twice, in a header file. Correct this.
2020-08-30 14:43:41 +02:00
aryanrawlani28 e22b32abfe GUI: U32: Use Common::U32String::format where necessary and GUIError to u32
- Where necessary as in, where translated messages are used.
- GUIErrorMessage now takes in U32String
- error messages across some engines use U32Strings. they are changed because they show a message dialog.
2020-08-30 14:43:41 +02:00
aryanrawlani28 bed05ea134 GUI: U32: Fix compilation errors across entire project
After the initial changes just to scummvm/gui for u32, this commit includes the whole project

- Widget creations now always have u32 descriptions, labels, or tooltips
- Message dialogs make use of default arguments instead of providing the same argument explicitly
- encode String::format properly before passing on as argument where necessary
- Modify hugo utils (yesNoBox and notify box) to use u32
- Also provide fake constructors for the above which redirect to the u32 constructor
- Convert all keymap descriptions to u32 across all engines
- showConfirmationDialog in mohawk now uses u32
- showScummVMDialog also uses u32
- Scumm engine has dialogs now which use u32
- General fixes and wrapping convertToU32String for setLabels and related functions
- Add a fake constructor to MesssageDialog which redirects to the u32 constructor
2020-08-30 14:43:41 +02:00
Zvika Haramaty a4e01b46f4 SCI: fix #10907 - Wrong music when restoring games 2020-05-24 12:42:58 +03:00
sluicebox 916ce02661 SCI: Factor save game code into functions
Factors some common save game code into functions and creates an
overload of GuestAdditions::runSaveRestore that doesn't rely on
SCI memory for returning the description string, all of which will
be used by the custom save/restore kMacPlatform32 subops.
2020-04-19 23:33:54 -07:00
Filippos Karapetis 41e1053898 SCI: Stop any currently playing audio when loading. Fixes bug #9953.
Loading is not normally allowed while audio is being played in SCI games.
Stopping sounds is needed in ScummVM, as the player may load via
Control-F5 at any point, even while a sound is playing.
2020-03-21 18:35:27 +02:00
Zvika Haramaty 540a3cd7a5 SCI: adding stopAfterFading to savegame, fixing #10685 2020-03-16 01:22:50 +02:00
Filippos Karapetis ff044aa431 SCI: Move the GK2 subtitle patch dialog inside the SciEngine class
This is now grouped together with the other GUI messages. The script
patcher class itself does not need to handle such logic
2020-02-09 23:27:11 +02:00
sluicebox 15ce41c4da SCI32: Delete planes when restoring Mac games 2020-02-01 20:00:20 -08:00
sluicebox 11065630c0 SCI: Fix CAMELOT menu items when restoring 2019-11-20 14:12:54 -08:00
Filippos Karapetis 7f83640894 SCI32: Add a game option to double the videos in KQ7 by default
Scaling works correctly with the Windows variant, which uses AVI files,
but the DOS variant uses Robot videos, and the way scaling is done
there is different, and is not working yet with KQ7 DOS. Nonetheless,
both versions are included in the game, so it's not a major issue.
2018-09-01 13:14:38 +03:00
Filippos Karapetis c978139f10 SCI32: Fix broken palette when loading a game in Shivers from the GMM 2018-08-27 01:50:32 +03:00
Colin Snover 2e061d95c5 COMMON: Move VER macro for serializer into common code 2018-01-31 17:58:01 +01:00
Colin Snover c7c5f28bdb SCI32: Clean up scriptWidth/scriptHeight/screenWidth/screenHeight
This removes the unnecessary Buffer subclass and stops most places
where the output buffer was being interrogated about dimensions
instead of GfxFrameout.
2017-10-06 22:56:26 -05:00
Colin Snover 5cffa3891f SCI32: Clean up GfxPalette32
* Replace raw pointers with smart pointers
* Use references instead of const pointers where appropriate
* Tweak initialisation
* Tweak palette copies to the stack
2017-10-06 22:10:50 -05:00
Colin Snover d73ada9088 SCI: Fix generation of save games 2017-09-24 11:12:45 -05:00
Colin Snover 9298f6a81e SCI: Split save game metadata writing to separate function
RAMA has its own custom save game format that game scripts write,
but we still want to be able to use these save game files from the
ScummVM launcher, so the metadata has to be able to be written
separately from the rest of the game saving.
2017-09-23 20:56:48 -05:00
Colin Snover d17ae077dd SCI: Use reference instead of pointer for required out-data in metadata save function 2017-09-23 20:56:48 -05:00
Colin Snover a447664373 SCI32: Add missing include for ConfMan 2017-09-08 19:10:21 -05:00
Colin Snover f11b0a4ff5 SCI32: Toggle Phant2 content censoring from game options
To enable the optional content censoring mode, Phant2 looks
for a RESDUK.PAT file, which is normally placed by the game's
installer if the user chose to enable censorship. If the file
exists, the game reads an unlock password out of the file and
asks the user to enter the password when starting a new game to
create an uncensored game, or to click a "less intense" button
to start the game with censoring. The censorship state of the
game is then persisted in the save game file, and installations
with the RESDUK.PAT file need to enter the password again in
order to restore any of the uncensored saves.

Since we do not have an installer that can enable this feature,
add a game option toggle to enable/disable censoring (for the
releases that have the optional censorship mode) instead so the
censored content feature is available for anyone that wants to use
it. This flag is restored from ScummVM whenever a save game is
loaded, so it can be toggled on or off at any point without
needing a separate save game, unlike in the original interpreter.
2017-09-08 16:03:24 -05:00
Colin Snover 3bc00e6633 SCI: Stop double-initialization of SCI0/1 objects
These objects should have been initialized only during the first
pass. Double-initialization does not cause any visible problem
problem during normal operation (mostly it just causes memory
waste by making Object::_baseVars/_baseMethod double up their
data), but could have silently allowed games to receive bogus data
for an out-of-bounds property or method index, instead of raising
an error.
2017-07-15 20:29:36 -05:00
Colin Snover d556dcc57b SCI: Switch SCI2 games to use Audio32
Upon investigation of Sound code across SCI32 games, it was
determined that there are actually (at least) 3 different
revisions, not just a single SCI2.1 version. This patch only
changes the parts of Sound code that are relevant to the correct
use of Audio32.

Fixes Trac#9736, Trac#9756, Trac#9767, Trac#9791.
2017-06-18 21:42:58 -05:00
Colin Snover 85e35943fe SCI32: Implement kLock & kDoAudio(1) for SCI32
1. Unlocking all resources of a type using a resource ID of -1 is
   gone in SCI32;
2. Audio locks need to be serialized starting in GK2 for the game's
   modified kDoAudio(1) call;
3. Audio locks in SCI3 must work more like SSCI, since at least
   Lighthouse's `BackMusic::fade` method will attempt to unlock
   audio that was never locked by a script. In SSCI (and now in
   ScummVM too) this is a no-op; previously in ScummVM, it would
   remove Audio32's own lock on the audio resource, resulting in a
   use-after-free;
4. kDoAudio(1) starting in GK2 returns the number of active
   *not-in-memory* channels being played, not the total number of
   active channels.

Fixes Trac#9675.
2017-06-09 23:00:14 -05:00
Colin Snover ddc00e4211 SCI: Remove unhelpful comment 2017-06-09 22:48:14 -05:00
Colin Snover cf98e16d90 SCI: Add serialization for ResourceId 2017-06-09 22:48:14 -05:00
Colin Snover 06e82211ee SCI: Implement Serializable for Object 2017-06-09 22:47:54 -05:00
Colin Snover bc728a1c93 SCI: Fix warning about missing base object when loading save games
This situation occurs rarely, but normally, when unreachable but
not yet GC'd objects use a superclass which has already been GC'd.

Thanks to @wjp for looking at this with me and clarifying what
was going on.
2017-05-20 21:14:18 -05:00
Colin Snover eda836f21a SCI: Nitpicky cleanup of some magic numbers and what-not-why comments 2017-05-20 21:14:18 -05:00
Colin Snover 881be25fcd SCI: Stop making copies of ObjMap and remove related dead code
ObjMap owns Objects, so every time this map gets copied instead of
referenced, it creates a copy of every single object in the
associated script. This is expensive, and it breaks things like
the `Object::syncBaseObject` call in savegame.cpp, which hasn't
actually been doing anything since
58190c36b4 because it has been
operating on copies.
2017-05-20 21:14:18 -05:00
Colin Snover 1911b19e15 SCI32: Make sure all save game validity checks are in kCheckSaveGame32
Save game metadata validity checks in SCI32 should all exist within
kCheckSaveGame32 since this allows most games to recover
successfully from an attempt to load an invalid save game. If
gamestate_restore fails, the game will usually crash because the
engine is left in an inconsistent state (game scripts have cleaned
up objects in preparation for a game load that is no longer
happening).
2017-05-13 22:46:25 -05:00
Colin Snover c9cbb8e31c SCI: Translate messages passed to dialogues 2017-05-08 11:26:46 -05:00
Colin Snover 00168003fe SCI: Clean up ugly syncBaseObject call 2017-04-30 13:44:34 -05:00
Colin Snover 94dc6ae052 SCI: Hold script data as mutable internally
Script buffer data is modified after a script is loaded by
savegame operations, and, in SCI16, by string operations. Casting
away const to allow these mutations to happen is not a very good
design, so this patch just changes the privately held reference
to data to be mutable. (Public accessors still return immutable
data.)
2017-04-30 12:47:32 -05:00
Colin Snover 6f95b1a440 SCI32: Fix missing mustSetViewVisible data in cloned objects
This information comes directly from script data and is not
modified at runtime, so it does not need to be persisted in save
games, but does need to be set when reconstructing clones.
2017-04-23 13:07:25 -05:00
Colin Snover f3db412d6f SCI32: Serialize Robots in SCI3
This is necessary for at least Lighthouse, which maintains the
state of Robots across save games.
2017-04-23 13:07:25 -05:00