Commit Graph
272 Commits
Author SHA1 Message Date
Le Philousophe 0b918a5352 SCI: Rename strcpy function to prepare for forbidden name
Even though strcpy in SegManager isn't a problem, our forbidden symbols
list being defined at preprocessor level, we won't be able to use this
name anymore.
2022-10-23 22:46:19 +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 f6dd4fa234 SCI: Add option to use KQ5 CD Windows cursors
Ticket #7800
2021-04-29 09:27:13 -07:00
Henrik "Henke37" Andersson 06cc82d493 SCI: Use getValOrDefault and tryGetVal 2021-02-12 00:41:23 +01:00
Filippos Karapetis d2f5023ee9 SCI: Do not apply script patches when checking for static selectors
Fixes bug #10969
2019-06-08 13:57:34 +03:00
Colin Snover 37459bc6c1 SCI: Fix UB in SegManager memcpy/strcpy operations
Passing overlapping buffers to C standard library memcpy, strcpy,
and strncpy is undefined behavior. In SSCI these operations would
perform a forward copy, and most stdlib implementations do the
same, but at least newer Linux glibc on x86 copies bytes in
reverse, so just using the standard library on this platform
results in broken output.

Because SSCI used a blind forward copy instead of memmove for
overlapping copy operations, this patch implements an explicit
forward copy to ensure that overlapping copies continue to operate
the same as in SSCI.

This fixes the Island of Dr. Brain v1.1 flamingo puzzle
(script 185, flamingos::init, localCall 4c3) on platforms that do
not perform forward copy in memcpy/strcpy/strncpy.

Thanks to @moralrecordings for research on this bug and an initial
patch using memmove.

Closes gh-1034.
2017-10-29 13:18:37 -05:00
Colin Snover ad05bfedd8 SCI: Expose API for retrieving multiple objects with the same name
This is needed by Phant2 guest additions to find the correct
slider for the music volume, since the sliders have no unique name.
2017-07-30 19:10:50 -05:00
Colin Snover ef69a59467 SCI: Stop leaking locals segments during script reuse
When a game deletes a script and then loads the same script again
before it has been fully deallocated,
SegManager::instantiateScript tries to reuse the same script
& locals segments, but it was failing to reuse the old locals
segment because Script::freeScript would unconditionally clear
the old locals SegmentId, which meant the old locals segment would
just leak.

This patch does not fix old save games which may contain orphaned
locals segments, but should prevent the problem from occurring
going forward. (It is possible to clean up these old save games,
but this is not a big leak so it doesn't seem worth the extra
effort to do so.)
2017-05-20 21:14:18 -05:00
Colin Snover 4917330038 SCI: Find and store the original static names of objects
See code comment in Object::init for more details.

Fixes Trac#9780.
2017-05-20 21:14:18 -05:00
Willem Jan Palenstijn 779b8336b1 SCI: Let getClassAddress fail gracefully with SCRIPT_GET_DONT_LOAD
This fixes a crash in the debugger when disassembling the class opcode
with a class from a script that hasn't yet been loaded.
2017-05-16 22:41:47 +02:00
Colin Snover ec12c5a342 SCI: Move ScummVM save/restore to GuestAdditions and reimplement for SCI32 2017-04-22 13:01:16 -05:00
Colin Snover 2d0c1c8ab5 SCI: Ensure object name reg_ts are valid before dereferencing them 2017-03-30 19:46:27 -05:00
Colin Snover 31daa956d6 SCI: Implement bounds-checked reads of game resources 2017-03-27 19:42:31 -05:00
Colin Snover 10d97ce379 SCI: Fix more unsafe C-string usage 2017-02-05 12:38:21 -06:00
Colin Snover b1c3332fdd SCI: Use strnlen instead of strlen to avoid buffer overflows 2017-02-05 10:24:02 -06:00
Colin Snover 8cce4f1b8c SCI32: Ignore attempts to free null array reg_ts 2017-01-09 19:34:54 -06:00
Colin Snover b011af9485 SCI: Remove unused second parameter to SegManager::getString 2016-12-18 19:02:41 -06:00
Colin Snover 12b2bc408f SCI: Remove unnecessary lock in SegManager 2016-12-03 12:21:55 -06:00
Colin Snover 40444b0aeb SCI32: Clarify some identifiers
transparentColor -> skipColor
displace -> origin
scaledWidth -> xResolution
scaledHeight -> yResolution
2016-10-09 11:21:46 -05:00
Colin Snover 3f91726765 SCI32: Rewrite kArray & kString
This change invalidates earlier SCI32 save games, which separated
arrays and strings in an incompatible manner. Old save games
contain invalid references to a string segment which no longer
exists, and contain incompatible array structures that lack
critical type information.
2016-09-29 19:39:16 -05:00
Colin Snover 741ac22e17 SCI: Fix pointer invalidation caused by array storage moves
When objects are added to a SegmentObjTable, it may cause the
internal storage for the table to expand and move to a new
region of memory. When this happens, all pointers to objects held
by a SegmentObjTable of the same type would be invalidated, due
to an implementation detail that should not be exposed. To prevent
this, objects are now allocated separately on the heap, so even if
the table's storage moves due to insertions, the objects owned by
the table will not, so references remain valid for the lifetime of
the object.
2016-08-13 15:41:31 -05:00
Colin Snover 6d1f8e8c87 SCI32: Fix invalid memory access after BitmapTable is extended
When new bitmaps are added and the underlying Common::Array needs
to move to expand, this invalidates all pointers to bitmaps, which
makes it basically impossible to use the bitmap segment since you
never know if a reference is going to be invalidated due to an
array move.

To solve this, BitmapTable is changed to hold pointers to
SciBitmaps that are allocated separately on the heap instead, so
when those bitmaps are looked up, the resulting pointers are valid
for the lifetime of the bitmap, instead of the lifetime of the
Common::Array used internally by BitmapTable.
2016-08-01 10:37:14 -05:00
Colin Snover 2071196f42 SCI32: Add bitmap segment and remove GC option from hunk segment 2016-08-01 10:37:14 -05:00
Colin Snover 4a637d65c3 SCI32: Enable optional explicit memory management of hunk entries
Bitmaps in ScrollWindow and Robot code are managed by the kernel
and not by game scripts, although they must be able to be
referenced through a reg_t. To prevent incorrect GC of bitmaps
that are in use but not referenced by any game script, explicit
memory management of hunk entries can be enabled.
2016-08-01 10:37:14 -05:00
Johannes Schickel 1c6112e121 SCI: Introduce accessors for SegmentObjTable entries.
This makes code not use _table directly whenever possible. An exception is the
save game code which is not easy to adapt due to design deficiencies.
2016-03-25 01:15:26 +01:00
Martin Kiewitz 2a883bdd42 SCI: Zero out dynamically allocated memory
Fixes Mixed Up Mother Goose SCI1.1 crash when saving
And could potentially fix all sorts of other issues
Original SCI only zeroed out heap on init.
2016-02-08 20:49:22 +01:00
Filippos Karapetis a5a531ec9f SCI: Use the actual segment in the segment manager for SCI3 games 2016-01-15 02:48:37 +02:00
Filippos Karapetis e13cc80348 SCI: Show the address segment when trying to free hunks from an invalid
address
2014-08-08 02:11:49 +03:00
Johannes Schickel 8fc7d60feb SCI: Make GPL headers consistent in themselves. 2014-02-18 02:39:37 +01:00
Martin Kiewitz 8bdffcb2fb SCI: script patcher is now a separate class 2013-12-04 20:42:16 +01:00
Filippos Karapetis cc34755986 SCI: Fix script bug #3615119 - "SCI: Crazy Nick Laura Bow - Uninitialized read error 2" 2013-10-30 09:42:56 +02:00
Filippos Karapetis 66fce6d156 SCI: Fix some non-initialized variables in SegManager - CID 1003116 2013-05-01 01:51:11 +03:00
Johannes Schickel 89abab97e3 JANITORIAL: Remove trailing whitespaces.
Powered by:
git ls-files "*.cpp" "*.h" "*.m" "*.mm" | xargs sed -i -e 's/[ \t]*$//'
2012-09-26 04:17:55 +02:00
Filippos Karapetis c80429008f SCI: Remove an unnecessary warning and related FIXME comments
It's perfectly normal behavior to have locals with a smaller segment ID
than the ID of their respective script, e.g. when scripts are
uninstantiated and then instantiated again
2012-07-03 03:34:30 +03:00
Filippos Karapetis f6e4312665 SCI: Add a hack for a bug in the script handling code
When resetting the segment manager, sometimes the locals block for a
script is placed in a segment smaller than the script itself. This
shouldn't be happening, but it isn't fatal, however it should be resolved
in a proper manner
2012-07-02 12:49:10 +03:00
Filippos Karapetis 2b50824133 SCI: Add setter/getter methods to reg_t's
No functionality change has been made with this commit. This avoids
setting and getting the reg_t members directly, and is the basis of any
future work on large SCI3 scripts (larger than 64KB)
2012-06-18 05:24:06 +03:00
Filippos Karapetis a0add53c60 SCI: Change getClassAddress() to only require the caller segment
The caller offset is never actually used inside the function
2012-06-15 22:32:17 +03:00
Filippos Karapetis 041b1447c0 SCI: Replace RAW_IS_OBJECT with a method 2012-06-15 22:32:15 +03:00
Filippos Karapetis 160732b2f7 Revert "SCI: Change Script::getObject() to accept a reg_t"
This reverts commit 577d7e41c9.
2012-06-15 22:32:14 +03:00
Filippos Karapetis 562a8a980c SCI: Further cleanup of the script code
Merge the init() and load() Script methods and reset the script when
necessary
2012-06-15 12:53:17 +03:00
Filippos Karapetis 577d7e41c9 SCI: Change Script::getObject() to accept a reg_t
This is needed for upcoming changes to the Script class
2012-06-15 12:24:14 +03:00
Tarek Soliman a4798602d7 JANITORIAL: Fix missing whitespace in pointer cast
find -name '*.h' -or -name '*.cpp' | xargs sed -r -i 's@\(([A-Za-z0-9]+)\*\)@(\1 *)@g'

This seems to have caught some params as well which is not undesirable IMO.
It also caught some strings containing this which is undesirable so I
excluded them manually. (engines/sci/engine/kernel_tables.h)
2012-02-15 10:07:10 -06:00
Willem Jan Palenstijn 71566a4307 SCI: Fix style 2011-11-11 00:16:57 +01:00
Willem Jan Palenstijn 8c57e4bf43 SCI: Fix const cast 2011-11-11 00:07:27 +01:00
Filippos Karapetis 5969c6bd2e SCI: Updated Script::getObjectMap()
It now returns a reference to the object list instead of copying it
2011-11-05 13:08:42 +02:00
Filippos Karapetis 58190c36b4 SCI: Made the object map hashmap of the Script class private 2011-11-05 10:07:03 +02:00
Filippos Karapetis 267c6f1756 SCI: Made more fields of the Script class private. Some cleanup. 2011-11-05 03:00:42 +02:00
Max Horn 529919e20b SCI: Remove dead code 2011-08-08 20:33:42 +02:00
Matthew Hoops 9539017ee3 ALL: initialise -> initialize 2011-05-25 11:17:11 -04:00