aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/kscripts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/engine/kscripts.cpp')
-rw-r--r--engines/sci/engine/kscripts.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index e7f466f9a2..4b7451d355 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -103,7 +103,7 @@ reg_t kLock(EngineState *s, int argc, reg_t *argv) {
g_sci->getResMan()->unlockResource(which);
else {
if (id.getType() == kResourceTypeInvalid)
- warning("[resMan] Attempt to unlock resource %i of invalid type %i", id.getNumber(), type);
+ warning("[resMan] Attempt to unlock resource %i of invalid type %i", id.getNumber(), argv[0].toUint16());
else
// Happens in CD games (e.g. LSL6CD) with the message
// resource. It isn't fatal, and it's usually caused
@@ -155,7 +155,7 @@ reg_t kClone(EngineState *s, int argc, reg_t *argv) {
debugC(2, kDebugLevelMemory, "Attempting to clone from %04x:%04x", PRINT_REG(parentAddr));
- uint16 infoSelector = readSelectorValue(s->_segMan, parentAddr, SELECTOR(_info_));
+ uint16 infoSelector = parentObj->getInfoSelector().offset;
cloneObj = s->_segMan->allocateClone(&cloneAddr);
if (!cloneObj) {
@@ -174,12 +174,12 @@ reg_t kClone(EngineState *s, int argc, reg_t *argv) {
// extend the internal storage size.
if (infoSelector & kInfoFlagClone)
parentObj = s->_segMan->getObject(parentAddr);
-
+
*cloneObj = *parentObj;
// Mark as clone
infoSelector &= ~kInfoFlagClass; // remove class bit
- writeSelectorValue(s->_segMan, cloneAddr, SELECTOR(_info_), infoSelector | kInfoFlagClone);
+ cloneObj->setInfoSelector(make_reg(0, infoSelector | kInfoFlagClone));
cloneObj->setSpeciesSelector(cloneObj->getPos());
if (parentObj->isClass())
@@ -206,7 +206,7 @@ reg_t kDisposeClone(EngineState *s, int argc, reg_t *argv) {
// At least kq4early relies on this behaviour. The scripts clone "Sound", then set bit 1 manually
// and call kDisposeClone later. In that case we may not free it, otherwise we will run into issues
// later, because kIsObject would then return false and Sound object wouldn't get checked.
- uint16 infoSelector = readSelectorValue(s->_segMan, obj, SELECTOR(_info_));
+ uint16 infoSelector = object->getInfoSelector().offset;
if ((infoSelector & 3) == kInfoFlagClone)
object->markAsFreed();
@@ -246,12 +246,24 @@ reg_t kScriptID(EngineState *s, int argc, reg_t *argv) {
return NULL_REG;
}
- uint16 address = scr->validateExportFunc(index);
+ uint16 address = scr->validateExportFunc(index, true);
- // Point to the heap for SCI1.1+ games
- if (getSciVersion() >= SCI_VERSION_1_1)
+ // Point to the heap for SCI1.1 - SCI2.1 games
+ if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1)
address += scr->getScriptSize();
+ // Bugfix for the intro speed in PQ2 version 1.002.011.
+ // This is taken from the patch by NewRisingSun(NRS) / Belzorash. Global 3
+ // is used for timing during the intro, and in the problematic version it's
+ // initialized to 0, whereas it's 6 in other versions. Thus, we assign it
+ // to 6 here, fixing the speed of the introduction. Refer to bug #3102071.
+ if (g_sci->getGameId() == GID_PQ2 && script == 200) {
+ if (s->variables[VAR_GLOBAL][3].isNull()) {
+ warning("Fixing speed in the intro of PQ2, version 1.002.011");
+ s->variables[VAR_GLOBAL][3] = make_reg(0, 6);
+ }
+ }
+
return make_reg(scriptSeg, address);
}