diff options
author | Colin Snover | 2017-09-08 20:54:48 -0500 |
---|---|---|
committer | Colin Snover | 2017-09-08 21:10:51 -0500 |
commit | 7eedfdbeaf2d1349a368ea308219f0f185322c0d (patch) | |
tree | 63d95e284e2f94ff302683ea9c3e0343d04849a4 /engines/sci/engine/kstring.cpp | |
parent | 5228aa29fa632249c835f98fbc4cfc01fa5f222b (diff) | |
download | scummvm-rg350-7eedfdbeaf2d1349a368ea308219f0f185322c0d.tar.gz scummvm-rg350-7eedfdbeaf2d1349a368ea308219f0f185322c0d.tar.bz2 scummvm-rg350-7eedfdbeaf2d1349a368ea308219f0f185322c0d.zip |
SCI32: Fix kString signatures to allow null references where appropriate
The original interpreter allowed most string references to be
null references, in which case it would substitute an empty
string.
Diffstat (limited to 'engines/sci/engine/kstring.cpp')
-rw-r--r-- | engines/sci/engine/kstring.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index 3c6a0424f8..5bab422425 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -803,26 +803,30 @@ Common::String format(const Common::String &source, int argc, const reg_t *argv) } reg_t kStringFormat(EngineState *s, int argc, reg_t *argv) { - reg_t stringHandle; - SciArray &target = *s->_segMan->allocateArray(kArrayTypeString, 0, &stringHandle); - reg_t source = argv[0]; - // Str objects may be passed in place of direct references to string data - if (s->_segMan->isObject(argv[0])) { - source = readSelector(s->_segMan, argv[0], SELECTOR(data)); - } - target.fromString(format(s->_segMan->getString(source), argc - 1, argv + 1)); - return stringHandle; + Common::Array<reg_t> args; + args.resize(argc + 1); + args[0] = NULL_REG; + Common::copy(argv, argv + argc, &args[1]); + return kStringFormatAt(s, args.size(), &args[0]); } reg_t kStringFormatAt(EngineState *s, int argc, reg_t *argv) { - SciArray &target = *s->_segMan->lookupArray(argv[0]); + reg_t stringHandle; + SciArray *target; + if (argv[0].isNull()) { + target = s->_segMan->allocateArray(kArrayTypeString, 0, &stringHandle); + } else { + target = s->_segMan->lookupArray(argv[0]); + stringHandle = argv[0]; + } + reg_t source = argv[1]; // Str objects may be passed in place of direct references to string data if (s->_segMan->isObject(argv[1])) { source = readSelector(s->_segMan, argv[1], SELECTOR(data)); } - target.fromString(format(s->_segMan->getString(source), argc - 2, argv + 2)); - return argv[0]; + target->fromString(format(s->_segMan->getString(source), argc - 2, argv + 2)); + return stringHandle; } reg_t kStringToInteger(EngineState *s, int argc, reg_t *argv) { |