diff options
Diffstat (limited to 'engines/touche')
-rw-r--r-- | engines/touche/detection.cpp | 50 | ||||
-rw-r--r-- | engines/touche/menu.cpp | 2 | ||||
-rw-r--r-- | engines/touche/resource.cpp | 22 | ||||
-rw-r--r-- | engines/touche/touche.h | 2 |
4 files changed, 40 insertions, 36 deletions
diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp index b7f9c092aa..0684144473 100644 --- a/engines/touche/detection.cpp +++ b/engines/touche/detection.cpp @@ -24,6 +24,7 @@ #include "engines/advancedDetector.h" #include "common/savefile.h" #include "common/system.h" +#include "common/translation.h" #include "base/plugins.h" @@ -126,34 +127,31 @@ static const char *directoryGlobs[] = { 0 }; -static const ADParams detectionParams = { - // Pointer to ADGameDescription or its superset structure - (const byte *)Touche::gameDescriptions, - // Size of that superset structure - sizeof(ADGameDescription), - // Number of bytes to compute MD5 sum for - 4096, - // List of all engine targets - toucheGames, - // Structure for autoupgrading obsolete targets - 0, - // Name of single gameid (optional) - "touche", - // List of files for file-based fallback detection (optional) - Touche::fileBasedFallback, - // Flags - kADFlagPrintWarningOnFileBasedFallback, - // Additional GUI options (for every game} - Common::GUIO_NONE, - // Maximum directory depth - 2, - // List of directory globs - directoryGlobs -}; - class ToucheMetaEngine : public AdvancedMetaEngine { public: - ToucheMetaEngine() : AdvancedMetaEngine(detectionParams) {} + ToucheMetaEngine() : AdvancedMetaEngine(Touche::gameDescriptions, sizeof(ADGameDescription), toucheGames) { + _md5Bytes = 4096; + _singleid = "touche"; + _maxScanDepth = 2; + _directoryGlobs = directoryGlobs; + } + + virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { + const ADGameDescription *matchedDesc = detectGameFilebased(allFiles, Touche::fileBasedFallback); + + if (matchedDesc) { // We got a match + Common::String report = Common::String::format(_("Your game version has been detected using " + "filename matching as a variant of %s."), matchedDesc->gameid); + report += "\n"; + report += _("If this is an original and unmodified version, please report any"); + report += "\n"; + report += _("information previously printed by ScummVM to the team."); + report += "\n"; + g_system->logMessage(LogMessageType::kInfo, report.c_str()); + } + + return matchedDesc; + } virtual const char *getName() const { return "Touche"; diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp index f469a95803..c58e2f1a33 100644 --- a/engines/touche/menu.cpp +++ b/engines/touche/menu.cpp @@ -103,7 +103,7 @@ struct MenuData { void addCharToDescription(int slot, char chr) { char *description = saveLoadDescriptionsTable[slot]; int descriptionLen = strlen(description); - if (descriptionLen < 32 && isprint(chr)) { + if (descriptionLen < 32 && isprint(static_cast<unsigned char>(chr))) { description[descriptionLen] = chr; description[descriptionLen + 1] = 0; } diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp index 8f4752e912..6df6fc0e5f 100644 --- a/engines/touche/resource.cpp +++ b/engines/touche/resource.cpp @@ -468,14 +468,22 @@ void ToucheEngine::res_loadSprite(int num, int index) { if (size > spr->size) { debug(8, "Reallocating memory for sprite %d (index %d), %d bytes needed", num, index, size - spr->size); spr->size = size; - if (spr->ptr) { - spr->ptr = (uint8 *)realloc(spr->ptr, size); - } else { - spr->ptr = (uint8 *)malloc(size); - } - if (!spr->ptr) { - error("Unable to reallocate memory for sprite %d (%d bytes)", num, size); + + uint8 *buffer = NULL; + if (spr->ptr) + buffer = (uint8 *)realloc(spr->ptr, size); + + if (!buffer) { + // Free previously allocated sprite (when realloc failed) + free(spr->ptr); + + buffer = (uint8 *)malloc(size); } + + if (!buffer) + error("[ToucheEngine::res_loadSprite] Unable to reallocate memory for sprite %d (%d bytes)", num, size); + + spr->ptr = buffer; } for (int i = 0; i < _currentImageHeight; ++i) { res_decodeScanLineImageRLE(spr->ptr + _currentImageWidth * i, _currentImageWidth); diff --git a/engines/touche/touche.h b/engines/touche/touche.h index 7e1aa3ac44..cbb3fec7aa 100644 --- a/engines/touche/touche.h +++ b/engines/touche/touche.h @@ -385,8 +385,6 @@ public: protected: - bool detectGame(); - void restart(); void readConfigurationSettings(); void writeConfigurationSettings(); |