aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/klists.cpp12
-rw-r--r--engines/sci/engine/segment.h6
2 files changed, 9 insertions, 9 deletions
diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp
index 2f66e51a6e..2ca5a65fc0 100644
--- a/engines/sci/engine/klists.cpp
+++ b/engines/sci/engine/klists.cpp
@@ -859,19 +859,19 @@ reg_t kArrayFill(EngineState *s, int argc, reg_t *argv) {
reg_t kArrayCopy(EngineState *s, int argc, reg_t *argv) {
SciArray &target = *s->_segMan->lookupArray(argv[0]);
const uint16 targetIndex = argv[1].toUint16();
+ const uint16 sourceIndex = argv[3].toUint16();
+ const int16 count = argv[4].toSint16();
- SciArray source;
- // String copies may be made from static script data
if (!s->_segMan->isArray(argv[2])) {
+ // String copies may be made from static script data
+ SciArray source;
source.setType(kArrayTypeString);
source.fromString(s->_segMan->getString(argv[2]));
+ target.copy(source, sourceIndex, targetIndex, count);
} else {
- source = *s->_segMan->lookupArray(argv[2]);
+ target.copy(*s->_segMan->lookupArray(argv[2]), sourceIndex, targetIndex, count);
}
- const uint16 sourceIndex = argv[3].toUint16();
- const uint16 count = argv[4].toUint16();
- target.copy(source, sourceIndex, targetIndex, count);
return argv[0];
}
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h
index a0c9f7f0dd..2b2e9466a2 100644
--- a/engines/sci/engine/segment.h
+++ b/engines/sci/engine/segment.h
@@ -761,12 +761,12 @@ public:
* Copies values from the source array. Both arrays will be grown if needed
* to prevent out-of-bounds reads/writes.
*/
- void copy(SciArray &source, const uint16 sourceIndex, const uint16 targetIndex, uint16 count) {
- if (count == 65535 /* -1 */) {
+ void copy(SciArray &source, const uint16 sourceIndex, const uint16 targetIndex, int16 count) {
+ if (count == -1) {
count = source.size() - sourceIndex;
}
- if (!count) {
+ if (count < 1) {
return;
}