diff options
Diffstat (limited to 'engines/titanic/true_talk/tt_string.cpp')
-rw-r--r-- | engines/titanic/true_talk/tt_string.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/engines/titanic/true_talk/tt_string.cpp b/engines/titanic/true_talk/tt_string.cpp index df93a5669c..76c109284a 100644 --- a/engines/titanic/true_talk/tt_string.cpp +++ b/engines/titanic/true_talk/tt_string.cpp @@ -122,4 +122,21 @@ TTstring TTstring::tokenize(const char *delim) { } } +int TTstring::deletePrefix(int count) { + int strSize = size(); + if (count > strSize) + count = strSize; + + if (_data->_referenceCount == 1) { + // No other references to this string, so we can just directly modify it + _data->_string = CString(_data->_string.c_str() + count); + } else { + // Detach string from current shared data, and create a new one with the substring + _data->_referenceCount--; + _data = new TTstringData(_data->_string.c_str() + count); + } + + return 1; +} + } // End of namespace Titanic |