@@ -1045,7 +1045,7 @@ Runtime::Runtime(OSystem *system, Audio::Mixer *mixer, const Common::FSNode &roo
1045
1045
_panoramaState(kPanoramaStateInactive ),
1046
1046
_listenerX(0 ), _listenerY(0 ), _listenerAngle(0 ), _soundCacheIndex(0 ),
1047
1047
_isInGame(false ),
1048
- _subtitleFont(nullptr ), _isDisplayingSubtitles(false ), _isSubtitleSourceAnimation(false ), _languageIndex(0 ), _defaultLanguage(defaultLanguage),
1048
+ _subtitleFont(nullptr ), _isDisplayingSubtitles(false ), _isSubtitleSourceAnimation(false ), _languageIndex(0 ), _defaultLanguageIndex( 0 ), _defaultLanguage(defaultLanguage),
1049
1049
_isCDVariant(false ) {
1050
1050
1051
1051
for (uint i = 0 ; i < kNumDirections ; i++) {
@@ -1294,6 +1294,7 @@ bool Runtime::bootGame(bool newGame) {
1294
1294
Common::Language lang = Common::parseLanguage (ConfMan.get (" language" ));
1295
1295
1296
1296
_languageIndex = 1 ;
1297
+ _defaultLanguageIndex = 1 ;
1297
1298
1298
1299
if (_gameID == GID_REAH) {
1299
1300
_animSpeedRotation = Fraction (21 , 1 ); // Probably accurate
@@ -1312,6 +1313,11 @@ bool Runtime::bootGame(bool newGame) {
1312
1313
1313
1314
uint langCount = sizeof (langIndexes) / sizeof (langIndexes[0 ]);
1314
1315
1316
+ for (uint li = 0 ; li < langCount; li++) {
1317
+ if (langIndexes[li] == _defaultLanguage)
1318
+ _defaultLanguageIndex = li;
1319
+ }
1320
+
1315
1321
for (uint li = 0 ; li < langCount; li++) {
1316
1322
if (langIndexes[li] == lang) {
1317
1323
_languageIndex = li;
@@ -1336,10 +1342,23 @@ bool Runtime::bootGame(bool newGame) {
1336
1342
Common::RU_RUS,
1337
1343
Common::EL_GRC,
1338
1344
Common::EN_USA,
1345
+
1346
+ // Additional subs present in Steam release
1347
+ Common::BG_BUL,
1348
+ Common::ZH_TWN,
1349
+ Common::JA_JPN,
1350
+ Common::HU_HUN,
1351
+ Common::ZH_CHN,
1352
+ Common::CS_CZE,
1339
1353
};
1340
1354
1341
1355
uint langCount = sizeof (langIndexes) / sizeof (langIndexes[0 ]);
1342
1356
1357
+ for (uint li = 0 ; li < langCount; li++) {
1358
+ if (langIndexes[li] == _defaultLanguage)
1359
+ _defaultLanguageIndex = li;
1360
+ }
1361
+
1343
1362
for (uint li = 0 ; li < langCount; li++) {
1344
1363
if (langIndexes[li] == lang) {
1345
1364
_languageIndex = li;
@@ -1350,19 +1369,23 @@ bool Runtime::bootGame(bool newGame) {
1350
1369
}
1351
1370
}
1352
1371
1353
- Common::CodePage codePage = Common::CodePage:: kWindows1252 ;
1372
+ Common::CodePage codePage = resolveCodePageForLanguage (lang) ;
1354
1373
1355
- if (lang == Common::PL_POL)
1356
- codePage = Common::CodePage::kWindows1250 ;
1357
- else if (lang == Common::RU_RUS)
1358
- codePage = Common::CodePage::kWindows1251 ;
1359
- else if (lang == Common::EL_GRC)
1360
- codePage = Common::CodePage::kWindows1253 ;
1374
+ bool subtitlesLoadedOK = loadSubtitles (codePage);
1361
1375
1362
- if (loadSubtitles (codePage)) {
1363
- debug (1 , " Subtitles loaded OK" );
1376
+ if (!loadSubtitles (codePage)) {
1377
+ lang = _defaultLanguage;
1378
+ _languageIndex = _defaultLanguageIndex;
1379
+
1380
+ warning (" Localization data failed to load, retrying with default language" );
1381
+
1382
+ codePage = resolveCodePageForLanguage (lang);
1383
+ subtitlesLoadedOK = loadSubtitles (codePage);
1364
1384
}
1365
1385
1386
+ if (subtitlesLoadedOK)
1387
+ debug (1 , " Subtitles loaded OK" );
1388
+
1366
1389
_uiGraphics.resize (24 );
1367
1390
for (uint i = 0 ; i < _uiGraphics.size (); i++) {
1368
1391
if (_gameID == GID_REAH) {
@@ -1388,6 +1411,27 @@ bool Runtime::bootGame(bool newGame) {
1388
1411
return true ;
1389
1412
}
1390
1413
1414
+ Common::CodePage Runtime::resolveCodePageForLanguage (Common::Language lang) {
1415
+ switch (lang) {
1416
+ case Common::PL_POL:
1417
+ case Common::CS_CZE:
1418
+ return Common::CodePage::kWindows1250 ;
1419
+ case Common::RU_RUS:
1420
+ case Common::BG_BUL:
1421
+ return Common::CodePage::kWindows1251 ;
1422
+ case Common::EL_GRC:
1423
+ return Common::CodePage::kWindows1253 ;
1424
+ case Common::ZH_TWN:
1425
+ return Common::CodePage::kBig5 ;
1426
+ case Common::JA_JPN:
1427
+ return Common::CodePage::kWindows932 ; // Uses Shift-JIS, which Windows 932 is an extension of
1428
+ case Common::ZH_CHN:
1429
+ return Common::CodePage::kGBK ;
1430
+ default :
1431
+ return Common::CodePage::kWindows1252 ;
1432
+ }
1433
+ }
1434
+
1391
1435
void Runtime::drawLabel (Graphics::ManagedSurface *surface, const Common::String &labelID, const Common::Rect &contentRect) {
1392
1436
Common::HashMap<Common::String, UILabelDef>::const_iterator labelDefIt = _locUILabels.find (labelID);
1393
1437
if (labelDefIt == _locUILabels.end ())
0 commit comments