diff options
author | Paul Gilbert | 2016-05-09 22:02:32 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:39:04 -0400 |
commit | 0f96471077d2c5a278fb1594e874e43029afff08 (patch) | |
tree | 29dfd407e5d5f75145067a0e12529df7449ebb08 /engines | |
parent | 5bb05084fda4e1ce63bd29815ed0676adb1645ed (diff) | |
download | scummvm-rg350-0f96471077d2c5a278fb1594e874e43029afff08.tar.gz scummvm-rg350-0f96471077d2c5a278fb1594e874e43029afff08.tar.bz2 scummvm-rg350-0f96471077d2c5a278fb1594e874e43029afff08.zip |
TITANIC: Add copy operators for TTString
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/true_talk/tt_string.cpp | 22 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_string.h | 3 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_word.cpp | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/engines/titanic/true_talk/tt_string.cpp b/engines/titanic/true_talk/tt_string.cpp index a41f0ced5f..189873daf0 100644 --- a/engines/titanic/true_talk/tt_string.cpp +++ b/engines/titanic/true_talk/tt_string.cpp @@ -53,6 +53,28 @@ TTString::~TTString() { delete _data; } +void TTString::operator=(const TTString &str) { + // Delete old string reference, if any + if (_data && --_data->_referenceCount == 0) + delete _data; + + // Copy source string data + _status = str._status; + _data = str._data; + if (_data) + _data->_referenceCount++; +} + +void TTString::operator=(const CString &str) { + // Delete old string reference, if any + if (_data && --_data->_referenceCount == 0) + delete _data; + + // Create new string data + _data = new TTStringData(str); + _status = SS_VALID; +} + bool TTString::isValid() const { return _status == SS_VALID; } diff --git a/engines/titanic/true_talk/tt_string.h b/engines/titanic/true_talk/tt_string.h index bc7278cce7..250f902068 100644 --- a/engines/titanic/true_talk/tt_string.h +++ b/engines/titanic/true_talk/tt_string.h @@ -49,6 +49,9 @@ public: TTString(TTString &str); virtual ~TTString(); + void operator=(const TTString &str); + void operator=(const CString &str); + /** * Returns true if the string is valid */ diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp index 3d0aae5f67..7d7cb2d0c2 100644 --- a/engines/titanic/true_talk/tt_word.cpp +++ b/engines/titanic/true_talk/tt_word.cpp @@ -39,7 +39,7 @@ int TTWord::load(SimpleFile *file, int mode) { int val; if (file->scanf("%d %s %s", &val, &str1, &str2)) { - _string = TTString(str1); + _string = str1; _field1C = val; _field20 = readNumber(str2.c_str()); _wordMode = mode; |