From 390b243ef2b8e21d429eada07a88adf3e6142a01 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 25 Feb 2019 09:21:56 +0100 Subject: BLADERUNNER: Avoid using global objects in subtitle code --- engines/bladerunner/subtitles.cpp | 17 ++++++++--------- engines/bladerunner/subtitles.h | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/bladerunner/subtitles.cpp b/engines/bladerunner/subtitles.cpp index 8edf27cec2..1ef22cb759 100644 --- a/engines/bladerunner/subtitles.cpp +++ b/engines/bladerunner/subtitles.cpp @@ -55,14 +55,14 @@ namespace BladeRunner { * DONE - OK - CHECK what happens in VQA when no corresponding TRE subs file? */ -const Common::String Subtitles::SUBTITLES_FONT_FILENAME_EXTERNAL = "SUBTLS_E.FON"; +const char *Subtitles::SUBTITLES_FONT_FILENAME_EXTERNAL = "SUBTLS_E.FON"; /* * All entries need to have the language code appended (after a '_'). * And all entries should get the suffix extension ".TRx"; the last letter in extension "TR*" should also be the language code * If/When adding new Text Resources here --> Update kMaxTextResourceEntries and also update method getIdxForSubsTreName() */ -const Common::String Subtitles::SUBTITLES_FILENAME_PREFIXES[kMaxTextResourceEntries] = { +const char *Subtitles::SUBTITLES_FILENAME_PREFIXES[kMaxTextResourceEntries] = { "INGQUO", // 0 // (in-game subtitles, not VQA subtitles) "WSTLGO", // 1 // all game (language) versions have the English ('E') version of WSTLGO "BRLOGO", // 2 // all game (language) versions have the English ('E') version of BRLOGO @@ -137,11 +137,11 @@ void Subtitles::init(void) { for (int i = 0; i < kMaxTextResourceEntries; i++) { _vqaSubsTextResourceEntries[i] = new TextResource(_vm); Common::String tmpConstructedFileName = ""; - if (SUBTITLES_FILENAME_PREFIXES[i] == "WSTLGO" || SUBTITLES_FILENAME_PREFIXES[i] == "BRLOGO") { - tmpConstructedFileName = SUBTITLES_FILENAME_PREFIXES[i] + "_E"; // Only English versions of these exist + if (!strcmp(SUBTITLES_FILENAME_PREFIXES[i], "WSTLGO") || !strcmp(SUBTITLES_FILENAME_PREFIXES[i], "BRLOGO")) { + tmpConstructedFileName = Common::String(SUBTITLES_FILENAME_PREFIXES[i]) + "_E"; // Only English versions of these exist } else { - tmpConstructedFileName = SUBTITLES_FILENAME_PREFIXES[i] + "_" + _vm->_languageCode; + tmpConstructedFileName = Common::String(SUBTITLES_FILENAME_PREFIXES[i]) + "_" + _vm->_languageCode; } if ( _vqaSubsTextResourceEntries[i]->open(tmpConstructedFileName)) { @@ -184,11 +184,11 @@ void Subtitles::setSubtitlesSystemInactive(bool flag) { int Subtitles::getIdxForSubsTreName(const Common::String &treName) const { Common::String tmpConstructedFileName = ""; for (int i = 0; i < kMaxTextResourceEntries; ++i) { - if (SUBTITLES_FILENAME_PREFIXES[i] == "WSTLGO" || SUBTITLES_FILENAME_PREFIXES[i] == "BRLOGO") { - tmpConstructedFileName = SUBTITLES_FILENAME_PREFIXES[i] + "_E"; // Only English versions of these exist + if (!strcmp(SUBTITLES_FILENAME_PREFIXES[i], "WSTLGO") || !strcmp(SUBTITLES_FILENAME_PREFIXES[i], "BRLOGO")) { + tmpConstructedFileName = Common::String(SUBTITLES_FILENAME_PREFIXES[i]) + "_E"; // Only English versions of these exist } else { - tmpConstructedFileName = SUBTITLES_FILENAME_PREFIXES[i] + "_" + _vm->_languageCode; + tmpConstructedFileName = Common::String(SUBTITLES_FILENAME_PREFIXES[i]) + "_" + _vm->_languageCode; } if (tmpConstructedFileName == treName) { return i; @@ -546,4 +546,3 @@ void Subtitles::reset() { } } // End of namespace BladeRunner - diff --git a/engines/bladerunner/subtitles.h b/engines/bladerunner/subtitles.h index 5daf5706d3..208a8f39e2 100644 --- a/engines/bladerunner/subtitles.h +++ b/engines/bladerunner/subtitles.h @@ -49,8 +49,8 @@ class Subtitles { static const int kMaxNumOfSubtitlesLines = 3; static const int kMaxWidthPerLineToAutoSplitThresholdPx = 610; static const int kMaxTextResourceEntries = 1 + 25; // Support in-game subs (1) and all possible VQAs (25) with spoken dialogue or translatable text! - static const Common::String SUBTITLES_FILENAME_PREFIXES[kMaxTextResourceEntries]; - static const Common::String SUBTITLES_FONT_FILENAME_EXTERNAL; + static const char *SUBTITLES_FILENAME_PREFIXES[kMaxTextResourceEntries]; + static const char *SUBTITLES_FONT_FILENAME_EXTERNAL; BladeRunnerEngine *_vm; -- cgit v1.2.3