aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/object.cpp
AgeCommit message (Collapse)Author
2018-08-25SCI32: Remove reg32_t and use reg_t in all casesFilippos Karapetis
reg32_t was a transitive solution, before reg_t's were adapted to use 32-bit addresses internally, and before support for SCI3 was added. It was introduced as another way to handle large script offsets in SCI3, and was only used for the program counter (PC). It's no longer needed, as we now support SCI3 script offsets using reg_t's, so we can use make_reg32 in all cases where we need to access offsets over 64KB
2017-07-15SCI: Stop double-initialization of SCI0/1 objectsColin Snover
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-15SCI: Fix up Object::_baseMethod implementationColin Snover
1. In SCI0/1, selectors and offsets in the method block are stored contiguously (all selectors, then all offsets), with a null separator between the two runs. All the later versions of SCI instead interleave selectors & offsets. Since these values are already being copied into a new array anyway, code for reading method selectors/offsets is now simplified by interleaving this data when it is written into _baseMethod for SCI0/1, so the same equation for retrieving method selectors/offsets can be used across all SCI versions. 2. In SCI1.1-2.1 branch, the method count was being copied into the first entry of the array, which meant that SCI1.1-2.1 had extra code for dealing with the fact that the first entry was not an entry. This has been fixed, and the extra code removed. 3. Data was being overread into _baseMethod in all games SCI0-2.1. (SCI0/1 had an extra magic value of 2, and SCI1.1-2.1 had an extra magic value of 3). Reviewing history, it's not clear why this happened, other than that it appears to have been introduced at 7b0760f1bc5c28abcede041a6e3930f84ff3d319. My best guess is that this was a confusion between byte count and record count, where the intent was to read an extra 2 bytes for the null separator in SCI0/1, but it actually read 2 records instead. (I do not have a guess on why SCI1.1 ended up with a 3.) This overreading has been removed.
2017-05-25SCI32: Fix SCI3 object names > 0xFFFFColin Snover
2017-05-20SCI: Find and store the original static names of objectsColin Snover
See code comment in Object::init for more details. Fixes Trac#9780.
2017-05-20SCI: Refactor relocation codeColin Snover
This groundwork enables an object to look up its static name separately from the normal process that is used to populate Object::_variables when an object is first constructed. (The static name property needs to be able to be retrieved from objects inside of earlier save games whose name properties may have already been modified at runtime, so the code cannot simply pluck the value out of Object::_variables when they are first initialised and then persisted into the save game, as nice and easy as that would have been.) This commit also helps to clarify the situation with relocation tables in SCI1 games that start with a zero entry. Refs Trac#9780.
2017-05-20SCI32: Remove bad assertion in relocateSci3Colin Snover
While extremely rare (only Rama script 64948 seems to have this profile), it *is* possible for an object to have zero properties (and thus, zero property offsets).
2017-05-20SCI: Nitpicky cleanup of some magic numbers and what-not-why commentsColin Snover
2017-05-20SCI: Remove duplicate relocateBlock functionColin Snover
2017-04-24SCI: Use the var count from the instance's class in SCI1.1-2.1 when looking ↵Colin Snover
up selectors At least some versions of Island of Dr Brain have a bMessager instance in script 0 with a var count greater than that of its class. This probably should never happen since it means the object has a variable with no corresponding selector. The next commit adds some extra sanity checking code to object initialization, to warn on any other games where this happens.
2017-04-23SCI32: Exclude SCI3 code from compilation when SCI32 is disabledColin Snover
2017-04-23SCI32: Fix mustSetViewVisible for SCI3Colin Snover
In SCI2/2.1, variable indexes are used along with a range encoded in the interpreter executable to determine whether an object variable is a view-related variable. Operands to aTop, sTop, ipToa, dpToa, ipTos, and dpTos are byte offsets into an object, which are divided by two to get the varindex to check against the interpreter range. In SCI3, objects in game scripts contain groups of 32 selectors, and each group has a flag that says whether or not the selectors in that group are view-related. Operands to aTop, sTop, ipToa, dpToa, ipTos, and dpTos are selectors.
2017-04-23SCI32: Replace magic numbers in SCI3 selector initColin Snover
2017-04-23SCI: Deduplicate Object::locateVarSelector codeColin Snover
The variable count returned by Object::getVarCount is populated by variable 1 in SCI1.1, so specially reading the variable explicitly for that engine version is not necessary.
2017-04-23SCI: Fix support for 32-bit SCI3 script offsetsColin Snover
2017-04-23SCI32: Fix bad relocations of SCI3 objectsColin Snover
2017-04-23SCI: Convert Object to use Common::Array for SCI3Colin Snover
In SCI3, index-to-selector tables no longer exist in compiled object data (instead, the SCI3 VM uses selectors directly and object data contains a bit map of valid selectors). In ScummVM, the table is generated by Object::initSelectorsSci3 for compatibility with the design of the ScummVM SCI VM. For consistency, _baseVars is converted to use a standard container, which works for all SCI versions. The table for SCI3 property offsets is also changed to use a standard container instead of manually managing the memory with malloc/free.
2017-04-23SCI32: Hook up mustSetViewVisible for SCI3Colin Snover
2017-04-22SCI: Fix whitespace errorsColin Snover
2017-03-27SCI: Implement bounds-checked reads of game resourcesColin Snover
2016-03-01SCI: Remove superfluous cast to boolean and fix code stylingFilippos Karapetis
2016-02-29SCI3: Collect bits for managing kInfoFlagViewVisibleLars Skovlund
2015-12-29SCI32: split up SCI2.1 into EARLY/MIDDLE/LATEMartin Kiewitz
- Detection works via signatures (couldn't find a better way) - new kString subcalls were introduced SCI2.1 LATE - kString now has signatures and is split via subcall table - kString fix, so that KQ7 doesn't crash, when starting a chapter - Sci2StringFunctionType removed, because no longer needed
2014-02-18SCI: Make GPL headers consistent in themselves.Johannes Schickel
2013-12-14SCI: Make second pass when loading objectsWillem Jan Palenstijn
This is because objects may be loaded before their base objects, which causes initBaseObject to fail for SCI0. Script::initializeObjectsSci0 already did this, but SegManager::saveLoadWithSerializer did not when calling initBaseObject after loading a savegame.
2012-06-18SCI: Add setter/getter methods to reg_t'sFilippos Karapetis
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-15SCI: Change getClassAddress() to only require the caller segmentFilippos Karapetis
The caller offset is never actually used inside the function
2012-06-15SCI: _propertyOffsetsSci3 and classpos should be 32-bit integersFilippos Karapetis
These are needed for future handling of large SCI3 script files
2011-10-11SCI: Changed a warning about wrong object variable count into a debugCFilippos Karapetis
2011-06-20ALL: Remove trailing whitespacesMax Horn
This tries to make our code a bit more compliant with our code formatting conventions. For future use, this is the command I used: git ls-files "*.cpp" "*.h" | xargs sed -i -e 's/[ \t]*$//'
2011-05-25SCI: Constify Object::_baseVarsMax Horn
This may have to be undone if we ever want to start free'ing _baseVars again.
2011-05-12GIT: Clean up: Suppress SVN tags, now uselessstrangerke
2011-03-14SCI: Remove a space at the end of a warningMatthew Hoops
2011-03-14SCI: Add code to enumerate shadowed selectorsWillem Jan Palenstijn
If an object defines more variables than its base class, some method selectors may be hidden. This code tries to enumerate the affected selectors. It may be useful for mass-scanning objects using 'find_callk Dummy'. It's disabled by default currently since it does things to partially uninitialized objects that I can't guarantee are 100% safe at this point.
2011-03-13SCI: Add reference to related bug to commentWillem Jan Palenstijn
2011-03-11SCI: Clarify fix for KQ5 witch freeze bug #3034714Willem Jan Palenstijn
The cause for this bug turns out to be a corrupt object that as a side effect accidentally bypasses its own corruption. See the added comments for details. Also add a warning that points out similarly corrupted objects.
2011-01-26SCI: Make SCI3 propertyId endianness hack a bit cleanerWillem Jan Palenstijn
svn-id: r55542
2011-01-25SCI: cleanupMax Horn
svn-id: r55539
2011-01-25SCI3: Fix script abort during startup on Big Endian platformsLars Skovlund
svn-id: r55525
2010-12-23Fix code formattingLars Skovlund
svn-id: r55026
2010-12-23SCI: Unbreak script loading on big-endian machines. Thanks to [md5] and wjp.Lars Skovlund
svn-id: r55025
2010-12-21- SCI: Added code to free the _baseVars value in SCI3 as well. Both free() ↵Filippos Karapetis
operations have been commented out for now, as MSVC complains about heap corruption in SCI3 games - Code formatting fixes svn-id: r54991
2010-12-21Make Object::_baseMethod a Common::Array. This is intended to clean upLars Skovlund
the Object class, and it also plugs a leak. svn-id: r54986
2010-11-22SCI: Fixed bug #3044050 - "SQ4FLOPPY: Crash while flying in Skate-o-Rama"Filippos Karapetis
Fixed Object::locateVarSelector() for SCI0-SCI1 games, as it wasn't checking the class for object variables svn-id: r54415
2010-11-19SCI: Moved the Object class in a separate fileFilippos Karapetis
svn-id: r54361