aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kstring.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 2f8ea1f33c..de86b8472e 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -670,20 +670,35 @@ reg_t kMessage(EngineState *s, int argc, reg_t *argv) {
s->_msgState->lastQuery(module, msg);
- byte *buffer = s->_segMan->derefBulkPtr(argv[1], 10);
-
- if (buffer) {
- assert(s->_segMan->dereference(argv[1]).isRaw);
-
- WRITE_LE_UINT16(buffer, module);
- WRITE_LE_UINT16(buffer + 2, msg.noun);
- WRITE_LE_UINT16(buffer + 4, msg.verb);
- WRITE_LE_UINT16(buffer + 6, msg.cond);
- WRITE_LE_UINT16(buffer + 8, msg.seq);
+ bool ok = false;
+
+ if (s->_segMan->dereference(argv[1]).isRaw) {
+ byte *buffer = s->_segMan->derefBulkPtr(argv[1], 10);
+
+ if (buffer) {
+ ok = true;
+ WRITE_LE_UINT16(buffer, module);
+ WRITE_LE_UINT16(buffer + 2, msg.noun);
+ WRITE_LE_UINT16(buffer + 4, msg.verb);
+ WRITE_LE_UINT16(buffer + 6, msg.cond);
+ WRITE_LE_UINT16(buffer + 8, msg.seq);
+ }
} else {
- warning("Message: buffer %04x:%04x invalid or too small to hold the tuple", PRINT_REG(argv[1]));
+ reg_t *buffer = s->_segMan->derefRegPtr(argv[1], 5);
+
+ if (buffer) {
+ ok = true;
+ buffer[0] = make_reg(0, module);
+ buffer[1] = make_reg(0, msg.noun);
+ buffer[2] = make_reg(0, msg.verb);
+ buffer[3] = make_reg(0, msg.cond);
+ buffer[4] = make_reg(0, msg.seq);
+ }
}
+ if (!ok)
+ warning("Message: buffer %04x:%04x invalid or too small to hold the tuple", PRINT_REG(argv[1]));
+
return NULL_REG;
}
default: