aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute
diff options
context:
space:
mode:
authorTobia Tesan2014-10-15 20:51:55 +0200
committerTobia Tesan2014-10-15 21:36:45 +0200
commita78a4d40dd1be6649f83a9411311d9210f1ddeea (patch)
treefeaa57b6d3af56fba23d49caecb8d0ac34da672a /engines/wintermute
parent8decf3d7424c8cb8eeae99d0aede78c445f18e9f (diff)
downloadscummvm-rg350-a78a4d40dd1be6649f83a9411311d9210f1ddeea.tar.gz
scummvm-rg350-a78a4d40dd1be6649f83a9411311d9210f1ddeea.tar.bz2
scummvm-rg350-a78a4d40dd1be6649f83a9411311d9210f1ddeea.zip
WINTERMUTE: Use Common::String in place of char *text in loadSubtitles
Diffstat (limited to 'engines/wintermute')
-rw-r--r--engines/wintermute/video/video_subtitle.cpp9
-rw-r--r--engines/wintermute/video/video_subtitle.h2
-rw-r--r--engines/wintermute/video/video_subtitler.cpp27
-rw-r--r--engines/wintermute/video/video_subtitler.h2
-rw-r--r--engines/wintermute/video/video_theora_player.cpp2
5 files changed, 19 insertions, 23 deletions
diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp
index 21fb5ec105..c9892b59a4 100644
--- a/engines/wintermute/video/video_subtitle.cpp
+++ b/engines/wintermute/video/video_subtitle.cpp
@@ -34,9 +34,12 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) {
_startFrame = _endFrame = 0;
}
-VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame): BaseClass(inGame) {
- _gameRef->expandStringByStringTable(&text);
- _text = Common::String(text);
+VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const long &startFrame, const long &endFrame): BaseClass(inGame) {
+ // TODO: Fix expandStringByStringTable instead of this ugly hack
+ char *tmp = new char[text.size()];
+ strcpy(tmp, text.c_str());
+ _gameRef->expandStringByStringTable(&tmp);
+ _text = Common::String(tmp);
_startFrame = startFrame;
_endFrame = endFrame;
}
diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h
index 3af0d06fa5..03d4b6bc05 100644
--- a/engines/wintermute/video/video_subtitle.h
+++ b/engines/wintermute/video/video_subtitle.h
@@ -36,7 +36,7 @@ namespace Wintermute {
class VideoSubtitle : public BaseClass {
public:
VideoSubtitle(BaseGame *inGame);
- VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame);
+ VideoSubtitle(BaseGame *inGame, const Common::String &text, const long &startFrame, const long &endFrame);
long getEndFrame();
long getStartFrame();
Common::String getText();
diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp
index b85e179b7c..f1becb00b3 100644
--- a/engines/wintermute/video/video_subtitler.cpp
+++ b/engines/wintermute/video/video_subtitler.cpp
@@ -49,8 +49,8 @@ VideoSubtitler::~VideoSubtitler(void) {
_subtitles.clear();
}
-bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFile) {
- if (!filename) {
+bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common::String &subtitleFile) {
+ if (filename.size() == 0) {
return false;
}
@@ -67,7 +67,7 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
Common::String newFile;
- if (subtitleFile) {
+ if (subtitleFile.size() != 0) {
newFile = Common::String(subtitleFile);
} else {
Common::String path = PathUtil::getDirectoryName(filename);
@@ -93,7 +93,6 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
char *tokenStart;
int tokenLength;
int tokenPos;
- int textLength;
int pos = 0;
int lineLength = 0;
@@ -102,7 +101,6 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
start = end = -1;
inToken = false;
tokenPos = -1;
- textLength = 0;
lineLength = 0;
@@ -120,7 +118,7 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
realLength = lineLength - 1;
}
- char *text = new char[realLength + 1];
+ Common::String text;
char *line = (char *)&buffer[pos];
for (int i = 0; i < realLength; i++) {
@@ -146,30 +144,25 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil
}
delete[] token;
} else {
- text[textLength] = line[i];
- textLength++;
+ text += line[i];
}
} else {
if (inToken) {
tokenLength++;
} else {
- text[textLength] = line[i];
- if (text[textLength] == '|') {
- text[textLength] = '\n';
+ if (line[i] == '|') {
+ text += '\n';
+ } else {
+ text += line[i];
}
- textLength++;
}
}
}
- text[textLength] = '\0';
-
- if (start != -1 && textLength > 0 && (start != 1 || end != 1)) {
+ if (start != -1 && text.size() > 0 && (start != 1 || end != 1)) {
_subtitles.push_back(new VideoSubtitle(_gameRef, text, start, end));
}
- delete [] text;
-
pos += lineLength + 1;
}
diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h
index 977fc10066..38fdf89508 100644
--- a/engines/wintermute/video/video_subtitler.h
+++ b/engines/wintermute/video/video_subtitler.h
@@ -42,7 +42,7 @@ public:
bool _showSubtitle;
uint _currentSubtitle;
- bool loadSubtitles(const char *filename, const char *subtitleFile);
+ bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile);
bool display();
bool update(long frame);
long _lastSample;
diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp
index 2af3ac1638..36d012ccb7 100644
--- a/engines/wintermute/video/video_theora_player.cpp
+++ b/engines/wintermute/video/video_theora_player.cpp
@@ -135,7 +135,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common:
#endif
- if (_subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str())) {
+ if (_subtitler->loadSubtitles(_filename, subtitleFile)) {
// We have subtitles
_subtitles = true;
} else {