aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2012-01-15 21:05:10 +0200
committerFilippos Karapetis2012-01-15 21:05:10 +0200
commitcbe75278050eea9226be4a3286e101f04a8c87b9 (patch)
treebcc1b16675944d6fa0617fc382b2c41129e19d58 /engines/sci/engine
parentaff92ea4cd0db8c9beacebe60c9a7c598b1eb01d (diff)
downloadscummvm-rg350-cbe75278050eea9226be4a3286e101f04a8c87b9.tar.gz
scummvm-rg350-cbe75278050eea9226be4a3286e101f04a8c87b9.tar.bz2
scummvm-rg350-cbe75278050eea9226be4a3286e101f04a8c87b9.zip
SCI: Use fromString() in kString(Dup) to simplify code
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/kstring.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 0f79c3592c..03359b48c1 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -745,30 +745,24 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) {
return make_reg(0, strcmp(string1.c_str(), string2.c_str()));
}
case 8: { // Dup
- const char *rawString = 0;
- uint32 size = 0;
reg_t stringHandle;
- SciString *sciString;
- Common::String commonString;
// We allocate the new string first because if the StringTable needs to
// grow, our rawString pointer will be invalidated
SciString *dupString = s->_segMan->allocateString(&stringHandle);
if (argv[1].segment == s->_segMan->getStringSegmentId()) {
- sciString = s->_segMan->lookupString(argv[1]);
- rawString = sciString->getRawData();
- size = sciString->getSize();
- } else {
- commonString = s->_segMan->getString(argv[1]);
- rawString = commonString.c_str();
- size = commonString.size() + 1;
- }
+ SciString *sciString = s->_segMan->lookupString(argv[1]);
+ const char *rawString = sciString->getRawData();
+ uint32 size = sciString->getSize();
- dupString->setSize(size);
+ dupString->setSize(sciString->getSize());
- for (uint32 i = 0; i < size; i++)
- dupString->setValue(i, rawString[i]);
+ for (uint32 i = 0; i < size; i++)
+ dupString->setValue(i, rawString[i]);
+ } else {
+ dupString->fromString(s->_segMan->getString(argv[1]));
+ }
return stringHandle;
}