[Scummvm-git-logs] scummvm master -> 6ec64ff3793bfced04491a83878cfc5ebf145004
bluegr
noreply at scummvm.org
Tue Dec 10 23:05:00 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0128e09639 SCI: Move the language detection fallback code into a separate function
6ec64ff379 PLUGINS: Initialize the _currentPlugin var in PluginManagerUncached
Commit: 0128e096392c324af18c9e437a2261d121c203ab
https://github.com/scummvm/scummvm/commit/0128e096392c324af18c9e437a2261d121c203ab
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2024-12-11T01:03:42+02:00
Commit Message:
SCI: Move the language detection fallback code into a separate function
Changed paths:
engines/sci/metaengine.cpp
diff --git a/engines/sci/metaengine.cpp b/engines/sci/metaengine.cpp
index 517d694d8ba..ea232151792 100644
--- a/engines/sci/metaengine.cpp
+++ b/engines/sci/metaengine.cpp
@@ -505,6 +505,67 @@ bool isSciCDVersion(const AdvancedMetaEngineBase::FileMap &allFiles) {
return false;
}
+Common::Language determineGameLanguage(ResourceManager &resMan, const SciMetaEngine::FileMap &allFiles) {
+ Common::Language language = Common::EN_ANY;
+
+ // Try to determine the game language
+ // Load up text 0 and start looking for "#" characters
+ // Non-English versions contain strings like XXXX#YZZZZ
+ // Where XXXX is the English string, #Y a separator indicating the language
+ // (e.g. #G for German) and ZZZZ is the translated text
+ // NOTE: This doesn't work for games which use message instead of text resources
+ // (like, for example, Eco Quest 1 and all SCI1.1 games and newer, e.g. Freddy Pharkas).
+ // As far as we know, these games store the messages of each language in separate
+ // resources, and it's not possible to detect that easily
+ // Also look for "%J" which is used in japanese games
+ Resource *text = resMan.findResource(ResourceId(kResourceTypeText, 0), false);
+ if (text) {
+ uint seeker = 0;
+ while (seeker < text->size()) {
+ if (text->getUint8At(seeker) == '#') {
+ if (seeker + 1 < text->size())
+ language = charToScummVMLanguage(text->getUint8At(seeker + 1));
+ break;
+ }
+ if (text->getUint8At(seeker) == '%') {
+ if ((seeker + 1 < text->size()) && (text->getUint8At(seeker + 1) == 'J')) {
+ language = charToScummVMLanguage(text->getUint8At(seeker + 1));
+ break;
+ }
+ }
+ seeker++;
+ }
+ }
+
+ // Try to determine the game language from config file (SCI1.1 and later)
+ const char *configNames[] = {"resource.cfg", "resource.win"};
+ for (int i = 0; i < ARRAYSIZE(configNames) && language == Common::EN_ANY; i++) {
+ Common::File file;
+ if (allFiles.contains(configNames[i]) && file.open(allFiles[configNames[i]])) {
+ while (!file.eos()) {
+ Common::String line = file.readLine();
+ uint32 separatorPos = line.find('=');
+ if (separatorPos == Common::String::npos) {
+ continue;
+ }
+ Common::String key = line.substr(0, separatorPos);
+ key.trim();
+ if (key.equalsIgnoreCase("language")) {
+ Common::String val = line.substr(separatorPos + 1);
+ val.trim();
+ Common::Language parsedLanguage = sciToScummVMLanguage(atoi(val.c_str()));
+ if (parsedLanguage != Common::UNK_LANG) {
+ language = parsedLanguage;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ return language;
+}
+
void constructFallbackDetectionEntry(const Common::String &gameId, Common::Platform platform, SciVersion sciVersion, Common::Language language, bool hasEgaViews, bool isCD, bool isDemo) {
Common::strlcpy(s_fallbackGameIdBuf, gameId.c_str(), sizeof(s_fallbackGameIdBuf));
@@ -600,62 +661,7 @@ ADDetectedGame SciMetaEngine::fallbackDetectExtern(uint md5Bytes, const FileMap
bool isDemo = false;
Common::String gameId = convertSierraGameId(sierraGameId, sciVersion, resMan, &isDemo);
- Common::Language language = Common::EN_ANY;
-
- // Try to determine the game language
- // Load up text 0 and start looking for "#" characters
- // Non-English versions contain strings like XXXX#YZZZZ
- // Where XXXX is the English string, #Y a separator indicating the language
- // (e.g. #G for German) and ZZZZ is the translated text
- // NOTE: This doesn't work for games which use message instead of text resources
- // (like, for example, Eco Quest 1 and all SCI1.1 games and newer, e.g. Freddy Pharkas).
- // As far as we know, these games store the messages of each language in separate
- // resources, and it's not possible to detect that easily
- // Also look for "%J" which is used in japanese games
- Resource *text = resMan.findResource(ResourceId(kResourceTypeText, 0), false);
- if (text) {
- uint seeker = 0;
- while (seeker < text->size()) {
- if (text->getUint8At(seeker) == '#') {
- if (seeker + 1 < text->size())
- language = charToScummVMLanguage(text->getUint8At(seeker + 1));
- break;
- }
- if (text->getUint8At(seeker) == '%') {
- if ((seeker + 1 < text->size()) && (text->getUint8At(seeker + 1) == 'J')) {
- language = charToScummVMLanguage(text->getUint8At(seeker + 1));
- break;
- }
- }
- seeker++;
- }
- }
-
- // Try to determine the game language from config file (SCI1.1 and later)
- const char *configNames[] = { "resource.cfg", "resource.win" };
- for (int i = 0; i < ARRAYSIZE(configNames) && language == Common::EN_ANY; i++) {
- Common::File file;
- if (allFiles.contains(configNames[i]) && file.open(allFiles[configNames[i]])) {
- while (!file.eos()) {
- Common::String line = file.readLine();
- uint32 separatorPos = line.find('=');
- if (separatorPos == Common::String::npos) {
- continue;
- }
- Common::String key = line.substr(0, separatorPos);
- key.trim();
- if (key.equalsIgnoreCase("language")) {
- Common::String val = line.substr(separatorPos + 1);
- val.trim();
- Common::Language parsedLanguage = sciToScummVMLanguage(atoi(val.c_str()));
- if (parsedLanguage != Common::UNK_LANG) {
- language = parsedLanguage;
- }
- break;
- }
- }
- }
- }
+ Common::Language language = determineGameLanguage(resMan, allFiles);
constructFallbackDetectionEntry(gameId, platform, sciVersion, language, gameViews == kViewEga, isCD, isDemo);
Commit: 6ec64ff3793bfced04491a83878cfc5ebf145004
https://github.com/scummvm/scummvm/commit/6ec64ff3793bfced04491a83878cfc5ebf145004
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2024-12-11T01:03:43+02:00
Commit Message:
PLUGINS: Initialize the _currentPlugin var in PluginManagerUncached
Changed paths:
base/plugins.h
diff --git a/base/plugins.h b/base/plugins.h
index 8a432ecd74f..15b7bdd7f1e 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -48,7 +48,7 @@ enum PluginType {
};
// TODO: Make the engine API version depend on ScummVM's version
-// because of the backlinking (posibly from the checkout revision)
+// because of the back linking (possibly from the checkout revision)
#define PLUGIN_TYPE_ENGINE_DETECTION_VERSION 1
#define PLUGIN_TYPE_ENGINE_VERSION 2
#define PLUGIN_TYPE_MUSIC_VERSION 1
@@ -346,7 +346,7 @@ protected:
bool _isDetectionLoaded;
- PluginManagerUncached() : _isDetectionLoaded(false), _detectionPlugin(nullptr) {}
+ PluginManagerUncached() : _detectionPlugin(nullptr), _currentPlugin(nullptr), _isDetectionLoaded(false) {}
bool loadPluginByFileName(const Common::Path &filename);
public:
More information about the Scummvm-git-logs
mailing list